@Test public void equalsBasics() { MergedContextConfiguration mergedConfig = new MergedContextConfiguration(null, null, null, null, null); assertEquals(mergedConfig, mergedConfig); assertNotEquals(mergedConfig, null); assertNotEquals(mergedConfig, 1); }
private void assertEqualsAndHashCodeContracts(Object master, Object equal, Object notEqual, Object subclass) { assertEquals("Should be equal", master, equal); assertEquals("Hash code for equal instances should match", master.hashCode(), equal.hashCode()); assertNotEquals("Should not be equal", master, notEqual); assertNotEquals("Hash code for non-equal instances should not match", master.hashCode(), notEqual.hashCode()); assertEquals("Subclass should be equal", master, subclass); assertEquals("Hash code for subclass should match", master.hashCode(), subclass.hashCode()); }
@Test public void equalsWith() { Timed<Integer> t1 = new Timed<Integer>(1, 5, TimeUnit.SECONDS); Timed<Integer> t2 = new Timed<Integer>(1, 5, TimeUnit.SECONDS); Timed<Integer> t3 = new Timed<Integer>(2, 5, TimeUnit.SECONDS); Timed<Integer> t4 = new Timed<Integer>(1, 4, TimeUnit.SECONDS); Timed<Integer> t5 = new Timed<Integer>(1, 5, TimeUnit.MINUTES); assertEquals(t1, t1); assertEquals(t1, t2); assertNotEquals(t1, t3); assertNotEquals(t1, t4); assertNotEquals(t2, t3); assertNotEquals(t2, t4); assertNotEquals(t2, t5); assertNotEquals(t3, t1); assertNotEquals(t3, t2); assertNotEquals(t3, t4); assertNotEquals(t3, t5); assertNotEquals(t4, t1); assertNotEquals(t4, t2); assertNotEquals(t4, t3); assertNotEquals(t4, t5); assertNotEquals(t5, t1); assertNotEquals(t5, t2); assertNotEquals(t5, t3); assertNotEquals(t5, t4); assertNotEquals(new Object(), t1); assertFalse(t1.equals(new Object())); }
@Test public void testAllocatesBitmapsInOrderGivenByAllocationOrder() { PreFillType smallWidth = new PreFillType.Builder(50, 100).setConfig(Bitmap.Config.ARGB_8888).build(); PreFillType smallHeight = new PreFillType.Builder(100, 50).setConfig(Bitmap.Config.RGB_565).build(); PreFillType[] expectedOrder = new PreFillType[] { smallWidth, smallHeight, smallWidth, smallHeight, }; HashMap<PreFillType, Integer> allocationOrder = new HashMap<>(); allocationOrder.put(smallWidth, 2); allocationOrder.put(smallHeight, 2); BitmapPreFillRunner handler = getHandler(allocationOrder); handler.run(); Bitmap[] expectedBitmaps = new Bitmap[expectedOrder.length]; for (int i = 0; i < expectedBitmaps.length; i++) { PreFillType current = expectedOrder[i]; expectedBitmaps[i] = Bitmap.createBitmap(current.getWidth(), current.getHeight(), current.getConfig()); } Bitmap current = addedBitmaps.get(0); for (int i = 1; i < addedBitmaps.size(); i++) { assertNotEquals(current, addedBitmaps.get(i)); current = addedBitmaps.get(i); } assertThat(addedBitmaps).hasSize(4); }
@Test public void originListMatch() throws Exception { Map<String, Object> attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com"); List<String> allowed = Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(allowed); assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes)); assertNotEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value()); }
@Test public void equalsWithDifferentLocations() { String[] locations1 = new String[] { "foo", "bar}" }; String[] locations2 = new String[] { "baz", "quux}" }; MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), locations1, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), locations2, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader); assertNotEquals(mergedConfig1, mergedConfig2); assertNotEquals(mergedConfig2, mergedConfig1); }
@Test public void testGenerate() { final ThreePhraseGenerator tpg = new ThreePhraseGenerator(); final String phrase = tpg.generate('-'); assertNotNull("Generated string is null", phrase); assertNotEquals("Generated string is empty", "", phrase); }
@Test public void testTestCategoryFound() throws Exception { assertNotNull("No plugin annotation on FakePlugin.", p); final Map<String, PluginEntry> testCategory = pluginCache.getCategory(p.category()); assertNotEquals("No plugins were found.", 0, pluginCache.size()); assertNotNull("The category '" + p.category() + "' was not found.", testCategory); assertFalse(testCategory.isEmpty()); }
@Test public void testEmptyList() { List<Boolean> testList = new ArrayList<>(); testList.add(true); testList.add(true); testList.add(true); DebugOverlayDrawable testD = new DebugOverlayDrawable(testList); DebugOverlayDrawable emptyD = new DebugOverlayDrawable(new ArrayList<>()); assertNotEquals(testD.hashCode(), emptyD.hashCode()); assertFalse(testD.isEquivalentTo(emptyD)); }
public void checkAssertion() { assertEquals("", systemErrRule.getLog()); assertNotEquals(0, commandScript.length()); assertTrue(commandScript.delete()); } });
@Override public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) { URI uri = request.getURI(); assertEquals("https", uri.getScheme()); assertNotNull(uri.getHost()); assertNotEquals(-1, uri.getPort()); assertNotNull(request.getRemoteAddress()); assertEquals("/foo", uri.getPath()); assertEquals("param=bar", uri.getQuery()); return Mono.empty(); } }
public static void assertClassLoaderIsSingular(ClassLoader classLoader) { // This is a check against the current HadoopTask which creates a single URLClassLoader with null parent Assert.assertNull(classLoader.getParent()); Assert.assertFalse(classLoader instanceof ApplicationClassLoader); Assert.assertTrue(classLoader instanceof URLClassLoader); final ClassLoader appLoader = HadoopDruidConverterConfig.class.getClassLoader(); Assert.assertNotEquals(StringUtils.format("ClassLoader [%s] is not isolated!", classLoader), appLoader, classLoader); } }
public static void copyResource(String resource, File out) throws IOException { Files.copy(TestUtils.class.getResourceAsStream(resource), out.toPath()); Assert.assertTrue(out.exists()); Assert.assertNotEquals(0, out.length()); } }
private void assertNotEqualsArchNotNull(final Processor.Arch arch, final Processor processor) { assertNotNull(arch); assertNotNull(processor); assertNotEquals(arch, processor.getArch()); }
public static void assertNotEqual( AnyValue a, AnyValue b ) { assertNotEquals( a + " should not be equivalent to " + b, a, b ); assertNotEquals( b + " should not be equivalent to " + a, b, a ); assertFalse( a + " should not equal " + b, a.ternaryEquals( b ) ); assertFalse( b + " should not equal " + a, b.ternaryEquals( a ) ); }
@Test public void testPartitionHashes() { assertEquals(8, idManager.getPartitionBound()); Set<Long> hashs = Sets.newHashSet(); for (long i=1;i<idManager.getPartitionBound()*2;i++) hashs.add(idManager.getPartitionHashForId(i)); assertTrue(hashs.size()>idManager.getPartitionBound()/2); assertNotEquals(idManager.getPartitionHashForId(101),idManager.getPartitionHashForId(102)); }
@Test public void testEquals() { assertEquals(new TypeLiteral<String>() {}, new TypeLiteral<String>() {}); assertEquals(new TypeLiteral<List<String>>() {}, new TypeLiteral<List<String>>() {}); assertNotEquals(new TypeLiteral<String>() {}, new TypeLiteral<List<String>>() {}); }
@Test public void originValueMatch() throws Exception { Map<String, Object> attributes = new HashMap<>(); WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class); this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain1.com"); List<String> allowed = Collections.singletonList("http://mydomain1.com"); OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(allowed); assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes)); assertNotEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value()); }
@Test public void equalsWithDifferentProfiles() { String[] activeProfiles1 = new String[] { "catbert", "dogbert" }; String[] activeProfiles2 = new String[] { "X", "Y" }; MergedContextConfiguration mergedConfig1 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles1, loader); MergedContextConfiguration mergedConfig2 = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, activeProfiles2, loader); assertNotEquals(mergedConfig1, mergedConfig2); assertNotEquals(mergedConfig2, mergedConfig1); }
@Test public void shouldSerialiseWithHistoricValues() throws Exception { assertNotNull("historicSerialisationPairs should not be null.", historicSerialisationPairs); assertNotEquals("historicSerialisationPairs should not be empty.", 0, historicSerialisationPairs.length); for (final Pair<INPUT, OUTPUT> pair : historicSerialisationPairs) { assertNotNull("historicSerialisationPairs first value should not be null", pair.getFirst()); serialiseFirst(pair); assertNotNull("historicSerialisationPairs second value should not be null", pair.getSecond()); deserialiseSecond(pair); } }