1 19 20 36 37 import java.io.*; 38 import java.util.*; 39 import org.w3c.dom.*; 40 41 import webapp.*; 42 43 44 public class TestWebAppDelegatorBaseBean extends BaseTest { 45 public static void main(String [] argv) { 46 TestWebAppDelegatorBaseBean o = new TestWebAppDelegatorBaseBean(); 47 if (argv.length > 0) 48 o.setDocumentDir(argv[0]); 49 try { 50 o.run(); 51 } catch (Exception e) { 52 e.printStackTrace(); 53 System.exit(1); 54 } 55 System.exit(0); 56 } 57 58 public void run() throws Exception { 59 WebAppDelegator webApp; 60 61 this.readDocument(); 62 63 out("creating the bean graph"); 64 webApp = WebAppDelegator.createGraph(doc); 65 66 out("bean graph created"); 68 webApp.write(out); 69 70 out("making some minor changes"); 71 webApp.setDescription(0, "Changed the description"); 72 webApp.getFilter(0).setFilterClass("foo"); 73 webApp.write(out); 74 75 out("set some goodnesses"); 76 SecurityConstraintType sc = new SecurityConstraintType(); 77 webApp.addSecurityConstraint(sc); 78 sc.setAuthConstraint(new AuthConstraintType()); 79 sc.getAuthConstraint().addGoodPresidentCandidate(true); 80 sc.getAuthConstraint().addGoodPresidentCandidate(false); 81 boolean firstCandiateGoodness = sc.getAuthConstraint().isGoodPresidentCandidate(0); 82 check(firstCandiateGoodness == true, "firstCandiateGoodness is good"); 83 boolean[] allCandidateGoodnesses = sc.getAuthConstraint().getGoodPresidentCandidate(); 84 check(allCandidateGoodnesses.length == 2, "2 candidates goodness"); 85 check(allCandidateGoodnesses[0] == true, "candidate 0 is good"); 86 check(allCandidateGoodnesses[1] == false, "candidate 1 is not good"); 87 webApp.write(out); 88 89 try { 90 webApp.validate(); 91 check(false, "Failed to get validate exception"); 92 } catch (org.netbeans.modules.schema2beans.ValidateException e) { 93 check(true, "Got good validate exception: "+e.getMessage()); 94 } 95 webApp.setVersion("2.4"); 96 try { 97 webApp.validate(); 98 check(false, "Failed to get validate exception"); 99 } catch (org.netbeans.modules.schema2beans.ValidateException e) { 100 check(true, "Got good validate exception: "+e.getMessage()); 101 } 102 sc.addWebResourceCollection(new WebResourceCollectionType()); 103 try { 104 webApp.validate(); 105 check(false, "Failed to get validate exception"); 106 } catch (org.netbeans.modules.schema2beans.ValidateException e) { 107 check(true, "Got good validate exception: "+e.getMessage()); 108 } 109 sc.getWebResourceCollection(0).setWebResourceName("blue"); 110 try { 111 webApp.validate(); 112 check(false, "Failed to get validate exception"); 113 } catch (org.netbeans.modules.schema2beans.ValidateException e) { 114 check(true, "Got good validate exception: "+e.getMessage()); 115 } 116 sc.getWebResourceCollection(0).addUrlPattern("*.html"); 117 webApp.write(out); 118 webApp.validate(); 119 120 out("Add some descriptions with xml:lang attributes."); 121 webApp.setDescriptionXmlLang(0, "en"); 122 webApp.addDescription("Das ist mein App."); 123 webApp.setDescriptionXmlLang(1, "de"); 124 webApp.validate(); 125 webApp.write(out); 126 127 out("Test multiple things"); 128 check("thing1".equals(webApp.getThing().getFilterName()), "thing1"); 129 check("thing2".equals(webApp.getThing2().getFilterName()), "thing2"); 130 check("thing3".equals(webApp.getThing3().getFilterName()), "thing3"); 131 132 webApp._setSchemaLocation("http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"); 133 webApp.write(out); 134 } 135 } 136 | Popular Tags |