1 25 26 package org.objectweb.jonas.jtests.clients.wsgen; 27 28 import java.io.File ; 29 import java.util.Enumeration ; 30 import java.util.jar.JarFile ; 31 import java.util.zip.ZipEntry ; 32 33 import junit.framework.Test; 34 import junit.framework.TestSuite; 35 36 37 40 public class F_WsGen extends A_WsGen { 41 42 public F_WsGen(String name) { 43 super(name); 44 } 45 46 public static Test suite() { 47 return new TestSuite(F_WsGen.class); 48 } 49 50 public void setUp() throws Exception { 51 super.setUp(); 52 } 53 54 public void tearDown() throws Exception { 55 super.tearDown(); 56 } 57 58 64 65 public void testWebappEndpointAlone() throws Exception { 66 67 String [] entries = new String [] { "META-INF/MANIFEST.MF", 69 "WEB-INF/wsdl/AddressBookPort.wsdl", 70 "WEB-INF/wsdl/AddressBook.xsd", 71 "WEB-INF/web.xml", 72 "WEB-INF/webservices.xml", 73 "WEB-INF/jonas-webservices.xml", 74 "WEB-INF/mapping.xml", 75 "WEB-INF/deploy-server-0.wsdd", 76 "WEB-INF/classes/org/objectweb/jonas/jtests/servlets/endpoint/Address.class", 77 "WEB-INF/classes/org/objectweb/jonas/jtests/servlets/endpoint/Address_Helper.class", 78 "WEB-INF/classes/org/objectweb/jonas/jtests/servlets/endpoint/AddressBook.class", 79 "WEB-INF/classes/org/objectweb/jonas/jtests/servlets/endpoint/AddressBookImpl.class", 80 "WEB-INF/classes/org/objectweb/jonas/jtests/servlets/endpoint/AddressBookException.class", 81 "WEB-INF/classes/org/objectweb/jonas/jtests/servlets/endpoint/AddressBookException_Helper.class"}; 82 83 JarFile alone = new JarFile (getJonasBaseFile("webapps" + File.separator + "webendpoint.war")); 84 85 checkEntries(entries, alone); 86 87 assertEquals("entries number doesn't match", entries.length, countEntries(alone)); 88 89 } 90 91 public void testWsClientEjb() throws Exception { 92 93 String path = "org/objectweb/jonas/jtests/beans/wsclient/"; 95 String [] entries = new String [] { "META-INF/MANIFEST.MF", 96 "META-INF/jonas-ejb-jar.xml", 97 "META-INF/ejb-jar.xml", 98 "META-INF/wsdl/query.wsdl"}; 99 100 JarFile wsclient = new JarFile (getJonasBaseFile("ejbjars" + File.separator + "wsclient.jar")); 101 102 checkEntries(entries, wsclient); 103 104 } 105 106 public void testTimeEndpoint() throws Exception { 107 String [] entries = new String [] { "META-INF/application.xml", 109 "META-INF/MANIFEST.MF", 110 "time.war", 111 "time.jar", 112 "time-client.jar"}; 113 114 JarFile time = new JarFile (getJonasBaseFile("apps" + File.separator + "time-test.ear")); 115 116 checkEntries(entries, time); 117 118 assertEquals("entries number doesn't match", 5, countEntries(time)); 119 120 String tmp = unpackJar(time); 122 123 JarFile web = new JarFile (tmp + File.separator 125 + "time.war"); 126 String [] webEntries = new String [] { "META-INF/MANIFEST.MF", 127 "WEB-INF/web.xml", 128 "WEB-INF/deploy-server-0.wsdd"}; 129 130 assertEquals("web entries number doesn't match", webEntries.length, countEntries(web)); 133 134 deleteDirectory(tmp); 135 136 } 137 138 public void checkEntries(String [] entries, JarFile file) { 139 140 for (int i = 0; i < entries.length; i++) { 141 ZipEntry ze = file.getEntry(entries[i]); 142 assertNotNull("missing entry '" + entries[i] + "' in '" + file.getName() + "'", ze); 143 } 144 } 145 146 public int countEntries(JarFile file) { 147 Enumeration e = file.entries(); 148 int count = 0; 149 while (e.hasMoreElements()) { 150 ZipEntry ze = (ZipEntry ) e.nextElement(); 151 if (!ze.getName().endsWith("/")) { 153 count++; 154 } 155 156 } 157 return count; 158 } 159 160 161 public static void main (String args[]) { 162 String testtorun = null; 163 for (int argn = 0; argn < args.length; argn++) { 165 String s_arg = args[argn]; 166 if (s_arg.equals("-n")) { 167 testtorun = args[++argn]; 168 } 169 } 170 if (testtorun == null) { 171 junit.textui.TestRunner.run(suite()); 172 } else { 173 junit.textui.TestRunner.run(new F_WsGen(testtorun)); 174 } 175 } 176 177 } 178 | Popular Tags |