01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.rewriter.engines.test;
06:
07: import com.sun.portal.rewriter.engines.LanguageConstants;
08: import com.sun.portal.rewriter.engines.RewriterBroker;
09: import com.sun.portal.rewriter.rom.RuleSet;
10: import com.sun.portal.rewriter.rom.RuleSetManager;
11: import com.sun.portal.rewriter.test.util.BasicTestCase;
12: import com.sun.portal.rewriter.util.ConfigManager;
13:
14: public class TestRewriterBroker extends BasicTestCase {
15: private static final RewriterBroker rewriterBroker;
16:
17: static {
18: String dummyRuleSetString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
19: + "<!DOCTYPE RuleSet SYSTEM \"jar://rewriter.jar/resources/RuleSet.dtd\">"
20: + "<RuleSet id=\"psxyzdummyset\">" + "</RuleSet>";
21:
22: RewriterBroker r = null;
23: try {
24: RuleSet lRuleSet = RuleSetManager
25: .create(dummyRuleSetString);
26: r = new RewriterBroker(lRuleSet);
27: } catch (Exception e) {
28: ConfigManager
29: .componentPanic(
30: "Unable to Initialize the Dummy RuleSet Object:",
31: e);
32: }
33:
34: rewriterBroker = r;
35: }//static block
36:
37: public TestRewriterBroker(String aName) {
38: super (aName);
39: }//constructor
40:
41: public void testISRewriterExists() {
42: String[] mimes = { LanguageConstants.CSS_MIME,
43: LanguageConstants.HTML_MIME, LanguageConstants.JS_MIME,
44: LanguageConstants.XML_MIME,
45: LanguageConstants.MARKUP_MIME, };
46:
47: for (int i = 0; i < mimes.length; i++) {
48: assertNotNull(rewriterBroker.getInstance(mimes[i]));
49: }
50: }//testISRewriterExists()
51:
52: public void testRewriterDoesNotExist() {
53: String[] mimes = { "text/htMl", "text/plain", "image/gif",
54: "image/jpg", "text", "text/wml", "text/vnd.wap.wml", };
55:
56: for (int i = 0; i < mimes.length; i++) {
57: assertNull(rewriterBroker.getInstance(mimes[i]));
58: }
59: }//testRewriterDoesNotExist()
60:
61: public static void main(String[] args) {
62: BasicTestCase.run(TestRewriterBroker.class);
63: }//main()
64:
65: }//class TestRewriterBroker
|