Package org.xmlBlaster.engine.runlevel

Examples of org.xmlBlaster.engine.runlevel.RunLevelActionSaxFactory


         String xml = "<action do='LOAD'\n" +
                      "        onStartupRunlevel='3'\n" +
                      "        sequence='5'\n" +
                      "        onFail='resource.configuration.pluginFailed'/>";
  
         RunLevelActionSaxFactory factory = new RunLevelActionSaxFactory(this.glob);
         RunLevelAction action = factory.readObject(xml);

         for (int i=0; i < 2; i++) {
            assertEquals(me + " checking do attribute", "LOAD", action.getDo());
            assertEquals(me + " checking onFail attribute", "resource.configuration.pluginFailed", action.getOnFail().getErrorCode());
            assertEquals(me + " checking onShutdownLevel attribute", -1, action.getOnShutdownRunlevel());
            assertEquals(me + " checking onStartupLevel attribute", 3, action.getOnStartupRunlevel());
            assertEquals(me + " checking sequence attribute", 5, action.getSequence());
            assertEquals(me + " checking hasOnFail", true, action.hasOnFail());
            assertEquals(me + " checking isOnShutdownLevel", false, action.isOnShutdownRunlevel());
            assertEquals(me + " checking isOnStartupLevel", true, action.isOnStartupRunlevel());
            xml = action.toXml();
            action = factory.readObject(xml);
            log.info("going to test the second time ...");
         }

         // now test a null string

         try {
            xml = null;
            action = factory.readObject(xml);
            assertTrue(me + " a null string is not allowed here. Should have thrown an exception", true);
         }
         catch (XmlBlasterException ex) {
            log.info("the exception is allowed here since a null string is not allowed here." + ex.getMessage());
         }
         try {
            xml = "";
            action = factory.readObject(xml);
            assertTrue(me + " an empty string is not allowed here. Should have thrown an exception", true);
         }
         catch (XmlBlasterException ex) {
            log.info("the exception is allowed here since an empty string is not allowed here." + ex.getMessage());
         }
         try {
            xml = "xyz";
            action = factory.readObject(xml);
            assertTrue(me + " a non-xml string is not allowed here. Should have thrown an exception", true);
         }
         catch (XmlBlasterException ex) {
            log.info("the exception is allowed here since a non-xml string is not allowed here." + ex.getMessage());
         }
         try {
            xml = "<xmlBlaster></xmlBlaster>";
            action = factory.readObject(xml);
            assertTrue(me + " a wrong tag name is not allowed here. Should have thrown an exception", true);
         }
         catch (XmlBlasterException ex) {
            log.info("the exception is allowed here since  a wrong tag name is not allowed here." + ex.getMessage());
         }

         // this is allowed ...
         xml = "<action/>";
         action = factory.readObject(xml);

      }
      catch (XmlBlasterException e) {
         fail(ME+ " failed: " + e.toString());
      }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.engine.runlevel.RunLevelActionSaxFactory

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.