微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

org.junit.matchers.JUnitMatchers的实例源码

项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseInvalidRootElement() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation2 type=\"submit\">\n")
        .append("</operation2>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.INVALID_XML,e.getErrorCode());
        Assert.assertthat(e.getMessage(),JUnitMatchers.containsstring("Root element must be an [operation]"));
        Assert.assertNull(e.getoperation());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseUnsupportedOperationType() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit2\">\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.UNSUPPORTED_OPERATION,JUnitMatchers.containsstring("Unsupported operation type"));
        Assert.assertNull(e.getoperation());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseUnsupportedChildElement() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append("  <test></test>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.UNSUPPORTED_ELEMENT,JUnitMatchers.containsstring("Unsupported [test] element"));
        // this should also contain an operation since the root element was parsed
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseTwoAccounts() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account username=\"customer1\" password=\"test1\"/>\n")
        .append(" <account username=\"customer2\" password=\"test2\"/>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.MULTIPLE_ELEMENTS_NOT_SUPPORTED,JUnitMatchers.containsstring("Multiple [account] elements are not supported"));
        // this should also contain an operation since the root element was parsed
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseAccountOnly() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account username=\"customer1\" password=\"test1\"/>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.MISSING_required_ELEMENT,JUnitMatchers.containsstring("The operation type [submit] requires a request element"));
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseAccountWithMissingUsernameAttribute() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account password=\"test1\"/>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.MISSING_required_ATTRIBUTE,JUnitMatchers.containsstring("The attribute [username] is required with the [account] element"));
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseAccountWithMissingPasswordAttribute() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account username=\"test1\"/>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.MISSING_required_ATTRIBUTE,JUnitMatchers.containsstring("The attribute [password] is required with the [account] element"));
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseAccountWithEmptyUsernameAttribute() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account username=\"\" password=\"test1\"/>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.EMPTY_VALUE,JUnitMatchers.containsstring("The [username] attribute was empty in the [account] element"));
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parSEOperationOnly() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.MISSING_required_ELEMENT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseStartEndTagMismatch() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"deliver\">\n")
        .append(" <account username=\"customer1\" password=\"test1\"/>\n")
        .append(" <deliverRequest referenceId=\"MYREF102020022\">\n")
        .append("  <operatorId>10</operatorId>\n")
        .append("  <sourceAddress type=\"network\">40404</sourceAddress>\n")
        .append("  <destinationAddress type=\"international\">+12065551212</destinationAddress>\n")
        .append("  <text encoding=\"ISO-8859-1\">48656c6c6f20576f726c64</text>\n")
        .append(" </submitRequest>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SAXParseException e) {
        // correct behavior
        Assert.assertthat(e.getMessage(),JUnitMatchers.containsstring("must be terminated by the matching end-tag"));
    }
}
项目:beyondj    文件SxmpSessionTest.java   
@Test
public void processthrowsSxmpParsingExceptionWithNoOperationType() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation2 type=\"submit\">\n")
        .append("</operation2>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());

    MockSxmpRequestProcessor processor = new MockSxmpRequestProcessor();
    SxmpSession session = new SxmpSession(processor,SxmpParser.VERSION_1_0);

    Response response = null;
    try {
        response = session.process(is);
        Assert.fail();
    } catch (SAXException e) {
        // correct behavior
        //Assert.assertEquals(SxmpErrorCode.INVALID_XML,JUnitMatchers.containsstring("Root element must be an [operation]"));
        //Assert.assertNull(e.getoperation());
    }
}
项目:envelope    文件TestMorphlineUtils.java   
@Test
public void convertToRowInvalidNullValue(
    final @Mocked RowUtils utils
) throws Exception {

  Record record = new Record();
  record.put("field1",null);

  StructType schema = DataTypes.createStructType(Lists.newArrayList(
      DataTypes.createStructField("field1",DataTypes.StringType,false))
  );

  try {
    MorphlineUtils.convertToRow(schema,record);
    fail("Did not throw a RuntimeException");
  } catch (Exception e) {
    assertthat(e.getMessage(),JUnitMatchers.containsstring("DataType cannot contain 'null'"));
  }

  new Verifications() {{
    RowUtils.toRowValue(any,(DataType) any); times = 0;
  }};
}
项目:envelope    文件TestMorphlineUtils.java   
@Test
public void convertToRowInvalidTypeNotNullable(
    final @Mocked RowUtils utils
) throws Exception {

  Record record = new Record();
  record.put("field1","one");

  StructType schema = DataTypes.createStructType(Lists.newArrayList(
      DataTypes.createStructField("field1",false))
  );

  new Expectations() {{
    RowUtils.toRowValue("one",DataTypes.StringType); result = new RuntimeException("Conversion exception");
  }};

  try {
    MorphlineUtils.convertToRow(schema,JUnitMatchers.containsstring("Error converting Field"));
  }
}
项目:envelope    文件TestMorphlineUtils.java   
@Test
public void convertToRowInvalidTypeNullable(
    final @Mocked RowUtils utils
) throws Exception {

  Record record = new Record();
  record.put("field1",true))
  );

  new Expectations() {{
    RowUtils.toRowValue("one",JUnitMatchers.containsstring("Error converting Field"));
  }
}
项目:envelope    文件TestMorphlineUtils.java   
@Test
public void convertToRowMissingColumnNotNullable(
    final @Mocked RowUtils utils
) throws Exception {

  Record record = new Record();
  record.put("foo",JUnitMatchers.containsstring("Error converting Record"));
  }

  new Verifications() {{
    RowUtils.toRowValue(any,(DataType) any); times = 0;
  }};
}
项目:envelope    文件TestMorphlineUtils.java   
@Test
public void convertToRowMissingColumnNullable(
    final @Mocked RowUtils utils
) throws Exception {

  Record record = new Record();
  record.put("foo",true))
  );

  try {
    MorphlineUtils.convertToRow(schema,(DataType) any); times = 0;
  }};
}
项目:envelope    文件TestRowUtils.java   
@Test
public void testToRowValueBoolean() {
  DataType field = DataTypes.BooleanType;

  assertEquals("Invalid Boolean",true,RowUtils.toRowValue(true,field));
  assertEquals("Invalid 'true'",RowUtils.toRowValue("true",RowUtils.toRowValue("TrUe",field));
  assertEquals("Invalid 'false'",false,RowUtils.toRowValue("false",RowUtils.toRowValue("FaLsE",field));

  try {
    RowUtils.toRowValue(123,field);
    fail("Expected a RuntimeException for invalid type");
  } catch (RuntimeException e) {
    assertthat(e.getMessage(),JUnitMatchers.containsstring("Invalid or unrecognized input format"));
  }
}
项目:envelope    文件TestRowUtils.java   
@Test
public void testToRowValueDate() {
  DataType field = DataTypes.DateType;

  DateTime dateObj = DateTime.parse("2017-01-01T00:00:00"); // Pass-thru the TZ
  Date sqlDate = new Date(dateObj.getMillis());

  assertEquals("Invalid Long",sqlDate,RowUtils.toRowValue(dateObj.getMillis(),field));
  assertEquals("Invalid String",RowUtils.toRowValue("2017-001",field)); // ISO Date format
  assertEquals("Invalid Date",RowUtils.toRowValue(dateObj.toDate(),field));
  assertEquals("Invalid DateTime",RowUtils.toRowValue(dateObj,field));

  thrown.expect(RuntimeException.class);
  thrown.expectMessage(JUnitMatchers.containsstring("Invalid or unrecognized input format"));
  RowUtils.toRowValue(123,field);
}
项目:envelope    文件TestRowUtils.java   
@Test
public void testToRowValueTimestamp() {
  DataType field = DataTypes.TimestampType;

  DateTime dateObj = DateTime.parse("2017-01-01T00:00:00"); // Pass-thru the TZ
  Timestamp sqlTimestamp = new Timestamp(dateObj.getMillis());

  assertEquals("Invalid Long",sqlTimestamp,field);
}
项目:cassandra-kmean    文件BatchlogEndpointFilterTest.java   
@Test
public void shouldSelect2hostsFromnonlocalRacks() throws UnkNownHostException
{
    Multimap<String,InetAddress> endpoints = ImmutableMultimap.<String,InetAddress> builder()
            .put(LOCAL,InetAddress.getByName("0"))
            .put(LOCAL,InetAddress.getByName("00"))
            .put("1",InetAddress.getByName("1"))
            .put("1",InetAddress.getByName("11"))
            .put("2",InetAddress.getByName("2"))
            .put("2",InetAddress.getByName("22"))
            .build();
    Collection<InetAddress> result = new TestEndpointFilter(LOCAL,endpoints).filter();
    assertthat(result.size(),is(2));
    assertthat(result,JUnitMatchers.hasItem(InetAddress.getByName("11")));
    assertthat(result,JUnitMatchers.hasItem(InetAddress.getByName("22")));
}
项目:datacollector    文件TestDriftRuleEL.java   
@Test
@SuppressWarnings("deprecation")
public void testDriftNamesIncompatibleTypes() throws Exception {
  ELVars vars = new ELVariables();

  Record record = new RecordImpl("creator","id",null,null);
  record.set(Field.create(1));

  RecordEL.setRecordInContext(vars,record);

  vars.addContextvariable(DataRuleEvaluator.PIPELINE_CONTEXT,new HashMap<>());
  vars.addContextvariable(DataRuleEvaluator.RULE_ID_CONTEXT,"ID");

  ELEval elEval = new ELEvaluator("",DriftRuleEL.class,AlertInfoEL.class);

  Assert.assertFalse(elEval.eval(vars,"${drift:names('/',true)}",Boolean.TYPE));
  Assert.assertthat(elEval.eval(vars,"${alert:info()}",String.class),JUnitMatchers.containsstring("Field / have unsupported type of INTEGER."));
}
项目:datacollector    文件TestDriftRuleEL.java   
@Test
@SuppressWarnings("deprecation")
public void testDriftOrderIncompatibleTypes() throws Exception {
  ELVars vars = new ELVariables();

  Record record = new RecordImpl("creator","${drift:order('/',JUnitMatchers.containsstring("Field / have unsupported type of INTEGER."));
}
项目:scylla-tools-java    文件BatchlogEndpointFilterTest.java   
@Test
public void shouldSelect2hostsFromnonlocalRacks() throws UnkNownHostException
{
    Multimap<String,JUnitMatchers.hasItem(InetAddress.getByName("22")));
}
项目:GraphTrek    文件BatchlogEndpointFilterTest.java   
@Test
public void shouldSelect2hostsFromnonlocalRacks() throws UnkNownHostException
{
    Multimap<String,JUnitMatchers.hasItem(InetAddress.getByName("22")));
}
项目:sqlite-jdbc    文件ErrorMessageTest.java   
@Test
public void moved() throws sqlException,IOException {
    File from = File.createTempFile("error-message-test-moved-from",".sqlite");
    from.deleteOnExit();

    Connection conn = DriverManager.getConnection("jdbc:sqlite:" + from.getAbsolutePath());
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("create table sample(id,name)");
    stmt.executeUpdate("insert into sample values(1,\"foo\")");

    File to = File.createTempFile("error-message-test-moved-from",".sqlite");
    assumeTrue(to.delete());
    assumeTrue(from.renameto(to));

    thrown.expectMessage(JUnitMatchers.containsstring("[sqlITE_READONLY_DBMOVED]"));
    stmt.executeUpdate("insert into sample values(2,\"bar\")");

    stmt.close();
    conn.close();
}
项目:sqlite-jdbc    文件ErrorMessageTest.java   
@Test
public void writeProtected() throws sqlException,IOException {
    File file = File.createTempFile("error-message-test-write-protected",".sqlite");
    file.deleteOnExit();

    Connection conn = DriverManager.getConnection("jdbc:sqlite:" + file.getAbsolutePath());
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("create table sample(id,\"foo\")");
    stmt.close();
    conn.close();

    assumeTrue(file.setReadOnly());

    conn = DriverManager.getConnection("jdbc:sqlite:" + file.getAbsolutePath());
    stmt = conn.createStatement();
    thrown.expectMessage(JUnitMatchers.containsstring("[sqlITE_READONLY]"));
    stmt.executeUpdate("insert into sample values(2,\"bar\")");
    stmt.close();
    conn.close();
}
项目:sqlite-jdbc    文件ErrorMessageTest.java   
@Test
public void shouldUsePlainErrorCodeAsvendorCodeAndExtendedAsResultCode() throws sqlException,IOException {
    File from = File.createTempFile("error-message-test-plain-1",\"foo\")");

    File to = File.createTempFile("error-message-test-plain-2",".sqlite");
    assumeTrue(to.delete());
    assumeTrue(from.renameto(to));

    thrown.expectMessage(JUnitMatchers.containsstring("[sqlITE_READONLY_DBMOVED]"));
    thrown.expect(new vendorCodeMatcher(sqliteErrorCode.sqlITE_READONLY));
    thrown.expect(new ResultCodeMatcher(sqliteErrorCode.sqlITE_READONLY_DBMOVED));
    stmt.executeUpdate("insert into sample values(2,\"bar\")");

    stmt.close();
    conn.close();
}
项目:stratio-cassandra    文件BatchlogEndpointFilterTest.java   
@Test
public void shouldSelect2hostsFromnonlocalRacks() throws UnkNownHostException
{
    Multimap<String,JUnitMatchers.hasItem(InetAddress.getByName("22")));
}
项目:pentaho-kettle    文件PrivateDatabasesTestTemplate.java   
protected void doTest_OnePrivate_TwoShared() throws Exception {
  T Meta = createMeta();
  DatabaseMeta privateMeta = createDatabase( "privateMeta" );
  Meta.addDatabase( privateMeta );

  String xml = toXml( Meta );

  DatabaseMeta Meta1 = createDatabase( "Meta1" );
  Meta1.setShared( true );
  DatabaseMeta Meta2 = createDatabase( "Meta2" );
  Meta2.setShared( true );

  Sharedobjects fakeSharedobjects = createFakeSharedobjects( Meta1,Meta2 );

  T loaded = fromXml( xml,fakeSharedobjects );

  List<String> loadedDbs = Arrays.asList( loaded.getDatabaseNames() );
  assertEquals( 3,loadedDbs.size() );
  assertthat( loadedDbs,JUnitMatchers.hasItems( "Meta1","Meta2","privateMeta" ) );

  Set<String> privateDatabases = loaded.getPrivateDatabases();
  assertNotNull( privateDatabases );
  assertEquals( 1,privateDatabases.size() );
  assertTrue( privateDatabases.contains( "privateMeta" ) );
}
项目:pentaho-kettle    文件MappingUnitTest.java   
@SuppressWarnings( "unchecked" )
@Test
public void pickupTargetStepsFor_OutputIsNotDefined() throws Exception {
  StepMeta singleMeta = new StepMeta( "single",null );
  StepMeta copiedMeta = new StepMeta( "copied",null );
  Mockito.when( mockHelper.transMeta.findNextSteps( mockHelper.stepMeta ) ).thenReturn( Arrays.asList( singleMeta,copiedMeta ) );

  StepInterface single = Mockito.mock( StepInterface.class );
  Mockito.when( mockHelper.trans.findStepInterfaces( "single" ) ).thenReturn( Collections.singletonList( single ) );

  StepInterface copy1 = Mockito.mock( StepInterface.class );
  StepInterface copy2 = Mockito.mock( StepInterface.class );
  Mockito.when( mockHelper.trans.findStepInterfaces( "copied" ) ).thenReturn( Arrays.asList( copy1,copy2 ) );

  MappingIODeFinition deFinition = new MappingIODeFinition( null,null );
  StepInterface[] targetSteps = mapping.pickupTargetStepsFor( deFinition );

  assertthat( Arrays.asList( targetSteps ),JUnitMatchers.hasItems( is( single ),is( copy1 ),is( copy2 ) ) );
}
项目:Eatdubbo    文件RouteRuleTest.java   
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,AuthService&consumer.host=127.0.0.1&consumer.version != 1.0.0";
    try{
        RouteRule.parse(expr,"");
        Assert.fail();
    }catch(ParseException expected){
        assertthat(expected.getMessage(),JUnitMatchers.containsstring("Illegal route rule without then express"));
    }
}
项目:dubbo2    文件RouteRuleTest.java   
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,JUnitMatchers.containsstring("Illegal route rule without then express"));
    }
}
项目:github-test    文件RouteRuleTest.java   
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,AuthService&consumer.host=127.0.0.1&consumer.version != 1.0.0";
    try {
        RouteRule.parse(expr,"");
        Assert.fail();
    } catch (ParseException expected) {
        assertthat(expected.getMessage(),JUnitMatchers.containsstring("Illegal route rule without then express"));
    }
}
项目:dubBox-hystrix    文件RouteRuleTest.java   
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,JUnitMatchers.containsstring("Illegal route rule without then express"));
    }
}
项目:dubbocloud    文件RouteRuleTest.java   
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,JUnitMatchers.containsstring("Illegal route rule without then express"));
    }
}
项目:dubbos    文件RouteRuleTest.java   
@org.junit.Test
public void testParse_EmptyThen() {
    String expr = "service=com.alibaba.MemberService,JUnitMatchers.containsstring("Illegal route rule without then express"));
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parSEOperationRequestMismatch() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"deliver\">\n")
        .append(" <account username=\"customer1\" password=\"test1\"/>\n")
        .append(" <submitRequest referenceId=\"MYREF102020022\">\n")
        .append("  <operatorId>10</operatorId>\n")
        .append("  <sourceAddress type=\"network\">40404</sourceAddress>\n")
        .append("  <destinationAddress type=\"international\">+12065551212</destinationAddress>\n")
        .append("  <text encoding=\"ISO-8859-1\">48656c6c6f20576f726c64</text>\n")
        .append(" </submitRequest>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.OPTYPE_MISMATCH,JUnitMatchers.containsstring("The operation type [deliver] does not match the [submitRequest] element"));
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.DELIVER,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseSubmitMissingAccount() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <submitRequest referenceId=\"MYREF102020022\">\n")
        .append("  <operatorId>10</operatorId>\n")
        .append("  <deliveryReport>true</deliveryReport>\n")
        .append("  <sourceAddress type=\"network\">40404</sourceAddress>\n")
        .append("  <destinationAddress type=\"international\">+12065551212</destinationAddress>\n")
        .append("  <text encoding=\"ISO-8859-1\">48656c6c6f20576f726c64</text>\n")
        .append(" </submitRequest>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
        // correct behavior
        Assert.assertEquals(SxmpErrorCode.MISSING_required_ELEMENT,JUnitMatchers.containsstring("The [account] element is required before a [submitRequest] element"));
        Assert.assertNotNull(e.getoperation());
        PartialOperation partial = (PartialOperation)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,partial.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseSubmitEmptyOperatorId() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account username=\"customer1\" password=\"test1\"/>\n")
        .append(" <submitRequest referenceId=\"MYREF102020022\">\n")
        .append("  <operatorId></operatorId>\n")
        .append("  <deliveryReport>true</deliveryReport>\n")
        .append("  <sourceAddress type=\"network\">40f404</sourceAddress>\n")
        .append("  <destinationAddress type=\"international\">+12065551212</destinationAddress>\n")
        .append("  <text encoding=\"ISO-8859-1\">48656c6c6f20576f726c64</text>\n")
        .append(" </submitRequest>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
         // correct behavior
        Assert.assertEquals(SxmpErrorCode.EMPTY_VALUE,JUnitMatchers.containsstring("The element [operatorId] must contain a value"));
        Assert.assertNotNull(e.getoperation());
        SubmitRequest submitRequest = (SubmitRequest)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,submitRequest.getType());
    }
}
项目:beyondj    文件SxmpParserTest.java   
@Test
public void parseSubmitBadOperatorIdValue() throws Exception {
    StringBuilder string0 = new StringBuilder(200)
        .append("<?xml version=\"1.0\"?>\n")
        .append("<operation type=\"submit\">\n")
        .append(" <account username=\"customer1\" password=\"test1\"/>\n")
        .append(" <submitRequest referenceId=\"MYREF102020022\">\n")
        .append("  <operatorId>f</operatorId>\n")
        .append("  <deliveryReport>true</deliveryReport>\n")
        .append("  <sourceAddress type=\"network\">40f404</sourceAddress>\n")
        .append("  <destinationAddress type=\"international\">+12065551212</destinationAddress>\n")
        .append("  <text encoding=\"ISO-8859-1\">48656c6c6f20576f726c64</text>\n")
        .append(" </submitRequest>\n")
        .append("</operation>\n")
        .append("");

    ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
    SxmpParser parser = new SxmpParser();

    try {
        Operation operation = parser.parse(is);
        Assert.fail();
    } catch (SxmpParsingException e) {
         // correct behavior
        Assert.assertEquals(SxmpErrorCode.UNABLE_TO_CONVERT_VALUE,JUnitMatchers.containsstring("Unable to convert [f] to an integer for [operatorId]"));
        Assert.assertNotNull(e.getoperation());
        SubmitRequest submitRequest = (SubmitRequest)e.getoperation();
        Assert.assertEquals(Operation.Type.SUBMIT,submitRequest.getType());
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。