Package org.apache.hivemind

Examples of org.apache.hivemind.Registry


        f.init(filterConfig);

        verifyControls();

        Registry r = f.getRegistry();

        assertNotNull(r);

        ShutdownCoordinator coordinator = (ShutdownCoordinator) r
                .getService(ShutdownCoordinator.class);

        ShutdownListenerFixture l = new ShutdownListenerFixture();

        coordinator.addRegistryShutdownListener(l);
View Full Code Here


        assertEquals(true, fixture.getDidRun());
    }

    public void testStartupContribution() throws Exception
    {
        Registry r = createRegistry();

        StartupRunnableFixture fixture =
            (StartupRunnableFixture) r.getService(
                "hivemind.test.services.StartupRunnableFixture",
                StartupRunnableFixture.class);

        assertEquals(true, fixture.getDidRun());
    }
View Full Code Here

public class TestPooledServiceModel extends FrameworkTestCase
{

    public void testUnmanaged() throws Exception
    {
        Registry r = buildFrameworkRegistry(new StringHolderModule(ServiceModel.POOLED));

        StringHolder s =
            (StringHolder) r.getService("hivemind.test.services.StringHolder", StringHolder.class);

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

        verifyControls();
    }

    public void testIntegration() throws Exception
    {
        Registry r = buildFrameworkRegistry(new SimpleModule());

        SimpleService a = (SimpleService) r.getService(SimpleService.class);

        AdderWrapper aw1 = new AdderWrapper(a);

        byte[] data = serialize(aw1);
View Full Code Here

    private String _otherEndValue;

    public void testSingleThread() throws Exception
    {
        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");
View Full Code Here

    /**
     * Uses a second thread to ensure that the data in different threads is seperate.
     */
    public void testThreaded() throws Exception
    {
        Registry r = buildFrameworkRegistry(new StringHolderModule(ServiceModel.THREADED));

        StringHolder h = (StringHolder) r.getService(
                "hivemind.test.services.StringHolder",
                StringHolder.class);

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

View Full Code Here

        _didShutdown = false;
    }

    public void testIgnoreRegistyShutdownListener() throws Exception
    {
        Registry r = createRegistryShutdownListener(RegistryShutdownStringHolderImpl.class);

        StringHolder h = (StringHolder) r.getService(
                "hivemind.test.services.StringHolder",
                StringHolder.class);

        interceptLogging("hivemind.test.services");

        h.setValue("foo");

        assertLoggedMessage("Core implementation of service hivemind.test.services.StringHolder implements the RegistryCleanupListener interface, which is not supported by the threaded service model.");

        r.shutdown();

        assertEquals(false, _didShutdown);
    }
View Full Code Here

        return buildFrameworkRegistry(module);
   
   
    public void testDiscardable() throws Exception
    {
        Registry r = createRegistryShutdownListener(DiscardableStringHolderImpl.class);

        StringHolder h = (StringHolder) r.getService(
                "hivemind.test.services.StringHolder",
                StringHolder.class);

        h.setValue("bar");

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

        interceptLogging("hivemind.test.services");
View Full Code Here

public class TestServices extends FrameworkTestCase
{

    public void testSimple() throws Exception
    {
        Registry r = buildFrameworkRegistry(new SimpleModule());

        assertNotNull(r);

        SimpleService s =
            (SimpleService) r.getService("hivemind.test.services.Simple", SimpleService.class);

        assertNotNull(s);
        assertEquals(11, s.add(4, 7));
    }
View Full Code Here

    /**
     * Test that service instances are cached.
     */
    public void testCache() throws Exception
    {
        Registry r = buildFrameworkRegistry(new SimpleModule());

        assertNotNull(r);

        SimpleService s1 =
            (SimpleService) r.getService("hivemind.test.services.Simple", SimpleService.class);
        SimpleService s2 =
            (SimpleService) r.getService("hivemind.test.services.Simple", SimpleService.class);

        assertSame(s1, s2);
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.Registry

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.