Source Code Cross Referenced for TestStringPrep.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » test » stringprep » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.dev.test.stringprep 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 2003-2005, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:        package com.ibm.icu.dev.test.stringprep;
008:
009:        import com.ibm.icu.dev.test.TestFmwk;
010:        import com.ibm.icu.text.StringPrepParseException;
011:
012:        /**
013:         * @author ram
014:         *
015:         */
016:        public class TestStringPrep extends TestFmwk {
017:            public static void main(String[] args) throws Exception {
018:                new TestStringPrep().run(args);
019:            }
020:
021:            /*
022:               There are several special identifiers ("who") which need to be
023:               understood universally, rather than in the context of a particular
024:               DNS domain.  Some of these identifiers cannot be understood when an
025:               NFS client accesses the server, but have meaning when a local process
026:               accesses the file.  The ability to display and modify these
027:               permissions is permitted over NFS, even if none of the access methods
028:               on the server understands the identifiers.
029:
030:                Who                    Description
031:               _______________________________________________________________
032:
033:               "OWNER"                The owner of the file.
034:               "GROUP"                The group associated with the file.
035:               "EVERYONE"             The world.
036:               "INTERACTIVE"          Accessed from an interactive terminal.
037:               "NETWORK"              Accessed via the network.
038:               "DIALUP"               Accessed as a dialup user to the server.
039:               "BATCH"                Accessed from a batch job.
040:               "ANONYMOUS"            Accessed without any authentication.
041:               "AUTHENTICATED"        Any authenticated user (opposite of
042:                                      ANONYMOUS)
043:               "SERVICE"              Access from a system service.
044:
045:               To avoid conflict, these special identifiers are distinguish by an
046:               appended "@" and should appear in the form "xxxx@" (note: no domain
047:               name after the "@").  For example: ANONYMOUS@.
048:             */
049:            private String[] mixed_prep_data = {
050:                    "OWNER@",
051:                    "GROUP@",
052:                    "EVERYONE@",
053:                    "INTERACTIVE@",
054:                    "NETWORK@",
055:                    "DIALUP@",
056:                    "BATCH@",
057:                    "ANONYMOUS@",
058:                    "AUTHENTICATED@",
059:                    "\u0930\u094D\u092E\u094D\u0915\u094D\u0937\u0947\u0924\u094D@slip129-37-118-146.nc.us.ibm.net",
060:                    "\u0936\u094d\u0930\u0940\u092e\u0926\u094d@saratoga.pe.utexas.edu",
061:                    "\u092d\u0917\u0935\u0926\u094d\u0917\u0940\u0924\u093e@dial-120-45.ots.utexas.edu",
062:                    "\u0905\u0927\u094d\u092f\u093e\u092f@woo-085.dorms.waller.net",
063:                    "\u0905\u0930\u094d\u091c\u0941\u0928@hd30-049.hil.compuserve.com",
064:                    "\u0935\u093f\u0937\u093e\u0926@pem203-31.pe.ttu.edu",
065:                    "\u092f\u094b\u0917@56K-227.MaxTNT3.pdq.net",
066:                    "\u0927\u0943\u0924\u0930\u093e\u0937\u094d\u091f\u094d\u0930@dial-36-2.ots.utexas.edu",
067:                    "\u0909\u0935\u093E\u091A\u0943@slip129-37-23-152.ga.us.ibm.net",
068:                    "\u0927\u0930\u094d\u092e\u0915\u094d\u0937\u0947\u0924\u094d\u0930\u0947@ts45ip119.cadvision.com",
069:                    "\u0915\u0941\u0930\u0941\u0915\u094d\u0937\u0947\u0924\u094d\u0930\u0947@sdn-ts-004txaustP05.dialsprint.net",
070:                    "\u0938\u092e\u0935\u0947\u0924\u093e@bar-tnt1s66.erols.com",
071:                    "\u092f\u0941\u092f\u0941\u0924\u094d\u0938\u0935\u0903@101.st-louis-15.mo.dial-access.att.net",
072:                    "\u092e\u093e\u092e\u0915\u093e\u0903@h92-245.Arco.COM",
073:                    "\u092a\u093e\u0923\u094d\u0921\u0935\u093e\u0936\u094d\u091a\u0948\u0935@dial-13-2.ots.utexas.edu",
074:                    "\u0915\u093f\u092e\u0915\u0941\u0930\u094d\u0935\u0924@net-redynet29.datamarkets.com.ar",
075:                    "\u0938\u0902\u091c\u0935@ccs-shiva28.reacciun.net.ve",
076:                    "\u0c30\u0c18\u0c41\u0c30\u0c3e\u0c2e\u0c4d@7.houston-11.tx.dial-access.att.net",
077:                    "\u0c35\u0c3f\u0c36\u0c4d\u0c35\u0c28\u0c3e\u0c27@ingw129-37-120-26.mo.us.ibm.net",
078:                    "\u0c06\u0c28\u0c02\u0c26\u0c4d@dialup6.austintx.com",
079:                    "\u0C35\u0C26\u0C4D\u0C26\u0C3F\u0C30\u0C3E\u0C1C\u0C41@dns2.tpao.gov.tr",
080:                    "\u0c30\u0c3e\u0c1c\u0c40\u0c35\u0c4d@slip129-37-119-194.nc.us.ibm.net",
081:                    "\u0c15\u0c36\u0c30\u0c2c\u0c3e\u0c26@cs7.dillons.co.uk.203.119.193.in-addr.arpa",
082:                    "\u0c38\u0c02\u0c1c\u0c40\u0c35\u0c4d@swprd1.innovplace.saskatoon.sk.ca",
083:                    "\u0c15\u0c36\u0c30\u0c2c\u0c3e\u0c26@bikini.bologna.maraut.it",
084:                    "\u0c38\u0c02\u0c1c\u0c40\u0c2c\u0c4d@node91.subnet159-198-79.baxter.com",
085:                    "\u0c38\u0c46\u0c28\u0c4d\u0c17\u0c41\u0c2a\u0c4d\u0c24@cust19.max5.new-york.ny.ms.uu.net",
086:                    "\u0c05\u0c2e\u0c30\u0c47\u0c02\u0c26\u0c4d\u0c30@balexander.slip.andrew.cmu.edu",
087:                    "\u0c39\u0c28\u0c41\u0c2e\u0c3e\u0c28\u0c41\u0c32@pool029.max2.denver.co.dynip.alter.net",
088:                    "\u0c30\u0c35\u0c3f@cust49.max9.new-york.ny.ms.uu.net",
089:                    "\u0c15\u0c41\u0c2e\u0c3e\u0c30\u0c4d@s61.abq-dialin2.hollyberry.com",
090:                    "\u0c35\u0c3f\u0c36\u0c4d\u0c35\u0c28\u0c3e\u0c27@\u0917\u0928\u0947\u0936.sanjose.ibm.com",
091:                    "\u0c06\u0c26\u0c3f\u0c24\u0c4d\u0c2f@www.\u00E0\u00B3\u00AF.com",
092:                    "\u0C15\u0C02\u0C26\u0C4D\u0C30\u0C47\u0C17\u0C41\u0c32@www.\u00C2\u00A4.com",
093:                    "\u0c36\u0c4d\u0c30\u0c40\u0C27\u0C30\u0C4D@www.\u00C2\u00A3.com",
094:                    "\u0c15\u0c02\u0c1f\u0c2e\u0c36\u0c46\u0c1f\u0c4d\u0c1f\u0c3f@\u0025",
095:                    "\u0c2e\u0c3e\u0c27\u0c35\u0c4d@\u005C\u005C",
096:                    "\u0c26\u0c46\u0c36\u0c46\u0c1f\u0c4d\u0c1f\u0c3f@www.\u0021.com",
097:                    "test@www.\u0024.com", "help@\u00C3\u00BC.com", };
098:
099:            public void TestNFS4MixedPrep() {
100:                for (int i = 0; i < mixed_prep_data.length; i++) {
101:                    try {
102:                        String src = mixed_prep_data[i];
103:                        byte[] dest = NFS4StringPrep.mixed_prepare(src
104:                                .getBytes("UTF-8"));
105:                        String destString = new String(dest, "UTF-8");
106:                        int destIndex = destString.indexOf('@');
107:                        if (destIndex < 0) {
108:                            errln("Delimiter @ disappeared from the output!");
109:                        }
110:                    } catch (Exception e) {
111:                        errln("mixed_prepare for string: " + mixed_prep_data[i]
112:                                + " failed with " + e.toString());
113:                    }
114:                }
115:                /* test the error condition */
116:                {
117:                    String src = "OWNER@oss.software.ibm.com";
118:                    try {
119:                        byte[] dest = NFS4StringPrep.mixed_prepare(src
120:                                .getBytes("UTF-8"));
121:                        if (dest != null) {
122:                            errln("Did not get the expected exception");
123:                        }
124:                    } catch (Exception e) {
125:                        logln("mixed_prepare for string: " + src
126:                                + " passed with " + e.toString());
127:                    }
128:
129:                }
130:            }
131:
132:            public void TestCISPrep() {
133:
134:                for (int i = 0; i < (TestData.conformanceTestCases.length); i++) {
135:                    TestData.ConformanceTestCase testCase = TestData.conformanceTestCases[i];
136:                    String src = testCase.input;
137:                    Exception expected = testCase.expected;
138:                    String expectedDest = testCase.output;
139:                    try {
140:                        byte[] dest = NFS4StringPrep.cis_prepare(src
141:                                .getBytes("UTF-8"));
142:                        String destString = new String(dest, "UTF-8");
143:                        if (!expectedDest.equalsIgnoreCase(destString)) {
144:                            errln("Did not get the expected output for nfs4_cis_prep at index "
145:                                    + i);
146:                        }
147:                    } catch (Exception e) {
148:                        if (!expected.equals(e)) {
149:                            errln("Did not get the expected exception");
150:                        }
151:                    }
152:
153:                }
154:            }
155:
156:            public void TestCSPrep() {
157:
158:                // Checking for bidi is turned off
159:                String src = "\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774\u0644\u064A\u0647\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74";
160:                try {
161:                    NFS4StringPrep.cs_prepare(src.getBytes("UTF-8"), false);
162:                } catch (Exception e) {
163:                    errln("Got unexpected exception: " + e.toString());
164:                }
165:
166:                // normalization is turned off
167:                try {
168:                    src = "www.\u00E0\u00B3\u00AF.com";
169:                    byte[] dest = NFS4StringPrep.cs_prepare(src
170:                            .getBytes("UTF-8"), false);
171:                    String destStr = new String(dest, "UTF-8");
172:                    if (!src.equals(destStr)) {
173:                        errln("Did not get expected output. Expected: "
174:                                + prettify(src) + " Got: " + prettify(destStr));
175:                    }
176:                } catch (Exception e) {
177:                    errln("Got unexpected exception: " + e.toString());
178:                }
179:
180:                // test case insensitive string
181:                try {
182:                    src = "THISISATEST";
183:                    byte[] dest = NFS4StringPrep.cs_prepare(src
184:                            .getBytes("UTF-8"), false);
185:                    String destStr = new String(dest, "UTF-8");
186:                    if (!src.toLowerCase().equals(destStr)) {
187:                        errln("Did not get expected output. Expected: "
188:                                + prettify(src) + " Got: " + prettify(destStr));
189:                    }
190:                } catch (Exception e) {
191:                    errln("Got unexpected exception: " + e.toString());
192:                }
193:                // test case sensitive string
194:                try {
195:                    src = "THISISATEST";
196:                    byte[] dest = NFS4StringPrep.cs_prepare(src
197:                            .getBytes("UTF-8"), true);
198:                    String destStr = new String(dest, "UTF-8");
199:                    if (!src.equals(destStr)) {
200:                        errln("Did not get expected output. Expected: "
201:                                + prettify(src) + " Got: " + prettify(destStr));
202:                    }
203:                } catch (Exception e) {
204:                    errln("Got unexpected exception: " + e.toString());
205:                }
206:            }
207:
208:            public void TestCoverage() {
209:                if (new StringPrepParseException("coverage", 0, "", 0, 0) == null) {
210:                    errln("Construct StringPrepParseException(String, int, String, int, int)");
211:                }
212:            }
213:
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.