Package org.xmlBlaster.client.qos

Examples of org.xmlBlaster.client.qos.GetQos


      try {
         Global gAdmin = glob.getClone(null);
         connAdmin = gAdmin.getXmlBlasterAccess();
         connAdmin.connect(new ConnectQos(gAdmin, user, passwd), null);
         GetKey gk = new GetKey(glob, command);
         GetQos gq = new GetQos(glob);
         MsgUnit[] msgs = connAdmin.get(gk, gq);
         return msgs;
      }
      finally {
         if (connAdmin != null) { try { connAdmin.disconnect(null); } catch (Throwable et) {} }
View Full Code Here


               publishMessages();
               continue;
            }
            else if (key == 'g') {
               GetKey gk = new GetKey(glob, "Banking");
               GetQos gq = new GetQos(glob);
               try {
                  MsgUnit[] msgs = con.get(gk, gq);
                  if (msgs.length > 0) {
                     GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
                     log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
View Full Code Here

      if (con == null) {
         if (log.isLoggable(Level.FINE)) log.fine("forwardGet - Nothing to forward");
         return null;
      }

      return con.get(new GetKey(glob, xmlKey), new GetQos(glob, getQos.getData()));
   }
View Full Code Here

      MsgUnit[] msgs = null;

      try {
         // starts the get request for the given oid
         msgs = connection.get(new GetKey(glob, oid, Constants.EXACT).toXml(),
               new GetQos(glob).toXml());
      } catch (XmlBlasterException xe) {
         log.throwing(this.getClass().getName(), "run", xe);
      }

      if (msgs == null || msgs.length < 1) {
View Full Code Here

         log.warning("XmlBlasterException: " + e.getMessage());
         assertTrue("publish - XmlBlasterException: " + e.getMessage(), false);
      }

      try {
         GetQos qos = new GetQos(glob);
         qos.addAccessFilter(new AccessFilterQos(glob, "GnuRegexFilter", "1.0", regPattern));

         MsgUnit[] msgUnits = con.get("<key oid='MSG'/>", qos.toXml());
         assertTrue("Expected one returned message", msgUnits!=null);
         assertTrue("Expected exactly one returned message", msgUnits.length==1);
         assertTrue("Message content in corrupted '" + new String(msgUnits[0].getContent()) + "' versus '" + content + "'",
                msgUnits[0].getContent().length == content.length());
         log.info("Success: Got one message.");
      } catch(XmlBlasterException e) {
         log.warning("XmlBlasterException: " + e.getMessage());
         assertTrue("get - XmlBlasterException: " + e.getMessage(), false);
      }


      log.info("TEST 2: The message content does NOT match the pattern");
      try {
         con.publish(new MsgUnit("<key oid='MSG'/>", new String("aaaaaac").getBytes(), null));
      } catch(XmlBlasterException e) {
         log.warning("XmlBlasterException: " + e.getMessage());
         assertTrue("publish - XmlBlasterException: " + e.getMessage(), false);
      }

      try {
         GetQos qos = new GetQos(glob);
         qos.addAccessFilter(new AccessFilterQos(glob, "GnuRegexFilter", "1.0", regPattern));

         MsgUnit[] msgUnits = con.get("<key oid='MSG'/>", qos.toXml());
         if (msgUnits.length > 0) log.info(msgUnits[0].toXml());
         assertTrue("Expected zero returned message", msgUnits!=null);
         assertEquals("Expected zero returned message", 0, msgUnits.length);
         log.info("Success: Got no message.");
      } catch(XmlBlasterException e) {
View Full Code Here

         con.publish(msgUnit);

         // This should not be possible as the message was volatile
         try {
            GetKey gk = new GetKey(glob, "HelloWorldVolatile");
            GetQos gq = new GetQos(glob);
            MsgUnit[] msgs = con.get(gk, gq);
            if (msgs.length > 0) {
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               log.severe("Did not expect any message as it was volatile");
            }
View Full Code Here

            MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
            con.publish(msgUnit);


            GetKey gk = new GetKey(con.getGlobal(), "AllProtocols");
            GetQos gq = new GetQos(con.getGlobal());
            MsgUnit[] msgs = con.get(gk.toXml(), gq.toXml());
            GetReturnQos grq = new GetReturnQos(con.getGlobal(), msgs[0].getQos());

            log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                         "' and status=" + grq.getState());
View Full Code Here

            publishMsg(publishOidArr[0], contentArr[0]);
            publishMsg(publishOidArr[2], contentArr[2]);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...

            GetKey gk = new GetKey(glob, publishOidArr[0]);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<10; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState());
            }

            sendErase(publishOidArr[0]);
            assertEquals("", 0, this.synchronousCache.getNumQueriesCached());
            sendErase(publishOidArr[2]);
         }
         catch (XmlBlasterException e) {
            log.severe("testCachedAccess() failed: " + e.getMessage());
            fail(e.getMessage());
         }
         assertEquals("Unexpected update arrived", 0, this.updateInterceptor.waitOnUpdate(1000L, 0));
      }

      {
         log.info("Entering testCachedAccess with updated MsgUnit ...");
         try {
            PublishReturnQos publishReturnQos = publishMsg(publishOidArr[0], contentArr[0]);

            GetKey gk = new GetKey(glob, publishOidArr[0]);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<5; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               assertEquals("", publishReturnQos.getRcvTimestamp(), grq.getRcvTimestamp());
               assertEquals("", contentArr[0], msgs[0].getContentStr());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState() + " rcv=" + grq.getRcvTimestamp());
            }

            // Now publish again an check if cache is updated
            String contentNew = contentArr[0]+"-NEW";
            publishReturnQos = publishMsg(publishOidArr[0], contentNew);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...
            for (int i=0; i<5; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               assertEquals("", publishReturnQos.getRcvTimestamp().getTimestamp(), grq.getRcvTimestamp().getTimestamp());
               assertEquals("", publishReturnQos.getKeyOid(), msgs[0].getKeyOid());
               assertEquals("", contentNew, msgs[0].getContentStr());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState() + " rcv=" + grq.getRcvTimestamp());
            }

            sendErase(publishOidArr[0]);
            assertEquals("", 0, this.synchronousCache.getNumQueriesCached());
         }
         catch (XmlBlasterException e) {
            log.severe("testCachedAccess() failed: " + e.getMessage());
            fail(e.getMessage());
         }
         assertEquals("Unexpected update arrived", 0, this.updateInterceptor.waitOnUpdate(1000L, 0));
      }

      {
         log.info("Entering testCachedAccess with XPATH ...");
         try {
            PublishReturnQos publishReturnQos0 = publishMsg(publishOidArr[0], contentArr[0]);
            PublishReturnQos publishReturnQos1 = publishMsg(publishOidArr[1], contentArr[1]);
            publishMsg(publishOidArr[2], contentArr[2]);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...

            // This should match [0] and [1] msg:
            GetKey gk = new GetKey(glob, "//key[starts-with(@oid,'oid-')]", Constants.XPATH);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<10; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               assertEquals("", 2, msgs.length);
               GetReturnQos grq0 = new GetReturnQos(glob, msgs[0].getQos());
View Full Code Here

      log.info("Success: Publishing of " + oid + " done");
   }

   private void doGet(String oid, int expect) {
      GetKey key = new GetKey(this.glob, oid);
      GetQos qos = new GetQos(this.glob);
      HistoryQos histQos = new HistoryQos(this.glob, 2);
      qos.setHistoryQos(histQos);
      try {
         MsgUnit[] msg = this.glob.getXmlBlasterAccess().get(key, qos);
         assertNotNull("should not be null", msg);
         assertEquals("the number of returned values is wrong", expect, msg.length);
      }
View Full Code Here

    */
   public void testGetQos() {
      System.out.println("***QueryQosFactoryTest: GetQos ...");
     
      try {
         GetQos getQos = new GetQos(glob);
         getQos.setWantContent(false);
         HistoryQos hh = new HistoryQos(glob, 33);
         hh.setNewestFirst(false);
         getQos.setHistoryQos(hh);
         getQos.addAccessFilter(new AccessFilterQos(glob, "ContentLenFilter", "1.0", new Query(glob, "800")));
         getQos.addAccessFilter(new AccessFilterQos(glob, "ContentLenFilter2", "3.2", new Query(glob, "a<10")));
         System.out.println("GetQos: " + getQos.toXml());
         QueryQosData qos = factory.readObject(getQos.toXml());
         assertEquals("", false, qos.getWantContent());
         assertEquals("", 33, qos.getHistoryQos().getNumEntries());
         assertEquals("", false, qos.getHistoryQos().getNewestFirst());
         AccessFilterQos[] filterArr = qos.getAccessFilterArr();
         assertEquals("", 2, filterArr.length);
View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.qos.GetQos

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.