• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Contains类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.mockito.internal.matchers.Contains的典型用法代码示例。如果您正苦于以下问题:Java Contains类的具体用法?Java Contains怎么用?Java Contains使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Contains类属于org.mockito.internal.matchers包,在下文中一共展示了Contains类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testTraceAndMeasureJoinPointWithLoggerDontPrint

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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\"" ) ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:25,代码来源:TraceUtilitiesTest.java


示例2: testTraceAndMeasureConstructorJoinPointWithLogger

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"Operation : public com.ibm.logger.FakeClassWithAspect(int)\"" ) );
    Assert.assertThat( message, new Contains( "parameters=\"123\"" ) );
    Assert.assertThat( message, new Contains( "cacheHit=\"false\"" ) );
    Assert.assertThat( message, new Contains( "cacheEnabled=\"false\"" ) );
    Assert.assertThat( message, new Contains( "resultSize=\"0\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:27,代码来源:TraceUtilitiesTest.java


示例3: requireThatUnknownDocTypeThrowsIllegalArgumentException

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:18,代码来源:JsonReaderTestCase.java


示例4: testTraceAndMeasureJoinPointExitLog

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@Test
public void testTraceAndMeasureJoinPointExitLog() {

    classWithAspect.methodWithTrace();

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.logRecordList;
    assertEquals( 1, logRecordList.size() );
    LogRecord logRecord = logRecordList.get( 0 );
    String message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertThat( message, new Contains( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace()\"" ) );
    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=\"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

}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:34,代码来源:TraceUtilitiesTest.java


示例5: testTraceAndMeasureJoinPointEntryLog

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@Test
public void testTraceAndMeasureJoinPointEntryLog() {

    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    classWithAspect.methodWithTrace();

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.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=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace()\"" ) );
    Assert.assertThat( message, new Contains( "parameters=\"\"" ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertThat( message, new Contains( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace()\"" ) );
    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=\"12\"" ) );
    Assert.assertThat( message, new Contains( "return=\"Hello world1\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:29,代码来源:TraceUtilitiesTest.java


示例6: testTraceAndMeasureJoinPointEntryLogParameterAndPrintMode

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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, 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=\"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, new Contains( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace(java.lang.String,java.lang.String,int,int[],java.lang.String)\"" ) );
    Assert.assertThat( message, new Contains( parameterTraceString ) );
    Assert.assertThat( message, new Contains( "cacheHit=\"false\"" ) );
    Assert.assertThat( message, new Contains( "cacheEnabled=\"false\"" ) );
    Assert.assertThat( message, new Contains( "resultSize=\"12\"" ) );
    Assert.assertThat( message, new Contains( "return=\"********\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:30,代码来源:TraceUtilitiesTest.java


示例7: testTraceAndMeasureJoinPointEntryLogParameterSecured

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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, 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=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace()\"" ) );
    String parameterTraceString = "parameters=\"********\"";
    Assert.assertThat( message, new Contains( parameterTraceString ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertThat( message, new Contains( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace()\"" ) );
    Assert.assertThat( message, new Contains( parameterTraceString ) );
    Assert.assertThat( message, new Contains( "cacheHit=\"false\"" ) );
    Assert.assertThat( message, new Contains( "cacheEnabled=\"false\"" ) );
    Assert.assertThat( message, new Contains( "resultSize=\"12\"" ) );
    Assert.assertThat( message, new Contains( "return=\"********\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:31,代码来源:TraceUtilitiesTest.java


示例8: testTraceAndMeasureJoinPointMethodThrowingError

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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, 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=\"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( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"public java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithTrace(java.lang.String)\"" ) );
    Assert.assertThat( message, new Contains( "parameters=\"throwing\"" ) );
    Assert.assertThat( message, new Contains( "cacheHit=\"false\"" ) );
    Assert.assertThat( message, new Contains( "cacheEnabled=\"false\"" ) );
    Assert.assertThat( message, new Contains( "resultSize=\"38\"" ) );
    Assert.assertThat( message, new Contains( "return=\"java.lang.NullPointerException: my npe\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:33,代码来源:TraceUtilitiesTest.java


示例9: testTraceAndMeasureConstructorJoinPointEntryAndExitLogSecured

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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, 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=\"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( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"public com.ibm.logger.FakeClassWithAspect(java.lang.String)\"" ) );
    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=\"0\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:28,代码来源:TraceUtilitiesTest.java


示例10: testTraceAndMeasureConstructorJoinPointEntryAndExitLog

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@Test
public void testTraceAndMeasureConstructorJoinPointEntryAndExitLog() {

    FakeClassWithAspect.LOGGER.setLevel( Level.FINER );

    classWithAspect = new FakeClassWithAspect( "hello" );

    // expect an exit log
    List<LogRecord> logRecordList = aspectClassLogHandler.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=\"public com.ibm.logger.FakeClassWithAspect(java.lang.String)\"" ) );
    Assert.assertThat( message, new Contains( "parameters=\"hello\"" ) );

    logRecord = logRecordList.get( 1 );
    message = logRecord.getMessage();
    System.out.println( message );
    Assert.assertThat( message, new Contains( "<exit" ) );
    Assert.assertThat( message, new Contains( "operation=\"public com.ibm.logger.FakeClassWithAspect(java.lang.String)\"" ) );
    Assert.assertThat( message, new Contains( "parameters=\"hello\"" ) );
    Assert.assertThat( message, new Contains( "cacheHit=\"false\"" ) );
    Assert.assertThat( message, new Contains( "cacheEnabled=\"false\"" ) );
    Assert.assertThat( message, new Contains( "resultSize=\"0\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:28,代码来源:TraceUtilitiesTest.java


示例11: testTraceAndMeasureJoinPointWithLogger

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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, 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 java.lang.String com.ibm.logger.FakeClassWithAspect.methodWithServiceLogger()\"" ) );
    Assert.assertThat( message, new Contains( "parameters=\"\"" ) );

    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 Contains( "return=\"Hello to you too\"" ) );
}
 
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:29,代码来源:TraceUtilitiesTest.java


示例12: shouldReturnCurrentUserDetails

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@Test
public void shouldReturnCurrentUserDetails() throws Exception {
    User user = new User("john", "password", Arrays.asList(new SimpleGrantedAuthority("admin")));
    UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(user, user.getPassword());

    UserDto userDto = new UserDto();
    userDto.setUserName("john");
    userDto.setEmail("[email protected]");

    when(userService.getCurrentUser()).thenReturn(userDto);

    mockMvc.perform(get("/users/current").principal(authenticationToken))
            .andExpect(status().isOk())
            .andExpect(content().string(new Contains("\"userName\":\"john\"")));
}
 
开发者ID:motech,项目名称:motech,代码行数:16,代码来源:UserControllerTest.java


示例13: testNegativeConstuctorWrongTask

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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);
}
 
开发者ID:torakiki,项目名称:sejda,代码行数:9,代码来源:XmlConfigurationStrategyTest.java


示例14: testNegativeConstuctorWrongParam

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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);
}
 
开发者ID:torakiki,项目名称:sejda,代码行数:9,代码来源:XmlConfigurationStrategyTest.java


示例15: testNegativeNotFoundClassParam

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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);
}
 
开发者ID:torakiki,项目名称:sejda,代码行数:8,代码来源:XmlConfigurationStrategyTest.java


示例16: assertParserErrorMatches

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
private void assertParserErrorMatches(String expectedError, String... json) {
    exception.expect(JsonReaderException.class);
    exception.expectMessage(new Contains(expectedError));
    String jsonData = inputJson(json);
    new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:7,代码来源:JsonReaderTestCase.java


示例17: test_index

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@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>")));
}
 
开发者ID:cnagel,项目名称:spring-scalate,代码行数:7,代码来源:HomeControllerTests.java


示例18: test_post

import org.mockito.internal.matchers.Contains; //导入依赖的package包/类
@Test
public void test_post() throws Exception {
	mvc.perform(post("/").param("text", "Hello")).andExpect(status().isOk()).andExpect(
			content().string(new Contains("<li>Hello</li>")));
}
 
开发者ID:cnagel,项目名称:spring-scalate,代码行数:6,代码来源:HomeControllerTests.java



注:本文中的org.mockito.internal.matchers.Contains类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Dispatcher类代码示例发布时间:2022-05-23
下一篇:
Java ICLanguageSettingEntry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap