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.rproxy.rewriter.engines.js.test;
06:
07: import com.sun.portal.rewriter.Rewriter;
08: import com.sun.portal.log.common.PortalLogger;
09: import com.sun.portal.rewriter.RewriterPool;
10: import com.sun.portal.rewriter.engines.LanguageConstants;
11: import com.sun.portal.rewriter.rom.RuleSet;
12: import com.sun.portal.rewriter.test.util.BasicTestCase;
13: import com.sun.portal.rewriter.test.util.CreateRuleSet;
14: import com.sun.portal.rproxy.connectionhandler.Request;
15: import com.sun.portal.rproxy.rewriter.SRAPRewriterModule;
16: import com.sun.portal.rproxy.rewriter.test.util.MockRequest;
17: import com.sun.portal.rproxy.rewriter.test.util.SRAPTestSystemFactory;
18: import junit.framework.TestSuite;
19:
20: public class TestSRAPJSDHTMLFunctions extends BasicTestCase {
21:
22: public TestSRAPJSDHTMLFunctions(String aName) {
23: super (aName);
24: }//constuctor
25:
26: public void testBugNo4790402PortalInterestHREF() throws Exception {
27: Request lRequest = new MockRequest(
28: "https://pgateway-1.advocatehealth.com/",
29: "http://carenet.advocatehealth.com/pho/ui/common/buttons.js");
30:
31: String lInput = "function doButton(com, stat, txt, cbt, id)\n"
32: + "{\n"
33: + " document.writeln(\"<table class=\\\"none\\\" border=\\\"0\\\" cellspacing=\\\"0\\\" cellpadding=\\\"0\\\">\");\n"
34: + " document.writeln(\" <tr>\");\n"
35: + " document.writeln(\" <td><img src=\\\"/pho/ui/common/images/bottomnav/btn_left.gif\\\" width=\\\"11\\\" height=\\\"21\\\"/></td>\");\n"
36: + " document.writeln(\" <td class=\\\"middle2\\\" background=\\\"/pho/ui/common/images/bottomnav/btn_center.gif\\\">\");\n"
37: + " document.writeln(\" <a class=\\\"whiteb\\\" href=\\\"#\\\"\");\n"
38: + " if(id)\n"
39: + " document.writeln(\" id=\\\"\" + id + \"\\\"\");\n"
40: + " if(cbt)\n"
41: + " document.writeln(\" name=\\\"commandButton\\\" value=\\\"\" + com + \"self.status='';\\\"\");\n"
42: + " document.writeln(\" onClick=\\\"\" + com + \"self.status='';\\\"\");\n"
43: + " document.writeln(\" onMouseOver=\\\"self.status='\" + stat + \"';return true;\\\"\");\n"
44: + " document.writeln(\" onMouseOut=\\\"self.status='';return true;\\\">\" + txt);\n"
45: + " document.writeln(\" </a>\");\n"
46: + " document.writeln(\" </td>\");\n"
47: + " document.writeln(\" <td><img src=\\\"/pho/ui/common/images/bottomnav/btn_right.gif\\\" width=\\\"11\\\" height=\\\"21\\\"/></td>\");\n"
48: + " document.writeln(\" <td><img src=\\\"/pho/ui/common/images/spacer.gif\\\" width=\\\"5\\\" height=\\\"21\\\"/></td>\");\n"
49: + " document.writeln(\" </tr>\");\n"
50: + " document.writeln(\"</table>\");\n" + "}\n";
51: String lExpectation = "function doButton(com, stat, txt, cbt, id)\n"
52: + "{\n"
53: + " document.writeln(\"<table class=\\\"none\\\" border=\\\"0\\\" cellspacing=\\\"0\\\" cellpadding=\\\"0\\\">\");\n"
54: + " document.writeln(\" <tr>\");\n"
55: + " document.writeln(\" <td><img src=\\\"https://pgateway-1.advocatehealth.com/http://carenet.advocatehealth.com/pho/ui/common/images/bottomnav/btn_left.gif\\\" width=\\\"11\\\" height=\\\"21\\\"/></td>\");\n"
56: + " document.writeln(\" <td class=\\\"middle2\\\" background=\\\"https://pgateway-1.advocatehealth.com/http://carenet.advocatehealth.com/pho/ui/common/images/bottomnav/btn_center.gif\\\">\");\n"
57: + " document.writeln(\" <a class=\\\"whiteb\\\" href=\\\"#\\\"\");\n"
58: + " if(id)\n"
59: + " document.writeln(\" id=\\\"\" + id + \"\\\"\");\n"
60: + " if(cbt)\n"
61: + " document.writeln(\" name=\\\"commandButton\\\" value=\\\"\" + com + \"self.status='';\\\"\");\n"
62: + " document.writeln(\" onClick=\\\"\" + com + \"self.status='';\\\"\");\n"
63: + " document.writeln(\" onMouseOver=\\\"self.status='\" + stat + \"';return true;\\\"\");\n"
64: + " document.writeln(\" onMouseOut=\\\"self.status='';return true;\\\">\" + txt);\n"
65: + " document.writeln(\" </a>\");\n"
66: + " document.writeln(\" </td>\");\n"
67: + " document.writeln(\" <td><img src=\\\"https://pgateway-1.advocatehealth.com/http://carenet.advocatehealth.com/pho/ui/common/images/bottomnav/btn_right.gif\\\" width=\\\"11\\\" height=\\\"21\\\"/></td>\");\n"
68: + " document.writeln(\" <td><img src=\\\"https://pgateway-1.advocatehealth.com/http://carenet.advocatehealth.com/pho/ui/common/images/spacer.gif\\\" width=\\\"5\\\" height=\\\"21\\\"/></td>\");\n"
69: + " document.writeln(\" </tr>\");\n"
70: + " document.writeln(\"</table>\");\n" + "}\n";
71:
72: String lHTMLAttRules = "<Attribute name=\"BACKGround\" />"
73: + "<Attribute name=\"src\" />"
74: + "<Attribute name=\"href\" />";
75:
76: String lJSFunRules = "<Function type=\"DHTML\" name=\"*.write*\" paramPatterns=\"y\"/>\n";
77:
78: RuleSet lRuleSet = CreateRuleSet.withHTMLAttJSVarJSFunRules(
79: lHTMLAttRules, "", lJSFunRules);
80: Rewriter lRewriter = RewriterPool.create(lRuleSet,
81: LanguageConstants.JS_MIME);
82: String lResult = lRewriter.rewrite(lInput,
83: SRAPTestSystemFactory.createSRAPTranslator(lRequest));
84: assertEquals(lExpectation, lResult);
85: }//testBugNo4790402PortalInterestHREF()
86:
87: public static void main(String[] args) {
88: SRAPRewriterModule.initFile();
89: //BasicTestCase.run( new TestSuite( TestSRAPJSDHTMLFunctions.class ) );
90:
91: TestSuite testSuite = new TestSuite();
92: testSuite.addTest(new TestSRAPJSDHTMLFunctions(
93: "testBugNo4790402PortalInterestHREF"));
94: BasicTestCase.run(testSuite);
95: }//main()
96: }//class TestSRAPJSDHTMLFunctions
|