KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > util > url > test > URLGeneratorTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.util.url.test;
8
9
10 import java.net.URISyntaxException JavaDoc;
11
12 import org.jdom.Document;
13 import org.jdom.Element;
14
15 import com.inversoft.config.ConfigurationException;
16 import com.inversoft.junit.Request;
17 import com.inversoft.junit.URL;
18 import com.inversoft.junit.WebTestCase;
19 import com.inversoft.junit.internal.http.MockHttpServletRequest;
20 import com.inversoft.verge.util.url.URLGenerator;
21 import com.inversoft.verge.util.url.config.CategoryConfig;
22 import com.inversoft.verge.util.url.config.URLConfigBuilder;
23 import com.inversoft.verge.util.url.config.URLConfigRegistry;
24
25
26 /**
27  * <p>
28  * This class contains the tests for the URL generation
29  * system
30  * </p>
31  *
32  * @author Brian Pontarelli
33  * @since 2.0
34  * @version 2.0
35  */

36 public class URLGeneratorTest extends WebTestCase {
37
38     static {
39         URLConfigBuilder builder = new URLConfigBuilder();
40         Document doc = createGoodDocument();
41         
42         try {
43             builder.build(doc,
44                 URLConfigRegistry.getInstance(new MockHttpServletRequest(null)));
45         } catch (ConfigurationException ce) {
46             fail(ce.toString());
47         }
48     }
49
50
51     /**
52      * Constructor for URLGeneratorTest.
53      * @param name
54      */

55     public URLGeneratorTest(String JavaDoc name) {
56         super(name);
57         setLocal(true);
58     }
59
60
61     public void testCat1() {
62         CategoryConfig cc = URLGenerator.getCategory(request, "testCat1");
63         String JavaDoc url = URLGenerator.generateURL(cc, request);
64         String JavaDoc expected = "https://www.inversoft.com:8000/MyWebApp";
65         System.out.println(url);
66         System.out.println(expected);
67         assertEquals("Should be equal", url, expected);
68     }
69
70     /**
71      * Since testCat1 is full, this tests that the baseURI is not used expect for the
72      * path as it is supposed to be
73      */

74     public void testCat1_1() {
75         try {
76             CategoryConfig cc = URLGenerator.getCategory(request, "testCat1");
77             String JavaDoc url = URLGenerator.generateURL(cc,
78                 "http://www.yahoo.com:100/path.jsp", request);
79             String JavaDoc expected = "https://www.inversoft.com:8000/MyWebApp/path.jsp";
80             System.out.println(url);
81             System.out.println(expected);
82             assertEquals("Should be equal", url, expected);
83         } catch (URISyntaxException JavaDoc use) {
84             fail(use.toString());
85         }
86     }
87
88     /**
89      * Since testCat1 is full, this tests that the path that is appended, has the
90      * correct slashes
91      */

92     public void testCat1_2() {
93         try {
94             CategoryConfig cc = URLGenerator.getCategory(request, "testCat1");
95             String JavaDoc url = URLGenerator.generateURL(cc, "path.jsp", request);
96             String JavaDoc expected = "https://www.inversoft.com:8000/MyWebApp/path.jsp";
97             System.out.println(url);
98             System.out.println(expected);
99             assertEquals("Should be equal", url, expected);
100         } catch (URISyntaxException JavaDoc use) {
101             fail(use.toString());
102         }
103     }
104
105     /**
106      * Since testCat1 is full, this tests that the path that is appended, has the
107      * correct slashes
108      */

109     public void testCat1_3() {
110         try {
111             CategoryConfig cc = URLGenerator.getCategory(request, "testCat1");
112             String JavaDoc url = URLGenerator.generateURL(cc, "path.jsp?query=true#fragment", request);
113             String JavaDoc expected = "https://www.inversoft.com:8000/MyWebApp/path.jsp?query=true#fragment";
114             System.out.println(url);
115             System.out.println(expected);
116             assertEquals("Should be equal", url, expected);
117         } catch (URISyntaxException JavaDoc use) {
118             fail(use.toString());
119         }
120     }
121
122     public void testCat2() {
123         CategoryConfig cc = URLGenerator.getCategory(request, "testCat2");
124         String JavaDoc url = URLGenerator.generateURL(cc, request);
125         String JavaDoc expected = "http://www.inversoft.com:8000/MyWebApp";
126         System.out.println(url);
127         System.out.println(expected);
128         assertEquals("Should be equal", url, expected);
129     }
130
131     public void testCat3() {
132         CategoryConfig cc = URLGenerator.getCategory(request, "testCat3");
133         String JavaDoc url = URLGenerator.generateURL(cc, request);
134         String JavaDoc expected = "https://localhost:8000/MyWebApp";
135         System.out.println(url);
136         System.out.println(expected);
137         assertEquals("Should be equal", url, expected);
138     }
139
140     public void testCat4() {
141         CategoryConfig cc = URLGenerator.getCategory(request, "testCat4");
142         String JavaDoc url = URLGenerator.generateURL(cc, request);
143         String JavaDoc expected = "https://www.inversoft.com:80/MyWebApp";
144         System.out.println(url);
145         System.out.println(expected);
146         assertEquals("Should be equal", url, expected);
147     }
148
149     public void testCat5() {
150         CategoryConfig cc = URLGenerator.getCategory(request, "testCat5");
151         String JavaDoc url = URLGenerator.generateURL(cc, request);
152         String JavaDoc expected = "http://www.inversoft.com:443/MyWebApp";
153         System.out.println(url);
154         System.out.println(expected);
155         assertEquals("Should be equal", url, expected);
156     }
157
158     public void testCat6() {
159         CategoryConfig cc = URLGenerator.getCategory(request, "testCat6");
160         String JavaDoc url = URLGenerator.generateURL(cc, request);
161         String JavaDoc expected = "http://www.inversoft.com/MyWebApp";
162         System.out.println(url);
163         System.out.println(expected);
164         assertEquals("Should be equal", url, expected);
165     }
166
167     public void testCat7() {
168         CategoryConfig cc = URLGenerator.getCategory(request, "testCat7");
169         String JavaDoc url = URLGenerator.generateURL(cc, request);
170         String JavaDoc expected = "https://www.inversoft.com/MyWebApp";
171         System.out.println(url);
172         System.out.println(expected);
173         assertEquals("Should be equal", url, expected);
174     }
175
176     public void testCat8() {
177         CategoryConfig cc = URLGenerator.getCategory(request, "testCat8");
178         String JavaDoc url = URLGenerator.generateURL(cc, request);
179         String JavaDoc expected = "http://www.inversoft.com";
180         System.out.println(url);
181         System.out.println(expected);
182         assertEquals("Should be equal", url, expected);
183     }
184
185     public void beginCat9(Request request) {
186         URL url = new URL(null, null, "http", null, "www.inversoft.com", "");
187         request.setURL(url);
188     }
189
190     public void testCat9() {
191         CategoryConfig cc = URLGenerator.getCategory(request, "testCat9");
192         String JavaDoc url = URLGenerator.generateURL(cc, request);
193         String JavaDoc expected = "http://www.inversoft.com:8000/MyWebApp";
194         System.out.println(url);
195         System.out.println(expected);
196         assertEquals("Should be equal", url, expected);
197     }
198
199     public void beginCat9_1(Request request) {
200         URL url = new URL(null, null, "https", null, "www.inversoft.com", "");
201         request.setURL(url);
202     }
203
204     public void testCat9_1() {
205         CategoryConfig cc = URLGenerator.getCategory(request, "testCat9");
206         String JavaDoc url = URLGenerator.generateURL(cc, request);
207         String JavaDoc expected = "https://www.inversoft.com:8000/MyWebApp";
208         System.out.println(url);
209         System.out.println(expected);
210         assertEquals("Should be equal", url, expected);
211     }
212
213     /**
214      * For the testCat9_2 test that uses the baseURI, this sets the protocol to https
215      * so that the baseURI use can be tested
216      */

217     public void beginCat9_2(Request request) {
218         URL url = new URL(null, null, "https", null, "www.inversoft.com", "");
219         request.setURL(url);
220     }
221
222     /**
223      * Since testCat9 is missing the protocol, this tests that the baseURI is used
224      */

225     public void testCat9_2() {
226         try {
227             CategoryConfig cc = URLGenerator.getCategory(request, "testCat9");
228             String JavaDoc url = URLGenerator.generateURL(cc,
229                 "http://www.yahoo.com:100/path.jsp", request);
230             String JavaDoc expected = "http://www.inversoft.com:8000/MyWebApp/path.jsp";
231             System.out.println(url);
232             System.out.println(expected);
233             assertEquals("Should be equal", url, expected);
234         } catch (URISyntaxException JavaDoc use) {
235             fail(use.toString());
236         }
237     }
238
239     /**
240      * For the testCat9_3 test that uses the baseURI, this sets the protocol to file
241      * so that the baseURI, which does not set the protocol, is not used
242      */

243     public void beginCat9_3(Request request) {
244         URL url = new URL(null, null, "file", null, "www.inversoft.com", "");
245         request.setURL(url);
246     }
247
248     /**
249      * Since testCat9 is missing the protocol, this tests that the baseURI is not used
250      * when the protocol is not specified
251      */

252     public void testCat9_3() {
253         try {
254             CategoryConfig cc = URLGenerator.getCategory(request, "testCat9");
255             String JavaDoc url = URLGenerator.generateURL(cc, "/page.jsp", request);
256             String JavaDoc expected = "file://www.inversoft.com:8000/MyWebApp/page.jsp";
257             System.out.println(url);
258             System.out.println(expected);
259             assertEquals("Should be equal", url, expected);
260         } catch (URISyntaxException JavaDoc use) {
261             fail(use.toString());
262         }
263     }
264
265     public void beginCat10(Request request) {
266         URL url = new URL(null, null, "http", null, "www.yahoo.com", "");
267         request.setURL(url);
268     }
269
270     public void testCat10() {
271         CategoryConfig cc = URLGenerator.getCategory(request, "testCat10");
272         String JavaDoc url = URLGenerator.generateURL(cc, request);
273         String JavaDoc expected = "https://www.yahoo.com:8000/MyWebApp";
274         System.out.println(url);
275         System.out.println(expected);
276         assertEquals("Should be equal", url, expected);
277     }
278
279     /**
280      * Since testCat10 is missing the host, this will put in a bogus host to ensure
281      * that the host from the baseURI is used.
282      */

283     public void beginCat10_1(Request request) {
284         URL url = new URL(null, null, "http", null, "www.bogus.com", "");
285         request.setURL(url);
286     }
287
288     /**
289      * Ensures that the baseURI is used to retrieve the host name
290      */

291     public void testCat10_1() {
292         try {
293             CategoryConfig cc = URLGenerator.getCategory(request, "testCat10");
294             String JavaDoc url = URLGenerator.generateURL(cc,
295                 "http://www.NotBogus.com:100/path.jsp", request);
296             String JavaDoc expected = "https://www.NotBogus.com:8000/MyWebApp/path.jsp";
297             System.out.println(url);
298             System.out.println(expected);
299             assertEquals("Should be equal", url, expected);
300         } catch (URISyntaxException JavaDoc use) {
301             fail (use.toString());
302         }
303     }
304
305     /**
306      * Since testCat10 is missing the host, this will put in a good host to ensure
307      * that the host from the baseURI is not used when it is not specified.
308      */

309     public void beginCat10_2(Request request) {
310         URL url = new URL(null, null, "http", null, "www.GoodHost.com", "");
311         request.setURL(url);
312     }
313
314     /**
315      * Ensures that the baseURI is not used to retrieve the host name, it one is
316      * not contained in it
317      */

318     public void testCat10_2() {
319         try {
320             CategoryConfig cc = URLGenerator.getCategory(request, "testCat10");
321             String JavaDoc url = URLGenerator.generateURL(cc, "/path.jsp", request);
322             String JavaDoc expected = "https://www.GoodHost.com:8000/MyWebApp/path.jsp";
323             System.out.println(url);
324             System.out.println(expected);
325             assertEquals("Should be equal", url, expected);
326         } catch (URISyntaxException JavaDoc use) {
327             fail (use.toString());
328         }
329     }
330
331     public void beginCat11(Request request) {
332         URL url = new URL(null, null, "http", null, "www.google.com:9012", "");
333         request.setURL(url);
334     }
335
336     public void testCat11() {
337         CategoryConfig cc = URLGenerator.getCategory(request, "testCat11");
338         String JavaDoc url = URLGenerator.generateURL(cc, request);
339         String JavaDoc expected = "https://www.inversoft.com:9012/MyWebApp";
340         System.out.println(url);
341         System.out.println(expected);
342         assertEquals("Should be equal", url, expected);
343     }
344
345     /**
346      * Since testCat11 leaves out the port number, this puts a port into the request
347      * to ensure that the baseURI is used
348      */

349     public void beginCat11_1(Request request) {
350         URL url = new URL(null, null, "http", null, "www.google.com:9012", "");
351         request.setURL(url);
352     }
353
354     /**
355      * Tests that the port number from the baseURI is used
356      */

357     public void testCat11_1() {
358         try {
359             CategoryConfig cc = URLGenerator.getCategory(request, "testCat11");
360             String JavaDoc url = URLGenerator.generateURL(cc,
361                 "http://www.bogus.com:100/path.jsp", request);
362             String JavaDoc expected = "https://www.inversoft.com:100/MyWebApp/path.jsp";
363             System.out.println(url);
364             System.out.println(expected);
365             assertEquals("Should be equal", url, expected);
366         } catch (URISyntaxException JavaDoc use) {
367             fail (use.toString());
368         }
369     }
370
371     /**
372      * Since testCat11 leaves out the port number, this puts a port into the request
373      * to ensure that the baseURI is used, but resolved to follow the scheme of
374      * the baseURI
375      */

376     public void beginCat11_2(Request request) {
377         URL url = new URL(null, null, "http", null, "www.google.com:9012", "");
378         request.setURL(url);
379     }
380
381     /**
382      * Tests that the port number from the baseURI is used, the scheme is
383      * specified
384      */

385     public void testCat11_2() {
386         try {
387             CategoryConfig cc = URLGenerator.getCategory(request, "testCat11");
388             String JavaDoc url = URLGenerator.generateURL(cc,
389                 "http://www.bogus.com/path.jsp", request);
390             String JavaDoc expected = "https://www.inversoft.com:80/MyWebApp/path.jsp";
391             System.out.println(url);
392             System.out.println(expected);
393             assertEquals("Should be equal", url, expected);
394         } catch (URISyntaxException JavaDoc use) {
395             fail (use.toString());
396         }
397
398         try {
399             CategoryConfig cc = URLGenerator.getCategory(request, "testCat11");
400             String JavaDoc url = URLGenerator.generateURL(cc,
401                 "https://www.bogus.com/path.jsp", request);
402             String JavaDoc expected = "https://www.inversoft.com/MyWebApp/path.jsp";
403             System.out.println(url);
404             System.out.println(expected);
405             assertEquals("Should be equal", url, expected);
406         } catch (URISyntaxException JavaDoc use) {
407             fail (use.toString());
408         }
409     }
410
411     /**
412      * Since testCat11 leaves out the port number, this puts a port into the request
413      * to ensure that the baseURI is not used if it is not specified
414      */

415     public void beginCat11_3(Request request) {
416         URL url = new URL(null, null, "http", null, "www.google.com:9012", "");
417         request.setURL(url);
418     }
419
420     /**
421      * Tests that the port number from the baseURI is not used, if one is not
422      * specified
423      */

424     public void testCat11_3() {
425         try {
426             CategoryConfig cc = URLGenerator.getCategory(request, "testCat11");
427             String JavaDoc url = URLGenerator.generateURL(cc,
428                 "/path.jsp", request);
429             String JavaDoc expected = "https://www.inversoft.com:9012/MyWebApp/path.jsp";
430             System.out.println(url);
431             System.out.println(expected);
432             assertEquals("Should be equal", url, expected);
433         } catch (URISyntaxException JavaDoc use) {
434             fail (use.toString());
435         }
436     }
437
438     public void beginCat12(Request request) {
439         URL url = new URL("contextPath", null, "http", null, "www.yahoo.com", "");
440         request.setURL(url);
441     }
442
443     public void testCat12() {
444         CategoryConfig cc = URLGenerator.getCategory(request, "testCat12");
445         String JavaDoc url = URLGenerator.generateURL(cc, request);
446         String JavaDoc expected = "http://www.inversoft.com:8000/contextPath";
447         System.out.println(url);
448         System.out.println(expected);
449         assertEquals("Should be equal", url, expected);
450     }
451
452     /**
453      * Since cat12 leaves out the context, this tests that the context from the
454      * baseURI is used
455      */

456     public void beginCat12_1(Request request) {
457         URL url = new URL("contextPath", null, "http", null, "www.yahoo.com", "");
458         request.setURL(url);
459     }
460
461     public void testCat12_1() {
462         try {
463             CategoryConfig cc = URLGenerator.getCategory(request, "testCat12");
464             String JavaDoc url = URLGenerator.generateURL(cc,
465                 "http://www.bogus.com:9000/path.jsp", request);
466             String JavaDoc expected = "http://www.inversoft.com:8000/contextPath/path.jsp";
467             System.out.println(url);
468             System.out.println(expected);
469             assertEquals("Should be equal", url, expected);
470         } catch (URISyntaxException JavaDoc use) {
471             fail(use.toString());
472         }
473     }
474
475     /**
476      * Since cat12 leaves out the context, this tests that the context from the
477      * baseURI is not used if it is not specified
478      */

479     public void beginCat12_2(Request request) {
480         URL url = new URL("contextPath", null, "http", null, "www.yahoo.com", "");
481         request.setURL(url);
482     }
483
484     public void testCat12_2() {
485         try {
486             CategoryConfig cc = URLGenerator.getCategory(request, "testCat12");
487             String JavaDoc url = URLGenerator.generateURL(cc,
488                 "http://www.bogus.com:8000", request);
489             String JavaDoc expected = "http://www.inversoft.com:8000/contextPath";
490             System.out.println(url);
491             System.out.println(expected);
492             assertEquals("Should be equal", url, expected);
493         } catch (URISyntaxException JavaDoc use) {
494             fail(use.toString());
495         }
496     }
497
498     /**
499      * Check that cat12 leaves out the context, because we told it to.
500      */

501     public void beginCat12_3(Request request) {
502         URL url = new URL("contextPath", null, "http", null, "www.yahoo.com", "");
503         request.setURL(url);
504     }
505
506     public void testCat12_3() {
507         try {
508             CategoryConfig cc = URLGenerator.getCategory(request, "testCat12");
509             String JavaDoc url = URLGenerator.generateURL(cc,
510                 "http://www.bogus.com:8000", false, request);
511             String JavaDoc expected = "http://www.inversoft.com:8000";
512             System.out.println(url);
513             System.out.println(expected);
514             assertEquals("Should be equal", url, expected);
515         } catch (URISyntaxException JavaDoc use) {
516             fail(use.toString());
517         }
518     }
519
520     /**
521      * Check that cat12 leaves out the context, because we told it to and encodes
522      * and appends the query and fragment
523      */

524     public void beginCat12_4(Request request) {
525         URL url = new URL("contextPath", null, "http", null, "www.yahoo.com", "");
526         request.setURL(url);
527     }
528
529     public void testCat12_4() {
530         try {
531             if (isLocal()) {
532                 getResponse().setEncode(true);
533                 CategoryConfig cc = URLGenerator.getCategory(request, "testCat12");
534                 String JavaDoc url = URLGenerator.generateURL(cc,
535                     "http://www.bogus.com:8000?query=true#frag", false, request,
536                     response);
537                 String JavaDoc expected = "http://www.inversoft.com:8000?query=true#frag#encode";
538                 System.out.println(url);
539                 System.out.println(expected);
540                 assertEquals("Should be equal", url, expected);
541             }
542         } catch (URISyntaxException JavaDoc use) {
543             fail(use.toString());
544         }
545     }
546
547     /**
548      * Since testCat12 leaves out the context, this tests that the context from the
549      * baseURI is not used if it is not specified
550      */

551     public void beginExtraMethods(Request request) {
552         URL url = new URL("contextPath", null, "http", null, "www.yahoo.com", "");
553         request.setURL(url);
554     }
555
556     public void testExtraMethods() {
557         try {
558             CategoryConfig cc = URLGenerator.getCategory(request, "testCat12");
559             String JavaDoc url = URLGenerator.generateURL(cc,
560                 "http://www.bogus.com:8000", true, request);
561             String JavaDoc expected = "http://www.inversoft.com:8000/contextPath";
562             System.out.println(url);
563             System.out.println(expected);
564             assertEquals("Should be equal", url, expected);
565             
566             url = URLGenerator.generateURL("http://www.bogus.com:8000",
567                 request.getContextPath());
568             expected = "http://www.bogus.com:8000/contextPath";
569             System.out.println(url);
570             System.out.println(expected);
571             assertEquals("Should be equal", url, expected);
572             
573             url = URLGenerator.generateURL("test.jsp", request.getContextPath());
574             expected = "test.jsp";
575             System.out.println(url);
576             System.out.println(expected);
577             assertEquals("Should be equal", url, expected);
578
579             url = URLGenerator.generateURL("/test.jsp", request.getContextPath());
580             expected = "/contextPath/test.jsp";
581             System.out.println(url);
582             System.out.println(expected);
583             assertEquals("Should be equal", url, expected);
584
585             url = URLGenerator.generateURL("/test.jsp?query=foo@bar|bar@foo",
586                 request.getContextPath());
587             expected = "/contextPath/test.jsp?query=foo@bar|bar@foo";
588             System.out.println(url);
589             System.out.println(expected);
590             assertEquals("Should be equal", url, expected);
591
592             url = URLGenerator.generateURL("/test.jsp?query=foo@bar|bar@foo#ref",
593                 request.getContextPath());
594             expected = "/contextPath/test.jsp?query=foo@bar|bar@foo#ref";
595             System.out.println(url);
596             System.out.println(expected);
597             assertEquals("Should be equal", url, expected);
598
599             if (isLocal()) {
600                 getResponse().setEncode(true);
601                 url = URLGenerator.generateURL(null, "/test.jsp", true, request,
602                     response);
603                 expected = "/contextPath/test.jsp#encode";
604                 System.out.println(url);
605                 System.out.println(expected);
606                 assertEquals("Should be equal", url, expected);
607             }
608         } catch (URISyntaxException JavaDoc use) {
609             fail(use.toString());
610         }
611     }
612
613     public static Document createGoodDocument() {
614         Element root = new Element("url");
615         Document doc = new Document(root);
616         
617         Element cat = new Element("category");
618         cat.setAttribute("name", "testCat1");
619         Element protocol = new Element("protocol");
620         protocol.addContent("https");
621         Element host = new Element("host");
622         host.addContent("www.inversoft.com");
623         Element port = new Element("port");
624         port.addContent("8000");
625         Element context = new Element("context");
626         context.addContent("MyWebApp");
627         cat.addContent(protocol);
628         cat.addContent(host);
629         cat.addContent(port);
630         cat.addContent(context);
631         root.addContent(cat);
632         
633         cat = new Element("category");
634         cat.setAttribute("name", "testCat2");
635         protocol = new Element("protocol");
636         protocol.addContent("http");
637         host = new Element("host");
638         host.addContent("www.inversoft.com");
639         port = new Element("port");
640         port.addContent("8000");
641         context = new Element("context");
642         context.addContent("MyWebApp");
643         cat.addContent(protocol);
644         cat.addContent(host);
645         cat.addContent(port);
646         cat.addContent(context);
647         root.addContent(cat);
648
649         cat = new Element("category");
650         cat.setAttribute("name", "testCat3");
651         protocol = new Element("protocol");
652         protocol.addContent("https");
653         host = new Element("host");
654         host.addContent("localhost");
655         port = new Element("port");
656         port.addContent("8000");
657         context = new Element("context");
658         context.addContent("MyWebApp");
659         cat.addContent(protocol);
660         cat.addContent(host);
661         cat.addContent(port);
662         cat.addContent(context);
663         root.addContent(cat);
664
665         cat = new Element("category");
666         cat.setAttribute("name", "testCat4");
667         protocol = new Element("protocol");
668         protocol.addContent("https");
669         host = new Element("host");
670         host.addContent("www.inversoft.com");
671         port = new Element("port");
672         port.addContent("80");
673         context = new Element("context");
674         context.addContent("MyWebApp");
675         cat.addContent(protocol);
676         cat.addContent(host);
677         cat.addContent(port);
678         cat.addContent(context);
679         root.addContent(cat);
680
681         cat = new Element("category");
682         cat.setAttribute("name", "testCat5");
683         protocol = new Element("protocol");
684         protocol.addContent("http");
685         host = new Element("host");
686         host.addContent("www.inversoft.com");
687         port = new Element("port");
688         port.addContent("443");
689         context = new Element("context");
690         context.addContent("MyWebApp");
691         cat.addContent(protocol);
692         cat.addContent(host);
693         cat.addContent(port);
694         cat.addContent(context);
695         root.addContent(cat);
696
697         cat = new Element("category");
698         cat.setAttribute("name", "testCat6");
699         protocol = new Element("protocol");
700         protocol.addContent("http");
701         host = new Element("host");
702         host.addContent("www.inversoft.com");
703         port = new Element("port");
704         port.addContent("80");
705         context = new Element("context");
706         context.addContent("MyWebApp");
707         cat.addContent(protocol);
708         cat.addContent(host);
709         cat.addContent(port);
710         cat.addContent(context);
711         root.addContent(cat);
712
713         cat = new Element("category");
714         cat.setAttribute("name", "testCat7");
715         protocol = new Element("protocol");
716         protocol.addContent("https");
717         host = new Element("host");
718         host.addContent("www.inversoft.com");
719         port = new Element("port");
720         port.addContent("443");
721         context = new Element("context");
722         context.addContent("MyWebApp");
723         cat.addContent(protocol);
724         cat.addContent(host);
725         cat.addContent(port);
726         cat.addContent(context);
727         root.addContent(cat);
728
729         cat = new Element("category");
730         cat.setAttribute("name", "testCat8");
731         protocol = new Element("protocol");
732         protocol.addContent("http");
733         host = new Element("host");
734         host.addContent("www.inversoft.com");
735         port = new Element("port");
736         port.addContent("80");
737         context = new Element("context");
738         context.addContent("");
739         cat.addContent(protocol);
740         cat.addContent(host);
741         cat.addContent(port);
742         cat.addContent(context);
743         root.addContent(cat);
744
745         cat = new Element("category");
746         cat.setAttribute("name", "testCat9");
747         //protocol = new Element("protocol");
748
//protocol.addContent("https");
749
host = new Element("host");
750         host.addContent("www.inversoft.com");
751         port = new Element("port");
752         port.addContent("8000");
753         context = new Element("context");
754         context.addContent("MyWebApp");
755         //cat.addContent(protocol);
756
cat.addContent(host);
757         cat.addContent(port);
758         cat.addContent(context);
759         root.addContent(cat);
760
761         cat = new Element("category");
762         cat.setAttribute("name", "testCat10");
763         protocol = new Element("protocol");
764         protocol.addContent("https");
765         //host = new Element("host");
766
//host.addContent("www.inversoft.com");
767
port = new Element("port");
768         port.addContent("8000");
769         context = new Element("context");
770         context.addContent("MyWebApp");
771         cat.addContent(protocol);
772         //cat.addContent(host);
773
cat.addContent(port);
774         cat.addContent(context);
775         root.addContent(cat);
776
777         cat = new Element("category");
778         cat.setAttribute("name", "testCat11");
779         protocol = new Element("protocol");
780         protocol.addContent("https");
781         host = new Element("host");
782         host.addContent("www.inversoft.com");
783         //port = new Element("port");
784
//port.addContent("8000");
785
context = new Element("context");
786         context.addContent("MyWebApp");
787         cat.addContent(protocol);
788         cat.addContent(host);
789         //cat.addContent(port);
790
cat.addContent(context);
791         root.addContent(cat);
792
793         cat = new Element("category");
794         cat.setAttribute("name", "testCat12");
795         protocol = new Element("protocol");
796         protocol.addContent("http");
797         host = new Element("host");
798         host.addContent("www.inversoft.com");
799         port = new Element("port");
800         port.addContent("8000");
801         //context = new Element("context");
802
//context.addContent("MyWebApp");
803
cat.addContent(protocol);
804         cat.addContent(host);
805         cat.addContent(port);
806         //cat.addContent(context);
807
root.addContent(cat);
808
809         return doc;
810     }
811 }
Popular Tags