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.
6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7 * or http://www.netbeans.org/cddl.txt.
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]"
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.
20 package org.netbeans.test.xslt;
22 import java.awt.Point;
23 import java.awt.Rectangle;
24 import java.awt.event.InputEvent;
25 import javax.swing.JTable;
26 import javax.swing.tree.TreePath;
27 import org.netbeans.jellytools.EditorOperator;
28 import org.netbeans.jellytools.JellyTestCase;
29 import org.netbeans.jellytools.MainWindowOperator;
30 import org.netbeans.jellytools.NewFileNameLocationStepOperator;
31 import org.netbeans.jellytools.NewFileWizardOperator;
32 import org.netbeans.jellytools.NewProjectNameLocationStepOperator;
33 import org.netbeans.jellytools.NewProjectWizardOperator;
34 import org.netbeans.jellytools.actions.SaveAllAction;
35 import org.netbeans.jemmy.Timeout;
36 import org.netbeans.jemmy.drivers.input.MouseEventDriver;
37 import org.netbeans.jemmy.operators.JButtonOperator;
38 import org.netbeans.jemmy.operators.JComboBoxOperator;
39 import org.netbeans.jemmy.operators.JComponentOperator;
40 import org.netbeans.jemmy.operators.JDialogOperator;
41 import org.netbeans.jemmy.operators.JLabelOperator;
42 import org.netbeans.jemmy.operators.JRadioButtonOperator;
43 import org.netbeans.jemmy.operators.JTableOperator;
44 import org.netbeans.jemmy.operators.JTextFieldOperator;
45 import org.netbeans.jemmy.operators.JTreeOperator;
46 import org.netbeans.test.xslt.lib.Helpers;
47 import org.netbeans.test.xslt.lib.PaletteOperator;
48 import org.netbeans.test.xslt.lib.XSLTEditorOperator;
49 import org.netbeans.junit.NbTestCase;
50 import org.netbeans.junit.NbModuleSuite;
54 * @author ca@netbeans.org
57 public class AcceptanceTestCase extends JellyTestCase {
59 static final String [] m_aTestMethods = {
60 "createNewXSLTModule",
68 static final String SCHEMA_NAME = "schema";
69 static final String SCHEMA_EXTENSION = ".xsd";
70 static final String strWSDLFileName = "testWSDL";
72 static final String FILE_NAME = "testXSLFile.xsl";
74 static final String TEST_PROJECT_NAME = "AcceptanceTestProject";
76 static final String CONCAT_TITLE = "Concat";
78 public AcceptanceTestCase(String arg0) {
82 public static junit.framework.Test suite() {
83 return NbModuleSuite.create(
84 NbModuleSuite.createConfiguration(AcceptanceTestCase.class)
85 .addTest(m_aTestMethods)
92 public void createNewXSLTModule() {
95 String strDirectory = System.getProperties().getProperty("nbjunit.workdir");
97 MainWindowOperator.getDefault().maximize();
99 NewProjectWizardOperator opWizard = NewProjectWizardOperator.invoke();
100 opWizard.selectCategory("SOA");
101 opWizard.selectProject("XSLT Module");
104 NewProjectNameLocationStepOperator opLocationStep = new NewProjectNameLocationStepOperator();
105 opLocationStep.txtProjectName().setText(TEST_PROJECT_NAME);
106 opLocationStep.txtProjectLocation().setText(strDirectory);
112 public void createSchemas() {
115 for (int i = 0; i < 2; i++) {
116 createSchema(SCHEMA_NAME + i, i);
122 private void createSchema(String strName, int index) {
123 final String strSampleSchemas = "XML";
124 final String strFileType = "Purchase Order Sample Schema";
125 final String strSrc = "src";
127 final int FOLDER_FIELD_INDEX = 2;
129 final String strNameSpace = "http://xml.netbeans.org/schema/test";
131 NewFileWizardOperator opNewFileWizard = NewFileWizardOperator.invoke();
132 opNewFileWizard.selectCategory(strSampleSchemas);
133 opNewFileWizard.selectFileType(strFileType);
134 opNewFileWizard.next();
136 NewFileNameLocationStepOperator opNewFileNameLocationStep = new NewFileNameLocationStepOperator();
137 opNewFileNameLocationStep.setObjectName(strName);
138 new JTextFieldOperator(opNewFileNameLocationStep, FOLDER_FIELD_INDEX).setText(strSrc);
139 opNewFileWizard.finish();
142 public void createWSDL() {
145 final String JTABLE_CLASS = "javax.swing.JTable";
147 final String strWSDLDocument = "XML";
148 final String strFileType = "WSDL Document";
150 final int FOLDER_FIELD_INDEX = 2;
152 NewFileWizardOperator opNewFileWizard = NewFileWizardOperator.invoke();
153 opNewFileWizard.selectCategory(strWSDLDocument);
154 opNewFileWizard.selectFileType(strFileType);
155 opNewFileWizard.next();
157 final String strSrc = "src";
159 NewFileNameLocationStepOperator opNewFileNameLocationStep = new NewFileNameLocationStepOperator();
160 opNewFileNameLocationStep.setObjectName(strWSDLFileName);
161 new JTextFieldOperator(opNewFileNameLocationStep, FOLDER_FIELD_INDEX).setText(strSrc);
162 opNewFileWizard.next();
164 JDialogOperator opAbstractConfigStep = new JDialogOperator("New WSDL Document");
166 JComponentOperator opComponent = Helpers.getComponentOperator(opAbstractConfigStep, JTABLE_CLASS, 2);
167 JTable table = (JTable) opComponent.getSource();
168 JTableOperator opInputTable = new JTableOperator(table);
170 opComponent = Helpers.getComponentOperator(opAbstractConfigStep, JTABLE_CLASS, 1);
171 table = (JTable) opComponent.getSource();
172 JTableOperator opOutputTable = new JTableOperator(table);
174 Rectangle r = opInputTable.getCellRect(0, 1, false);
175 new MouseEventDriver().clickMouse(opInputTable, r.x + r.width - 5, r.y + r.height - 5, 1, InputEvent.BUTTON1_MASK, 0, new Timeout("timeout", 500));
177 JDialogOperator opSelectElementOrType = new JDialogOperator("Select Element Or Type");
179 JTreeOperator opTree = new JTreeOperator(opSelectElementOrType);
180 TreePath treePath = opTree.findPath("By File|" + TEST_PROJECT_NAME + "|src/schema0.xsd|Elements|purchaseOrder");
181 opTree.selectPath(treePath);
182 new JButtonOperator(opSelectElementOrType, "OK").pushNoBlock();
183 opSelectElementOrType.waitClosed();
185 r = opOutputTable.getCellRect(0, 1, false);
186 new MouseEventDriver().clickMouse(opOutputTable, r.x + r.width - 5, r.y + r.height - 5, 1, InputEvent.BUTTON1_MASK, 0, new Timeout("timeout", 500));
188 opSelectElementOrType = new JDialogOperator("Select Element Or Type");
189 opTree = new JTreeOperator(opSelectElementOrType);
190 treePath = opTree.findPath("By File|" + TEST_PROJECT_NAME + "|src/schema1.xsd|Elements|purchaseOrder");
191 opTree.selectPath(treePath);
192 new JButtonOperator(opSelectElementOrType, "OK").pushNoBlock();
193 opSelectElementOrType.waitClosed();
195 opNewFileWizard.next();
197 JDialogOperator opConcreteConfigStep = new JDialogOperator("New WSDL Document");
199 JComboBoxOperator opCombo = new JComboBoxOperator(opConcreteConfigStep);
200 opCombo.selectItem("SOAP");
202 JRadioButtonOperator opRadio = new JRadioButtonOperator(opConcreteConfigStep, "Document Literal");
203 opRadio.pushNoBlock();
205 opNewFileWizard.finish();
210 public void createXSLT() {
213 // final String strSOADocument = "Service Oriented Architecture";
214 final String strSOADocument = "SOA";
215 final String strFileType = "XSLT Service";
216 final String strXSLFile = "XSL File:";
218 NewFileWizardOperator opNewFileWizard = NewFileWizardOperator.invoke();
219 opNewFileWizard.selectCategory(strSOADocument);
220 opNewFileWizard.selectFileType(strFileType);
221 opNewFileWizard.next();
223 new JRadioButtonOperator(opNewFileWizard, "Request-Reply Service").pushNoBlock();
225 opNewFileWizard.next();
227 opNewFileWizard.next();
229 JLabelOperator opLabel = new JLabelOperator(opNewFileWizard, strXSLFile);
230 Helpers.getTextFieldOpByLabel(opLabel).setText(FILE_NAME);
232 opNewFileWizard.finish();
237 public void editXSLT() {
240 XSLTEditorOperator opEditor = new XSLTEditorOperator(FILE_NAME);
242 opEditor.dropPaletteItemOnCanvas(PaletteOperator.Groups.STRING, "concat", new Point(50, 50));
244 opEditor.bindSourceToMethoid("billTo|street", CONCAT_TITLE, 0, 0);
245 opEditor.bindSourceToMethoid("billTo|city", CONCAT_TITLE, 0, 1);
246 opEditor.bindMethoidToTarget(CONCAT_TITLE, 0, "purchaseOrder|billTo|name");
248 opEditor.bindSourceToTarget("shipTo|name", "purchaseOrder|shipTo|name");
249 opEditor.bindSourceToTarget("shipTo|city", "purchaseOrder|shipTo|city");
250 opEditor.bindSourceToTarget("shipTo|street", "purchaseOrder|shipTo|street");
255 public void checkSource() {
256 final long goldenCheckSum = 181301011L; // 708657604L
260 XSLTEditorOperator opEditor = new XSLTEditorOperator(FILE_NAME);
262 opEditor.switchToSource();
264 EditorOperator opNBEditor = new EditorOperator(FILE_NAME);
265 String strText = opNBEditor.getText();
266 Helpers.writeJemmyLog("{" + strText + "}");
268 opEditor.switchToDesign();
270 if (!Helpers.isCRC32Equal(strText, goldenCheckSum)) {
271 fail("The source check sum doesn't match the golden value");
278 public void tearDown() {
279 new SaveAllAction().performAPI();