Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5893

test.wsdl not found in ServiceClientTest::testWSDLWithImportsFromZIP

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Invalid
    • 1.7.6
    • 1.8.0
    • kernel
    • None
    • jdk 1.8
      mvn 3.3.3
      Axis2 1.8.0-SNAPSHOT

    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=

      {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")));
      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mgainty@hotmail.com Martin Gainty
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: