001: /*
002: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005: package com.sun.portal.rewriter.test;
006:
007: import com.sun.portal.rewriter.AbstractTranslator;
008: import com.sun.portal.rewriter.RewriterModule;
009: import com.sun.portal.rewriter.engines.js.parser.JSParser;
010: import com.sun.portal.rewriter.engines.markup.MarkupRewriter;
011: import com.sun.portal.rewriter.engines.xml.XMLRewriter;
012: import com.sun.portal.rewriter.services.DataServiceHelper;
013: import com.sun.portal.rewriter.test.util.BasicTestCase;
014: import com.sun.portal.rewriter.util.ConfigManager;
015: import com.sun.portal.rewriter.util.Constants;
016: import com.sun.portal.rewriter.util.uri.StandardURI;
017:
018: public class TestRewriterModule extends BasicTestCase {
019: public TestRewriterModule(String aName) {
020: super (aName);
021: }//constructor
022:
023: public void testConfigProps() {
024: String text = "Rewriter Component Property '";
025:
026: {
027: String moduleID = ConfigManager
028: .getProperty(Constants.PROPERTY_MODULE_ID);
029: assertTrue(
030: text
031: + Constants.PROPERTY_MODULE_ID
032: + "' should not be null"
033: + ". Correct the property in file: "
034: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
035: moduleID.length() > 0);
036: }
037:
038: {
039: boolean commentBaseHREF = ConfigManager
040: .getBoolean(MarkupRewriter.PROPERTY_IS_COMMENT_BASE_HREF);
041: assertTrue(
042: text
043: + MarkupRewriter.PROPERTY_IS_COMMENT_BASE_HREF
044: + "' should be 'true' "
045: + ". Correct the property in file: "
046: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
047: commentBaseHREF);
048: }
049:
050: {
051: boolean commentBodyBackground = ConfigManager
052: .getBoolean(MarkupRewriter.PROPERTY_IS_COMMENT_BODY_BACKGROUND);
053: assertTrue(
054: text
055: + MarkupRewriter.PROPERTY_IS_COMMENT_BODY_BACKGROUND
056: + " should be 'true'"
057: + ". Correct the property in file: "
058: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
059: commentBodyBackground);
060: }
061:
062: {
063: boolean rewriteVarsInDHTML = ConfigManager
064: .getBoolean(JSParser.PROPERTY_IS_REWRITE_VARS_IN_DHTML);
065: assertTrue(
066: text
067: + JSParser.PROPERTY_IS_REWRITE_VARS_IN_DHTML
068: + " should be true "
069: + ". Correct the property in file: "
070: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
071: rewriteVarsInDHTML);
072: }
073:
074: {
075: boolean rewriteXSL = ConfigManager
076: .getBoolean(XMLRewriter.PROPERTY_IS_REWRITE_XSL);
077: assertTrue(
078: text
079: + XMLRewriter.PROPERTY_IS_REWRITE_XSL
080: + "should be true"
081: + ". Correct the property in file: "
082: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
083: rewriteXSL);
084: }
085:
086: {
087: boolean normalizeLikeBrowser = ConfigManager
088: .getBoolean(StandardURI.PROPERTY_IS_NORMALIZE_URI_LIKE_BROWSER);
089: assertTrue(
090: text
091: + StandardURI.PROPERTY_IS_NORMALIZE_URI_LIKE_BROWSER
092: + "' should be true"
093: + ". Correct the property in file: "
094: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
095: normalizeLikeBrowser);
096: }
097:
098: {
099: boolean insertScriptReferrer = ConfigManager
100: .getBoolean(AbstractTranslator.PROPERTY_IS_ADD_SCRIPT_REFERRER);
101: assertTrue(
102: text
103: + AbstractTranslator.PROPERTY_IS_ADD_SCRIPT_REFERRER
104: + "' should be true"
105: + ". Correct the property in file: "
106: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
107: insertScriptReferrer);
108: }
109:
110: {
111: boolean insertCodeBase = ConfigManager
112: .getBoolean(MarkupRewriter.PROPERTY_IS_INSERT_CODEBASE);
113: assertTrue(
114: text
115: + MarkupRewriter.PROPERTY_IS_INSERT_CODEBASE
116: + "' should be true"
117: + ". Correct the property in file: "
118: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
119: insertCodeBase);
120: }
121:
122: {
123: String excludedFormTypes = ConfigManager.getProperty(
124: MarkupRewriter.PROPERTY_EXCLUDED_FORM_INPUT_TYPES)
125: .trim();
126: assertTrue(
127: text
128: + MarkupRewriter.PROPERTY_EXCLUDED_FORM_INPUT_TYPES
129: + "' should be true"
130: + ". Correct the property in file: "
131: + RewriterModule.RESOURCE_REWRITER_MODULE_PROPERTIES_LOCATION,
132: excludedFormTypes.length() > 0);
133: }
134: }//testConfigProps()
135:
136: public static void main(String[] args) {
137: RewriterModule.init(DataServiceHelper.getDefaultFileProps(),
138: null, null);
139: BasicTestCase.run(TestRewriterModule.class);
140: }//main()
141:
142: }//class TestRewriterModule
|