/** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ static public void assertNotSame(Object expected, Object actual) { assertNotSame(null, expected, actual); }
/** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ public static void assertNotSame(Object expected, Object actual) { Assert.assertNotSame(expected, actual); }
/** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown with the * given message. */ public static void assertNotSame(String message, Object expected, Object actual) { Assert.assertNotSame(message, expected, actual); }
/** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ static public void assertNotSame(Object expected, Object actual) { assertNotSame(null, expected, actual); }
/** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown with the * given message. */ @SuppressWarnings("deprecation") public static void assertNotSame(String message, Object expected, Object actual) { Assert.assertNotSame(message, expected, actual); }
/** * Asserts that two objects do not refer to the same object. If they do * refer to the same object an AssertionFailedError is thrown. */ @SuppressWarnings("deprecation") public static void assertNotSame(Object expected, Object actual) { Assert.assertNotSame(expected, actual); }
/** * Asserts that an expected {@link Activity} is currently active one, with the possibility to * verify that the expected {@code Activity} is a new instance of the {@code Activity}. * * @param message the message that should be displayed if the assert fails * @param expectedClass the {@code Class} object that is expected to be active e.g. {@code MyActivity.class} * @param isNewInstance {@code true} if the expected {@code Activity} is a new instance of the {@code Activity} */ public void assertCurrentActivity(String message, Class<? extends Activity> expectedClass, boolean isNewInstance) { boolean found = false; assertCurrentActivity(message, expectedClass); Activity activity = activityUtils.getCurrentActivity(false); if(activity == null){ Assert.assertNotSame(message, isNewInstance, false); return; } for (int i = 0; i < activityUtils.getAllOpenedActivities().size() - 1; i++) { String instanceString = activityUtils.getAllOpenedActivities().get(i).toString(); if (instanceString.equals(activity.toString())) found = true; } Assert.assertNotSame(message, isNewInstance, found); }
@Override public void onAfterRemove(Cache.Entry<TestKey, TestValue> entry) { assertNotSame(key, entry.getKey()); assertNotSame(newTestVal, entry.getValue()); } });
@Override public IgniteBiTuple onBeforeRemove(Cache.Entry<TestKey, TestValue> entry) { assertNotSame(key, entry.getKey()); assertNotSame(newTestVal, entry.getValue()); return super.onBeforeRemove(entry); }
@Override public TestValue onBeforePut(Cache.Entry<TestKey, TestValue> entry, TestValue newVal) { assertNotSame(key, entry.getKey()); assertNotSame(val, entry.getValue()); assertEquals(newTestVal, newVal); // Try change value. entry.getValue().val(WRONG_VALUE); return newVal; }
@Test public void testApplicationAsApplicationContextOfBaseContext() throws Exception { final Context context = InstrumentationRegistry.getTargetContext(); final Context app_context = context.getApplicationContext(); assertTrue(app_context instanceof Application); final CondomContext condom_context = CondomContext.wrap(context, TAG); final Context condom_app_context = condom_context.getApplicationContext(); assertTrue(condom_app_context instanceof Application); assertNotSame(app_context, condom_app_context); assertTrue(((Application) condom_app_context).getBaseContext() instanceof CondomContext); }
/** * Assuming the given cache has maximum size {@code maxSize}, this method populates the cache (by * getting a bunch of different keys), then makes sure all the items in the cache are also in the * eviction queue. It will invoke the given {@code operation} on the first element in the eviction * queue, and then reverify that all items in the cache are in the eviction queue, and verify that * the head of the eviction queue has changed as a result of the operation. */ static void checkRecency( LoadingCache<Integer, Integer> cache, int maxSize, Receiver<ReferenceEntry<Integer, Integer>> operation) { checkNotNull(operation); if (hasLocalCache(cache)) { warmUp(cache, 0, 2 * maxSize); LocalCache<Integer, Integer> cchm = toLocalCache(cache); Segment<?, ?> segment = cchm.segments[0]; drainRecencyQueue(segment); assertEquals(maxSize, accessQueueSize(cache)); assertEquals(maxSize, cache.size()); ReferenceEntry<?, ?> originalHead = segment.accessQueue.peek(); @SuppressWarnings("unchecked") ReferenceEntry<Integer, Integer> entry = (ReferenceEntry) originalHead; operation.accept(entry); drainRecencyQueue(segment); assertNotSame(originalHead, segment.accessQueue.peek()); assertEquals(cache.size(), accessQueueSize(cache)); } }
Assert.assertNotSame("The inserted model should not exist in the original list", oldModel.id(), expected.id()); .assertNotSame("Incorrectly updated an item.", model.hashCode(), expected.hashCode()); } else { assertEquals("Models should have same hashcode when not updated",
@Test public void modelClickListenerOverridesViewClickListener() { final ModelWithClickListener_ model = new ModelWithClickListener_(); TestController controller = new TestController(); controller.setModel(model); ViewClickListener viewClickListener = new ViewClickListener(); model.clickListener(viewClickListener); assertNotNull(model.clickListener()); ModelClickListener modelClickListener = new ModelClickListener(); model.clickListener(modelClickListener); assertNotSame(model.clickListener(), viewClickListener); lifecycleHelper.buildModelsAndBind(controller); mockModelForClicking(model); assertNotNull(model.clickListener()); View viewMock = mockModelForClicking(model); model.clickListener().onClick(viewMock); assertTrue(modelClickListener.clicked); assertFalse(viewClickListener.clicked); }
@Test public void deleteRealtimeSegmentFromGetAPI() throws Exception { long currRealtimeRows = numRowsReturned(CommonConstants.Helix.TableType.REALTIME); String segmentList = sendGetRequest(_controllerRequestURLBuilder. forSegmentListAPIWithTableType(TABLE_NAME, CommonConstants.Helix.TableType.REALTIME.toString())); JsonNode realtimeSegmentsList = getSegmentsFromJsonSegmentAPI(segmentList, CommonConstants.Helix.TableType.REALTIME.toString()); String removedSegment = realtimeSegmentsList.get(0).asText(); long removedSegmentRows = getNumRowsFromRealtimeMetadata(removedSegment); Assert.assertNotSame(removedSegmentRows, 0L); sendGetRequest(_controllerRequestURLBuilder. forDeleteSegmentWithGetAPI(TABLE_NAME, removedSegment, CommonConstants.Helix.TableType.REALTIME.toString())); waitForNumRows(currRealtimeRows - removedSegmentRows, CommonConstants.Helix.TableType.REALTIME); String postDeleteSegmentList = sendGetRequest(_controllerRequestURLBuilder .forSegmentListAPIWithTableType(TABLE_NAME, CommonConstants.Helix.TableType.REALTIME.toString())); JsonNode realtimeSegmentsListReturn = getSegmentsFromJsonSegmentAPI(postDeleteSegmentList, CommonConstants.Helix.TableType.REALTIME.toString()); removeValue(realtimeSegmentsList, removedSegment); Assert.assertEquals(realtimeSegmentsListReturn, realtimeSegmentsList); }
@Test public void deleteRealtimeSegmentFromDeleteAPI() throws Exception { long currRealtimeRows = numRowsReturned(CommonConstants.Helix.TableType.REALTIME); String segmentList = sendGetRequest(_controllerRequestURLBuilder .forSegmentListAPIWithTableType(TABLE_NAME, CommonConstants.Helix.TableType.REALTIME.toString())); JsonNode realtimeSegmentsList = getSegmentsFromJsonSegmentAPI(segmentList, CommonConstants.Helix.TableType.REALTIME.toString()); String removedSegment = realtimeSegmentsList.get(0).asText(); long removedSegmentRows = getNumRowsFromRealtimeMetadata(removedSegment); Assert.assertNotSame(removedSegmentRows, 0L); sendDeleteRequest(_controllerRequestURLBuilder. forSegmentDeleteAPI(TABLE_NAME, removedSegment, CommonConstants.Helix.TableType.REALTIME.toString())); waitForNumRows(currRealtimeRows - removedSegmentRows, CommonConstants.Helix.TableType.REALTIME); String postDeleteSegmentList = sendGetRequest(_controllerRequestURLBuilder .forSegmentListAPIWithTableType(TABLE_NAME, CommonConstants.Helix.TableType.REALTIME.toString())); JsonNode realtimeSegmentsListReturn = getSegmentsFromJsonSegmentAPI(postDeleteSegmentList, CommonConstants.Helix.TableType.REALTIME.toString()); removeValue(realtimeSegmentsList, removedSegment); Assert.assertEquals(realtimeSegmentsListReturn, realtimeSegmentsList); }
@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); } });
Assert.assertNotSame(removedSegmentRows, 0L);
@Test public void testMetricsPublisherReset() { // precondition: HystrixMetricsPublisherFactory class is not loaded. Calling HystrixPlugins.reset() here should be good enough to run this with other tests. // set first custom publisher HystrixCommandKey key = HystrixCommandKey.Factory.asKey("key"); HystrixMetricsPublisherCommand firstCommand = new HystrixMetricsPublisherCommandDefault(key, null, null, null, null); HystrixMetricsPublisher firstPublisher = new CustomPublisher(firstCommand); HystrixPlugins.getInstance().registerMetricsPublisher(firstPublisher); // ensure that first custom publisher is used HystrixMetricsPublisherCommand cmd = HystrixMetricsPublisherFactory.createOrRetrievePublisherForCommand(key, null, null, null, null); assertSame(firstCommand, cmd); // reset, then change to second custom publisher HystrixPlugins.reset(); HystrixMetricsPublisherCommand secondCommand = new HystrixMetricsPublisherCommandDefault(key, null, null, null, null); HystrixMetricsPublisher secondPublisher = new CustomPublisher(secondCommand); HystrixPlugins.getInstance().registerMetricsPublisher(secondPublisher); // ensure that second custom publisher is used cmd = HystrixMetricsPublisherFactory.createOrRetrievePublisherForCommand(key, null, null, null, null); assertNotSame(firstCommand, cmd); assertSame(secondCommand, cmd); }