001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.xml.wsdl.model.extensions.i18n;
043:
044: import java.io.File;
045: import java.net.URI;
046: import java.net.URL;
047: import java.util.Collection;
048: import java.util.Iterator;
049: import java.util.ResourceBundle;
050: import javax.swing.text.Document;
051: import junit.framework.TestCase;
052: import org.netbeans.modules.xml.wsdl.model.Definitions;
053:
054: import org.netbeans.modules.xml.wsdl.model.WSDLModel;
055: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType;
056: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role;
057:
058: import org.netbeans.modules.xml.wsdl.model.extensions.TestCatalogModel;
059: import org.netbeans.modules.xml.wsdl.model.impl.Util;
060:
061: /**
062: *
063: * @author sgenipudi
064: */
065: public class ReadChineaseTest extends TestCase {
066:
067: // private static final ResourceBundle mMessages =
068: // ResourceBundle.getBundle("org.netbeans.modules.xml.wsdl.model.extensions.i18n.Bundle");
069:
070: public ReadChineaseTest(String testName) {
071: super (testName);
072: }
073:
074: protected void setUp() throws Exception {
075: }
076:
077: protected void tearDown() throws Exception {
078:
079: }
080:
081: public void testChineasePartnerLinkType() throws Exception {
082: TestCatalogModel.getDefault().setDocumentPooling(true);
083: String fileName = "/org/netbeans/modules/xml/wsdl/model/extensions/i18n/resources/SynchronousSample.wsdl";
084: URL url = getClass().getResource(fileName);
085: URI uri = url.toURI();
086: WSDLModel model = TestCatalogModel.getDefault().getWSDLModel(
087: uri);
088: Definitions def = model.getDefinitions();
089: Collection<PartnerLinkType> plts = def
090: .getExtensibilityElements(PartnerLinkType.class);
091: Iterator<PartnerLinkType> it = plts.iterator();
092: if (it.hasNext()) {
093: PartnerLinkType plt = it.next();
094: String pltName = plt.getName();
095: //The following is not the right way to define a string constant that has unicode chars in it.
096: //Though you see chinese chars (may be a Java editor bug too), Java treats them differently.
097: //If you want to do a string comparison with unicode string constant then
098: //unicode values of the non-ASCII chars must be escaped...
099: //e.g the following string will look like "partnerlinktype1\uc5ec\ubcf4\uc138\uc694"
100: //where the chinese chars are escaped.
101: String expectedPLTName = "partnerlinktype1??";
102: model.startTransaction();
103: plt.setName("modified" + pltName);
104: model.endTransaction();
105: Document doc = model.getBaseDocument();
106: //uncomment the following and view the file in the IDE you will see the proper modified name
107: //for the partner link type with the original chinese chars intact.
108: /*org.netbeans.modules.xml.wsdl.model.extensions.Util.dumpToFile(doc,
109: new File("d:\\temp\\somefile.wsdl"));*/
110: assert (true);
111: }
112: }
113:
114: /*public void testChineasePartnerLinkTypeRole() throws Exception {
115: String fileName = "/org/netbeans/modules/xml/wsdl/model/extensions/i18n/resources/SynchronousSample.wsdl";
116: URL url = getClass().getResource(fileName);
117: URI uri = url.toURI();
118:
119: WSDLModel model = TestCatalogModel.getDefault().getWSDLModel(uri);
120: Definitions def = model.getDefinitions();
121: Collection<PartnerLinkType> plts = def.getExtensibilityElements(PartnerLinkType.class);
122: Iterator<PartnerLinkType> it = plts.iterator();
123: if(it.hasNext()) {
124: PartnerLinkType plt = it.next();
125: String pltName = plt.getName();
126:
127: Role role1 = plt.getRole1();
128: if(role1 != null) {
129: String name = role1.getName();
130: String expectedRoleName = "partnerlinktyperole1рш";
131: //uncomment this to test
132: //the role name is not having correct chinease strings
133: assertEquals("name should match", expectedRoleName, name);
134: }
135: }
136: }*/
137:
138: public void testChineasePartnerLinkTypeDummy() throws Exception {
139: assertEquals("name should match", "partnerlinktyperole1рш",
140: "partnerlinktyperole1рш");
141: }
142: }
|