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 6d41caa cxf-tools-common: fix warnings
6d41caa is described below
commit 6d41caac92d1a814db231a06f676273d3551b62d
Author: Alexey Markevich <[email protected]>
AuthorDate: Wed May 13 01:32:52 2020 +0300
cxf-tools-common: fix warnings
---
.../apache/cxf/tools/common/model/JavaMethod.java | 4 +-
.../common/toolspec/parser/CommandLineParser.java | 20 +--
.../common/toolspec/parser/Messages.properties | 1 -
.../org/apache/cxf/tools/util/ToolsStaxUtils.java | 31 ++--
.../{StAXUtilTest.java => ToolsStaxUtilsTest.java} | 12 +-
.../org/apache/cxf/tools/util/resources/test.wsdl | 178 ---------------------
6 files changed, 18 insertions(+), 228 deletions(-)
diff --git
a/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java
b/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java
index 23cc025..8ea04f9 100644
---
a/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java
+++
b/tools/common/src/main/java/org/apache/cxf/tools/common/model/JavaMethod.java
@@ -148,9 +148,7 @@ public class JavaMethod implements JavaAnnotatable {
}
private void replaceParameter(JavaParameter p1, JavaParameter p2) {
- int index = ((ArrayList<?>)parameters).indexOf(p1);
- parameters.remove(index);
- parameters.add(index, p2);
+ parameters.set(parameters.indexOf(p1), p2);
if ((p1.isIN() && p2.isOUT()) || p1.isINOUT()) {
p2.setStyle(Style.INOUT);
}
diff --git
a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
index f6b11b6..ba37374 100644
---
a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
+++
b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/CommandLineParser.java
@@ -29,8 +29,6 @@ import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
@@ -77,12 +75,7 @@ public class CommandLineParser {
public CommandDocument parseArguments(String[] args) throws
BadUsageException, IOException {
if (LOG.isLoggable(Level.FINE)) {
- StringBuilder debugMsg = new StringBuilder("Parsing arguments: ");
-
- for (int i = 0; i < args.length; i++) {
- debugMsg.append(args[i]).append(' ');
- }
- LOG.fine(debugMsg.toString());
+ LOG.fine("Parsing arguments: " + String.join(" ", args));
}
if (toolspec == null) {
@@ -91,17 +84,8 @@ public class CommandLineParser {
// Create a result document
- Document resultDoc = null;
+ final Document resultDoc = DOMUtils.newDocument();
- try {
- DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
Boolean.TRUE);
-
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl",
true);
- resultDoc = factory.newDocumentBuilder().newDocument();
- } catch (Exception ex) {
- LOG.log(Level.SEVERE, "FAIL_CREATE_DOM_MSG");
- }
Element commandEl =
resultDoc.createElementNS("http://cxf.apache.org/Xutil/Command", "command");
Attr attr =
diff --git
a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/Messages.properties
b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/Messages.properties
index 8cd3c69..b7f0fef 100644
---
a/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/Messages.properties
+++
b/tools/common/src/main/java/org/apache/cxf/tools/common/toolspec/parser/Messages.properties
@@ -18,7 +18,6 @@
# under the License.
#
#
-FAIL_CREATE_DOM_MSG=Failed to create a new DOM
ERROR_SERIALIZE_COMMAND_MSG=Error serializing command doc
CANNOT_GET_USAGE_MSG=Can not get usage message
ARGUMENT_IS_NULL_MSG=Argument is null
diff --git
a/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
b/tools/common/src/test/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
similarity index 87%
rename from
tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
rename to
tools/common/src/test/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
index bacf840..1380404 100644
--- a/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
+++ b/tools/common/src/test/java/org/apache/cxf/tools/util/ToolsStaxUtils.java
@@ -25,7 +25,8 @@ import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayDeque;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.Map;
@@ -45,7 +46,7 @@ public final class ToolsStaxUtils {
public static List<Tag> getTags(final File source) throws Exception {
List<Tag> tags = new ArrayList<>();
- List<String> ignoreEmptyTags = Arrays.asList(new String[]{"sequence"});
+ Collection<String> ignoreEmptyTags = Collections.singleton("sequence");
try (InputStream is = new
BufferedInputStream(Files.newInputStream(source.toPath()))) {
XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
@@ -75,12 +76,9 @@ public final class ToolsStaxUtils {
reader.getAttributeValue(i));
}
stack.push(newTag);
- }
- if (event == XMLStreamConstants.CHARACTERS) {
+ } else if (event == XMLStreamConstants.CHARACTERS) {
newTag.setText(reader.getText());
- }
-
- if (event == XMLStreamConstants.END_ELEMENT) {
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
Tag startTag = stack.pop();
if (checkingPoint != null &&
checkingPoint.equals(reader.getName())) {
@@ -102,23 +100,21 @@ public final class ToolsStaxUtils {
}
public static Tag getTagTree(final File source) throws Exception {
- return getTagTree(source, new ArrayList<>());
+ return getTagTree(source, Collections.emptyList());
}
- public static Tag getTagTree(final File source, final List<String>
ignoreAttr) throws Exception {
- try (InputStream is = new
BufferedInputStream(Files.newInputStream(source.toPath()))) {
- return getTagTree(is, ignoreAttr, null);
- }
+ public static Tag getTagTree(final File source, final Collection<String>
ignoreAttr) throws Exception {
+ return getTagTree(source, ignoreAttr, null);
}
public static Tag getTagTree(final File source,
- final List<String> ignoreAttr,
+ final Collection<String> ignoreAttr,
Map<QName, Set<String>> types) throws
Exception {
try (InputStream is = new
BufferedInputStream(Files.newInputStream(source.toPath()))) {
return getTagTree(is, ignoreAttr, types);
}
}
public static Tag getTagTree(final InputStream is,
- final List<String> ignoreAttr,
+ final Collection<String> ignoreAttr,
Map<QName, Set<String>> types) throws
Exception {
Tag root = new Tag();
root.setName(new QName("root", "root"));
@@ -163,12 +159,9 @@ public final class ToolsStaxUtils {
newTag.setParent(currentTag);
currentTag.getTags().add(newTag);
currentTag = newTag;
- }
- if (event == XMLStreamConstants.CHARACTERS) {
+ } else if (event == XMLStreamConstants.CHARACTERS) {
newTag.setText(reader.getText());
- }
-
- if (event == XMLStreamConstants.END_ELEMENT) {
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
currentTag = currentTag.getParent();
}
}
diff --git
a/tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java
b/tools/common/src/test/java/org/apache/cxf/tools/util/ToolsStaxUtilsTest.java
similarity index 81%
rename from
tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java
rename to
tools/common/src/test/java/org/apache/cxf/tools/util/ToolsStaxUtilsTest.java
index 62611c2..5795ffe 100644
--- a/tools/common/src/test/java/org/apache/cxf/tools/util/StAXUtilTest.java
+++
b/tools/common/src/test/java/org/apache/cxf/tools/util/ToolsStaxUtilsTest.java
@@ -19,8 +19,6 @@
package org.apache.cxf.tools.util;
-import java.io.File;
-
import org.apache.cxf.tools.common.ProcessorTestBase;
import org.apache.cxf.tools.common.Tag;
@@ -28,14 +26,11 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
-public class StAXUtilTest extends ProcessorTestBase {
+public class ToolsStaxUtilsTest extends ProcessorTestBase {
@Test
public void testGetTags() throws Exception {
- File file = new
File(getClass().getResource("resources/test.wsdl").toURI());
-
- file = getResource("resources/test2.wsdl");
- Tag tag1 = ToolsStaxUtils.getTagTree(file);
+ Tag tag1 =
ToolsStaxUtils.getTagTree(getResource("resources/test2.wsdl"));
assertEquals(1, tag1.getTags().size());
Tag def1 = tag1.getTags().get(0);
assertEquals(6, def1.getTags().size());
@@ -43,8 +38,7 @@ public class StAXUtilTest extends ProcessorTestBase {
Tag schema1 = types1.getTags().get(0);
assertEquals(4, schema1.getTags().size());
- file = getResource("resources/test3.wsdl");
- Tag tag2 = ToolsStaxUtils.getTagTree(file);
+ Tag tag2 =
ToolsStaxUtils.getTagTree(getResource("resources/test3.wsdl"));
assertEquals(1, tag2.getTags().size());
Tag def2 = tag2.getTags().get(0);
assertEquals(6, def2.getTags().size());
diff --git
a/tools/common/src/test/java/org/apache/cxf/tools/util/resources/test.wsdl
b/tools/common/src/test/java/org/apache/cxf/tools/util/resources/test.wsdl
deleted file mode 100644
index ad4eaad..0000000
--- a/tools/common/src/test/java/org/apache/cxf/tools/util/resources/test.wsdl
+++ /dev/null
@@ -1,178 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<wsdl:definitions xmlns:tns="http://apache.org/hello_world_doc_lit"
xmlns:ns1="http://apache.org/hello_world_doc_lit/types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="GreeterService"
targetNamespace="http://apache.org/hello_world_doc_lit">
- <wsdl:types>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://apache.org/hello_world_doc_lit/types"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://apache.org/hello_world_doc_lit/types">
- <xs:element name="faultDetail">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="minor" type="xs:short"/>
- <xs:element name="major" type="xs:short"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="greetMe">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="requestType" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="greetMeOneWay">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="requestType" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="greetMeResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="responseType" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="pingMe">
- <xs:complexType>
- <xs:sequence/>
- </xs:complexType>
- </xs:element>
- <xs:element name="pingMeResponse">
- <xs:complexType>
- <xs:sequence/>
- </xs:complexType>
- </xs:element>
- <xs:element name="sayHi">
- <xs:complexType>
- <xs:sequence/>
- </xs:complexType>
- </xs:element>
- <xs:element name="sayHiResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="responseType" type="xs:string"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:schema>
- </wsdl:types>
- <wsdl:message name="sayHiResponse">
- <wsdl:part name="result" element="ns1:sayHiResponse">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="greetMeResponse">
- <wsdl:part name="result" element="ns1:greetMeResponse">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="greetMe">
- <wsdl:part name="parameters" element="ns1:greetMe">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="pingMe">
- <wsdl:part name="parameters" element="ns1:pingMe">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="pingMeResponse">
- <wsdl:part name="result" element="ns1:pingMeResponse">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="sayHi">
- <wsdl:part name="parameters" element="ns1:sayHi">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="PingMeFault">
- <wsdl:part name="PingMeFault" element="ns1:faultDetail">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="greetMeOneWay">
- <wsdl:part name="parameters" element="ns1:greetMeOneWay">
- </wsdl:part>
- </wsdl:message>
- <wsdl:portType name="Greeter">
- <wsdl:operation name="greetMe">
- <wsdl:input name="greetMe" message="tns:greetMe">
- </wsdl:input>
- <wsdl:output name="greetMeResponse" message="tns:greetMeResponse">
- </wsdl:output>
- </wsdl:operation>
- <wsdl:operation name="greetMeOneWay">
- <wsdl:input name="greetMeOneWay" message="tns:greetMeOneWay">
- </wsdl:input>
- </wsdl:operation>
- <wsdl:operation name="sayHi">
- <wsdl:input name="sayHi" message="tns:sayHi">
- </wsdl:input>
- <wsdl:output name="sayHiResponse" message="tns:sayHiResponse">
- </wsdl:output>
- </wsdl:operation>
- <wsdl:operation name="pingMe">
- <wsdl:input name="pingMe" message="tns:pingMe">
- </wsdl:input>
- <wsdl:output name="pingMeResponse" message="tns:pingMeResponse">
- </wsdl:output>
- <wsdl:fault name="PingMeFault" message="tns:PingMeFault">
- </wsdl:fault>
- </wsdl:operation>
- </wsdl:portType>
- <wsdl:binding name="GreeterServiceSoapBinding" type="tns:Greeter">
- <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
- <wsdl:operation name="greetMe">
- <soap:operation soapAction="" style="document"/>
- <wsdl:input name="greetMe">
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output name="greetMeResponse">
- <soap:body use="literal"/>
- </wsdl:output>
- </wsdl:operation>
- <wsdl:operation name="greetMeOneWay">
- <soap:operation soapAction="" style="document"/>
- <wsdl:input name="greetMeOneWay">
- <soap:body use="literal"/>
- </wsdl:input>
- </wsdl:operation>
- <wsdl:operation name="sayHi">
- <soap:operation soapAction="" style="document"/>
- <wsdl:input name="sayHi">
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output name="sayHiResponse">
- <soap:body use="literal"/>
- </wsdl:output>
- </wsdl:operation>
- <wsdl:operation name="pingMe">
- <soap:operation soapAction="" style="document"/>
- <wsdl:input name="pingMe">
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output name="pingMeResponse">
- <soap:body use="literal"/>
- </wsdl:output>
- <wsdl:fault name="PingMeFault">
- <soap:fault name="PingMeFault" use="literal"/>
- </wsdl:fault>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:service name="GreeterService">
- <wsdl:port name="GreeterPort" binding="tns:GreeterServiceSoapBinding">
- <soap:address location="http://localhost:9090"/>
- </wsdl:port>
- </wsdl:service>
-</wsdl:definitions>