当前位置: 首页>>代码示例>>Java>>正文


Java StringContains类代码示例

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


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

示例1: convertAndSendCustomJmsMessageConverter

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void convertAndSendCustomJmsMessageConverter() throws JMSException {
	messagingTemplate.setJmsMessageConverter(new SimpleMessageConverter() {
		@Override
		public javax.jms.Message toMessage(Object object, Session session)
				throws JMSException, org.springframework.jms.support.converter.MessageConversionException {
			throw new org.springframework.jms.support.converter.MessageConversionException("Test exception");
		}
	});

	messagingTemplate.convertAndSend("myQueue", "msg to convert");
	verify(jmsTemplate).send(eq("myQueue"), messageCreator.capture());

	thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
	thrown.expectMessage(new StringContains("Test exception"));
	messageCreator.getValue().createMessage(mock(Session.class));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:JmsMessagingTemplateTests.java

示例2: missingJiraUrl

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void missingJiraUrl() throws IOException, ScmSyncException {
  Properties props = new Properties();
  props.setProperty("port","31");
  props.setProperty("allowed.hosts", "127.0.0.1,192.168.1.1");
  props.setProperty("jira.user", "user");
  props.setProperty("jira.password", "password");

  writePropertiesFile(props, Server.propertiesFileName);

  // Set runtime environment
  System.setProperty(Server.homeDirProperty, testDir.getAbsolutePath());

  expectedException.expect(ScmSyncException.class);
  expectedException.expectMessage(new StringContains("jira.url property missing from"));

  new Server();

}
 
开发者ID:attivio,项目名称:scmsynchronizer,代码行数:20,代码来源:ServerStartupTests.java

示例3: missingAllowedList

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void missingAllowedList() throws Exception {
  // Configure Partial Properties File
  Properties props = new Properties();
  props.setProperty("port","31");
  File propFile = writePropertiesFile(props, Server.propertiesFileName);

  // Set runtime environment
  System.setProperty(Server.homeDirProperty, testDir.getAbsolutePath());

  // configure expected error
  expectedException.expect(ScmSyncException.class);
  expectedException.expectMessage(new StringContains("Cannot locate allowed.hosts property in scmsync properties"));

  new Server();

}
 
开发者ID:attivio,项目名称:scmsynchronizer,代码行数:18,代码来源:ServerStartupTests.java

示例4: testAddFriend

import org.hamcrest.core.StringContains; //导入依赖的package包/类
/**
 * US02.01.01, UC02.02.01
 */
@Test
public void testAddFriend() throws Exception {

    onView(withId(R.id.addFriendFab)).perform(click());
    pause();
    onView(withClassName(new StringContains("EditText"))).
            perform(typeText(TEST_OTHER_USER),
                        closeSoftKeyboard());
    pause();
    onView(withText("Add")).
            perform(click());
    pause();
    onData(hasToString(TEST_OTHER_USER))
            .inAdapterView(withId(R.id.friendsListListView))
            .check(matches(isDisplayed()));
    pause();
}
 
开发者ID:CMPUT301F15T03,项目名称:301p,代码行数:21,代码来源:FriendsListTest.java

示例5: testAddAndRemoveFriend

import org.hamcrest.core.StringContains; //导入依赖的package包/类
/**
 * UC02.03.01
 */
@Test
public void testAddAndRemoveFriend() throws InterruptedException {

    onView(withId(R.id.addFriendFab)).perform(click());
    pause();
    onView(withClassName(new StringContains("EditText")))
            .perform(typeText(TEST_OTHER_USER),
                    closeSoftKeyboard());
    pause();
    onView(withText("Add"))
            .perform(click());
    pause();
    onData(hasToString(TEST_OTHER_USER))
            .inAdapterView(withId(R.id.friendsListListView))
            .check(matches(isDisplayed()));
    pause();
    onData(hasToString(TEST_OTHER_USER))
            .inAdapterView(withId(R.id.friendsListListView))
            .perform(longClick());
    pause();
    onView(withId(R.id.friendsListListView))
            .check(matches(not(withAdaptedData(hasToString(TEST_OTHER_USER)))));
    pause();

}
 
开发者ID:CMPUT301F15T03,项目名称:301p,代码行数:29,代码来源:FriendsListTest.java

示例6: testEncodeDeclaredExtensionWithAddressContent

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void testEncodeDeclaredExtensionWithAddressContent() {
	IParser parser = new FhirContext().newJsonParser();

	MyPatientWithOneDeclaredAddressExtension patient = new MyPatientWithOneDeclaredAddressExtension();
	patient.addAddress().setUse(AddressUse.HOME);
	patient.setFoo(new Address().addLine("line1"));

	String val = parser.encodeResourceToString(patient);
	ourLog.info(val);
	assertThat(val, StringContains.containsString("\"extension\":[{\"url\":\"urn:foo\",\"valueAddress\":{\"line\":[\"line1\"]}}]"));

	MyPatientWithOneDeclaredAddressExtension actual = parser.parseResource(MyPatientWithOneDeclaredAddressExtension.class, val);
	assertEquals(AddressUse.HOME, patient.getAddress().get(0).getUse());
	Address ref = actual.getFoo();
	assertEquals("line1", ref.getLine().get(0).getValue());

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:19,代码来源:JsonParserTest.java

示例7: testAddFriend_emptyInput

import org.hamcrest.core.StringContains; //导入依赖的package包/类
/**
 * US02.01.01, UC02.02.01
 */
@Test
public void testAddFriend_emptyInput() {
    onView(withId(R.id.addFriendFab)).perform(click());
    pause();
    onView(withClassName(new StringContains("EditText")))
            .perform(clearText(),
                    closeSoftKeyboard());
    pause();
    onView(withText("Add"))
            .perform(click());

    //assert list does not contain friend
    onView(withId(R.id.friendsListListView))
            .check(matches(not(withAdaptedData(hasToString(PrimaryUserHelper.FRIEND_WITH_AN_INVENTORY)))));
    pause();


}
 
开发者ID:CMPUT301F15T03,项目名称:301p,代码行数:22,代码来源:FriendsListTest.java

示例8: testEncodeResourceRef

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void testEncodeResourceRef() throws DataFormatException {

	Patient patient = new Patient();
	patient.setManagingOrganization(new Reference());

	IParser p = new FhirContext().newJsonParser();
	String str = p.encodeResourceToString(patient);
	assertThat(str, IsNot.not(StringContains.containsString("managingOrganization")));

	patient.setManagingOrganization(new Reference("Organization/123"));
	str = p.encodeResourceToString(patient);
	assertThat(str, StringContains.containsString("\"managingOrganization\":{\"reference\":\"Organization/123\"}"));

	Organization org = new Organization();
	org.addIdentifier().setSystem("foo").setValue("bar");
	patient.setManagingOrganization(new Reference(org));
	str = p.encodeResourceToString(patient);
	assertThat(str, StringContains.containsString("\"contained\":[{\"resourceType\":\"Organization\""));

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:22,代码来源:JsonParserTest.java

示例9: testDFSWithInvalidCommmand

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void testDFSWithInvalidCommmand() throws Throwable {
  FsShell shell = new FsShell(new Configuration());
  try (GenericTestUtils.SystemErrCapturer capture =
           new GenericTestUtils.SystemErrCapturer()) {
    ToolRunner.run(shell, new String[]{"dfs -mkdirs"});
    Assert.assertThat("FSShell dfs command did not print the error " +
            "message when invalid command is passed",
        capture.getOutput(), StringContains.containsString(
            "-mkdirs: Unknown command"));
    Assert.assertThat("FSShell dfs command did not print help " +
            "message when invalid command is passed",
        capture.getOutput(), StringContains.containsString(
            "Usage: hadoop fs [generic options]"));
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:17,代码来源:TestFsShell.java

示例10: testExceptionNullMessage

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void testExceptionNullMessage() throws Exception {
  final String cmdName = "-cmdExNullMsg";
  final Command cmd = Mockito.mock(Command.class);
  Mockito.when(cmd.run(Mockito.<String>anyVararg())).thenThrow(
      new IllegalArgumentException());
  Mockito.when(cmd.getUsage()).thenReturn(cmdName);

  final CommandFactory cmdFactory = Mockito.mock(CommandFactory.class);
  final String[] names = {cmdName};
  Mockito.when(cmdFactory.getNames()).thenReturn(names);
  Mockito.when(cmdFactory.getInstance(cmdName)).thenReturn(cmd);

  FsShell shell = new FsShell(new Configuration());
  shell.commandFactory = cmdFactory;
  try (GenericTestUtils.SystemErrCapturer capture =
           new GenericTestUtils.SystemErrCapturer()) {
    ToolRunner.run(shell, new String[]{cmdName});
    Assert.assertThat(capture.getOutput(),
        StringContains.containsString(cmdName
            + ": Null exception message"));
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:24,代码来源:TestFsShell.java

示例11: testEncodeBundleCategory

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void testEncodeBundleCategory() {

	Bundle b = new Bundle();
	BundleEntryComponent e = b.addEntry();
	e.setResource(new Patient());
	e.getResource().getMeta().addTag().setSystem("scheme").setCode( "term").setDisplay( "label");

	String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b);
	ourLog.info(val);

	assertThat(val, StringContains.containsString("<category term=\"term\" label=\"label\" scheme=\"scheme\"/>"));

	b = ourCtx.newXmlParser().parseResource(Bundle.class, val);
	assertEquals(1, b.getEntry().size());
	assertEquals(1, b.getEntry().get(0).getResource().getMeta().getTag().size());
	assertEquals("scheme", b.getEntry().get(0).getResource().getMeta().getTag().get(0).getSystem());
	assertEquals("term", b.getEntry().get(0).getResource().getMeta().getTag().get(0).getCode());
	assertEquals("label", b.getEntry().get(0).getResource().getMeta().getTag().get(0).getDisplay());
	assertNull(b.getEntry().get(0).getResource());

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:23,代码来源:XmlParserTest.java

示例12: testEncodeExtensionWithResourceContent

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void testEncodeExtensionWithResourceContent() {
	IParser parser = new FhirContext().newJsonParser();

	Patient patient = new Patient();
	patient.addAddress().setUse(AddressUse.HOME);
	patient.addExtension().setUrl("urn:foo").setValue( new Reference("Organization/123"));

	String val = parser.encodeResourceToString(patient);
	ourLog.info(val);
	assertThat(val, StringContains.containsString("\"extension\":[{\"url\":\"urn:foo\",\"valueResource\":{\"reference\":\"Organization/123\"}}]"));

	Patient actual = parser.parseResource(Patient.class, val);
	assertEquals(AddressUse.HOME, patient.getAddress().get(0).getUse());
	List<Extension> ext = actual.getExtension();
	assertEquals(1, ext.size());
	Reference ref = (Reference) ext.get(0).getValue();
	assertEquals("Organization/123", ref.getReference());

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:21,代码来源:JsonParserTest.java

示例13: testOutOfBoundsDate

import org.hamcrest.core.StringContains; //导入依赖的package包/类
/**
 * See issue #50
 */
@Test
public void testOutOfBoundsDate() {
	Patient p = new Patient();
	p.setBirthDate(new DateTimeDt("2000-15-31"));

	String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p);
	ourLog.info(encoded);

	assertThat(encoded, StringContains.containsString("2000-15-31"));

	p = ourCtx.newXmlParser().parseResource(Patient.class, encoded);
	assertEquals("2000-15-31", p.getBirthDate().getValueAsString());
	assertEquals("2001-03-31", new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthDate().getValue()));

	ValidationResult result = ourCtx.newValidator().validateWithResult(p);
	String resultString = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result.getOperationOutcome());
	ourLog.info(resultString);

	assertEquals(2, result.getOperationOutcome().getIssue().size());
	assertThat(resultString, StringContains.containsString("cvc-datatype-valid.1.2.3"));
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:25,代码来源:ResourceValidatorTest.java

示例14: testEncodeBundleCategory

import org.hamcrest.core.StringContains; //导入依赖的package包/类
@Test
public void testEncodeBundleCategory() {

	Bundle b = new Bundle();
	BundleEntry e = b.addEntry();
	e.setResource(new Patient());
	e.addCategory("scheme", "term", "label");

	String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeBundleToString(b);
	ourLog.info(val);

	assertThat(val, StringContains.containsString("<category term=\"term\" label=\"label\" scheme=\"scheme\"/>"));

	b = ourCtx.newXmlParser().parseBundle(val);
	assertEquals(1, b.getEntries().size());
	assertEquals(1, b.getEntries().get(0).getCategories().size());
	assertEquals("term", b.getEntries().get(0).getCategories().get(0).getTerm());
	assertEquals("label", b.getEntries().get(0).getCategories().get(0).getLabel());
	assertEquals("scheme", b.getEntries().get(0).getCategories().get(0).getScheme());
	assertNull(b.getEntries().get(0).getResource());

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:23,代码来源:XmlParserTest.java

示例15: testOutOfBoundsDate

import org.hamcrest.core.StringContains; //导入依赖的package包/类
/**
 * See issue #50
 */
@Test
public void testOutOfBoundsDate() {
	Patient p = new Patient();
	p.setBirthDate(new DateDt("2000-15-31"));

	String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(p);
	ourLog.info(encoded);

	assertThat(encoded, StringContains.containsString("2000-15-31"));

	p = ourCtx.newXmlParser().parseResource(Patient.class, encoded);
	assertEquals("2000-15-31", p.getBirthDateElement().getValueAsString());
	assertEquals("2001-03-31", new SimpleDateFormat("yyyy-MM-dd").format(p.getBirthDate()));

	ValidationResult result = ourCtx.newValidator().validateWithResult(p);
	String resultString = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(result.getOperationOutcome());
	ourLog.info(resultString);

	assertEquals(2, result.getOperationOutcome().getIssue().size());
	assertThat(resultString, StringContains.containsString("cvc-pattern-valid: Value '2000-15-31'"));
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:25,代码来源:ResourceValidatorDstu2Test.java


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