Examples of PushResponse


Examples of org.drools.guvnor.client.rpc.PushResponse

    public void testSimple() throws Exception {

        final Backchannel backchannel = Backchannel.getInstance();

        backchannel.push( "mici",
                          new PushResponse( "m",
                                            "b" ) );
        backchannel.push( "davos",
                          new PushResponse( "d",
                                            "b" ) );
        List<PushResponse> r = backchannel.await( "mici" );
        assertEquals( 1,
                      r.size() );
        assertEquals( "m",
                      r.get( 0 ).messageType );
        r = backchannel.await( "davos" );
        assertEquals( 1,
                      r.size() );
        assertEquals( "d",
                      r.get( 0 ).messageType );

        final boolean[] check = new boolean[1];

        Thread t = new Thread( new Runnable() {
            public void run() {
                try {
                    @SuppressWarnings("unused")
                    List<PushResponse> list = backchannel.await( "mici" );
                    /*
                    for (PushResponse resp: list) {
                                       System.err.println(resp.messageType + "," + resp.message);
                    }
                    */
                    check[0] = true;
                } catch ( InterruptedException e ) {
                    fail( "Should not interrupt" );
                }
            }
        } );

        t.setDaemon( true );
        t.start();

        Thread.sleep( 400 );

        assertFalse( check[0] );
        backchannel.push( "davos",
                          new PushResponse( "x",
                                            "y" ) );
        //bc.push("mic", new PushResponse("Q", "W"));
        t.join();

        check[0] = false;
        backchannel.push( "mici",
                          new PushResponse( "R",
                                            "T" ) );
        backchannel.push( "mici",
                          new PushResponse( "Q",
                                            "A" ) );

        final List<List<PushResponse>> container = new ArrayList<List<PushResponse>>();

        t = new Thread( new Runnable() {
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

        for ( int i = 0; i < 1000; i++ ) {
            spinup( backchannel,
                    i );
        }
        backchannel.push( "mc",
                          new PushResponse( "yo",
                                            "yo" ) );
        backchannel.push( "mc",
                          new PushResponse( "yo",
                                            "yo" ) );

        //for (int i=0; i< 1000; i++) {
        List<PushResponse> res = backchannel.await( "mc" );
        assertEquals( 2,
                      res.size() );

        res = backchannel.await( "mc" );
        assertEquals( 0,
                      res.size() );
        //assertNull(res); //as other concurrent things will be unlatching...

        Thread.sleep( 20 );

        for ( int i = 0; i < 20000; i++ ) {
            backchannel.push( "mc",
                              new PushResponse( "yo",
                                                "yo" ) );
            backchannel.push( "mc",
                              new PushResponse( "yo",
                                                "yo" ) );

            res = backchannel.await( "mc" );
            assertEquals( 2,
                          res.size() );
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

                    Thread.sleep( i / 2 );
                } catch ( InterruptedException e ) {
                    fail( "should not interrupt" );
                }
                bc.push( i + "user",
                         new PushResponse( i + "type",
                                           "message" ) );
            }
        } );

        t.setDaemon( true );
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

        t2.start();


        Thread.sleep(200);

        bc.publish(new PushResponse("hey", "ho"));

        //t.join();
        //t2.join();

        Thread.sleep(500);
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

    public void testSimple() throws Exception {

            final Backchannel bc = new Backchannel();

        bc.push("mic", new PushResponse("m", "b"));
        bc.push("dave", new PushResponse("d", "b"));
        List<PushResponse> r = bc.await("mic");
        assertEquals(1, r.size());
        assertEquals("m", r.get(0).messageType);
        r = bc.await("dave");
        assertEquals(1, r.size());
        assertEquals("d", r.get(0).messageType);


        final boolean[] check = new boolean[1];

        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    List<PushResponse> list = bc.await("mic");
                    /*
                    for (PushResponse resp: list) {
                                       System.err.println(resp.messageType + "," + resp.message);
                    }
                    */
                    check[0] = true;
                } catch (InterruptedException e) {
                    fail("Should not interrupt");
                }
            }
        });

        t.setDaemon(true);
        t.start();


        Thread.sleep(400);

        assertFalse(check[0]);
        bc.push("dave", new PushResponse("x", "y"));
        //bc.push("mic", new PushResponse("Q", "W"));
        t.join();



       

        check[0] = false;
        bc.push("mic", new PushResponse("R", "T"));
        bc.push("mic", new PushResponse("Q", "A"));


        final List<List<PushResponse>> container = new ArrayList();

        t = new Thread(new Runnable() {
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

    public void testManyConcurrent() throws Exception {
        final Backchannel bc = new Backchannel();
        for (int i =0; i < 1000; i++) {
            spinup(bc, i);
        }
        bc.push("mic", new PushResponse("yo", "yo"));
        bc.push("mic", new PushResponse("yo", "yo"));

        //for (int i=0; i< 1000; i++) {
        List<PushResponse> res = bc.await("mic");
        assertEquals(2, res.size());

        res = bc.await("mic");
        assertEquals(0, res.size());
        //assertNull(res); //as other concurrent things will be unlatching...

        Thread.sleep(20);

        for (int i = 0; i < 20000; i++) {
            bc.push("mic", new PushResponse("yo", "yo"));
            bc.push("mic", new PushResponse("yo", "yo"));

            res = bc.await("mic");
            assertEquals(2, res.size());
        }
    }
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

                try {
                    Thread.sleep(i / 2);
                } catch (InterruptedException e) {
                    fail("should not interrupt");
                }
                bc.push(i + "user", new PushResponse(i + "type", "message"));
            }
        });

        t.setDaemon(true);
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

        return repositoryAssetOperations.getAssetCount(request);
    }

    private void push(String messageType,
                      String message) {
        Backchannel.getInstance().publish(new PushResponse(messageType,
                message));
    }
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

        return repositoryAssetOperations.getAssetCount( request );
    }

    private void push(String messageType,
                      String message) {
        backchannel.publish( new PushResponse( messageType,
                                               message ) );
    }
View Full Code Here

Examples of org.drools.guvnor.client.rpc.PushResponse

    /**
     * Pushes a message back to (all) clients.
     */
    private void push(String messageType,
                      String message) {
        backchannel.publish( new PushResponse( messageType,
                                                             message ) );
    }
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.