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.util;
006:
007: import com.sun.portal.rewriter.AbsoluteTranslator;
008: import com.sun.portal.rewriter.Translator;
009: import com.sun.portal.rewriter.rom.DataRuleCollection;
010: import com.sun.portal.rewriter.rom.Rule;
011: import com.sun.portal.rewriter.rom.RuleCollection;
012: import com.sun.portal.rewriter.rom.RuleSet;
013: import com.sun.portal.rewriter.rom.common.Attribute;
014: import com.sun.portal.rewriter.rom.common.AttributeRule;
015: import com.sun.portal.rewriter.rom.common.TagText;
016: import com.sun.portal.rewriter.rom.common.TagTextRule;
017: import com.sun.portal.rewriter.rom.html.Applet;
018: import com.sun.portal.rewriter.rom.html.AppletRule;
019: import com.sun.portal.rewriter.rom.html.Form;
020: import com.sun.portal.rewriter.rom.html.FormRule;
021: import com.sun.portal.rewriter.rom.html.HTMLRules;
022: import com.sun.portal.rewriter.rom.js.Function;
023: import com.sun.portal.rewriter.rom.js.FunctionRule;
024: import com.sun.portal.rewriter.rom.js.JSRules;
025: import com.sun.portal.rewriter.rom.js.Variable;
026: import com.sun.portal.rewriter.rom.js.VariableRule;
027: import com.sun.portal.rewriter.rom.xml.XMLRules;
028: import com.sun.portal.rewriter.util.uri.PageSpec;
029:
030: /**
031: * This class contains all the inputs required to do testing of all the
032: * modules. All the unit tests put in the class main() method depend on this
033: * for the test/default data
034: *
035: * @version 1.0 12/15/2001
036: * @author Raja Nagendra Kumar, Nagendra.Raja@sun.com
037: */
038: public final class SampleRuleObjects implements Rule {
039:
040: //RuleSet Inputs Start
041: public static final FormRule[] defaultHTMLForms = new FormRule[] {
042: new FormRule(new Form(
043: "http://rajanagendra.sun.com/Forms.jsp", "Form1",
044: "input*", "raja|*|*")),
045: new FormRule(new Form(
046: "http://rajanagendra.sun.com/Forms.jsp", "Form1",
047: "*", "raja|*|*")),
048: new FormRule(new Form("/somehtml.html", "form1",
049: "iplanet1", "0|1234|url1")),
050: new FormRule(new Form("/somehtml.html", "form1",
051: "iplanet*", "url1, url2, url3")),
052: new FormRule(new Form("/somehtml.html", "form1", "*3",
053: "*|*|*| url2")),
054: new FormRule(new Form("/somehtml.html", "form1",
055: "iplanet1", "*|*|*| none")),
056: new FormRule(new Form("*", "*", "iplanet2", "0|1234|*")), };
057:
058: public static final AppletRule[] defaultHTMLApplets = new AppletRule[] { new AppletRule(
059: new Applet("NetFile.class", "archives", "123|wer|*",
060: "/netfile.jsp")), };
061:
062: public static final AttributeRule[] defaultHTMLAttributes = new AttributeRule[] {
063: new AttributeRule(new Attribute("href", "a",
064: "http://raja.sun.com/*", null, null)),
065: new AttributeRule(new Attribute("onLoad", null, null,
066: Rule.DJS, null)),
067:
068: };
069:
070: public static final VariableRule[] defaultJSVariables = new VariableRule[] { new VariableRule(
071: new Variable("aURL")), };
072:
073: public static final FunctionRule[] defaultJSFunctions = new FunctionRule[] { new FunctionRule(
074: new Function("func1", ",,,*,*", EXPRESSION, null)), };
075:
076: public static final AttributeRule[] defaultXMLAttributes = new AttributeRule[] { new AttributeRule(
077: new Attribute("href", "a", "http://raja.sun.com/*", null,
078: null)), };
079:
080: public static final TagTextRule[] defaultXMLTextStrings = new TagTextRule[] { new TagTextRule(
081: new TagText("span", "*,*|raja", null)), };
082:
083: private static final String testBase = "http://rajanagendra.sun.com/Base/Raja/";
084: private static final String testPath = "raja.html?name=raja";
085: public static PageSpec testPageSpec;
086: public static Translator defaultTranslator;
087:
088: public static HTMLRules defaultHTMLRules;
089: public static JSRules defaultJSRules;
090: public static XMLRules defaultXMLRules;
091: public static RuleSet defaultRuleSet;
092:
093: static {
094: try {
095: testPageSpec = new PageSpec(testBase + testPath, "");
096: defaultTranslator = new AbsoluteTranslator(testPageSpec);
097: defaultHTMLRules = new HTMLRules(new RuleCollection[] {
098: new DataRuleCollection(FORM, defaultHTMLForms),
099: new DataRuleCollection(APPLET, defaultHTMLApplets),
100: new DataRuleCollection(ATTRIBUTE,
101: defaultHTMLAttributes), });
102:
103: defaultJSRules = new JSRules(
104: new RuleCollection[] {
105: new DataRuleCollection(FUNCTION,
106: defaultJSFunctions),
107: new DataRuleCollection(VARIABLE,
108: defaultJSVariables), });
109:
110: defaultXMLRules = new XMLRules(new RuleCollection[] {
111: new DataRuleCollection(ATTRIBUTE,
112: defaultXMLAttributes),
113: new DataRuleCollection(TAGTEXT,
114: defaultXMLTextStrings), });
115:
116: defaultRuleSet = new RuleSet("default_ruleset", Rule.NONE,
117: new RuleCollection[] { defaultHTMLRules,
118: defaultJSRules, defaultXMLRules, });
119: } catch (Exception e) {
120: defaultHTMLRules = null;
121: defaultJSRules = null;
122: defaultXMLRules = null;
123: defaultRuleSet = null;
124: }
125: //RuleSet Inputs End
126: }//static block
127:
128: public String toXML() {
129: return null;
130: }
131: }//class SampleRuleObjects
|