@Test public void testTimedAwaitWithoutSet() throws InterruptedException { assertFalse(Promises.settable().await(50, TimeUnit.MILLISECONDS)); }
@Test public void testCancelAfterCancel() { final Task<?> task = TestUtil.noop(); final Exception reason1 = new Exception(); final Exception reason2 = new Exception(); assertTrue(task.cancel(reason1)); assertFalse(task.cancel(reason2)); assertCancelled(task, reason1); }
@Test public void testValue() { final String value = "value"; final Promise<String> promise = Promises.value(value); assertTrue(promise.isDone()); assertFalse(promise.isFailed()); assertEquals(value, promise.get()); }
protected void assertNumberOfAttributes(PrismObject<ShadowType> shadow, Integer expectedNumberOfAttributes) { PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("No attributes in repo shadow "+shadow, attributesContainer); List<Item<?,?>> attributes = attributesContainer.getValue().getItems(); assertFalse("Empty attributes in repo shadow "+shadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes in repo shadow "+shadow, (int)expectedNumberOfAttributes, attributes.size()); } }
protected <F extends FocusType> PrismReferenceValue getSingleLinkRef(PrismObject<F> focus) { F focusType = focus.asObjectable(); assertEquals("Unexpected number of linkRefs", 1, focusType.getLinkRef().size()); ObjectReferenceType linkRefType = focusType.getLinkRef().get(0); String accountOid = linkRefType.getOid(); assertFalse("No linkRef oid", StringUtils.isBlank(accountOid)); PrismReferenceValue accountRefValue = linkRefType.asReferenceValue(); assertEquals("OID mismatch in linkRefValue", accountOid, accountRefValue.getOid()); return accountRefValue; }
/** * Verifies the common assertions for the obtained Future object * * @param f, the future * @param expected, expected result after get * @throws Exception */ private void assertFutureResult(Future<?> f, Object expected) throws Exception { assertNotNull(f); assertFalse(f.isCancelled()); assertEquals(expected, f.get()); assertTrue(f.isDone()); }
@Test public void testEquals() { final ShallowTraceBuilder builder = new ShallowTraceBuilder(100L); builderCopy.setPendingNanos(234L); builderCopy.setEndNanos(345L); assertEquals(builder.build(), builderCopy.build()); builderCopy.setPendingNanos(234L); builderCopy.setEndNanos(345L); assertFalse(builder.build().equals(builderCopy.build())); builderCopy.setPendingNanos(234L); builderCopy.setEndNanos(345L); assertFalse(builder.build().equals(builderCopy.build())); builderCopy.setEndNanos(345L); builderCopy.setResultType(ResultType.ERROR); assertFalse(builder.build().equals(builderCopy.build()));
@Test(dependsOnMethods = "testListSingleTag") public void testListResourceByTag() { Set<Volume> volumes = client.getVolumeApi().listVolumes(ListVolumesOptions.Builder.tags(ImmutableMap.of(prefix + "-second-tag", "second-tag-value"))); assertNotNull(volumes); assertFalse(volumes.isEmpty()); assertEquals(1, volumes.size()); }
@Test public void testSharedCacheStoreAfterInvalidation() { assertNull(cache(0, cacheName).get(key)); cache(0, cacheName).put(key, value); assertEquals(value, cache(1, cacheName).get(key)); cache(1, cacheName).put(key, changedValue); assertFalse(cache(0, cacheName).getAdvancedCache().getDataContainer().containsKey(key)); assertEquals(changedValue, cache(0, cacheName).get(key)); } }
@Test(dependsOnMethods="testJmxOperations") public void testCacheMBeanUnregisterOnRemove() throws Exception { cacheManager.defineConfiguration("test", new ConfigurationBuilder().build()); assertNotNull(cacheManager.getCache("test")); ObjectName cacheMBean = getCacheObjectName(JMX_DOMAIN, "test(local)"); assertTrue(existsObject(cacheMBean)); cacheManager.administration().removeCache("test"); assertFalse(existsObject(cacheMBean)); }
@SpecAssertion( section = "0", id = "Setup", note = "Checks that TestConfiguration.getAmountClasses() returns a non empty collection of amount " + "implementations") @Test(description = "TChecks that MonetaryAmount classes are registered for testing.") public void testTestAmountConfiguration() { Collection<Class> amountClasses = TCKTestSetup.getTestConfiguration().getAmountClasses(); AssertJUnit.assertNotNull("TCK Test Configuration amount classes are null.", amountClasses); AssertJUnit.assertFalse("TCK Test Configuration amount classes is empty.", amountClasses.isEmpty()); }
public static void assertAttributeNotNull(PrismObject<ShadowType> repoShadow, QName name) { Collection<String> values = getAttributeValues(repoShadow, name); assertFalse("No values for "+name+" in "+repoShadow, values == null || values.isEmpty()); assertEquals(1, values.size()); assertNotNull(values.iterator().next()); }
private <T> void assertDone(final Task<T> task, final T expectedValue) { assertTrue(task.isDone()); assertFalse(task.isFailed()); assertEquals(expectedValue, task.get()); assertNull(task.getError()); assertTrue(task.getShallowTrace().getStartNanos() > 0); assertTrue(task.getShallowTrace().getStartNanos() <= task.getShallowTrace().getEndNanos()); }
public void testDefaultEnlistment() { ConfigurationBuilder builder = getLocalBuilder(); builder.transaction().transactionMode(TransactionMode.TRANSACTIONAL); dcm = new DefaultCacheManager(getGlobalConfig(), builder.build()); Cache<Object,Object> cache = dcm.getCache(); assertFalse(cache.getCacheConfiguration().transaction().useSynchronization()); assertFalse(cache.getCacheConfiguration().transaction().recovery().enabled()); cache.put("k", "v"); assertEquals("v", cache.get("k")); }
public void testTxCommit1() throws Exception { TransactionManager tm = TestingUtil.getTransactionManager(cache); tm.begin(); cache.put("key", "value"); Transaction t = tm.suspend(); assertTrue(cache.isEmpty()); tm.resume(t); tm.commit(); assertFalse(cache.isEmpty()); }
private void assertRunOrPending(final Task<?> task) { assertFalse(task.isDone()); assertFalse(task.isFailed()); assertTrue(task.getShallowTrace().getStartNanos() > 0); assertNotNull(task.getShallowTrace().getEndNanos()); try { task.get(); fail("Should have thrown PromiseUnresolvedException"); } catch (PromiseUnresolvedException e) { // Expected case } try { task.getError(); fail("Should have thrown PromiseUnresolvedException"); } catch (PromiseUnresolvedException e) { // Expected case } }
private static void assertCacheConfiguration(ConfigurationBuilderHolder holder, String name) { Configuration configuration = getConfiguration(holder, name); assertNotNull("Configuration " + name + " expected", configuration); assertFalse("Configuration " + name + " should not be a template", configuration.isTemplate()); }
private void checkRelease(ConnectionSemaphore semaphore) throws IOException { semaphore.acquireChannelLock(PK); boolean tooManyCaught = false; try { semaphore.acquireChannelLock(PK); } catch (TooManyConnectionsException | TooManyConnectionsPerHostException e) { tooManyCaught = true; } assertTrue(tooManyCaught); tooManyCaught = false; semaphore.releaseChannelLock(PK); try { semaphore.acquireChannelLock(PK); } catch (TooManyConnectionsException | TooManyConnectionsPerHostException e) { tooManyCaught = true; } assertFalse(tooManyCaught); }
@Test public void testPropagateValue() { final String value = "value"; final SettablePromise<String> source = Promises.settable(); final SettablePromise<String> dest = Promises.settable(); Promises.propagateResult(source, dest); assertFalse(dest.isDone()); source.done(value); assertTrue(dest.isDone()); assertFalse(dest.isFailed()); assertEquals(value, dest.get()); }
protected void assertNumberOfAttributes(PrismObject<ShadowType> shadow, Integer expectedNumberOfAttributes) { PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("No attributes in repo shadow "+shadow, attributesContainer); List<Item<?,?>> attributes = attributesContainer.getValue().getItems(); assertFalse("Empty attributes in repo shadow "+shadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes in repo shadow "+shadow, (int)expectedNumberOfAttributes, attributes.size()); } }