Martin Gainty created AXIS2-5893:
------------------------------------
Summary: test.wsdl not found in
ServiceClientTest::testWSDLWithImportsFromZIP
Key: AXIS2-5893
URL: https://issues.apache.org/jira/browse/AXIS2-5893
Project: Axis2
Issue Type: Bug
Components: kernel
Affects Versions: 1.7.6
Environment: jdk 1.8
mvn 3.3.3
Axis2 1.8.0-SNAPSHOT
Reporter: Martin Gainty
Priority: Minor
Fix For: 1.8.0
//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={new java.io.File(wsdlFullName)};
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("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 66 tobeJared[i]
already exists tobeJared[i]="+tobeJared[i]);
//continue; // Just in case it already exists
}
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(log.isDebugEnabled())
log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 72
buffer="+buffer);
int nRead = in.read(buffer, 0, buffer.length);
if(log.isDebugEnabled())
log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 76
nRead="+nRead);
if (nRead <= 0)
break;
if(log.isDebugEnabled())
log.debug("ServiceClientTest::testWSDLWithImportsFromZIP() LINE 79 before
out.write(buffer="+buffer);
out.write(buffer, 0, nRead);
}
}
if(in!=null) in.close();
if(out!=null)
{
out.flush();
try {
out.close();
}
catch(java.io.IOException ioe) {
log.error("ServiceClientTest::testWSDLWithImportsFromZIP LINE 105 out.close()
throws IOException messsage="+ioe.getMessage()); }
}
if(stream!=null)
{
stream.flush();
stream.close();
}
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")));
}
}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]