Package de.novanic.eventservice.config

Examples of de.novanic.eventservice.config.EventServiceConfiguration


        assertTrue(myConfigurationLoader.isAvailable());
    }

    @Test
    public void testLoad() {
        EventServiceConfiguration theEventServiceConfiguration = myConfigurationLoader.load();
        assertEquals("Default Configuration", theEventServiceConfiguration.getConfigDescription());
        assertEquals(Integer.valueOf(0), theEventServiceConfiguration.getMinWaitingTime());
        assertEquals(Integer.valueOf(20000), theEventServiceConfiguration.getMaxWaitingTime());
        assertEquals(Integer.valueOf(90000), theEventServiceConfiguration.getTimeoutTime());
        assertEquals(SessionConnectionIdGenerator.class.getName(), theEventServiceConfiguration.getConnectionIdGeneratorClassName());
        assertEquals(DefaultClientConnector.class.getName(), theEventServiceConfiguration.getConnectionStrategyClientConnectorClassName());
        assertEquals(LongPollingServerConnector.class.getName(), theEventServiceConfiguration.getConnectionStrategyServerConnectorClassName());
        assertEquals("utf-8", theEventServiceConfiguration.getConnectionStrategyEncoding());
        assertEquals(Integer.valueOf(1000), theEventServiceConfiguration.getMaxEvents());
    }
View Full Code Here


        ServletConfig theServletConfig = new ServletConfigDummy(true, false);
        ConfigurationLoader theConfigurationLoader = new WebDescriptorConfigurationLoader(theServletConfig);

        assertTrue(theConfigurationLoader.isAvailable());

        EventServiceConfiguration theConfiguration = theConfigurationLoader.load();
        assertEquals(Integer.valueOf(30000), theConfiguration.getMaxWaitingTime());
        assertEquals(Integer.valueOf(0), theConfiguration.getMinWaitingTime());
        assertEquals(Integer.valueOf(120000), theConfiguration.getTimeoutTime());
        assertEquals(Integer.valueOf(3), theConfiguration.getReconnectAttemptCount());
        assertEquals(SessionConnectionIdGenerator.class.getName(), theConfiguration.getConnectionIdGeneratorClassName());
        assertNull(theConfiguration.getConnectionStrategyClientConnectorClassName());
        assertEquals(LongPollingServerConnector.class.getName(), theConfiguration.getConnectionStrategyServerConnectorClassName());
        assertEquals("iso-8859-1", theConfiguration.getConnectionStrategyEncoding());
        assertEquals(Integer.valueOf(7000), theConfiguration.getMaxEvents());
    }
View Full Code Here

        ServletConfig theServletConfig = new ServletConfigDummy(true, true);
        ConfigurationLoader theConfigurationLoader = new WebDescriptorConfigurationLoader(theServletConfig);

        assertTrue(theConfigurationLoader.isAvailable());

        EventServiceConfiguration theConfiguration = theConfigurationLoader.load();
        assertEquals(Integer.valueOf(40000), theConfiguration.getMaxWaitingTime());
        assertEquals(Integer.valueOf(1), theConfiguration.getMinWaitingTime());
        assertEquals(Integer.valueOf(130000), theConfiguration.getTimeoutTime());
        assertEquals(Integer.valueOf(1), theConfiguration.getReconnectAttemptCount());
        assertEquals(SessionConnectionIdGenerator.class.getName(), theConfiguration.getConnectionIdGeneratorClassName());
        assertNull(theConfiguration.getConnectionStrategyClientConnectorClassName());
        assertEquals(LongPollingServerConnector.class.getName(), theConfiguration.getConnectionStrategyServerConnectorClassName());
        assertEquals("utf-8", theConfiguration.getConnectionStrategyEncoding());
        assertEquals(Integer.valueOf(5000), theConfiguration.getMaxEvents());
    }
View Full Code Here

        assertEquals(0, myEventService.getActiveListenDomains().size());

        //Configuration of WebDescriptorConfigurationLoader (see DummyServletConfig). That configuration and ConfigurationLoader
        //was initialized with the init-method of EventServiceImpl.
        EventServiceConfiguration theConfiguration = theEventServiceConfigurationFactory.loadEventServiceConfiguration();
        assertEquals(Integer.valueOf(40000), theConfiguration.getMaxWaitingTime());
        assertEquals(Integer.valueOf(5000), theConfiguration.getMinWaitingTime());
        assertEquals(Integer.valueOf(120000), theConfiguration.getTimeoutTime());
    }
View Full Code Here

        ConfigurationLoader theConfigurationLoader = new WebDescriptorConfigurationLoader(theServletConfig);

        assertTrue(theConfigurationLoader.isAvailable());

        EventServiceConfiguration theConfiguration = theConfigurationLoader.load();
        assertEquals(Integer.valueOf(30000), theConfiguration.getMaxWaitingTime());
        assertEquals(Integer.valueOf(0), theConfiguration.getMinWaitingTime());
        assertEquals(Integer.valueOf(120000), theConfiguration.getTimeoutTime());
        assertNull(theConfiguration.getReconnectAttemptCount());
        assertNull(theConfiguration.getConnectionIdGeneratorClassName());
        assertNull(theConfiguration.getConnectionStrategyClientConnectorClassName());
        assertNull(theConfiguration.getConnectionStrategyServerConnectorClassName());
        assertNull(theConfiguration.getConnectionStrategyEncoding());
        assertNull(theConfiguration.getMaxEvents());
    }
View Full Code Here

        ConfigurationLoader theConfigurationLoader = new WebDescriptorConfigurationLoader(theServletConfig);

        assertTrue(theConfigurationLoader.isAvailable());

        EventServiceConfiguration theConfiguration = theConfigurationLoader.load();
        assertEquals(Integer.valueOf(30000), theConfiguration.getMaxWaitingTime());
        assertEquals(Integer.valueOf(0), theConfiguration.getMinWaitingTime());
        assertEquals(Integer.valueOf(120000), theConfiguration.getTimeoutTime());
        assertNull(theConfiguration.getReconnectAttemptCount());
        assertNull(theConfiguration.getConnectionIdGeneratorClassName());
        assertNull(theConfiguration.getConnectionStrategyClientConnectorClassName());
        assertEquals(LongPollingServerConnector.class.getName(), theConfiguration.getConnectionStrategyServerConnectorClassName());
        assertEquals("iso-8859-1", theConfiguration.getConnectionStrategyEncoding());
        assertEquals(Integer.valueOf(7000), theConfiguration.getMaxEvents());
    }
View Full Code Here

    }

    @Test
    public void testListen_2() throws Exception {
        //Tests listen with a min. waiting time
        EventServiceConfiguration theEventServiceConfiguration = createConfiguration(500, 1500, 9999);
        tearDownEventServiceConfiguration();
        setUp(theEventServiceConfiguration);

        myEventRegistry = EventRegistryFactory.getInstance().getEventRegistry();
        setUp(myEventRegistry);
View Full Code Here

        assertEquals(0, myEventRegistry.listen(getLongPollingListener(), TEST_USER_ID).size());
    }

    @Test
    public void testListen_Domain_Isolation() throws Exception {
        EventServiceConfiguration theEventServiceConfiguration = createConfiguration(0, 2000, 9999);
        tearDownEventServiceConfiguration();
        setUp(theEventServiceConfiguration);

        myEventRegistry = EventRegistryFactory.getInstance().getEventRegistry();
        setUp(myEventRegistry);

        myEventRegistry.registerUser(TEST_DOMAIN, TEST_USER_ID, null);
        myEventRegistry.registerUser(TEST_DOMAIN_2, TEST_USER_ID_2, null);
        startAddEvent(TEST_DOMAIN, 250);

        joinThreads();

        final ListenCallable theListenCallable = new ListenCallable(TEST_USER_ID);
        final FutureTask<ListenResult> theFutureTask = new FutureTask<ListenResult>(theListenCallable);

        final ListenCallable theListenCallable_2 = new ListenCallable(TEST_USER_ID_2);
        final FutureTask<ListenResult> theFutureTask_2 = new FutureTask<ListenResult>(theListenCallable_2);

        new Thread(theFutureTask).start();
        new Thread(theFutureTask_2).start();

        ListenResult theListenResult = theFutureTask.get();
        ListenResult theListenResult_2 = theFutureTask_2.get();

        assertEquals(1, theListenResult.getEvents().size());
        assertEquals(0, theListenResult_2.getEvents().size());

        //the ListenCallable_2 shouldn't abort when another user of another domain gets an event
        final long theRunningTime = theListenResult.getRunningTimeMillis();
        final long theRunningTime_2 = theListenResult_2.getRunningTimeMillis();
        assertTrue(theRunningTime_2 > theRunningTime);
        assertTrue(theRunningTime_2 >= theEventServiceConfiguration.getMaxWaitingTime());
    }
View Full Code Here

        assertEquals(0, myEventRegistry.listen(getLongPollingListener(), TEST_USER_ID_2).size());
    }

    @Test
    public void testAddUserSpecificEvent_Isolation() throws Exception {
        EventServiceConfiguration theEventServiceConfiguration = createConfiguration(0, 2000, 9999);
        tearDownEventServiceConfiguration();
        setUp(theEventServiceConfiguration);

        myEventRegistry = EventRegistryFactory.getInstance().getEventRegistry();
        setUp(myEventRegistry);

        myEventRegistry.registerUser(TEST_DOMAIN, TEST_USER_ID, null);
        myEventRegistry.registerUser(TEST_DOMAIN, TEST_USER_ID_2, null);
        startAddEvent(TEST_USER_ID, 250);

        joinThreads();

        final ListenCallable theListenCallable = new ListenCallable(TEST_USER_ID);
        final FutureTask<ListenResult> theFutureTask = new FutureTask<ListenResult>(theListenCallable);
        theFutureTask.run();

        final ListenCallable theListenCallable_2 = new ListenCallable(TEST_USER_ID_2);
        final FutureTask<ListenResult> theFutureTask_2 = new FutureTask<ListenResult>(theListenCallable_2);
        theFutureTask_2.run();

        ListenResult theListenResult = theFutureTask.get();
        ListenResult theListenResult_2 = theFutureTask_2.get();

        assertEquals(1, theListenResult.getEvents().size());
        assertEquals(0, theListenResult_2.getEvents().size());

        //the ListenCallable_2 shouldn't abort when an other user of the same domain gets a user specific event
        final long theRunningTime = theListenResult.getRunningTimeMillis();
        final long theRunningTime_2 = theListenResult_2.getRunningTimeMillis();
        assertTrue(theRunningTime_2 > theRunningTime);
        assertTrue(theRunningTime_2 >= theEventServiceConfiguration.getMaxWaitingTime());
    }
View Full Code Here

    @Test
    public void testTimeOut() throws Exception {
        //set the default waiting time greater than time out time to produce a time out
        EventRegistry theEventRegistry = EventRegistryFactory.getInstance().getEventRegistry();
        EventServiceConfiguration theEventServiceConfiguration = theEventRegistry.getConfiguration();

        final int theTimeoutTime = 400;
        final int theNewMaxWaitingTime = theTimeoutTime + 1700;
        EventServiceConfiguration theNewEventServiceConfiguration = createConfiguration(
                theEventServiceConfiguration.getMinWaitingTime(),
                theNewMaxWaitingTime,
                theTimeoutTime);

        tearDownEventServiceConfiguration();
        setUp(theNewEventServiceConfiguration);

        theEventRegistry = EventRegistryFactory.getInstance().getEventRegistry();

        theEventRegistry.registerUser(TEST_DOMAIN, TEST_USER_ID, null);
        theEventRegistry.addEvent(TEST_DOMAIN, new DummyEvent());
        assertTrue(theEventRegistry.isUserRegistered(TEST_USER_ID));

        theEventRegistry.registerUnlistenEvent(TEST_USER_ID, UnlistenEventListener.Scope.UNLISTEN, null);

        List<DomainEvent> theEvents = theEventRegistry.listen(getLongPollingListener(), TEST_USER_ID);
        assertNotNull(theEvents);
        assertEquals(1, theEvents.size());
        assertFalse(theEvents.get(0).getEvent() instanceof UnlistenEvent);

        assertTrue(theEventRegistry.isUserRegistered(TEST_USER_ID));

        //It is waiting for events and will cause a timeout, because the max. waiting time is configured longer than the timeout time.
        //The result is a UnlistenEvent, because the timeout doesn't effect that method, but the next call.
        theEvents = theEventRegistry.listen(getLongPollingListener(), TEST_USER_ID);

        //wait for the UserActivityScheduler-Thread
        Thread.yield();
        Thread.sleep(theNewEventServiceConfiguration.getTimeoutTime() + 100);

        assertNotNull(theEvents);
        assertEquals(1, theEvents.size());
        assertTrue(theEvents.get(0).getEvent() instanceof UnlistenEvent);
        assertFalse(theEventRegistry.isUserRegistered(TEST_USER_ID));
View Full Code Here

TOP

Related Classes of de.novanic.eventservice.config.EventServiceConfiguration

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.