KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > model > extensions > i18n > ReadChineaseTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.wsdl.model.extensions.i18n;
21
22 import java.io.File JavaDoc;
23 import java.net.URI JavaDoc;
24 import java.net.URL JavaDoc;
25 import java.util.Collection JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.ResourceBundle JavaDoc;
28 import javax.swing.text.Document JavaDoc;
29 import junit.framework.TestCase;
30 import org.netbeans.modules.xml.wsdl.model.Definitions;
31
32 import org.netbeans.modules.xml.wsdl.model.WSDLModel;
33 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType;
34 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role;
35
36 import org.netbeans.modules.xml.wsdl.model.extensions.TestCatalogModel;
37 import org.netbeans.modules.xml.wsdl.model.impl.Util;
38 /**
39  *
40  * @author sgenipudi
41  */

42 public class ReadChineaseTest extends TestCase {
43     
44 // private static final ResourceBundle mMessages =
45
// ResourceBundle.getBundle("org.netbeans.modules.xml.wsdl.model.extensions.i18n.Bundle");
46

47     public ReadChineaseTest(String JavaDoc testName) {
48         super(testName);
49     }
50     
51     protected void setUp() throws Exception JavaDoc {
52     }
53     
54     protected void tearDown() throws Exception JavaDoc {
55         
56     }
57     
58     public void testChineasePartnerLinkType() throws Exception JavaDoc {
59         TestCatalogModel.getDefault().setDocumentPooling(true);
60         String JavaDoc fileName = "/org/netbeans/modules/xml/wsdl/model/extensions/i18n/resources/SynchronousSample.wsdl";
61         URL JavaDoc url = getClass().getResource(fileName);
62         URI JavaDoc uri = url.toURI();
63         WSDLModel model = TestCatalogModel.getDefault().getWSDLModel(uri);
64         Definitions def = model.getDefinitions();
65         Collection JavaDoc<PartnerLinkType> plts = def.getExtensibilityElements(PartnerLinkType.class);
66         Iterator JavaDoc<PartnerLinkType> it = plts.iterator();
67         if(it.hasNext()) {
68             PartnerLinkType plt = it.next();
69             String JavaDoc pltName = plt.getName();
70             //The following is not the right way to define a string constant that has unicode chars in it.
71
//Though you see chinese chars (may be a Java editor bug too), Java treats them differently.
72
//If you want to do a string comparison with unicode string constant then
73
//unicode values of the non-ASCII chars must be escaped...
74
//e.g the following string will look like "partnerlinktype1\uc5ec\ubcf4\uc138\uc694"
75
//where the chinese chars are escaped.
76
String JavaDoc expectedPLTName = "partnerlinktype1??";
77             model.startTransaction();
78             plt.setName("modified"+pltName);
79             model.endTransaction();
80             Document JavaDoc doc = model.getBaseDocument();
81             //uncomment the following and view the file in the IDE you will see the proper modified name
82
//for the partner link type with the original chinese chars intact.
83
/*org.netbeans.modules.xml.wsdl.model.extensions.Util.dumpToFile(doc,
84                     new File("d:\\temp\\somefile.wsdl"));*/

85             assert(true);
86         }
87     }
88     
89      /*public void testChineasePartnerLinkTypeRole() throws Exception {
90         String fileName = "/org/netbeans/modules/xml/wsdl/model/extensions/i18n/resources/SynchronousSample.wsdl";
91         URL url = getClass().getResource(fileName);
92         URI uri = url.toURI();
93       
94         WSDLModel model = TestCatalogModel.getDefault().getWSDLModel(uri);
95         Definitions def = model.getDefinitions();
96         Collection<PartnerLinkType> plts = def.getExtensibilityElements(PartnerLinkType.class);
97         Iterator<PartnerLinkType> it = plts.iterator();
98         if(it.hasNext()) {
99             PartnerLinkType plt = it.next();
100             String pltName = plt.getName();
101       
102             Role role1 = plt.getRole1();
103             if(role1 != null) {
104                 String name = role1.getName();
105                 String expectedRoleName = "partnerlinktyperole1рш";
106                 //uncomment this to test
107                 //the role name is not having correct chinease strings
108                 assertEquals("name should match", expectedRoleName, name);
109             }
110         }
111     }*/

112     
113     public void testChineasePartnerLinkTypeDummy() throws Exception JavaDoc {
114         assertEquals("name should match","partnerlinktyperole1рш", "partnerlinktyperole1рш");
115     }
116 }
117
Popular Tags