Java 类org.hamcrest.core.CombinableMatcher 实例源码

项目:android-testing-guide    文件:AssertTests.java   
@Test
public void testAssertThatHamcrestCoreMatchers() {
    assertThat("good", allOf(equalTo("good"), startsWith("good")));
    assertThat("good", not(allOf(equalTo("bad"), equalTo("good"))));
    assertThat("good", anyOf(equalTo("bad"), equalTo("good")));
    assertThat(7, not(CombinableMatcher.either(equalTo(3)).or(equalTo(4))));
    assertThat(new Object(), not(sameInstance(new Object())));
}
项目:Advanced_Java    文件:AssertTests.java   
@Test
public void testAssertThatHamcrestCoreMatchers() {
    assertThat("good", allOf(equalTo("good"), startsWith("good")));
    assertThat("good", not(allOf(equalTo("bad"), equalTo("good"))));
    assertThat("good", anyOf(equalTo("bad"), equalTo("good")));
    assertThat(7, not(CombinableMatcher.<Integer> either(equalTo(3)).or(equalTo(4))));
    assertThat(new Object(), not(sameInstance(new Object())));
}
项目:offheap-store    文件:UpfrontAllocatingPageSourceTest.java   
@Test
public void testReallyLargeUpfrontAllocation() {
  try {
    new UpfrontAllocatingPageSource(new OffHeapBufferSource(), Long.MAX_VALUE, MemoryUnit.GIGABYTES.toBytes(1));
    Assert.fail("Expected IllegalArgumentException");
  } catch (IllegalArgumentException e) {
    Assert.assertThat(e.getMessage(), CombinableMatcher.either(containsString("physical memory")).or(containsString("allocate more off-heap memory")));
  }
}
项目:statistics    文件:StatisticSamplerTest.java   
@Test
public void testShortPeriodSampler() throws InterruptedException {
  StatisticArchive<Integer> archive = new StatisticArchive<>(20);
  StatisticSampler<Integer> sampler = new StatisticSampler<>(100L, TimeUnit.MILLISECONDS, constant(GAUGE, 42), archive);
  try {
    sampler.start();
    TimeUnit.SECONDS.sleep(1);
    assertBy(1, TimeUnit.SECONDS, contentsOf(archive), hasSize(CombinableMatcher.both(greaterThan(10)).and(lessThan(20))));
  } finally {
    sampler.shutdown();
  }
}
项目:smog    文件:SimpleMatcherExamplesTest.java   
@Test
public void testBothMatcher() throws Exception {
    Matcher<String> matcher = CombinableMatcher.both(equalTo("abc")).and(equalTo("bc"));

    assertDescription(matcher, "('abc' and 'bc')");
    assertMismatch("abc", matcher, "'bc' was 'abc'");
}
项目:testfun    文件:ExpectedConstraintViolation.java   
/**
 * Adds {@code matcher} to the list of requirements for any thrown exception.
 */
// Should be able to remove this suppression in some brave new hamcrest world.
@SuppressWarnings("unchecked")
public void expect(Matcher<?> matcher) {
    if (this.matcher == null) {
        this.matcher = (Matcher<Object>) matcher;
    } else {
        this.matcher = CombinableMatcher.both(this.matcher).and((Matcher<Object>) matcher);
    }
}
项目:testfun    文件:ExpectedConstraintViolation.java   
/**
 * Adds to the list of requirements for any thrown exception that it
 * should <em>contain</em> string {@code substring}
 */
public void expectViolation(String substring) {
    if (matcher == null) {
        expect(CombinableMatcher.either(
                new CausedBy(org.hibernate.exception.ConstraintViolationException.class))
                .or(new CausedBy(ConstraintViolationException.class)));
    }

    expectMessage(CoreMatchers.containsString(substring));
}
项目:sejda    文件:PdfFileSourceAdapterTest.java   
@Test
public void windowsFileWithPassword() {
    PdfFileSource result = new PdfFileSourceAdapter("/tmp/inputFile1.pdf:secret123").getPdfFileSource();
    assertThat(result.getPassword(), is("secret123"));
    assertThat(result.getSource(),
            CombinableMatcher.<File> either(is(new File("/tmp/inputFile1.pdf"))).or(
                    is(new File("c:\\tmp\\inputFile1.pdf"))));
}
项目:sejda    文件:PdfFileSourceAdapterTest.java   
@Test
public void windowsFileNoPassword() {
    PdfFileSource result = new PdfFileSourceAdapter("/tmp/inputFile1.pdf").getPdfFileSource();
    assertNull(result.getPassword());
    assertThat(result.getSource(),
            CombinableMatcher.<File> either(is(new File("/tmp/inputFile1.pdf"))).or(
                    is(new File("c:\\tmp\\inputFile1.pdf"))));
}
项目:sejda    文件:PdfFileSourceAdapterTest.java   
@Test
public void protectedFileWithPasswordContainingSeparator() {
    PdfFileSource result = new PdfFileSourceAdapter("/tmp/inputFile1.pdf:secret.pdf:password").getPdfFileSource();
    assertThat(result.getPassword(), is("secret.pdf:password"));
    assertThat(result.getSource(),
            CombinableMatcher.<File> either(is(new File("/tmp/inputFile1.pdf"))).or(
                    is(new File("c:\\tmp\\inputFile1.pdf"))));
}
项目:tf-exploitation-server    文件:DataSourceConfigurationTestUtilities.java   
public static CombinableMatcher<? super IDataSourceConfiguration> isThisTestSource() {
  return both(hasName(equalTo(THIS_SOURCE_NAME)))//
      .and(hasUri(equalTo(THIS_SOURCE_URI)))
      .and(hasLanguages(containsInAnyOrder(EN, DE)))
      .and(hasRank(closeTo(THIS_SOURCE_RANK, TOLERANCE)));
}
项目:tf-exploitation-server    文件:DataSourceConfigurationTestUtilities.java   
public static CombinableMatcher<? super IDataSourceConfiguration> isThatTestSource() {
  return both(hasName(equalTo(THAT_SOURCE_NAME)))//
      .and(hasUri(equalTo(THAT_SOURCE_URI)))
      .and(hasLanguages(containsInAnyOrder(EN)))
      .and(hasRank(closeTo(THAT_SOURCE_RANK, TOLERANCE)));
}