cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buhhu...@apache.org
Subject [cxf] branch master updated: cxf-core: cleanup URIParserUtil; use String.isEmpty(); replace custom impl with Java one (#501)
Date Mon, 21 Jan 2019 19:33:14 GMT
This is an automated email from the ASF dual-hosted git repository.

buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 6d508b3  cxf-core: cleanup URIParserUtil; use String.isEmpty(); replace custom impl with Java one (#501)
6d508b3 is described below

commit 6d508b399265de89b73059a187e0264861bd07fc
Author: Alexey Markevich <amarkevich@talend.com>
AuthorDate: Mon Jan 21 22:33:09 2019 +0300

    cxf-core: cleanup URIParserUtil; use String.isEmpty(); replace custom impl with Java one (#501)
---
 .../bus/extension/TextExtensionFragmentParser.java |  20 +--
 .../org/apache/cxf/common/util/PackageUtils.java   |  91 ++++---------
 .../org/apache/cxf/common/util/StringUtils.java    |   9 +-
 .../org/apache/cxf/common/util/URIParserUtil.java  | 151 ---------------------
 .../AbstractInDatabindingInterceptor.java          |   2 +-
 .../java/org/apache/cxf/staxutils/StaxUtils.java   |  16 +--
 .../apache/cxf/staxutils/W3CDOMStreamWriter.java   |   2 +-
 .../apache/cxf/staxutils/W3CNamespaceContext.java  |   9 +-
 .../transform/DelegatingNamespaceContext.java      |   6 +-
 .../cxf/staxutils/transform/InTransformReader.java |   8 +-
 .../staxutils/transform/OutTransformWriter.java    |  22 +--
 .../org/apache/cxf/ws/addressing/ContextUtils.java |   2 +-
 .../apache/cxf/common/util/PackageUtilsTest.java   |  26 ++++
 .../apache/cxf/common}/util/URIParserUtilTest.java |  36 +++--
 .../apache/cxf/common/util/URIParserUtilsTest.java |  56 --------
 .../staxutils/transform/TransformTestUtils.java    |   2 +-
 .../java/org/apache/cxf/jaxws/ServiceImpl.java     |   5 +-
 .../org/apache/cxf/tools/common/ToolContext.java   |   7 +-
 .../apache/cxf/tools/common/model/JavaField.java   |   8 +-
 .../tools/corba/common/ProcessorEnvironment.java   |   4 +-
 .../processor/internal/jaxws/FaultBean.java        |   5 +-
 .../processor/internal/jaxws/Wrapper.java          |   3 +-
 .../jaxws/processor/internal/ProcessorUtil.java    |  10 +-
 .../cxf/tools/wsdlto/jaxws/CodeGenBugTest.java     |  19 +--
 24 files changed, 137 insertions(+), 382 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java b/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java
index dea7058..45a082b 100644
--- a/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java
+++ b/core/src/main/java/org/apache/cxf/bus/extension/TextExtensionFragmentParser.java
@@ -29,13 +29,11 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import java.util.regex.Pattern;
 
 import org.apache.cxf.common.logging.LogUtils;
 
 public class TextExtensionFragmentParser {
     private static final Logger LOG = LogUtils.getL7dLogger(TextExtensionFragmentParser.class);
-    private static Pattern colonPattern = Pattern.compile(":");
 
     final ClassLoader loader;
     public TextExtensionFragmentParser(ClassLoader loader) {
@@ -43,21 +41,11 @@ public class TextExtensionFragmentParser {
     }
 
     public List<Extension> getExtensions(final URL url) {
-        InputStream is = null;
-        try {
-            is = url.openStream();
+        try (InputStream is = url.openStream()) {
             return getExtensions(is);
         } catch (Exception e) {
             LOG.log(Level.WARNING, e.getMessage(), e);
             return new ArrayList<>();
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    // Ignore
-                }
-            }
         }
     }
 
@@ -86,18 +74,18 @@ public class TextExtensionFragmentParser {
 
     private Extension getExtensionFromTextLine(String line) {
         line = line.trim();
-        if (line.length() == 0 || line.charAt(0) == '#') {
+        if (line.isEmpty() || line.charAt(0) == '#') {
             return null;
         }
         final Extension ext = new Extension(loader);
-        String[] parts = colonPattern.split(line, 0);
+        final String[] parts = line.split(":");
         ext.setClassname(parts[0]);
         if (ext.getClassname() == null) {
             return null;
         }
         if (parts.length >= 2) {
             String interfaceName = parts[1];
-            if (interfaceName != null && "".equals(interfaceName)) {
+            if (interfaceName != null && interfaceName.isEmpty()) {
                 interfaceName = null;
             }
             ext.setInterfaceName(interfaceName);
diff --git a/core/src/main/java/org/apache/cxf/common/util/PackageUtils.java b/core/src/main/java/org/apache/cxf/common/util/PackageUtils.java
index 70de559..dd7f8d6 100644
--- a/core/src/main/java/org/apache/cxf/common/util/PackageUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/PackageUtils.java
@@ -22,6 +22,7 @@ package org.apache.cxf.common.util;
 import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -85,26 +86,22 @@ public final class PackageUtils {
     }
 
     public static String parsePackageName(String namespace, String defaultPackageName) {
-        String packageName = (defaultPackageName != null && defaultPackageName.trim().length() > 0)
-            ? defaultPackageName : null;
-
-        if (packageName == null) {
-            packageName = getPackageNameByNameSpaceURI(namespace);
-        }
-        return packageName;
+        return (defaultPackageName != null && !defaultPackageName.trim().isEmpty())
+            ? defaultPackageName : getPackageNameByNameSpaceURI(namespace.trim());
     }
 
     public static String getPackageNameByNameSpaceURI(String nameSpaceURI) {
         int idx = nameSpaceURI.indexOf(':');
-        String scheme = "";
+        boolean urnScheme = false;
         if (idx >= 0) {
-            scheme = nameSpaceURI.substring(0, idx);
-            if ("http".equalsIgnoreCase(scheme) || "urn".equalsIgnoreCase(scheme)) {
-                nameSpaceURI = nameSpaceURI.substring(idx + 1);
+            final String scheme = nameSpaceURI.substring(0, idx);
+            urnScheme = "urn".equalsIgnoreCase(scheme);
+            if ("http".equalsIgnoreCase(scheme) || urnScheme) {
+                nameSpaceURI = nameSpaceURI.substring(idx + (urnScheme ? 1 : 3)); //
             }
         }
 
-        List<String> tokens = tokenize(nameSpaceURI, "/: ");
+        List<String> tokens = tokenize(nameSpaceURI, "/:");
         if (tokens.isEmpty()) {
             return null;
         }
@@ -118,20 +115,21 @@ public final class PackageUtils {
             }
         }
 
-        String domain = tokens.get(0);
-        idx = domain.indexOf(':');
-        if (idx >= 0) {
-            domain = domain.substring(0, idx);
-        }
-        List<String> r = reverse(tokenize(domain, "urn".equals(scheme) ? ".-" : "."));
+        String domain = tokens.remove(0);
+        // comma was removed by tokenize
+//        idx = domain.indexOf(':');
+//        if (idx >= 0) {
+//            domain = domain.substring(0, idx);
+//        }
+        List<String> r = tokenize(domain, urnScheme ? ".-" : ".");
+        Collections.reverse(r);
         if ("www".equalsIgnoreCase(r.get(r.size() - 1))) {
             // remove leading www
             r.remove(r.size() - 1);
         }
 
         // replace the domain name with tokenized items
-        tokens.addAll(1, r);
-        tokens.remove(0);
+        tokens.addAll(0, r);
 
         // iterate through the tokens and apply xml->java name algorithm
         for (int i = 0; i < tokens.size(); i++) {
@@ -141,7 +139,7 @@ public final class PackageUtils {
             token = removeIllegalIdentifierChars(token);
 
             // this will check for reserved keywords
-            if (containsReservedKeywords(token)) {
+            if (JavaUtils.isJavaKeyword(token)) {
                 token = '_' + token;
             }
 
@@ -149,7 +147,7 @@ public final class PackageUtils {
         }
 
         // concat all the pieces and return it
-        return combine(tokens, '.');
+        return String.join(".", tokens);
     }
 
     private static List<String> tokenize(String str, String sep) {
@@ -162,15 +160,6 @@ public final class PackageUtils {
         return r;
     }
 
-    private static <T> List<T> reverse(List<T> a) {
-        List<T> r = new ArrayList<>();
-
-        for (int i = a.size() - 1; i >= 0; i--) {
-            r.add(a.get(i));
-        }
-        return r;
-    }
-
     private static String removeIllegalIdentifierChars(String token) {
         StringBuilder newToken = new StringBuilder();
         for (int i = 0; i < token.length(); i++) {
@@ -190,45 +179,13 @@ public final class PackageUtils {
         return newToken.toString();
     }
 
-    private static String combine(List<?> r, char sep) {
-        StringBuilder buf = new StringBuilder(r.get(0).toString());
-
-        for (int i = 1; i < r.size(); i++) {
-            buf.append(sep);
-            buf.append(r.get(i));
-        }
-
-        return buf.toString();
-    }
-
-    private static boolean containsReservedKeywords(String token) {
-        return JavaUtils.isJavaKeyword(token);
-    }
-
     public static String getNamespace(String packageName) {
-        if (packageName == null || packageName.length() == 0) {
+        if (packageName == null || packageName.isEmpty()) {
             return null;
         }
-        StringTokenizer tokenizer = new StringTokenizer(packageName, ".");
-        String[] tokens;
-        if (tokenizer.countTokens() == 0) {
-            tokens = new String[0];
-        } else {
-            tokens = new String[tokenizer.countTokens()];
-            for (int i = tokenizer.countTokens() - 1; i >= 0; i--) {
-                tokens[i] = tokenizer.nextToken();
-            }
-        }
-        StringBuilder namespace = new StringBuilder("http://");
-        String dot = "";
-        for (int i = 0; i < tokens.length; i++) {
-            if (i == 1) {
-                dot = ".";
-            }
-            namespace.append(dot + tokens[i]);
-        }
-        namespace.append('/');
-        return namespace.toString();
+        final List<String> parts = Arrays.asList(packageName.split("\\."));
+        Collections.reverse(parts); 
+        return "http://" + String.join(".", parts) + '/';
     }
 
 }
diff --git a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
index 48244f5..7f3f3bd 100644
--- a/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/util/StringUtils.java
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.common.util;
 
-import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -36,10 +35,6 @@ public final class StringUtils {
     private StringUtils() {
     }
 
-    public static boolean isFileExist(String file) {
-        return new File(file).exists() && new File(file).isFile();
-    }
-
     public static boolean isEmpty(String str) {
         if (str != null) {
             int len = str.length();
@@ -118,7 +113,7 @@ public final class StringUtils {
      * @return capitalized form.
      */
     public static String capitalize(String name) {
-        if (name == null || name.length() == 0) {
+        if (name == null || name.isEmpty()) {
             return name;
         }
         char[] chars = name.toCharArray();
@@ -127,7 +122,7 @@ public final class StringUtils {
     }
 
     public static String uncapitalize(String str) {
-        if (str == null || str.length() == 0) {
+        if (str == null || str.isEmpty()) {
             return str;
         }
         return new StringBuilder(str.length())
diff --git a/core/src/main/java/org/apache/cxf/common/util/URIParserUtil.java b/core/src/main/java/org/apache/cxf/common/util/URIParserUtil.java
index d8f0681..ab8c63a 100644
--- a/core/src/main/java/org/apache/cxf/common/util/URIParserUtil.java
+++ b/core/src/main/java/org/apache/cxf/common/util/URIParserUtil.java
@@ -25,12 +25,9 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.StringTokenizer;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.helpers.JavaUtils;
 
 public final class URIParserUtil {
     private static final String EXCLUDED_CHARS = "<>\"{}|\\^`";
@@ -68,154 +65,6 @@ public final class URIParserUtil {
         return urls;
     }
 
-    public static String parsePackageName(String namespace, String defaultPackageName) {
-        String packageName = (defaultPackageName != null && defaultPackageName.trim().length() > 0)
-            ? defaultPackageName : null;
-
-        if (packageName == null) {
-            packageName = getPackageName(namespace);
-        }
-        return packageName;
-    }
-
-    public static String getPackageName(String nameSpaceURI) {
-        int idx = nameSpaceURI.indexOf(':');
-        String scheme = "";
-        if (idx >= 0) {
-            scheme = nameSpaceURI.substring(0, idx);
-            if ("http".equalsIgnoreCase(scheme) || "urn".equalsIgnoreCase(scheme)) {
-                nameSpaceURI = nameSpaceURI.substring(idx + 1);
-            }
-        }
-
-        List<String> tokens = tokenize(nameSpaceURI, "/: ");
-        if (tokens.isEmpty()) {
-            return "cxf";
-        }
-
-        if (tokens.size() > 1) {
-            String lastToken = tokens.get(tokens.size() - 1);
-            idx = lastToken.lastIndexOf('.');
-            if (idx > 0) {
-                //lastToken = lastToken.substring(0, idx);
-                lastToken = lastToken.replace('.', '_');
-                tokens.set(tokens.size() - 1, lastToken);
-            }
-        }
-
-        String domain = tokens.get(0);
-        idx = domain.indexOf(':');
-        if (idx >= 0) {
-            domain = domain.substring(0, idx);
-        }
-        List<String> r = reverse(tokenize(domain, "urn".equals(scheme) ? ".-" : "."));
-        if ("www".equalsIgnoreCase(r.get(r.size() - 1))) {
-            // remove leading www
-            r.remove(r.size() - 1);
-        }
-
-        // replace the domain name with tokenized items
-        tokens.addAll(1, r);
-        tokens.remove(0);
-
-        // iterate through the tokens and apply xml->java name algorithm
-        for (int i = 0; i < tokens.size(); i++) {
-
-            // get the token and remove illegal chars
-            String token = tokens.get(i);
-            token = removeIllegalIdentifierChars(token);
-
-            // this will check for reserved keywords
-            if (containsReservedKeywords(token)) {
-                token = '_' + token;
-            }
-
-            tokens.set(i, token.toLowerCase());
-        }
-
-        // concat all the pieces and return it
-        return combine(tokens, '.');
-    }
-
-    public static String getNamespace(String packageName) {
-        if (packageName == null || packageName.length() == 0) {
-            return null;
-        }
-        StringTokenizer tokenizer = new StringTokenizer(packageName, ".");
-        String[] tokens;
-        if (tokenizer.countTokens() == 0) {
-            tokens = new String[0];
-        } else {
-            tokens = new String[tokenizer.countTokens()];
-            for (int i = tokenizer.countTokens() - 1; i >= 0; i--) {
-                tokens[i] = tokenizer.nextToken();
-            }
-        }
-        StringBuilder namespace = new StringBuilder("http://");
-        String dot = "";
-        for (int i = 0; i < tokens.length; i++) {
-            if (i == 1) {
-                dot = ".";
-            }
-            namespace.append(dot + tokens[i]);
-        }
-        namespace.append('/');
-        return namespace.toString();
-    }
-
-    private static List<String> tokenize(String str, String sep) {
-        StringTokenizer tokens = new StringTokenizer(str, sep);
-        List<String> r = new ArrayList<>();
-
-        while (tokens.hasMoreTokens()) {
-            r.add(tokens.nextToken());
-        }
-        return r;
-    }
-
-    private static String removeIllegalIdentifierChars(String token) {
-        StringBuilder newToken = new StringBuilder();
-        for (int i = 0; i < token.length(); i++) {
-            char c = token.charAt(i);
-
-            if (i == 0 && !Character.isJavaIdentifierStart(c)) {
-                // prefix an '_' if the first char is illegal
-                newToken.append("_" + c);
-            } else if (!Character.isJavaIdentifierPart(c)) {
-                // replace the char with an '_' if it is illegal
-                newToken.append('_');
-            } else {
-                // add the legal char
-                newToken.append(c);
-            }
-        }
-        return newToken.toString();
-    }
-
-    private static String combine(List<String> r, char sep) {
-        StringBuilder buf = new StringBuilder(r.get(0));
-
-        for (int i = 1; i < r.size(); i++) {
-            buf.append(sep);
-            buf.append(r.get(i));
-        }
-
-        return buf.toString();
-    }
-
-    private static <T> List<T> reverse(List<T> a) {
-        List<T> r = new ArrayList<>();
-
-        for (int i = a.size() - 1; i >= 0; i--) {
-            r.add(a.get(i));
-        }
-        return r;
-    }
-
-    public static boolean containsReservedKeywords(String token) {
-        return JavaUtils.isJavaKeyword(token);
-    }
-
     public static String escapeChars(String s) {
         StringBuilder b = new StringBuilder(s.length());
 
diff --git a/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java b/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
index 5a23ed5..08dabd9 100644
--- a/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
+++ b/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
@@ -184,7 +184,7 @@ public abstract class AbstractInDatabindingInterceptor extends AbstractPhaseInte
             }
 
             MessagePartInfo p = msgInfo.getMessageParts().get(index);
-            if (name.getNamespaceURI() == null || name.getNamespaceURI().length() == 0) {
+            if (name.getNamespaceURI() == null || name.getNamespaceURI().isEmpty()) {
                 // message part has same namespace with the message
                 name = new QName(p.getMessageInfo().getName().getNamespaceURI(), name.getLocalPart());
             }
diff --git a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
index b56e789..b2d312b 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
@@ -826,7 +826,7 @@ public final class StaxUtils {
 
         // Write out the element name
         if (uri != null) {
-            if (prefix.length() == 0 && StringUtils.isEmpty(uri)) {
+            if (prefix.isEmpty() && StringUtils.isEmpty(uri)) {
                 writer.writeStartElement(local);
             } else {
                 writer.writeStartElement(prefix, local, uri);
@@ -845,7 +845,7 @@ public final class StaxUtils {
             if (nsURI == null) {
                 nsURI = "";
             }
-            if (nsPrefix.length() == 0) {
+            if (nsPrefix.isEmpty()) {
                 writer.writeDefaultNamespace(nsURI);
                 writer.setDefaultNamespace(nsURI);
             } else {
@@ -862,7 +862,7 @@ public final class StaxUtils {
         // We need this check because namespace writing works
         // different on Woodstox and the RI.
         if (writeElementNS) {
-            if (prefix.length() == 0) {
+            if (prefix.isEmpty()) {
                 writer.writeDefaultNamespace(uri);
                 writer.setDefaultNamespace(uri);
             } else {
@@ -875,9 +875,9 @@ public final class StaxUtils {
         for (int i = 0; i < reader.getAttributeCount(); i++) {
             String ns = reader.getAttributeNamespace(i);
             String nsPrefix = reader.getAttributePrefix(i);
-            if (ns == null || ns.length() == 0) {
+            if (ns == null || ns.isEmpty()) {
                 writer.writeAttribute(reader.getAttributeLocalName(i), reader.getAttributeValue(i));
-            } else if (nsPrefix == null || nsPrefix.length() == 0) {
+            } else if (nsPrefix == null || nsPrefix.isEmpty()) {
                 writer.writeAttribute(reader.getAttributeNamespace(i), reader.getAttributeLocalName(i),
                                       reader.getAttributeValue(i));
             } else {
@@ -976,7 +976,7 @@ public final class StaxUtils {
         String decUri = writer.getNamespaceContext().getNamespaceURI(prefix);
         boolean declareNamespace = decUri == null || !decUri.equals(ns);
 
-        if (ns == null || ns.length() == 0) {
+        if (ns == null || ns.isEmpty()) {
             writer.writeStartElement(localName);
             if (StringUtils.isEmpty(decUri)) {
                 declareNamespace = false;
@@ -1015,9 +1015,9 @@ public final class StaxUtils {
                 } else {
                     String attns = attr.getNamespaceURI();
                     String value = attr.getNodeValue();
-                    if (attns == null || attns.length() == 0) {
+                    if (attns == null || attns.isEmpty()) {
                         writer.writeAttribute(name, value);
-                    } else if (attrPrefix.length() == 0) {
+                    } else if (attrPrefix.isEmpty()) {
                         writer.writeAttribute(attns, name, value);
                     } else {
                         if (repairing && writer.getNamespaceContext().getNamespaceURI(attrPrefix) == null) {
diff --git a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
index 22d9317..ec6eaca 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamWriter.java
@@ -238,7 +238,7 @@ public class W3CDOMStreamWriter implements XMLStreamWriter {
     }
 
     public void writeNamespace(String prefix, String namespace) throws XMLStreamException {
-        if (prefix.length() == 0) {
+        if (prefix.isEmpty()) {
             writeDefaultNamespace(namespace);
         } else {
             Attr attr = document.createAttributeNS(XML_NS, "xmlns:" + prefix);
diff --git a/core/src/main/java/org/apache/cxf/staxutils/W3CNamespaceContext.java b/core/src/main/java/org/apache/cxf/staxutils/W3CNamespaceContext.java
index 13ad279..c2ece6b 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/W3CNamespaceContext.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/W3CNamespaceContext.java
@@ -45,14 +45,7 @@ public class W3CNamespaceContext implements NamespaceContext {
     }
 
     public String getNamespaceURI(String prefix) {
-        String name = prefix;
-        if (name.length() == 0) {
-            name = "xmlns";
-        } else {
-            name = "xmlns:" + prefix;
-        }
-
-        return getNamespaceURI(currentNode, name);
+        return getNamespaceURI(currentNode, !prefix.isEmpty() ? "xmlns:" + prefix : "xmlns");
     }
 
     private String getNamespaceURI(Element e, String name) {
diff --git a/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java b/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
index a0f3e2b..7ad0fef 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
@@ -59,7 +59,7 @@ public class DelegatingNamespaceContext implements NamespaceContext {
     }
 
     public String findUniquePrefix(String ns) {
-        if (ns.length() == 0) {
+        if (ns.isEmpty()) {
             return null;
         }
         String existingPrefix = getPrefix(ns);
@@ -103,11 +103,11 @@ public class DelegatingNamespaceContext implements NamespaceContext {
     }
 
     public String getPrefix(String ns) {
-        if (ns.length() == 0) {
+        if (ns.isEmpty()) {
             return null;
         }
         String value = nsMap.get(ns);
-        if (value != null && value.length() == 0) {
+        if (value != null && value.isEmpty()) {
             return null;
         }
         if (value != null) {
diff --git a/core/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java b/core/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
index 402d2c2..a3b0e7b 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
@@ -124,13 +124,13 @@ public class InTransformReader extends DepthXMLStreamReader {
                 expected = theName;
             } else {
                 String prefix = theName.getPrefix();
-                if (prefix.length() == 0 && theName.getNamespaceURI().length() == 0
-                    && expected.getNamespaceURI().length() > 0) {
+                if (prefix.isEmpty() && theName.getNamespaceURI().isEmpty()
+                    && !expected.getNamespaceURI().isEmpty()) {
                     prefix = namespaceContext.getPrefix(expected.getNamespaceURI());
                     if (prefix == null) {
                         prefix = namespaceContext.findUniquePrefix(expected.getNamespaceURI());
                     }
-                } else if (prefix.length() > 0 && expected.getNamespaceURI().length() == 0) {
+                } else if (!prefix.isEmpty() && expected.getNamespaceURI().isEmpty()) {
                     prefix = "";
                 }
                 expected = new QName(expected.getNamespaceURI(), expected.getLocalPart(), prefix);
@@ -290,7 +290,7 @@ public class InTransformReader extends DepthXMLStreamReader {
     public String getPrefix() {
         QName name = readCurrentElement();
         String prefix = name.getPrefix();
-        if (prefix.length() == 0 && getNamespaceURI().length() > 0) {
+        if (prefix.isEmpty() && !getNamespaceURI().isEmpty()) {
             prefix = namespaceContext.getPrefix(getNamespaceURI());
             if (prefix == null) {
                 prefix = "";
diff --git a/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java b/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
index f14ed10..e0e528b 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/transform/OutTransformWriter.java
@@ -100,7 +100,7 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
             return;
         }
         String value = nsMap.get(uri);
-        if ((value != null && value.length() == 0)
+        if ((value != null && value.isEmpty())
             || uri.equals(replaceNamespace)) {
             return;
         }
@@ -108,7 +108,7 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
         uri = value != null ? value : uri;
 
         if (writtenUris.get(0).contains(uri)
-            && (prefix.length() == 0 || prefix.equals(namespaceContext.getPrefix(uri)))) {
+            && (prefix.isEmpty() || prefix.equals(namespaceContext.getPrefix(uri)))) {
             return;
         }
 
@@ -116,7 +116,7 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
             super.writeDefaultNamespace(uri);
             namespaceContext.addPrefix("", uri);
         } else {
-            if (prefix.length() == 0) {
+            if (prefix.isEmpty()) {
                 prefix = namespaceContext.findUniquePrefix(uri);
             }
             super.writeNamespace(prefix, uri);
@@ -132,7 +132,7 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
             return;
         }
         String value = nsMap.get(uri);
-        if ((value != null && value.length() == 0)
+        if ((value != null && value.isEmpty())
             || (isDefaultNamespaceRedefined() && !isDefaultNamespaceRedefined(uri))
             || uri.equals(replaceNamespace)) {
             return;
@@ -154,7 +154,7 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
             return;
         }
         String value = nsMap.get(uri);
-        if ((value != null && value.length() == 0)
+        if ((value != null && value.isEmpty())
             || (isDefaultNamespaceRedefined() && !isDefaultNamespaceRedefined(uri))) {
             return;
         }
@@ -188,8 +188,8 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
         if (expected == null) {
             expected = theName;
         } else {
-            if (prefix.length() == 0 && expected.getNamespaceURI().length() > 0
-                && theName.getNamespaceURI().length() == 0) {
+            if (prefix.isEmpty() && !expected.getNamespaceURI().isEmpty()
+                && theName.getNamespaceURI().isEmpty()) {
                 // if the element is promoted to a qualified element, use the prefix bound
                 // to that namespace. If the namespace is unbound, generate a new prefix and
                 // write its declaration later.
@@ -197,7 +197,7 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
                 if (prefix == null) {
                     prefix = namespaceContext.findUniquePrefix(expected.getNamespaceURI());
                 }
-            } else if (prefix.length() > 0 && expected.getNamespaceURI().length() == 0) {
+            } else if (!prefix.isEmpty() && expected.getNamespaceURI().isEmpty()) {
                 // if the element is demoted to a unqualified element, use an empty prefix.
                 prefix = "";
             }
@@ -255,7 +255,7 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
             return;
         }
         write(expected, false);
-        if (expected.getNamespaceURI().length() > 0 && theName.getNamespaceURI().length() == 0) {
+        if (!expected.getNamespaceURI().isEmpty() && theName.getNamespaceURI().isEmpty()) {
             // the element is promoted to a qualified element, thus write its declaration
             writeNamespace(expected.getPrefix(), expected.getNamespaceURI());
         }
@@ -377,9 +377,9 @@ public class OutTransformWriter extends DelegatingXMLStreamWriter {
     private void write(QName qname, boolean replacePrefix) throws XMLStreamException {
         boolean writeNs = false;
         String prefix = "";
-        if (qname.getNamespaceURI().length() > 0) {
+        if (!qname.getNamespaceURI().isEmpty()) {
             if ((replacePrefix || isDefaultNamespaceRedefined())
-                && qname.getPrefix().length() == 0) {
+                && qname.getPrefix().isEmpty()) {
                 // if the default namespace is configured to be replaced, a non-empty prefix must be assigned
                 prefix = namespaceContext.getPrefix(qname.getNamespaceURI());
                 if (prefix == null) {
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java b/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
index 61e2c91..fbfc5cb 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/ContextUtils.java
@@ -336,7 +336,7 @@ public final class ContextUtils {
     public static boolean hasEmptyAction(AddressingProperties maps) {
         boolean empty = maps.getAction() == null;
         if (maps.getAction() != null
-            && maps.getAction().getValue().length() == 0) {
+            && maps.getAction().getValue().isEmpty()) {
             maps.setAction(null);
             empty = false;
         }
diff --git a/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java b/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java
index 57188c7..b619da4 100644
--- a/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java
+++ b/core/src/test/java/org/apache/cxf/common/util/PackageUtilsTest.java
@@ -115,4 +115,30 @@ public class PackageUtilsTest {
               org.apache.cxf.configuration.spring.JAXBBeanFactory.class));
         assertEquals("org.apache.cxf", packageName);
     }
+
+    @Test
+    public void testParsePackageName() throws Exception {
+        assertEquals("com.example.test.passed",
+                PackageUtils.parsePackageName("http://www.example.com/test:passed", " "));
+        assertEquals("org.apache.cxf.no_body_parts.wsdl",
+                PackageUtils.parsePackageName("urn:org:apache:cxf:no_body_parts/wsdl", ""));
+    }
+
+    @Test
+    public void testGetPackageNameByNameSpaceURI() throws Exception {
+        assertEquals("com.iona.cxf", PackageUtils.getPackageNameByNameSpaceURI("http://www.cxf.iona.com"));
+        assertEquals("com.iona._class", PackageUtils.getPackageNameByNameSpaceURI("urn:www.class.iona.com"));
+        assertEquals("uri.cxf_apache_org.jstest",
+                PackageUtils.getPackageNameByNameSpaceURI("uri:cxf.apache.org:jstest"));
+        assertEquals("soapinterface.ems.esendex.com",
+                PackageUtils.getPackageNameByNameSpaceURI("com.esendex.ems.soapinterface"));
+    }
+
+    @Test
+    public void testGetNamespace() throws Exception {
+        final String packageName = PackageUtils.getNamespace(getClass().getPackage().getName());
+        assertEquals("http://util.common.cxf.apache.org/", packageName);
+    }
+
+
 }
\ No newline at end of file
diff --git a/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java b/core/src/test/java/org/apache/cxf/common/util/URIParserUtilTest.java
similarity index 66%
rename from tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
rename to core/src/test/java/org/apache/cxf/common/util/URIParserUtilTest.java
index 0baa496..d6a9fb1 100644
--- a/tools/common/src/test/java/org/apache/cxf/tools/util/URIParserUtilTest.java
+++ b/core/src/test/java/org/apache/cxf/common/util/URIParserUtilTest.java
@@ -17,29 +17,44 @@
  * under the License.
  */
 
-package org.apache.cxf.tools.util;
+package org.apache.cxf.common.util;
 
+import java.net.URISyntaxException;
 import java.net.URLDecoder;
 import java.nio.charset.StandardCharsets;
 
-import org.apache.cxf.common.util.URIParserUtil;
-
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 
 public class URIParserUtilTest {
 
     @Test
-    public void testGetPackageName() {
-
-        String packageName = URIParserUtil.getPackageName("http://www.cxf.iona.com");
-        assertEquals(packageName, "com.iona.cxf");
-        packageName = URIParserUtil.getPackageName("urn://www.class.iona.com");
-        assertEquals(packageName, "com.iona._class");
+    public void testRelativize() throws URISyntaxException {
+        assertNull(URIParserUtil.relativize(null, "foo"));
+        assertNull(URIParserUtil.relativize("foo", null));
+        assertEquals("", URIParserUtil.relativize("", ""));
+        assertEquals("", URIParserUtil.relativize("fds", ""));
+        assertEquals("../", URIParserUtil.relativize("fds/", ""));
+        assertEquals("fdsfs", URIParserUtil.relativize("", "fdsfs"));
+        assertEquals("fdsfs/a", URIParserUtil.relativize("", "fdsfs/a"));
+        assertEquals("../de", URIParserUtil.relativize("ab/cd", "de"));
+        assertEquals("../de/fe/gh", URIParserUtil.relativize("ab/cd", "de/fe/gh"));
+        assertEquals("../../../de/fe/gh", URIParserUtil.relativize("/abc/def/", "de/fe/gh"));
+        assertNull(URIParserUtil.relativize("file:/c:/abc/def/", "de/fe/gh")); // null as the URI obtained by
+                                                                               // the 2 strings are not both
+                                                                               // absolute or not absolute
+        assertEquals("pippo2.xsd", URIParserUtil.relativize("/abc/def/pippo1.xsd", "/abc/def/pippo2.xsd"));
+        assertEquals("../default/pippo2.xsd",
+                     URIParserUtil.relativize("/abc/def/pippo1.xsd", "/abc/default/pippo2.xsd"));
+        assertEquals("def/pippo2.xsd", URIParserUtil.relativize("/abc/def", "/abc/def/pippo2.xsd"));
+        assertEquals("hello_world_schema2.xsd",
+                     URIParserUtil.relativize("jar:file:/home/a.jar!/wsdl/others/",
+                                              "jar:file:/home/a.jar!/wsdl/others/hello_world_schema2.xsd"));
     }
 
     @Test
@@ -78,7 +93,7 @@ public class URIParserUtilTest {
         assertTrue(uri2.contains(uri));
         assertTrue(uri2.contains(new java.io.File("").toString()));
 
-        uri = getClass().getResource("/schemas/wsdl/test.xsd").toString();
+        uri = getClass().getResource("/schemas/echoSchema.xsd").toString();
         uri2 = URIParserUtil.getAbsoluteURI(uri);
         assertNotNull(uri2);
         assertTrue(uri2.startsWith("file"));
@@ -108,4 +123,5 @@ public class URIParserUtilTest {
         String s = URIParserUtil.escapeChars(orig);
         assertEquals(orig, URLDecoder.decode(s, StandardCharsets.UTF_8.name()));
     }
+
 }
\ No newline at end of file
diff --git a/core/src/test/java/org/apache/cxf/common/util/URIParserUtilsTest.java b/core/src/test/java/org/apache/cxf/common/util/URIParserUtilsTest.java
deleted file mode 100644
index 73a1744..0000000
--- a/core/src/test/java/org/apache/cxf/common/util/URIParserUtilsTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.common.util;
-
-import java.net.URISyntaxException;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-
-public class URIParserUtilsTest {
-
-    @Test
-    public void testRelativize() throws URISyntaxException {
-        assertNull(URIParserUtil.relativize(null, "foo"));
-        assertNull(URIParserUtil.relativize("foo", null));
-        assertEquals("", URIParserUtil.relativize("", ""));
-        assertEquals("", URIParserUtil.relativize("fds", ""));
-        assertEquals("../", URIParserUtil.relativize("fds/", ""));
-        assertEquals("fdsfs", URIParserUtil.relativize("", "fdsfs"));
-        assertEquals("fdsfs/a", URIParserUtil.relativize("", "fdsfs/a"));
-        assertEquals("../de", URIParserUtil.relativize("ab/cd", "de"));
-        assertEquals("../de/fe/gh", URIParserUtil.relativize("ab/cd", "de/fe/gh"));
-        assertEquals("../../../de/fe/gh", URIParserUtil.relativize("/abc/def/", "de/fe/gh"));
-        assertNull(URIParserUtil.relativize("file:/c:/abc/def/", "de/fe/gh")); // null as the URI obtained by
-                                                                               // the 2 strings are not both
-                                                                               // absolute or not absolute
-        assertEquals("pippo2.xsd", URIParserUtil.relativize("/abc/def/pippo1.xsd", "/abc/def/pippo2.xsd"));
-        assertEquals("../default/pippo2.xsd",
-                     URIParserUtil.relativize("/abc/def/pippo1.xsd", "/abc/default/pippo2.xsd"));
-        assertEquals("def/pippo2.xsd", URIParserUtil.relativize("/abc/def", "/abc/def/pippo2.xsd"));
-        assertEquals("hello_world_schema2.xsd",
-                     URIParserUtil.relativize("jar:file:/home/a.jar!/wsdl/others/",
-                                              "jar:file:/home/a.jar!/wsdl/others/hello_world_schema2.xsd"));
-    }
-
-}
\ No newline at end of file
diff --git a/core/src/test/java/org/apache/cxf/staxutils/transform/TransformTestUtils.java b/core/src/test/java/org/apache/cxf/staxutils/transform/TransformTestUtils.java
index 1b08c61..df72695 100755
--- a/core/src/test/java/org/apache/cxf/staxutils/transform/TransformTestUtils.java
+++ b/core/src/test/java/org/apache/cxf/staxutils/transform/TransformTestUtils.java
@@ -212,7 +212,7 @@ public final class TransformTestUtils {
                 return e;
             } else if (e == XMLStreamConstants.CHARACTERS) {
                 String text = reader.getText();
-                if (text.trim().length() == 0) {
+                if (text.trim().isEmpty()) {
                     continue;
                 }
                 return e;
diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
index fb88b0f..6004b9a 100644
--- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
+++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
@@ -64,7 +64,6 @@ import org.apache.cxf.common.i18n.UncheckedException;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.util.URIParserUtil;
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.source.SourceDataBinding;
@@ -609,8 +608,8 @@ public class ServiceImpl extends ServiceDelegate {
         }
 
         String tns = webService.targetNamespace();
-        if (tns.length() == 0) {
-            tns = URIParserUtil.getNamespace(PackageUtils.getPackageName(seiClass));
+        if (tns.isEmpty()) {
+            tns = PackageUtils.getNamespace(PackageUtils.getPackageName(seiClass));
         }
 
         return new QName(tns, name);
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java b/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
index 3f0b755..b646327 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
@@ -30,7 +30,8 @@ import javax.xml.namespace.QName;
 
 import org.xml.sax.InputSource;
 
-import org.apache.cxf.common.util.URIParserUtil;
+
+import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.tools.common.model.JavaModel;
 import org.apache.cxf.tools.util.PropertyUtil;
 
@@ -226,11 +227,11 @@ public class ToolContext {
         if (getPackageName() != null) {
             return getPackageName();
         }
-        return URIParserUtil.parsePackageName(ns, null);
+        return PackageUtils.parsePackageName(ns, null);
     }
 
     public String getCustomizedNS(String ns) {
-        return URIParserUtil.getNamespace(mapPackageName(ns));
+        return PackageUtils.getNamespace(mapPackageName(ns));
     }
 
     public void setJaxbBindingFiles(List<InputSource> bindings) {
diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaField.java b/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaField.java
index 505cf1d..c7386b8 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaField.java
+++ b/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaField.java
@@ -23,7 +23,7 @@ import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.cxf.common.util.URIParserUtil;
+import org.apache.cxf.helpers.JavaUtils;
 
 public class JavaField extends JavaType implements JavaAnnotatable {
     private String modifier;
@@ -80,10 +80,10 @@ public class JavaField extends JavaType implements JavaAnnotatable {
     }
 
     public String getParaName() {
-        if (URIParserUtil.containsReservedKeywords(this.name)) {
-            return "_" + this.name;
+        if (JavaUtils.isJavaKeyword(name)) {
+            return "_" + name;
         }
-        return this.name;
+        return name;
     }
 
 }
diff --git a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/ProcessorEnvironment.java b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/ProcessorEnvironment.java
index 049b60e..0e74e9c 100644
--- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/ProcessorEnvironment.java
+++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/ProcessorEnvironment.java
@@ -25,7 +25,7 @@ import java.util.Map;
 
 import org.xml.sax.InputSource;
 
-import org.apache.cxf.common.util.URIParserUtil;
+import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.util.PropertyUtil;
 
@@ -149,7 +149,7 @@ public class ProcessorEnvironment {
     }
 
     public String getCustomizedNS(String ns) {
-        return URIParserUtil.getNamespace(mapPackageName(ns));
+        return PackageUtils.getNamespace(mapPackageName(ns));
     }
 
     public void addJaxbBindingFile(String location, InputSource is) {
diff --git a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java
index 8a3b6d5..9693201 100644
--- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java
+++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/FaultBean.java
@@ -29,7 +29,6 @@ import javax.xml.ws.WebFault;
 
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.util.URIParserUtil;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.model.JavaClass;
 import org.apache.cxf.tools.common.model.JavaField;
@@ -82,10 +81,10 @@ public final class FaultBean {
 
         String pkg = PackageUtils.getPackageName(exceptionClass);
         if (pkg.length() > 0) {
-            jClass.setElementName(new QName(URIParserUtil.getNamespace(pkg),
+            jClass.setElementName(new QName(PackageUtils.getNamespace(pkg),
                                         exceptionClass.getSimpleName()));
         } else {
-            jClass.setElementName(new QName(URIParserUtil.getNamespace(ToolConstants.DEFAULT_PACKAGE_NAME),
+            jClass.setElementName(new QName(PackageUtils.getNamespace(ToolConstants.DEFAULT_PACKAGE_NAME),
                                         exceptionClass.getSimpleName()));
         }
         jClass.annotate(new WrapperBeanAnnotator(exceptionClass));
diff --git a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
index 4a67803..db343bf 100644
--- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
+++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/Wrapper.java
@@ -37,7 +37,6 @@ import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.util.URIParserUtil;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolException;
@@ -89,7 +88,7 @@ public class Wrapper {
         }
         String ns = wrapperBeanName.getNamespaceURI();
         jClass.setNamespace(ns);
-        jClass.setPackageName(URIParserUtil.getPackageName(ns));
+        jClass.setPackageName(PackageUtils.getPackageNameByNameSpaceURI(ns));
         jClass.setName(NameUtil.mangleNameToClassName(wrapperBeanName.getLocalPart()));
         jClass.setElementName(wrapperBeanName);
         return jClass;
diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
index a59e657..8cfc9ab 100644
--- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
+++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/processor/internal/ProcessorUtil.java
@@ -36,7 +36,7 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.common.jaxb.JAXBUtils;
-import org.apache.cxf.common.util.URIParserUtil;
+import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.helpers.JavaUtils;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -175,13 +175,7 @@ public final class ProcessorUtil {
     }
 
     public static String parsePackageName(String namespace, String defaultPackageName) {
-        String packageName = (defaultPackageName != null && defaultPackageName.trim().length() > 0)
-            ? defaultPackageName : null;
-
-        if (packageName == null) {
-            packageName = URIParserUtil.getPackageName(namespace);
-        }
-        return packageName;
+        return PackageUtils.parsePackageName(namespace, defaultPackageName);
     }
 
     public static String getAbsolutePath(String location) throws IOException {
diff --git a/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java b/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
index b745829..79d30b7 100644
--- a/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
+++ b/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
@@ -812,19 +812,14 @@ public class CodeGenBugTest extends AbstractCodeGenTest {
 
     @Test
     public void testParameterOrderDifferentNS() throws Exception {
-        try {
-            env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/bug978/bug.wsdl"));
-            processor.setContext(env);
-            processor.execute();
-
-            String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),
-                                                                  "org/tempuri/GreeterRPCLit.java"));
-            assertTrue(results.indexOf("@WebParam(partName  =  \"inInt\",  name  =  \"inInt\")") != -1);
-            assertTrue(results.indexOf("Style.RPC") != -1);
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/bug978/bug.wsdl"));
+        processor.setContext(env);
+        processor.execute();
 
-        } catch (Exception e) {
-            fail("The cxf978.wsdl is a valid wsdl, should pass the test, caused by: " + e.getMessage());
-        }
+        String results = FileUtils.getStringFromFile(new File(output,
+                                                              "org/tempuri/GreeterRPCLit.java"));
+        assertTrue(results.indexOf("@WebParam(partName  =  \"inInt\",  name  =  \"inInt\")") != -1);
+        assertTrue(results.indexOf("Style.RPC") != -1);
     }
 
     @Test


Mime
View raw message