Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 35963 invoked from network); 25 Jan 2011 11:44:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Jan 2011 11:44:55 -0000 Received: (qmail 41411 invoked by uid 500); 25 Jan 2011 11:44:54 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 41294 invoked by uid 500); 25 Jan 2011 11:44:53 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 41287 invoked by uid 99); 25 Jan 2011 11:44:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jan 2011 11:44:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jan 2011 11:44:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 53CDC2388A02; Tue, 25 Jan 2011 11:44:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1063238 - in /cxf/branches/2.3.x-fixes: ./ tools/corba/src/main/java/org/apache/cxf/tools/corba/ tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/ tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ too... Date: Tue, 25 Jan 2011 11:44:31 -0000 To: commits@cxf.apache.org From: ffang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110125114431.53CDC2388A02@eris.apache.org> Author: ffang Date: Tue Jan 25 11:44:30 2011 New Revision: 1063238 URL: http://svn.apache.org/viewvc?rev=1063238&view=rev Log: Merged revisions 1063236 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1063236 | ffang | 2011-01-25 19:35:43 +0800 (二, 25 1 2011) | 1 line [CXF-3280]idl2wsdl does not process multiple include directories -I correctly. ........ Added: cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/Parent.idl - copied unchanged from r1063236, cxf/trunk/tools/corba/src/test/resources/idl/Parent.idl cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/expected_Parent.wsdl - copied unchanged from r1063236, cxf/trunk/tools/corba/src/test/resources/idl/expected_Parent.wsdl cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/subdir1/ - copied from r1063236, cxf/trunk/tools/corba/src/test/resources/idl/subdir1/ cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/subdir1/Included1.idl - copied unchanged from r1063236, cxf/trunk/tools/corba/src/test/resources/idl/subdir1/Included1.idl cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/subdir2/ - copied from r1063236, cxf/trunk/tools/corba/src/test/resources/idl/subdir2/ cxf/branches/2.3.x-fixes/tools/corba/src/test/resources/idl/subdir2/Included2.idl - copied unchanged from r1063236, cxf/trunk/tools/corba/src/test/resources/idl/subdir2/Included2.idl Modified: cxf/branches/2.3.x-fixes/ (props changed) cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java Propchange: cxf/branches/2.3.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java?rev=1063238&r1=1063237&r2=1063238&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java (original) +++ cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java Tue Jan 25 11:44:30 2011 @@ -51,7 +51,9 @@ public class IDLToWSDL extends AbstractC } private Set getArrayKeys() { - return new HashSet(); + Set arrayKeys = new HashSet(); + arrayKeys.add(ToolCorbaConstants.CFG_INCLUDEDIR); + return arrayKeys; } public void execute(boolean exitOnFinish) { @@ -144,7 +146,7 @@ public class IDLToWSDL extends AbstractC if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) { env.put(ToolCorbaConstants.CFG_INCLUDEDIR, - doc.getParameter(ToolCorbaConstants.CFG_INCLUDEDIR)); + doc.getParameters(ToolCorbaConstants.CFG_INCLUDEDIR)); } if (env.optionSet(ToolCorbaConstants.CFG_WSDLOUTPUTFILE)) { env.put(ToolCorbaConstants.CFG_WSDLOUTPUTFILE, Modified: cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java?rev=1063238&r1=1063237&r2=1063238&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java (original) +++ cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/DefaultIncludeResolver.java Tue Jan 25 11:44:30 2011 @@ -20,10 +20,17 @@ package org.apache.cxf.tools.corba.idlpreprocessor; import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.util.Arrays; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.cxf.common.logging.LogUtils; + /** * @author lk @@ -31,6 +38,7 @@ import java.util.Arrays; */ public class DefaultIncludeResolver implements IncludeResolver { + private static final Logger LOG = LogUtils.getL7dLogger(DefaultIncludeResolver.class); private final File[] userIdlDirs; public DefaultIncludeResolver(File... idlDirs) { @@ -61,8 +69,21 @@ public class DefaultIncludeResolver impl // offload slash vs backslash to URL machinery URL searchDirURL = searchDirURI.toURL(); final URL url = new URL(searchDirURL, spec); - // TODO: if "file in URL exists" - return url; + + // Check if file in URL exists, otherwise try next searchDir + try { + // If we can open a stream, the file exists + InputStream str = url.openStream(); + str.close(); + return url; + } catch (IOException ioe) { + if (LOG.isLoggable(Level.WARNING)) { + LOG.fine("Not able to resolve " + + spec + + "from " + + searchDirURL.toString()); + } + } } catch (MalformedURLException e) { final PreprocessingException preprocessingException = new PreprocessingException( "Unable to resolve user include '" + spec + "' in '" Modified: cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java?rev=1063238&r1=1063237&r2=1063238&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java (original) +++ cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLProcessor.java Tue Jan 25 11:44:30 2011 @@ -21,7 +21,6 @@ package org.apache.cxf.tools.corba.proce import java.io.File; import java.net.URL; import java.util.HashMap; -import java.util.StringTokenizer; import antlr.TokenStreamHiddenTokenFilter; import antlr.collections.AST; @@ -85,17 +84,13 @@ public class IDLProcessor implements Pro private DefaultIncludeResolver getDefaultIncludeResolver(File currentDir) { DefaultIncludeResolver includeResolver; - if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) { - String includedDirs = env.get(ToolCorbaConstants.CFG_INCLUDEDIR).toString(); - StringTokenizer tok = new StringTokenizer(includedDirs, ""); - File[] includeDirs = new File[tok.countTokens()]; - int i = 0; - while (tok.hasMoreTokens()) { - String includeDir = tok.nextToken(); - File infile = new File(includeDir); - includeDirs[i] = infile; - i++; + if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) { + String[] includedDirs = (String[]) env.get(ToolCorbaConstants.CFG_INCLUDEDIR); + File[] includeDirs = new File[includedDirs.length]; + for (int i = 0; i < includedDirs.length; i++) { + includeDirs[i] = new File(includedDirs[i]); } + includeResolver = new DefaultIncludeResolver(includeDirs); } else { includeResolver = new DefaultIncludeResolver(currentDir); Modified: cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java?rev=1063238&r1=1063237&r2=1063238&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java (original) +++ cxf/branches/2.3.x-fixes/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java Tue Jan 25 11:44:30 2011 @@ -89,7 +89,11 @@ public class OperationVisitor extends Vi WSDLASTVisitor wsdlVisitor) { boolean result = false; AST node2 = node.getFirstChild(); - if (node2.getType() == IDLTokenTypes.LITERAL_oneway) { + + if (null == node2) { + // throw whatever appropriate error + // or do nothing and return false + } else if (node2.getType() == IDLTokenTypes.LITERAL_oneway) { result = true; } else { int type = node2.getType(); Modified: cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java?rev=1063238&r1=1063237&r2=1063238&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java (original) +++ cxf/branches/2.3.x-fixes/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java Tue Jan 25 11:44:30 2011 @@ -319,4 +319,24 @@ public class IDLToWSDLTest extends ToolT assertEquals("IDLToWSDL Failed", noError, exc); doTestGeneratedWsdl(expected, actual); } + + public void testMultipleIncludes() throws Exception { + File input = new File(getClass().getResource("/idl/Parent.idl").toURI()); + File actual = new File(output, "Parent.wsdl"); + File expected = + new File(getClass().getResource("/idl/expected_Parent.wsdl").toURI()); + + File include1Dir = new File(getClass().getResource("/idl/subdir1").toURI()); + File include2Dir = new File(getClass().getResource("/idl/subdir2").toURI()); + + String[] args = new String[] {"-ow", "Parent.wsdl", + "-o", output.toString(), + "-I", include1Dir.toString(), + "-I", include2Dir.toString(), + input.toString() + }; + int exc = execute(args); + assertEquals("IDLToWSDL Failed", noError, exc); + doTestGeneratedWsdl(expected, actual); + } }