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

org.mockito.internal.matchers.Contains的实例源码

项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureJoinPointWithLoggerDontPrint() {
    ApplyTraceAspect.printReturnValue = false;
    FakeClassWithAspect.SERVICE_LOGGER.setLevel( Level.FINER );

    classWithAspect.methodWithServiceLogger();

    // expect an exit log
    List<LogRecord> logRecordList = serviceLoggerlogHandler.logRecordList;
    assertEquals( 2,logRecordList.size() );
    LogRecord logRecord = logRecordList.get( 0 );
    String message = logRecord.getMessage();

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,new Contains( "<exit" ) );
    Assert.assertthat( message,new Contains( "operation=\"Operation : public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithServiceLogger()\"" ) );
    Assert.assertthat( message,new Contains( "parameters=\"\"" ) );
    Assert.assertthat( message,new Contains( "cacheHit=\"false\"" ) );
    Assert.assertthat( message,new Contains( "cacheEnabled=\"false\"" ) );
    Assert.assertthat( message,new Contains( "resultSize=\"16\"" ) );
    Assert.assertthat( message,new Not( new Contains( "return=\"Hello to you too\"" ) ) );
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureConstructorJoinPointWithLogger() {
    FakeClassWithAspect.SERVICE_LOGGER.setLevel( Level.FINER );

    classWithAspect = new FakeClassWithAspect( 123 );

    // expect an exit log
    List<LogRecord> logRecordList = serviceLoggerlogHandler.logRecordList;
    assertEquals( 2,logRecordList.size() );
    LogRecord logRecord = logRecordList.get( 0 );
    String message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,new Contains( "<entry" ) );
    Assert.assertthat( message,new Contains( "operation=\"Operation : public com.ibm.logger.FakeClassWithAspect(int)\"" ) );
    Assert.assertthat( message,new Contains( "parameters=\"123\"" ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,new Contains( "parameters=\"123\"" ) );
    Assert.assertthat( message,new Contains( "resultSize=\"0\"" ) );
}
项目:vespa    文件JsonReaderTestCase.java   
@Test
public void requireThatUnkNownDocTypeThrowsIllegalArgumentException() {
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage(new Contains("Document type walrus does not exist"));

    final String jsonData = inputJson(
            "[","      {","          'put': 'id:ns:walrus::walrus1',","          'fields': {","              'aField': 42","          }","      }","]");

    new JsonReader(types,jsonToInputStream(jsonData),parserFactory).next();
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureJoinPointExitLog() {

    classWithAspect.methodWithTrace();

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 1,new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace()\"" ) );
    Assert.assertthat( message,new Contains( "resultSize=\"1000\"" ) );
    Assert.assertthat( message,new Contains( "return=\"Hello world1\"" ) );

    // measure and trace disabled
    // trace entry
    // trace exit
    // measurement impact

    // method throwing an exception
    // print mode on method return
    // print mode on method argument

    // option not to print return

    // option not to trace

}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureJoinPointEntryLog() {

    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    classWithAspect.methodWithTrace();

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 2,new Contains( "parameters=\"\"" ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,new Contains( "resultSize=\"12\"" ) );
    Assert.assertthat( message,new Contains( "return=\"Hello world1\"" ) );
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureJoinPointEntryLogParameterandPrintMode() {

    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    classWithAspect.methodWithTrace( "arg1","arg2",123,new int[] { 1,2,3 },"filter" );

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 2,new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace(java.lang.String,java.lang.String,int,int[],java.lang.String)\"" ) );
    String parameterTraceString = "parameters=\"arg1," + Integer.toString( "arg2".hashCode() ) + ",********,filter\"";
    Assert.assertthat( message,new Contains( parameterTraceString ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,java.lang.String)\"" ) );
    Assert.assertthat( message,new Contains( parameterTraceString ) );
    Assert.assertthat( message,new Contains( "return=\"********\"" ) );
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureJoinPointEntryLogParameterSecured() {

    ApplyTraceAspect.secure = true;
    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    classWithAspect.methodWithTrace();

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 2,new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace()\"" ) );
    String parameterTraceString = "parameters=\"********\"";
    Assert.assertthat( message,new Contains( "return=\"********\"" ) );
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureJoinPointMethodThrowingError() {
    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    try {
        classWithAspect.methodWithTrace( "throwing" );
        fail( "expected NullPointerException" );
    } catch ( NullPointerException ex ) {
        assertEquals( "my npe",ex.getMessage() );
    }

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 2,new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace(java.lang.String)\"" ) );
    Assert.assertthat( message,new Contains( "parameters=\"throwing\"" ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,new Contains( "parameters=\"throwing\"" ) );
    Assert.assertthat( message,new Contains( "resultSize=\"38\"" ) );
    Assert.assertthat( message,new Contains( "return=\"java.lang.NullPointerException: my npe\"" ) );
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureConstructorJoinPointEntryAndExitLogSecured() {
    ApplyTraceAspect.secure = true;
    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    classWithAspect = new FakeClassWithAspect( "hello" );

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 2,new Contains( "operation=\"public com.ibm.logger.FakeClassWithAspect(java.lang.String)\"" ) );
    Assert.assertthat( message,new Contains( "parameters=\"********\"" ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,new Contains( "parameters=\"********\"" ) );
    Assert.assertthat( message,new Contains( "resultSize=\"0\"" ) );
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureConstructorJoinPointEntryAndExitLog() {

    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    classWithAspect = new FakeClassWithAspect( "hello" );

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 2,new Contains( "parameters=\"hello\"" ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertthat( message,new Contains( "parameters=\"hello\"" ) );
    Assert.assertthat( message,new Contains( "resultSize=\"0\"" ) );
}
项目:ibm-performance-monitor    文件TraceUtilitiesTest.java   
@Test
public void testTraceAndMeasureJoinPointWithLogger() {
    ApplyTraceAspect.printReturnValue = true;
    FakeClassWithAspect.SERVICE_LOGGER.setLevel( Level.FINER );

    classWithAspect.methodWithServiceLogger();

    // expect an exit log
    List<LogRecord> logRecordList = serviceLoggerlogHandler.logRecordList;
    assertEquals( 2,new Contains( "return=\"Hello to you too\"" ) );
}
项目:sejda    文件XmlConfigurationStrategyTest.java   
@Test
public void testNegativeConstuctorWrongTask() throws ConfigurationException {
    InputStream stream = getClass().getClassLoader().getResourceAsstream("failing-task-sejda-config.xml");
    expected.expectMessage(new Contains(
            "The configured class java.lang.String is not a subtype of interface org.sejda.model.task.Task"));
    when(provider.getConfigurationStream()).thenReturn(stream);
    XmlConfigurationStrategy.newInstance(provider);
}
项目:sejda    文件XmlConfigurationStrategyTest.java   
@Test
public void testNegativeConstuctorWrongparam() throws ConfigurationException {
    InputStream stream = getClass().getClassLoader().getResourceAsstream("failing-param-sejda-config.xml");
    expected.expectMessage(new Contains(
            "The configured class java.lang.String is not a subtype of interface org.sejda.model.parameter.base.TaskParameters"));
    when(provider.getConfigurationStream()).thenReturn(stream);
    XmlConfigurationStrategy.newInstance(provider);
}
项目:sejda    文件XmlConfigurationStrategyTest.java   
@Test
public void testNegativeNotFoundClassparam() throws ConfigurationException {
    InputStream stream = getClass().getClassLoader().getResourceAsstream("failing-no-param-class-sejda-config.xml");
    expected.expectMessage(new Contains("Unable to find the configured bla.bla.not.existing.Class"));
    when(provider.getConfigurationStream()).thenReturn(stream);
    XmlConfigurationStrategy.newInstance(provider);
}
项目:vespa    文件JsonReaderTestCase.java   
private void assertParserErrorMatches(String expectedError,String... json) {
    exception.expect(JsonReaderException.class);
    exception.expectMessage(new Contains(expectedError));
    String jsonData = inputJson(json);
    new JsonReader(types,parserFactory).next();
}
项目:spring-scalate    文件HomeControllerTests.java   
@Test
public void test_index() throws Exception {
    mvc.perform(get("/")).andExpect(status().isOk()).andExpect(
            content().string(new Contains("<label>Say what ever:</label>"))).andExpect(
            content().string(new StartsWith("<!DOCTYPE html>")));
}
项目:spring-scalate    文件HomeControllerTests.java   
@Test
public void test_post() throws Exception {
    mvc.perform(post("/").param("text","Hello")).andExpect(status().isOk()).andExpect(
            content().string(new Contains("<li>Hello</li>")));
}

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