类org.junit.jupiter.params.provider.MethodSource源码实例Demo

下面列出了怎么用org.junit.jupiter.params.provider.MethodSource的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: yosegi   文件: TestNumberCellIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_equal_obj_1( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 0 };
  PrimitiveObject[] compareData = new PrimitiveObject[]{ new ByteObj( (byte)-10 ) , new ShortObj( (short)-10 ) , new IntegerObj( -10 ) , new LongObj( -10 ) , new FloatObj( -10.0f ) , new DoubleObj( -10.0d ) };
  for( PrimitiveObject obj : compareData ){
    IFilter filter = new NumberFilter( NumberFilterType.EQUAL , obj );
    boolean[] filterResult = new boolean[30];
    filterResult = column.filter( filter , filterResult );
    if( filterResult == null ){
      assertTrue( true );
      return;
    }
    for( int i = 0 ; i < mustReadIndex.length ; i++ ){
      assertTrue( filterResult[mustReadIndex[i]] );
    }
  }
}
 
源代码2 项目: yosegi   文件: TestBooleanPrimitiveColumn.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_getPrimitiveObjectArray_1( final String targetClassName ) throws IOException{
  IColumn column = createNotNullColumn( targetClassName );
  IExpressionIndex indexList = new AllExpressionIndex( column.size() );
  PrimitiveObject[] objArray = column.getPrimitiveObjectArray( indexList , 0 , indexList.size() );

  assertEquals( objArray[0].getBoolean() , true );
  assertEquals( objArray[1].getBoolean() , false );
  assertEquals( objArray[2].getBoolean() , true );
  assertEquals( objArray[3].getBoolean() , false );
  assertEquals( objArray[4].getBoolean() , true );
  assertEquals( objArray[5].getBoolean() , false );
  assertEquals( objArray[6].getBoolean() , true );
  assertEquals( objArray[7].getBoolean() , false );
  assertEquals( objArray[8].getBoolean() , true );
  assertEquals( objArray[9].getBoolean() , false );
  assertEquals( objArray[10].getBoolean() , true );
}
 
源代码3 项目: camel-quarkus   文件: JsonComponentsTest.java
@ParameterizedTest
@MethodSource("listJsonDataFormatsToBeTested")
public void testUnmarshallingDifferentPojos(String jsonComponent) {
    String bodyA = "{\"name\":\"name A\"}";
    String bodyB = "{\"value\":1.0}";

    RestAssured.given().contentType(ContentType.TEXT)
            .queryParam("json-component", jsonComponent)
            .body(bodyA)
            .post("/dataformats-json/in-a");
    RestAssured.given().contentType(ContentType.TEXT)
            .queryParam("json-component", jsonComponent)
            .body(bodyB)
            .post("/dataformats-json/in-b");
    RestAssured.given()
            .queryParam("json-component", jsonComponent)
            .post("/dataformats-json/out-a")
            .then()
            .body(equalTo(bodyA));
    RestAssured.given()
            .queryParam("json-component", jsonComponent)
            .post("/dataformats-json/out-b")
            .then()
            .body(equalTo(bodyB));
}
 
源代码4 项目: yosegi   文件: TestBooleanPrimitiveColumn.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_getPrimitiveObjectArray_2( final String targetClassName ) throws IOException{
  IColumn column = createNotNullColumn( targetClassName );
  List<Integer> list = new ArrayList<Integer>();
  list.add( Integer.valueOf( 0 ) );
  list.add( Integer.valueOf( 2 ) );
  list.add( Integer.valueOf( 4 ) );
  list.add( Integer.valueOf( 6 ) );
  list.add( Integer.valueOf( 8 ) );
  list.add( Integer.valueOf( 10 ) );
  IExpressionIndex indexList = new ListIndexExpressionIndex( list );
  PrimitiveObject[] objArray = column.getPrimitiveObjectArray( indexList , 0 , indexList.size() );

  assertEquals( objArray[0].getBoolean() , true );
  assertEquals( objArray[1].getBoolean() , true );
  assertEquals( objArray[2].getBoolean() , true );
  assertEquals( objArray[3].getBoolean() , true );
  assertEquals( objArray[4].getBoolean() , true );
  assertEquals( objArray[5].getBoolean() , true );
}
 
源代码5 项目: yosegi   文件: TestNumberBlockIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_lt_2( final IBlockIndex index , final IFilter[] filter ) throws IOException{
  int[] mustReadIndex = { 0 };
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter[4] );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
源代码6 项目: yosegi   文件: TestNumberBlockIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_gt_2( final IBlockIndex index , final IFilter[] filter ) throws IOException{
  int[] mustReadIndex = { 0 };
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter[10] );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
源代码7 项目: yosegi   文件: TestIntegerPrimitiveColumn.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_encodeAndDecode_equalsSetValue_withInt32( final String targetClassName ) throws IOException{
  int[] intArray = new int[]{
    (int)Integer.MAX_VALUE,
    (int)Integer.MIN_VALUE,
    (int)Short.MAX_VALUE,
    (int)Short.MIN_VALUE,
    (int)Byte.MAX_VALUE,
    (int)Byte.MIN_VALUE,
    1,
    1,
    2,
    2
  };
  IColumn column = createTestColumn( targetClassName , intArray );
  assertEquals( column.size() , 10 );
  for ( int i = 0 ; i < 10 ; i++ ) {
    assertEquals( ( (PrimitiveObject)( column.get(i).getRow() ) ).getLong() , intArray[i] );
  }
}
 
源代码8 项目: yosegi   文件: TestStringBlockIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_compareString_3( final IBlockIndex index ) throws IOException{
  int[] mustReadIndex = { 0 , 1 , 3 };
  IFilter filter = new RangeStringCompareFilter( "bb" , true , "x" , false );
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
源代码9 项目: yosegi   文件: TestNumberCellIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_ge_obj_3( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 };
  PrimitiveObject[] compareData = new PrimitiveObject[]{ new ByteObj( (byte)0 ) , new ShortObj( (short)0 ) , new IntegerObj( 0 ) , new LongObj( 0 ) , new FloatObj( 0.0f ) , new DoubleObj( 0.0d ) };
  for( PrimitiveObject obj : compareData ){
    IFilter filter = new NumberFilter( NumberFilterType.GE , obj );
    boolean[] filterResult = new boolean[30];
    filterResult = column.filter( filter , filterResult );
    if( filterResult == null ){
      assertTrue( true );
      return;
    }
    for( int i = 0 ; i < mustReadIndex.length ; i++ ){
      assertTrue( filterResult[mustReadIndex[i]] );
    }
  }
}
 
源代码10 项目: yosegi   文件: TestStringCellIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_backwardMatch_1( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 0 , 20 };
  IFilter filter = new BackwardMatchStringFilter( "0" );
  boolean[] filterResult = new boolean[30];
  filterResult = column.filter( filter , filterResult );
  if( filterResult == null ){
    assertTrue( true );
    return;
  }
  //dumpFilterResult( filterResult );
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( filterResult[mustReadIndex[i]] );
  }
}
 
源代码11 项目: yosegi   文件: TestNumberCellIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_ge_obj_2( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 28 , 29 };
  PrimitiveObject[] compareData = new PrimitiveObject[]{ new ByteObj( (byte)28 ) , new ShortObj( (short)28 ) , new IntegerObj( 28 ) , new LongObj( 28 ) , new FloatObj( 28.0f ) , new DoubleObj( 28.0d ) };
  for( PrimitiveObject obj : compareData ){
    IFilter filter = new NumberFilter( NumberFilterType.GE , obj );
    boolean[] filterResult = new boolean[30];
    filterResult = column.filter( filter , filterResult );
    if( filterResult == null ){
      assertTrue( true );
      return;
    }
    for( int i = 0 ; i < mustReadIndex.length ; i++ ){
      assertTrue( filterResult[mustReadIndex[i]] );
    }
  }
}
 
源代码12 项目: yosegi   文件: TestShortPrimitiveColumn.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_encodeAndDecode_equalsSetValue_withIntBit0( final String targetClassName ) throws IOException{
  short[] valueArray = new short[]{
    (short)0,
    (short)0,
    (short)0,
    (short)0,
    (short)0,
    (short)0,
    (short)0,
    (short)0,
    (short)0,
    (short)0
  };
  IColumn column = createTestColumn( targetClassName , valueArray );
  assertEquals( column.size() , 10 );
  for ( int i = 0 ; i < 10 ; i++ ) {
    assertEquals( ( (PrimitiveObject)( column.get(i).getRow() ) ).getShort() , valueArray[i] );
  }
}
 
源代码13 项目: incubator-tuweni   文件: SSZTestSuite.java
@ParameterizedTest(name = "{index}. ssz->value {0} {3}->{2}")
@MethodSource("readUintBoundsTests")
void testUintBoundsFromSSZ(String type, boolean valid, String value, String ssz) {
  if (valid) {
    int bitLength = Integer.valueOf(type.substring("uint".length()));
    Bytes read;
    if (bitLength < 31) {
      read = Bytes.ofUnsignedLong((long) SSZ.decode(Bytes.fromHexString(ssz), reader -> reader.readUInt(bitLength)));
    } else if (bitLength < 62) {
      read = Bytes.ofUnsignedLong(SSZ.decode(Bytes.fromHexString(ssz), reader -> reader.readULong(bitLength)));
    } else {
      read = Bytes
          .wrap(
              SSZ.decode(Bytes.fromHexString(ssz), reader -> reader.readUnsignedBigInteger(bitLength)).toByteArray());
    }
    assertEquals(Bytes.wrap(new BigInteger(value).toByteArray()).toShortHexString(), read.toShortHexString());
  }
}
 
源代码14 项目: camel-k-runtime   文件: RoutesLoaderTest.java
@ParameterizedTest
@MethodSource("parameters")
public void testLoaders(String location, Class<? extends SourceLoader> type) throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI(location);
    SourceLoader loader = RoutesConfigurer.load(runtime, source);

    assertThat(loader).isInstanceOf(type);
    assertThat(runtime.builders).hasSize(1);
    assertThat(runtime.builders).first().isInstanceOf(RouteBuilder.class);

    RouteBuilder builder = (RouteBuilder)runtime.builders.get(0);
    builder.setContext(runtime.getCamelContext());
    builder.configure();

    List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
    assertThat(routes).hasSize(1);
    assertThat(routes.get(0).getInput().getEndpointUri()).matches("timer:/*tick");
    assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class);
}
 
源代码15 项目: yosegi   文件: TestNumberBlockIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_range_1( final IBlockIndex index , final IFilter[] filter ) throws IOException{
  int[] mustReadIndex = { 0 };
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter[15] );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
源代码16 项目: yosegi   文件: TestNumberBlockIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_range_6( final IBlockIndex index , final IFilter[] filter ) throws IOException{
  int[] mustReadIndex = { 0 , 1 , 2 , 3 };
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter[20] );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
源代码17 项目: yosegi   文件: TestNumberCellIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_le_obj_2( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 };
  PrimitiveObject[] compareData = new PrimitiveObject[]{ new ByteObj( (byte)29 ) , new ShortObj( (short)29 ) , new IntegerObj( 29 ) , new LongObj( 29 ) , new FloatObj( 29.0f ) , new DoubleObj( 29.0d ) };
  for( PrimitiveObject obj : compareData ){
    IFilter filter = new NumberFilter( NumberFilterType.LE , obj );
    boolean[] filterResult = new boolean[30];
    filterResult = column.filter( filter , filterResult );
    if( filterResult == null ){
      assertTrue( true );
      return;
    }
    for( int i = 0 ; i < mustReadIndex.length ; i++ ){
      assertTrue( filterResult[mustReadIndex[i]] );
    }
  }
}
 
源代码18 项目: yosegi   文件: TestIntegerPrimitiveColumn.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_encodeAndDecode_equalsSetValue_withInt16( final String targetClassName ) throws IOException{
  int[] intArray = new int[]{
    (int)Short.MAX_VALUE,
    (int)Short.MIN_VALUE,
    (int)Byte.MAX_VALUE,
    (int)Byte.MIN_VALUE,
    1,
    1,
    -1,
    -1,
    2,
    2
  };
  IColumn column = createTestColumn( targetClassName , intArray );
  assertEquals( column.size() , 10 );
  for ( int i = 0 ; i < 10 ; i++ ) {
    assertEquals( ( (PrimitiveObject)( column.get(i).getRow() ) ).getInt() , intArray[i] );
  }
}
 
源代码19 项目: camel-k-runtime   文件: RoutesLoaderTest.java
@ParameterizedTest
@MethodSource("parameters")
public void testLoaders(String location, Class<? extends SourceLoader> type) throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI(location);
    SourceLoader loader = runtime.load(source);

    assertThat(loader).isInstanceOf(type);
    assertThat(runtime.builders).hasSize(1);
    assertThat(runtime.builders).first().isInstanceOf(RouteBuilder.class);

    RouteBuilder builder = (RouteBuilder)runtime.builders.get(0);
    builder.setContext(runtime.getCamelContext());
    builder.configure();

    List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
    assertThat(routes).hasSize(1);
    assertThat(routes.get(0).getInput().getEndpointUri()).isEqualTo("timer:tick");
    assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class);
}
 
源代码20 项目: yosegi   文件: TestStringCellIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_forwardMatch_1( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 0 };
  IFilter filter = new ForwardMatchStringFilter( "0" );
  boolean[] filterResult = new boolean[30];
  filterResult = column.filter( filter , filterResult );
  if( filterResult == null ){
    assertTrue( true );
    return;
  }
  //dumpFilterResult( filterResult );
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( filterResult[mustReadIndex[i]] );
  }
}
 
源代码21 项目: vividus   文件: WebApplicationConfigurationTests.java
@ParameterizedTest
@MethodSource("resolutionDataProvider")
void testIsMobileWindowResolution(int actualWidth, boolean mobileViewport)
{
    WebApplicationConfiguration webApplicationConfiguration = prepareWebApplicationConfiguration();
    webApplicationConfiguration.setMobileScreenResolutionWidthThreshold(WIDTH_THRESHOLD);
    IJavascriptActions javascriptActions = mockJavascriptActions(actualWidth);
    assertEquals(mobileViewport, webApplicationConfiguration.isMobileViewport(javascriptActions));
}
 
@MethodSource("rangeSource")
@ParameterizedTest
void testConvert(String rangeAsString, Set<Integer> expected)
{
    IntegerRange range = converter.convert(rangeAsString);
    assertEquals(expected, range.getRange());
}
 
源代码23 项目: yosegi   文件: TestBytePrimitiveColumn.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_null_1( final String targetClassName ) throws IOException{
  IColumn column = createNullColumn( targetClassName );
  assertNull( column.get(0).getRow() );
  assertNull( column.get(1).getRow() );
}
 
源代码24 项目: smithy   文件: BoxIndexTest.java
@ParameterizedTest
@MethodSource("data")
public void checksIfBoxed(Model model, String shapeId, boolean isBoxed) {
    BoxIndex index = model.getKnowledge(BoxIndex.class);
    ShapeId targetId = ShapeId.from(shapeId);

    if (isBoxed && !index.isBoxed(targetId)) {
        Assertions.fail("Did not expect shape to be determined as boxed: " + targetId);
    } else if (!isBoxed && index.isBoxed(targetId)) {
        Assertions.fail("Expected shape to be determined as boxed: " + targetId);
    }
}
 
源代码25 项目: kogito-runtimes   文件: BusinessRuleUnitTest.java
@ParameterizedTest
@MethodSource("processes")
public void testBasicBusinessRuleUnitControlledByUnitOfWork(String bpmnPath) throws Exception {

    Application app = generateCode(Collections.singletonList(bpmnPath), Collections.singletonList("org/kie/kogito/codegen/tests/BusinessRuleUnit.drl"));
    assertThat(app).isNotNull();
    final List<String> startedProcesses = new ArrayList<>();
    // add custom event listener that collects data
    ((DefaultProcessEventListenerConfig)app.config().process().processEventListeners()).listeners().add(new DefaultProcessEventListener() {

        @Override
        public void beforeProcessStarted(ProcessStartedEvent event) {
            startedProcesses.add(event.getProcessInstance().getId());
        }

    });
    UnitOfWork uow = app.unitOfWorkManager().newUnitOfWork();
    uow.start();

    Process<? extends Model> p = app.processes().processById("BusinessRuleUnit");

    Model m = p.createModel();
    m.fromMap(Collections.singletonMap("person", new Person("john", 25)));

    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();

    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
    Model result = (Model)processInstance.variables();
    assertThat(result.toMap()).hasSize(1).containsKey("person");
    assertThat(result.toMap().get("person")).isNotNull().hasFieldOrPropertyWithValue("adult", true);

    // since the unit of work has not been finished yet not listeners where invoked
    assertThat(startedProcesses).hasSize(0);
    uow.end();
    // after unit of work has been ended listeners are invoked
    assertThat(startedProcesses).hasSize(1);
}
 
源代码26 项目: smithy   文件: ModifiedTraitTest.java
@ParameterizedTest
@MethodSource("data")
public void testConst(String oldValue, String newValue, String tag, String searchString) {
    TestCaseData data = new TestCaseData(oldValue, newValue);
    Shape definition = createDefinition(ModifiedTrait.DIFF_ERROR_CONST);
    Model modelA = Model.assembler().addShape(definition).addShape(data.oldShape).assemble().unwrap();
    Model modelB = Model.assembler().addShape(definition).addShape(data.newShape).assemble().unwrap();
    List<ValidationEvent> events = ModelDiff.compare(modelA, modelB);

    assertThat(TestHelper.findEvents(events, "ModifiedTrait").size(), equalTo(1));
}
 
源代码27 项目: yosegi   文件: TestCalcLogicalDataSizeLong.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_hasNull_3( final String targetClassName ) throws IOException {
  IColumn column = new PrimitiveColumn( ColumnType.LONG , "column" );
  column.add( ColumnType.LONG , new LongObj( (long)1 ) , 1 );
  column.add( ColumnType.LONG , new LongObj( (long)2 ) , 5 );

  ColumnBinary columnBinary = create( column , targetClassName );
  assertEquals( columnBinary.logicalDataSize , Long.BYTES * 2 );
}
 
源代码28 项目: yosegi   文件: TestDoubleRangeBlockIndex.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_canBlockSkip_1( final IBlockIndex bIndex , final IFilter filter , final boolean result ){
  if( result ){
    assertEquals( result , bIndex.getBlockSpreadIndex( filter ).isEmpty() );
  }
  else{
    assertTrue( bIndex.getBlockSpreadIndex( filter ) == null );
  }
}
 
源代码29 项目: incubator-tuweni   文件: TomlTest.java
@ParameterizedTest
@MethodSource("stringSupplier")
void shouldParseString(String input, String expected) {
  TomlParseResult result = Toml.parse(input);
  assertFalse(result.hasErrors(), () -> joinErrors(result));
  assertEquals(expected, result.getString("foo"));
}
 
源代码30 项目: yosegi   文件: TestCompressor.java
@ParameterizedTest
@MethodSource( "data1" )
public void T_compressAndSet_1( final String[] classNames , final byte[] compressTarget , final int start , final int length , final byte[] success ) throws IOException{
  for( int i = 0 ; i < classNames.length ; i++ ){
    ICompressor compressor = FindCompressor.get( classNames[i] );
    byte[] compressData = compressor.compress( compressTarget , start , length );
    byte[] decompressData = new byte[ compressor.getDecompressSize( compressData , 0 , compressData.length ) ];
    compressor.decompressAndSet( compressData , 0 , compressData.length , decompressData );
    assertTrue( Arrays.equals( decompressData , success ) );
  }
}
 
 类所在包
 同包方法