Example usage for junit.framework Assert assertNotSame

List of usage examples for junit.framework Assert assertNotSame

Introduction

In this page you can find the example usage for junit.framework Assert assertNotSame.

Prototype

static public void assertNotSame(Object expected, Object actual) 

Source Link

Document

Asserts that two objects do not refer to the same object.

Usage

From source file:Project2Test.java

@Test
public void objectIdentityNon() {
    Assert.assertNotSame(service.getAnimalName(), "dog");
}

From source file:com.karriem.tp.tddassignment.TDDTestNGTest.java

@Test
public void ObjectSame() {

    Assert.assertNotSame(service.object(), ctx);
}

From source file:ma.glasnost.orika.test.converter.PassThroughConverterTestCase.java

@Test
public void testPassThroughConverter() {

    PassThroughConverter ptc = new PassThroughConverter(A.class);

    MapperFactory factory = MappingUtil.getMapperFactory();

    factory.getConverterFactory().registerConverter(ptc);

    A a = new A();
    a.setId(42L);//  ww  w  .  j a v a 2  s.  co  m
    B b = new B();
    b.setString("Hello");
    C c = new C();
    c.setA(a);
    c.setB(b);

    D d = factory.getMapperFacade().map(c, D.class);

    Assert.assertEquals(c.getA(), d.getA());
    Assert.assertEquals(c.getB(), d.getB());
    Assert.assertSame(c.getA(), d.getA());
    Assert.assertNotSame(c.getB(), d.getB());

}

From source file:ma.glasnost.orika.test.converter.CloneableConverterTestCase.java

@Test
public void cloneableConverter() throws DatatypeConfigurationException {

    CloneableConverter cc = new CloneableConverter(SampleCloneable.class);

    MapperFactory factory = MappingUtil.getMapperFactory();
    factory.getConverterFactory().registerConverter(cc);

    GregorianCalendar cal = new GregorianCalendar();
    cal.add(Calendar.YEAR, 10);//from  www.j av  a  2s.c o  m
    XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance()
            .newXMLGregorianCalendar((GregorianCalendar) cal);
    cal.add(Calendar.MONTH, 3);

    ClonableHolder source = new ClonableHolder();
    source.value = new SampleCloneable();
    source.value.id = 5L;
    source.date = new Date(System.currentTimeMillis() + 100000);
    source.timestamp = new Timestamp(System.currentTimeMillis() + 50000);
    source.calendar = cal;
    source.xmlCalendar = xmlCal;

    ClonableHolder dest = factory.getMapperFacade().map(source, ClonableHolder.class);
    Assert.assertEquals(source.value, dest.value);
    Assert.assertNotSame(source.value, dest.value);
    Assert.assertEquals(source.date, dest.date);
    Assert.assertNotSame(source.date, dest.date);
    Assert.assertEquals(source.timestamp, dest.timestamp);
    Assert.assertNotSame(source.timestamp, dest.timestamp);
    Assert.assertEquals(source.calendar, dest.calendar);
    Assert.assertNotSame(source.calendar, dest.calendar);
    Assert.assertEquals(source.xmlCalendar, dest.xmlCalendar);
    Assert.assertNotSame(source.xmlCalendar, dest.xmlCalendar);
}

From source file:com.platform.middlewares.HTTPIndexMiddleware.java

@Override
public boolean handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request,
        HttpServletResponse response) {//from   w w  w .j  a v  a2  s . c  om
    Log.i(TAG, "handling: " + target + " " + baseRequest.getMethod());
    String indexFile = MainActivity.app.getFilesDir() + "/" + BUNDLES + "/" + extractedFolder + "/index.html";

    File temp = new File(indexFile);
    if (!temp.exists()) {
        Log.e(TAG, "handle: FILE DOES NOT EXIST: " + temp.getAbsolutePath());
        return false;
    }

    try {
        byte[] body = FileUtils.readFileToByteArray(temp);
        Assert.assertNotNull(body);
        Assert.assertNotSame(body.length, 0);
        response.setHeader("Content-Length", String.valueOf(body.length));
        return BRHTTPHelper.handleSuccess(200, body, baseRequest, response, "text/html;charset=utf-8");
    } catch (IOException e) {
        e.printStackTrace();
        Log.d(TAG, "handle: error sending response: " + target + " " + baseRequest.getMethod());
        return BRHTTPHelper.handleError(500, null, baseRequest, response);
    }

}

From source file:edu.txstate.dmlab.clusteringwiki.cluster.ClusterDocumentComparisonTest.java

@Test
public void testNotSimDocsFromResults() throws Exception {
    final CollectionContext ctx = getTestContext();

    final IClusterDocument d1 = ctx.allDocs.get(1);

    final IClusterDocument d2 = ctx.allDocs.get(2);

    double sim = d1.computeSimilarity(d2);

    Assert.assertNotSame(sim, 1.0D);
}

From source file:de.hybris.platform.commerceservices.security.impl.DefaultSecureTokenServiceTest.java

@Test
public void testCycle() {
    final SecureToken data = new SecureToken(TEST_DATA, TEST_TS);
    final String token = service.encryptData(data);
    Assert.assertNotNull(token);/*from w  w  w.j ava 2s  . c om*/
    final SecureToken result = service.decryptData(token);
    Assert.assertNotSame(result, data);
    Assert.assertEquals(TEST_DATA, result.getData());
    Assert.assertEquals(TEST_TS, result.getTimeStamp());
}

From source file:org.openxdata.server.service.impl.RoleServiceTest.java

@Test
public void deleteRole_shouldDeleteGivenRole() throws Exception {

    List<Role> roles = roleService.getRoles();
    Assert.assertEquals(2, roles.size());

    final String roleName = "Role Name";
    roleService.saveRole(new Role(roleName));
    roles = roleService.getRoles();/*  w ww.j a  va2 s . c  o  m*/
    Assert.assertEquals(3, roles.size());

    Role role = roles.get(0);
    if (!role.getName().equals(roleName))
        role = roles.get(1);

    roleService.deleteRole(role);

    roles = roleService.getRoles();
    Assert.assertEquals(2, roles.size());
    Assert.assertNotSame(roleName, roles.get(0).getName());
}

From source file:org.atemsource.atem.utility.snapshot.SnapshotBuilderTest.java

@Test
public void test() {
    EntityA entityA = new EntityA();
    entityA.setIntP(100);//  w  w  w. ja v a 2s .  c om
    entityA.setBooleanO(true);
    List<EntityB> list = new ArrayList<EntityB>();
    EntityB b1 = new EntityB();
    b1.setInteger(5);
    list.add(b1);
    entityA.setList(list);

    EntityType<EntityB> entityTypeB = entityTypeRepository.getEntityType(EntityB.class);
    SnapshotBuilder subBuilder = snapshotBuilderFactory.create(entityTypeB);
    subBuilder.include("integer");
    Transformation<?, ?> subTransformation = subBuilder.create();

    EntityType<EntityA> entityTypeA = entityTypeRepository.getEntityType(EntityA.class);
    SnapshotBuilder builder = snapshotBuilderFactory.create(entityTypeA);
    builder.include("intP");
    builder.include("list").cascade(subTransformation);

    Transformation<EntityA, DynamicEntity> snapshotting = (Transformation<EntityA, DynamicEntity>) builder
            .create();

    DynamicEntity snapshot = snapshotting.getAB().convert(entityA,
            new SimpleTransformationContext(entityTypeRepository));

    EntityA restored = snapshotting.getBA().convert(snapshot,
            new SimpleTransformationContext(entityTypeRepository));

    Assert.assertFalse(((List) snapshot.get("list")).get(0) instanceof EntityB);
    Assert.assertEquals(100, restored.getIntP());
    Assert.assertNotSame(entityA.getList(), restored.getList());
    Assert.assertEquals(5, restored.getList().get(0).getInteger());
    Assert.assertEquals(null, restored.getBooleanO());

}

From source file:ma.glasnost.orika.test.converter.CloneableConverterNoSetAccessibleTestCase.java

@Test
public void cloneableConverterWithoutSetAccessible() throws DatatypeConfigurationException {

    final SecurityManager initialSm = System.getSecurityManager();
    try {//from   w  w w  .j  a  v a  2s. c o m
        System.setSecurityManager(new SecurityManager() {
            public void checkPermission(java.security.Permission perm) {
                if ("suppressAccessChecks".equals(perm.getName())) {
                    for (StackTraceElement ste : new Throwable().getStackTrace()) {
                        if (ste.getClassName().equals(CloneableConverter.class.getCanonicalName())) {
                            throw new SecurityException("not permitted");
                        }
                    }
                }
            }
        });

        CloneableConverter cc = new CloneableConverter(SampleCloneable.class);

        MapperFactory factory = MappingUtil.getMapperFactory();
        factory.getConverterFactory().registerConverter(cc);

        GregorianCalendar cal = new GregorianCalendar();
        cal.add(Calendar.YEAR, 10);
        XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance()
                .newXMLGregorianCalendar((GregorianCalendar) cal);
        cal.add(Calendar.MONTH, 3);

        ClonableHolder source = new ClonableHolder();
        source.value = new SampleCloneable();
        source.value.id = 5L;
        source.date = new Date(System.currentTimeMillis() + 100000);
        source.timestamp = new Timestamp(System.currentTimeMillis() + 50000);
        source.calendar = cal;
        source.xmlCalendar = xmlCal;

        ClonableHolder dest = factory.getMapperFacade().map(source, ClonableHolder.class);
        Assert.assertEquals(source.value, dest.value);
        Assert.assertNotSame(source.value, dest.value);
        Assert.assertEquals(source.date, dest.date);
        Assert.assertNotSame(source.date, dest.date);
        Assert.assertEquals(source.timestamp, dest.timestamp);
        Assert.assertNotSame(source.timestamp, dest.timestamp);
        Assert.assertEquals(source.calendar, dest.calendar);
        Assert.assertNotSame(source.calendar, dest.calendar);
        Assert.assertEquals(source.xmlCalendar, dest.xmlCalendar);
        Assert.assertNotSame(source.xmlCalendar, dest.xmlCalendar);
    } finally {
        System.setSecurityManager(initialSm);
    }
}