CVS update: JGroups/tests/junit-functional/org/jgroups/tests ProgrammaticApiTest.java

"Bela Ban" <[email protected]> Wed, 20 Oct 2010 12:19:02 +0000
Newsgroups gmane.comp.java.javagroups.cvs
Message-ID <[email protected]>
  User: belaban 
  Date: 10/10/20 12:19:02

  Modified:    tests/junit-functional/org/jgroups/tests
                        ProgrammaticApiTest.java
  Log:
  ns
  
  Revision  Changes    Path
  1.2       +19 -6     JGroups/tests/junit-functional/org/jgroups/tests/ProgrammaticApiTest.java
  
  Index: ProgrammaticApiTest.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/tests/junit-functional/org/jgroups/tests/ProgrammaticApiTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProgrammaticApiTest.java	6 Oct 2010 09:46:32 -0000	1.1
  +++ ProgrammaticApiTest.java	20 Oct 2010 12:19:02 -0000	1.2
  @@ -9,18 +9,15 @@
   
   /**
    * @author Bela Ban
  - * @version $Id: ProgrammaticApiTest.java,v 1.1 2010/10/06 09:46:32 belaban Exp $
  + * @version $Id: ProgrammaticApiTest.java,v 1.2 2010/10/20 12:19:02 belaban Exp $
    */
   @Test(groups=Global.FUNCTIONAL,sequential=false)
   public class ProgrammaticApiTest {
   
       public void testChannelCreation() throws Exception {
           JChannel ch=new JChannel(false);
  -        ch.setReceiver(new ReceiverAdapter() {
  -            public void receive(Message msg) {
  -                System.out.println("<< " + msg);
  -            }
  -        });
  +        MyReceiver receiver=new MyReceiver();
  +        ch.setReceiver(receiver);
           ProtocolStack stack=ch.createProtocolStack();
           stack.addProtocol(new SHARED_LOOPBACK()).addProtocol(new MockProtocol1()).addProtocol(new MockProtocol2());
           stack.init();
  @@ -29,6 +26,8 @@
           Protocol transport=stack.getTransport();
           transport.up(new Event(Event.MSG, new Message(null, Util.createRandomAddress(), "hello world")));
   
  +        Util.close(ch);
  +        assert receiver.getNumMsgsReceived() == 1;
       }
   
   
  @@ -40,4 +39,18 @@
       protected static class MockProtocol2 extends Protocol {
           
       }
  +
  +
  +    static class MyReceiver extends ReceiverAdapter {
  +        int num_msgs_received=0;
  +
  +        public int getNumMsgsReceived() {
  +            return num_msgs_received;
  +        }
  +
  +        public void receive(Message msg) {
  +            System.out.println("<< " + msg);
  +            num_msgs_received++;
  +        }
  +    }
   }
  
  
  

------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev