/** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ public static void assertSame(Object expected, Object actual) { Assert.assertSame(expected, actual); }
/** * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown with the given message. */ public static void assertSame(String message, Object expected, Object actual) { Assert.assertSame(message, expected, actual); }
/** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ static public void assertSame(Object expected, Object actual) { assertSame(null, expected, actual); }
/** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ @SuppressWarnings("deprecation") public static void assertSame(Object expected, Object actual) { Assert.assertSame(expected, actual); }
/** * Asserts that two objects refer to the same object. If they are not * an AssertionFailedError is thrown with the given message. */ @SuppressWarnings("deprecation") public static void assertSame(String message, Object expected, Object actual) { Assert.assertSame(message, expected, actual); }
/** * Asserts that two objects refer to the same object. If they are not * the same an AssertionFailedError is thrown. */ static public void assertSame(Object expected, Object actual) { assertSame(null, expected, actual); }
/** * Verify that the listener completes in a reasonable amount of time, and Asserts that the future * throws an {@code ExecutableException} and that the cause of the {@code ExecutableException} is * {@code expectedCause}. */ public void assertException(Throwable expectedCause) throws Exception { // Verify that the listener executed in a reasonable amount of time. Assert.assertTrue(countDownLatch.await(1L, TimeUnit.SECONDS)); try { future.get(); Assert.fail("This call was supposed to throw an ExecutionException"); } catch (ExecutionException expected) { Assert.assertSame(expectedCause, expected.getCause()); } }
/** * Causes this thread to call the named void method, and asserts that the call returns normally. */ public void callAndAssertReturns(String methodName, Object... arguments) throws Exception { checkNotNull(methodName); checkNotNull(arguments); sendRequest(methodName, arguments); assertSame(null, getResponse(methodName).getResult()); }
public void testGetKeysArrayConstructorCloned() { Object[] keys = new Object[] {ONE, TWO}; MultiKey mk = new MultiKey(keys, true); Object[] array = mk.getKeys(); Assert.assertTrue(array != keys); Assert.assertTrue(Arrays.equals(array, keys)); Assert.assertSame(ONE, array[0]); Assert.assertSame(TWO, array[1]); Assert.assertEquals(2, array.length); }
public void testGetKeysArrayConstructorNonCloned() { Object[] keys = new Object[] {ONE, TWO}; MultiKey mk = new MultiKey(keys, false); Object[] array = mk.getKeys(); Assert.assertTrue(array != keys); // still not equal Assert.assertTrue(Arrays.equals(array, keys)); Assert.assertSame(ONE, array[0]); Assert.assertSame(TWO, array[1]); Assert.assertEquals(2, array.length); }
public void testGetKeysSimpleConstructor() { MultiKey mk = new MultiKey(ONE, TWO); Object[] array = mk.getKeys(); Assert.assertSame(ONE, array[0]); Assert.assertSame(TWO, array[1]); Assert.assertEquals(2, array.length); }
public void testExceptionConversion() { Exception ex1 = createException(); ex1.initCause(createSimpleCause()); Throwable ex = HiveSQLException.toCause(HiveSQLException.toString(ex1)); Assert.assertSame(RuntimeException.class, ex.getClass()); Assert.assertEquals("exception1", ex.getMessage()); Assert.assertSame(UnsupportedOperationException.class, ex.getCause().getClass()); Assert.assertEquals("exception2", ex.getCause().getMessage()); } };
static void checkEviction(LocalCache<?, ?> map) { if (map.evictsBySize()) { for (Segment<?, ?> segment : map.segments) { drainRecencyQueue(segment); assertEquals(0, segment.recencyQueue.size()); assertEquals(0, segment.readCount.get()); ReferenceEntry<?, ?> prev = null; for (ReferenceEntry<?, ?> current : segment.accessQueue) { if (prev != null) { assertSame(prev, current.getPreviousInAccessQueue()); assertSame(prev.getNextInAccessQueue(), current); } Object key = current.getKey(); if (key != null) { assertSame(current, segment.getEntry(key, current.getHash())); } prev = current; } } } else { for (Segment<?, ?> segment : map.segments) { assertEquals(0, segment.recencyQueue.size()); } } }
static void checkValidState(LocalCache<?, ?> cchm) { for (Segment<?, ?> segment : cchm.segments) { segment.cleanUp(); assertFalse(segment.isLocked()); Map<?, ?> table = segmentTable(segment); // cleanup and then check count after we have a strong reference to all entries segment.cleanUp(); // under high memory pressure keys/values may be nulled out but not yet enqueued assertThat(table.size()).isAtMost(segment.count); for (Entry<?, ?> entry : table.entrySet()) { assertNotNull(entry.getKey()); assertNotNull(entry.getValue()); assertSame(entry.getValue(), cchm.get(entry.getKey())); } } checkEviction(cchm); checkExpiration(cchm); }
assertTrue(entries.add(current)); if (prev != null) { assertSame(prev, current.getPreviousInWriteQueue()); assertSame(prev.getNextInWriteQueue(), current); assertThat(prev.getWriteTime()).isAtMost(current.getWriteTime()); assertSame(current, segment.getEntry(key, current.getHash())); assertTrue(entries.add(current)); if (prev != null) { assertSame(prev, current.getPreviousInAccessQueue()); assertSame(prev.getNextInAccessQueue(), current); assertSame(current, segment.getEntry(key, current.getHash()));
@Test public void getFolder_calledTwice_shouldReturnFirstInstance() { String folderName = "Trash"; Folder webDavFolder = webDavStore.getFolder(folderName); Folder result = webDavStore.getFolder(folderName); assertSame(webDavFolder, result); }
public void testGetIndexed() { MultiKey mk = new MultiKey(ONE, TWO); Assert.assertSame(ONE, mk.getKey(0)); Assert.assertSame(TWO, mk.getKey(1)); try { mk.getKey(-1); fail(); } catch (IndexOutOfBoundsException ex) {} try { mk.getKey(2); fail(); } catch (IndexOutOfBoundsException ex) {} }
@Override public void run() { assertSame(this, Thread.currentThread()); try { while (true) { Request request = requestQueue.take(); Object result; try { result = invokeMethod(request.methodName, request.arguments); } catch (ThreadDeath death) { return; } catch (InvocationTargetException exception) { responseQueue.put(new Response(request.methodName, null, exception.getTargetException())); continue; } catch (Throwable throwable) { responseQueue.put(new Response(request.methodName, null, throwable)); continue; } responseQueue.put(new Response(request.methodName, result, null)); } } catch (ThreadDeath death) { return; } catch (InterruptedException ignored) { // SynchronousQueue sometimes throws InterruptedException while the threads are stopping. } catch (Throwable uncaught) { this.uncaughtThrowable = uncaught; } }
@Override public void onAfterPut(Cache.Entry<TestKey, TestValue> entry) { assertNotSame(key, entry.getKey()); assertSame(entry.getValue(), entry.getValue()); assertSame(entry.getKey(), entry.getKey()); // Try change value. entry.getValue().val(WRONG_VALUE); } });
@Override public void onAfterPut(Cache.Entry<TestKey, TestValue> entry) { assertNotSame(key, entry.getKey()); assertSame(entry.getValue(), entry.getValue()); assertSame(entry.getKey(), entry.getKey()); // Try change value. entry.getValue().val(WRONG_VALUE); } });