Package mx4j.loading

Examples of mx4j.loading.MLetParser


      Logger logger = getLogger();

      try
      {
         HashSet mbeans = new HashSet();
         MLetParser parser = new MLetParser(this);
         List tags = parser.parse(content);

         for (int i = 0; i < tags.size(); ++i)
         {
            MLetTag tag = (MLetTag)tags.get(i);
View Full Code Here


      Logger logger = getLogger();

      try
      {
         HashSet mbeans = new HashSet();
         MLetParser parser = new MLetParser(this);
         List tags = parser.parse(content);

         for (int i = 0; i < tags.size(); ++i)
         {
            MLetTag tag = (MLetTag)tags.get(i);
View Full Code Here

      super(s);
   }

   public void testInvalidMLetFileParsing() throws Exception
   {
      MLetParser parser = new MLetParser();

      String content = null;
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      content = "";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      content = " ";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      content = " <!--";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      content = " -->";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      content = "<!-- -->\n<!-- ->";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      content = "<!- -->";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid, missing attributes
      content = "<!-- -->\n<MLET/>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid, missing archive attribute
      content = "<MLET CODE = \" test.mx4j.MBeanNormal\"/>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid, missing archive attribute
      content = "\n<MLET CODE=\" test.mx4j.MBeanNormal\">\n</MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid, missing archive attribute
      content = "\n<MLET OBJECT=\"mx4j-mbean.ser\">\n</MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid, missing code or object attribute
      content = "<MLET ARCHIVE = \"..\\lib\"></MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid, either code or object attribute must be present
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" OBJECT=\"mx4j-mbean.ser\" ARCHIVE = \"..\\lib\"></MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid arg tag
//      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\">\n<></MLET>";
//      try {parser.parse(content); fail();}
//      catch (MLetParseException x) {}

      // Invalid arg tag
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\">\n<ARG></MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid arg tag
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\">\n<ARG type=\"int\"></MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid arg tag
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\">\n<ARG value=\"int\"></MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid name tag
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\" name>\n</MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid name tag
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\" name=>\n</MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid version tag
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\" version>\n</MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }

      // Invalid version tag
      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE = \"..\\lib\" version=>\n</MLET>";
      try
      {
         parser.parse(content);
         fail();
      }
      catch (MLetParseException x)
      {
      }
View Full Code Here

   }

   public void testValidMLetFileParsing() throws Exception
   {
      MLetParser parser = new MLetParser();
      String content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE=\"mx4j-tests.jar\" NAME=\":name=MLetTest1\"/>";
      parser.parse(content);

      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE=\"mx4j-tests.jar\" NAME=\":name=MLetTest2\">\n\t<ARG TYPE=\"int\" VALUE=\"5\">\n</MLET>\n";
      parser.parse(content);

      content = "<MLET CODE=\"test.mx4j.MBeanNormal\" ARCHIVE=\"mx4j-tests.jar\" CODEBASE=\"dist\\test\\\" NAME=\":name=MLetTest3\">\n\t<ARG TYPE=\"int\" VALUE=\"5\"/>\n</MLET>\n";
      parser.parse(content);
   }
View Full Code Here

      parser.parse(content);
   }

   public void testCompleteMLetFileParsing() throws Exception
   {
      MLetParser parser = new MLetParser();

      StringBuffer content = new StringBuffer();
      content.append("<!-- Comment -->");
      content.append("<MLET \n");
      content.append("      Code=\"mx4j.tools.naming.NamingService\"\n");
      content.append("      archive = \" ../lib \"\n");
      content.append("      CodeBase= \"http://localhost:8080/download\"\n");
      content.append("      NAME=\":name=test\"\n");
      content.append("      Version=\"1\">\n");
      content.append("      <!-- Comment -->");
      content.append("      <ARG \n");
      content.append("           Type=\"boolean\"\n");
      content.append("           VALUE = \"true\">\n");
      content.append("      <!-- Comment -->");
      content.append("      <ARG \n");
      content.append("           TYPE = \"boolean\"\n");
      content.append("           value=\"true\"/>\n");
      content.append("</MLet>");

      parser.parse(content.toString());
   }
View Full Code Here

      int index = urlString.lastIndexOf('/') + 1;
      String jar = urlString.substring(index);

      String codebase = ".";
      String content = "<MLET CODE=\"" + className + "\" NAME=\":name=test\" ARCHIVE=\"" + jar + "\" CODEBASE=\"" + codebase + "\"/>";
      MLetParser parser = new MLetParser();
      List tags = parser.parse(content);
      MLetTag tag = (MLetTag)tags.get(0);
      URL mletFileURL = new URL("http://mx4j.sourceforge.net/mlets/mbeans.mlet");
      URL codebaseURL = tag.normalizeCodeBase(mletFileURL);
      assertEquals(codebaseURL.toExternalForm(), "http://mx4j.sourceforge.net/mlets/");

      content = "<MLET CODE=\"" + className + "\" NAME=\":name=test\" ARCHIVE=\"" + jar + "\"/>";
      tags = parser.parse(content);
      tag = (MLetTag)tags.get(0);
      codebaseURL = tag.normalizeCodeBase(mletFileURL);
      assertEquals(codebaseURL.toExternalForm(), "http://mx4j.sourceforge.net/mlets/");

      codebase = "../lib";
      content = "<MLET CODE=\"" + className + "\" NAME=\":name=test\" ARCHIVE=\"" + jar + "\" CODEBASE=\"" + codebase + "\"/>";
      tags = parser.parse(content);
      tag = (MLetTag)tags.get(0);
      codebaseURL = tag.normalizeCodeBase(mletFileURL);
      assertEquals(codebaseURL.toExternalForm(), "http://mx4j.sourceforge.net/lib/");

      codebase = "ftp://mx4j.sourceforge.net/mbeans";
      content = "<MLET CODE=\"" + className + "\" NAME=\":name=test\" ARCHIVE=\"" + jar + "\" CODEBASE=\"" + codebase + "\"/>";
      tags = parser.parse(content);
      tag = (MLetTag)tags.get(0);
      codebaseURL = tag.normalizeCodeBase(mletFileURL);
      assertEquals(codebaseURL.toExternalForm(), codebase + "/");
   }
View Full Code Here

TOP

Related Classes of mx4j.loading.MLetParser

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.