KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > j2ee > multiview > PagesAndReferencesDDTest


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.j2ee.multiview;
21
22 import javax.swing.text.JTextComponent JavaDoc;
23 import java.awt.Component JavaDoc;
24 import java.io.File JavaDoc;
25 import javax.swing.JButton JavaDoc;
26 import javax.swing.JCheckBox JavaDoc;
27 import javax.swing.JLabel JavaDoc;
28 import javax.swing.JPanel JavaDoc;
29 import javax.swing.JRadioButton JavaDoc;
30 import javax.swing.JTextArea JavaDoc;
31 import javax.swing.JTextField JavaDoc;
32 import junit.framework.Test;
33 import junit.textui.TestRunner;
34 import org.netbeans.api.project.Project;
35 import org.netbeans.jellytools.JellyTestCase;
36 import org.netbeans.junit.NbTestSuite;
37 import org.netbeans.modules.j2ee.dd.api.common.EjbLocalRef;
38 import org.netbeans.modules.j2ee.dd.api.common.EjbRef;
39 import org.netbeans.modules.j2ee.dd.api.common.EnvEntry;
40 import org.netbeans.modules.j2ee.dd.api.common.MessageDestination;
41 import org.netbeans.modules.j2ee.dd.api.common.MessageDestinationRef;
42 import org.netbeans.modules.j2ee.dd.api.common.ResourceEnvRef;
43 import org.netbeans.modules.j2ee.dd.api.common.ResourceRef;
44 import org.netbeans.modules.j2ee.dd.api.web.DDProvider;
45 import org.netbeans.modules.j2ee.dd.api.web.ErrorPage;
46 import org.netbeans.modules.j2ee.dd.api.web.JspConfig;
47 import org.netbeans.modules.j2ee.dd.api.web.JspPropertyGroup;
48 import org.netbeans.modules.j2ee.dd.api.web.WebApp;
49 import org.netbeans.modules.j2ee.ddloaders.web.DDDataObject;
50 import org.netbeans.modules.j2ee.ddloaders.web.multiview.DDBeanTableModel;
51 import org.netbeans.modules.j2ee.ddloaders.web.multiview.ErrorPagesTablePanel;
52 import org.netbeans.modules.web.project.WebProject;
53 import org.netbeans.modules.xml.multiview.ui.LinkButton;
54 import org.netbeans.test.j2ee.lib.J2eeProjectSupport;
55 import org.openide.filesystems.FileObject;
56 import org.openide.loaders.DataObject;
57
58 /**
59  *
60  * @author jp159440
61  */

62 public class PagesAndReferencesDDTest extends JellyTestCase{
63     
64     /** Creates a new instance of PagesAndReferencesDDTest */
65     public PagesAndReferencesDDTest(String JavaDoc testName) {
66         super(testName);
67     }
68     
69     protected void tearDown() throws Exception JavaDoc {
70         super.tearDown();
71     }
72     
73     protected void setUp() throws Exception JavaDoc {
74         super.setUp();
75     }
76     
77     public static final String JavaDoc WEB_PROJECT_NAME = "TestWebApp";
78     public static final String JavaDoc WEB_PROJECT_PATH = System.getProperty("xtest.tmpdir") + File.separator + WEB_PROJECT_NAME;
79     
80     private static Project project;
81     private static FileObject ddFo;
82     private static WebApp webapp;
83     private static DDDataObject ddObj;
84     private static DDTestUtils utils;
85     
86     public static Test suite() {
87         NbTestSuite suite = new NbTestSuite();
88         suite.addTest(new PagesAndReferencesDDTest("testOpenProject"));
89         suite.addTest(new PagesAndReferencesDDTest("testExistingWelcomePages"));
90         suite.addTest(new PagesAndReferencesDDTest("testAddWelcomePage"));
91         suite.addTest(new PagesAndReferencesDDTest("testDelWelcomePage"));
92         suite.addTest(new PagesAndReferencesDDTest("testExistingErrorPages"));
93         suite.addTest(new PagesAndReferencesDDTest("testAddErrorPage"));
94         suite.addTest(new PagesAndReferencesDDTest("testModifyErrorPage"));
95         suite.addTest(new PagesAndReferencesDDTest("testDelErrorPage"));
96         suite.addTest(new PagesAndReferencesDDTest("testExistingProperyGroups"));
97         suite.addTest(new PagesAndReferencesDDTest("testModifyProperyGroup"));
98         suite.addTest(new PagesAndReferencesDDTest("testDelPropertyGroup"));
99         suite.addTest(new PagesAndReferencesDDTest("testExistingEnvEntries"));
100         suite.addTest(new PagesAndReferencesDDTest("testAddEnvEntry"));
101         suite.addTest(new PagesAndReferencesDDTest("testModifyEnvEntry"));
102         suite.addTest(new PagesAndReferencesDDTest("testDelEnvEntry"));
103         suite.addTest(new PagesAndReferencesDDTest("testExistingResReferences"));
104         suite.addTest(new PagesAndReferencesDDTest("testAddResReference"));
105         suite.addTest(new PagesAndReferencesDDTest("testModifyResReference"));
106         suite.addTest(new PagesAndReferencesDDTest("testDelResReference"));
107         suite.addTest(new PagesAndReferencesDDTest("testExistingResEnvReferences"));
108         suite.addTest(new PagesAndReferencesDDTest("testAddResEnvReference"));
109         suite.addTest(new PagesAndReferencesDDTest("testModifyResEnvReference"));
110         suite.addTest(new PagesAndReferencesDDTest("testDelResEnvReference"));
111         suite.addTest(new PagesAndReferencesDDTest("testExistingEJBReferences"));
112         suite.addTest(new PagesAndReferencesDDTest("testAddLocalEJBReference"));
113         suite.addTest(new PagesAndReferencesDDTest("testModifyLocalEJBReference"));
114         suite.addTest(new PagesAndReferencesDDTest("testDelLocalEJBReference"));
115         suite.addTest(new PagesAndReferencesDDTest("testAddRemoteEJBReference"));
116         suite.addTest(new PagesAndReferencesDDTest("testModifyRemoteEJBReference"));
117         suite.addTest(new PagesAndReferencesDDTest("testDelRemoteEJBReference"));
118         suite.addTest(new PagesAndReferencesDDTest("testExistingMsgDstReferences"));
119         suite.addTest(new PagesAndReferencesDDTest("testAddMsgDstReference"));
120         suite.addTest(new PagesAndReferencesDDTest("testModifyMsgDstReference"));
121         suite.addTest(new PagesAndReferencesDDTest("testDelMsgDstReference"));
122         return suite;
123     }
124     
125     /** Use for execution inside IDE */
126     public static void main(java.lang.String JavaDoc[] args) {
127         // run only selected test case
128
TestRunner.run(suite());
129     }
130     
131     public void testOpenProject() throws Exception JavaDoc{
132         File JavaDoc projectDir = new File JavaDoc(WEB_PROJECT_PATH);
133         Project project = (Project)J2eeProjectSupport.openProject(projectDir);
134         assertNotNull("Project is null.", project);
135         WebProject webproj = (WebProject)project;
136         assertNotNull("Project is not webproject",webproj);
137         ddFo = webproj.getAPIWebModule().getDeploymentDescriptor();
138         assertNotNull("Can't get deploy descriptor file object",ddFo);
139         webapp = DDProvider.getDefault().getDDRoot(ddFo);
140         ddObj = (DDDataObject)DataObject.find(ddFo);
141         assertNotNull("Multiview is null",ddObj);
142         ddObj.openView(3);
143         utils = new DDTestUtils(ddObj,this);
144         Utils.waitForAWTDispatchThread();
145     }
146     
147     private void iterChilds(JPanel JavaDoc panel) {
148         Component JavaDoc[] comp = panel.getComponents();
149         for (int i = 0; i < comp.length; i++) {
150             System.out.println(i+" "+comp[i].getClass().getName());
151             if(comp[i] instanceof JTextField JavaDoc) {
152                 System.out.println(((JTextField JavaDoc)comp[i]).getText());
153             }
154             if(comp[i] instanceof JTextArea JavaDoc) {
155                 System.out.println(((JTextArea JavaDoc)comp[i]).getText());
156             }
157             if(comp[i] instanceof JLabel JavaDoc) {
158                 System.out.println(((JLabel JavaDoc)comp[i]).getText());
159             }
160             if(comp[i] instanceof JCheckBox JavaDoc) {
161                 System.out.println(((JCheckBox JavaDoc)comp[i]).isSelected());
162             }
163             if(comp[i] instanceof JRadioButton JavaDoc) {
164                 System.out.println(((JRadioButton JavaDoc)comp[i]).getName());
165             }
166             if(comp[i] instanceof JButton JavaDoc) {
167                 System.out.println(((JButton JavaDoc)comp[i]).getText());
168             }
169             if(comp[i] instanceof LinkButton) {
170                 System.out.println(((LinkButton)comp[i]).getText());
171             }
172         }
173         
174     }
175     
176     public void testExistingWelcomePages() throws Exception JavaDoc {
177         JPanel JavaDoc panel = utils.getInnerSectionPanel("welcome_files");
178         Component JavaDoc[] comp = panel.getComponents();
179         assertEquals("Welcome pages doesn't match","index.jsp",((JTextField JavaDoc)comp[1]).getText());
180         String JavaDoc[] files = webapp.getSingleWelcomeFileList().getWelcomeFile();
181         assertEquals("Wrong number of welcome files",1,files.length);
182         assertEquals("Wrong welcome file","index.jsp",files[0].trim());
183     }
184     
185     public void testAddWelcomePage() throws Exception JavaDoc {
186         JPanel JavaDoc panel = utils.getInnerSectionPanel("welcome_files");
187         Component JavaDoc[] comp = panel.getComponents();
188         utils.setText((JTextField JavaDoc)comp[1],"index2.jsp, index3.jsp");
189         ((Component JavaDoc)comp[2]).requestFocus();
190         new StepIterator() {
191             public boolean step() throws Exception JavaDoc {
192                 return utils.contains(".*<welcome-file-list>\\s*<welcome-file>index2.jsp</welcome-file>\\s*<welcome-file>index3.jsp</welcome-file>\\s*</welcome-file-list>.*");
193             }
194             public void finalCheck() {
195                 utils.checkInDDXML(".*<welcome-file-list>\\s*<welcome-file>index2.jsp</welcome-file>\\s*<welcome-file>index3.jsp</welcome-file>\\s*</welcome-file-list>.*");
196                 String JavaDoc[] files = webapp.getSingleWelcomeFileList().getWelcomeFile();
197                 assertEquals("Wrong count of welcome pages",2,files.length);
198                 assertEquals("Welcome file name doesn't match.","index2.jsp",files[0]);
199                 assertEquals("Welcome file name doesn't match.","index3.jsp",files[1]);
200             }
201         };
202         utils.save();
203     }
204     
205     public void testDelWelcomePage() throws Exception JavaDoc {
206         JPanel JavaDoc panel = utils.getInnerSectionPanel("welcome_files");
207         Component JavaDoc[] comp = panel.getComponents();
208         utils.setText((JTextField JavaDoc)comp[1],"index.jsp");
209         ((Component JavaDoc)comp[2]).requestFocus();
210         utils.waitForDispatchThread();
211         new StepIterator() {
212             public boolean step() throws Exception JavaDoc {
213                 return utils.contains(".*<welcome-file-list>\\s*<welcome-file>\\s*index.jsp\\s*</welcome-file>\\s*</welcome-file-list>.*");
214             }
215             
216             public void finalCheck() {
217                 utils.checkInDDXML(".*<welcome-file-list>\\s*<welcome-file>\\s*index.jsp\\s*</welcome-file>\\s*</welcome-file-list>.*");
218                 String JavaDoc[] files = webapp.getSingleWelcomeFileList().getWelcomeFile();
219                 assertEquals("Wrong count of welcome pages",1,files.length);
220                 assertEquals("Welcome file name doesn't match.","index.jsp",files[0].trim());
221             }
222         };
223         utils.save();
224     }
225     
226     public void testExistingErrorPages() throws Exception JavaDoc {
227         JPanel JavaDoc panel = utils.getInnerSectionPanel("error_pages");
228         Component JavaDoc[] comp = panel.getComponents();
229         DDBeanTableModel model = (DDBeanTableModel) ((ErrorPagesTablePanel)comp[1]).getTable().getModel();
230         assertEquals("Wrong count of error pages",1,model.getRowCount());
231         assertEquals("Error wrong error page parameter.","/index.jsp",model.getValueAt(0,0));
232         assertEquals("Error wrong error page parameter.",new Integer JavaDoc(404),model.getValueAt(0,1));
233         assertEquals("Error wrong error page parameter.",null,model.getValueAt(0,2));
234         ErrorPage[] errorPage = webapp.getErrorPage();
235         utils.testProperties(errorPage[0],new String JavaDoc[]{"Location","ErrorCode","ExceptionType"}, new Object JavaDoc[]{"/index.jsp",new Integer JavaDoc(404),null});
236     }
237     
238     public void testAddErrorPage() throws Exception JavaDoc {
239         JPanel JavaDoc panel = utils.getInnerSectionPanel("error_pages");
240         Component JavaDoc[] comp = panel.getComponents();
241         DDBeanTableModel model = (DDBeanTableModel) ((ErrorPagesTablePanel)comp[1]).getTable().getModel();
242         model.addRow(new Object JavaDoc[]{"/index2.jsp",null,"java.lang.NullPointerException"});
243         ddObj.modelUpdatedFromUI();
244         utils.waitForDispatchThread();
245         utils.save();
246         assertEquals("Error page not added",2,model.getRowCount());
247         int i=0;
248         ErrorPage[] errorPages = webapp.getErrorPage();
249         for (i = 0; i < errorPages.length; i++) {
250             if(errorPages[i].getLocation().equals("/index2.jsp")) break;
251         }
252         assertTrue("New error page not found",i<errorPages.length);
253         utils.testProperties(errorPages[i],new String JavaDoc[]{"Location","ErrorCode","ExceptionType"}, new Object JavaDoc[]{"/index2.jsp",null,"java.lang.NullPointerException"});
254         for (i = 0; i < model.getRowCount(); i++) {
255             if(model.getValueAt(i,0).equals("/index2.jsp")) break;
256         }
257         assertTrue("New error page not found",i<model.getRowCount());
258         utils.testTableRow(model,i,new String JavaDoc[]{"/index2.jsp",null,"java.lang.NullPointerException"});
259         utils.checkInDDXML(".*<error-page>\\s*<exception-type>java.lang.NullPointerException</exception-type>\\s*<location>/index2.jsp</location>\\s*</error-page>.*");
260     }
261     
262     public void testModifyErrorPage() throws Exception JavaDoc {
263         JPanel JavaDoc panel = utils.getInnerSectionPanel("error_pages");
264         Component JavaDoc[] comp = panel.getComponents();
265         DDBeanTableModel model = (DDBeanTableModel) ((ErrorPagesTablePanel)comp[1]).getTable().getModel();
266         int i;
267         for (i = 0; i < model.getRowCount(); i++) {
268             if(model.getValueAt(i,0).equals("/index.jsp")) break;
269         }
270         assertTrue("Error page not found",i<model.getRowCount());
271         model.setValueAt("/index3.jsp",i,0);
272         ddObj.modelUpdatedFromUI();
273         new StepIterator() {
274             public boolean step() throws Exception JavaDoc {
275                 return utils.contains(".*<location>/index3.jsp</location>\\s*</error-page>.*");
276             }
277             
278             public void finalCheck() {
279                 utils.checkInDDXML(".*<location>/index3.jsp</location>\\s*</error-page>.*");
280             }
281         };
282         model.setValueAt(null,i,1);
283         model.setValueAt("java.lang.IndexOutOfBoundsException",i,2);
284         ddObj.modelUpdatedFromUI();
285         new StepIterator() {
286             public boolean step() throws Exception JavaDoc {
287                 return utils.contains(".*<exception-type>java.lang.IndexOutOfBoundsException</exception-type>.*");
288             }
289             
290             public void finalCheck() {
291                 utils.checkInDDXML(".*<exception-type>java.lang.IndexOutOfBoundsException</exception-type>.*");
292             }
293         };
294         utils.save();
295         for (i = 0; i < webapp.getErrorPage().length; i++) {
296             if(webapp.getErrorPage(i).getLocation().equals("/index3.jsp")) break;
297         }
298         assertTrue("Error page not found.",i<webapp.getErrorPage().length);
299         utils.testProperties(webapp.getErrorPage(i),new String JavaDoc[]{"Location","ErrorCode","ExceptionType"},new Object JavaDoc[]{"/index3.jsp",null,"java.lang.IndexOutOfBoundsException"});
300         utils.checkInDDXML(".*<error-page>\\s*<exception-type>java.lang.IndexOutOfBoundsException</exception-type>\\s*<location>/index3.jsp</location>\\s*</error-page>.*");
301     }
302     
303     public void testDelErrorPage() throws Exception JavaDoc {
304         JPanel JavaDoc panel = utils.getInnerSectionPanel("error_pages");
305         Component JavaDoc[] comp = panel.getComponents();
306         DDBeanTableModel model = (DDBeanTableModel) ((ErrorPagesTablePanel)comp[1]).getTable().getModel();
307         int i;
308         for (i = 0; i < model.getRowCount(); i++) {
309             if(model.getValueAt(i,0).equals("/index3.jsp")) break;
310         }
311         assertTrue("Error page not found",i<model.getRowCount());
312         model.removeRow(i);
313         ddObj.modelUpdatedFromUI();
314         utils.waitForDispatchThread();
315         utils.save();
316         for(i=0;i<webapp.getErrorPage().length;i++) {
317             assertFalse("Error Page not removed",webapp.getErrorPage(i).getLocation().equals("index3.jsp"));
318         }
319         utils.checkNotInDDXML(".*<error-page>.*<location>/index3.jsp</location>\\s*</error-page>.*");
320     }
321             
322     public void testExistingProperyGroups() throws Exception JavaDoc {
323         JspConfig jspConfig = webapp.getSingleJspConfig();
324         assertNotNull("JspConfig is null",jspConfig);
325         JspPropertyGroup[] propertyGroups = jspConfig.getJspPropertyGroup();
326         assertEquals("Wrong number of JspProperyGroups",1,propertyGroups.length);
327         JspPropertyGroup propertyGrp = propertyGroups[0];
328         utils.checkProperyGrpup(propertyGrp,"PropGrpName","PropGrpDesc","ASCII",new String JavaDoc[] {"head.jsp","head2.jsp"},new String JavaDoc[] {"foot.jsp","foot2.jsp"},new String JavaDoc[]{"/*"},new boolean[]{true,true,true});
329     }
330     
331     public void testModifyProperyGroup() throws Exception JavaDoc {
332         JspPropertyGroup propertyGrp = webapp.getSingleJspConfig().getJspPropertyGroup(0);
333         JPanel JavaDoc panel = utils.getInnerSectionPanel(propertyGrp);
334         Component JavaDoc[] comp = panel.getComponents();
335         panel.requestFocus();
336         utils.waitForDispatchThread();
337         utils.setText((JTextComponent JavaDoc)comp[1],"newname");
338         comp[3].requestFocus();
339         new StepIterator() {
340             public boolean step() throws Exception JavaDoc {
341                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<display-name>newname</display-name>.*</jsp-property-group>\\s*</jsp-config>.*");
342             }
343         };
344         utils.setText((JTextComponent JavaDoc)comp[3],"newdesc");
345         comp[5].requestFocus();
346         new StepIterator() {
347             public boolean step() throws Exception JavaDoc {
348                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<description>newdesc</description>.*</jsp-property-group>\\s*</jsp-config>.*");
349             }
350         };
351         utils.setText((JTextComponent JavaDoc)comp[5],"*");
352         comp[9].requestFocus();
353         new StepIterator() {
354             public boolean step() throws Exception JavaDoc {
355                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<url-pattern>\\*</url-pattern>.*</jsp-property-group>\\s*</jsp-config>.*");
356             }
357         };
358         utils.setText((JTextComponent JavaDoc)comp[9],"ISO-8859-2");
359         comp[10].requestFocus();
360         new StepIterator() {
361             public boolean step() throws Exception JavaDoc {
362                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<page-encoding>ISO-8859-2</page-encoding>.*</jsp-property-group>\\s*</jsp-config>.*");
363             }
364         };
365         ((JCheckBox JavaDoc)comp[10]).setSelected(false);
366         ddObj.modelUpdatedFromUI();
367         comp[14].requestFocus();
368         utils.waitForDispatchThread();
369         new StepIterator() {
370             public boolean step() throws Exception JavaDoc {
371                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<el-ignored>false</el-ignored>.*</jsp-property-group>\\s*</jsp-config>.*");
372             }
373         };
374         ((JCheckBox JavaDoc)comp[11]).setSelected(false);
375         comp[14].requestFocus();
376         ddObj.modelUpdatedFromUI();
377         utils.waitForDispatchThread();
378         new StepIterator() {
379             public boolean step() throws Exception JavaDoc {
380                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<scripting-invalid>false</scripting-invalid>.*</jsp-property-group>\\s*</jsp-config>.*");
381             }
382         };
383         ((JCheckBox JavaDoc)comp[12]).setSelected(false);
384         ddObj.modelUpdatedFromUI();
385         comp[14].requestFocus();
386         ddObj.modelUpdatedFromUI();
387         new StepIterator() {
388             public boolean step() throws Exception JavaDoc {
389                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<is-xml>false</is-xml>.*</jsp-property-group>\\s*</jsp-config>.*");
390             }
391         };
392         utils.setText((JTextComponent JavaDoc)comp[14],"prelude.jsp");
393         comp[17].requestFocus();
394         new StepIterator() {
395             public boolean step() throws Exception JavaDoc {
396                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<include-prelude>prelude.jsp</include-prelude>.*</jsp-property-group>\\s*</jsp-config>.*");
397             }
398         };
399         utils.setText((JTextComponent JavaDoc)comp[17],"coda.jsp");
400         comp[1].requestFocus();
401         new StepIterator() {
402             public boolean step() throws Exception JavaDoc {
403                 return utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<include-coda>coda.jsp</include-coda>.*</jsp-property-group>\\s*</jsp-config>.*");
404             }
405         };
406         utils.save();
407         utils.checkProperyGrpup(propertyGrp,"newname","newdesc","ISO-8859-2",new String JavaDoc[]{"prelude.jsp"},new String JavaDoc[]{"coda.jsp"},new String JavaDoc[]{"*"},new boolean[]{false,false,false});
408         String JavaDoc xml = ".*<jsp-config>\\s*" +
409                 "<jsp-property-group>\\s*"+
410                 "<description>newdesc</description>\\s*"+
411                 "<display-name>newname</display-name>\\s*"+
412                 "<url-pattern>\\*</url-pattern>\\s*"+
413                 "<el-ignored>false</el-ignored>\\s*"+
414                 "<page-encoding>ISO-8859-2</page-encoding>\\s*"+
415                 "<scripting-invalid>false</scripting-invalid>\\s*"+
416                 "<is-xml>false</is-xml>\\s*"+
417                 "<include-prelude>prelude.jsp</include-prelude>\\s*"+
418                 "<include-coda>coda.jsp</include-coda>\\s*"+
419                 "</jsp-property-group>\\s*"+
420                 "</jsp-config>.*";
421         utils.checkInDDXML(xml);
422     }
423     
424     public void testDelPropertyGroup() throws Exception JavaDoc {
425         JspPropertyGroup propertyGrp = webapp.getSingleJspConfig().getJspPropertyGroup(0);
426         final String JavaDoc name = propertyGrp.getDefaultDisplayName();
427         webapp.getSingleJspConfig().removeJspPropertyGroup(propertyGrp);
428         ddObj.modelUpdatedFromUI();
429         utils.waitForDispatchThread();
430         new StepIterator() {
431             public boolean step() throws Exception JavaDoc {
432                 return !utils.contains(".*<jsp-config>\\s*<jsp-property-group>.*<display-name>"+name+"</display-name>.*</jsp-property-group>\\s*</jsp-config>.*");
433             }
434         };
435         utils.save();
436         JspPropertyGroup[] groups = webapp.getSingleJspConfig().getJspPropertyGroup();
437         for (int i = 0; i < groups.length; i++) {
438             assertNotSame("Property group not deleted",name,groups[i].getDefaultDisplayName());
439         }
440     }
441     
442     public void testExistingEnvEntries() throws Exception JavaDoc {
443         ddObj.openView(4);
444         utils.waitForDispatchThread();
445         DDBeanTableModel model = utils.getModelByBean("env_entries");
446         utils.testTable(model,new String JavaDoc[][]{{"EnvName","java.lang.Character","EnvValue","EnvDesc"}});
447         EnvEntry[] entries = webapp.getEnvEntry();
448         assertEquals("Wrong number of env entries",1,entries.length);
449         utils.testProperties(entries[0],new String JavaDoc[]{"EnvEntryName","EnvEntryType","EnvEntryValue"},new Object JavaDoc[]{"EnvName","java.lang.Character","EnvValue"});
450         assertEquals("EnvDesc",entries[0].getDefaultDescription());
451     }
452     
453     public void testAddEnvEntry() throws Exception JavaDoc {
454         DDBeanTableModel model = utils.getModelByBean("env_entries");
455         model.addRow(new Object JavaDoc[]{"newEnvName","java.lang.Integer","newEnvValue","newEnvDesc"});
456         ddObj.modelUpdatedFromUI();
457         utils.waitForDispatchThread();
458         utils.save();
459         EnvEntry envEntry = (EnvEntry) utils.getBeanByProp(webapp.getEnvEntry(),"EnvEntryName","newEnvName");
460         assertNotNull("New Env Entry is not added.",envEntry);
461         utils.testProperties(envEntry,new String JavaDoc[]{"EnvEntryName","EnvEntryType","EnvEntryValue"},new Object JavaDoc[]{"newEnvName","java.lang.Integer","newEnvValue"});
462         assertEquals("newEnvDesc",envEntry.getDefaultDescription());
463         utils.checkInDDXML(".*<env-entry>\\s*<description>newEnvDesc</description>\\s*<env-entry-name>newEnvName</env-entry-name>\\s*<env-entry-type>java.lang.Integer</env-entry-type>\\s*<env-entry-value>newEnvValue</env-entry-value>\\s*</env-entry>.*");
464     }
465     
466     public void testModifyEnvEntry() throws Exception JavaDoc {
467         DDBeanTableModel model = utils.getModelByBean("env_entries");
468         int row = utils.getRowIndexByProp(model,0,"EnvName");
469         assertTrue("Env entry not found in table model",row>=0);
470         utils.setTableRow(model,row,new Object JavaDoc[]{"EnvNameMod","java.lang.Double","EnvValueMod","EnvDescMod"});
471         ddObj.modelUpdatedFromUI();
472         utils.waitForDispatchThread();
473         new StepIterator() {
474             public boolean step() throws Exception JavaDoc {
475                 return utils.contains(".*<env-entry>\\s*<description>EnvDescMod</description>\\s*<env-entry-name>EnvNameMod</env-entry-name>\\s*<env-entry-type>java.lang.Double</env-entry-type>\\s*<env-entry-value>EnvValueMod</env-entry-value>\\s*</env-entry>.*");
476             }
477         };
478         EnvEntry envEntry = (EnvEntry) utils.getBeanByProp(webapp.getEnvEntry(),"EnvEntryName","EnvNameMod");
479         assertNotNull("Env Entry not modified",envEntry);
480         utils.testProperties(envEntry,new String JavaDoc[]{"EnvEntryName","EnvEntryType","EnvEntryValue"},new Object JavaDoc[]{"EnvNameMod","java.lang.Double","EnvValueMod"});
481         assertEquals("EnvDescMod",envEntry.getDefaultDescription());
482         utils.checkNotInDDXML(".*<env-entry>.*<env-entry-name>EnvName</env-entry-name>.*</env-entry>.*");
483         utils.checkInDDXML(".*<env-entry>\\s*<description>EnvDescMod</description>\\s*<env-entry-name>EnvNameMod</env-entry-name>\\s*<env-entry-type>java.lang.Double</env-entry-type>\\s*<env-entry-value>EnvValueMod</env-entry-value>\\s*</env-entry>.*");
484     }
485     
486     public void testDelEnvEntry() throws Exception JavaDoc {
487         DDBeanTableModel model = utils.getModelByBean("env_entries");
488         String JavaDoc entryName = (String JavaDoc) model.getValueAt(0,0);
489         model.removeRow(0);
490         ddObj.modelUpdatedFromUI();
491         utils.waitForDispatchThread();
492         utils.save();
493         Object JavaDoc envEntry = utils.getBeanByProp(webapp.getEnvEntry(),"EnvEntryName",entryName);
494         assertNull("Env Entry was not deleted",envEntry);
495         utils.checkNotInDDXML(".*<env-entry>.*<env-entry-name>"+entryName+"</env-entry-name>.*</env-entry>.*");
496     }
497     
498     public void testExistingResReferences() throws Exception JavaDoc {
499         DDBeanTableModel model = utils.getModelByBean("res_refs");
500         utils.testTable(model,new String JavaDoc[][]{{"ResName","javax.mail.Session","Application","Unshareable","ResDesc"}});
501         ResourceRef[] refs = webapp.getResourceRef();
502         assertEquals("Wrong number of resource references",1,refs.length);
503         utils.testProperties(refs[0],new String JavaDoc[]{"ResRefName","ResType","ResAuth","ResSharingScope"},new Object JavaDoc[]{"ResName","javax.mail.Session","Application","Unshareable"});
504         assertEquals("ResDesc",refs[0].getDefaultDescription());
505     }
506     
507     public void testAddResReference() throws Exception JavaDoc {
508         DDBeanTableModel model = utils.getModelByBean("res_refs");
509         model.addRow(new Object JavaDoc[]{"newResName","java.net.URL","Container","Shareable","newResDesc"});
510         ddObj.modelUpdatedFromUI();
511         utils.waitForDispatchThread();
512         utils.save();
513         new StepIterator() {
514             public boolean step() throws Exception JavaDoc {
515                 return utils.contains(".*<resource-ref>\\s*<description>newResDesc</description>\\s*<res-ref-name>newResName</res-ref-name>\\s*<res-type>java.net.URL</res-type>\\s*<res-auth>Container</res-auth>\\s*<res-sharing-scope>Shareable</res-sharing-scope>\\s*</resource-ref>.*");
516             }
517         };
518         ResourceRef ref= (ResourceRef) utils.getBeanByProp(webapp.getResourceRef(),"ResRefName","newResName");
519         assertNotNull("New Resource Ref is not added.",ref);
520         utils.testProperties(ref,new String JavaDoc[]{"ResRefName","ResType","ResAuth","ResSharingScope"},new Object JavaDoc[]{"newResName","java.net.URL","Container","Shareable"});
521         assertEquals("newResDesc",ref.getDefaultDescription());
522         utils.checkInDDXML(".*<resource-ref>\\s*<description>newResDesc</description>\\s*<res-ref-name>newResName</res-ref-name>\\s*<res-type>java.net.URL</res-type>\\s*<res-auth>Container</res-auth>\\s*<res-sharing-scope>Shareable</res-sharing-scope>\\s*</resource-ref>.*");
523     }
524     
525     public void testModifyResReference() throws Exception JavaDoc {
526         DDBeanTableModel model = utils.getModelByBean("res_refs");
527         int row = utils.getRowIndexByProp(model,0,"ResName");
528         assertTrue("Resource ref not found in table model",row>=0);
529         utils.setTableRow(model,row,new Object JavaDoc[]{"ResNameMod","javax.sql.DataSource","Container","Shareable","ResDescMod"});
530         ddObj.modelUpdatedFromUI();
531         utils.waitForDispatchThread();
532         new StepIterator() {
533             public boolean step() throws Exception JavaDoc {
534                 return utils.contains(".*<resource-ref>\\s*<description>ResDescMod</description>\\s*<res-ref-name>ResNameMod</res-ref-name>\\s*<res-type>javax.sql.DataSource</res-type>\\s*<res-auth>Container</res-auth>\\s*<res-sharing-scope>Shareable</res-sharing-scope>\\s*</resource-ref>.*");
535             }
536         };
537         utils.save();
538         ResourceRef ref = (ResourceRef) utils.getBeanByProp(webapp.getResourceRef(),"ResRefName","ResNameMod");
539         assertNotNull("Resource ref not modified",ref);
540         utils.testProperties(ref,new String JavaDoc[]{"ResRefName","ResType","ResAuth","ResSharingScope"},new Object JavaDoc[]{"ResNameMod","javax.sql.DataSource","Container","Shareable"});
541         assertEquals("ResDescMod",ref.getDefaultDescription());
542         utils.checkNotInDDXML(".*<resource-ref>.*<res-ref-name>ResName</res-ref-name>.*</resource-ref>.*");
543         utils.checkInDDXML(".*<resource-ref>\\s*<description>ResDescMod</description>\\s*<res-ref-name>ResNameMod</res-ref-name>\\s*<res-type>javax.sql.DataSource</res-type>\\s*<res-auth>Container</res-auth>\\s*<res-sharing-scope>Shareable</res-sharing-scope>\\s*</resource-ref>.*");
544     }
545     
546     public void testDelResReference() throws Exception JavaDoc {
547         DDBeanTableModel model = utils.getModelByBean("res_refs");
548         String JavaDoc resRefName = (String JavaDoc) model.getValueAt(0,0);
549         model.removeRow(0);
550         ddObj.modelUpdatedFromUI();
551         utils.waitForDispatchThread();
552         utils.save();
553         Object JavaDoc resRef = utils.getBeanByProp(webapp.getResourceRef(),"ResRefName",resRefName);
554         assertNull("Resource ref was not deleted",resRef);
555         utils.checkNotInDDXML(".*<resource-ref>.*<res-ref-name>"+resRefName+"</res-ref-name>.*</resource-ref>.*");
556     }
557     
558     public void testExistingResEnvReferences() throws Exception JavaDoc {
559         DDBeanTableModel model = utils.getModelByBean("res_env_refs");
560         utils.testTable(model,new String JavaDoc[][]{{"ResEnvName","javax.jms.Topic","ResEnvdesc"}});
561         ResourceEnvRef[] refs = webapp.getResourceEnvRef();
562         assertEquals("Wrong number of resource references",1,refs.length);
563         utils.testProperties(refs[0],new String JavaDoc[]{"ResourceEnvRefName","ResourceEnvRefType"},new Object JavaDoc[]{"ResEnvName","javax.jms.Topic"});
564         assertEquals("ResEnvdesc",refs[0].getDefaultDescription());
565     }
566     
567     public void testAddResEnvReference() throws Exception JavaDoc {
568         DDBeanTableModel model = utils.getModelByBean("res_env_refs");
569         model.addRow(new Object JavaDoc[]{"newResEnvName","javax.jms.Queue","newResEnvDesc"});
570         ddObj.modelUpdatedFromUI();
571         utils.waitForDispatchThread();
572         utils.save();
573         new StepIterator() {
574             public boolean step() throws Exception JavaDoc {
575                 return utils.contains(".*<resource-env-ref>\\s*<description>newResEnvDesc</description>\\s*<resource-env-ref-name>newResEnvName</resource-env-ref-name>\\s*<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>\\s*</resource-env-ref>.*");
576             }
577         };
578         ResourceEnvRef ref= (ResourceEnvRef) utils.getBeanByProp(webapp.getResourceEnvRef(),"ResourceEnvRefName","newResEnvName");
579         assertNotNull("New Env Resource Ref is not added.",ref);
580         utils.testProperties(ref,new String JavaDoc[]{"ResourceEnvRefName","ResourceEnvRefType"},new Object JavaDoc[]{"newResEnvName","javax.jms.Queue"});
581         assertEquals("newResEnvDesc",ref.getDefaultDescription());
582         utils.checkInDDXML(".*<resource-env-ref>\\s*<description>newResEnvDesc</description>\\s*<resource-env-ref-name>newResEnvName</resource-env-ref-name>\\s*<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>\\s*</resource-env-ref>.*");
583     }
584     
585     public void testModifyResEnvReference() throws Exception JavaDoc {
586         DDBeanTableModel model = utils.getModelByBean("res_env_refs");
587         int row = utils.getRowIndexByProp(model,0,"ResEnvName");
588         assertTrue("Resource env ref not found in table model",row>=0);
589         utils.setTableRow(model,row,new Object JavaDoc[]{"ResEnvNameMod","javax.jms.Queue","ResEnvDescMod"});
590         ddObj.modelUpdatedFromUI();
591         utils.waitForDispatchThread();
592         new StepIterator() {
593             public boolean step() throws Exception JavaDoc {
594                 return utils.contains(".*<resource-env-ref>\\s*<description>ResEnvDescMod</description>\\s*<resource-env-ref-name>ResEnvNameMod</resource-env-ref-name>\\s*<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>\\s*</resource-env-ref>.*");
595             }
596         };
597         utils.save();
598         ResourceEnvRef ref= (ResourceEnvRef) utils.getBeanByProp(webapp.getResourceEnvRef(),"ResourceEnvRefName","ResEnvNameMod");
599         assertNotNull("Resource env ref not modified",ref);
600         utils.testProperties(ref,new String JavaDoc[]{"ResourceEnvRefName","ResourceEnvRefType"},new Object JavaDoc[]{"ResEnvNameMod","javax.jms.Queue"});
601         assertEquals("ResEnvDescMod",ref.getDefaultDescription());
602         utils.checkNotInDDXML(".*<resource-env-ref>.*<resource-env-ref-name>ResEnvName</resource-env-ref-name>.*</resource-env-ref>.*");
603         utils.checkInDDXML(".*<resource-env-ref>\\s*<description>ResEnvDescMod</description>\\s*<resource-env-ref-name>ResEnvNameMod</resource-env-ref-name>\\s*<resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>\\s*</resource-env-ref>.*");
604     }
605     
606     public void testDelResEnvReference() throws Exception JavaDoc {
607         DDBeanTableModel model = utils.getModelByBean("res_env_refs");
608         String JavaDoc resEnvRefName = (String JavaDoc) model.getValueAt(0,0);
609         model.removeRow(0);
610         ddObj.modelUpdatedFromUI();
611         utils.waitForDispatchThread();
612         utils.save();
613         Object JavaDoc resRef = utils.getBeanByProp(webapp.getResourceEnvRef(),"ResourceEnvRefName",resEnvRefName);
614         assertNull("Env. resource ref was not deleted",resRef);
615         utils.checkNotInDDXML(".*<resource-env-ref>.*<resource-env-ref-name>"+resEnvRefName+"</resource-env-ref-name>.*</resource-env-ref>.*");
616     }
617     
618     public void testExistingEJBReferences() throws Exception JavaDoc {
619         DDBeanTableModel model = utils.getModelByBean("ejb_refs");
620         String JavaDoc[][] vals = {{"EJBName2","Session","Remote","EJBHome2","EJBRemote","LinkedEJB2","EJBDesc2"},
621         {"EJBName","Entity","Local","EJBHome","EJBLocal","LinkedEJB","EJBDesc"}};
622         utils.testTable(model,vals);
623         EjbLocalRef[] refs = webapp.getEjbLocalRef();
624         assertEquals("Wrong number of EJB local references",1,refs.length);
625         utils.testProperties(refs[0],new String JavaDoc[]{"EjbRefName","EjbRefType","LocalHome","Local","EjbLink"},new Object JavaDoc[]{"EJBName","Entity","EJBHome","EJBLocal","LinkedEJB"});
626         assertEquals("EJBDesc",refs[0].getDefaultDescription());
627         EjbRef[] refs2 = webapp.getEjbRef();
628         assertEquals("Wrong number of EJB remote references",1,refs.length);
629         utils.testProperties(refs2[0],new String JavaDoc[]{"EjbRefName","EjbRefType","Home","Remote","EjbLink"},new Object JavaDoc[]{"EJBName2","Session","EJBHome2","EJBRemote","LinkedEJB2"});
630         assertEquals("EJBDesc2",refs2[0].getDefaultDescription());
631     }
632     
633     public void testAddLocalEJBReference() throws Exception JavaDoc {
634         DDBeanTableModel model = utils.getModelByBean("ejb_refs");
635         model.addRow(new Object JavaDoc[]{"newEJBName","Session","Local","newHome","newLocal","newLinked","newDesc"});
636         ddObj.modelUpdatedFromUI();
637         utils.waitForDispatchThread();
638         utils.save();
639         new StepIterator() {
640             public boolean step() throws Exception JavaDoc {
641                 return utils.contains(".*<ejb-local-ref>\\s*<description>newDesc</description>\\s*<ejb-ref-name>newEJBName</ejb-ref-name>\\s*<ejb-ref-type>Session</ejb-ref-type>\\s*<local-home>newHome</local-home>\\s*<local>newLocal</local>\\s*<ejb-link>newLinked</ejb-link>\\s*</ejb-local-ref>.*");
642             }
643         };
644         EjbLocalRef ref= (EjbLocalRef) utils.getBeanByProp(webapp.getEjbLocalRef(),"EjbRefName","newEJBName");
645         assertNotNull("New Local EJB Ref is not added.",ref);
646         utils.testProperties(ref,new String JavaDoc[]{"EjbRefName","EjbRefType","LocalHome","Local","EjbLink"},new Object JavaDoc[]{"newEJBName","Session","newHome","newLocal","newLinked"});
647         assertEquals("newDesc",ref.getDefaultDescription());
648         utils.checkInDDXML(".*<ejb-local-ref>\\s*<description>newDesc</description>\\s*<ejb-ref-name>newEJBName</ejb-ref-name>\\s*<ejb-ref-type>Session</ejb-ref-type>\\s*<local-home>newHome</local-home>\\s*<local>newLocal</local>\\s*<ejb-link>newLinked</ejb-link>\\s*</ejb-local-ref>.*");
649     }
650     
651     public void testModifyLocalEJBReference() throws Exception JavaDoc {
652         DDBeanTableModel model = utils.getModelByBean("ejb_refs");
653         int row = utils.getRowIndexByProp(model,0,"EJBName");
654         assertTrue("Local EJB ref not found in table model",row>=0);
655         utils.setTableRow(model,row,new Object JavaDoc[]{"EJBNameMod","Session","","EJBHomeMod","EJBLocalMod","LinkedEJBMod","EJBDescMod"});
656         ddObj.modelUpdatedFromUI();
657         utils.waitForDispatchThread();
658         new StepIterator() {
659             public boolean step() throws Exception JavaDoc {
660                 return utils.contains(".*<ejb-local-ref>\\s*<description>EJBDescMod</description>\\s*<ejb-ref-name>EJBNameMod</ejb-ref-name>\\s*<ejb-ref-type>Session</ejb-ref-type>\\s*<local-home>EJBHomeMod</local-home>\\s*<local>EJBLocalMod</local>\\s*<ejb-link>LinkedEJBMod</ejb-link>\\s*</ejb-local-ref>.*");
661             }
662         };
663         utils.save();
664         EjbLocalRef ref= (EjbLocalRef) utils.getBeanByProp(webapp.getEjbLocalRef(),"EjbRefName","EJBNameMod");
665         assertNotNull("Local EJB ref not modified",ref);
666         utils.testProperties(ref,new String JavaDoc[]{"EjbRefName","EjbRefType","LocalHome","Local","EjbLink"},new Object JavaDoc[]{"EJBNameMod","Session","EJBHomeMod","EJBLocalMod","LinkedEJBMod"});
667         assertEquals("EJBDescMod",ref.getDefaultDescription());
668         utils.checkNotInDDXML(".*<ejb-local-ref>.*<ejb-ref-name>EJBName</ejb-ref-name>.*</ejb-local-ref>.*");
669         utils.checkInDDXML(".*<ejb-local-ref>\\s*<description>EJBDescMod</description>\\s*<ejb-ref-name>EJBNameMod</ejb-ref-name>\\s*<ejb-ref-type>Session</ejb-ref-type>\\s*<local-home>EJBHomeMod</local-home>\\s*<local>EJBLocalMod</local>\\s*<ejb-link>LinkedEJBMod</ejb-link>\\s*</ejb-local-ref>.*");
670     }
671     
672     public void testDelLocalEJBReference() throws Exception JavaDoc {
673         DDBeanTableModel model = utils.getModelByBean("ejb_refs");
674         int row = utils.getRowIndexByProp(model,2,"Local");
675         assertTrue("No local EJB ref found in table model",row>=0);
676         String JavaDoc refName = (String JavaDoc) model.getValueAt(row,0);
677         model.removeRow(row);
678         ddObj.modelUpdatedFromUI();
679         utils.waitForDispatchThread();
680         utils.save();
681         Object JavaDoc resRef = utils.getBeanByProp(webapp.getEjbLocalRef(),"EjbRefName",refName);
682         assertNull("Local EJB ref was not deleted",resRef);
683         utils.checkNotInDDXML(".*<ejb-local-ref>.*<ejb-ref-name>"+refName+"</ejb-ref-name>.*</ejb-local-ref>.*");
684     }
685     
686     public void testAddRemoteEJBReference() throws Exception JavaDoc {
687         DDBeanTableModel model = utils.getModelByBean("ejb_refs");
688         model.addRow(new Object JavaDoc[]{"newEJBName2","Session","Remote","newHome2","newRemote","newLinked2","newDesc2"});
689         ddObj.modelUpdatedFromUI();
690         utils.waitForDispatchThread();
691         utils.save();
692         new StepIterator() {
693             public boolean step() throws Exception JavaDoc {
694                 return utils.contains(".*<ejb-ref>\\s*<description>newDesc2</description>\\s*<ejb-ref-name>newEJBName2</ejb-ref-name>\\s*<ejb-ref-type>Session</ejb-ref-type>\\s*<home>newHome2</home>\\s*<remote>newRemote</remote>\\s*<ejb-link>newLinked2</ejb-link>\\s*</ejb-ref>.*");
695             }
696         };
697         EjbRef ref= (EjbRef) utils.getBeanByProp(webapp.getEjbRef(),"EjbRefName","newEJBName2");
698         assertNotNull("New EJB Ref is not added.",ref);
699         utils.testProperties(ref,new String JavaDoc[]{"EjbRefName","EjbRefType","Home","Remote","EjbLink"},new Object JavaDoc[]{"newEJBName2","Session","newHome2","newRemote","newLinked2"});
700         assertEquals("newDesc2",ref.getDefaultDescription());
701         utils.checkInDDXML(".*<ejb-ref>\\s*<description>newDesc2</description>\\s*<ejb-ref-name>newEJBName2</ejb-ref-name>\\s*<ejb-ref-type>Session</ejb-ref-type>\\s*<home>newHome2</home>\\s*<remote>newRemote</remote>\\s*<ejb-link>newLinked2</ejb-link>\\s*</ejb-ref>.*");
702     }
703     
704     public void testModifyRemoteEJBReference() throws Exception JavaDoc {
705         DDBeanTableModel model = utils.getModelByBean("ejb_refs");
706         int row = utils.getRowIndexByProp(model,0,"EJBName2");
707         assertTrue("EJB ref not found in table model",row>=0);
708         utils.setTableRow(model,row,new Object JavaDoc[]{"EJBName2Mod","Entity","","EJBHome2Mod","EJBRemoteMod","LinkedEJB2Mod","EJBDesc2Mod"});
709         ddObj.modelUpdatedFromUI();
710         utils.waitForDispatchThread();
711         new StepIterator() {
712             public boolean step() throws Exception JavaDoc {
713                 return utils.contains(".*<ejb-ref>\\s*<description>EJBDesc2Mod</description>\\s*<ejb-ref-name>EJBName2Mod</ejb-ref-name>\\s*<ejb-ref-type>Entity</ejb-ref-type>\\s*<home>EJBHome2Mod</home>\\s*<remote>EJBRemoteMod</remote>\\s*<ejb-link>LinkedEJB2Mod</ejb-link>\\s*</ejb-ref>.*");
714             }
715         };
716         utils.save();
717         EjbRef ref= (EjbRef) utils.getBeanByProp(webapp.getEjbRef(),"EjbRefName","EJBName2Mod");
718         assertNotNull("EJB ref not modified",ref);
719         utils.testProperties(ref,new String JavaDoc[]{"EjbRefName","EjbRefType","Home","Remote","EjbLink"},new Object JavaDoc[]{"EJBName2Mod","Entity","EJBHome2Mod","EJBRemoteMod","LinkedEJB2Mod"});
720         assertEquals("EJBDesc2Mod",ref.getDefaultDescription());
721         utils.checkNotInDDXML(".*<ejb-ref>.*<ejb-ref-name>EJBName2</ejb-ref-name>.*</ejb-ref>.*");
722         utils.checkInDDXML(".*<ejb-ref>\\s*<description>EJBDesc2Mod</description>\\s*<ejb-ref-name>EJBName2Mod</ejb-ref-name>\\s*<ejb-ref-type>Entity</ejb-ref-type>\\s*<home>EJBHome2Mod</home>\\s*<remote>EJBRemoteMod</remote>\\s*<ejb-link>LinkedEJB2Mod</ejb-link>\\s*</ejb-ref>.*");
723     }
724     
725     public void testDelRemoteEJBReference() throws Exception JavaDoc {
726         DDBeanTableModel model = utils.getModelByBean("ejb_refs");
727         int row = utils.getRowIndexByProp(model,2,"Remote");
728         assertTrue("No remote EJB ref found in table model",row>=0);
729         String JavaDoc refName = (String JavaDoc) model.getValueAt(row,0);
730         model.removeRow(row);
731         ddObj.modelUpdatedFromUI();
732         utils.waitForDispatchThread();
733         utils.save();
734         Object JavaDoc resRef = utils.getBeanByProp(webapp.getEjbRef(),"EjbRefName",refName);
735         assertNull("Remote EJB ref was not deleted",resRef);
736         utils.checkNotInDDXML(".*<ejb-ref>.*<ejb-ref-name>"+refName+"</ejb-ref-name>.*</ejb-ref>.*");
737     }
738     
739     public void testExistingMsgDstReferences() throws Exception JavaDoc {
740         DDBeanTableModel model = utils.getModelByBean("message_dest_refs");
741         utils.testTable(model,new String JavaDoc[][] {{"MsgName","javax.jms.Topic","Produces","MsgLink","MsgDesc"}});
742         MessageDestinationRef[] refs = webapp.getMessageDestinationRef();
743         assertEquals("Wrong number of message dst references",1,refs.length);
744         utils.testProperties(refs[0],new String JavaDoc[]{"MessageDestinationRefName","MessageDestinationType","MessageDestinationUsage","MessageDestinationLink"},new Object JavaDoc[]{"MsgName","javax.jms.Topic","Produces","MsgLink"});
745         assertEquals("MsgDesc",refs[0].getDefaultDescription());
746     }
747     
748     public void testAddMsgDstReference() throws Exception JavaDoc {
749         DDBeanTableModel model = utils.getModelByBean("message_dest_refs");
750         model.addRow(new Object JavaDoc[]{"newMsgName","javax.jms.Queue","Consumes","newMsgLink","newMsgDesc"});
751         ddObj.modelUpdatedFromUI();
752         utils.waitForDispatchThread();
753         utils.save();
754         new StepIterator() {
755             public boolean step() throws Exception JavaDoc {
756                 return utils.contains(".*<message-destination-ref>\\s*<description>newMsgDesc</description>\\s*<message-destination-ref-name>newMsgName</message-destination-ref-name>\\s*<message-destination-type>javax.jms.Queue</message-destination-type>\\s*<message-destination-usage>Consumes</message-destination-usage>\\s*<message-destination-link>newMsgLink</message-destination-link>\\s*</message-destination-ref>.*");
757             }
758         };
759         MessageDestinationRef ref= (MessageDestinationRef) utils.getBeanByProp(webapp.getMessageDestinationRef(),"MessageDestinationRefName","newMsgName");
760         assertNotNull("Message dst ref is not added.",ref);
761         utils.testProperties(ref,new String JavaDoc[]{"MessageDestinationRefName","MessageDestinationType","MessageDestinationUsage","MessageDestinationLink"},new Object JavaDoc[]{"newMsgName","javax.jms.Queue","Consumes","newMsgLink"});
762         assertEquals("newMsgDesc",ref.getDefaultDescription());
763         utils.checkInDDXML(".*<message-destination-ref>\\s*<description>newMsgDesc</description>\\s*<message-destination-ref-name>newMsgName</message-destination-ref-name>\\s*<message-destination-type>javax\\.jms\\.Queue</message-destination-type>\\s*<message-destination-usage>Consumes</message-destination-usage>\\s*<message-destination-link>newMsgLink</message-destination-link>\\s*</message-destination-ref>.*");
764     }
765     
766     public void testModifyMsgDstReference() throws Exception JavaDoc {
767         DDBeanTableModel model = utils.getModelByBean("message_dest_refs");
768         int row = utils.getRowIndexByProp(model,0,"MsgName");
769         assertTrue("Message dst ref not found in table model",row>=0);
770         utils.setTableRow(model,row,new Object JavaDoc[]{"MsgNameMod","javax.jms.Queue","ConsumesProduces","MsgLinkMod","MsgDescMod"});
771         ddObj.modelUpdatedFromUI();
772         utils.waitForDispatchThread();
773         new StepIterator() {
774             public boolean step() throws Exception JavaDoc {
775                 return utils.contains(".*<message-destination-ref>\\s*<description>MsgDescMod</description>\\s*<message-destination-ref-name>MsgNameMod</message-destination-ref-name>\\s*<message-destination-type>javax.jms.Queue</message-destination-type>\\s*<message-destination-usage>ConsumesProduces</message-destination-usage>\\s*<message-destination-link>MsgLinkMod</message-destination-link>\\s*</message-destination-ref>.*");
776             }
777         };
778         utils.save();
779         MessageDestinationRef ref= (MessageDestinationRef) utils.getBeanByProp(webapp.getMessageDestinationRef(),"MessageDestinationRefName","MsgNameMod");
780         assertNotNull("EJB ref not modified",ref);
781         utils.testProperties(ref,new String JavaDoc[]{"MessageDestinationRefName","MessageDestinationType","MessageDestinationUsage","MessageDestinationLink"},new Object JavaDoc[]{"MsgNameMod","javax.jms.Queue","ConsumesProduces","MsgLinkMod"});
782         assertEquals("MsgDescMod",ref.getDefaultDescription());
783         utils.checkNotInDDXML(".*<message-destination-ref>.*<message-destination-ref-name>MsgName</message-destination-ref-name>.*</message-destination-ref>.*");
784         utils.checkInDDXML(".*<message-destination-ref>\\s*<description>MsgDescMod</description>\\s*<message-destination-ref-name>MsgNameMod</message-destination-ref-name>\\s*<message-destination-type>javax.jms.Queue</message-destination-type>\\s*<message-destination-usage>ConsumesProduces</message-destination-usage>\\s*<message-destination-link>MsgLinkMod</message-destination-link>\\s*</message-destination-ref>.*");
785     }
786     
787     public void testDelMsgDstReference() throws Exception JavaDoc {
788         DDBeanTableModel model = utils.getModelByBean("message_dest_refs");
789         String JavaDoc refName = (String JavaDoc) model.getValueAt(0,0);
790         model.removeRow(0);
791         ddObj.modelUpdatedFromUI();
792         utils.waitForDispatchThread();
793         utils.save();
794         Object JavaDoc resRef = utils.getBeanByProp(webapp.getMessageDestinationRef(),"MessageDestinationRefName",refName);
795         assertNull("Message dst ref was not deleted",resRef);
796         utils.checkNotInDDXML(".*<message-destination-ref>.*<message-destination-ref-name>"+refName+"</message-destination-ref-name>.*</message-destination-ref>.*");
797     }
798 }
799
Popular Tags