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.util.xml.test;
006:
007: import com.sun.portal.rewriter.test.util.BasicTestCase;
008: import com.sun.portal.rewriter.util.xml.Tag;
009: import com.sun.portal.rewriter.util.xml.TagParser;
010: import junit.framework.TestSuite;
011:
012: public class TestTagParser extends BasicTestCase {
013: public TestTagParser(String aName) {
014: super (aName);
015: }//constuctor
016:
017: public void testParse() {
018: String[][] lData = {
019: { "base=''", "base = \"\" " },
020:
021: { "base=\"abc.html\"", "base = \"abc.html\" ", },
022: { "base", "base " },
023:
024: { " base", "base " },
025:
026: {
027: "xml version=\"1.0\" abc=\"\" encoding=UTF-8 abjc=\"\" ",
028: "xml version = \"1.0\" abc = \"\" encoding = \"UTF-8\" abjc = \"\" ", }, //0
029:
030: {
031: "xml version=\"1.0\" abc=\"\" encoding=UTF-8 ",
032: "xml version = \"1.0\" abc = \"\" encoding = \"UTF-8\" ", }, //1
033:
034: {
035: "xml version=\"1.0\" abc=\"\" encoding=\"UTF-8\" ",
036: "xml version = \"1.0\" abc = \"\" encoding = \"UTF-8\" ", }, //2
037:
038: {
039: "xml version=\"1.0\" encoding=\"UTF-8\" abc=\"\" ",
040: "xml version = \"1.0\" encoding = \"UTF-8\" abc = \"\" ", }, //3
041:
042: {
043: "xml version=\"1.0\" encoding=\"UTF-8\" encoding=\"UTF-108\" ",
044: "xml version = \"1.0\" encoding = \"UTF-108\" ",
045: "xml version = \"1.0\" encoding = \"UTF-108\" encoding = \"UTF-108\" ", }, //4
046:
047: { "xml version=\"1.0\" encoding=\"UTF-8\" ",
048: "xml version = \"1.0\" encoding = \"UTF-8\" ", }, //5
049:
050: { "xml version=\"1.0\" encoding=UTF-8",
051: "xml version = \"1.0\" encoding = \"UTF-8\" ", }, //6
052:
053: {
054: "<base href \t = \t \"/raha.html\" target = \"_blank\" >=10",
055: "<base href = \"/raha.html\" target = \"_blank\" > = \"10\" ", }, //7
056:
057: {
058: "base href \t = \t \"/raha.html\" target = \"_blank\" ",
059: "base href = \"/raha.html\" target = \"_blank\" ", }, //8
060:
061: {
062: "base href \t = \t \"/raha.html\" target = \"_blank\"",
063: "base href = \"/raha.html\" target = \"_blank\" ", }, //9
064:
065: {
066: "<base href \t = \t \"/raha.html\" target = \"_blank\"",
067: "<base href = \"/raha.html\" target = \"_blank\" ", }, //10
068:
069: { null, new Tag().toString() }, //11
070:
071: { "", new Tag().toString() }, //12
072:
073: {
074: " <applet name=\"applet\" \n"
075: + " code=\"Chalo.class\" \n"
076: + " width=\"400\" \n"
077: + " height=\"200\" \n"
078: + " codebase=http://www.sun.com/applets/somedir/../rajesh/./mahesh/raju/.\n"
079: + " archive=\"abc/def/Chalo.jar\" \n",
080: "<applet name = \"applet\" code = \"Chalo.class\" width = \"400\" height = \"200\" codebase = \"http://www.sun.com/applets/somedir/../rajesh/./mahesh/raju/.\" archive = \"abc/def/Chalo.jar\" " }, //13
081:
082: {
083: "applet name=\"applet\" \n"
084: + " code=\"Hello1.class\" \n"
085: + " width=\"400\" \n"
086: + " height=\"200\" \n"
087: + " codebase=\"/applets/somedir/\" \n"
088: + " archive=\"abc/def/Hello1.jar\"\n",
089: "applet name = \"applet\" code = \"Hello1.class\" width = \"400\" height = \"200\" codebase = \"/applets/somedir/\" archive = \"abc/def/Hello1.jar\" "
090:
091: }, //14
092:
093: { "raju = \"http.com\" href = \"100\"",
094: "raju = \"http.com\" href = \"100\" " }, //15
095:
096: { " a raju=111 href=\" \"",
097: "a raju = \"111\" href = \"\" " }, //16
098:
099: {
100: "<td id=2 bgcolor=#efefef align=center width=120 onClick=\"return c('/grphp?hl=en'); style=cursor:hand;\"",
101: "<td id = \"2\" bgcolor = \"#efefef\" align = \"center\" width = \"120\" onClick = \"return c('/grphp?hl=en'); style=cursor:hand;\" ",
102: //"<td id = \"2\" bgcolor = \"#efefef\" align = \"center\" width = \"120\" nowrap onClick = \"return c('/grphp?hl=en');\" style = \"cursor:hand;>\" "
103: }, //17
104:
105: /*{
106: "<base href \t = \t \"/raha.html\" target = \"_blank\" >",
107: "<base href = \"/raha.html\" target = \"_blank\" ",
108: }, //1
109:
110: {
111: "<base href \n = \n \"/raha.html\" target = \"_blank\">",
112: "<base href = \"/raha.html\" target = \"_blank\" ",
113: },
114:
115: {
116: "<?xml version=\"1.0\" encodING ?>\n",
117: "<?xml version = \"1.0\" encodING ?> ",
118: },
119:
120: {
121: "raju = href = \"100\"",
122: "raju = \"href=100\" "
123: },
124:
125: {
126: "raju = href = \" \"",
127: "raju = \"href= \" "
128: },
129:
130: {
131: " a raju = href = \" \"",
132: "a raju = \"href= \" "
133:
134: },
135:
136: {
137: " raju=111 href=\" \" dummy = ",
138: "raju = \"111\" href = \" \" dummy = \"\" "
139:
140: },
141:
142: {
143: " a raju=111 href=\" \" dummy ",
144: "a raju = \"111\" href = \" \" dummy "
145: },
146:
147: {
148: " a raju=111 href=\" \" dummy = ",
149: "a raju = \"111\" href = \" \" dummy = \"\" "
150: },
151:
152: {
153: " a raju= href=\" \"",
154: "a raju = \"href= \" "
155:
156: },
157:
158: {
159: "<a href=\"/mgyhp.html\" onClick = \" var \"ab\" = 10 +45 -122 3339 style.behavior = ' var ab = 10 m+13 ; url(#default#homepage)';setHomePage('http://www.google.com/');\">",
160: "<a href = \"/mgyhp.html\" onClick = \"var\" ab\" = 10 +45 -122 3339 style.behavior = ' var ab = 10 m+13 ; url(#default#homepage)';setHomePage('http://www.google.com/');\">",
161: //"<a href = \"/mgyhp.html\" onClick = \"var ab=10 +45 -122 3339 style.behavior=' var ab=10 m+13 ; url(#default#homepage)';setHomePage('http://www.google.com/');>\" "
162: },
163:
164: {
165: "<td id=2 bgcolor=#efefef align=center width=120 nowrap onClick=\"return c('/grphp?hl=en');\" style=cursor:hand;>",
166: "<td id = \"2\" bgcolor = \"#efefef\" align = \"center\" width = \"120\" nowrap onClick=\"return c('/grphp?hl=en');\" style=cursor:hand;>",
167: //"<td id = \"2\" bgcolor = \"#efefef\" align = \"center\" width = \"120\" nowrap onClick = \"return c('/grphp?hl=en');\" style = \"cursor:hand;>\" "
168: },*/
169: };
170:
171: for (int i = 0; i < lData.length; i++) {
172: Tag t = TagParser.parse(lData[i][0], null);
173: assertEquals("Failed For i = " + i + t.toString(),
174: lData[i][1], t.toString());
175: }
176: }//testParse()
177:
178: public static void main(String[] args) {
179: //BasicTestCase.run( TestTagParser.class );
180:
181: TestSuite testSuite = new TestSuite();
182: testSuite.addTest(new TestTagParser("testParse"));
183: BasicTestCase.run(testSuite);
184: }//main()
185: }//class TestTagParser
|