KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > xml > schema > core > sequential > PropertyVerifier


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.test.xml.schema.core.sequential;
21
22 import java.awt.Point JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.LinkedList JavaDoc;
25 import javax.swing.ListModel JavaDoc;
26 import org.netbeans.jellytools.EditorOperator;
27 import org.netbeans.jellytools.ProjectsTabOperator;
28 import org.netbeans.jellytools.actions.OpenAction;
29 import org.netbeans.jellytools.actions.PropertiesAction;
30 import org.netbeans.jellytools.nodes.ProjectRootNode;
31 import org.netbeans.jellytools.properties.Property;
32 import org.netbeans.jellytools.properties.PropertySheetOperator;
33 import org.netbeans.jemmy.operators.JButtonOperator;
34 import org.netbeans.jemmy.operators.JCheckBoxOperator;
35 import org.netbeans.jemmy.operators.JDialogOperator;
36 import org.netbeans.jemmy.operators.JListOperator;
37 import org.netbeans.jemmy.operators.JPopupMenuOperator;
38 import org.netbeans.jemmy.operators.JRadioButtonOperator;
39 import org.netbeans.jemmy.operators.Operator.StringComparator;
40 import org.w3c.dom.Node JavaDoc;
41 import org.netbeans.test.xml.schema.core.lib.sequential.SequentialTest;
42 import org.netbeans.test.xml.schema.core.lib.sequential.TestSequence;
43 import org.netbeans.test.xml.schema.core.lib.dom.parser.NodeIterator;
44 import org.netbeans.test.xml.schema.core.lib.dom.parser.SchemaDOMBuilder;
45 import org.netbeans.test.xml.schema.core.lib.dom.parser.ExtraNodeInfo;
46 import org.netbeans.test.xml.schema.core.lib.types.ComponentCategories;
47 import org.netbeans.test.xml.schema.core.lib.util.Helpers;
48 import org.netbeans.test.xml.schema.core.lib.SchemaMultiView;
49
50
51 /**
52  *
53  * @author ca@netbeans.org
54  */

55 public abstract class PropertyVerifier extends TestSequence {
56     
57     static final String JavaDoc PROJECT_NAME = "XSDTestProject";
58     
59     static final int NO_EVENT_TIMEOUT = 500;
60     
61     private SchemaDOMBuilder m_builder = new SchemaDOMBuilder();
62     
63     private SchemaMultiView m_opMultiView = null;
64     private Node m_domNode;
65     
66     private ColumnViewNode m_node = new ColumnViewNode(0, 0);
67     
68     private PropertySheetOperator m_opPropertySheet;
69     
70     protected abstract String JavaDoc getSchemaName();
71     
72     protected abstract int getFirstLine();
73     
74     private ExtraNodeInfo getExtraNodeInfo() {
75         return ExtraNodeInfo.getExtraNodeInfo(m_domNode);
76     }
77     
78     public void setupOnce() {
79         
80 // MainWindowOperator.getDefault().maximize();
81

82         System.setProperty("jelly.wait.no.event", "false");
83         
84         String JavaDoc strProjectsFolder = System.getProperty("xtest.data") + "/projects/" + PROJECT_NAME + "/src/qa/xmltools/samples";
85 //---
86
m_builder.setFileName(strProjectsFolder + "/" + getSchemaName() + ".xsd");
87         
88         m_builder.setInitialLineNumber(getFirstLine());
89         
90         m_builder.build();
91         
92 //---
93
Helpers.closeTopComponentIfOpened("Navigator");
94         
95         new PropertiesAction().performMenu();
96         m_opPropertySheet = new PropertySheetOperator();
97         
98         openSchema();
99         
100         m_opMultiView = new SchemaMultiView(getSchemaName());
101         
102         m_opMultiView.switchToSchema();
103         
104         m_opMultiView.switchToSchemaColumns();
105         
106         m_testList = new LinkedList JavaDoc<SequentialTest>();
107        m_testList.add(new AttributesCategory());
108         m_testList.add(new AttributeGroupsCategory());
109
110         m_testList.add(new ComplexTypesCategory());
111         m_testList.add(new ElementsCategory());
112         
113         m_testList.add(new GroupsCategory());
114         m_testList.add(new SimpleTypesCategory());
115     }
116     
117     public void finalCleanup() {
118         if (m_opMultiView != null) {
119             m_opMultiView.close();
120         }
121     }
122     
123     private void waitNoEvent() {
124         Helpers.waitNoEvent(NO_EVENT_TIMEOUT);
125     }
126     
127     public class ColumnViewTestSequence extends TestSequence {
128         private ComponentCategories m_category;
129         private JListOperator m_opList = null;
130         
131         protected ArrayList JavaDoc<ColumnViewNode> m_trace = new ArrayList JavaDoc<ColumnViewNode>();
132         
133         NodeIterator m_nodeIterator;
134         
135         public ColumnViewTestSequence(ComponentCategories category) {
136             m_category = category;
137         }
138         
139         private String JavaDoc getFullTestName(String JavaDoc strMethodName) {
140             ExtraNodeInfo nodeInfo = getExtraNodeInfo();
141             String JavaDoc str = strMethodName + "-component[" + nodeInfo.getColumnViewName() + "]";
142             return Helpers.getFullTestName(str);
143         }
144         
145         public void setupOnce() {
146             m_testList = new LinkedList JavaDoc<SequentialTest>();
147             m_testList.add(new ColumnViewNavigator());
148             m_testList.add(new PropertiesTestSequence());
149             
150             m_node.m_col = 0;
151             m_node.m_row = m_category.getValue();
152             m_opList = m_opMultiView.getColumnListOperator(m_node.m_col);
153             m_opList.selectItem(m_node.m_row);
154             waitNoEvent();
155             
156             m_nodeIterator = m_builder.getNodeIterator(m_category);
157         }
158         
159         public void setup() {
160             boolean bRows = false;
161             int col = m_node.m_col + 1;
162             
163             clearTestStatus();
164             
165             m_opList = m_opMultiView.getColumnListOperator(col);
166             if (m_opList == null) {
167                 bRows = true;
168             } else {
169                 ListModel JavaDoc model = m_opList.getModel();
170                 int row = -1;
171                 int modelSize = model.getSize();
172                 while(true) {
173                     if (++row >= modelSize) {
174                         bRows = true;
175                         break;
176                     }
177                     
178                     String JavaDoc strValue = model.getElementAt(row).toString();
179                     if (col > 1 && strValue.indexOf("[Global") >= 0) {
180                         continue;
181                     }
182                     
183                     m_trace.add(new ColumnViewNode(m_node));
184                     m_node.m_col = col;
185                     m_node.m_row = row;
186                     preExecute();
187                     break;
188                 }
189             }
190             
191             if (bRows) {
192                 while (true) {
193                     m_opList = m_opMultiView.getColumnListOperator(m_node.m_col);
194                     if ((m_node.m_row + 1) < m_opList.getModel().getSize()) {
195                         m_node.m_row++;
196                         preExecute();
197                         break;
198                     } else {
199                         int index = m_trace.size() - 1;
200                         if (index >= 0) {
201                             m_node = m_trace.remove(index);
202                             if (m_node.m_col == 0) {
203                                 setCompleted();
204                                 break;
205                             }
206                         }
207                     }
208                 }
209             }
210         }
211         
212         private void preExecute() {
213             m_domNode = m_nodeIterator.next();
214         }
215         
216         public void cleanup() {
217             // Overrrides besic implementation to execute ColumnViewTestSequence in a cycle
218
}
219         
220         public class ColumnViewNavigator extends SequentialTest {
221             
222             public void setupOnce() {
223                 clearCompleted();
224             }
225             
226             public void execute() {
227                 startTest();
228                 
229                 m_opList.selectItem(m_node.m_row);
230                 Helpers.waitNoEvent();
231                 
232                 String JavaDoc strItem = m_opList.getSelectedValue().toString();
233                 strItem = strItem.substring(0, strItem.lastIndexOf("[")-1);
234                 
235                 ExtraNodeInfo sn = getExtraNodeInfo();
236                 
237                 if (!strItem.equals(sn.getColumnViewName())) {
238                     fail("DOM name [" + sn.getColumnViewName() + "] isn't equal to [" + strItem + "] one displayed in column view.");
239                 }
240                 endTest();
241             }
242             
243             protected String JavaDoc getTestName() {
244                 return getFullTestName("ColumnViewNavigator");
245             }
246         }
247         
248         public class PropertiesTestSequence extends TestSequence {
249             private PropertySheetOperator m_pso;
250             
251             public void setupOnce() {
252                 clearCompleted();
253                 
254                 ExtraNodeInfo sn = getExtraNodeInfo();
255                 
256                 String JavaDoc name = sn.getComponentName(); //XMLElement.getUnqualifiledName(m_element.getName());
257
String JavaDoc refName = sn.getNamedAttrValue("ref"); //m_element.getAttributeValue("ref");
258
String JavaDoc strParent = sn.isGlobal() ? "" : sn.getParentColumnViewName(); // m_element.isGlobal() ? "" : m_element.getParentNameUnqualified();
259

260                 m_pso = new PropertySheetOperator();
261                 
262                 m_pso.setComparator(new StringComparator() {
263                     public boolean equals(String JavaDoc caption, String JavaDoc match) {
264                         return caption.equals(match);
265                     }
266                 });
267                 
268                 m_testList = new LinkedList JavaDoc<SequentialTest>();
269                 
270                 if (!name.equals("documentation")) {
271                     m_testList.add(new PropIDVerifier("ID" + sn.getLineNumber()));
272                     m_testList.add(new ChangesInSourceVerifier("id", "ID" + sn.getLineNumber()));
273                 }
274                 
275                 if (name.equals("schema")) {
276                     m_testList.add(new PropAttrFormDefaultVerifier());
277                     m_testList.add(new PropElemFormDefaultVerifier());
278                     
279                 } else if (name.equals("element") && refName == null) {
280                     m_testList.add(new PropNameVerifier());
281                     m_testList.add(new PropNillableVerifier());
282                     m_testList.add(new PropFixedValueVerifier());
283                     m_testList.add(new PropDefaultValueVerifier());
284                     
285                     m_testList.add(new ElementPropBlockVerifier());
286                     
287                     if (sn.isGlobal()) {
288                         m_testList.add(new PropFinalVerifier());
289                     } else {
290                         m_testList.add(new PropFormVerifier());
291                         
292                         if (strParent.equals("all")) {
293                             m_testList.add(new PropMinOccursAllVerifier());
294                         } else {
295                             m_testList.add(new PropMinOccursVerifier());
296                             m_testList.add(new PropMaxOccursVerifier());
297                         }
298                     }
299                 } else if (name.equals("complexType")) {
300                     m_testList.add(new PropMixedContentVerifier());
301                     if (sn.isGlobal()) {
302                         m_testList.add(new PropNameVerifier());
303                         m_testList.add(new PropAbstractVerifier());
304                         m_testList.add(new PropBlockVerifier());
305                         m_testList.add(new PropFinalVerifier());
306                     }
307                 } else if (name.equals("attribute")) {
308                     if (refName == null) {
309                         m_testList.add(new PropNameVerifier());
310                     }
311                     m_testList.add(new PropFixedValueVerifier());
312                     m_testList.add(new PropDefaultValueVerifier());
313                 }
314             }
315             
316             public void cleanup() {
317                 m_opMultiView.switchToSchema();
318                 setCompleted();
319             }
320             
321             public class ChangesInSourceVerifier extends SequentialTest {
322                 private String JavaDoc m_strSrcChanges;
323                 private boolean m_verifyAbsence = false;
324                 
325                 public ChangesInSourceVerifier(String JavaDoc strAttrName, String JavaDoc strAttrValue) {
326                     m_strSrcChanges = strAttrName + "=\"" + strAttrValue + "\"";
327                 }
328                 
329                 public ChangesInSourceVerifier(String JavaDoc strAbsentString) {
330                     m_verifyAbsence = true;
331                     m_strSrcChanges = strAbsentString;
332                 }
333                 
334                 public void execute() {
335                     startTest();
336                     
337                     int index = m_opList.getSelectedIndex();
338                     Point JavaDoc p = m_opList.getClickPoint(index);
339                     m_opList.clickForPopup(p.x, p.y);
340                     new JPopupMenuOperator().pushMenu("Go To|Source");
341                     waitNoEvent();
342                     
343                     EditorOperator opEditor = new EditorOperator(getSchemaName());
344                     
345                     int line = opEditor.getLineNumber();
346                     ExtraNodeInfo nodeInfo = getExtraNodeInfo();
347                     int expectedLineNumber = nodeInfo.getLineNmb();
348                     
349                     if (expectedLineNumber != line) {
350                         fail("\"Go To Source\" jumped on the wrong line number " + line + " instead of " + expectedLineNumber);
351                     }
352                     
353                     String JavaDoc strLine = opEditor.getText(line);
354                     
355                     String JavaDoc strPattern = "";
356                     if (m_verifyAbsence) {
357                         strPattern = ".* (" + m_strSrcChanges + "){0}.*\\s*";
358                     } else {
359                         strPattern = ".* (" + m_strSrcChanges + "){1}.*\\s*";
360                     }
361                     
362                     if (!strLine.matches(strPattern)) {
363                         fail("Invalid or missing attribute " + m_strSrcChanges + " in line " + strLine);
364                     }
365                     
366                     endTest();
367                 }
368                 
369                 public String JavaDoc getTestName() {
370                     return getFullTestName("ChangesInSourceVerifier-[" + m_strSrcChanges + (m_verifyAbsence ? "]-(absence)" : "]"));
371                 }
372                 
373                 public void cleanup() {
374                     m_opMultiView.switchToSchema();
375                     waitNoEvent();
376                     
377                     setCompleted();
378                 }
379             }
380             
381             public class SingleValueSetter extends SequentialTest {
382                 private String JavaDoc m_strProperty;
383                 private String JavaDoc m_strValue;
384                 
385                 public SingleValueSetter(String JavaDoc strProperty, String JavaDoc strValue) {
386                     m_strProperty = strProperty;
387                     m_strValue = strValue;
388                 }
389                 
390                 public void execute() {
391                     startTest();
392                     
393                     Property p = new Property(m_pso, m_strProperty);
394                     p.setValue(m_strValue);
395                     waitNoEvent();
396                     
397                     endTest();
398                 }
399                 
400                 public String JavaDoc getTestName() {
401                     return getFullTestName("SingleValueSetter-[" + m_strProperty + "=\"" + m_strValue +"\"]");
402                 }
403                
404             }
405             
406             public class DefaultValueSetter extends SequentialTest {
407                 private String JavaDoc m_strProperty;
408                 
409                 public DefaultValueSetter(String JavaDoc strProperty) {
410                     m_strProperty = strProperty;
411                 }
412                 
413                 public void execute() {
414                     startTest();
415                     
416                     Property p = new Property(m_pso, m_strProperty);
417                     p.setDefaultValue();
418                     waitNoEvent();
419                     
420                     endTest();
421                 }
422                 
423                 public String JavaDoc getTestName() {
424                     return getFullTestName("DefaultValueSetter-[" + m_strProperty+"]");
425                 }
426             }
427             
428             public class PropIDVerifier extends SequentialTest {
429                 private String JavaDoc m_ID;
430                 
431                 public PropIDVerifier(String JavaDoc ID) {
432                     m_ID = ID;
433                 }
434                 
435                 public void execute() {
436                     clearTestStatus();
437                     startTest();
438                     
439                     Property p = new Property(m_pso, "ID");
440                     p.setValue(m_ID);
441                     waitNoEvent();
442                     
443                     endTest();
444                 }
445                 
446                 public String JavaDoc getTestName() {
447                     return getFullTestName("PropIDVerifier");
448                 }
449             }
450             
451             public class PropAttrFormDefaultVerifier extends TestSequence {
452                 String JavaDoc ATTRIBUTE_FORM_DEFAULT = "Attribute Form Default";
453                 String JavaDoc ATTR_ATTRIBUTE_FORM_DEFAULT = "attributeFormDefault";
454                 
455                 public void setupOnce() {
456                     m_testList = new LinkedList JavaDoc<SequentialTest>();
457                     
458                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ATTRIBUTE_FORM_DEFAULT, "Unqualified (not set)"));
459                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ATTRIBUTE_FORM_DEFAULT));
460                     
461                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ATTRIBUTE_FORM_DEFAULT, "Qualified"));
462                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ATTRIBUTE_FORM_DEFAULT, "qualified"));
463                     
464                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ATTRIBUTE_FORM_DEFAULT, "Unqualified"));
465                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ATTRIBUTE_FORM_DEFAULT, "unqualified"));
466                 }
467             }
468             
469             public class PropElemFormDefaultVerifier extends TestSequence {
470                 String JavaDoc ELEMENT_FORM_DEFAULT = "Element Form Default";
471                 String JavaDoc ATTR_ELEMENT_FORM_DEFAULT = "elementFormDefault";
472                 
473                 public void setupOnce() {
474                     m_testList = new LinkedList JavaDoc<SequentialTest>();
475                     
476                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ELEMENT_FORM_DEFAULT, "Unqualified (not set)"));
477                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ELEMENT_FORM_DEFAULT));
478                     
479                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ELEMENT_FORM_DEFAULT, "Qualified"));
480                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ELEMENT_FORM_DEFAULT, "qualified"));
481                     
482                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ELEMENT_FORM_DEFAULT, "Unqualified"));
483                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ELEMENT_FORM_DEFAULT, "unqualified"));
484                 }
485             }
486             
487             public class PropNameVerifier extends TestSequence {
488                 private String JavaDoc m_strLastName = null;
489                 
490                 public void setupOnce() {
491                     final String JavaDoc newName = "abcde";
492                     
493                     Property p = new Property(m_pso, "Name");
494                     m_strLastName = p.getValue();
495                     
496                     m_testList = new LinkedList JavaDoc<SequentialTest>();
497                     
498                     m_testList.add(new PropNameGetter());
499                     
500                     m_testList.add(new PropertiesTestSequence.SingleValueSetter("Name", newName));
501                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier("name", newName));
502                     
503                     m_testList.add(new PropertiesTestSequence.SingleValueSetter("Name", m_strLastName));
504                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier("name", m_strLastName));
505                 }
506                 
507                 public class PropNameGetter extends SequentialTest {
508                     public void execute() {
509                         startTest();
510                         
511                         if (m_strLastName == null) {
512                             fail("Name property is not found in property sheet");
513                         }
514                         
515                         endTest();
516                     }
517                     
518                     public String JavaDoc getTestName() {
519                         return getFullTestName("PropNameGetter");
520                     }
521                 }
522             }
523             
524             public class PropNillableVerifier extends TestSequence {
525                 String JavaDoc NILLABLE = "Nillable";
526                 String JavaDoc ATTR_NILLABLE = "nillable";
527                 
528                 public void setupOnce() {
529                     m_testList = new LinkedList JavaDoc<SequentialTest>();
530                     
531                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(NILLABLE, "True"));
532                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_NILLABLE, "true"));
533                     
534                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(NILLABLE, "False"));
535                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_NILLABLE, "false"));
536                     
537                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(NILLABLE, "False (Not set)"));
538                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_NILLABLE));
539                 }
540             }
541             
542             public class PropFixedValueVerifier extends TestSequence {
543                 private String JavaDoc FIXED_VALUE = "Fixed Value";
544                 private String JavaDoc ATTR_FIXED = "fixed";
545                 private String JavaDoc VALUE = "FV";
546                 
547                 public void setupOnce() {
548                     m_testList = new LinkedList JavaDoc<SequentialTest>();
549                     
550                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(FIXED_VALUE, VALUE));
551                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FIXED, VALUE));
552                     
553                     m_testList.add(new PropertiesTestSequence.DefaultValueSetter(FIXED_VALUE));
554                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FIXED));
555                 }
556             }
557             
558             public class PropDefaultValueVerifier extends TestSequence {
559                 private String JavaDoc DEFAULT_VALUE = "Default Value";
560                 private String JavaDoc ATTR_DEFAULT = "default";
561                 private String JavaDoc VALUE = "DV";
562                 
563                 public void setupOnce() {
564                     m_testList = new LinkedList JavaDoc<SequentialTest>();
565                     
566                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(DEFAULT_VALUE, VALUE));
567                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_DEFAULT, VALUE));
568                     
569                     m_testList.add(new PropertiesTestSequence.DefaultValueSetter(DEFAULT_VALUE));
570                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_DEFAULT));
571                 }
572             }
573             
574             public class PropMixedContentVerifier extends TestSequence {
575                 String JavaDoc MIXED_CONTENT = "Mixed Content";
576                 String JavaDoc ATTR_MIXED = "mixed";
577                 
578                 public void setupOnce() {
579                     m_testList = new LinkedList JavaDoc<SequentialTest>();
580                     
581                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MIXED_CONTENT, "True"));
582                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIXED, "true"));
583                     
584                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MIXED_CONTENT, "False"));
585                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIXED, "false"));
586                     
587                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MIXED_CONTENT, "False (not set)"));
588                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIXED));
589                 }
590             }
591             
592             public class PropMinOccursVerifier extends TestSequence {
593                 String JavaDoc MIN_OCCURS = "Min Occurs";
594                 String JavaDoc ATTR_MIN_OCCURS = "minOccurs";
595                 
596                 public void setupOnce() {
597                     m_testList = new LinkedList JavaDoc<SequentialTest>();
598                     
599                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MIN_OCCURS, "0"));
600                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIN_OCCURS, "0"));
601                     
602                     m_testList.add(new PropertiesTestSequence.DefaultValueSetter(MIN_OCCURS));
603                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIN_OCCURS));
604                 }
605             }
606             
607             public class PropMaxOccursVerifier extends TestSequence {
608                 String JavaDoc MAX_OCCURS = "Max Occurs";
609                 String JavaDoc ATTR_MAX_OCCURS = "maxOccurs";
610                 
611                 public void setupOnce() {
612                     m_testList = new LinkedList JavaDoc<SequentialTest>();
613                     
614                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MAX_OCCURS, "10"));
615                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MAX_OCCURS, "10"));
616                     
617                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MAX_OCCURS, "unbounded"));
618                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MAX_OCCURS, "unbounded"));
619                     
620                     m_testList.add(new PropertiesTestSequence.DefaultValueSetter(MAX_OCCURS));
621                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MAX_OCCURS));
622                 }
623             }
624             
625             public class PropMinOccursAllVerifier extends TestSequence {
626                 String JavaDoc MIN_OCCURS = "Min Occurs";
627                 String JavaDoc ATTR_MIN_OCCURS = "minOccurs";
628                 
629                 public void setupOnce() {
630                     m_testList = new LinkedList JavaDoc<SequentialTest>();
631                     
632                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MIN_OCCURS, "0"));
633                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIN_OCCURS, "0"));
634                     
635                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MIN_OCCURS, "1"));
636                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIN_OCCURS, "1"));
637                     
638                     m_testList.add(new PropertiesTestSequence.DefaultValueSetter(MIN_OCCURS));
639                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MIN_OCCURS));
640                 }
641             }
642             
643             public class PropMaxOccursAllVerifier extends TestSequence {
644                 String JavaDoc MAX_OCCURS = "Max Occurs";
645                 String JavaDoc ATTR_MAX_OCCURS = "maxOccurs";
646                 
647                 public void setupOnce() {
648                     m_testList = new LinkedList JavaDoc<SequentialTest>();
649                     
650                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MAX_OCCURS, "0"));
651                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MAX_OCCURS, "0"));
652                     
653                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(MAX_OCCURS, "1"));
654                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MAX_OCCURS, "1"));
655                     
656                     m_testList.add(new PropertiesTestSequence.DefaultValueSetter(MAX_OCCURS));
657                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_MAX_OCCURS));
658                 }
659             }
660             
661             public class PropAbstractVerifier extends TestSequence {
662                 private String JavaDoc ABSTRACT = "Abstract";
663                 private String JavaDoc ATTR_ABSTRACT = "abstract";
664                 
665                 public void setupOnce() {
666                     m_testList = new LinkedList JavaDoc<SequentialTest>();
667                     
668                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ABSTRACT, "True"));
669                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ABSTRACT, "true"));
670                     
671                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ABSTRACT, "False"));
672                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ABSTRACT, "false"));
673                     
674                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(ABSTRACT, "False (not set)"));
675                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_ABSTRACT));
676                 }
677             }
678             
679             public class PropFormVerifier extends TestSequence {
680                 private String JavaDoc FORM = "Form";
681                 private String JavaDoc ATTR_FORM = "form";
682                 
683                 public void setupOnce() {
684                     m_testList = new LinkedList JavaDoc<SequentialTest>();
685                     
686                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(FORM, "Qualified"));
687                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FORM, "qualified"));
688                     
689                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(FORM, "Unqualified"));
690                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FORM, "unqualified"));
691                     
692                     m_testList.add(new PropertiesTestSequence.SingleValueSetter(FORM, "Default for schema (not set)"));
693                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FORM));
694                 }
695             }
696             
697             public class DialogValueSetter extends SequentialTest {
698                 private String JavaDoc m_strProperty;
699                 private String JavaDoc m_strRadio;
700                 private String JavaDoc m_strCheck;
701                 
702                 private String JavaDoc m_strAttr;
703                 private String JavaDoc m_strValue;
704                 
705                 
706                 private String JavaDoc USE_SCHEMA_DEFAULT = "Use schema default";
707                 
708                 public DialogValueSetter(String JavaDoc strAttr, String JavaDoc strValue, String JavaDoc strProperty, String JavaDoc strRadio, String JavaDoc strCheck) {
709                     m_strProperty = strProperty;
710                     m_strRadio = strRadio;
711                     m_strCheck = strCheck;
712                     
713                     m_strAttr = strAttr;
714                     m_strValue = strValue;
715                     
716                 }
717                 
718                 public void execute() {
719                     startTest();
720                     
721                     Property p = new Property(m_pso, m_strProperty);
722                     p.openEditor();
723                     
724                     JDialogOperator opEditor = new JDialogOperator();
725                     waitNoEvent();
726                     
727                     new JRadioButtonOperator(opEditor, USE_SCHEMA_DEFAULT).push();
728                     
729                     new JRadioButtonOperator(opEditor, m_strRadio).push();
730                     
731                     if (m_strCheck != null) {
732                         new JCheckBoxOperator(opEditor, m_strCheck).push();
733                     }
734                     
735                     new JButtonOperator(opEditor, "OK").push();
736                     opEditor.waitClosed();
737                     
738                     endTest();
739                 }
740                 
741                 public String JavaDoc getTestName() {
742                     String JavaDoc strName = "DialogValueSetter-[" + m_strAttr + "=\"" + m_strValue + "\"]";
743                     return getFullTestName(strName);
744                 }
745             }
746             
747             public class PropBlockVerifier extends TestSequence {
748                 protected String JavaDoc ATTRIBUTE_PROHIBITED_SUBSTITUTIONS = "Prohibited Substitutions (Block) ";
749                 protected String JavaDoc ATTR_BLOCK = "block";
750                 protected String JavaDoc strCheckBoxGroup = "Block substitutions of the following kinds:";
751                 
752                 public void setupOnce() {
753                     m_testList = new LinkedList JavaDoc<SequentialTest>();
754                     
755                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_BLOCK, "", ATTRIBUTE_PROHIBITED_SUBSTITUTIONS, "Allow all substitutions (empty value)", null));
756                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_BLOCK, ""));
757                     
758                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_BLOCK, "#all", ATTRIBUTE_PROHIBITED_SUBSTITUTIONS, "Block all substitutions (#all)", null));
759                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_BLOCK, "#all"));
760                     
761                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_BLOCK, "extension", ATTRIBUTE_PROHIBITED_SUBSTITUTIONS, strCheckBoxGroup, "Extension"));
762                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_BLOCK, "extension"));
763                     
764                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_BLOCK, "restriction", ATTRIBUTE_PROHIBITED_SUBSTITUTIONS, strCheckBoxGroup, "Restriction"));
765                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_BLOCK, "restriction"));
766                     
767                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_BLOCK, "", ATTRIBUTE_PROHIBITED_SUBSTITUTIONS, "Use schema default", null));
768                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_BLOCK));
769                 }
770             }
771             
772             public class ElementPropBlockVerifier extends PropBlockVerifier {
773                 
774                 public void setupOnce() {
775                     super.setupOnce();
776                     
777                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_BLOCK, "substitution", ATTRIBUTE_PROHIBITED_SUBSTITUTIONS, strCheckBoxGroup, "Substitution"));
778                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_BLOCK, "substitution"));
779                     
780                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_BLOCK, "", ATTRIBUTE_PROHIBITED_SUBSTITUTIONS, "Use schema default", null));
781                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_BLOCK));
782                 }
783             }
784             
785             public class PropFinalVerifier extends TestSequence {
786                 protected String JavaDoc ATTRIBUTE_PROHIBITED_DERIVATIONS = "Prohibited Derivations (Final)";
787                 protected String JavaDoc ATTR_FINAL = "final";
788                 protected String JavaDoc strCheckBoxGroup = "Prevent type derivations of the following kinds:";
789                 
790                 public void setupOnce() {
791                     m_testList = new LinkedList JavaDoc<SequentialTest>();
792                     
793                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_FINAL, "", ATTRIBUTE_PROHIBITED_DERIVATIONS, "Allow all type derivations (empty value)", null));
794                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FINAL, ""));
795                     
796                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_FINAL, "#all", ATTRIBUTE_PROHIBITED_DERIVATIONS, "Prevent all type derivations (#all)", null));
797                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FINAL, "#all"));
798                     
799                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_FINAL, "extension", ATTRIBUTE_PROHIBITED_DERIVATIONS, strCheckBoxGroup, "Extension"));
800                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FINAL, "extension"));
801                     
802                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_FINAL, "restriction", ATTRIBUTE_PROHIBITED_DERIVATIONS, strCheckBoxGroup, "Restriction"));
803                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FINAL, "restriction"));
804                     
805                     m_testList.add(new PropertiesTestSequence.DialogValueSetter(ATTR_FINAL, "", ATTRIBUTE_PROHIBITED_DERIVATIONS, "Use schema default", null));
806                     m_testList.add(new PropertiesTestSequence.ChangesInSourceVerifier(ATTR_FINAL));
807                 }
808             }
809         }
810     }
811     
812     public class AttributesCategory extends ColumnViewTestSequence {
813         public AttributesCategory() {
814             super(ComponentCategories.ATTRIBUTES);
815         }
816     }
817     
818     public class AttributeGroupsCategory extends ColumnViewTestSequence {
819         public AttributeGroupsCategory() {
820             super(ComponentCategories.ATTRIBUTE_GROUPS);
821         }
822     }
823     
824     public class ComplexTypesCategory extends ColumnViewTestSequence {
825         public ComplexTypesCategory() {
826             super(ComponentCategories.COMPLEX_TYPES);
827         }
828     }
829     
830     public class ElementsCategory extends ColumnViewTestSequence {
831         public ElementsCategory() {
832             super(ComponentCategories.ELEMENTS);
833         }
834     }
835     
836     public class GroupsCategory extends ColumnViewTestSequence {
837         public GroupsCategory() {
838             super(ComponentCategories.GROUPS);
839         }
840     }
841     
842     public class SimpleTypesCategory extends ColumnViewTestSequence {
843         public SimpleTypesCategory() {
844             super(ComponentCategories.SIMPLE_TYPES);
845         }
846     }
847     
848     public class ColumnViewNode {
849         public int m_row;
850         public int m_col;
851         
852         public ColumnViewNode(ColumnViewNode node) {
853             m_row = node.m_row;
854             m_col = node.m_col;
855         }
856         
857         public ColumnViewNode(int row, int col) {
858             m_row = row;
859             m_col = col;
860         }
861     }
862     
863     private void openSchema() {
864         ProjectsTabOperator pto = ProjectsTabOperator.invoke();
865         
866         ProjectRootNode nodeProjectRoot = pto.getProjectRootNode(PROJECT_NAME);
867         nodeProjectRoot.select();
868         org.netbeans.jellytools.nodes.Node nodeXSD = new org.netbeans.jellytools.nodes.Node(nodeProjectRoot, "Source Packages|qa.xmltools.samples|" + getSchemaName() + ".xsd");
869         
870         new OpenAction().performPopup(nodeXSD);
871         waitNoEvent();
872     }
873 }
874
Popular Tags