1 19 20 package org.netbeans.test.j2ee.multiview; 21 22 import javax.swing.text.JTextComponent ; 23 import java.awt.Component ; 24 import java.io.File ; 25 import javax.swing.JButton ; 26 import javax.swing.JCheckBox ; 27 import javax.swing.JLabel ; 28 import javax.swing.JPanel ; 29 import javax.swing.JRadioButton ; 30 import javax.swing.JTextArea ; 31 import javax.swing.JTextField ; 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 62 public class PagesAndReferencesDDTest extends JellyTestCase{ 63 64 65 public PagesAndReferencesDDTest(String testName) { 66 super(testName); 67 } 68 69 protected void tearDown() throws Exception { 70 super.tearDown(); 71 } 72 73 protected void setUp() throws Exception { 74 super.setUp(); 75 } 76 77 public static final String WEB_PROJECT_NAME = "TestWebApp"; 78 public static final String 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 126 public static void main(java.lang.String [] args) { 127 TestRunner.run(suite()); 129 } 130 131 public void testOpenProject() throws Exception { 132 File projectDir = new File (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 panel) { 148 Component [] 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 ) { 152 System.out.println(((JTextField )comp[i]).getText()); 153 } 154 if(comp[i] instanceof JTextArea ) { 155 System.out.println(((JTextArea )comp[i]).getText()); 156 } 157 if(comp[i] instanceof JLabel ) { 158 System.out.println(((JLabel )comp[i]).getText()); 159 } 160 if(comp[i] instanceof JCheckBox ) { 161 System.out.println(((JCheckBox )comp[i]).isSelected()); 162 } 163 if(comp[i] instanceof JRadioButton ) { 164 System.out.println(((JRadioButton )comp[i]).getName()); 165 } 166 if(comp[i] instanceof JButton ) { 167 System.out.println(((JButton )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 { 177 JPanel panel = utils.getInnerSectionPanel("welcome_files"); 178 Component [] comp = panel.getComponents(); 179 assertEquals("Welcome pages doesn't match","index.jsp",((JTextField )comp[1]).getText()); 180 String [] 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 { 186 JPanel panel = utils.getInnerSectionPanel("welcome_files"); 187 Component [] comp = panel.getComponents(); 188 utils.setText((JTextField )comp[1],"index2.jsp, index3.jsp"); 189 ((Component )comp[2]).requestFocus(); 190 new StepIterator() { 191 public boolean step() throws Exception { 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 [] 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 { 206 JPanel panel = utils.getInnerSectionPanel("welcome_files"); 207 Component [] comp = panel.getComponents(); 208 utils.setText((JTextField )comp[1],"index.jsp"); 209 ((Component )comp[2]).requestFocus(); 210 utils.waitForDispatchThread(); 211 new StepIterator() { 212 public boolean step() throws Exception { 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 [] 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 { 227 JPanel panel = utils.getInnerSectionPanel("error_pages"); 228 Component [] 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 (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 []{"Location","ErrorCode","ExceptionType"}, new Object []{"/index.jsp",new Integer (404),null}); 236 } 237 238 public void testAddErrorPage() throws Exception { 239 JPanel panel = utils.getInnerSectionPanel("error_pages"); 240 Component [] comp = panel.getComponents(); 241 DDBeanTableModel model = (DDBeanTableModel) ((ErrorPagesTablePanel)comp[1]).getTable().getModel(); 242 model.addRow(new Object []{"/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 []{"Location","ErrorCode","ExceptionType"}, new Object []{"/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 []{"/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 { 263 JPanel panel = utils.getInnerSectionPanel("error_pages"); 264 Component [] 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 { 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 { 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 []{"Location","ErrorCode","ExceptionType"},new Object []{"/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 { 304 JPanel panel = utils.getInnerSectionPanel("error_pages"); 305 Component [] 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 { 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 [] {"head.jsp","head2.jsp"},new String [] {"foot.jsp","foot2.jsp"},new String []{"/*"},new boolean[]{true,true,true}); 329 } 330 331 public void testModifyProperyGroup() throws Exception { 332 JspPropertyGroup propertyGrp = webapp.getSingleJspConfig().getJspPropertyGroup(0); 333 JPanel panel = utils.getInnerSectionPanel(propertyGrp); 334 Component [] comp = panel.getComponents(); 335 panel.requestFocus(); 336 utils.waitForDispatchThread(); 337 utils.setText((JTextComponent )comp[1],"newname"); 338 comp[3].requestFocus(); 339 new StepIterator() { 340 public boolean step() throws Exception { 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 )comp[3],"newdesc"); 345 comp[5].requestFocus(); 346 new StepIterator() { 347 public boolean step() throws Exception { 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 )comp[5],"*"); 352 comp[9].requestFocus(); 353 new StepIterator() { 354 public boolean step() throws Exception { 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 )comp[9],"ISO-8859-2"); 359 comp[10].requestFocus(); 360 new StepIterator() { 361 public boolean step() throws Exception { 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 )comp[10]).setSelected(false); 366 ddObj.modelUpdatedFromUI(); 367 comp[14].requestFocus(); 368 utils.waitForDispatchThread(); 369 new StepIterator() { 370 public boolean step() throws Exception { 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 )comp[11]).setSelected(false); 375 comp[14].requestFocus(); 376 ddObj.modelUpdatedFromUI(); 377 utils.waitForDispatchThread(); 378 new StepIterator() { 379 public boolean step() throws Exception { 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 )comp[12]).setSelected(false); 384 ddObj.modelUpdatedFromUI(); 385 comp[14].requestFocus(); 386 ddObj.modelUpdatedFromUI(); 387 new StepIterator() { 388 public boolean step() throws Exception { 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 )comp[14],"prelude.jsp"); 393 comp[17].requestFocus(); 394 new StepIterator() { 395 public boolean step() throws Exception { 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 )comp[17],"coda.jsp"); 400 comp[1].requestFocus(); 401 new StepIterator() { 402 public boolean step() throws Exception { 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 []{"prelude.jsp"},new String []{"coda.jsp"},new String []{"*"},new boolean[]{false,false,false}); 408 String 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 { 425 JspPropertyGroup propertyGrp = webapp.getSingleJspConfig().getJspPropertyGroup(0); 426 final String name = propertyGrp.getDefaultDisplayName(); 427 webapp.getSingleJspConfig().removeJspPropertyGroup(propertyGrp); 428 ddObj.modelUpdatedFromUI(); 429 utils.waitForDispatchThread(); 430 new StepIterator() { 431 public boolean step() throws Exception { 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 { 443 ddObj.openView(4); 444 utils.waitForDispatchThread(); 445 DDBeanTableModel model = utils.getModelByBean("env_entries"); 446 utils.testTable(model,new String [][]{{"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 []{"EnvEntryName","EnvEntryType","EnvEntryValue"},new Object []{"EnvName","java.lang.Character","EnvValue"}); 450 assertEquals("EnvDesc",entries[0].getDefaultDescription()); 451 } 452 453 public void testAddEnvEntry() throws Exception { 454 DDBeanTableModel model = utils.getModelByBean("env_entries"); 455 model.addRow(new Object []{"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 []{"EnvEntryName","EnvEntryType","EnvEntryValue"},new Object []{"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 { 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 []{"EnvNameMod","java.lang.Double","EnvValueMod","EnvDescMod"}); 471 ddObj.modelUpdatedFromUI(); 472 utils.waitForDispatchThread(); 473 new StepIterator() { 474 public boolean step() throws Exception { 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 []{"EnvEntryName","EnvEntryType","EnvEntryValue"},new Object []{"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 { 487 DDBeanTableModel model = utils.getModelByBean("env_entries"); 488 String entryName = (String ) model.getValueAt(0,0); 489 model.removeRow(0); 490 ddObj.modelUpdatedFromUI(); 491 utils.waitForDispatchThread(); 492 utils.save(); 493 Object 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 { 499 DDBeanTableModel model = utils.getModelByBean("res_refs"); 500 utils.testTable(model,new String [][]{{"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 []{"ResRefName","ResType","ResAuth","ResSharingScope"},new Object []{"ResName","javax.mail.Session","Application","Unshareable"}); 504 assertEquals("ResDesc",refs[0].getDefaultDescription()); 505 } 506 507 public void testAddResReference() throws Exception { 508 DDBeanTableModel model = utils.getModelByBean("res_refs"); 509 model.addRow(new Object []{"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 { 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 []{"ResRefName","ResType","ResAuth","ResSharingScope"},new Object []{"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 { 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 []{"ResNameMod","javax.sql.DataSource","Container","Shareable","ResDescMod"}); 530 ddObj.modelUpdatedFromUI(); 531 utils.waitForDispatchThread(); 532 new StepIterator() { 533 public boolean step() throws Exception { 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 []{"ResRefName","ResType","ResAuth","ResSharingScope"},new Object []{"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 { 547 DDBeanTableModel model = utils.getModelByBean("res_refs"); 548 String resRefName = (String ) model.getValueAt(0,0); 549 model.removeRow(0); 550 ddObj.modelUpdatedFromUI(); 551 utils.waitForDispatchThread(); 552 utils.save(); 553 Object 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 { 559 DDBeanTableModel model = utils.getModelByBean("res_env_refs"); 560 utils.testTable(model,new String [][]{{"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 []{"ResourceEnvRefName","ResourceEnvRefType"},new Object []{"ResEnvName","javax.jms.Topic"}); 564 assertEquals("ResEnvdesc",refs[0].getDefaultDescription()); 565 } 566 567 public void testAddResEnvReference() throws Exception { 568 DDBeanTableModel model = utils.getModelByBean("res_env_refs"); 569 model.addRow(new Object []{"newResEnvName","javax.jms.Queue","newResEnvDesc"}); 570 ddObj.modelUpdatedFromUI(); 571 utils.waitForDispatchThread(); 572 utils.save(); 573 new StepIterator() { 574 public boolean step() throws Exception { 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 []{"ResourceEnvRefName","ResourceEnvRefType"},new Object []{"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 { 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 []{"ResEnvNameMod","javax.jms.Queue","ResEnvDescMod"}); 590 ddObj.modelUpdatedFromUI(); 591 utils.waitForDispatchThread(); 592 new StepIterator() { 593 public boolean step() throws Exception { 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 []{"ResourceEnvRefName","ResourceEnvRefType"},new Object []{"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 { 607 DDBeanTableModel model = utils.getModelByBean("res_env_refs"); 608 String resEnvRefName = (String ) model.getValueAt(0,0); 609 model.removeRow(0); 610 ddObj.modelUpdatedFromUI(); 611 utils.waitForDispatchThread(); 612 utils.save(); 613 Object 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 { 619 DDBeanTableModel model = utils.getModelByBean("ejb_refs"); 620 String [][] 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 []{"EjbRefName","EjbRefType","LocalHome","Local","EjbLink"},new Object []{"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 []{"EjbRefName","EjbRefType","Home","Remote","EjbLink"},new Object []{"EJBName2","Session","EJBHome2","EJBRemote","LinkedEJB2"}); 630 assertEquals("EJBDesc2",refs2[0].getDefaultDescription()); 631 } 632 633 public void testAddLocalEJBReference() throws Exception { 634 DDBeanTableModel model = utils.getModelByBean("ejb_refs"); 635 model.addRow(new Object []{"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 { 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 []{"EjbRefName","EjbRefType","LocalHome","Local","EjbLink"},new Object []{"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 { 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 []{"EJBNameMod","Session","","EJBHomeMod","EJBLocalMod","LinkedEJBMod","EJBDescMod"}); 656 ddObj.modelUpdatedFromUI(); 657 utils.waitForDispatchThread(); 658 new StepIterator() { 659 public boolean step() throws Exception { 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 []{"EjbRefName","EjbRefType","LocalHome","Local","EjbLink"},new Object []{"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 { 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 refName = (String ) model.getValueAt(row,0); 677 model.removeRow(row); 678 ddObj.modelUpdatedFromUI(); 679 utils.waitForDispatchThread(); 680 utils.save(); 681 Object 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 { 687 DDBeanTableModel model = utils.getModelByBean("ejb_refs"); 688 model.addRow(new Object []{"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 { 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 []{"EjbRefName","EjbRefType","Home","Remote","EjbLink"},new Object []{"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 { 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 []{"EJBName2Mod","Entity","","EJBHome2Mod","EJBRemoteMod","LinkedEJB2Mod","EJBDesc2Mod"}); 709 ddObj.modelUpdatedFromUI(); 710 utils.waitForDispatchThread(); 711 new StepIterator() { 712 public boolean step() throws Exception { 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 []{"EjbRefName","EjbRefType","Home","Remote","EjbLink"},new Object []{"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 { 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 refName = (String ) model.getValueAt(row,0); 730 model.removeRow(row); 731 ddObj.modelUpdatedFromUI(); 732 utils.waitForDispatchThread(); 733 utils.save(); 734 Object 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 { 740 DDBeanTableModel model = utils.getModelByBean("message_dest_refs"); 741 utils.testTable(model,new String [][] {{"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 []{"MessageDestinationRefName","MessageDestinationType","MessageDestinationUsage","MessageDestinationLink"},new Object []{"MsgName","javax.jms.Topic","Produces","MsgLink"}); 745 assertEquals("MsgDesc",refs[0].getDefaultDescription()); 746 } 747 748 public void testAddMsgDstReference() throws Exception { 749 DDBeanTableModel model = utils.getModelByBean("message_dest_refs"); 750 model.addRow(new Object []{"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 { 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 []{"MessageDestinationRefName","MessageDestinationType","MessageDestinationUsage","MessageDestinationLink"},new Object []{"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 { 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 []{"MsgNameMod","javax.jms.Queue","ConsumesProduces","MsgLinkMod","MsgDescMod"}); 771 ddObj.modelUpdatedFromUI(); 772 utils.waitForDispatchThread(); 773 new StepIterator() { 774 public boolean step() throws Exception { 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 []{"MessageDestinationRefName","MessageDestinationType","MessageDestinationUsage","MessageDestinationLink"},new Object []{"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 { 788 DDBeanTableModel model = utils.getModelByBean("message_dest_refs"); 789 String refName = (String ) model.getValueAt(0,0); 790 model.removeRow(0); 791 ddObj.modelUpdatedFromUI(); 792 utils.waitForDispatchThread(); 793 utils.save(); 794 Object 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 |