@RunWith(Theories.class) public class BufferExpansionTest { @DataPoint public static final MutableDirectBuffer EXPANDABLE_ARRAY_BUFFER = new ExpandableArrayBuffer(); @DataPoint public static final MutableDirectBuffer EXPANDABLE_DIRECT_BYTE_BUFFER = new ExpandableDirectByteBuffer(); @Theory public void shouldExpand(final MutableDirectBuffer buffer) { final int capacity = buffer.capacity(); final int index = capacity + 50; final int value = 777; buffer.putInt(index, value); assertThat(buffer.capacity(), greaterThan(capacity)); assertThat(buffer.getInt(index), is(value)); } }
private MaterialConfigConverter materialConfigConverter = new MaterialConfigConverter(); @DataPoint public static MaterialConfig gitMaterialConfig = new GitMaterialConfig(url("git-url"), "branch", "submodule", true, filterFor("*.doc"), false, "folder", cis("gitMaterial"), false); @DataPoint public static MaterialConfig hgMaterialConfig = new HgMaterialConfig(new HgUrlArgument("hg-url"), true, filterFor("*.png"), false, "folder", cis("hgMaterial")); @DataPoint public static MaterialConfig svnMaterialConfig = new SvnMaterialConfig(url("svn-url"), "user", "pass", true, new GoCipher(), true, filterFor("*.txt"), false, "folder", cis("name1")); @DataPoint public static MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:9090", "user", "pass", true, "view", new GoCipher(), cis("p4Material"), true, filterFor("*.jpg"), false, "folder"); @DataPoint public static MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(url("tfs-url"), "user", "domain", "pass", "prj-path", new GoCipher(), true, filterFor("*.txt"), false, "folder", cis("tfsMaterial")); @DataPoint public static MaterialConfig pkgMaterialConfig = new PackageMaterialConfig(cis("name"), "pkg-id", packageDefinition); @DataPoint public static MaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(cis("name"), scmConfig, "folder", filterFor("*.txt")); @DataPoint public static MaterialConfig dependencyMaterialConfig = new DependencyMaterialConfig(cis("name1"), cis("pipeline1"), cis("stage1"));
@RunWith(Theories.class) public class FragmentedMessageTest @DataPoint public static final String IPC_CHANNEL = CommonContext.IPC_CHANNEL; @DataPoint public static final String UNICAST_CHANNEL = "aeron:udp?endpoint=localhost:54325"; @DataPoint public static final String MULTICAST_CHANNEL = "aeron:udp?endpoint=224.20.30.39:54326|interface=localhost";
@RunWith(Theories.class) public class ExclusivePublicationTest @DataPoint public static final String MULTICAST_CHANNEL = "aeron:udp?endpoint=224.20.30.39:54326|interface=localhost"; @DataPoint public static final String UNICAST_CHANNEL = "aeron:udp?endpoint=localhost:54325"; @DataPoint public static final String IPC_CHANNEL = CommonContext.IPC_CHANNEL;
@DataPoint public static ValueProducer<PrimitiveIntSet> intV = new ValueProducer<PrimitiveIntSet>( PrimitiveIntSet.class ) @DataPoint public static ValueProducer<PrimitiveLongSet> longV = new ValueProducer<PrimitiveLongSet>( PrimitiveLongSet.class ) @DataPoint public static ValueProducer<PrimitiveIntLongMap> intLongV = new ValueProducer<PrimitiveIntLongMap>( PrimitiveIntLongMap.class ) @DataPoint public static ValueProducer<PrimitiveLongIntMap> longIntV = new ValueProducer<PrimitiveLongIntMap>( PrimitiveLongIntMap.class ) @DataPoint public static ValueProducer<PrimitiveLongLongMap> longLongV = new ValueProducer<PrimitiveLongLongMap>( PrimitiveLongLongMap.class ) @DataPoint public static ValueProducer<PrimitiveIntObjectMap> intObjV = new ValueProducer<PrimitiveIntObjectMap>( PrimitiveIntObjectMap.class ) @DataPoint public static ValueProducer<PrimitiveLongObjectMap> longObjV = new ValueProducer<PrimitiveLongObjectMap>( PrimitiveLongObjectMap.class ) @DataPoint public static Factory<PrimitiveIntSet> intSet = Primitive::intSet;
private static final int INDEX = 8; @DataPoint public static final MutableDirectBuffer ARRAY_BUFFER = new UnsafeBuffer( new byte[BUFFER_CAPACITY], 0, BUFFER_CAPACITY); @DataPoint public static final MutableDirectBuffer DIRECT_BYTE_BUFFER = new UnsafeBuffer( ByteBuffer.allocateDirect(BUFFER_CAPACITY), 0, BUFFER_CAPACITY); @DataPoint public static final MutableDirectBuffer EXPANDABLE_ARRAY_BUFFER = new ExpandableArrayBuffer(BUFFER_CAPACITY); @DataPoint public static final MutableDirectBuffer EXPANDABLE_DIRECT_BYTE_BUFFER = new ExpandableDirectByteBuffer(BUFFER_CAPACITY);
@DataPoint public static final Fixture ONE_TO_ONE_QUEUE = () -> new OneToOneConcurrentArrayQueue<>(QUEUE_CAPACITY); @DataPoint public static final Fixture MANY_TO_ONE_QUEUE = () -> new ManyToOneConcurrentArrayQueue<>(QUEUE_CAPACITY); @DataPoint public static final Fixture MANY_TO_MANY_QUEUE = () -> new ManyToManyConcurrentArrayQueue<>(QUEUE_CAPACITY);
private static final double DOUBLE_VALUE = Integer.MAX_VALUE + 7.0d; @DataPoint public static final AtomicBuffer BYTE_ARRAY_BACKED = new UnsafeBuffer(new byte[BUFFER_CAPACITY], 0, BUFFER_CAPACITY); @DataPoint public static final AtomicBuffer HEAP_BYTE_BUFFER = new UnsafeBuffer( ByteBuffer.allocate(BUFFER_CAPACITY), 0, BUFFER_CAPACITY); @DataPoint public static final AtomicBuffer DIRECT_BYTE_BUFFER = new UnsafeBuffer( ByteBuffer.allocateDirect(BUFFER_CAPACITY), 0, BUFFER_CAPACITY); @DataPoint public static final AtomicBuffer HEAP_BYTE_BUFFER_SLICE = new UnsafeBuffer( ((ByteBuffer)(ByteBuffer.allocate(BUFFER_CAPACITY * 2).position(BUFFER_CAPACITY))).slice()); @DataPoint public static final AtomicBuffer HEAP_BYTE_BUFFER_READ_ONLY = new UnsafeBuffer( ByteBuffer.allocate(BUFFER_CAPACITY).asReadOnlyBuffer(), 0, BUFFER_CAPACITY);
@RunWith(Theories.class) public class TheoryTest extends TestCase { @DataPoint public static Integer i = 1; @Theory public void testTheory1(final Integer i) { assertEquals(1, i.intValue()); } @Theory public void testTheory2(final Integer i) { } @Theory public void testTheory3(final Integer i) { } }
@RunWith(Theories.class) public static class TheoriesTest { @DataPoint public static int i = 1; @Theory public void testTheory(final int i) { assertEquals(1, i); } @Theory public void failingTheory(final int i) { fail(); } @Theory public void errorTheory(final int i) { throw new NullPointerException(); } } }
@DataPoint public static GeneratedClassWithName simpleClass() { final JavaFileObject object = CodeGenUtils .createTestClass(field(STRING_TYPE, "foo", Retained.class)); return new GeneratedClassWithName(object, TEST_CLASS); }
@DataPoint public static APITestScenario createSimpleSource() { TestSource source = new TestSource("test", generateClassName(), Modifier.PUBLIC); source.appendFields(new RetainedTestField(String.class).createFieldSpec(), new ArgTestField(Integer.class).createFieldSpec()) .appendTransformation((b, s) -> b.superclass(MockedFragment.class)); return base -> new APITestBase(base, source); }
@DataPoint public static APITestScenario createSourceWithInnerClass() { TestSource enclosingClass = new TestSource("test", generateClassName(), Modifier.PUBLIC); TestSource source = new TestSource(null, generateClassName(), Modifier.PUBLIC); source.appendFields(new RetainedTestField(String.class).createFieldSpec(), new ArgTestField(Integer.class).createFieldSpec()) .appendTransformation((b, s) -> b.superclass(MockedFragment.class)); enclosingClass.innerClasses(true, source); return base -> new APITestBase(base, source, enclosingClass, new TestSource[] {}); }