Examples of MsgInterceptor


Examples of org.xmlBlaster.test.MsgInterceptor

   /**
    * Connect to xmlBlaster and login
    */
   protected void setUp() {
      try {
         this.msgInterceptor = new MsgInterceptor(glob, log, null);
         this.senderConnection = glob.getXmlBlasterAccess();
         String passwd = "secret";
         ConnectQos qos = new ConnectQos(glob, senderName, passwd);
         this.senderConnection.connect(qos, this.msgInterceptor);
      }
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

         serverThread = EmbeddedXmlBlaster.startXmlBlaster(glob);
         log.info("XmlBlaster is ready for testing");

         log.info("============ STEP 5: Start subscriber");
         // A testsuite helper to collect update messages
         this.updateInterceptorRcv = new MsgInterceptor(glob, log, null);

         Global globRcv = glob.getClone(null);
         conRcv = globRcv.getXmlBlasterAccess();
        
         ConnectQos qosSub = new ConnectQos(globRcv, sessionNameRcv, passwd);
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

      }

      try {
         con = glob.getXmlBlasterAccess();
         ConnectQos qos = new ConnectQos(glob); // == "<qos></qos>";
         this.updateInterceptor = new MsgInterceptor(this.glob, log, this);
         con.connect(qos, this.updateInterceptor);
      }
      catch (Exception e) {
          log.severe(e.toString());
          e.printStackTrace();
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

         ConnectQos qosSnd = new ConnectQos(globSnd);
         String secretSndCbSessionId = "TrustMeSubSnd";
         CallbackAddress addrSnd = new CallbackAddress(globSnd);
         addrSnd.setSecretCbSessionId(secretSndCbSessionId);
         qosSnd.getSessionCbQueueProperty().setCallbackAddress(addrSnd);
         this.updateInterceptorSnd = new MsgInterceptor(globSnd, log, null);
         ConnectReturnQos crqPub = conSnd.connect(qosSnd, this.updateInterceptorSnd);
         log.info("Connect success as " + crqPub.getSessionName());

         log.info("============ STEP 2: Subscribe in Pub/Sub mode");
         SubscribeKey sk = new SubscribeKey(globSnd, oid);
         SubscribeQos sq = new SubscribeQos(globSnd);
         sq.setWantInitialUpdate(false);
         sq.setWantLocal(true);
         SubscribeReturnQos srq = conSnd.subscribe(sk, sq);
         log.info("Subscription to '" + oid + "' done");
         assertEquals("", 0, this.updateInterceptorSnd.waitOnUpdate(1000L, oid, Constants.STATE_OK));

         log.info("============ STEP 3: Start receiver");
         Global globRcv = glob.getClone(null);
         conRcv = globRcv.getXmlBlasterAccess();
         ConnectQos qosRcv = new ConnectQos(globRcv, sessionNameRcv, passwd);
         CallbackAddress addr = new CallbackAddress(globRcv);
         addr.setRetries(-1);
         String secretCbSessionId = "TrustMeSub";
         addr.setSecretCbSessionId(secretCbSessionId);
         qosRcv.getSessionCbQueueProperty().setCallbackAddress(addr);
         this.updateInterceptorRcv = new MsgInterceptor(globRcv, log, null);
         ConnectReturnQos crqRcv = conRcv.connect(qosRcv, this.updateInterceptorRcv); // Login to xmlBlaster
         log.info("Connect as subscriber '" + crqRcv.getSessionName() + "' success");

         {
            log.info("============ STEP 4: Publish PtP message which is NOT subscribable");
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

         cbProps.setRetries(1);
         cbProps.setDelay(1000);
         cbProps.setPtpAllowed(true);
         qos.addCallbackAddress(cbProps);

         this.updateInterceptor = new MsgInterceptor(this.glob, log, null);
         con.connect(qos, this.updateInterceptor); // Login to xmlBlaster and collect update messages with interceptor
      }
      catch (Exception e) {
         log.severe(e.toString() + " \n" + glob.getProperty().toXml() + " GLOBAL.INSTANCE:\n" + Global.instance().getProperty().toXml());
         e.printStackTrace();
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

   Logger log = Logger.getLogger(PtPDestination.class.getName());
  
   public PtPDestination(Global parentGlobal, String sessionName) {
      this.global = parentGlobal.getClone(null);
      this.sessionName = new SessionName(this.global, sessionName);
      this.updateInterceptor = new MsgInterceptor(this.global, log, null);
   }
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

    */
   protected void setUp() {
      try {
         senderConnection = glob.getXmlBlasterAccess(); // Find orb
         ConnectQos qos = new ConnectQos(this.glob, this.senderName, "secret");
         this.updateInterceptor = new MsgInterceptor(this.glob, log, null);
         senderConnection.connect(qos, this.updateInterceptor); // Login to xmlBlaster
      }
      catch (Exception e) {
          log.severe("Login failed: " + e.toString());
          e.printStackTrace();
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

      try {
         log.info("============ STEP 1: Start subscriber");

         Global globSub = glob.getClone(null);
         // A testsuite helper to collect update messages
         this.updateInterceptorSub = new MsgInterceptor(globSub, log, null);

         conSub = globSub.getXmlBlasterAccess();
        
         ConnectReturnQos crqSub = null;
         {
            ConnectQos qosSub = new ConnectQos(globSub, sessionNameSub, passwd);

            CallbackAddress addr = new CallbackAddress(globSub);
            addr.setRetries(-1);
            String secretCbSessionId = "TrustMeSub";
            addr.setSecretCbSessionId(secretCbSessionId);
            qosSub.getSessionCbQueueProperty().setCallbackAddress(addr);

            log.info("First subscribe connect QoS = " + qosSub.toXml());
            crqSub = conSub.connect(qosSub, this.updateInterceptorSub); // Login to xmlBlaster
            log.info("Connect as subscriber '" + crqSub.getSessionName() + "' success");
         }

         SubscribeKey sk = new SubscribeKey(globSub, oid);
         SubscribeQos sq = new SubscribeQos(globSub);
         sq.setWantInitialUpdate(false);
         sq.setWantLocal(true);
         sq.setWantContent(true);
        
         HistoryQos historyQos = new HistoryQos(globSub);
         historyQos.setNumEntries(1);
         sq.setHistoryQos(historyQos);

         /*SubscribeReturnQos srq = */conSub.subscribe(sk.toXml(), sq.toXml());
         log.info("Subscription to '" + oid + "' done");

         log.info("============ STEP 2: Start publisher");
         Global globPub = glob.getClone(null);
         conPub = globPub.getXmlBlasterAccess();
         ConnectQos qosPub = new ConnectQos(globPub, sessionNamePub, passwd);
         ConnectReturnQos crqPub = conPub.connect(qosPub, null)// Login to xmlBlaster, no updates
         log.info("Connect success as " + crqPub.getSessionName());

         log.info("============ STEP 3: Stop subscriber callback");
         try {
            Client.shutdownCb(conSub, Client.Shutdown.KEEP_LOGGED_IN);
            // conSub.getCbServer().shutdown();
         }
         catch (XmlBlasterException e) {
            fail("ShutdownCB: " + e.getMessage());
         }

         log.info("============ STEP 4: Publish messages");
         int numPub = 8;
         MsgUnit[] sentArr = new MsgUnit[numPub];
         PublishReturnQos[] sentQos = new PublishReturnQos[numPub];
         for(int i=0; i<numPub; i++) {
            PublishKey pk = new PublishKey(globPub, oid, "text/xml", "1.0");
            pk.setClientTags("<org.xmlBlaster><demo/></org.xmlBlaster>");
            PublishQos pq = new PublishQos(globPub);
            pq.setPriority(PriorityEnum.NORM_PRIORITY);
            pq.setPersistent(false);
            pq.setLifeTime(60000L);
            if (i == 0) {
               TopicProperty topicProperty = new TopicProperty(globPub);
               topicProperty.setDestroyDelay(60000L);
               topicProperty.setCreateDomEntry(true);
               topicProperty.setReadonly(false);
               topicProperty.getHistoryQueueProperty().setMaxEntries(numPub+5);
               pq.setTopicProperty(topicProperty);
               log.info("Added TopicProperty on first publish: " + topicProperty.toXml());
            }

            byte[] content = "Hello".getBytes();
            MsgUnit msgUnit = new MsgUnit(pk, content, pq);
            sentArr[i] = msgUnit;
            PublishReturnQos prq = conPub.publish(msgUnit);
            sentQos[i] = prq;
            log.info("Got status='" + prq.getState() + "' rcvTimestamp=" + prq.getRcvTimestamp().toString() +
                        " for published message '" + prq.getKeyOid() + "'");
         }

         log.info("============ STEP 5: Start subscriber callback with same public sessionId");
         Global globSub2 = glob.getClone(null);
         MsgInterceptor updateInterceptorSub2 = new MsgInterceptor(globSub2, log, null);
         updateInterceptorSub2.setLogPrefix("TrustMeSub2");

         conSub2 = globSub2.getXmlBlasterAccess(); // Create a new client
         String secretCbSessionId2 = "TrustMeSub2";
         {
            ConnectQos qosSub = new ConnectQos(globSub, sessionNameSub, passwd);
            CallbackAddress addr = new CallbackAddress(globSub);
            addr.setRetries(-1);
            addr.setSecretCbSessionId(secretCbSessionId2);
            qosSub.getSessionCbQueueProperty().setCallbackAddress(addr);
            qosSub.getSessionQos().setSessionName(crqSub.getSessionQos().getSessionName());

            log.info("Second subscribe connect QoS = " + qosSub.toXml());
            ConnectReturnQos crqSub2 = conSub2.connect(qosSub, updateInterceptorSub2); // Login to xmlBlaster
            log.info("Connect as subscriber '" + crqSub2.getSessionName() + "' success");
         }

         assertEquals("", 0, updateInterceptorSub.count()); // The first login session should not receive anything

         assertEquals("", numPub, updateInterceptorSub2.waitOnUpdate(4000L, oid, Constants.STATE_OK));
         updateInterceptorSub2.compareToReceived(sentArr, secretCbSessionId2);
         updateInterceptorSub2.compareToReceived(sentQos);

         updateInterceptorSub2.clear();
      }
      catch (XmlBlasterException e) {
         log.severe(e.toString());
         fail(e.toString());
      }
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

         try {
            log.info("Connecting ...");
            Global globTmp = glob.getClone(null);
            this.conHolderArr[ii].con = globTmp.getXmlBlasterAccess();
            ConnectQos qos = new ConnectQos(globTmp, name, passwd);
            this.conHolderArr[ii].update = new MsgInterceptor(globTmp, log, null);
            this.conHolderArr[ii].connectReturnQos = this.conHolderArr[ii].con.connect(qos, this.conHolderArr[ii].update);
         }
         catch (Exception e) {
            Thread.dumpStack();
            log.severe("Can't connect to xmlBlaster: " + e.toString());
View Full Code Here

Examples of org.xmlBlaster.test.MsgInterceptor

    * Default ctor.
    */
   public TestReplication() {
      super();
      XMLUnit.setIgnoreWhitespace(true);
      this.interceptor = new MsgInterceptor(new Global(), log, null, (I_Update)null);
   }
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.