Package org.apache.hivemind.servlet

Examples of org.apache.hivemind.servlet.HiveMindFilter


    public void testBasic() throws Exception
    {
        ServletContext servletContext = new MockServletContext();
        FilterConfig filterConfig = new MockFilterConfig(servletContext);

        Filter f = new HiveMindFilter();

        f.init(filterConfig);

        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();
View Full Code Here


        }
    }

    public void testExceptionInInit() throws Exception
    {
        Filter f = new HiveMindFilter();

        interceptLogging(HiveMindFilter.class.getName());

        f.init(null);

        // It's a NPE that gets thrown.

        assertLoggedMessage("null");

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

        f.destroy();
    }
View Full Code Here

        f.destroy();
    }

    public void testDestroyWithoutRepository()
    {
        Filter f = new HiveMindFilter();

        f.destroy();
    }
View Full Code Here

        f.destroy();
    }

    public void testFilterWithoutRepository() throws Exception
    {
        Filter f = new HiveMindFilter();

        interceptLogging(HiveMindFilter.class.getName());

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

        assertLoggedMessage("Unable to cleanup current thread");
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.servlet.HiveMindFilter

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.