@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())));
}
java类org.hamcrest.core.CombinableMatcher的实例源码
AssertTests.java 文件源码
项目:android-testing-guide
阅读 31
收藏 0
点赞 0
评论 0
AssertTests.java 文件源码
项目:Advanced_Java
阅读 34
收藏 0
点赞 0
评论 0
@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())));
}
UpfrontAllocatingPageSourceTest.java 文件源码
项目:offheap-store
阅读 38
收藏 0
点赞 0
评论 0
@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")));
}
}
StatisticSamplerTest.java 文件源码
项目:statistics
阅读 28
收藏 0
点赞 0
评论 0
@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();
}
}
SimpleMatcherExamplesTest.java 文件源码
项目:smog
阅读 30
收藏 0
点赞 0
评论 0
@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'");
}
ExpectedConstraintViolation.java 文件源码
项目:testfun
阅读 38
收藏 0
点赞 0
评论 0
/**
* 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);
}
}
ExpectedConstraintViolation.java 文件源码
项目:testfun
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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));
}
PdfFileSourceAdapterTest.java 文件源码
项目:sejda
阅读 35
收藏 0
点赞 0
评论 0
@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"))));
}
PdfFileSourceAdapterTest.java 文件源码
项目:sejda
阅读 32
收藏 0
点赞 0
评论 0
@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"))));
}
PdfFileSourceAdapterTest.java 文件源码
项目:sejda
阅读 30
收藏 0
点赞 0
评论 0
@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"))));
}
DataSourceConfigurationTestUtilities.java 文件源码
项目:tf-exploitation-server
阅读 27
收藏 0
点赞 0
评论 0
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)));
}
DataSourceConfigurationTestUtilities.java 文件源码
项目:tf-exploitation-server
阅读 28
收藏 0
点赞 0
评论 0
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)));
}