Package org.glassfish.jersey.process.internal.RequestScope

Examples of org.glassfish.jersey.process.internal.RequestScope.Instance


public class RequestScopeTest {
    @Test
    public void testScopeWithCreatedInstance() {
        final RequestScope requestScope = new RequestScope();
        assertNull(requestScope.suspendCurrent());
        final Instance instance = requestScope.createInstance();
        final TestProvider inhab = new TestProvider("a");
        instance.put(inhab, "1");
        requestScope.runInScope(instance, new Runnable() {

            @Override
            public void run() {
                assertEquals("1", instance.get(inhab));
                instance.release();
                assertEquals("1", instance.get(inhab));
            }
        });
        assertNull(instance.get(inhab));
    }
View Full Code Here


    @Test
    public void testScopeReleaseInsideScope() {
        final RequestScope requestScope = new RequestScope();
        assertNull(requestScope.suspendCurrent());
        final Instance instance = requestScope.createInstance();
        final TestProvider inhab = new TestProvider("a");
        instance.put(inhab, "1");
        requestScope.runInScope(instance, new Runnable() {

            @Override
            public void run() {
                Instance internalInstance = requestScope.suspendCurrent();
                assertEquals(internalInstance, instance);
                assertEquals("1", instance.get(inhab));
                instance.release();
                assertEquals("1", instance.get(inhab));
            }
View Full Code Here

    @Test
    public void testScopeWithImplicitInstance() throws Exception {
        final RequestScope requestScope = new RequestScope();
        assertNull(requestScope.suspendCurrent());
        final TestProvider inhab = new TestProvider("a");
        Instance instance = requestScope.runInScope(new Callable<Instance>() {

            @Override
            public Instance call() throws Exception {
                Instance internalInstance = requestScope.suspendCurrent();
                assertNull(internalInstance.get(inhab));
                internalInstance.put(inhab, "1");
                assertEquals("1", internalInstance.get(inhab));
                return internalInstance;
            }
        });
        assertEquals("1", instance.get(inhab));
        instance.release();
View Full Code Here

    @Test
    public void testScopeWithTwoInternalTasks() throws Exception {
        final RequestScope requestScope = new RequestScope();
        assertNull(requestScope.suspendCurrent());
        final TestProvider inhab = new TestProvider("a");
        Instance instance = requestScope.runInScope(new Callable<Instance>() {

            @Override
            public Instance call() throws Exception {
                final Instance internalInstance = requestScope.suspendCurrent();

                Instance anotherInstance = requestScope.runInScope(new Callable<Instance>() {

                    @Override
                    public Instance call() throws Exception {
                        final Instance currentInstance = requestScope.suspendCurrent();
                        assertTrue(!currentInstance.equals(internalInstance));
                        currentInstance.put(inhab, "1");
                        return currentInstance;
                    }
                });
                assertTrue(!anotherInstance.equals(internalInstance));
                assertEquals("1", anotherInstance.get(inhab));
View Full Code Here

    @Test
    public void testMultipleGetInstanceCalls() throws Exception {
        final RequestScope requestScope = new RequestScope();
        assertNull(requestScope.suspendCurrent());
        final TestProvider inhab = new TestProvider("a");
        Instance instance = requestScope.runInScope(new Callable<Instance>() {

            @Override
            public Instance call() throws Exception {
                final Instance internalInstance = requestScope.suspendCurrent();
                internalInstance.put(inhab, "1");
                requestScope.suspendCurrent();
                requestScope.suspendCurrent();
                requestScope.suspendCurrent();
                requestScope.suspendCurrent();
                return internalInstance;
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.process.internal.RequestScope.Instance

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.