Java Code Examples for org.junit.Assert.assertNotSame()

The following are Jave code examples for showing how to use assertNotSame() of the org.junit.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: dubbocloud   File: RegistryProtocolTest.java   View Source Code Vote up 6 votes
@Test
public void testExport() {
    RegistryProtocol registryProtocol = new RegistryProtocol();
    registryProtocol.setCluster(new FailfastCluster());
    registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension());

    Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
    registryProtocol.setProtocol(dubboProtocol);
    URL newRegistryUrl = registryUrl.addParameter(Constants.EXPORT_KEY, serviceUrl);
    DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class,
            newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) });
    Exporter<DemoService> exporter = registryProtocol.export(invoker);
    Exporter<DemoService> exporter2 = registryProtocol.export(invoker);
    //同一个invoker,多次export的exporter不同
    Assert.assertNotSame(exporter, exporter2);
    exporter.unexport();
    exporter2.unexport();
    
}
 
Example 2
Project: jrpip   File: VmBoundServiceTest.java   View Source Code Vote up 6 votes
public void testVmBoundEcho() throws Exception
{
    this.setupServer();

    FastServletProxyFactory fspf = new FastServletProxyFactory();
    fspf.setUseLocalService(false);
    Echo echo = fspf.create(Echo.class, "http://localhost:" + PORT + "/JrpipServlet");
    Assert.assertNotSame(echo.getClass(), EchoImpl.class);
    Assert.assertEquals("hello", echo.echo("hello"));
    Assert.assertEquals("goodbye", echo.echo("goodbye"));
    Thread.sleep(600L);
    Assert.assertTrue(this.servlet.getThankYous() > 0);

    this.tearDownServer();
    this.setupServer();

    try
    {
        echo.echo("hello");
        Assert.fail("must not get here");
    }
    catch (JrpipVmBoundException e)
    {
        LOGGER.info("expected exception thrown for testing", e);
    }
}
 
Example 3
Project: java-threading   File: AsyncLazyTest.java   View Source Code Vote up 6 votes
public void testValueFactoryThrowsSynchronously(boolean specifyJff) {
	// use our own so we don't get main thread deadlocks, which isn't the point of this test.
	JoinableFutureFactory jff = specifyJff ? new JoinableFutureContext().getFactory() : null;
	AtomicBoolean executed = new AtomicBoolean(false);
	AsyncLazy<Object> lazy = new AsyncLazy<>(
		() -> {
			Assert.assertFalse(executed.get());
			executed.set(true);
			throw new RuntimeException();
		},
		jff);

	CompletableFuture<? extends Object> future1 = lazy.getValueAsync();
	CompletableFuture<? extends Object> future2 = lazy.getValueAsync();
	Assert.assertNotSame("Futures must be different to isolate cancellation.", future1, future2);
	Assert.assertTrue(future1.isDone());
	Assert.assertTrue(future1.isCompletedExceptionally());
	Assert.assertFalse(future1.isCancelled());

	thrown.expect(CompletionException.class);
	thrown.expectCause(isA(RuntimeException.class));
	future1.join();
}
 
Example 4
Project: hadoop   File: TestApplicatonReport.java   View Source Code Vote up 6 votes
@Test
public void testApplicationReport() {
  long timestamp = System.currentTimeMillis();
  ApplicationReport appReport1 =
      createApplicationReport(1, 1, timestamp);
  ApplicationReport appReport2 =
      createApplicationReport(1, 1, timestamp);
  ApplicationReport appReport3 =
      createApplicationReport(1, 1, timestamp);
  Assert.assertEquals(appReport1, appReport2);
  Assert.assertEquals(appReport2, appReport3);
  appReport1.setApplicationId(null);
  Assert.assertNull(appReport1.getApplicationId());
  Assert.assertNotSame(appReport1, appReport2);
  appReport2.setCurrentApplicationAttemptId(null);
  Assert.assertNull(appReport2.getCurrentApplicationAttemptId());
  Assert.assertNotSame(appReport2, appReport3);
  Assert.assertNull(appReport1.getAMRMToken());
}
 
Example 5
Project: bootstrap   File: AbstractBusinessEntityTest.java   View Source Code Vote up 6 votes
/**
 * Test equals and hash code operation with all possible combinations
 * 
 * @param modelClass
 *            the entity to test.
 * @param idProperties
 *            the list of business key parts.
 * @throws InstantiationException
 *             due to reflection.
 * @throws IllegalAccessException
 *             due to reflection.
 * @throws InvocationTargetException
 *             due to reflection.
 * @param <T>
 *            The type of the entity to test.
 */
protected <T> void testEqualsAndHash(final Class<T> modelClass, final String... idProperties)
		throws InstantiationException, IllegalAccessException, InvocationTargetException {
	final T systemUser = modelClass.newInstance();
	final T systemUser2 = modelClass.newInstance();
	Assert.assertFalse(systemUser.equals(null)); // NOPMD NOSONAR -- for coverage
	Assert.assertEquals(systemUser, systemUser);
	Assert.assertEquals(systemUser, systemUser2);
	Assert.assertFalse(systemUser.equals(1));
	Assert.assertNotSame(0, systemUser.hashCode());

	// Get all identifier combinations
	final List<List<String>> combinations = combinations(idProperties);

	// For each, compute equality and hash code
	testCombinations(modelClass, combinations);

	// Test inheritance "canEqual" if available (as Scala)
	final T mockCanEqual = Mockito.mock(modelClass);
	systemUser.equals(mockCanEqual);
}
 
Example 6
Project: flume-release-1.7.0   File: TestDefaultSourceFactory.java   View Source Code Vote up 6 votes
@Test
public void testDuplicateCreate()  {

  Source avroSource1 = sourceFactory.create("avroSource1", "avro");
  Source avroSource2 = sourceFactory.create("avroSource2", "avro");

  Assert.assertNotNull(avroSource1);
  Assert.assertNotNull(avroSource2);
  Assert.assertNotSame(avroSource1, avroSource2);
  Assert.assertTrue(avroSource1 instanceof AvroSource);
  Assert.assertTrue(avroSource2 instanceof AvroSource);

  Source s1 = sourceFactory.create("avroSource1", "avro");
  Source s2 = sourceFactory.create("avroSource2", "avro");

  Assert.assertNotSame(avroSource1, s1);
  Assert.assertNotSame(avroSource2, s2);

}
 
Example 7
Project: GitHub   File: DynamicDefaultDiskStorageTest.java   View Source Code Vote up 5 votes
@Test
public void testGet_InternalFilesDir() throws Exception {
  File dir = mContext.getFilesDir();

  DynamicDefaultDiskStorage supplier = createInternalFilesDirStorage();

  // initial state
  Assert.assertNull(supplier.mCurrentState.delegate);

  // after first initialization
  DiskStorage storage = supplier.get();
  Assert.assertEquals(storage, supplier.mCurrentState.delegate);
  Assert.assertTrue(storage instanceof DefaultDiskStorage);

  File baseDir = new File(dir, mBaseDirectoryName);
  Assert.assertTrue(baseDir.exists());
  Assert.assertTrue(getStorageSubdirectory(baseDir, 1).exists());

  // no change => should get back the same storage instance
  DiskStorage storage2 = supplier.get();
  Assert.assertEquals(storage, storage2);

  // root directory has been moved (proxy for delete). So we should get back a different instance
  File baseDirOrig = baseDir.getAbsoluteFile();
  Assert.assertTrue(baseDirOrig.renameTo(new File(dir, "dummydir")));
  DiskStorage storage3 = supplier.get();
  Assert.assertNotSame(storage, storage3);
  Assert.assertTrue(storage3 instanceof DefaultDiskStorage);
  Assert.assertTrue(baseDir.exists());
  Assert.assertTrue(getStorageSubdirectory(baseDir, 1).exists());
}
 
Example 8
Project: Byter   File: JmxNetworkManagerTest.java   View Source Code Vote up 5 votes
/**
 * Test change functions on server.
 * @throws IOException IOException
 * @throws IntrospectionException IntrospectionException
 * @throws InstanceNotFoundException InstanceNotFoundException
 * @throws ReflectionException ReflectionException
 */
@Test
public void testInvokeChangeType() throws IOException, IntrospectionException, InstanceNotFoundException, ReflectionException {
    //connect to server
    final JMXConnector connection = JmxConnectionHelper.buildJmxMPConnector(JMXSERVERIP,serverObj.getConnectorSystemPort());
    //get MBeanServerConnection
    MBeanServerConnection mbsConnection = JmxServerHelper.getMBeanServer(connection);
    //check if mbeans are registered
    Assert.assertNotSame(0,mbsConnection.getMBeanCount());
    //get networkManager
    ObjectName networkManagerOn = JmxServerHelper.findObjectName(mbsConnection,"de.b4sh.byter","NetworkManager");
    //list functions
    final List<MBeanOperationInfo> functions = JmxServerHelper.getOperations(mbsConnection,networkManagerOn);
    //do actual test for network
    String networkTypeOld = JmxServerHelper.getNetworkManagerNetworkType(mbsConnection,networkManagerOn);
    String networkResponse = JmxServerHelper.setNetworkManagerNetworkType(mbsConnection,networkManagerOn, NetworkType.BufferedNetwork.getKey());
    Assert.assertNotEquals("",networkResponse);
    log.log(Level.INFO, "TEST: Change Response:" + networkResponse);
    String networkType = JmxServerHelper.getNetworkManagerNetworkType(mbsConnection,networkManagerOn);
    Assert.assertNotEquals(networkType,networkTypeOld);
    //do actual test for writer
    String writerTypeOld = JmxServerHelper.getNetworkManagerWriterType(mbsConnection,networkManagerOn);
    String writerResponse = JmxServerHelper.setNetworkManagerWriterType(mbsConnection,networkManagerOn, WriterType.BufferedWriter.getKey());
    Assert.assertNotEquals("",writerResponse);
    log.log(Level.INFO, "TEST: Change Response:" + writerResponse);
    String writerType = JmxServerHelper.getNetworkManagerWriterType(mbsConnection,networkManagerOn);
    Assert.assertNotEquals(writerType,writerTypeOld);
}
 
Example 9
Project: dubbox-hystrix   File: ReferenceCountExchangeClientTest.java   View Source Code Vote up 5 votes
/**
 * 测试不共享连接
 */
@Test
public void test_not_share_connect(){
    init(1);
    Assert.assertNotSame(demoClient.getLocalAddress(), helloClient.getLocalAddress());
    Assert.assertNotSame(demoClient, helloClient);
    destoy();
}
 
Example 10
Project: vertx-zero   File: AsyncTestBase.java   View Source Code Vote up 5 votes
protected void assertNotSame(final Object unexpected, final Object actual) {
    checkThread();
    try {
        Assert.assertNotSame(unexpected, actual);
    } catch (final AssertionError e) {
        handleThrowable(e);
    }
}
 
Example 11
Project: crnk-framework   File: ProcessInstanceRepositoryTest.java   View Source Code Vote up 5 votes
@Test
public void patchName() {
	ScheduleApprovalProcessInstance processInstance = postProcess(null, null, null);
	processInstance.setName("newName");
	ScheduleApprovalProcessInstance savedProcessInstance = processRepository.save(processInstance);
	Assert.assertEquals("newName", savedProcessInstance.getName());
	Assert.assertNotSame(processInstance, savedProcessInstance);
}
 
Example 12
Project: Byter   File: JmxClientNetworkTest.java   View Source Code Vote up 5 votes
/**
 * change attributes and read them back afterwards.
 * @throws IOException ioe
 */
@Test
public void t2testClientNetworkChangeAttributes() throws IOException {
    //connect to server
    final JMXConnector connection = JmxConnectionHelper.buildJmxMPConnector(JMXSERVERIP,clientObj.getConnectorSystemPort());
    MBeanServerConnection mbs = JmxServerHelper.getMBeanServer(connection);
    Assert.assertNotSame(0,mbs.getMBeanCount());
    ObjectName network = JmxServerHelper.findObjectName(mbs,"de.b4sh.byter","Network");
    Assert.assertNotNull(network);
    //test things here
    final int networkBufferSizeOld = JmxClientNetworkHelper.getNetworkBufferSize(mbs,network);
    JmxClientNetworkHelper.changeNetworkBufferSize(mbs,network,12345);
    final int networkBufferSizeNew = JmxClientNetworkHelper.getNetworkBufferSize(mbs,network);
    Assert.assertNotEquals(networkBufferSizeNew,networkBufferSizeOld);
    Assert.assertEquals(networkBufferSizeNew,12345);

    final String hostaddressOld = JmxClientNetworkHelper.getServerHostAddress(mbs,network);
    JmxClientNetworkHelper.changeServerHostAddress(mbs,network,"127.0.0.1");
    final String hostaddressNew = JmxClientNetworkHelper.getServerHostAddress(mbs,network);
    Assert.assertNotEquals(hostaddressNew,hostaddressOld);
    Assert.assertEquals(hostaddressNew,"127.0.0.1");

    final int hostportOld = JmxClientNetworkHelper.getServerHostPort(mbs,network);
    JmxClientNetworkHelper.changeServerHostPort(mbs,network,80);
    final int hostportNew = JmxClientNetworkHelper.getServerHostPort(mbs,network);
    Assert.assertNotEquals(hostportNew,hostportOld);
    Assert.assertEquals(80,hostportNew);

    final int targetPregenChunkSizeOld = JmxClientNetworkHelper.getTargetPregenChunkSize(mbs,network);
    JmxClientNetworkHelper.changePregenChunkSize(mbs,network,12345);
    final int targetPregenChunkSizeNew = JmxClientNetworkHelper.getTargetPregenChunkSize(mbs,network);
    Assert.assertNotEquals(targetPregenChunkSizeOld,targetPregenChunkSizeNew);
    Assert.assertEquals(12345,targetPregenChunkSizeNew);

    final long transmitTargetOld = JmxClientNetworkHelper.getTransmitTarget(mbs,network);
    JmxClientNetworkHelper.changeTransmitTarget(mbs,network,12345);
    final long transmitTargetNew = JmxClientNetworkHelper.getTransmitTarget(mbs,network);
    Assert.assertNotEquals(transmitTargetNew,transmitTargetOld);
    Assert.assertEquals(transmitTargetNew,12345);
}
 
Example 13
Project: CorePatch   File: DeflateCompressorTest.java   View Source Code Vote up 5 votes
@Test
public void testCreateOrResetDeflater_Uncached() {
  compressor.setCaching(false);
  Deflater deflater1 = compressor.createOrResetDeflater();
  Deflater deflater2 = compressor.createOrResetDeflater();
  Assert.assertNotSame(deflater1, deflater2);
}
 
Example 14
Project: hadoop   File: TestYarnCLI.java   View Source Code Vote up 5 votes
@Test
public void testGetApplicationReportException() throws Exception {
  ApplicationCLI cli = createAndGetAppCLI();
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  when(client.getApplicationReport(any(ApplicationId.class))).thenThrow(
      new ApplicationNotFoundException("History file for application"
          + applicationId + " is not found"));
  int exitCode = cli.run(new String[] { "application", "-status",
      applicationId.toString() });
  verify(sysOut).println(
      "Application with id '" + applicationId
          + "' doesn't exist in RM or Timeline Server.");
  Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
}
 
Example 15
Project: CorePatch   File: QualifiedRecommendationTest.java   View Source Code Vote up 5 votes
@Test
@SuppressWarnings("EqualsIncompatibleType") // For ErrorProne
public void testEquals() {
  Assert.assertEquals(DEFAULT_QUALIFIED_RECOMMENDATION, DEFAULT_QUALIFIED_RECOMMENDATION);
  Assert.assertEquals(DEFAULT_QUALIFIED_RECOMMENDATION, CLONED_DEFAULT_QUALIFIED_RECOMMENDATION);
  Assert.assertNotSame(DEFAULT_QUALIFIED_RECOMMENDATION, CLONED_DEFAULT_QUALIFIED_RECOMMENDATION);
  for (QualifiedRecommendation mutation : ALL_MUTATIONS) {
    Assert.assertNotEquals(DEFAULT_QUALIFIED_RECOMMENDATION, mutation);
  }
  Assert.assertFalse(DEFAULT_QUALIFIED_RECOMMENDATION.equals(null));
  Assert.assertFalse(DEFAULT_QUALIFIED_RECOMMENDATION.equals("foo"));
}
 
Example 16
Project: https-github.com-apache-zookeeper   File: StatTest.java   View Source Code Vote up 5 votes
@Test
public void testDataSizeChange()
    throws IOException, KeeperException, InterruptedException
{
    String name = "/foo";
    zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);

    Stat stat;

    stat = newStat();
    zk.getData(name, false, stat);

    Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
    Assert.assertEquals(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(0, stat.getCversion());
    Assert.assertEquals(0, stat.getVersion());
    Assert.assertEquals(0, stat.getAversion());
    Assert.assertEquals(0, stat.getEphemeralOwner());
    Assert.assertEquals(name.length(), stat.getDataLength());
    Assert.assertEquals(0, stat.getNumChildren());

    zk.setData(name, (name + name).getBytes(), -1);

    stat = newStat();
    zk.getData(name, false, stat);

    Assert.assertNotSame(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
    Assert.assertNotSame(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(0, stat.getCversion());
    Assert.assertEquals(1, stat.getVersion());
    Assert.assertEquals(0, stat.getAversion());
    Assert.assertEquals(0, stat.getEphemeralOwner());
    Assert.assertEquals(name.length() * 2, stat.getDataLength());
    Assert.assertEquals(0, stat.getNumChildren());
}
 
Example 17
Project: ZooKeeper   File: StatTest.java   View Source Code Vote up 5 votes
@Test
public void testDataSizeChange()
    throws IOException, KeeperException, InterruptedException
{
    String name = "/foo";
    zk.create(name, name.getBytes(), Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);

    Stat stat;

    stat = newStat();
    zk.getData(name, false, stat);

    Assert.assertEquals(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
    Assert.assertEquals(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(0, stat.getCversion());
    Assert.assertEquals(0, stat.getVersion());
    Assert.assertEquals(0, stat.getAversion());
    Assert.assertEquals(0, stat.getEphemeralOwner());
    Assert.assertEquals(name.length(), stat.getDataLength());
    Assert.assertEquals(0, stat.getNumChildren());

    zk.setData(name, (name + name).getBytes(), -1);

    stat = newStat();
    zk.getData(name, false, stat);

    Assert.assertNotSame(stat.getCzxid(), stat.getMzxid());
    Assert.assertEquals(stat.getCzxid(), stat.getPzxid());
    Assert.assertNotSame(stat.getCtime(), stat.getMtime());
    Assert.assertEquals(0, stat.getCversion());
    Assert.assertEquals(1, stat.getVersion());
    Assert.assertEquals(0, stat.getAversion());
    Assert.assertEquals(0, stat.getEphemeralOwner());
    Assert.assertEquals(name.length() * 2, stat.getDataLength());
    Assert.assertEquals(0, stat.getNumChildren());
}
 
Example 18
Project: Bytecoder   File: EnumTest.java   View Source Code Vote up 5 votes
@Test
public void testValueOf() {
    Value theEnum = Value.valueOf("THREE");
    Assert.assertEquals("THREE", theEnum.name());
    Assert.assertSame(theEnum, Value.THREE);
    Assert.assertSame(Value.THREE, Value.THREE);
    Value theValue = Value.TWO;
    Assert.assertNotSame(Value.THREE, theValue);
    Assert.assertSame(Value.TWO, theValue);
}
 
Example 19
Project: rskj   File: PrecompiledContractTest.java   View Source Code Vote up 5 votes
@Test
public void getBridgeContractTwice() {
    DataWord bridgeAddress = new DataWord(PrecompiledContracts.BRIDGE_ADDR.getBytes());
    PrecompiledContract bridge1 = PrecompiledContracts.getContractForAddress(ConfigHelper.CONFIG, bridgeAddress);
    PrecompiledContract bridge2 = PrecompiledContracts.getContractForAddress(ConfigHelper.CONFIG, bridgeAddress);

    Assert.assertNotNull(bridge1);
    Assert.assertNotNull(bridge2);
    Assert.assertNotSame(bridge1, bridge2);
}
 
Example 20
Project: ZooKeeper   File: ToStringTest.java   View Source Code Vote up 4 votes
/** Verify jute - which we've had particular problems with in the past 
 * wrt null fields */
@Test
public void testJuteToString() {
    SetDataRequest req = new SetDataRequest(null, null, 0);
    Assert.assertNotSame("ERROR", req.toString());
}