Details
Description
//current algo to locate test.wsdl never locates entry in test-zip.zip
//this will add the test.wsdl entry allowing find method to locate 'test.wsdl'
@Test
public void testWSDLWithImportsFromZIP() throws Exception
{
OnDemandLogger log = new OnDemandLogger(ServiceClientTest.class);
java.io.FileInputStream in=null;
ConfigurationContext configContext = ConfigurationContextFactory.createEmptyConfigurationContext();
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 45 configContext="+configContext);
String basedir = System.getProperty("basedir");
if (basedir == null) basedir = ".";
String zipName="/AXIS2-~1/modules/kernel/target/test-zip.zip";
String wsdlFullName="/AXIS2-~1/modules/kernel/target/test-zip.zip!/test.wsdl";
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 49 zipName="+zipName);
byte buffer[] = new byte[1024];
// Open archive file
FileOutputStream stream = new FileOutputStream(zipName);
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 53 stream="+stream);
JarOutputStream out = new JarOutputStream(stream, new Manifest());
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 55 JarOutputStream out="+out);
File []tobeJared=
;
for (int i = 0; i < tobeJared.length; i++)
{
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 64 tobeJared[i]="+tobeJared[i]);
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 65 tobeJared[i].isDirectory()="+tobeJared[i].isDirectory());
if (tobeJared[i] == null || !tobeJared[i].exists() || tobeJared[i].isDirectory())
if(log.isDebugEnabled()) log.debug("Adding jar entry=" + tobeJared[i].getName());
// Add archive entry
JarEntry jarAdd = new JarEntry(tobeJared[i].getName());
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 63 jarAdd="+jarAdd);
jarAdd.setTime(tobeJared[i].lastModified());
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 65 before out.putNextEntry(jarAdd) out="out" jarAdd="+jarAdd);
out.putNextEntry(jarAdd);
// Write test.wsdl file to archive
in = new java.io.FileInputStream(tobeJared[i]);
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 71 FileInputStream in="+in);
while (true)
}
if(in!=null) in.close();
if(out!=null)
{
out.flush();
try
catch(java.io.IOException ioe)
{ log.error("ServiceClientTest::testWSDLWithImportsFromZIP LINE 105 out.close() throws IOException messsage="+ioe.getMessage()); } }
if(stream!=null)
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 86 Adding completed OK");
URL zipUrl = new File(zipName).toURI().toURL(); //URL zipUrl = new File(basedir, "target/test-zip.zip").toURI().toURL();
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP LINE 63 zipURL="+zipUrl);
URL wsdlUrl = new File(wsdlFullName).toURI().toURL(); //URL wsdlUrl=new URL("jar:" + zipUrl+ "
test.wsdl");
if(log.isDebugEnabled()) log.debug("ServiceClientTest::testWSDLWithImportsFromZIP LINE 64 wsdlURL="+wsdlUrl.getFile() );
ServiceClient serviceClient = new ServiceClient(configContext, wsdlUrl, new QName("urn:test", "EchoService"), "EchoPort");
//make sure test.xsd is in same folder as your test.wsdl before implementing
List<XmlSchema> schemas = serviceClient.getAxisService().getSchema();
assertEquals(1, schemas.size());
XmlSchema schema = schemas.get(0);
assertNotNull(schema.getTypeByName(new QName("urn:test", "echoResponse")));
}
}