Package de.novanic.eventservice.service.registry.user

Examples of de.novanic.eventservice.service.registry.user.UserInfo


        assertContainsScriptCycle(theByteArrayOutputStream.toString());
    }

    @Test
    public void testListen_Max_Waiting_Concurrency() throws Exception {
        final UserInfo theUserInfo = new UserInfo("test_user") {
            private boolean isFirstCall = true;
            private boolean isSecondCall = false;

            public boolean isEventsEmpty() {
                if(isFirstCall) {
                    isFirstCall = false;
                    isSecondCall = true;
                    return true;
                } else if(isSecondCall) {
                    isSecondCall = false;
                    return false;
                } else {
                    return true;
                }
            }
        };

        long theLastActivationTime = theUserInfo.getLastActivityTime();
        long theStartTime = System.currentTimeMillis();

        StreamingServerConnector theStreamingServerConnector = createStreamingServerConnector(700, new ByteArrayOutputStream());
        theStreamingServerConnector.listen(theUserInfo);

        long theEndTime = System.currentTimeMillis();
        assertTrue(theEndTime - theStartTime >= 600); //one cycle is expected...
        assertEquals(theLastActivationTime, theUserInfo.getLastActivityTime()); //..., but no user activity was reported, caused by the failed double-check
    }
View Full Code Here


public class LongPollingServerConnectorTest extends ConnectionStrategyServerConnectorTest
{
    @Test
    public void testListen() throws Exception {
        final Domain theDomain = DomainFactory.getDomain("test_domain");
        final UserInfo theUserInfo = new UserInfo("test_user");

        ConnectionStrategyServerConnector theLongPollingListener = new LongPollingServerConnector(createConfiguration(0, 2000, 90000));

        ListenRunnable theListenRunnable = new ListenRunnable(theLongPollingListener, theUserInfo);
        Thread theListenThread = new Thread(theListenRunnable);
        theListenThread.start();

        theUserInfo.addEvent(theDomain, new DummyEvent());

        theListenThread.join();

        ListenResult theListenResult = theListenRunnable.getListenResult();
        assertEquals(1, theListenResult.getEvents().size());
View Full Code Here

    }

    @Test
    public void testListen_Min_Waiting() throws Exception {
        final Domain theDomain = DomainFactory.getDomain("test_domain");
        final UserInfo theUserInfo = new UserInfo("test_user");

        ConnectionStrategyServerConnector theLongPollingListener = new LongPollingServerConnector(createConfiguration(500, 2000, 90000));

        ListenRunnable theListenRunnable = new ListenRunnable(theLongPollingListener, theUserInfo);
        Thread theListenThread = new Thread(theListenRunnable);
        theListenThread.start();

        theUserInfo.addEvent(theDomain, new DummyEvent());

        theListenThread.join();

        ListenResult theListenResult = theListenRunnable.getListenResult();
        assertEquals(1, theListenResult.getEvents().size());
View Full Code Here

    }

    @Test
    public void testListen_Min_Waiting_Interrupted() throws Exception {
        final Domain theDomain = DomainFactory.getDomain("test_domain");
        final UserInfo theUserInfo = new UserInfo("test_user");
        ConnectionStrategyServerConnector theLongPollingListener = new LongPollingServerConnector(createConfiguration(1000, 2000, 90000));

        ListenRunnable theListenRunnable = new ListenRunnable(theLongPollingListener, theUserInfo);
        Thread theListenThread = new Thread(theListenRunnable);

        Date theStartTime = new Date();
        theListenThread.start();

        theUserInfo.addEvent(theDomain, new DummyEvent());

        //wait to ensure that the connector is waiting
        Thread.sleep(200);

        //interrupt min. waiting
View Full Code Here

        assertTrue((theEndTime.getTime() - theStartTime.getTime()) < 1000);
    }

    @Test
    public void testListen_Max_Waiting() throws Exception {
        final UserInfo theUserInfo = new UserInfo("test_user");

        ConnectionStrategyServerConnector theLongPollingListener = new LongPollingServerConnector(createConfiguration(0, 500, 90000));

        ListenRunnable theListenRunnable = new ListenRunnable(theLongPollingListener, theUserInfo);
        Thread theListenThread = new Thread(theListenRunnable);
View Full Code Here

//        assertTrue(theListenDomains.isEmpty());
//    }

    @Test
    public void testUnlisten_Termination() {
        UserInfo theTestUser_1 = mock(UserInfo.class, TEST_USER_ID);
        when(theTestUser_1.getUserId()).thenReturn(TEST_USER_ID);
        when(theTestUser_1.getLastActivityTime()).thenReturn(PlatformUtil.getCurrentTime());
        when(theTestUser_1.getUnlistenEvent()).thenReturn(new DefaultUnlistenEvent());

        UserInfo theTestUser_2 = mock(UserInfo.class, TEST_USER_ID_2);
        when(theTestUser_2.getUserId()).thenReturn(TEST_USER_ID_2);
        when(theTestUser_2.getLastActivityTime()).thenReturn(PlatformUtil.getCurrentTime());
        when(theTestUser_2.getUnlistenEvent()).thenReturn(new DefaultUnlistenEvent());

        UserManager theUserManager = UserManagerFactory.getInstance().getUserManager(99999);
        theUserManager.addUser(theTestUser_1);
        theUserManager.addUser(theTestUser_2);
View Full Code Here

TOP

Related Classes of de.novanic.eventservice.service.registry.user.UserInfo

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.