/** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ static public void assertNotSame(Object expected, Object actual) { assertNotSame(null, expected, actual); }
/** * Asserts that two objects refer to the same object. If they are not the same an * AssertionFailedError is thrown. */ public static void assertNotSame(Object expected, Object actual) { assertNotSame(null, expected, actual); }
@Test public void prof_01_performanceStatisticsUsage(){ //WHEN PerformanceStatistics stats = new PerformanceStatistics(); //These numbers should not be 0 - compiler is using some system resources assertNotNull(stats); assertNotSame(0, stats.getUsedHeapMemory()); assertNotSame(0, stats.getCommittedNonHeapMemory()); assertNotSame(0, stats.getThreadCount()); }
/** * Call getFactory(),of a new MonetaryAmount instance with a new monetary context, a * new number and a new currency. The instances must be non equal. */ @SpecAssertion(section = "4.2.2", id = "422-B6") @Test(description = "4.2.2 For each amount class, check new amounts are not equal for different currencies and " + "contexts.") public void testMonetaryAmountFactories_CreateWithMonetaryContextNumberAndCurrency() { for (Class type : Monetary.getAmountTypes()) { if (type.equals(TestAmount.class)) { continue; } MonetaryAmountFactory<MonetaryAmount> f = Monetary.getAmountFactory(type); MonetaryContext mc1 = f.getDefaultMonetaryContext(); MonetaryContext mc2 = f.getMaximalMonetaryContext(); MonetaryAmount m1 = f.setCurrency("CHF").setContext(mc1).setNumber(10).create(); MonetaryAmount m2 = f.setCurrency("USD").setContext(mc2).setNumber(11).create(); AssertJUnit.assertNotSame("Section 4.2.2: Expected not same for " + type.getName(), m1, m2); AssertJUnit.assertTrue("Section 4.2.2: Expected isEqualTo==true for " + type.getName(), m1.isEqualTo(m1)); AssertJUnit.assertTrue("Section 4.2.2: Expected isEqualTo==true for " + type.getName(), m2.isEqualTo(m2)); AssertJUnit.assertTrue("Section 4.2.2: Expected equality for " + type.getName(), m1.equals(m1)); AssertJUnit.assertTrue("Section 4.2.2: Expected equality for " + type.getName(), m2.equals(m2)); } }
/** * Call getFactory(),of a new MonetaryAmount instance * with a new monetary context(if possible-check the max context). The * instances must be non equal and have the same currency and number value. */ @SpecAssertion(section = "4.2.2", id = "422-B5") @Test(description = "4.2.2 For each amount class, check new amounts with explcit MonetaryContext.") public void testMonetaryAmountFactories_CreateWithMonetaryContext() { for (Class type : Monetary.getAmountTypes()) { MonetaryAmountFactory<MonetaryAmount> f = Monetary.getAmountFactory(type); MonetaryContext mc1 = f.getDefaultMonetaryContext(); MonetaryContext mc2 = f.getMaximalMonetaryContext(); MonetaryAmount m1; MonetaryAmount m2; if (mc1.equals(mc2)) { // In this cases both amount must be equals m1 = f.setCurrency("CHF").setContext(mc1).setNumber(10).create(); m2 = f.setCurrency("CHF").setContext(mc2).setNumber(10).create(); AssertJUnit.assertNotSame("Section 4.2.2: Expected non equal instances for " + type.getName(), m1, m2); } else { // In this cases both amount must be non equals m1 = f.setCurrency("CHF").setContext(mc1).setNumber(10).create(); m2 = f.setCurrency("CHF").setContext(mc2).setNumber(10).create(); AssertJUnit.assertNotSame("Section 4.2.2: Expected non equal instances for " + type.getName(), m1, m2); } AssertJUnit.assertTrue("Section 4.2.2: Expected equality for " + type.getName(), m1.equals(m1)); AssertJUnit.assertTrue("Section 4.2.2: Expected equality for " + type.getName(), m2.equals(m2)); } }
AssertJUnit.assertEquals("Section 4.2.7: Rounding did change currency: " + rounded.getClass().getName(), currency.getCurrencyCode(), rounded.getCurrency().getCurrencyCode()); AssertJUnit.assertNotSame( "Section 4.2.7: Rounding did not have any effect, should use scale==2 as default.", m.getNumber().getScale(), rounded.getNumber().getScale());
f = Monetary.getAmountFactory(type); MonetaryAmount m2 = f.setCurrency("USD").setNumber(10).create(); AssertJUnit.assertNotSame("Section 4.2.2: Expected non equal instances for " + type.getName(), m1, m2); f = Monetary.getAmountFactory(type); MonetaryAmount m2 = f.setCurrency("USD").setNumber(10.5d).create(); AssertJUnit.assertNotSame("Section 4.2.2: Expected non equal instances for " + type.getName(), m1, m2); f = Monetary.getAmountFactory(type); MonetaryAmount m2 = f.setCurrency("USD").setNumber(new BigDecimal("10.52")).create(); AssertJUnit.assertNotSame("Section 4.2.2: Expected non equal instances for " + type.getName(), m1, m2);
public void testConsecutiveInvocationOfAllVersionsForKey() throws Exception { waitForClusterToForm(CACHE_NAME); int key = 1; Map<Address, InternalCacheValue<Object>> result1 = getAllVersions(0, key); Map<Address, InternalCacheValue<Object>> result2 = getAllVersions(0, key); assertNotSame(result1, result2); // Assert that a different map is returned, i.e. a new CompletableFuture was created assertEquals(result1, result2); // Assert that returned values are still logically equivalent }
public void cancelRebalance() { assertNotSame(CacheTopology.Phase.NO_REBALANCE, topology.getPhase()); assertNotSame(CacheTopology.Phase.CONFLICT_RESOLUTION, topology.getPhase()); // Use the read CH as the current CH topology = new CacheTopology(topology.getTopologyId() + 1, topology.getRebalanceId() + 1, readConsistentHash(), null, null, CacheTopology.Phase.NO_REBALANCE, topology.getActualMembers(), persistentUUIDs(topology.getActualMembers())); }
@Test public void testEquals() { ZNRecord record1 = new ZNRecord("id"); record1.setSimpleField("k1", "v1"); record1.setMapField("m1", new HashMap<String, String>()); record1.getMapField("m1").put("k1", "v1"); record1.setListField("l1", new ArrayList<String>()); record1.getListField("l1").add("v1"); ZNRecord record2 = new ZNRecord("id"); record2.setSimpleField("k1", "v1"); record2.setMapField("m1", new HashMap<String, String>()); record2.getMapField("m1").put("k1", "v1"); record2.setListField("l1", new ArrayList<String>()); record2.getListField("l1").add("v1"); AssertJUnit.assertEquals(record1, record2); record2.setSimpleField("k2", "v1"); AssertJUnit.assertNotSame(record1, record2); }
@Test public void prof_04_testMaxEventsInList(){ //Here, we create 7 events ProfilingDataManager manager = ProfilingDataManager.getInstance(); ProfilingDataLog event1 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", FASTEST_METHOD_EST, System.currentTimeMillis()); ProfilingDataLog event2 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", MIDDLE_METHOD_EST, System.currentTimeMillis()); ProfilingDataLog event3 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis()); ProfilingDataLog event4 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis()); ProfilingDataLog event5 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis()); ProfilingDataLog event6 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis()); ProfilingDataLog event7 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis()); manager.prepareRequestProfilingEvent(event1); manager.prepareRequestProfilingEvent(event2); manager.prepareRequestProfilingEvent(event3); manager.prepareRequestProfilingEvent(event4); manager.prepareRequestProfilingEvent(event5); manager.prepareRequestProfilingEvent(event6); manager.prepareRequestProfilingEvent(event7); //Only 5 slowest requests should be saved in methodList assertNotSame(7, manager.getPerformanceMap().get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().size()); }
private void checkSnapshot(final Snapshot snapshot) { assertNotNull(snapshot.getId()); assertNotNull(snapshot.getName()); assertNotSame(Snapshot.Type.UNRECOGNIZED, snapshot.getSnapshotType()); }
static void checkVolume(final Volume volume) { assertNotNull(volume.getId()); assertNotNull(volume.getName()); assertNotSame(Volume.Type.UNRECOGNIZED, volume.getType()); }
static void checkVolume(final Volume volume) { assertNotNull(volume.getId()); assertNotNull(volume.getName()); assertNotSame(Volume.Type.UNRECOGNIZED, volume.getType()); }
private void checkSnapshot(final Snapshot snapshot) { assertNotNull(snapshot.getId()); assertNotNull(snapshot.getName()); assertNotSame(Snapshot.Type.UNRECOGNIZED, snapshot.getSnapshotType()); }
public void channelLookupTest() { when(mockChannel.getAddress()).thenReturn(a); when(mockChannel.down(isA(Event.class))).thenReturn(a); when(mockChannel.getView()).thenReturn(v); when(mockChannel.getProtocolStack()).thenReturn(ps); when(ps.getTransport()).thenReturn(new UDP()); EmbeddedCacheManager cm = null; try { GlobalConfigurationBuilder gc = GlobalConfigurationBuilder.defaultClusteredBuilder(); gc.transport().defaultTransport().addProperty("channelLookup", DummyLookup.class.getName()); cm = TestCacheManagerFactory.createClusteredCacheManager(gc, new ConfigurationBuilder()); cm.start(); cm.getCache(); GlobalComponentRegistry gcr = TestingUtil.extractGlobalComponentRegistry(cm); Transport t = gcr.getComponent(Transport.class); assertNotNull(t); assertTrue(t instanceof JGroupsTransport); assertNotSame(JChannel.class, ((JGroupsTransport) t).getChannel().getClass()); } finally { TestingUtil.killCacheManagers(cm); } }
@Test() void testGetStat() { String path = "/tmp/getStatTest"; _zkClient.deleteRecursively(path); Stat stat, newStat; stat = _zkClient.getStat(path); AssertJUnit.assertNull(stat); _zkClient.createPersistent(path, true); stat = _zkClient.getStat(path); AssertJUnit.assertNotNull(stat); newStat = _zkClient.getStat(path); AssertJUnit.assertEquals(stat, newStat); _zkClient.writeData(path, new ZNRecord("Test")); newStat = _zkClient.getStat(path); AssertJUnit.assertNotSame(stat, newStat); }
public void testEmbeddedReplaceMemcachedCASTest() throws Exception { final String key1 = "5"; // 1. Put with Memcached Future<Boolean> f = cacheFactory.getMemcachedClient().set(key1, 0, "v1"); assertTrue(f.get(60, TimeUnit.SECONDS)); CASValue oldValue = cacheFactory.getMemcachedClient().gets(key1); // 2. Replace with Embedded assertTrue(cacheFactory.getEmbeddedCache().replace(key1, "v1", "v2")); // 4. Get with Memcached and verify value/CAS CASValue newValue = cacheFactory.getMemcachedClient().gets(key1); assertEquals("v2", newValue.getValue()); assertNotSame("The version (CAS) should have changed, " + "oldCase=" + oldValue.getCas() + ", newCas=" + newValue.getCas(), oldValue.getCas(), newValue.getCas()); }
public void shouldDoSerializeParseRoundTrip() { JsonObject original = object().put("a", object().get()).put("b", "test").putArray("c", "1","2","3").get(); String json = JsonSerializer.serialize(original, true); String json2 = JsonSerializer.serialize(original, false); // there should be a difference (pretty printing) AssertJUnit.assertNotSame(json, json2); // if we parse it back and reprint it they should be identical to each other and the original AssertJUnit.assertEquals( JsonSerializer.serialize(jsonParser.parse(json), false), JsonSerializer.serialize(jsonParser.parse(json2), false)); AssertJUnit.assertEquals( JsonSerializer.serialize(original, false), JsonSerializer.serialize(jsonParser.parse(json2), false)); }
public void testWithFlagsSemantics() { final AdvancedCache<MagicKey, String> cache1 = advancedCache(0, cacheName); final AdvancedCache<MagicKey, String> cache2 = advancedCache(1, cacheName); assertNotSame("CacheStores", getCacheStore(cache1), getCacheStore(cache2)); assertLoadsAndReset(cache1, 0, cache2, 0);