Example usage for junit.framework Assert assertSame

List of usage examples for junit.framework Assert assertSame

Introduction

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

Prototype

static public void assertSame(Object expected, Object actual) 

Source Link

Document

Asserts that two objects refer to the same object.

Usage

From source file:Project2Test.java

@Test
public void objectIdentity() {
    Assert.assertSame(service.getAnimalName(), "cat");
}

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);/*from www  . j  a v a 2 s  . c om*/
    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:com.comcast.cim.rest.client.xhtml.TestXhtmlHttpClient.java

@Test
public void testDelegatesRequestExecutionToHelpers() throws Exception {
    XhtmlApplicationState state = new XhtmlApplicationState(null, null, null);
    HttpGet get = new HttpGet("http://foo.example.com/");

    URL context = new URL("http://foo.example.com/");
    XhtmlResponseHandler rh = new XhtmlResponseHandler(context);

    EasyMock.expect(mockFactory.get(context)).andReturn(rh);
    EasyMock.expect(mockHttpClient.execute(get, rh)).andReturn(state);

    replayMocks();//from w w w  . ja v a  2 s.co m
    XhtmlApplicationState result = impl.execute(get);
    verifyMocks();
    Assert.assertSame(state, result);
}

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceControllerConfigBeanDefinitionParserTest.java

@Test
public void test1() {
    RemoteServiceControllerConfig config;

    config = appContext.getBean("serviceController100", RemoteServiceControllerConfig.class);
    Assert.assertEquals(1, config.getServiceModuleConfigs().size());
    Assert.assertEquals("myModule700", config.getServiceModuleConfigs().iterator().next().getName());
    Assert.assertTrue(config.getResponseCompressionEnabled());
    Assert.assertFalse(config.getRpcTokenProtectionEnabled());
    Assert.assertEquals("rpcTokenService", config.getRpcTokenValidatorName());
    Assert.assertSame(appContext.getBean("serializationPolicyProvider"),
            config.getSerializationPolicyProvider());
}

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

@Test
public void testPassThroughConverterGenerics() {

    /*// w  w w  .  j  a v a 2 s .com
     * Note: we register the generic Holder<?> and pass it a Holder<Wrapper<B>>
     * we expect that it should be passed-through
     * 
     */
    PassThroughConverter ptc = new PassThroughConverter(new TypeBuilder<Holder<?>>() {
    }.build());
    MapperFactory factory = MappingUtil.getMapperFactory();

    factory.getConverterFactory().registerConverter(ptc);

    B b = new B();
    b.setString("Hello");
    Holder<B> holder = new Holder<B>();
    holder.setHeld(b);
    Wrapper<Holder<B>> wrapper = new Wrapper<Holder<B>>();
    wrapper.setHeld(holder);

    Type<Wrapper<Holder<B>>> fromType = new TypeBuilder<Wrapper<Holder<B>>>() {
    }.build();
    Type<Decorator<Holder<B>>> toType = new TypeBuilder<Decorator<Holder<B>>>() {
    }.build();

    Decorator<Holder<B>> d = factory.getMapperFacade().map(wrapper, fromType, toType);

    Assert.assertEquals(wrapper.getHeld(), d.getHeld());
    Assert.assertSame(wrapper.getHeld(), d.getHeld());
}

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceControllerConfigBeanDefinitionParserTest.java

@Test
public void test2() {
    RemoteServiceControllerConfig config;

    config = appContext.getBean("serviceController101", RemoteServiceControllerConfig.class);
    Assert.assertEquals(1, config.getServiceModuleConfigs().size());
    Assert.assertEquals("myModule701", config.getServiceModuleConfigs().iterator().next().getName());
    Assert.assertTrue(config.getResponseCompressionEnabled());
    Assert.assertFalse(config.getRpcTokenProtectionEnabled());
    Assert.assertEquals("rpcTokenService", config.getRpcTokenValidatorName());
    Assert.assertSame(appContext.getBean("serializationPolicyProvider"),
            config.getSerializationPolicyProvider());
}

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

/**
 * This test method demonstrates that you can decide to treat one of the default cloneable types
 * as immutable if desired by registering your own PassThroughConverter for that type
 * /*from w w  w  .j  a v  a  2 s  . c  om*/
 * @throws DatatypeConfigurationException
 */
@Test
public void overrideDefaultCloneableToImmutable() throws DatatypeConfigurationException {

    PassThroughConverter cc = new PassThroughConverter(Date.class, Calendar.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.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.assertSame(source.date, dest.date);
    Assert.assertEquals(source.calendar, dest.calendar);
    Assert.assertSame(source.calendar, dest.calendar);
    Assert.assertEquals(source.xmlCalendar, dest.xmlCalendar);
    Assert.assertNotSame(source.xmlCalendar, dest.xmlCalendar);

}

From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceControllerConfigBeanDefinitionParserTest.java

@Test
public void test6() {
    RemoteServiceControllerConfig config;

    config = appContext.getBean("serviceController105", RemoteServiceControllerConfig.class);
    Assert.assertSame(appContext.getBean("serializationPolicyProvider2"),
            config.getSerializationPolicyProvider());
}

From source file:com.link_intersystems.lang.reflect.Class2Test.java

@Test
public void getClassLoaderForSystemClass() throws ClassNotFoundException {
    Class2<String> class2 = Class2.get(String.class);
    ClassLoader classLoader = class2.getType().getClassLoader();
    assertNull(classLoader);//from   w ww.  j a  v  a 2s . co  m

    ClassLoader classLoader2 = class2.getClassLoader();
    assertEquals(ClassLoader.getSystemClassLoader(), classLoader2);

    Class2<Object> class2ByName = Class2.get(String.class.getCanonicalName());
    Assert.assertSame(class2, class2ByName);
}

From source file:com.connectsdk.service.sessions.WebOSWebAppSessionTest.java

@Test
public void testGetPlaylistControl() {
    Assert.assertSame(session, session.getPlaylistControl());
}