Java Code Examples for junit.framework.Assert#assertNotSame()

The following examples show how to use junit.framework.Assert#assertNotSame() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Test cached session when the transport.jms.CacheLevel is 2
 *
 * @throws Exception
 */
@Test
public void testCacheLevelTwo() throws Exception {
    String queueName = "testCaching2";
    Properties jmsProperties = JMSTestsUtils.getJMSPropertiesForDestination(queueName, PROVIDER_URL, true);
    JMSBrokerController brokerController = new JMSBrokerController(PROVIDER_URL, jmsProperties);
    jmsProperties.put(JMSConstants.PARAM_CACHE_LEVEL, "2");
    try {
        brokerController.startProcess();
        Queue queue = brokerController.connect(queueName, true);
        CachedJMSConnectionFactory cachedJMSConnectionFactory = new CachedJMSConnectionFactory(jmsProperties);
        Connection connection1 = cachedJMSConnectionFactory.getConnection(null, null);
        Session session1 = cachedJMSConnectionFactory.getSession(connection1);
        MessageConsumer consumer1 = cachedJMSConnectionFactory.getMessageConsumer(session1, queue);
        Connection connection2 = cachedJMSConnectionFactory.getConnection(null, null);
        Session session2 = cachedJMSConnectionFactory.getSession(connection2);
        MessageConsumer consumer2 = cachedJMSConnectionFactory.getMessageConsumer(session2, queue);
        Assert.assertEquals("Connection should be cached", connection1.getClientID(), connection2.getClientID());
        Assert.assertEquals("Session should be cached", session1, session2);
        Assert.assertNotSame("Message Consumer should not be cached", ((ActiveMQMessageConsumer) consumer1).
                getConsumerId().toString(), ((ActiveMQMessageConsumer) consumer2).getConsumerId().toString());
    } finally {
        brokerController.disconnect();
        brokerController.stopProcess();
    }
}
 
Example 2
@Test
public void clearFilters() {
    final List<Person> listOfPersons = getListOfPersons(100);
    FilterableListContainer<Person> container = new FilterableListContainer<>(
            listOfPersons);
    container.addContainerFilter(new SimpleStringFilter("firstName",
            "First1", true, true));
    Assert.assertNotSame(listOfPersons.size(), container.size());
    container.removeAllContainerFilters();
    Assert.assertEquals(listOfPersons.size(), container.size());
    container.addContainerFilter(new SimpleStringFilter("firstName",
            "foobar", true, true));
    Assert.assertEquals(0, container.size());

    final MutableBoolean fired = new MutableBoolean(false);
    container.addListener(new Container.ItemSetChangeListener() {
        @Override
        public void containerItemSetChange(
                Container.ItemSetChangeEvent event) {
            fired.setTrue();
        }
    });
    container.removeAllContainerFilters();
    Assert.assertTrue(fired.booleanValue());
    Assert.assertEquals(listOfPersons.size(), container.size());
}
 
Example 3
@Test
public void testMergeHashTemplate() {
    HashMap map = new HashMap();
    map.put("key", "value");
    LocationTemplate tpl = new HashMapLocationTemplate(map);

    Config config = new Config();
    config.setTemplate(tpl);

    Config merged = Config.merge(config, new Config());
    map.put("key", "othervalue");

    Assert.assertNotSame(config, merged);
    Assert.assertNotSame(config.getTemplate(), merged.getTemplate());
    Assert.assertEquals("value", ((HashMapLocationTemplate)merged.getTemplate()).get("key"));
    Assert.assertEquals("othervalue", ((HashMapLocationTemplate)config.getTemplate()).get("key"));
}
 
Example 4
/**
 * 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);
}
 
Example 5
/**
 * Test cached connection when the transport.jms.CacheLevel is 1
 *
 * @throws Exception
 */
@Test
public void testCacheLevelOne() throws Exception {
    String queueName = "testCaching1";
    Properties jmsProperties = JMSTestsUtils.getJMSPropertiesForDestination(queueName, PROVIDER_URL, true);
    JMSBrokerController brokerController = new JMSBrokerController(PROVIDER_URL, jmsProperties);
    jmsProperties.put(JMSConstants.PARAM_CACHE_LEVEL, "1");
    try {
        brokerController.startProcess();
        Queue queue = brokerController.connect(queueName, true);
        CachedJMSConnectionFactory cachedJMSConnectionFactory = new CachedJMSConnectionFactory(jmsProperties);
        Connection connection1 = cachedJMSConnectionFactory.getConnection(null, null);
        String clientID1 = connection1.getClientID();
        Session session1 = cachedJMSConnectionFactory.getSession(connection1);
        MessageConsumer consumer1 = cachedJMSConnectionFactory.getMessageConsumer(session1, queue);
        Connection connection2 = cachedJMSConnectionFactory.getConnection(null, null);
        Session session2 = cachedJMSConnectionFactory.getSession(connection2);
        MessageConsumer consumer2 = cachedJMSConnectionFactory.getMessageConsumer(session2, queue);
        Assert.assertEquals("Connection should be cached", clientID1, connection2.getClientID());
        Assert.assertNotSame("Session should not be cached", session1, session2);
        Assert.assertNotSame("Message Consumer should not be cached", ((ActiveMQMessageConsumer) consumer1).
                getConsumerId().toString(), ((ActiveMQMessageConsumer) consumer2).getConsumerId().toString());
        cachedJMSConnectionFactory.closeConnection();
        Connection connection3 = cachedJMSConnectionFactory.getConnection(null, null);
        Assert.assertNotSame("Connection should be closed", clientID1, connection3.getClientID());
    } finally {
        brokerController.disconnect();
        brokerController.stopProcess();
    }
}
 
Example 6
Source Project: pandroid   File: EventUnitTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDeliveryPolicyUnchecked() {
    String test = "testDeliveryPolicyUnchecked";
    eventBusManager.sendSync(test, null);
    eventBusManager.registerReceiver(taggedListener);
    Assert.assertNotSame(resultObject, test);
}
 
Example 7
public static void verifyUpdaterThreadIsAlive() throws InterruptedException
{
  QueueConnectionImpl conn2 = (QueueConnectionImpl) pool.getPrimaryConnection();
  Assert.assertNotSame(conn1, conn2);
  Assert.assertFalse(conn1.getServer().equals(conn2.getServer()));
  assertNull(((QueueConnectionImpl)conn1).getUpdater());
  assertTrue((conn2).getUpdater().isAlive());
}
 
Example 8
@Test
public void testCopyToFolder() throws Exception {
	User user = userDao.findByUsername("admin");
	Document doc = docDao.findById(1);
	Assert.assertNotNull(doc);
	Folder folder = doc.getFolder();
	Assert.assertEquals(6, folder.getId());

	DocumentHistory transaction = new DocumentHistory();
	transaction.setFolderId(103L);
	transaction.setUser(user);
	transaction.setDocId(doc.getId());
	transaction.setUserId(1L);
	transaction.setNotified(0);
	transaction.setComment("pippo_reason");
	transaction.setFilename(doc.getFileName());

	Folder newFolder = folderDao.findById(6);
	docDao.initialize(doc);

	DummyStorer storer = (DummyStorer) Context.get().getBean(Storer.class);
	try {
		storer.setUseDummyFile(true);
		Document newDoc = documentManager.copyToFolder(doc, newFolder, transaction);
		Assert.assertNotSame(doc.getId(), newDoc.getId());
		Assert.assertEquals(newFolder, newDoc.getFolder());
	} finally {
		storer.setUseDummyFile(false);
	}
}
 
Example 9
@Test
public void testUpdate() throws GeomajasException, ParseException {
	// test updating geometry and name
	WKTReader wktReader = new WKTReader();
	Point geometry = (Point) wktReader.read("POINT (100 0)");
	SimpleFeatureBuilder build = new SimpleFeatureBuilder(pointLayer.getSchema());
	SimpleFeature feature = build.buildFeature("POINT.4", new Object[] { "point44", geometry });
	pointLayer.update(feature);
	SimpleFeature point4 = (SimpleFeature) pointLayer.read("POINT.4");
	Assert.assertEquals("point44", point4.getAttribute("NAME"));
	Assert.assertNotSame(geometry, point4.getDefaultGeometry());
	Assert.assertTrue(geometry.equalsTopo((Geometry) point4.getDefaultGeometry()));
}
 
Example 10
public void testReadOnlySerializationOfNewObject()
{
    final ParaDesk newDesk = new ParaDesk();
    Assert.assertFalse(newDesk instanceof MithraTransactionalObject);  // i.e. "read only"
    Assert.assertFalse(newDesk instanceof MithraDatedObject);  // i.e. "not dated"
    newDesk.setDeskIdString("tis");
    newDesk.setActiveBoolean(false);
    newDesk.setSizeDoubleNull();
    newDesk.setConnectionLong(123456);
    newDesk.setTagInt(4);
    newDesk.setStatusChar('X');
    newDesk.setCreateTimestamp(new Timestamp(1000000));
    newDesk.setLocationByte((byte)8);
    newDesk.setClosedDate(new Date(1002000));
    newDesk.setMaxFloat((float)128.64);
    newDesk.setMinShort((short)2);

    final ParaDesk copyOfNewDesk = (ParaDesk) serializeAndDeserialize(newDesk);
    Assert.assertNotSame(newDesk, copyOfNewDesk);
    Assert.assertEquals(newDesk.getDeskIdString()   , copyOfNewDesk.getDeskIdString());
    Assert.assertEquals(newDesk.isActiveBoolean()   , copyOfNewDesk.isActiveBoolean());
    Assert.assertTrue(copyOfNewDesk.isSizeDoubleNull());
    Assert.assertEquals(newDesk.getConnectionLong() , copyOfNewDesk.getConnectionLong());
    Assert.assertEquals(newDesk.getTagInt()         , copyOfNewDesk.getTagInt());
    Assert.assertEquals(newDesk.getStatusChar()     , copyOfNewDesk.getStatusChar());
    Assert.assertEquals(newDesk.getCreateTimestamp(), copyOfNewDesk.getCreateTimestamp());
    Assert.assertEquals(newDesk.getLocationByte()   , copyOfNewDesk.getLocationByte());
    Assert.assertEquals(newDesk.getClosedDate()     , copyOfNewDesk.getClosedDate());
    Assert.assertEquals(newDesk.getMaxFloat()       , copyOfNewDesk.getMaxFloat(), 0.0);
    Assert.assertEquals(newDesk.getMinShort()       , copyOfNewDesk.getMinShort());
}
 
Example 11
Source Project: mrgeo   File: ColorScaleResourceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@Category(UnitTest.class)
public void testGetColorScaleSwatchMissingColorScale() throws Exception
{
  Mockito.when(
      service.createColorScaleSwatch(Mockito.anyString(), Mockito.anyString(), Mockito.anyInt(), Mockito.anyInt()))
      .thenAnswer(new Answer()
      {
        public Object answer(InvocationOnMock invocation) throws MrsPyramidServiceException
        {
          throw new MrsPyramidServiceException("Base path \"" + invocation.getArguments()[0] + "\" does not exist.");
        }
      });

  ImageResponseWriter writer = new PngImageResponseWriter();
  Mockito.when(service.getImageResponseWriter(Mockito.anyString())).thenReturn(writer);

  String path = "/mrgeo/test-files/output/org.mrgeo.resources.raster.mrspyramid/ColorScaleResourceTest/missing.xml";

  Response response = target("colorscales/" + path)
      .queryParam("width", "100")
      .queryParam("height", "10")
      .request().get();

  Assert.assertNotSame("image/png", response.getHeaderString("Content-Type"));
  Assert.assertEquals(400, response.getStatus());
  Assert.assertEquals("Color scale file not found: " + path, response.readEntity(String.class));
}
 
Example 12
Source Project: epoxy   File: DifferCorrectnessTest.java    License: Apache License 2.0 5 votes vote down vote up
private void checkDiff(List<TestModel> modelsBeforeDiff, List<TestModel> modelsAfterDiff,
    List<TestModel> actualModels) {
  assertEquals("Diff produces list of different size.", actualModels.size(),
      modelsAfterDiff.size());

  for (int i = 0; i < modelsAfterDiff.size(); i++) {
    TestModel model = modelsAfterDiff.get(i);
    final TestModel expected = actualModels.get(i);

    if (model == InsertedModel.INSTANCE) {
      // If the item at this index is new then it shouldn't exist in the original list
      for (TestModel oldModel : modelsBeforeDiff) {
        Assert.assertNotSame("The inserted model should not exist in the original list",
            oldModel.id(), expected.id());
      }
    } else {
      assertEquals("Models at same index should have same id", expected.id(), model.id());

      if (model.updated) {
        // If there was a change operation then the item hashcodes should be different
        Assert
            .assertNotSame("Incorrectly updated an item.", model.hashCode(), expected.hashCode());
      } else {
        assertEquals("Models should have same hashcode when not updated",
            expected.hashCode(), model.hashCode());
      }

      // Clear state so the model can be used again in another diff
      model.updated = false;
    }
  }
}
 
Example 13
Source Project: pandroid   File: SecurityTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testEncryptionManager() {
    RsaAesCryptoManager rsaAesCryptoManager = new RsaAesCryptoManager(activityRule.getActivity(), PandroidLogger.getInstance());
    String key = UUID.randomUUID().toString();
    String value = UUID.randomUUID().toString();

    String encryptedValue = rsaAesCryptoManager.symetricEncrypt(key, value);
    Assert.assertNotSame(value, encryptedValue);
    Assert.assertEquals(value, rsaAesCryptoManager.symetricDecrypt(key, encryptedValue));


    encryptedValue = rsaAesCryptoManager.asymmetricEncrypt(value);
    Assert.assertNotSame(value, encryptedValue);
    Assert.assertEquals(value, rsaAesCryptoManager.asymmetricDecrypt(encryptedValue));
}
 
Example 14
@Test
public void testMonitorFactoryGroupCache() throws Exception {
    Monitor monitor1 = monitorFactory.getMonitor(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa"));
    Monitor monitor2 = monitorFactory.getMonitor(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb"));
    Assert.assertNotSame(monitor1, monitor2);
}
 
Example 15
@Test
  public void importEOSWalletBySinglePrvKey() {
//    owner key: 5Jnx4Tv6iu5fyq9g3aKmKsEQrhe7rJZkJ4g3LTK5i7tBDitakvP
//    active key: 5JK2n2ujYXsooaqbfMQqxxd8P7xwVNDaajTuqRagJNGPi88yPGw
//    active key: 5J25CphXSMh2SUdjspX7M4sLT5QATkTXJhiGSMn4nwg1HbhHLRe

    List<String> prvKeys = new ArrayList<>(3);
    prvKeys.add("5Jnx4Tv6iu5fyq9g3aKmKsEQrhe7rJZkJ4g3LTK5i7tBDitakvP");
    prvKeys.add("5JK2n2ujYXsooaqbfMQqxxd8P7xwVNDaajTuqRagJNGPi88yPGw");
    prvKeys.add("5J25CphXSMh2SUdjspX7M4sLT5QATkTXJhiGSMn4nwg1HbhHLRe");
    Metadata meta = eosMetadata();
    meta.setSource(Metadata.FROM_WIF);

    List<EOSKeystore.PermissionObject> permissionObjects = new ArrayList<>();
    EOSKeystore.PermissionObject permObj = new EOSKeystore.PermissionObject();
    permObj.setPublicKey("EOS621QecaYWvdKdCvHJRo76fvJwTo1Y4qegPnKxsf3FJ5zm2pPru");
    permObj.setPermission("owner");
    permissionObjects.add(permObj);

    permObj = new EOSKeystore.PermissionObject();
    permObj.setPublicKey("EOS6qTGVvgoT39AAJp1ykty8XVDFv1GfW4QoS4VyjfQQPv5ziMNzF");
    permObj.setPermission("active");
    permissionObjects.add(permObj);

    permObj = new EOSKeystore.PermissionObject();
    permObj.setPublicKey("EOS877B3gaJytVzFizhWPD26SefS9QV1qYTZT2QCcXueQfV4PAN8h");
    permObj.setPermission("sns");
    permissionObjects.add(permObj);

    Wallet wallet = WalletManager.importWalletFromPrivateKeys(meta, ACCOUNT_NAME, prvKeys, permissionObjects, SampleKey.PASSWORD, true);
    Assert.assertEquals(ChainType.EOS, wallet.getMetadata().getChainType());
    Assert.assertEquals(Metadata.FROM_WIF, wallet.getMetadata().getSource());
    Assert.assertNotSame(0L, wallet.getCreatedAt());
    Assert.assertEquals(ACCOUNT_NAME, wallet.getAddress());
    List<String> expectedPubKeys = new ArrayList<>();
    expectedPubKeys.add("EOS621QecaYWvdKdCvHJRo76fvJwTo1Y4qegPnKxsf3FJ5zm2pPru");
    expectedPubKeys.add("EOS6qTGVvgoT39AAJp1ykty8XVDFv1GfW4QoS4VyjfQQPv5ziMNzF");
    expectedPubKeys.add("EOS877B3gaJytVzFizhWPD26SefS9QV1qYTZT2QCcXueQfV4PAN8h");
    List<String> publicKeys = new ArrayList<>(3);
    for (EOSKeystore.KeyPathPrivate keyPathPrivate : wallet.getKeyPathPrivates()) {
      publicKeys.add(keyPathPrivate.getPublicKey());
    }
    Assert.assertTrue(Arrays.equals(expectedPubKeys.toArray(), publicKeys.toArray()));
  }
 
Example 16
@Test
public void testChangePassword() {
	Assert.assertEquals(0, service.changePassword(1L, 1L, "admin", "test", false));
	Assert.assertEquals(0, service.changePassword(1L, 1L, "test", "admin", false));
	Assert.assertNotSame(0, service.changePassword(1L, 1L, "xxxxx", "test", false));
}
 
Example 17
@Test
public void testMonitorFactoryGroupCache() throws Exception {
    Monitor monitor1 = monitorFactory.getMonitor(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa"));
    Monitor monitor2 = monitorFactory.getMonitor(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb"));
    Assert.assertNotSame(monitor1, monitor2);
}
 
Example 18
@Test
public void testRegistryFactoryGroupCache() throws Exception {
    Registry registry1 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa"));
    Registry registry2 = registryFactory.getRegistry(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb"));
    Assert.assertNotSame(registry1, registry2);
}
 
Example 19
@Test
public void testMonitorFactoryGroupCache() throws Exception {
    Monitor monitor1 = monitorFactory.getMonitor(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=aaa"));
    Monitor monitor2 = monitorFactory.getMonitor(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":2233?group=bbb"));
    Assert.assertNotSame(monitor1, monitor2);
}
 
Example 20
Source Project: JTAF-XCore   File: IgnoreErrorsAssert.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Asserts that two objects do not refer to the same object. If they are
 * not, a Throwable is stored in the accumulator with the given message.
 * 
 * @param message
 *            message to be thrown if they are the same
 * @param expected
 *            expected object
 * @param actual
 *            actual object that is being checked
 */
@SuppressWarnings("deprecation")
public void assertNotSame(String message, Object expected, Object actual) {
    try {
        Assert.assertNotSame(message, expected, actual);
    } catch (Throwable e) {
        ea.addError(e);
    }

}