/** * If called with an expression evaluating to {@code false}, the test will halt and be ignored. */ public static void assumeTrue(boolean b) { assumeThat(b, is(true)); }
/** * If called with an expression evaluating to {@code false}, the test will halt and be ignored. */ public static void assumeTrue(boolean b) { assumeThat(b, is(true)); }
/** * Attempts to halt the test and ignore it if Throwable <code>e</code> is * not <code>null</code>. Similar to {@link #assumeNoException(Throwable)}, * but provides an additional message that can explain the details * concerning the assumption. * * @param e if non-null, the offending exception * @param message Additional message to pass to {@link AssumptionViolatedException}. * @see #assumeNoException(Throwable) */ public static void assumeNoException(String message, Throwable e) { assumeThat(message, e, nullValue()); } }
/** * Attempts to halt the test and ignore it if Throwable <code>t</code> is * not <code>null</code>. Similar to {@link #assumeNoException(Throwable)}, * but provides an additional message that can explain the details * concerning the assumption. * * @param t if non-null, the offending exception * @param message Additional message to pass to {@link AssumptionViolatedException}. * @see #assumeNoException(Throwable) */ public static void assumeNoException(String message, Throwable t) { assumeThat(message, t, nullValue()); } }
/** * If called with a {@code null} array or one or more {@code null} elements in {@code objects}, * the test will halt and be ignored. */ public static void assumeNotNull(Object... objects) { assumeThat(objects, notNullValue()); assumeThat(asList(objects), everyItem(notNullValue())); }
/** * If called with one or more null elements in <code>objects</code>, the test will halt and be ignored. */ public static void assumeNotNull(Object... objects) { assumeThat(asList(objects), everyItem(notNullValue())); }
@Test public void patchForObject() throws URISyntaxException { // JDK client does not support the PATCH method Assume.assumeThat(this.clientHttpRequestFactory, Matchers.not(Matchers.instanceOf(SimpleClientHttpRequestFactory.class))); String s = template.patchForObject(baseUrl + "/{method}", helloWorld, String.class, "patch"); assertEquals("Invalid content", helloWorld, s); }
@Before public void assumeDebug() { assumeThat("These tests can only be run in debug mode.", ComponentsConfiguration.IS_INTERNAL_BUILD, is(true)); }
@Before public void setUp() { Optional<InetAddress> opt = network.getLocalNonLoopbackIpv4Address(); assumeThat(opt.isPresent(), CoreMatchers.is(true)); nonLoopbackLocal = opt.get(); }
@Test public void getLocalNonLoopbackIpv4Address_returns_a_valid_local_and_non_loopback_ipv4() { Optional<InetAddress> address = underTest.getLocalNonLoopbackIpv4Address(); // address is empty on offline builds assumeThat(address.isPresent(), CoreMatchers.is(true)); assertThat(address.get()).isInstanceOf(Inet4Address.class); assertThat(address.get().isLoopbackAddress()).isFalse(); }
@BeforeClass public static void beforeClass() { Assume.assumeFalse( SystemUtils.IS_OS_WINDOWS ); Assume.assumeThat( OsBeanUtil.getOpenFileDescriptors(), not( OsBeanUtil.VALUE_UNAVAILABLE ) ); }
@Test public void shouldNotThrowWhenOldRecordingLogsAreDeleted() throws IOException { createSegmentFile(recordingThreeId); final Path segmentFilePath = Paths.get(segmentFileName(recordingThreeId, 0)); final boolean segmentFileExists = Files.exists(archiveDir.toPath().resolve(segmentFilePath)); assumeThat(segmentFileExists, is(true)); final Catalog catalog = new Catalog(archiveDir, null, 0, MAX_ENTRIES, clock); catalog.close(); }
@Test public void testPowerOf2Capacity() { assumeThat(spec.isBounded(), is(true)); int n = Pow2.roundToPowerOfTwo(spec.capacity); for (int i = 0; i < n; i++) { assertTrue("Failed to insert:" + i, queue.offer(i)); } assertFalse(queue.offer(n)); }
@Test public void shouldCallExternalErrorOnDateTimeWithZoneName() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( ZonedDateTime.now() ), "ZonedDateTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnDate() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( LocalDate.now() ), "LocalDate values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnLocalDateTime() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( LocalDateTime.now() ), "LocalDateTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnLocalTime() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( LocalTime.now() ), "LocalTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnDuration() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), durationValue( Duration.ofDays( 10 ) ), "Duration values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnTime() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( OffsetTime.now() ), "OffsetTime values cannot be unpacked with this version of bolt." ); }
@Test public void shouldCallExternalErrorOnDateTimeWithOffset() throws Exception { assumeThat( packerUnderTest.version(), equalTo( 1L ) ); testUnpackableStructParametersWithKnownType( new Neo4jPackV2(), ValueUtils.of( OffsetDateTime.now() ), "OffsetDateTime values cannot be unpacked with this version of bolt." ); }