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 + "/");
}