Java Code Examples for junit.framework.Assert.assertSame()

The following are Jave code examples for showing how to use assertSame() of the junit.framework.Assert class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: CloseableBitmapTest.java   View Source Code Vote up 6 votes
@Test
public void testBasic() throws Exception {
  Assert.assertFalse(mCloseableStaticBitmap.isClosed());
  Assert.assertSame(mBitmap, mCloseableStaticBitmap.getUnderlyingBitmap());

  // close it now
  mCloseableStaticBitmap.close();
  Assert.assertTrue(mCloseableStaticBitmap.isClosed());
  Assert.assertNull(mCloseableStaticBitmap.getUnderlyingBitmap());
  verify(mResourceReleaser).release(mBitmap);

  // close it again
  mCloseableStaticBitmap.close();
  Assert.assertTrue(mCloseableStaticBitmap.isClosed());
  Assert.assertNull(mCloseableStaticBitmap.getUnderlyingBitmap());
}
 
Example 2
Project: fuck_zookeeper   File: ReadOnlyModeTest.java   View Source Code Vote up 6 votes
/**
 * Tests a situation when client firstly connects to a read-only server and
 * then connects to a majority server. Transition should be transparent for
 * the user.
 */
@Test(timeout = 90000)
public void testSessionEstablishment() throws Exception {
    qu.shutdown(2);

    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
            watcher, true);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    Assert.assertSame("should be in r/o mode", States.CONNECTEDREADONLY, zk
            .getState());
    long fakeId = zk.getSessionId();

    watcher.reset();
    qu.start(2);
    Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
            "127.0.0.1:" + qu.getPeer(2).clientPort, CONNECTION_TIMEOUT));
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    zk.create("/test", "test".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    Assert.assertFalse("fake session and real session have same id", zk
            .getSessionId() == fakeId);

    zk.close();
}
 
Example 3
Project: aws-sdk-java-v2   File: BatchWriteRetryStrategyTest.java   View Source Code Vote up 6 votes
@Test
public void testExceptionThrown_NoRetry() {

    RuntimeException exception = new RuntimeException("BOOM");

    when(ddbMock.batchWriteItem(any(BatchWriteItemRequest.class))).thenThrow(exception);

    // put a random item
    Item item = new Item(UUID.randomUUID().toString());
    List<FailedBatch> failedBatches = mapper.batchSave(item);

    Assert.assertEquals(1, failedBatches.size());
    FailedBatch failedBatch = failedBatches.get(0);

    Assert.assertEquals(
            "Failed batch should contain all the input items for batchWrite",
            Collections.singletonMap(TABLE_NAME, Arrays.asList(item.toPutSaveRequest())),
            failedBatch.getUnprocessedItems());
    Assert.assertSame(
            "The exception should be the same as one thrown by BatchWriteItem",
            exception,
            failedBatch.getException());
}
 
Example 4
Project: flume-release-1.7.0   File: TestAbstractConfigurationProvider.java   View Source Code Vote up 6 votes
@Test
public void testReusableChannel() throws Exception {
  String agentName = "agent1";
  Map<String, String> properties = getPropertiesForChannel(agentName,
                                                           RecyclableChannel.class.getName());
  MemoryConfigurationProvider provider =
      new MemoryConfigurationProvider(agentName, properties);

  MaterializedConfiguration config1 = provider.getConfiguration();
  Channel channel1 = config1.getChannels().values().iterator().next();
  Assert.assertTrue(channel1 instanceof RecyclableChannel);

  MaterializedConfiguration config2 = provider.getConfiguration();
  Channel channel2 = config2.getChannels().values().iterator().next();
  Assert.assertTrue(channel2 instanceof RecyclableChannel);

  Assert.assertSame(channel1, channel2);
}
 
Example 5
Project: flume-release-1.7.0   File: TestAbstractConfigurationProvider.java   View Source Code Vote up 6 votes
@Test
public void testUnspecifiedChannel() throws Exception {
  String agentName = "agent1";
  Map<String, String> properties = getPropertiesForChannel(agentName,
                                                           UnspecifiedChannel.class.getName());
  MemoryConfigurationProvider provider =
      new MemoryConfigurationProvider(agentName, properties);

  MaterializedConfiguration config1 = provider.getConfiguration();
  Channel channel1 = config1.getChannels().values().iterator().next();
  Assert.assertTrue(channel1 instanceof UnspecifiedChannel);

  MaterializedConfiguration config2 = provider.getConfiguration();
  Channel channel2 = config2.getChannels().values().iterator().next();
  Assert.assertTrue(channel2 instanceof UnspecifiedChannel);

  Assert.assertSame(channel1, channel2);
}
 
Example 6
Project: ZooKeeper   File: ReadOnlyModeTest.java   View Source Code Vote up 6 votes
/**
 * Tests a situation when client firstly connects to a read-only server and
 * then connects to a majority server. Transition should be transparent for
 * the user.
 */
@Test(timeout = 90000)
public void testSessionEstablishment() throws Exception {
    qu.shutdown(2);

    CountdownWatcher watcher = new CountdownWatcher();
    ZooKeeper zk = new ZooKeeper(qu.getConnString(), CONNECTION_TIMEOUT,
            watcher, true);
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    Assert.assertSame("should be in r/o mode", States.CONNECTEDREADONLY, zk
            .getState());
    long fakeId = zk.getSessionId();

    watcher.reset();
    qu.start(2);
    Assert.assertTrue("waiting for server up", ClientBase.waitForServerUp(
            "127.0.0.1:" + qu.getPeer(2).clientPort, CONNECTION_TIMEOUT));
    watcher.waitForConnected(CONNECTION_TIMEOUT);
    zk.create("/test", "test".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    Assert.assertFalse("fake session and real session have same id", zk
            .getSessionId() == fakeId);

    zk.close();
}
 
Example 7
Project: github-test   File: ForkingClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    ForkingClusterInvoker<ForkingClusterInvokerTest> invoker = new ForkingClusterInvoker<ForkingClusterInvokerTest>(
            dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 8
Project: dubbocloud   File: FailfastClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test(expected = RpcException.class)
public void testInvokeExceptoin() {
    resetInvoker1ToException();
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    invoker.invoke(invocation);
    Assert.assertSame(invoker1, RpcContext.getContext().getInvoker());
}
 
Example 9
Project: EatDubbo   File: FailfastClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test(expected = RpcException.class)
public void testInvokeExceptoin() {
    resetInvoker1ToException();
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    invoker.invoke(invocation);
    Assert.assertSame(invoker1, RpcContext.getContext().getInvoker());
}
 
Example 10
Project: EatDubbo   File: FailfastClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvoker1ToNoException();
    
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 11
Project: EatDubbo   File: ForkingClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    ForkingClusterInvoker<ForkingClusterInvokerTest> invoker = new ForkingClusterInvoker<ForkingClusterInvokerTest>(
                                                                                                                    dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 12
Project: EatDubbo   File: FailSafeClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 13
Project: dubbo2   File: FailbackClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>(
                                                                                                                        dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 14
Project: dubbo2   File: FailfastClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test(expected = RpcException.class)
public void testInvokeExceptoin() {
    resetInvoker1ToException();
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    invoker.invoke(invocation);
    Assert.assertSame(invoker1, RpcContext.getContext().getInvoker());
}
 
Example 15
Project: dubbo2   File: FailfastClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {
    
    resetInvoker1ToNoException();
    
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 16
Project: github-test   File: FailSafeClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 17
Project: dubbocloud   File: ForkingClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    ForkingClusterInvoker<ForkingClusterInvokerTest> invoker = new ForkingClusterInvoker<ForkingClusterInvokerTest>(
                                                                                                                    dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}
 
Example 18
Project: guava-mock   File: MockFutureListener.java   View Source Code Vote up 5 votes
/**
 * 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());
  }
}
 
Example 19
Project: JavaGraph   File: STSTest.java   View Source Code Vote up 5 votes
/**
 * Tests hostGraphToStartLocation.
 */
public void testHostGraphToStartLocation() {
    Location l = this.sts.hostGraphToStartLocation(this.g2);
    Assert.assertSame(this.sts.getCurrentLocation(), l);
    Assert.assertSame(this.sts.getStartLocation(), l);

    LocationVariable v = this.sts.getLocationVariable(this.e2[1]);
    Assert.assertNotNull(v);
}
 
Example 20
Project: github-test   File: FailbackClusterInvokerTest.java   View Source Code Vote up 5 votes
@Test()
public void testInvokeNoExceptoin() {

    resetInvokerToNoException();

    FailbackClusterInvoker<FailbackClusterInvokerTest> invoker = new FailbackClusterInvoker<FailbackClusterInvokerTest>(
            dic);
    Result ret = invoker.invoke(invocation);
    Assert.assertSame(result, ret);
}