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)
{
}