Examples of ThreadEventNotifier


Examples of org.apache.hivemind.service.ThreadEventNotifier

        Registry r = (Registry) servletContext.getAttribute(HiveMindFilter.CONTEXT_KEY);

        assertNotNull(r);

        ThreadEventNotifier t =
            (ThreadEventNotifier) r.getService(
                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                ThreadEventNotifier.class);

        Listener l = new Listener();

        t.addThreadCleanupListener(l);

        HttpServletRequest request = new MockRequest();

        f.doFilter(request, new MockResponse(), new MockFilterChain());

        assertSame(r, HiveMindFilter.getRegistry(request));

        assertEquals(true, l.getCleanup());

        f.destroy();

        try
        {
            t.addThreadCleanupListener(null);
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertExceptionSubstring(ex, "The HiveMind Registry has been shutdown.");
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

    {
        Registry r = buildFrameworkRegistry("StringHolder.xml");

        StringHolder h =
            (StringHolder) r.getService("hivemind.test.services.StringHolder", StringHolder.class);
        ThreadEventNotifier n =
            (ThreadEventNotifier) r.getService(
                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                ThreadEventNotifier.class);

        interceptLogging("hivemind.test.services.StringHolder");

        assertNull(h.getValue());

        h.setValue("fred");

        assertEquals("fred", h.getValue());

        n.fireThreadCleanup();

        assertNull(h.getValue());

        assertEquals(
            "<ThreadedProxy for hivemind.test.services.StringHolder(hivemind.test.services.StringHolder)>",
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

                "hivemind.test.services.ThreadedDiscardable",
                StringHolder.class);

        h.setValue("bar");

        ThreadEventNotifier n =
            (ThreadEventNotifier) r.getService(
                "hivemind.ThreadEventNotifier",
                ThreadEventNotifier.class);

        interceptLogging("hivemind.test.services");

        n.fireThreadCleanup();

        assertLoggedMessage("threadDidDiscardService() has been invoked.");
    }
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

        Registry r = f.getRegistry();

        assertNotNull(r);

        ThreadEventNotifier t = (ThreadEventNotifier) r.getService(
                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                ThreadEventNotifier.class);

        ThreadListenerFixture l = new ThreadListenerFixture();

        t.addThreadCleanupListener(l);

        MockControl requestControl = newControl(HttpServletRequest.class);
        HttpServletRequest request = (HttpServletRequest) requestControl.getMock();
        HttpServletResponse response = (HttpServletResponse) newMock(HttpServletResponse.class);
        FilterChain chain = (FilterChain) newMock(FilterChain.class);

        request.setAttribute(AutoloadingHiveMindFilter.REQUEST_KEY, r);

        chain.doFilter(request, response);

        request.getAttribute(AutoloadingHiveMindFilter.REBUILD_REQUEST_KEY);
        requestControl.setReturnValue(null);

        request.getAttribute(AutoloadingHiveMindFilter.REQUEST_KEY);
        requestControl.setReturnValue(r);

        replayControls();

        f.doFilter(request, response, chain);

        assertSame(r, AutoloadingHiveMindFilter.getRegistry(request));

        assertEquals(true, l.getCleanup());

        f.destroy();

        try
        {
            t.addThreadCleanupListener(null);
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertExceptionSubstring(ex, "The HiveMind Registry has been shutdown.");
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

        assertNull(s.getValue());

        s.setValue("funky monkey");
        assertEquals("funky monkey", s.getValue());

        ThreadEventNotifier n =
            (ThreadEventNotifier) r.getService(
                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                ThreadEventNotifier.class);

        n.fireThreadCleanup();

        assertEquals("funky monkey", s.getValue());
    }
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

        Registry r = buildFrameworkRegistry(new StringHolderModule(ServiceModel.THREADED));

        StringHolder h = (StringHolder) r.getService(
                "hivemind.test.services.StringHolder",
                StringHolder.class);
        ThreadEventNotifier n = (ThreadEventNotifier) r.getService(
                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                ThreadEventNotifier.class);

        interceptLogging("hivemind.test.services.StringHolder");

        assertNull(h.getValue());

        h.setValue("fred");

        assertEquals("fred", h.getValue());

        n.fireThreadCleanup();

        assertNull(h.getValue());

        assertEquals(
                "<OuterProxy for hivemind.test.services.StringHolder(hivemind.test.services.StringHolder)>",
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

                "hivemind.test.services.StringHolder",
                StringHolder.class);

        h.setValue("bar");

        ThreadEventNotifier n = (ThreadEventNotifier) r.getService(
                "hivemind.ThreadEventNotifier",
                ThreadEventNotifier.class);

        interceptLogging("hivemind.test.services");

        n.fireThreadCleanup();

        assertLoggedMessage("threadDidDiscardService() has been invoked.");
    }
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

        Registry r = f.getRegistry();

        assertNotNull(r);

        ThreadEventNotifier t = (ThreadEventNotifier) r.getService(
                HiveMind.THREAD_EVENT_NOTIFIER_SERVICE,
                ThreadEventNotifier.class);

        ThreadListenerFixture l = new ThreadListenerFixture();

        t.addThreadCleanupListener(l);

        MockControl requestControl = newControl(HttpServletRequest.class);
        HttpServletRequest request = (HttpServletRequest) requestControl.getMock();
        HttpServletResponse response = (HttpServletResponse) newMock(HttpServletResponse.class);
        FilterChain chain = (FilterChain) newMock(FilterChain.class);

        request.setAttribute(HiveMindFilter.REQUEST_KEY, r);

        chain.doFilter(request, response);

        request.getAttribute(HiveMindFilter.REBUILD_REQUEST_KEY);
        requestControl.setReturnValue(null);

        request.getAttribute(HiveMindFilter.REQUEST_KEY);
        requestControl.setReturnValue(r);

        replayControls();

        f.doFilter(request, response, chain);

        assertSame(r, HiveMindFilter.getRegistry(request));

        assertEquals(true, l.getCleanup());

        f.destroy();

        try
        {
            t.addThreadCleanupListener(null);
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertExceptionSubstring(ex, "The HiveMind Registry has been shutdown.");
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

        assertNull(_s.get("foo"));
    }

    public void testWithNotifier()
    {
        ThreadEventNotifier notifier = new ThreadEventNotifierImpl();
        ThreadLocalStorageImpl s = new ThreadLocalStorageImpl();

        s.setNotifier(notifier);

        s.put("biff", "bamf");

        assertEquals("bamf", s.get("biff"));

        notifier.fireThreadCleanup();

        assertNull(s.get("biff"));
    }
View Full Code Here

Examples of org.apache.hivemind.service.ThreadEventNotifier

        }
    }

    public void testThreadCleanup() throws Throwable
    {
        ThreadEventNotifier notifier = new ThreadEventNotifierImpl();
        ThreadLocalStorageImpl local = new ThreadLocalStorageImpl();

        local.setNotifier(notifier);

        local.put("session", "Main Session");

        TestRunner tr = new TestRunner(local, notifier);
        TestThreadGroup tg = new TestThreadGroup("Test Thread Group");
        new Thread(tg, tr).start();

        while (!_testRunnerCompleted)
            Thread.yield();

        if (_testRunnerFailure != null)
            throw _testRunnerFailure;

        assertEquals(local.get("session"), "Main Session");

        notifier.fireThreadCleanup();

        assertNull(local.get("session"));
    }
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.