Package org.xmlBlaster.test.util

Examples of org.xmlBlaster.test.util.Client


    */
   public void testSubSubPub() {
      try {
         boolean consumable = true;
         int session = 1;
         Client pub1 = new Client(this.global, "pub1", responses);
         pub1.init("testConsumableQueue", null, consumable, session);

         Client sub1 = new Client(this.global, "sub1", responses);
         sub1.init(null, "testConsumableQueue", consumable, session);
         Client sub2 = new Client(this.global, "sub2", responses);
         sub2.init(null, "testConsumableQueue", consumable, session);
         Client deadMsg = new Client(this.global, "deadMsg", responses);
         deadMsg.init(null, "__sys__deadMessage", !consumable, session);
        
         assertEquals("wrong number of initial responses", 0, responses.size());

         synchronized(responses) {
            pub1.publish("firstMessage");
            for (int i=0; i < 1; i++) responses.wait(WAIT_DELAY);
            Thread.sleep(200L); // wait in case an unexpected update comes in betweeen
            assertEquals("wrong number of updates", 1, responses.size());
         }
         responses.clear();        

         synchronized(responses) {
            sub1.setUpdateException(new XmlBlasterException(this.global, ErrorCode.USER_UPDATE_ERROR, "testSubSubPub"));
            pub1.publish("firstMessage");
            for (int i=0; i < 2; i++) responses.wait(WAIT_DELAY);
            Thread.sleep(200L); // wait in case an unexpected update comes in betweeen
            assertEquals("wrong number of updates", 2, responses.size());
            assertEquals("update should be a dead message", "deadMsg", responses.get(1));
         }

         responses.clear();        
         synchronized(responses) {
            sub1.setUpdateException(null);
            sub2.setUpdateException(new XmlBlasterException(this.global, ErrorCode.USER_UPDATE_ERROR, "testSubSubPub"));
            pub1.publish("firstMessage");
            for (int i=0; i < 1; i++) responses.wait(WAIT_DELAY);
            Thread.sleep(200L); // wait in case an unexpected update comes in betweeen
            assertEquals("wrong number of updates, since the first sub receives, so it should not even try the second", 1, responses.size());
         }

         /** only one dead message here since the first gives up delivery */        
         responses.clear();        
         synchronized(responses) {
            sub1.setUpdateException(new XmlBlasterException(this.global, ErrorCode.USER_UPDATE_ERROR, "testSubSubPub"));
            sub2.setUpdateException(new XmlBlasterException(this.global, ErrorCode.USER_UPDATE_ERROR, "testSubSubPub"));
            pub1.publish("firstMessage");
            for (int i=0; i < 2; i++) responses.wait(WAIT_DELAY);
            Thread.sleep(200L); // wait in case an unexpected update comes in betweeen
            assertEquals("wrong number of updates", 2, responses.size());
            assertEquals("update should be a dead message", "deadMsg", responses.get(1));
         }
        
         sub1.shutdown(false);
         sub2.shutdown(false);
         pub1.shutdown(true);
         deadMsg.shutdown(false);
      }
      catch (Exception ex) {
         ex.printStackTrace();
         assertTrue(false);
      }
View Full Code Here


    */
   public void testPubSub() {
      try {
         boolean consumable = true;
         int session = 1;
         Client pub1 = new Client(this.global, "pub1", responses);
         pub1.init("testConsumableQueue", null, consumable, session);

         pub1.publish("firstMessage");

         Client sub1 = new Client(this.global, "sub1", responses);
         assertEquals("wrong number of initial responses", 0, responses.size());

         synchronized(responses) {
            sub1.init(null, "testConsumableQueue", consumable, session);

            responses.wait(WAIT_DELAY);
            Thread.sleep(1000L); // wait in case an unexpected update comes in betweeen
            assertEquals("wrong number of updates", 1, responses.size());
         }
        
         sub1.shutdown(false);
         pub1.shutdown(true);
      }
      catch (Exception ex) {
         ex.printStackTrace();
         assertTrue(false);
View Full Code Here

    */
   public void testPubSubSub() {
      try {
         boolean consumable = true;
         int session = 1;
         Client pub1 = new Client(this.global, "pub1", responses);
         pub1.init("testConsumableQueue", null, consumable, session);

         pub1.publish("firstMessage");

         Client sub1 = new Client(this.global, "sub1", responses);
         Client sub2 = new Client(this.global, "sub2", responses);
         assertEquals("wrong number of initial responses", 0, responses.size());

         synchronized(responses) {
            sub1.init(null, "testConsumableQueue", consumable, session);
            sub2.init(null, "testConsumableQueue", consumable, session);

            responses.wait(WAIT_DELAY);
            Thread.sleep(1000L); // wait in case an unexpected update comes in betweeen
            assertEquals("wrong number of updates", 1, responses.size());
         }
        
         sub1.shutdown(false);
         sub2.shutdown(false);
         pub1.shutdown(true);
      }
      catch (Exception ex) {
         ex.printStackTrace();
         assertTrue(false);
View Full Code Here

TOP

Related Classes of org.xmlBlaster.test.util.Client

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.