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: * If you wish your version of this file to be governed by only the CDDL
025: * or only the GPL Version 2, indicate your decision by adding
026: * "[Contributor] elects to include this software in this distribution
027: * under the [CDDL or GPL Version 2] license." If you do not indicate a
028: * single choice of license, a recipient has the option to distribute
029: * your version of this file under either the CDDL, the GPL Version 2 or
030: * to extend the choice of license to its licensees as provided above.
031: * However, if you add GPL Version 2 code and therefore, elected the GPL
032: * Version 2 license, then the option applies only if the new code is
033: * made subject to such option by the copyright holder.
034: *
035: * Contributor(s):
036: *
037: * Portions Copyrighted 2007 Sun Microsystems, Inc.
038: */
039: package org.netbeans.modules.ws.qaf;
040:
041: import java.io.IOException;
042: import javax.swing.ListModel;
043: import junit.framework.Test;
044: import junit.framework.TestSuite;
045: import junit.textui.TestRunner;
046: import org.netbeans.jellytools.Bundle;
047: import org.netbeans.jellytools.EditorOperator;
048: import org.netbeans.jellytools.NbDialogOperator;
049: import org.netbeans.jellytools.OutputTabOperator;
050: import org.netbeans.jellytools.nodes.Node;
051: import org.netbeans.jemmy.operators.JButtonOperator;
052: import org.netbeans.jemmy.operators.JListOperator;
053: import org.netbeans.junit.NbTestSuite;
054: import org.netbeans.modules.ws.qaf.WebServicesTestBase.ProjectType;
055:
056: /**
057: *
058: * @author jp154641
059: */
060: public class JavaSEWsValidation extends WsValidation {
061:
062: /** Default constructor.
063: * @param testName name of particular test case
064: */
065: public JavaSEWsValidation(String name) {
066: super (name);
067: }
068:
069: @Override
070: protected ProjectType getProjectType() {
071: return ProjectType.JAVASE_APPLICATION;
072: }
073:
074: @Override
075: protected String getWsClientProjectName() {
076: return "WsClientInJavaSE"; //NOI18N
077: }
078:
079: @Override
080: protected String getWsClientPackage() {
081: return "o.n.m.ws.qaf.client.j2se"; //NOI18N
082: }
083:
084: /** Creates suite from particular test cases. You can define order of testcases here. */
085: public static TestSuite suite() {
086: TestSuite suite = new NbTestSuite();
087: suite.addTest(new JavaSEWsValidation("testCreateWsClient")); //NOI18N
088: suite.addTest(new JavaSEWsValidation(
089: "testCallWsOperationInJavaMainClass")); //NOI18N
090: suite.addTest(new JavaSEWsValidation("testFixClientLibraries")); //NOI18N
091: suite.addTest(new JavaSEWsValidation("testWsClientHandlers")); //NOI18N
092: // suite.addTest(new EjbWsValidation("testRefreshClient")); //NOI18N
093: suite.addTest(new JavaSEWsValidation("testRunWsClientProject")); //NOI18N
094: return suite;
095: }
096:
097: /* Method allowing test execution directly from the IDE. */
098: public static void main(java.lang.String[] args) {
099: TestRunner.run(suite());
100: }
101:
102: public void testCallWsOperationInJavaMainClass() {
103: final EditorOperator eo = new EditorOperator("Main.java"); //NOI18N
104: eo.select("// TODO code application logic here"); //NOI18N
105: callWsOperation(eo, "myIntMethod", 18); //NOI18N
106: assertTrue("Web service lookup class has not been found", eo
107: .contains(getWsClientLookupCall())); //NOI18N
108: assertFalse("@WebServiceRef present", eo
109: .contains("@WebServiceRef")); //NOI18N
110: }
111:
112: /**
113: * Fix for actual issue 123961, that causes JAX-WS library isn't added into project when adding
114: * JAX-WS Web Service Client
115: */
116: public void testFixClientLibraries() {
117: Node libraries = new Node(getProjectRootNode(), "Libraries"); //NOI18N
118: libraries.performPopupActionNoBlock(Bundle.getString(
119: "org.netbeans.modules.java.j2seproject.ui.Bundle",
120: "LBL_AddLibrary_Action")); //NOI18N
121: NbDialogOperator add = new NbDialogOperator("Add Library"); //NOI18N
122: JListOperator libs = new JListOperator(add, 0);
123: ListModel mLibs = libs.getModel();
124: int iCount = mLibs.getSize();
125: int libPosition = -1;
126: String item = ""; //NOI18N
127: for (int i = 0; i < iCount; i++) {
128: item = mLibs.getElementAt(i).toString();
129: if (item.contains("jaxws21")) { //NOI18N
130: libPosition = i;
131: }
132: }
133: if (libPosition > -1) {
134: libs.selectItem(libPosition);
135: new JButtonOperator(add, "Add Library").push(); //NOI18N
136: } else {
137: fail("######## JAX-WS 2.1 library not found in the list #######"); //NOI18N
138:
139: }
140: }
141:
142: /**
143: * Since there's not Deploy action for Java Projects, it's Run insteda and output checked
144: * @throws java.io.IOException
145: */
146: public void testRunWsClientProject() throws IOException {
147: runProject(getProjectName());
148: OutputTabOperator oto = new OutputTabOperator(getProjectName());
149: assertTrue(oto.getText().indexOf("Result = []") > -1); //NOI18N
150: assertTrue(oto.getText().indexOf("BUILD SUCCESSFUL") > -1); //NOI18N
151: }
152: }
|