Examples of RequestEnd


Examples of org.apache.tuscany.core.context.event.RequestEnd

        Assert.assertNotNull(source);
        GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertNotNull(target);
        source.getGenericComponent().setString("foo");
        Assert.assertEquals("foo",target.getString());
        testCtx.publish(new RequestEnd(this,new Object()));

        //second request for session
        Object id2 = new Object();
        testCtx.publish(new RequestStart(this,id2));
        testCtx.publish(new HttpSessionBound(this,session));
        GenericComponent targetR2 = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertEquals("foo",targetR2.getString());
        GenericComponent sourceR2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(sourceR2);
        Assert.assertEquals("foo",sourceR2.getGenericComponent().getString());
       
        testCtx.publish(new RequestEnd(this,new Object()));

        //second session
        Object session2 = new Object();
        Object id3 = new Object();
        testCtx.publish(new RequestStart(this,id3));
        testCtx.publish(new HttpSessionBound(this,session2));
        GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source2);
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);

        Assert.assertNotNull(target2);
        Assert.assertEquals(null,target2.getString());
        Assert.assertEquals(null,source2.getGenericComponent().getString());
        source2.getGenericComponent().setString("baz");
        Assert.assertEquals("baz",source2.getGenericComponent().getString());
        Assert.assertEquals("baz",target2.getString());
       
        testCtx.publish(new RequestEnd(this,session2));
         Object id4 = new Object();
        testCtx.publish(new RequestStart(this,id4));
        testCtx.publish(new HttpSessionBound(this,session));
        testCtx.publish(new RequestEnd(this,session));

    }
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        Assert.assertNotNull(source);
        GenericComponent target = (GenericComponent)testCtx.getContext("target").getInstance(null);
        Assert.assertNotNull(target);
        source.getGenericComponent().setString("foo");
        Assert.assertEquals("foo",target.getString());
        testCtx.publish(new RequestEnd(this,new Object()));

        //second session
        Object id2 = new Object();
        testCtx.publish(new RequestStart(this,id2));
        GenericComponent source2 = (GenericComponent)testCtx.getContext("source").getInstance(null);
        Assert.assertNotNull(source2);
        GenericComponent target2 = (GenericComponent)testCtx.getContext("target").getInstance(null);

        Assert.assertNotNull(target2);
        Assert.assertEquals("foo",target2.getString());
        Assert.assertEquals("foo",source2.getGenericComponent().getString());
        source2.getGenericComponent().setString("baz");
        Assert.assertEquals("baz",source2.getGenericComponent().getString());
        Assert.assertEquals("baz",target2.getString());
       
        testCtx.publish(new RequestEnd(this,new Object()));

    }
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("foo", response);
        child.publish(new RequestEnd(this, id));

        // second request
        Object id2 = new Object();
        child.publish(new RequestStart(this, id2));
        ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        handler = (InvocationHandler) ctx.getHandler();
        Assert.assertEquals(2, mockInterceptor.getCount());
        response = handler.invoke(null, hello, new Object[]{"foo"});
        Assert.assertEquals("foo", response);
        Assert.assertEquals(3, mockInterceptor.getCount());
        child.publish(new RequestEnd(this, id2));

        child.publish(new ModuleStop(this));
        runtime.stop();

    }
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        // first request
        RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp1);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));

        // second request
        RequestScopeComponentImpl comp2 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp2);
        Assert.assertNotSame(comp1, comp2);
        Object id2 = new Object();
        scope.onEvent(new RequestEnd(this,id2));

        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        RequestScopeComponent comp1 = (RequestScopeComponent) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp1);
        RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));
        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        Assert.assertNotNull(comp1);
        scope.registerFactory(createConfiguration("NewTestService"));
        RequestScopeComponent comp2 = (RequestScopeComponent) scope.getContext("NewTestService").getInstance(null);
        Assert.assertNotNull(comp2);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));
        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        scope.start();

        RequestScopeComponentImpl comp1 = (RequestScopeComponentImpl) scope.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(comp1);
        Object id = new Object();
        scope.onEvent(new RequestEnd(this,id));

        // second request
        // should be null since the other context (thread) expired w/ onEvent(..)
        Assert.assertNull(scope.getContextByKey("TestService1", Thread.currentThread()));
        // Note should test better using concurrent threads to pull the instance
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        scope.onEvent(new RequestStart(this,request));
        OrderedDependentPojo source = (OrderedDependentPojo) scope.getContext("source").getInstance(null);
        assertNotNull(source.getPojo());
        // expire module
        assertEquals(2,source.getNumberInstantiated());
        scope.onEvent(new RequestEnd(this,request));
        assertEquals(0,source.getNumberInstantiated());
        scope.stop();
    }
View Full Code Here

Examples of org.apache.tuscany.core.context.event.RequestEnd

        GenericComponent testService2 = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
        GenericComponent testService3 = (GenericComponent) componentCtx.getContext("TestService3").getInstance(null);
        Assert.assertNotNull(testService1);
        Assert.assertNotNull(testService2);
        Assert.assertNotNull(testService3);
        scopeContainer.onEvent(new RequestEnd(this,id));
        scopeContainer.onEvent(new RequestStart(this,id));
        scopeContainer.onEvent(new HttpSessionBound(this,session));

        GenericComponent testService2a = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
        Assert.assertNotNull(testService2a);
        GenericComponent testService3a = (GenericComponent) componentCtx.getContext("TestService3").getInstance(null);
        Assert.assertNotNull(testService3a);
        Assert.assertEquals(testService2, testService2a);
        Assert.assertNotSame(testService3, testService3a);
        scopeContainer.onEvent(new RequestEnd(this,id));
        scopeContainer.onEvent(new HttpSessionEnd(this,session));

        Object session2 = new Object();
        Object id2 = new Object();
        scopeContainer.onEvent(new RequestStart(this,id2));
        scopeContainer.onEvent(new HttpSessionBound(this,session2));
        GenericComponent testService2b = (GenericComponent) componentCtx.getContext("TestService2").getInstance(null);
        Assert.assertNotNull(testService2b);
        Assert.assertNotSame(testService2, testService2b);

        scopeContainer.onEvent(new RequestEnd(this,id2));
        scopeContainer.onEvent(new HttpSessionEnd(this,session2));

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.