Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 29469 invoked from network); 9 Aug 2007 07:56:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Aug 2007 07:56:03 -0000 Received: (qmail 59614 invoked by uid 500); 9 Aug 2007 07:56:02 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 59546 invoked by uid 500); 9 Aug 2007 07:56:02 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 59537 invoked by uid 99); 9 Aug 2007 07:56:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2007 00:56:01 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2007 07:55:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2812A1A981A; Thu, 9 Aug 2007 00:55:34 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r564127 - in /incubator/cxf/trunk/tools/javato/ws: ./ src/main/java/org/apache/cxf/tools/java2ws/ src/main/java/org/apache/cxf/tools/java2wsdl/ src/main/java/org/apache/cxf/tools/java2wsdl/processor/ src/test/java/ src/test/java/org/ src/te... Date: Thu, 09 Aug 2007 07:55:33 -0000 To: cxf-commits@incubator.apache.org From: ema@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070809075534.2812A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ema Date: Thu Aug 9 00:55:31 2007 New Revision: 564127 URL: http://svn.apache.org/viewvc?view=rev&rev=564127 Log: [CXF-891] Create tool specification and java2ws container to check the input parameters Corrected typo errors Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml incubator/cxf/trunk/tools/javato/ws/src/test/java/ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java incubator/cxf/trunk/tools/javato/ws/src/test/resources/ - copied from r563798, incubator/cxf/trunk/tools/javato/test/src/test/resources/ Removed: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLContainer.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/Messages.properties incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml Modified: incubator/cxf/trunk/tools/javato/ws/pom.xml incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java Modified: incubator/cxf/trunk/tools/javato/ws/pom.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/pom.xml?view=diff&rev=564127&r1=564126&r2=564127 ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/pom.xml (original) +++ incubator/cxf/trunk/tools/javato/ws/pom.xml Thu Aug 9 00:55:31 2007 @@ -85,6 +85,13 @@ + org.apache.cxf + cxf-rt-frontend-jaxws + ${project.version} + test + + + com.sun.xml.bind jaxb-xjc @@ -99,7 +106,73 @@ + + + + org.apache.cxf + cxf-codegen-plugin + ${project.version} + + + generate-test-sources + generate-test-sources + + ${basedir}/target/generated/src/test/java + + + ${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_async.wsdl + + + ${basedir}/src/test/resources/java2wsdl_wsdl/doc_wrapped_simple.wsdl + + + ${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_doc_lit.wsdl + + + ${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_doc_wrapped_bare.wsdl + + + ${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_rpc_lit.wsdl + + + ${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl + + + ${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_bare.wsdl + + + ${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_fault.wsdl + + + + + wsdl2java + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-source + generate-test-sources + + add-test-source + + + + ${basedir}/src/test/generated + + + + + + + scm:svn:http://svn.apache.org/repos/asf/incubator/cxf/trunk/tools/javato/core scm:svn:https://svn.apache.org/repos/asf/incubator/cxf/trunk/tools/javato/ws Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java?view=diff&rev=564127&r1=564126&r2=564127 ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java (original) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWS.java Thu Aug 9 00:55:31 2007 @@ -41,7 +41,7 @@ try { j2w.run(); } catch (Exception ex) { - System.err.println("JavaToWSDL Error : " + ex.getMessage()); + System.err.println("JavaToWS Error : " + ex.getMessage()); System.err.println(); if (j2w.isVerbose()) { ex.printStackTrace(); @@ -72,8 +72,7 @@ private void run() throws Exception { ToolRunner.runTool(JavaToWSContainer.class, JavaToWSContainer.class - .getResourceAsStream("java2ws.xml"), false, args); - + .getResourceAsStream("java2ws.xml"), false, args); } private boolean isExitOnFinish() { @@ -83,5 +82,7 @@ } return "YES".equalsIgnoreCase(exit) || "TRUE".equalsIgnoreCase(exit); } + + } Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java?view=auto&rev=564127 ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java Thu Aug 9 00:55:31 2007 @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2ws; + +import java.util.HashSet; + +import org.apache.cxf.common.i18n.Message; +import org.apache.cxf.tools.common.AbstractCXFToolContainer; +import org.apache.cxf.tools.common.Processor; +import org.apache.cxf.tools.common.ToolConstants; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolException; +import org.apache.cxf.tools.common.toolspec.ToolSpec; +import org.apache.cxf.tools.common.toolspec.parser.BadUsageException; +import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor; +import org.apache.cxf.tools.java2wsdl.processor.JavaToProcessor; +import org.apache.cxf.tools.util.AnnotationUtil; + +public class JavaToWSContainer extends AbstractCXFToolContainer { + + private static final String TOOL_NAME = "java2wsdl"; + + public JavaToWSContainer(ToolSpec toolspec) throws Exception { + super(TOOL_NAME, toolspec); + } + + public void execute(boolean exitOnFinish) throws ToolException { + Processor processor = null; + try { + super.execute(exitOnFinish); + if (!hasInfoOption()) { + ToolContext env = new ToolContext(); + env.setParameters(getParametersMap(new HashSet())); + if (isVerboseOn()) { + env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE); + } + + processor = new JavaToProcessor(); + + processor.setEnvironment(env); + processor.process(); + } + } catch (ToolException ex) { + if (ex.getCause() instanceof BadUsageException) { + printUsageException(TOOL_NAME, (BadUsageException)ex.getCause()); + if (isVerboseOn()) { + ex.printStackTrace(); + } + } + throw ex; + } catch (Exception ex) { + System.err.println("Error : " + ex.getMessage()); + System.err.println(); + if (isVerboseOn()) { + ex.printStackTrace(); + } + + throw new ToolException(ex.getMessage(), ex.getCause()); + } + } + + public Class getServiceClass(ToolContext context) { + return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME), + getClass().getClassLoader()); + } + + + + public void checkParams(ErrorVisitor errors) throws ToolException { + if (errors.getErrors().size() > 0) { + Message msg = new Message("PARAMETER_MISSSING", LOG); + throw new ToolException(msg, new BadUsageException(getUsage(), errors)); + } + } +} + Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties?view=auto&rev=564127 ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/Messages.properties Thu Aug 9 00:55:31 2007 @@ -0,0 +1,27 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# +DIRECTORY_NOT_EXIST = Directory : {0} does not exist +NOT_A_DIRECTORY = {0} is not a directory +FILE_NOT_EXIST = File does not exist +NOT_A_FILE = {0} is not a file +PARAMETER_MISSING = Required parameter is missing + + Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml?view=auto&rev=564127 ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml (added) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml Thu Aug 9 00:55:31 2007 @@ -0,0 +1,215 @@ + + + + + + + + Examples : + + java2wsdl org.apache.hello_world_soap_http.Greeter java2ws -cp + ./tmp org.apache.hello_world_soap_http.Greeter java2ws -o + hello.wsdl org.apache.hello_world_soap_http.Greeter java2ws -o + hello.wsdl -t http://cxf.apache.org + org.apache.hello_world_soap_http.Greeter + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SEI class name + + + Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java?view=diff&rev=564127&r1=564126&r2=564127 ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java (original) +++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessor.java Thu Aug 9 00:55:31 2007 @@ -92,11 +92,13 @@ service.getName().getLocalPart() + ".wsdl"); File outputDir = getOutputDir(wsdlFile); - - generators.add(getWSDLGenerator(wsdlFile)); - generators.add(getWrapperBeanGenerator()); - generators.add(getFaultBeanGenerator()); - + if (context.containsKey(ToolConstants.CFG_WSDL)) { + generators.add(getWSDLGenerator(wsdlFile)); + } + if (context.containsKey(ToolConstants.CFG_WRAPPERBEAN)) { + generators.add(getWrapperBeanGenerator()); + generators.add(getFaultBeanGenerator()); + } generate(service, outputDir); System.setProperty(JAVA_CLASS_PATH, oldClassPath); LOG.log(Level.INFO, "RESUME_CP", oldClassPath); Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?view=auto&rev=564127 ============================================================================== --- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java (added) +++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java Thu Aug 9 00:55:31 2007 @@ -0,0 +1,90 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.tools.java2ws; + +import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLClassLoader; + +import org.apache.cxf.helpers.FileUtils; +import org.apache.cxf.tools.common.ToolContext; +import org.apache.cxf.tools.common.ToolTestBase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class JavaToWSTest extends ToolTestBase { + protected String cp; + protected ToolContext env; + protected File output; + + @Before + public void startUp() throws Exception { + env = new ToolContext(); + cp = System.getProperty("java.class.path"); + URL url = getClass().getResource("."); + output = new File(url.toURI()); + output = new File(output, "/generated/"); + FileUtils.mkDir(output); + } + + @After + public void tearDown() { + super.tearDown(); + System.setProperty("java.class.path", cp); + } + + @Test + public void testVersionOutput() throws Exception { + String[] args = new String[] {"-v"}; + JavaToWS.main(args); + assertNotNull(getStdOut()); + } + + @Test + public void testFlagWSDL() throws Exception { + String[] args = new String[] {"-wsdl", "-o", output.getPath() + "/tmp.wsdl", + "org.apache.hello_world_soap12_http.Greeter"}; + JavaToWS.main(args); + File wsdlFile = new File(output.getPath() + "/tmp.wsdl"); + assertTrue("wsdl is not generated", wsdlFile.exists()); + + + } + + protected String getClassPath() throws URISyntaxException { + ClassLoader loader = getClass().getClassLoader(); + StringBuffer classPath = new StringBuffer(); + if (loader instanceof URLClassLoader) { + URLClassLoader urlLoader = (URLClassLoader)loader; + for (URL url : urlLoader.getURLs()) { + File file; + file = new File(url.toURI()); + String filename = file.getAbsolutePath(); + if (filename.indexOf("junit") == -1) { + classPath.append(filename); + classPath.append(System.getProperty("path.separator")); + } + } + } + return classPath.toString(); + } + +}