01: package de.schlund.pfixxml.jmx;
02:
03: import java.io.File;
04: import java.io.Serializable;
05:
06: import junit.framework.TestCase;
07: import de.schlund.pfixxml.testrecording.Application;
08: import de.schlund.pfixxml.testrecording.ApplicationList;
09: import de.schlund.pfixxml.util.Xml;
10:
11: public class ApplicationListTest extends TestCase {
12: public void testJmxPrereqs() throws Exception {
13: assertTrue(Serializable.class
14: .isAssignableFrom(ApplicationList.class));
15: assertTrue(Serializable.class
16: .isAssignableFrom(Application.class));
17: }
18:
19: public void testApplicationTomcat() throws Exception {
20: Application app;
21:
22: app = new Application("foo", "bar", true, "/a", "mhm");
23: assertEquals(
24: "https://bar:8443/foo;jsessionid=nosuchsession.mhm",
25: app.getUrl(true, "/foo").toString());
26: assertEquals("http://bar:8080/xy;jsessionid=gg", app.getUrl(
27: false, "/xy", "gg").toString());
28: }
29:
30: public void testApplicationApache() throws Exception {
31: Application app;
32:
33: app = new Application("foo", "bar", false, "/a", "mhm");
34: assertEquals("http://bar/back;jsessionid=nosuchsession.mhm",
35: app.getUrl(false, "/back").toString());
36: assertEquals("http://bar/xy;jsessionid=gg", app.getUrl(false,
37: "/xy", "gg").toString());
38: }
39:
40: public void testNotFound() throws Exception {
41: assertNull(new ApplicationList().lookup("nosuchapp"));
42: }
43:
44: public void testFound() throws Exception {
45: Application app;
46: ApplicationList lst;
47:
48: app = new Application("foo", "bar", true, "/a", "mhm");
49: lst = new ApplicationList();
50: lst.add(app);
51: assertSame(app, lst.lookup("foo"));
52: }
53:
54: public void testLoad() throws Exception {
55:
56: ApplicationList lst;
57: Application app;
58:
59: lst = ApplicationList.load(Xml.parseMutable(new File(
60: "tests/junit/de/schlund/pfixxml/jmx/projects.xml")),
61: true, "foo");
62:
63: assertEquals(6, lst.size());
64: app = (Application) lst.getApplications().get(0);
65: assertEquals("sample1", app.getName());
66: assertTrue(app.getServer().startsWith("sample1."));
67: assertNotNull(lst.get("simplelink"));
68: assertNotNull(lst.get("simplepage"));
69: }
70: }
|