Package org.apache.wink.common

Examples of org.apache.wink.common.RuntimeContext


    public void testPreDestroyCalled() {
        ObjectFactory of = factoryRegistry.getObjectFactory(ProviderPreDestroySingleton.class);
        assertEquals(JSR250SingletonObjectFactory.class, of.getClass());
        // no PostConstruct in ProviderPreDestroySingleton
        assertEquals(called, null);
        RuntimeContext context = RuntimeContextTLS.getRuntimeContext();
        of.releaseInstance(of.getInstance(context), context);
        assertEquals(called, null)// we don't want releaseInstance to call @PreDestroy annotated method for singletons
        of.releaseAll(context);
        assertEquals(called, ProviderPreDestroySingleton.class.getSimpleName() + ".preDestroy()");
    }
View Full Code Here


    public void testResource() {
        ObjectFactory of = factoryRegistry.getObjectFactory(MyResource.class);
        assertEquals(JSR250PrototypeObjectFactory.class, of.getClass());
        // due to being a "Prototype" object factory, instances are only created upon request
        assertEquals(called, null);
        RuntimeContext context = RuntimeContextTLS.getRuntimeContext();
        of.getInstance(null);
        assertEquals(called, MyResource.class.getSimpleName() + ".postConstruct()");
        called = null;
        of.releaseAll(context);
        assertEquals(called, null)// instances created by "Prototype" object factories are per-request instances, not per-app or per-jvm
View Full Code Here

    public WinkConfiguration winkConfiguration = null;
   
    @Before
    public void setUp() {
        winkConfiguration = mock(WinkConfiguration.class);
        final RuntimeContext runtimeContext = mock(RuntimeContext.class);
        checking(new Expectations() {{
            allowing(runtimeContext).getAttribute(WinkConfiguration.class); will(returnValue(winkConfiguration));
        }});
        RuntimeContextTLS.setRuntimeContext(runtimeContext);
    }
View Full Code Here

    }
   
    @Before
    public void setUp() {
        providers = mock(Providers.class);
        final RuntimeContext runtimeContext = mock(RuntimeContext.class);
        winkConfiguration = mock(WinkConfiguration.class);
        checking(new Expectations() {{
            allowing(providers).getContextResolver(JAXBContext.class, MediaType.TEXT_XML_TYPE); will(returnValue(new MyJAXBContextResolver()));
            allowing(providers).getContextResolver(XmlFormattingOptions.class, MediaType.TEXT_XML_TYPE); will(returnValue(null));
            allowing(providers).getContextResolver(JAXBUnmarshalOptions.class, MediaType.TEXT_XML_TYPE); will(returnValue(null));
View Full Code Here

    private Providers providers;
   
    @Before
    public void setUp() {
        providers = mock(Providers.class);
        final RuntimeContext runtimeContext = mock(RuntimeContext.class);
        winkConfiguration = mock(WinkConfiguration.class);
        checking(new Expectations() {{
            allowing(providers).getContextResolver(XmlFormattingOptions.class, MediaType.TEXT_XML_TYPE); will(returnValue(null));
            allowing(providers).getContextResolver(JAXBUnmarshalOptions.class, MediaType.TEXT_XML_TYPE); will(returnValue(null));
            allowing(runtimeContext).getAttribute(MediaTypeCharsetAdjuster.class); will(returnValue(null));
View Full Code Here

    @Override
    public void setUp() throws Exception {
        createWinkDefaultPropsFile();
        super.setUp();
        Mockery mockery = new Mockery();
        final RuntimeContext context = mockery.mock(RuntimeContext.class);
        mockery.checking(new Expectations() {{
            allowing(context).getAttribute(WinkConfiguration.class); will(returnValue(null));
        }});
       
        RuntimeContextTLS.setRuntimeContext(context);
View Full Code Here

TOP

Related Classes of org.apache.wink.common.RuntimeContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.