Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.SessionName


    */
   public void updateEntry() {
      log.info("************ Starting updateEntry " + System.getProperty("java.vm.vendor") + ": " + System.getProperty("java.vm.version"));
      StorageId storageId = new StorageId(glob, Constants.RELATING_CALLBACK, "updateEntry");
      try {
         SessionName receiver = new SessionName(glob, "receiver1");
         PublishQosServer publishQosServer = new PublishQosServer(glob, "<qos/>");
         MsgUnit msgUnit = new MsgUnit(glob, "<key oid='XX'/>", new byte[0], publishQosServer.toXml());
         org.xmlBlaster.engine.ServerScope global = new org.xmlBlaster.engine.ServerScope();
         MsgUnitWrapper msgWrapper = new MsgUnitWrapper(glob, msgUnit, storageId);

View Full Code Here


         Global tmpGlobal = this.origGlobal.getClone(null);
         I_XmlBlasterAccess con = tmpGlobal.getXmlBlasterAccess(); // Find orb

         String passwd = "secret";
         ConnectQos connectQos = new ConnectQos(tmpGlobal, senderName, passwd); // == "<qos>...</qos>";
         connectQos.setSessionName(new SessionName(tmpGlobal, "general/1"));
         // set the persistent connection
         connectQos.setPersistent(this.persistent);
         // Setup fail save handling for connection ...
         Address addressProp = new Address(tmpGlobal);
         addressProp.setDelay(reconnectDelay); // retry connecting every 2 sec
         addressProp.setRetries(-1);       // -1 == forever
         addressProp.setPingInterval(-1L); // switched off
         con.registerConnectionListener(this);
         connectQos.setAddress(addressProp);
        
         // setup failsafe handling for callback ...
         if (this.failsafeCallback) {
            CallbackAddress cbAddress = new CallbackAddress(tmpGlobal);
            cbAddress.setRetries(-1);
            cbAddress.setPingInterval(-1);
            cbAddress.setDelay(1000L);
            cbAddress.setSecretCbSessionId("someSecredSessionId");
            connectQos.addCallbackAddress(cbAddress);
         }
         con.connect(connectQos, this);
         DisconnectQos disconnectQos = new DisconnectQos(tmpGlobal);
         con.disconnect(disconnectQos);
      }
      catch (XmlBlasterException e) {
          log.warning("setUp() - login failed: " + e.getMessage());
          fail("setUp() - login fail: " + e.getMessage());
      }
      catch (Exception e) {
          log.severe("setUp() - login failed: " + e.toString());
          e.printStackTrace();
          fail("setUp() - login fail: " + e.toString());
      }

      System.out.println("============== Connect for general/1");

      try {
         I_XmlBlasterAccess con = this.glob.getXmlBlasterAccess(); // Find orb

         String passwd = "secret";
         ConnectQos connectQos = new ConnectQos(this.glob, senderName, passwd); // == "<qos>...</qos>";
         connectQos.setSessionName(new SessionName(this.glob, "general/1"));
         // set the persistent connection
         connectQos.setPersistent(this.persistent);
         // Setup fail save handling for connection ...
         Address addressProp = new Address(glob);
         addressProp.setDelay(reconnectDelay); // retry connecting every 2 sec
View Full Code Here

   private Global createConnection(Global parentGlobal, String sessionName, boolean isPersistent, boolean expectEx) {
      try {
         Global ret = parentGlobal.getClone(null);
         I_XmlBlasterAccess con = ret.getXmlBlasterAccess(); // Find orb
         ConnectQos connectQos = new ConnectQos(glob); // == "<qos>...</qos>";
         connectQos.setSessionName(new SessionName(ret, sessionName));
         // set the persistent connection
         connectQos.setPersistent(isPersistent);
         // Setup fail save handling for connection ...
         Address addressProp = new Address(glob);
         addressProp.setDelay(reconnectDelay); // retry connecting every 2 sec
View Full Code Here

    * @param counts an int[] containing the expected amount of updates for each
    *        destination. NOTE this has to be filled out even if you expect an
    */
   private void doPublish(int destNum, boolean forceQueuing, boolean expectEx, int[] counts, long timeout, boolean persistent, String contentPrefix) {

      SessionName toSessionName = null;
      if (destNum < 0) toSessionName = new SessionName(this.glob, this.subjectName);
      else toSessionName = this.destinations[destNum].getSessionName();
     
      // String oid = "Message" + "-" + counter;
      log.info("Publishing a message " + toSessionName.getRelativeName() + " ...");
      PublishKey key = new PublishKey(this.glob, "testPtPDispatch");
     
      Destination destination = new Destination(this.glob, toSessionName);
      destination.forceQueuing(forceQueuing);
      PublishQos qos = new PublishQos(this.glob, destination);
      qos.setPersistent(persistent);
  
      String content = contentPrefix + "-" + this.counter;
      this.counter++;
      MsgUnit msgUnit = new MsgUnit(key, content.getBytes(), qos);

      try {
         this.glob.getXmlBlasterAccess().publish(msgUnit);
         assertTrue("did expect an exception after publishing to " + toSessionName.getRelativeName() + " here but got none", !expectEx);
      }
      catch (XmlBlasterException ex) {
         if (!expectEx) ex.printStackTrace();
         assertTrue("did'nt expect an exception after publishing to " + toSessionName.getRelativeName() + " here but got one: " + ex.getMessage(), expectEx);
      }
      log.info("Success: Publishing of message for " + toSessionName.getRelativeName() + " done");

      for (int i=0; i < this.destinations.length; i++)
         this.destinations[i].check(timeout, counts[i]);
   }
View Full Code Here

   }

   public void testMatch() {
      System.out.println("***SessionNameTest: testMatch ...");
      try {
         SessionName sessionName = new SessionName(glob, "client/jack/session/2");
         assertTrue("", sessionName.matchRelativeName("client/*/session/*"));
         assertTrue("", sessionName.matchRelativeName("client/*/session/2"));
         assertTrue("", sessionName.matchRelativeName("client/jack/session/*"));
         assertTrue("", sessionName.matchRelativeName("client/jack/session/2"));
         assertFalse("", sessionName.matchRelativeName("client/jack/session/3"));
         assertFalse("", sessionName.matchRelativeName("client/joe/session/2"));
         assertFalse("", sessionName.matchRelativeName("client/x"));
         assertEquals("", "client/*/session/2", sessionName.getRelativeSubjectIdWildcard());
         assertEquals("", "client/jack/session/*", sessionName.getRelativePubSessionIdWildcard());
         assertEquals("", "client/*/session/*", sessionName.getRelativeWildcard());
      }
      catch (IllegalArgumentException e) {
         fail("testMatch failed: " + e.toString());
      }
      System.out.println("***SessionNameTest: testMatch done");
View Full Code Here

   }
  
   public void testParse() {
      System.out.println("***SessionNameTest: testParse ...");
      try {
         SessionName sessionName = new SessionName(glob, "jack");
         //assertEquals("", "/node/unknown/client/jack", sessionName.getAbsoluteName());
         assertEquals("", "client/jack", sessionName.getAbsoluteName());
         assertEquals("", (String)null, sessionName.getNodeIdStr());
         assertEquals("", "client/jack", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", 0L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }
        
      try {
         SessionName sessionName = new SessionName(glob, "client/jack");
         System.out.println("AbsoluteName=" + sessionName.getAbsoluteName() + " RelativeName=" + sessionName.getRelativeName());
         assertEquals("", "client/jack", sessionName.getAbsoluteName());
         //assertEquals("", "/node/unknown/client/jack", sessionName.getAbsoluteName());
         assertEquals("", (String)null, sessionName.getNodeIdStr());
         assertEquals("", "client/jack", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", 0L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }
        
      try {
         SessionName sessionName = new SessionName(glob, "client/jack/99");
         System.out.println("AbsoluteName=" + sessionName.getAbsoluteName() + " RelativeName=" + sessionName.getRelativeName());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/99", sessionName.getAbsoluteName());
         else
            assertEquals("", "client/jack/99", sessionName.getAbsoluteName());
         assertEquals("", (String)null, sessionName.getNodeIdStr());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/99", sessionName.getRelativeName());
         else
            assertEquals("", "client/jack/99", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", 99L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }
        
      try {
         SessionName sessionName = new SessionName(glob, "/node/heron/client/jack/session/99");
         System.out.println("AbsoluteName=" + sessionName.getAbsoluteName() + " RelativeName=" + sessionName.getRelativeName());
         if (SessionName.useSessionMarker())
            assertEquals("", "/node/heron/client/jack/session/99", sessionName.getAbsoluteName());
         else
            assertEquals("", "/node/heron/client/jack/99", sessionName.getAbsoluteName());
         assertEquals("", "heron", sessionName.getNodeId().getId());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/99", sessionName.getRelativeName());
         else
            assertEquals("", "client/jack/99", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", 99L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }
        
      try { // Test copy constructor ...
         SessionName tmp = new SessionName(glob, "client/jack");
         SessionName sessionName = new SessionName(glob, tmp, -4L);
         System.out.println("AbsoluteName=" + sessionName.getAbsoluteName() + " RelativeName=" + sessionName.getRelativeName());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/-4", sessionName.getAbsoluteName());
         else
            assertEquals("", "client/jack/-4", sessionName.getAbsoluteName());
         assertEquals("", (String)null, sessionName.getNodeIdStr());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/-4", sessionName.getRelativeName());
         else
            assertEquals("", "client/jack/-4", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", -4L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }

      try { // Test given node ID ...
         SessionName tmp = new SessionName(glob, new NodeId("avalon"), "client/jack");
         SessionName sessionName = new SessionName(glob, tmp, -4);
         System.out.println("AbsoluteName=" + sessionName.getAbsoluteName() + " RelativeName=" + sessionName.getRelativeName());
         if (SessionName.useSessionMarker())
            assertEquals("Expected /node/avalon/client/jack/session/-4 but was:" + sessionName.getAbsoluteName(), "/node/avalon/client/jack/session/-4", sessionName.getAbsoluteName());
         else
            assertEquals("Expected /node/avalon/client/jack/-4 but was:" + sessionName.getAbsoluteName(), "/node/avalon/client/jack/-4", sessionName.getAbsoluteName());
         assertEquals("", "avalon", sessionName.getNodeId().getId());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/-4", sessionName.getRelativeName());
         else
            assertEquals("", "client/jack/-4", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", -4L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }

      try { // Test given node ID ...
         SessionName tmp = new SessionName(glob, new NodeId("/node/avalon"), "client/jack");
         SessionName sessionName = new SessionName(glob, tmp, -4);
         System.out.println("AbsoluteName=" + sessionName.getAbsoluteName() + " RelativeName=" + sessionName.getRelativeName());
         if (SessionName.useSessionMarker())
            assertEquals("", "/node/avalon/client/jack/session/-4", sessionName.getAbsoluteName());
         else
            assertEquals("", "/node/avalon/client/jack/-4", sessionName.getAbsoluteName());
         assertEquals("", "avalon", sessionName.getNodeId().getId());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/-4", sessionName.getRelativeName());
         else
            assertEquals("", "client/jack/-4", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", -4L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }

      try { // Test given node ID ...
         SessionName sessionName = new SessionName(glob, new NodeId("/node/sauron/client/jack/99"), "/node/heron/client/jack/99");
         System.out.println("AbsoluteName=" + sessionName.getAbsoluteName() + " RelativeName=" + sessionName.getRelativeName());
         if (SessionName.useSessionMarker())
            assertEquals("", "/node/sauron/client/jack/session/99", sessionName.getAbsoluteName());
         else
            assertEquals("", "/node/sauron/client/jack/99", sessionName.getAbsoluteName());
         assertEquals("", "sauron", sessionName.getNodeId().getId());
         if (SessionName.useSessionMarker())
            assertEquals("", "client/jack/session/99", sessionName.getRelativeName());
         else
            assertEquals("", "client/jack/99", sessionName.getRelativeName());
         assertEquals("", "jack", sessionName.getLoginName());
         assertEquals("", 99L, sessionName.getPublicSessionId());
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }
        
      try { // Test given node ID ...
         new SessionName(glob, new NodeId("/avalon"), "client/jack");
         fail("testParse failed, nodeId is invalid.");
      }
      catch (IllegalArgumentException e) {
         System.out.println("SUCCESS: " + e.toString());
      }

      try {
         new SessionName(glob, null);
         fail("testParse failed, null should throw an exception.");
      }
      catch (IllegalArgumentException e) {
         System.out.println("SUCCESS: " + e.toString());
      }
        
      try {
         new SessionName(glob, "");
         fail("testParse failed, \"\" should throw an exception.");
      }
      catch (IllegalArgumentException e) {
         System.out.println("SUCCESS: " + e.toString());
      }
        
      try {
         new SessionName(glob, "/");
         fail("testParse failed, \"/\" should throw an exception.");
      }
      catch (IllegalArgumentException e) {
         System.out.println("SUCCESS: " + e.toString());
      }
        
      try {
         new SessionName(glob, "//////");
         fail("testParse failed, \"//////\" should throw an exception.");
      }
      catch (IllegalArgumentException e) {
         System.out.println("SUCCESS: " + e.toString());
      }

      try {
         // missing clusterNodeId is similar to relative addressing,
         // changed 2009-05-21 Marcel to not throw exception anymore
         new SessionName(glob, "/node//joe/2");
         System.out.println("SUCCESS: \"/node//joe/2\" missing clusterNodeId is similar to relative addressing.");
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }
        
      try {
         // missing clusterNodeId is similar to relative addressing,
         // changed 2009-05-21 Marcel to not throw exception anymore
         new SessionName(glob, "/node//client/joe/2");
         System.out.println("SUCCESS: /node//client/joe/2 missing clusterNodeId is similar to relative addressing.");
      }
      catch (IllegalArgumentException e) {
         fail("testParse failed: " + e.toString());
      }
View Full Code Here

         StringTokenizer st = new StringTokenizer(clients, ",")// joe,jack,averell,...
         int found = 0;
         while (st.hasMoreTokens()) {
            String client = (String)st.nextToken();
            log.info("Parsing name=" + client);
            SessionName sessionName = new SessionName(glob, client);
            if (sessionName.getLoginName().equals(this.firstName))
               found++;
            else if (sessionName.getLoginName().equals(this.secondName))
               found++;
         }
         assertTrue("Check of '__cmd:?clientList' failed", found==2);
      }
      catch (XmlBlasterException e) {
View Full Code Here

         PublishQos publishQos = new PublishQos(glob);
         msgUnit = new MsgUnit(msgUnit, null, null, publishQos.getData());
         if (ptp) {
            PublishKey pk = new PublishKey(glob);
            PublishQos pq = new PublishQos(glob);
            pq.addDestination(new Destination(new SessionName(glob, secondName)));
            msgUnit = new MsgUnit(msgUnit, pk.getData(), null, pq.getData());
         }
         publishOid = callbackConnection.publish(msgUnit).getKeyOid();
         log.info("Success: Publish " + msgUnit.getKey() + " done");
         if (!ptp)
View Full Code Here

         }

         // Send a message to 'receiver' and block for the reply
         PublishKey pk = new PublishKey(sender.getGlobal(), "requestForEnlightenment");
         PublishQos pq = new PublishQos(sender.getGlobal());
         pq.addDestination(new Destination(new SessionName(sender.getGlobal(), receiverName)));
         MsgUnit msgUnit = new MsgUnit(pk, "Tell me the truth!", pq);
         MsgUnit[] replies = sender.request(msgUnit, 3000, 1);
         assertEquals("Missing reply message.", 1, replies.length);
         assertEquals("On doubt no ultimate truth, my dear.", replies[0].getContentStr());
         log.info(senderName+": Got " + replies.length + " reply :\n" + replies[0].toXml());
View Full Code Here

      try {
         I_XmlBlasterAccess con = this.glob.getXmlBlasterAccess(); // Find orb

         String passwd = "secret";
         ConnectQos connectQos = new ConnectQos(this.glob, senderName, passwd); // == "<qos>...</qos>";
         connectQos.setSessionName(new SessionName(this.glob, this.sessionName));
         con.connect(connectQos, this)// Login to xmlBlaster, register for updates
      }
      catch (XmlBlasterException e) {
          log.warning("setUp() - login failed: " + e.getMessage());
          fail("setUp() - login fail: " + e.getMessage());
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.SessionName

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.