Refine search
private void compareVersions(Map<String, VersionTag<VersionSource<?>>> versions, InternalDistributedMember defaultID, List<InternalDistributedMember> vmIds, List<RegionVersionVector<VersionSource<?>>> versionVectors) { for (Map.Entry<String, VersionTag<VersionSource<?>>> entry : versions.entrySet()) { VersionTag<VersionSource<?>> tag = entry.getValue(); tag.replaceNullIDs(defaultID); for (int i = 0; i < vmIds.size(); i++) { assertThat(versionVectors.get(i).contains(tag.getMemberID(), tag.getRegionVersion())) .describedAs( vmIds.get(i) + " should contain " + tag) .isTrue(); } } }
@Test public void testRollbackFailDoesntLeak() throws Exception { final BoomHandler handler = new BoomHandler(); dbRule.getJdbi().setTransactionHandler(handler); final Handle h = dbRule.openHandle(); assertThat(h.isClosed()).isFalse(); handler.failRollback = true; assertThatThrownBy(() -> h.useTransaction(h2 -> h2.execute("insert into true"))) .isInstanceOf(UnableToCreateStatementException.class); assertThat(h.isInTransaction()) .describedAs("rollback failed but handle should still be in transaction").isTrue(); assertThatThrownBy(h::close) .isInstanceOf(CloseException.class); assertThat(h.isClosed()).isTrue(); assertThat(h.getConnection().isClosed()).isTrue(); }
@Override public void run() { try { long stopTime = System.currentTimeMillis() + 5000; Random ran = new Random(System.currentTimeMillis()); while (System.currentTimeMillis() < stopTime) { for (int i = 0; i < 10; i++) { CCRegion.put("cckey" + i, new DeltaValue("ccvalue" + ran.nextInt())); } } long events = CCRegion.getCachePerfStats().getDeltaFailedUpdates(); assertThat(events > 0).describedAs("expected some failed deltas").isTrue(); } catch (CacheException e) { fail("while performing concurrent operations", e); } } };
protected void awaitTermination(GfshScript script) throws InterruptedException { boolean exited = process.waitFor(script.getTimeout(), script.getTimeoutTimeUnit()); try { assertThat(exited).describedAs("Process of [" + script.toString() + "] did not exit after " + script.getTimeout() + " " + script.getTimeoutTimeUnit().toString()).isTrue(); assertThat(process.exitValue()).isEqualTo(script.getExpectedExitValue()); } catch (AssertionError error) { printLogFiles(); throw error; } }
public ProjectAssert assertFile(String localPath, boolean exist) { File candidate = file(localPath); assertThat(candidate.exists()) .describedAs("Invalid presence (%s) exist for %s", exist, localPath) .isEqualTo(exist); return this; }
case 2: case 4: assertThat(entry).isNotNull(); assertThat(Arrays.equals(values[i], (byte[]) v)).isTrue(); break; case 1: // updated assertThat(v).isNotNull(); boolean condition = v instanceof Long; assertThat(condition).describedAs( "Value for key " + i + " is not a Long, is a " + v.getClass().getName()).isTrue(); Long timestamp = (Long) entry.getValue(); assertThat(v).isNotNull(); boolean condition = v instanceof Long; assertThat(condition).describedAs( "Value for key " + i + " is not a Long, is a " + v.getClass().getName()).isTrue(); Long timestamp = (Long) entry.getValue();
assertThat(manager.getHelper().hasAvailabilityIndicator(cliCommand.value()[0])) .describedAs(cliCommand.value()[0] + " in " + commandMarker.getClass() + " has no availability indicator defined. " + "Please add the command in the CommandAvailabilityIndicator")
@Test public void testInvokeEquals() throws Throwable { final Method equalsMethod = testService.getClass().getMethod("equals", Object.class); final Boolean result = (Boolean) testSubject.invoke(testService, equalsMethod, new Object[] {testSubject}); verify(methodHandler, times(0)).invoke(any()); assertThat(feignDecorator.isCalled()) .describedAs("FeignDecorator is called") .isTrue(); assertThat(result) .describedAs("Return of invocation") .isTrue(); }
private void assertStats(DistributedMetricStatsInt distribution, String label, int onLeak, int offLeak, int total) { Optional<MetricStatsInt> statsOption = distribution.getForLabel(label); assertThat(statsOption.isPresent()).describedAs("distribution for label %s not found", label).isTrue(); MetricStatsInt stats = statsOption.get(); assertThat(stats.getOnLeak()).isEqualTo(onLeak); assertThat(stats.getTotal()).isEqualTo(total); }
@Test public void can_move_to_OPERATIONAL_from_STARTED_only() { for (State state : values()) { boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(OPERATIONAL); if (state == STARTED) { assertThat(tryToMoveTo).describedAs("from state " + state).isTrue(); } else { assertThat(tryToMoveTo).describedAs("from state " + state).isFalse(); } } }
@Test public void can_move_to_STOPPING_from_STARTING_STARTED_OPERATIONAL_only() { for (State state : values()) { boolean tryToMoveTo = newLifeCycle(state).tryToMoveTo(STOPPING); if (state == STARTING || state == STARTED || state == OPERATIONAL) { assertThat(tryToMoveTo).describedAs("from state " + state).isTrue(); } else { assertThat(tryToMoveTo).describedAs("from state " + state).isFalse(); } } }
@Override public void run2() { Cache cache = getCache(); Region<?, ?> pr = cache.getRegion(rName); assertThat(pr).describedAs("Region already destroyed.").isNotNull(); pr.destroyRegion(); assertThat(pr.isDestroyed()).describedAs("Region isDestroyed false").isTrue(); assertThat(cache.getRegion(rName)).describedAs("Region not destroyed.").isNull(); } });
@Test public void redactorWillIdentifySampleTabooProperties() { List<String> shouldBeRedacted = Arrays.asList("gemfire.security-password", "password", "other-password-option", CLUSTER_SSL_TRUSTSTORE_PASSWORD, GATEWAY_SSL_TRUSTSTORE_PASSWORD, SERVER_SSL_KEYSTORE_PASSWORD, "security-username", "security-manager", "security-important-property", "javax.net.ssl.keyStorePassword", "javax.net.ssl.some.security.item", "javax.net.ssl.keyStoreType", "sysprop-secret-prop"); for (String option : shouldBeRedacted) { assertThat(isTaboo(option)) .describedAs("This option should be identified as taboo: " + option).isTrue(); } }
@Test public void redactorWillAllowSampleMiscProperties() { List<String> shouldNotBeRedacted = Arrays.asList("gemfire.security-manager", CLUSTER_SSL_ENABLED, CONSERVE_SOCKETS, "username", "just-an-option"); for (String option : shouldNotBeRedacted) { assertThat(isTaboo(option)) .describedAs("This option should not be identified as taboo: " + option).isFalse(); } }
@Test public void testInvokeToString() throws Throwable { final Method toStringMethod = testService.getClass().getMethod("toString"); final Object result = testSubject.invoke(testService, toStringMethod, new Object[0]); verify(methodHandler, times(0)).invoke(any()); assertThat(feignDecorator.isCalled()) .describedAs("FeignDecorator is called") .isTrue(); assertThat(result) .describedAs("Return of invocation") .isEqualTo(target.toString()); }
@Test public void testInvokeHashcode() throws Throwable { final Method hashCodeMethod = testService.getClass().getMethod("hashCode"); final Integer result = (Integer) testSubject.invoke(testService, hashCodeMethod, new Object[0]); verify(methodHandler, times(0)).invoke(any()); assertThat(feignDecorator.isCalled()) .describedAs("FeignDecorator is called") .isTrue(); assertThat(result) .describedAs("Return of invocation") .isEqualTo(target.hashCode()); } }
@Test public void scanSubscriberTerminated() { BlockingIterable.SubscriberIterator<String> test = new BlockingIterable.SubscriberIterator<>(Queues.<String>one().get(), 123); assertThat(test.scan(Scannable.Attr.TERMINATED)).describedAs("before TERMINATED").isFalse(); test.onComplete(); assertThat(test.scan(Scannable.Attr.TERMINATED)).describedAs("after TERMINATED").isTrue(); }
@Test public void testInvoke() throws Throwable { final Object result = testSubject.invoke(testService, greetingMethod, new Object[0]); verify(methodHandler, times(1)).invoke(any()); assertThat(feignDecorator.isCalled()) .describedAs("FeignDecorator is called") .isTrue(); assertThat(result) .describedAs("Return of invocation") .isEqualTo(testService.greeting()); }
assertThat(size).describedAs("Size doesn't return expected value") .isEqualTo(PUT_RANGE_1_END); assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region") .isFalse(); assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region") .isFalse(); boolean replaceSucceeded = pr.replace(Integer.toString(i), Integer.toString(i), "replaced" + i); assertThat(replaceSucceeded).describedAs("for i=" + i).isTrue(); assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region") .isFalse(); assertThat(replaceSucceeded).describedAs("for i=" + i).isFalse(); assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region") .isFalse(); assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region") .isFalse(); assertThat(pr.isEmpty()).describedAs("isEmpty doesn't return proper state of the region") .isFalse(); assertThat(removeResult).describedAs("for i=" + i).isFalse(); Object expected1 = i <= PUT_RANGE_1_END ? "twice replaced" + i : null;
@Test public void scanSubscriberCancelled() { BlockingIterable.SubscriberIterator<String> test = new BlockingIterable.SubscriberIterator<>( Queues.<String>one().get(), 123); //simulate cancellation by offering two elements test.onNext("a"); assertThat(test.scan(Scannable.Attr.CANCELLED)).describedAs("before CANCELLED").isFalse(); test.onNext("b"); assertThat(test.scan(Scannable.Attr.CANCELLED)).describedAs("after CANCELLED").isTrue(); }