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.test;
06:
07: import com.sun.portal.rewriter.engines.LanguageConstants;
08: import com.sun.portal.log.common.PortalLogger;
09: import com.sun.portal.rewriter.test.util.BasicTestCase;
10: import com.sun.portal.rewriter.util.i18n.MIMEHelper;
11: import com.sun.portal.rewriter.util.uri.PageSpec;
12: import com.sun.portal.rproxy.rewriter.SRAPRewriterModule;
13: import com.sun.portal.rproxy.rewriter.util.http.ContentInfo;
14: import junit.framework.TestSuite;
15: import junitx.util.PrivateAccessor;
16:
17: public class TestSRAPAdapterHelper extends BasicTestCase {
18: public TestSRAPAdapterHelper(String aName) {
19: super (aName);
20: }//constructor
21:
22: public void testUpdateMIME() throws Throwable {
23: String[][] lData = {
24: { "hTtps://raja.sun.com/abcW", MIMEHelper.UNKNOWN_MIME }, //0
25: { "hTtps://raja.sun.com/abc", LanguageConstants.JS_MIME }, //1
26: { "https://raja.sun.com", MIMEHelper.UNKNOWN_MIME }, //2
27: { "htTps://raja.sun.com/", MIMEHelper.UNKNOWN_MIME }, //3
28: { "httPs://raja.sun.com/abc/", MIMEHelper.UNKNOWN_MIME }, //4
29: { "https://raja.sun.com/abc.xyz",
30: MIMEHelper.UNKNOWN_MIME }, //5
31: { "ftp://raja.sun.com", MIMEHelper.UNKNOWN_MIME }, //6
32: { "nntp://raja.sun.com/", MIMEHelper.UNKNOWN_MIME }, //7
33: { "ftp://raja.sun.com/abc.xyz", MIMEHelper.UNKNOWN_MIME }, //8
34: { "ftp://raja.sun.com/abc.HTML",
35: LanguageConstants.HTML_MIME }, //9
36: { "http://raja.sun.com/abc.cgi",
37: LanguageConstants.HTML_MIME }, //10
38: { "http://raja.sun.com/abc.jsp",
39: LanguageConstants.HTML_MIME }, //11
40: { "http://raja.sun.com/abc.css",
41: LanguageConstants.CSS_MIME }, //12
42: { "http://raja.sun.com/abc.xml",
43: LanguageConstants.XML_MIME }, //13
44: { "http://raja.sun.com/text.css1",
45: MIMEHelper.UNKNOWN_MIME }, //14
46: { "text.css1", LanguageConstants.CSS_MIME }, //15
47: { "http://raja.sun.com/text.ts",
48: LanguageConstants.CSS_MIME }, //16
49: { "http://raja.sun.com/abc.css1",
50: MIMEHelper.UNKNOWN_MIME }, //17
51: { "http://raja.sun.com/abc.Js",
52: LanguageConstants.JS_MIME }, //18
53: { "http://raja.sun.com/abc.jS",
54: LanguageConstants.JS_MIME }, //19
55: };
56:
57: for (int i = 0; i < lData.length; i++) {
58: ContentInfo bContentInfo = new ContentInfo();
59: PageSpec bPageSpec = new PageSpec(lData[i][0]);
60: PrivateAccessor
61: .invoke(
62: Class
63: .forName("com.sun.portal.rproxy.rewriter.SRAPAdapterHelper"),
64: "updateMIME", new Class[] { PageSpec.class,
65: ContentInfo.class }, new Object[] {
66: bPageSpec, bContentInfo });
67: assertEquals("for i=" + i, lData[i][1], bContentInfo
68: .getMIME());
69: }
70: }//testUpdateMIME()
71:
72: public static void main(String[] args) {
73: SRAPRewriterModule.initFile();
74: //BasicTestCase.run( TestSRAPAdapterHelper.class );
75: TestSuite testSuite = new TestSuite();
76: testSuite.addTest(new TestSRAPAdapterHelper("testUpdateMIME"));
77: BasicTestCase.run(testSuite);
78: }//main()
79: }//class TestSRAPAdapterHelper
|