View Javadoc

1   package org.apache.directmemory.memory;
2   
3   import java.util.Arrays;
4   import java.util.Collection;
5   
6   import org.junit.runner.RunWith;
7   import org.junit.runners.Parameterized;
8   import org.junit.runners.Parameterized.Parameters;
9   
10  /*
11   * Licensed to the Apache Software Foundation (ASF) under one
12   * or more contributor license agreements.  See the NOTICE file
13   * distributed with this work for additional information
14   * regarding copyright ownership.  The ASF licenses this file
15   * to you under the Apache License, Version 2.0 (the
16   * "License"); you may not use this file except in compliance
17   * with the License.  You may obtain a copy of the License at
18   *
19   *   http://www.apache.org/licenses/LICENSE-2.0
20   *
21   * Unless required by applicable law or agreed to in writing,
22   * software distributed under the License is distributed on an
23   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24   * KIND, either express or implied.  See the License for the
25   * specific language governing permissions and limitations
26   * under the License.
27   */
28  
29  @RunWith( Parameterized.class )
30  public class DefaultMemoryManagerServiceTest
31      extends AbstractMemoryManagerServiceTest
32  {
33  
34      @Parameters
35      public static Collection<Object[]> data()
36      {
37          return Arrays.asList( new Object[][] { { MemoryManagerServiceImpl.class },
38              { UnsafeMemoryManagerServiceImpl.class } } );
39      }
40  
41      private final Class<? extends MemoryManagerService<Object>> memoryManagerServiceClass;
42  
43      public DefaultMemoryManagerServiceTest( Class<? extends MemoryManagerService<Object>> memoryManagerServiceClass )
44      {
45          this.memoryManagerServiceClass = memoryManagerServiceClass;
46      }
47  
48      @Override
49      protected MemoryManagerService<Object> instanciateMemoryManagerService( int bufferSize )
50      {
51          try
52          {
53              final MemoryManagerService<Object> mms = memoryManagerServiceClass.newInstance();
54              mms.init( 1, bufferSize );
55              return mms;
56          }
57          catch ( Exception e )
58          {
59              throw new RuntimeException( e );
60          }
61      }
62  
63  }