Examples of Publisher


Examples of org.xmlBlaster.contrib.filewatcher.Publisher

      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.dirName);
      prop.put("filewatcher.sent", this.dirNameSent);
      prop.put("filewatcher.discarded", this.dirNameDiscarded);
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();

      // repeat that with already existing directories
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.dirName);
      prop.put("filewatcher.sent", this.dirNameSent);
      prop.put("filewatcher.discarded", this.dirNameDiscarded);
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
      cleanUpDirs();

      // relative path are added to the 'directoryName'
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.dirName);
      prop.put("filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
      // relative path are added to the 'directoryName' repeat with existing directories
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.dirName);
      prop.put("filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      checkDirs();
     
      cleanUpDirs();
     
      // now some which should fail:
      // existing file but not a directory
      File file = new File(this.dirName);
      try {
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.dirName + "'", false);
      }
     
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.dirName);
      prop.put("filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
         assertTrue("an exception should occur since '" + this.dirName + "' is a file and should be a directory", false);
      }
      catch (XmlBlasterException ex) {
         log.info("Exception is OK here");
      }
      cleanUpDirs();
     
      try {
         file = new File(this.dirName);
         boolean ret = file.mkdir();
         assertTrue("could not create directory '" + this.dirName + "'", ret);
         file = new File(this.dirNameSent);
         file.createNewFile();
      }
      catch (IOException ex) {
         assertTrue("could not create the file '" + this.dirNameSent + "'", false);
      }
     
      prop = new PropertiesInfo(new Properties());
      prop.put("mom.topicName", "dummy");
      prop.put("filewatcher.directoryName", this.dirName);
      prop.put("filewatcher.sent", "Sent");
      prop.put("filewatcher.discarded", "Discarded");
      try {
         new Publisher(this.global, "test", prop);
         assertTrue("an exception should occur since '" + this.dirName + "' is a file and should be a directory", false);
      }
      catch (XmlBlasterException ex) {
         log.info("Exception is OK here");
      }
View Full Code Here

Examples of org.xmlBlaster.contrib.filewatcher.Publisher

      String discarded = prop.get("filewatcher.discarded", null);
     
      org.xmlBlaster.engine.ServerScope engineGlobal = new org.xmlBlaster.engine.ServerScope();
      prop.put("mom.connectQos", this.getConnectQos(engineGlobal));
     
      Publisher publisher = null;
      try {
         publisher = new Publisher(engineGlobal, "test", prop);
         publisher.init();

         this.updateInterceptor.clear();
         // too big
         String tooBig = this.dirName + File.separator + "tooBig.dat";
         writeFile(tooBig, maximumSize+1, lockExt, delaySinceLastChange* 2);
         int ret = this.updateInterceptor.waitOnUpdate(delaySinceLastChange* 2);
         assertEquals("expected no updates", 0, ret);

         File tmp = new File(tooBig);
         if (deliverFirst) {
            assertFalse("the file '" + tooBig + "' should have been removed", tmp.exists());
            checkMoved("tooBig.dat", absSubPath, discarded);
         }
         else {
            assertTrue("the file '" + tooBig + "' should still be here", tmp.exists());
         }

         this.updateInterceptor.clear();

         singleDump("ok.dat", maximumSize-1, lockExt, delaySinceLastChange* 2, deliverFirst, absSubPath, sent);
         singleDump("ok.gif", maximumSize-1, lockExt, delaySinceLastChange* 2, deliverSecond, absSubPath, sent);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         assertTrue("An exception should not occur here " + ex.getMessage(), false);
      }
      finally {
         if (publisher != null) {
            try {
               publisher.shutdown();
            }
            catch (Throwable ex) {
               ex.printStackTrace();
               fail("exception when shutting down the poller " + ex.getMessage());
            }
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.