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 06db917 cxf-tools-corba: fix PMD rule: UnusedAssignment
06db917 is described below
commit 06db9172c41e43552897e1ec388ac96e0699c6bf
Author: Alexey Markevich <[email protected]>
AuthorDate: Sun Mar 21 02:27:33 2021 +0300
cxf-tools-corba: fix PMD rule: UnusedAssignment
---
.../java/org/apache/cxf/tools/corba/IDLToWSDL.java | 13 +-
.../java/org/apache/cxf/tools/corba/WSDLToIDL.java | 11 +-
.../cxf/tools/corba/common/SchemaFactory.java | 6 +-
.../cxf/tools/corba/common/WSDLCorbaFactory.java | 5 +-
.../cxf/tools/corba/common/idltypes/IdlRoot.java | 8 +-
.../tools/corba/processors/idl/ArrayVisitor.java | 6 +-
.../corba/processors/idl/AttributeVisitor.java | 7 +-
.../corba/processors/idl/DeclaratorVisitor.java | 8 +-
.../corba/processors/idl/DefinitionVisitor.java | 2 +-
.../tools/corba/processors/idl/FixedVisitor.java | 4 +-
.../corba/processors/idl/IDLToWSDLProcessor.java | 13 +-
.../processors/idl/ObjectReferenceVisitor.java | 18 +-
.../corba/processors/idl/OperationVisitor.java | 5 +-
.../corba/processors/idl/ParamDeferredAction.java | 7 +-
.../corba/processors/idl/ParamTypeSpecVisitor.java | 3 +-
.../corba/processors/idl/PortTypeVisitor.java | 2 +-
.../corba/processors/idl/ScopedNameVisitor.java | 16 +-
.../corba/processors/idl/SequenceVisitor.java | 6 +-
.../tools/corba/processors/idl/StringVisitor.java | 4 +-
.../tools/corba/processors/idl/StructVisitor.java | 6 +-
.../cxf/tools/corba/processors/idl/TypesUtils.java | 4 +-
.../tools/corba/processors/idl/TypesVisitor.java | 3 +-
.../tools/corba/processors/idl/UnionVisitor.java | 7 +-
.../tools/corba/processors/idl/WSDLASTVisitor.java | 6 +-
.../tools/corba/processors/wsdl/WSDLParameter.java | 23 +--
.../corba/processors/wsdl/WSDLToCorbaBinding.java | 47 ++---
.../corba/processors/wsdl/WSDLToCorbaHelper.java | 64 +++---
.../processors/wsdl/WSDLToCorbaProcessor.java | 3 +-
.../corba/processors/wsdl/WSDLToIDLAction.java | 36 ++--
.../cxf/tools/corba/processors/wsdl/WSDLTypes.java | 4 +-
.../org/apache/cxf/tools/corba/IDLToWSDLTest.java | 228 ++++++++-------------
.../org/apache/cxf/tools/corba/WSDLToIDLTest.java | 171 +++++-----------
.../cxf/tools/corba/common/ToolTestBase.java | 67 ------
.../idlpreprocessor/IdlPreprocessorReaderTest.java | 15 +-
.../corba/processors/IDLToWSDLGenerationTest.java | 1 -
.../tools/corba/utils/WSDLGenerationTester.java | 34 +--
.../src/test/resources/toolspecs/idl2wsdl.xml | 184 -----------------
.../src/test/resources/toolspecs/wsdl2idl.xml | 112 ----------
.../cxf/tools/wadlto/jaxb/CustomizationParser.java | 26 +--
.../cxf/tools/wadlto/jaxrs/SourceGenerator.java | 6 +-
40 files changed, 307 insertions(+), 884 deletions(-)
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
index debea29..6f3a319 100644
--- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
+++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/IDLToWSDL.java
@@ -20,7 +20,7 @@
package org.apache.cxf.tools.corba;
import java.io.File;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
import org.apache.cxf.common.i18n.Message;
@@ -50,19 +50,14 @@ public class IDLToWSDL extends AbstractCXFToolContainer {
}
private Set<String> getArrayKeys() {
- Set<String> arrayKeys = new HashSet<>();
- arrayKeys.add(ToolCorbaConstants.CFG_INCLUDEDIR);
- return arrayKeys;
+ return Collections.singleton(ToolCorbaConstants.CFG_INCLUDEDIR);
}
public void execute(boolean exitOnFinish) {
- IDLToWSDLProcessor idlProcessor = new IDLToWSDLProcessor();
- ProcessorEnvironment env = null;
-
try {
super.execute(exitOnFinish);
if (!hasInfoOption()) {
- env = new ProcessorEnvironment();
+ ProcessorEnvironment env = new ProcessorEnvironment();
env.setParameters(getParametersMap(getArrayKeys()));
if (isVerboseOn()) {
env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
@@ -70,6 +65,8 @@ public class IDLToWSDL extends AbstractCXFToolContainer {
env.put(ToolConstants.CFG_CMD_ARG, args);
initialise(env);
validate(env);
+
+ IDLToWSDLProcessor idlProcessor = new IDLToWSDLProcessor();
idlProcessor.setEnvironment(env);
idlProcessor.process();
}
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
index b1a0f4a..ff0332f 100644
--- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
+++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/WSDLToIDL.java
@@ -20,7 +20,7 @@
package org.apache.cxf.tools.corba;
import java.io.File;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
import org.apache.cxf.common.i18n.Message;
@@ -53,17 +53,14 @@ public class WSDLToIDL extends AbstractCXFToolContainer {
}
private Set<String> getArrayKeys() {
- return new HashSet<>();
+ return Collections.emptySet();
}
public void execute(boolean exitOnFinish) {
- WSDLToCorbaProcessor corbaProcessor = new WSDLToCorbaProcessor();
- ProcessorEnvironment env = null;
-
try {
super.execute(exitOnFinish);
if (!hasInfoOption()) {
- env = new ProcessorEnvironment();
+ ProcessorEnvironment env = new ProcessorEnvironment();
env.setParameters(getParametersMap(getArrayKeys()));
if (isVerboseOn()) {
env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
@@ -80,6 +77,8 @@ public class WSDLToIDL extends AbstractCXFToolContainer {
initialise(env);
validate(env);
+
+ WSDLToCorbaProcessor corbaProcessor = new
WSDLToCorbaProcessor();
corbaProcessor.setEnvironment(env);
corbaProcessor.process();
}
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java
index 8dc9769..ed81e83 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java
@@ -108,11 +108,9 @@ public abstract class SchemaFactory {
public abstract ExtensionRegistry newPopulatedExtensionRegistry();
private static String findFactoryImplName() {
- String factoryImplName = null;
-
// First, check the system property.
try {
- factoryImplName = System.getProperty(PROPERTY_NAME);
+ String factoryImplName = System.getProperty(PROPERTY_NAME);
if (factoryImplName != null) {
return factoryImplName;
@@ -131,7 +129,7 @@ public abstract class SchemaFactory {
properties.load(is);
}
- factoryImplName = properties.getProperty(PROPERTY_NAME);
+ String factoryImplName = properties.getProperty(PROPERTY_NAME);
if (factoryImplName != null) {
return factoryImplName;
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java
index 43c5c6c..2521505 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java
@@ -120,11 +120,10 @@ public abstract class WSDLCorbaFactory {
public abstract ExtensionRegistry newPopulatedExtensionRegistry();
private static String findFactoryImplName() {
- String factoryImplName = null;
// First, check the system property.
try {
- factoryImplName = System.getProperty(PROPERTY_NAME);
+ String factoryImplName = System.getProperty(PROPERTY_NAME);
if (factoryImplName != null) {
return factoryImplName;
@@ -143,7 +142,7 @@ public abstract class WSDLCorbaFactory {
properties.load(is);
}
- factoryImplName = properties.getProperty(PROPERTY_NAME);
+ String factoryImplName = properties.getProperty(PROPERTY_NAME);
if (factoryImplName != null) {
return factoryImplName;
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/idltypes/IdlRoot.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/idltypes/IdlRoot.java
index 73ed2c2..bcde40b 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/idltypes/IdlRoot.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/idltypes/IdlRoot.java
@@ -27,13 +27,11 @@ import java.util.Map;
public final class IdlRoot extends IdlScopeBase {
- private Map<String, IdlType> primitiveTypes;
- private List<String> includeList;
+ private final Map<String, IdlType> primitiveTypes = new HashMap<>();
+ private final List<String> includeList = new ArrayList<>();
private IdlRoot() {
super(null, "");
- primitiveTypes = new HashMap<>();
- includeList = new ArrayList<>();
for (short i = IdlPrimitive.MINIMUM; i <= IdlPrimitive.MAXIMUM; ++i) {
IdlPrimitive prim = IdlPrimitive.create(this, i);
@@ -55,7 +53,7 @@ public final class IdlRoot extends IdlScopeBase {
public IdlDefn lookup(String nm, boolean undefined) {
- IdlDefn result = null;
+ final IdlDefn result;
if (!undefined && primitiveTypes.containsKey(nm)) {
result = primitiveTypes.get(nm);
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ArrayVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ArrayVisitor.java
index 5d8fcdd..076a9a3 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ArrayVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ArrayVisitor.java
@@ -80,7 +80,7 @@ public class ArrayVisitor extends VisitorBase {
AST firstSizeNode = node.getFirstChild();
AST nextSizeNode = firstSizeNode.getNextSibling();
- Types result = null;
+ final Types result;
// process all anonarrays, skip first array as it might not be
anonymous
if (nextSizeNode != null) {
@@ -94,8 +94,8 @@ public class ArrayVisitor extends VisitorBase {
// process first array
Long size = Long.valueOf(firstSizeNode.toString());
- XmlSchemaType stype = null;
- CorbaType ctype = null;
+ final XmlSchemaType stype;
+ final CorbaType ctype;
if (identifierNode != null) {
Scope scopedName = getScope();
if (result.getSchemaType() != null) {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java
index 4b1af8b..54f040b 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/AttributeVisitor.java
@@ -97,8 +97,7 @@ public class AttributeVisitor extends VisitorBase {
AST node = attributeNode.getFirstChild();
AST readonlyNode = null;
- AST typeNode = null;
- AST nameNode = null;
+ final AST typeNode;
if (node.getType() == IDLTokenTypes.LITERAL_readonly) {
readonlyNode = node;
@@ -106,7 +105,7 @@ public class AttributeVisitor extends VisitorBase {
} else {
typeNode = node;
}
- nameNode = TypesUtils.getCorbaTypeNameNode(typeNode);
+ AST nameNode = TypesUtils.getCorbaTypeNameNode(typeNode);
while (nameNode != null) {
// getter is generated for readonly and readwrite attributes
generateGetter(typeNode, nameNode);
@@ -357,7 +356,7 @@ public class AttributeVisitor extends VisitorBase {
* @return the generated corba:operation.
*/
private OperationType generateCorbaOperation(Operation op, ParamType
param, ArgType arg) {
- OperationType operation = null;
+ final OperationType operation;
try {
operation =
(OperationType)extReg.createExtension(BindingOperation.class,
CorbaConstants.NE_CORBA_OPERATION);
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DeclaratorVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DeclaratorVisitor.java
index f8d623f..1891539 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DeclaratorVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DeclaratorVisitor.java
@@ -96,7 +96,6 @@ public class DeclaratorVisitor extends VisitorBase {
private void visitNewTypes(Scope newScope) {
CorbaType nextCorbaType = null;
- XmlSchemaType nextSchemaType = null;
CorbaType oldCorbaType = getCorbaType();
@@ -118,7 +117,7 @@ public class DeclaratorVisitor extends VisitorBase {
// Sequence
//
- nextSchemaType = duplicateXmlSchemaComplexType(newScope);
+ XmlSchemaType nextSchemaType =
duplicateXmlSchemaComplexType(newScope);
Sequence oldSequence = (Sequence) oldCorbaType;
Sequence newSequence = new Sequence();
@@ -135,7 +134,8 @@ public class DeclaratorVisitor extends VisitorBase {
// Fixed
//
- nextSchemaType = duplicateXmlSchemaSimpleType(newScope);
+// nextSchemaType =
+ duplicateXmlSchemaSimpleType(newScope);
Fixed oldFixed = (Fixed) getCorbaType();
Fixed newFixed = new Fixed();
@@ -149,7 +149,7 @@ public class DeclaratorVisitor extends VisitorBase {
nextCorbaType = newFixed;
} else {
System.err.println("[DeclaratorVisitor: Unexpected CORBA type
error!]");
- System.exit(1);
+ System.exit(1); //NOPMD
}
if (nextCorbaType != null) {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DefinitionVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DefinitionVisitor.java
index 0611f6d..959c35e 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DefinitionVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/DefinitionVisitor.java
@@ -46,7 +46,7 @@ public class DefinitionVisitor extends VisitorBase {
case IDLTokenTypes.LITERAL_custom:
case IDLTokenTypes.LITERAL_valuetype: {
System.out.println("Valuetypes not supported");
- System.exit(1);
+ System.exit(1); //NOPMD
break;
}
case IDLTokenTypes.LITERAL_module: {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
index 1cc9e5f..eacbb7d 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/FixedVisitor.java
@@ -78,7 +78,7 @@ public class FixedVisitor extends VisitorBase {
AST digitsNode = fixedNode.getFirstChild();
AST scaleNode = digitsNode.getNextSibling();
- Scope scopedName = null;
+ final Scope scopedName;
if (identifierNode == null) {
scopedName = TypesUtils.generateAnonymousScopedName(getScope(),
schema);
} else {
@@ -116,7 +116,7 @@ public class FixedVisitor extends VisitorBase {
// add xmlschema:fixed
setSchemaType(fixedSimpleType);
- CorbaType type = null;
+ final CorbaType type;
if (identifierNode != null) {
// corba:fixed
Fixed corbaFixed = new Fixed();
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
index ec13483..538ed2f 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/IDLToWSDLProcessor.java
@@ -243,10 +243,9 @@ public class IDLToWSDLProcessor extends IDLProcessor {
if (outputWriter == null) {
outputWriter = getOutputWriter(idl + ".wsdl", outputDir);
}
- String separator = System.getProperty("file.separator");
- File file = null;
+ final File file;
if (env.get(ToolConstants.CFG_OUTPUTDIR) != null) {
- file = new File(outputDir + separator + idl + ".wsdl");
+ file = new File(outputDir, idl + ".wsdl");
} else {
file = new File(idl + ".wsdl");
}
@@ -357,7 +356,7 @@ public class IDLToWSDLProcessor extends IDLProcessor {
System.err.println("IDLToWsdl Error : " + ex.getMessage());
System.err.println();
ex.printStackTrace();
- System.exit(1);
+ System.exit(1); //NOPMD
} else {
URI url = file.toURI();
return url.toString();
@@ -371,9 +370,9 @@ public class IDLToWSDLProcessor extends IDLProcessor {
}
private Writer createOutputWriter(String name) throws Exception {
- String outDir = outputDir;
+// String outDir = outputDir;
int index = name.lastIndexOf(System.getProperty("file.separator"));
- outDir = name.substring(0, index);
+ String outDir = name.substring(0, index);
String filename = name.substring(index + 1, name.length());
return getOutputWriter(filename, outDir);
}
@@ -493,7 +492,7 @@ public class IDLToWSDLProcessor extends IDLProcessor {
(AddressType)
def.getExtensionRegistry().createExtension(Port.class,
CorbaConstants.NE_CORBA_ADDRESS);
- String addr = null;
+ String addr;
String addrFileName = (String)
env.get(ToolCorbaConstants.CFG_ADDRESSFILE);
if (addrFileName != null) {
File addrFile = new File(addrFileName);
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
index 48a27b9..d6bbe86 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ObjectReferenceVisitor.java
@@ -241,7 +241,7 @@ public class ObjectReferenceVisitor extends VisitorBase {
private void isDuplicateReference(QName referenceName, QName bindingName,
Scope refScope,
XmlSchemaType wsaType, AST node) {
- XmlSchema refSchema = null;
+ XmlSchema refSchema;
if (!mapper.isDefaultMapping()) {
String tns = mapper.map(refScope.getParent());
String refSchemaFileName = getWsdlVisitor().getOutputDir()
@@ -410,7 +410,7 @@ public class ObjectReferenceVisitor extends VisitorBase {
if ((node.getFirstChild() == null)
|| (node.getFirstChild() != null && node.getFirstChild().getType()
!= IDLTokenTypes.SCOPEOP)) {
while (!isForward && currentScope != currentScope.getParent()) {
- Scope scopedName = null;
+ final Scope scopedName;
if (ScopedNameVisitor.isFullyScopedName(node)) {
scopedName =
ScopedNameVisitor.getFullyScopedName(currentScope, node);
} else {
@@ -426,7 +426,7 @@ public class ObjectReferenceVisitor extends VisitorBase {
}
// Check for forward declaration in global scope
if (!isForward) {
- Scope scopedName = null;
+ final Scope scopedName;
if (ScopedNameVisitor.isFullyScopedName(node)) {
scopedName = ScopedNameVisitor.getFullyScopedName(new Scope(),
node);
} else {
@@ -455,7 +455,7 @@ public class ObjectReferenceVisitor extends VisitorBase {
if ((node.getFirstChild() == null)
|| (node.getFirstChild() != null && node.getFirstChild().getType()
!= IDLTokenTypes.SCOPEOP)) {
while (result == null && currentScope != currentScope.getParent())
{
- Scope scopedName = null;
+ final Scope scopedName;
if (ScopedNameVisitor.isFullyScopedName(node)) {
scopedName =
ScopedNameVisitor.getFullyScopedName(currentScope, node);
} else {
@@ -485,7 +485,7 @@ public class ObjectReferenceVisitor extends VisitorBase {
}
}
if (result == null) {
- Scope scopedName = null;
+ final Scope scopedName;
if (ScopedNameVisitor.isFullyScopedName(node)) {
scopedName = ScopedNameVisitor.getFullyScopedName(new Scope(),
node);
} else {
@@ -520,32 +520,32 @@ public class ObjectReferenceVisitor extends VisitorBase {
AST node, WSDLASTVisitor wsdlVisitor) {
boolean result = false;
QName bindingName = null;
- String repositoryID = null;
Scope currentScope = scope;
- Scope customScope = null;
if ((node.getFirstChild() == null) || (node.getFirstChild() != null
&& node.getFirstChild().getType() != IDLTokenTypes.SCOPEOP)) {
while (bindingName == null
&& currentScope != currentScope.getParent()) {
+ final Scope customScope;
if (ScopedNameVisitor.isFullyScopedName(node)) {
customScope =
ScopedNameVisitor.getFullyScopedName(currentScope, node);
} else {
customScope = new Scope(currentScope, node);
}
- repositoryID = customScope.toIDLRepositoryID();
+ String repositoryID = customScope.toIDLRepositoryID();
bindingName = getBindingQNameByID(def, repositoryID,
wsdlVisitor);
currentScope = currentScope.getParent();
}
}
if (bindingName == null) {
+ final Scope customScope;
// Global scope is our last chance to resolve the node
if (ScopedNameVisitor.isFullyScopedName(node)) {
customScope = ScopedNameVisitor.getFullyScopedName(new
Scope(), node);
} else {
customScope = new Scope(new Scope(), node);
}
- repositoryID = customScope.toIDLRepositoryID();
+ String repositoryID = customScope.toIDLRepositoryID();
bindingName = getBindingQNameByID(def, repositoryID, wsdlVisitor);
if (bindingName == null) {
//check bindingName with prefix
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
index da5ce7f..c06f0cc 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/OperationVisitor.java
@@ -129,7 +129,7 @@ public class OperationVisitor extends VisitorBase {
Operation operation = generateOperation(operationQName.getLocalPart(),
isDuplicate);
- BindingOperation bindingOperation = null;
+ final BindingOperation bindingOperation;
if (isDuplicate) {
bindingOperation = generateBindingOperation(binding, operation,
operationQName.getLocalPart());
} else {
@@ -146,7 +146,6 @@ public class OperationVisitor extends VisitorBase {
// <op_attribute>
node = node.getFirstChild();
XmlSchemaSequence outputWrappingSequence = null;
- XmlSchemaElement outputElement = null;
if (node != null && (node.getType() == IDLTokenTypes.LITERAL_oneway)) {
// oneway operations map to operations with only input message
// no outputMsg nor outputPart need be created
@@ -155,7 +154,7 @@ public class OperationVisitor extends VisitorBase {
// normal operations map to request-response operations
// with input and output messages
outputWrappingSequence = new XmlSchemaSequence();
- outputElement = generateWrapper(new
QName(schema.getTargetNamespace(),
+ XmlSchemaElement outputElement = generateWrapper(new
QName(schema.getTargetNamespace(),
operation.getName() +
RESPONSE_SUFFIX),
outputWrappingSequence);
outputMsg = generateOutputMessage(operation, bindingOperation);
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamDeferredAction.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamDeferredAction.java
index 18f67bb..b968ab5 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamDeferredAction.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamDeferredAction.java
@@ -81,7 +81,6 @@ public class ParamDeferredAction implements
SchemaDeferredAction {
}
// Now we need to make sure we are importing any types we need
- XmlSchema importedSchema = null;
if
(stype.getQName().getNamespaceURI().equals(ReferenceConstants.WSADDRESSING_NAMESPACE))
{
boolean alreadyImported = false;
for (XmlSchemaExternal ext : schema.getExternals()) {
@@ -101,14 +100,10 @@ public class ParamDeferredAction implements
SchemaDeferredAction {
wsaImport.setSchemaLocation(ReferenceConstants.WSADDRESSING_LOCATION);
}
} else if
(!stype.getQName().getNamespaceURI().equals(schema.getTargetNamespace())) {
- importedSchema = manager.getXmlSchema(mapper.map(typeScope));
+ XmlSchema importedSchema =
manager.getXmlSchema(mapper.map(typeScope));
manager.addXmlSchemaImport(schema, importedSchema,
typeScope.toString("_"));
}
}
}
}
-
-
-
-
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamTypeSpecVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamTypeSpecVisitor.java
index 7fd6660..9cf5649 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamTypeSpecVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ParamTypeSpecVisitor.java
@@ -41,8 +41,7 @@ public class ParamTypeSpecVisitor extends VisitorBase {
// | <scoped_name>
- Visitor visitor = null;
-
+ final Visitor visitor;
if (PrimitiveTypesVisitor.accept(node)) {
// base_type_spec
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java
index 18cef1b..b3f2348 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/PortTypeVisitor.java
@@ -121,7 +121,7 @@ public class PortTypeVisitor extends VisitorBase {
specNode = specNode.getNextSibling();
}
- AST exportNode = null;
+ AST exportNode;
if (specNode.getType() == IDLTokenTypes.RCURLY) {
exportNode = specNode.getNextSibling();
} else if (specNode.getType() == IDLTokenTypes.COLON) {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
index 74645cf..e747276 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/ScopedNameVisitor.java
@@ -151,7 +151,7 @@ public class ScopedNameVisitor extends VisitorBase {
TypeMappingType typeMap,
XmlSchemaType stype,
Scope scopedName) {
- CorbaType ctype = null;
+ final CorbaType ctype;
if (stype.getQName().equals(Constants.XSD_STRING)) {
ctype = new CorbaType();
ctype.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
@@ -177,7 +177,7 @@ public class ScopedNameVisitor extends VisitorBase {
if ((node.getFirstChild() == null)
|| (node.getFirstChild() != null && node.getFirstChild().getType()
!= IDLTokenTypes.SCOPEOP)) {
while (!isForward && currentScope != currentScope.getParent()) {
- Scope scopedName = null;
+ final Scope scopedName;
if (isFullyScopedName(node)) {
scopedName = getFullyScopedName(currentScope, node);
} else {
@@ -194,7 +194,7 @@ public class ScopedNameVisitor extends VisitorBase {
}
// Check for forward declaration in global scope
if (!isForward) {
- Scope scopedName = null;
+ final Scope scopedName;
if (isFullyScopedName(node)) {
scopedName = getFullyScopedName(new Scope(), node);
} else {
@@ -224,7 +224,7 @@ public class ScopedNameVisitor extends VisitorBase {
if ((node.getFirstChild() == null)
|| (node.getFirstChild() != null && node.getFirstChild().getType()
!= IDLTokenTypes.SCOPEOP)) {
while (result == null && currentScope != currentScope.getParent())
{
- Scope scopedName = null;
+ final Scope scopedName;
if (isFullyScopedName(node)) {
scopedName = getFullyScopedName(currentScope, node);
} else {
@@ -249,7 +249,7 @@ public class ScopedNameVisitor extends VisitorBase {
}
// Check for forward declaration in global scope
if (result == null) {
- Scope scopedName = null;
+ final Scope scopedName;
if (isFullyScopedName(node)) {
scopedName = getFullyScopedName(new Scope(), node);
} else {
@@ -300,7 +300,7 @@ public class ScopedNameVisitor extends VisitorBase {
// it will be resolved by successvely n searching farther out
in
// enclosing scopes, while taking into consideration
// inheritance relationships among interfaces.
- Scope scopedName = null;
+ final Scope scopedName;
if (isFullyScopedName(node)) {
scopedName = getFullyScopedName(currentScope, node);
} else {
@@ -467,7 +467,6 @@ public class ScopedNameVisitor extends VisitorBase {
boolean result = findNonSchemaType(scopedName.toString(), wsdlVisitor,
holder);
if (!result) {
- QName qname = null;
XmlSchema xmlSchema = schemaRef;
String tns =
wsdlVisitor.getModuleToNSMapper().map(scopedName.getParent());
if (tns != null) {
@@ -481,13 +480,14 @@ public class ScopedNameVisitor extends VisitorBase {
// so the name
// and the typename will be different.
- String scopedNameString = null;
+ final String scopedNameString;
if (mapper.isDefaultMapping()) {
scopedNameString = scopedName.toString();
} else {
scopedNameString = scopedName.tail();
}
+ final QName qname;
if (exceptionMode) {
qname = new QName(xmlSchema.getTargetNamespace(),
scopedNameString + "Type");
} else {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/SequenceVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/SequenceVisitor.java
index 4666d31..1bbcc11 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/SequenceVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/SequenceVisitor.java
@@ -89,7 +89,7 @@ public class SequenceVisitor extends VisitorBase {
bound = Long.parseLong(boundNode.toString());
}
- Scope scopedName = null;
+ final Scope scopedName;
if (identifierNode == null) {
// anonymous type
scopedName = TypesUtils.generateAnonymousScopedName(getScope(),
schema);
@@ -97,7 +97,7 @@ public class SequenceVisitor extends VisitorBase {
scopedName = new Scope(getScope(), identifierNode);
}
- XmlSchemaType schemaType = null;
+ final XmlSchemaType schemaType;
// According to CORBA Binding for WSDL specification,
// idl:sequence<octet> maps to xs:base64Binary by default.
@@ -116,7 +116,7 @@ public class SequenceVisitor extends VisitorBase {
schemaType = generateSchemaType(null, scopedName, bound,
fullyQualifiedName);
}
- CorbaType corbaType = null;
+ final CorbaType corbaType;
if (identifierNode == null) {
corbaType = generateCorbaAnonsequence(ctype,
schemaType,
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java
index 06afbfa..5ff9a11 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StringVisitor.java
@@ -124,7 +124,7 @@ public class StringVisitor extends VisitorBase {
setSchemaType(simpleType);
- CorbaType anon = null;
+ final CorbaType anon;
if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
// corba:anonstring
Anonstring anonstring = new Anonstring();
@@ -169,7 +169,7 @@ public class StringVisitor extends VisitorBase {
Scope anonstringScopedName = new Scope(getScope(), "_Anon1_" +
stringScopedName.tail());
String anonstringName = anonstringScopedName.toString();
- CorbaType anon = null;
+ final CorbaType anon;
if (stringNode.getType() == IDLTokenTypes.LITERAL_string) {
// corba:anonstring
Anonstring anonstring = new Anonstring();
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
index aa26056..39cda36 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/StructVisitor.java
@@ -110,9 +110,9 @@ public class StructVisitor extends VisitorBase {
while (memberTypeNode != null) {
AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
- XmlSchemaType schemaType = null;
- CorbaType corbaType = null;
- Scope fqName = null;
+ final XmlSchemaType schemaType;
+ final CorbaType corbaType;
+ Scope fqName;
try {
TypesVisitor visitor = new TypesVisitor(structScope,
definition,
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesUtils.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesUtils.java
index d2ac074..c91ce2a 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesUtils.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesUtils.java
@@ -84,8 +84,8 @@ public final class TypesUtils {
}
public static Scope generateAnonymousScopedName(Scope scope, XmlSchema
schema) {
- Scope scopedName = null;
- XmlSchemaType anonSchemaType = null;
+ Scope scopedName;
+ XmlSchemaType anonSchemaType;
int id = 0;
do {
id++;
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesVisitor.java
index 0717ec7..6544a6d 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/TypesVisitor.java
@@ -51,8 +51,7 @@ public class TypesVisitor extends VisitorBase {
// <type_spec> ::= <simple_type_spec>
// | <constr_type_spec>
- Visitor visitor = null;
-
+ final Visitor visitor;
if (ConstrTypeSpecVisitor.accept(node)) {
// type_spec - constr_type_spec
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java
index cccf951..d42377d 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/UnionVisitor.java
@@ -141,9 +141,8 @@ public class UnionVisitor extends VisitorBase {
XmlSchemaChoice choice,
Union corbaUnion) {
while (caseNode != null) {
- AST typeNode = null;
- AST nameNode = null;
- AST labelNode = null;
+ final AST typeNode;
+ final AST nameNode;
// xmlschema:element
XmlSchemaElement element = new XmlSchemaElement(schema, false);
@@ -161,7 +160,7 @@ public class UnionVisitor extends VisitorBase {
// case:
createCase(caseNode, unionBranch);
- labelNode = caseNode.getFirstChild();
+ AST labelNode = caseNode.getFirstChild();
if (labelNode.getType() == IDLTokenTypes.LITERAL_case) {
labelNode = labelNode.getNextSibling();
}
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
index 8bc1871..6fbb8df 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/idl/WSDLASTVisitor.java
@@ -228,7 +228,7 @@ public final class WSDLASTVisitor implements ASTVisitor {
}
public void setSequenceOctetType(String type) throws Exception {
- XmlSchemaType stype = null;
+ final XmlSchemaType stype;
if
(type.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_BASE64BINARY)) {
stype = schemas.getTypeByQName(Constants.XSD_BASE64);
} else if
(type.equals(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_HEXBINARY)) {
@@ -301,7 +301,7 @@ public final class WSDLASTVisitor implements ASTVisitor {
String physicalFile) throws Exception {
Definition logicalDef = getLogicalDefinition(schemaFilename,
schemaWriter);
- Definition physicalDef = null;
+ final Definition physicalDef;
// schema only
if ((schemaFilename != null || importSchemaFilename != null)
&& (logicalFile == null && physicalFile == null)) {
@@ -403,7 +403,7 @@ public final class WSDLASTVisitor implements ASTVisitor {
private Definition getPhysicalDefinition(Definition logicalDef, boolean
schemaOnly)
throws WSDLException, JAXBException {
- Definition def = null;
+ final Definition def;
if (schemaOnly) {
def = logicalDef;
} else {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java
index 640fc49..f84566d 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLParameter.java
@@ -410,9 +410,7 @@ public final class WSDLParameter {
// Will check if the schema includes other schemas.
private static XmlSchemaElement findElement(XmlSchema xmlSchema, QName
elName) {
- XmlSchemaElement schemaElement = null;
-
- schemaElement = xmlSchema.getElementByName(elName);
+ XmlSchemaElement schemaElement = xmlSchema.getElementByName(elName);
if (schemaElement == null) {
String prefix = definition.getPrefix(elName.getNamespaceURI());
QName name = new QName(elName.getNamespaceURI(), prefix + ":" +
elName.getLocalPart(), prefix);
@@ -434,10 +432,9 @@ public final class WSDLParameter {
private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding,
XmlSchemaType schemaType,
QName typeName, boolean nill) throws
Exception {
- QName idltype = null;
- CorbaType corbaTypeImpl = null;
+ final QName idltype;
if (schemaType == null) {
- corbaTypeImpl =
(CorbaType)WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
+ CorbaType corbaTypeImpl =
(CorbaType)WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
if (nill) {
QName qname = corbaTypeImpl.getQName();
idltype =
wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart()
@@ -485,10 +482,8 @@ public final class WSDLParameter {
private static QName getSchemaTypeName(WSDLToCorbaBinding
wsdlToCorbaBinding, XmlSchemaType schemaType,
XmlSchemaAnnotation annotation,
QName typeName, boolean nill)
throws Exception {
- QName idltype = null;
- CorbaType corbaTypeImpl = null;
-
- corbaTypeImpl =
wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType, typeName,
null,
+ final QName idltype;
+ CorbaType corbaTypeImpl =
wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType, typeName,
null,
annotation, false);
if (corbaTypeImpl == null) {
throw new Exception("Couldn't convert schema type to corba type :
" + typeName);
@@ -559,9 +554,8 @@ public final class WSDLParameter {
// RULE No.3:
// The output message part refers to a global element declaration
- Part outputPart = null;
if (outputMessage != null && outputMessage.getParts().size() == 1) {
- outputPart =
(Part)outputMessage.getParts().values().iterator().next();
+ Part outputPart =
(Part)outputMessage.getParts().values().iterator().next();
if (outputPart != null) {
if ((outputPart.getElementName() == null) ||
getElement(outputPart, xmlSchemaList) == null) {
passedRule = false;
@@ -581,9 +575,8 @@ public final class WSDLParameter {
// Now lets see if we have any attributes...
// This should probably look at the restricted and substitute types
too.
- XmlSchemaComplexType xsct = null;
if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
- xsct = (XmlSchemaComplexType)inputEl.getSchemaType();
+ XmlSchemaComplexType xsct =
(XmlSchemaComplexType)inputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
@@ -597,7 +590,7 @@ public final class WSDLParameter {
if (outputMessage != null) {
if (outputEl != null && outputEl.getSchemaType() instanceof
XmlSchemaComplexType) {
- xsct = (XmlSchemaComplexType)outputEl.getSchemaType();
+ XmlSchemaComplexType xsct =
(XmlSchemaComplexType)outputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
index 7d12a41..0867edc 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaBinding.java
@@ -137,7 +137,7 @@ public class WSDLToCorbaBinding {
xmlSchemaList = typeProcessor.getXmlSchemaTypes();
helper.setXMLSchemaList(xmlSchemaList);
- List<PortType> intfs = null;
+ final List<PortType> intfs;
if (!interfaceNames.isEmpty()) {
intfs = new ArrayList<>(interfaceNames.size());
@@ -159,7 +159,7 @@ public class WSDLToCorbaBinding {
if (portType == null) {
String msgStr = "PortType " + interfaceName
+ " doesn't exist in WSDL.";
- throw new Exception(msgStr);
+ throw new ToolException(msgStr);
}
intfs.add(portType);
}
@@ -178,17 +178,16 @@ public class WSDLToCorbaBinding {
private List<PortType> getPortTypeList() throws Exception {
Map<QName, PortType> portTypes = CastUtils.cast(def.getAllPortTypes());
- List<PortType> intfs = null;
if (portTypes == null) {
org.apache.cxf.common.i18n.Message msg = new
org.apache.cxf.common.i18n.Message(
"No PortTypes defined in wsdl", LOG);
throw new Exception(msg.toString());
}
- PortType portType = null;
- intfs = new ArrayList<>();
+
+ List<PortType> intfs = new ArrayList<>();
if (portTypes.size() == 1) {
- portType = portTypes.values().iterator().next();
+ PortType portType = portTypes.values().iterator().next();
interfaceNames.add(portType.getQName().getLocalPart());
intfs.add(portType);
} else if (portTypes.size() > 1) {
@@ -213,13 +212,13 @@ public class WSDLToCorbaBinding {
int cnt = 0;
while (it2.hasNext()) {
cnt++;
- sb.append(" " + cnt + " --> " + it2.next().getLocalPart());
+ sb.append(" ").append(cnt).append(" -->
").append(it2.next().getLocalPart());
}
throw new Exception(sb.toString());
}
private Binding generateCORBABinding(Definition definition, PortType
portType) throws Exception {
- QName bqname = null;
+ QName bqname;
if (extReg == null) {
extReg = def.getExtensionRegistry();
@@ -255,7 +254,7 @@ public class WSDLToCorbaBinding {
+ " already exists in WSDL.";
org.apache.cxf.common.i18n.Message msg =
new org.apache.cxf.common.i18n.Message(msgStr, LOG);
- throw new Exception(msg.toString());
+ throw new ToolException(msg.toString());
}
}
@@ -266,19 +265,17 @@ public class WSDLToCorbaBinding {
def.addNamespace(pfx, CorbaConstants.NU_WSDL_CORBA);
}
- Binding binding = null;
- binding = def.createBinding();
+ Binding binding = def.createBinding();
binding.setPortType(portType);
binding.setQName(bqname);
bindingNames.add(bname);
mapBindingToInterface(portType.getQName().getLocalPart(), bname);
- BindingType bindingType = null;
addCorbaTypeMap(def);
try {
- bindingType = (BindingType)extReg
+ BindingType bindingType = (BindingType)extReg
.createExtension(Binding.class,
CorbaConstants.NE_CORBA_BINDING);
bindingType.setRepositoryID(WSDLToCorbaHelper.REPO_STRING
+
binding.getPortType().getQName().getLocalPart().replace('.', '/')
@@ -336,7 +333,7 @@ public class WSDLToCorbaBinding {
(AddressType)
def.getExtensionRegistry().createExtension(Port.class,
CorbaConstants.NE_CORBA_ADDRESS);
- String addr = null;
+ String addr;
if (getAddressFile() != null) {
File addrFile = new File(getAddressFile());
try {
@@ -404,7 +401,7 @@ public class WSDLToCorbaBinding {
private void addCorbaOperationExtElement(BindingOperation bo, Operation op)
throws Exception {
- OperationType operationType = null;
+ final OperationType operationType;
try {
operationType =
(OperationType)extReg.createExtension(BindingOperation.class,
CorbaConstants.NE_CORBA_OPERATION);
@@ -483,22 +480,20 @@ public class WSDLToCorbaBinding {
private void addCorbaTypes(XmlSchema xmlSchemaTypes) throws Exception {
Map<QName, XmlSchemaType> objs = xmlSchemaTypes.getSchemaTypes();
- CorbaType corbaTypeImpl = null;
for (XmlSchemaType type : objs.values()) {
boolean anonymous = WSDLTypes.isAnonymous(type.getName());
- corbaTypeImpl = helper.convertSchemaToCorbaType(type,
type.getQName(), null,
+ CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(type,
type.getQName(), null,
null, anonymous);
if (corbaTypeImpl != null
&& !helper.isDuplicate(corbaTypeImpl)) {
typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
}
}
- addCorbaElements(corbaTypeImpl, xmlSchemaTypes);
+ addCorbaElements(xmlSchemaTypes);
}
- private void addCorbaElements(CorbaType corbaTypeImpl,
- XmlSchema xmlSchemaTypes) throws Exception {
+ private void addCorbaElements(XmlSchema xmlSchemaTypes) throws Exception {
Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
for (XmlSchemaElement el : elements.values()) {
QName elName = el.getQName();
@@ -507,7 +502,7 @@ public class WSDLToCorbaBinding {
elName = el.getRef().getTargetQName();
schemaType = helper.getSchemaType(elName);
}
- boolean anonymous = false;
+ boolean anonymous;
if (schemaType == null) {
anonymous = true;
} else {
@@ -545,7 +540,7 @@ public class WSDLToCorbaBinding {
}
}
}
- corbaTypeImpl =
+ CorbaType corbaTypeImpl =
helper.convertSchemaToCorbaType(schemaType,
elName, schemaType,
annotation, anonymous);
@@ -569,7 +564,6 @@ public class WSDLToCorbaBinding {
private CorbaType convertFaultToCorbaType(XmlSchema xmlSchema, Fault
fault) throws Exception {
org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
- XmlSchemaType schemaType = null;
Iterator<Part> parts =
CastUtils.cast(fault.getMessage().getParts().values().iterator());
if (!parts.hasNext()) {
@@ -581,7 +575,7 @@ public class WSDLToCorbaBinding {
}
Part part = parts.next();
- schemaType = helper.lookUpType(part);
+ XmlSchemaType schemaType = helper.lookUpType(part);
if (schemaType != null) {
QName name = schemaType.getQName();
if (name == null) {
@@ -651,11 +645,10 @@ public class WSDLToCorbaBinding {
XmlSchemaType stype)
throws Exception {
org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
- XmlSchemaComplexType complex = null;
if (stype instanceof XmlSchemaComplexType) {
QName defaultName = schemaTypeName;
- complex = (XmlSchemaComplexType)stype;
+ XmlSchemaComplexType complex = (XmlSchemaComplexType)stype;
corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
corbaex.setQName(schemaTypeName);
corbaex.setType(helper.checkPrefix(schemaTypeName));
@@ -870,7 +863,7 @@ public class WSDLToCorbaBinding {
if (verboseOn) {
ex.printStackTrace();
}
- System.exit(1);
+ System.exit(1); //NOPMD
}
}
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaHelper.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaHelper.java
index 4428d61..0cd6cde 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaHelper.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaHelper.java
@@ -94,7 +94,7 @@ public class WSDLToCorbaHelper {
protected static final Logger LOG =
LogUtils.getL7dLogger(WSDLToCorbaHelper.class);
protected static final String[] DISCRIMINATORTYPES
- = new String[] {"long", "short", "boolean", "char"};
+ = {"long", "short", "boolean", "char"};
protected static final Set<String> SUPPORTEDDISTYPES =
new TreeSet<>(Arrays.asList(DISCRIMINATORTYPES));
@@ -169,7 +169,7 @@ public class WSDLToCorbaHelper {
throws Exception {
List<MemberType> members = new ArrayList<>();
- Iterator<? extends XmlSchemaObjectBase> iterL = null;
+ final Iterator<? extends XmlSchemaObjectBase> iterL;
if (particle instanceof XmlSchemaSequence) {
XmlSchemaSequence scontainer = (XmlSchemaSequence)particle;
iterL = scontainer.getItems().iterator();
@@ -274,7 +274,7 @@ public class WSDLToCorbaHelper {
QName defaultName,
QName schemaTypeName)
throws Exception {
- QName choicename = null;
+ QName choicename;
if (schemaTypeName == null) {
choicename = createQNameCorbaNamespace(defaultName.getLocalPart());
@@ -349,7 +349,7 @@ public class WSDLToCorbaHelper {
} else if (schemaType != null) {
XmlSchemaType st = schemaType;
boolean anonymous = WSDLTypes.isAnonymous(st.getName());
- QName typeName = null;
+ final QName typeName;
if (anonymous) {
typeName = new QName(elemName.getNamespaceURI(),
containingTypeName.getLocalPart() + "." +
elemName.getLocalPart());
@@ -368,7 +368,7 @@ public class WSDLToCorbaHelper {
if (element.getMaxOccurs() != 1 || element.getMinOccurs() != 1) {
QName name = createQNameCorbaNamespace(getModulePrefix(membertype)
+ elemName.getLocalPart()
+ "Array");
- CorbaType arraytype = null;
+ final CorbaType arraytype;
if (memName != null) {
arraytype = createArray(name, /*schemaName*/name, memName,
elemName,
element.getMaxOccurs(),
element.getMinOccurs(), false);
@@ -428,8 +428,7 @@ public class WSDLToCorbaHelper {
protected CorbaType processSequenceType(XmlSchemaSequence seq,
QName defaultName, QName
schemaTypeName)
throws Exception {
- CorbaType type = null;
- QName seqName = null;
+ final QName seqName;
if (schemaTypeName == null) {
seqName = createQNameCorbaNamespace(defaultName.getLocalPart() +
"SequenceStruct");
} else {
@@ -448,7 +447,7 @@ public class WSDLToCorbaHelper {
struct.getMember().add(memberType);
}
- type = struct;
+ CorbaType type = struct;
if (seq.getMaxOccurs() != 1 || seq.getMinOccurs() != 1) {
QName name =
createQNameTargetNamespace(type.getQName().getLocalPart() + "Array");
@@ -475,8 +474,7 @@ public class WSDLToCorbaHelper {
protected CorbaType processAllType(XmlSchemaAll seq, QName defaultName,
QName schematypeName) throws
Exception {
- QName allName = null;
- Struct type = null;
+ final QName allName;
if (schematypeName == null) {
allName = createQNameCorbaNamespace(defaultName.getLocalPart() +
"AllStruct");
@@ -484,7 +482,7 @@ public class WSDLToCorbaHelper {
allName = createQNameCorbaNamespace(schematypeName.getLocalPart()
+ "AllStruct");
}
- type = new Struct();
+ Struct type = new Struct();
type.setName(allName.getLocalPart());
type.setQName(allName);
type.setType(schematypeName);
@@ -542,11 +540,10 @@ public class WSDLToCorbaHelper {
boolean attrQualified = getAttributeQualification(attribute, uri);
if (attribute.getUse() == XmlSchemaUse.NONE
|| attribute.getUse() == XmlSchemaUse.OPTIONAL) {
- CorbaType attType = null;
if (attribute.getSchemaType() != null) {
// REVISIT, edell bug in XmlSchema 1.2.
// https://issues.apache.org/jira/browse/WSCOMMONS-208
- attType =
convertSchemaToCorbaType(attribute.getSchemaType(),
+ CorbaType attType =
convertSchemaToCorbaType(attribute.getSchemaType(),
checkPrefix(attrName),
attribute.getSchemaType(),
null, true);
@@ -562,7 +559,7 @@ public class WSDLToCorbaHelper {
attrQualified);
}
} else {
- attType =
processPrimitiveType(attribute.getSchemaTypeName());
+ CorbaType attType =
processPrimitiveType(attribute.getSchemaTypeName());
//REVISIT, bravi, attType is null for the wsaddr type
//{http://www.w3.org/2005/08/addressing}RelationshipTypeOpenEnum
if (attType != null) {
@@ -649,7 +646,7 @@ public class WSDLToCorbaHelper {
CorbaType corbaTypeImpl = null;
QName name;
- QName schematypeName = null;
+ QName schematypeName;
if (stype.getQName() == null) {
schematypeName = defaultName;
@@ -670,7 +667,7 @@ public class WSDLToCorbaHelper {
corbaTypeImpl = processSimpleRestrictionType(stype, name,
schematypeName, anonymous);
} else if (stype.getContent() instanceof XmlSchemaSimpleTypeList) {
XmlSchemaSimpleTypeList ltype =
(XmlSchemaSimpleTypeList)stype.getContent();
- CorbaType itemType = null;
+ CorbaType itemType;
if (ltype.getItemType() != null) {
itemType = convertSchemaToCorbaType(ltype.getItemType(), name,
stype, null, false);
if (itemType != null) {
@@ -707,7 +704,7 @@ public class WSDLToCorbaHelper {
QName name, QName
schematypeName,
boolean anonymous)
throws Exception {
- CorbaType corbaTypeImpl = null;
+ CorbaType corbaTypeImpl;
// checks if enumeration
XmlSchemaSimpleTypeRestriction restrictionType =
(XmlSchemaSimpleTypeRestriction)stype
@@ -860,10 +857,9 @@ public class WSDLToCorbaHelper {
protected boolean isSchemaTypeException(XmlSchemaType stype) {
boolean exception = false;
- XmlSchemaComplexType complex = null;
if (stype instanceof XmlSchemaComplexType) {
- complex = (XmlSchemaComplexType)stype;
+ XmlSchemaComplexType complex = (XmlSchemaComplexType)stype;
if (!isLiteralArray(complex)
&& !WSDLTypes.isOMGUnion(complex)
@@ -946,7 +942,7 @@ public class WSDLToCorbaHelper {
private CorbaType processComplexType(XmlSchemaComplexType complex, QName
defaultName,
XmlSchemaAnnotation annotation,
boolean anonymous) throws
Exception {
- CorbaType corbatype = null;
+ final CorbaType corbatype;
if (isLiteralArray(complex)) {
corbatype = processLiteralArray(complex, defaultName, anonymous);
} else if (WSDLTypes.isOMGUnion(complex)) {
@@ -968,7 +964,6 @@ public class WSDLToCorbaHelper {
private CorbaType processStruct(XmlSchemaComplexType complex, QName
defaultName)
throws Exception {
QName name;
- Struct corbaStruct = null;
QName schematypeName = checkPrefix(complex.getQName());
if (schematypeName == null) {
schematypeName =
createQNameTargetNamespace(defaultName.getLocalPart());
@@ -982,7 +977,7 @@ public class WSDLToCorbaHelper {
name =
checkPrefix(createQNameCorbaNamespace(schematypeName.getLocalPart()));
}
- corbaStruct = (Struct)recursionMap.get(name);
+ Struct corbaStruct = (Struct)recursionMap.get(name);
if (corbaStruct != null) {
return corbaStruct;
}
@@ -1037,7 +1032,6 @@ public class WSDLToCorbaHelper {
protected Struct processSimpleContentStruct(XmlSchemaSimpleContent
simpleContent,
QName defaultName, Struct
corbaStruct, QName schematypeName)
throws Exception {
- XmlSchemaType base = null;
List<MemberType> attrMembers = null;
CorbaType basetype = null;
@@ -1057,7 +1051,7 @@ public class WSDLToCorbaHelper {
}
if (basetype == null) {
- base = getSchemaType(ext.getBaseTypeName());
+ XmlSchemaType base = getSchemaType(ext.getBaseTypeName());
basetype = convertSchemaToCorbaType(base, base.getQName(),
base, null, false);
}
if (basetype == null) {
@@ -1077,14 +1071,12 @@ public class WSDLToCorbaHelper {
XmlSchemaSimpleContentRestriction restrict
=
(XmlSchemaSimpleContentRestriction)simpleContent.getContent();
- base = restrict.getBaseType();
-
if (restrict.getBaseTypeName() != null) {
basetype = processPrimitiveType(restrict.getBaseTypeName());
}
if (basetype == null) {
- base = getSchemaType(restrict.getBaseTypeName());
+ XmlSchemaType base = getSchemaType(restrict.getBaseTypeName());
basetype = convertSchemaToCorbaType(base, base.getQName(),
base, null, false);
}
@@ -1366,7 +1358,6 @@ public class WSDLToCorbaHelper {
private CorbaType processOMGUnion(XmlSchemaComplexType complex, QName
defaultName) throws Exception {
QName name;
- Union corbaUnion = null;
QName schematypeName = checkPrefix(complex.getQName());
if (schematypeName == null) {
@@ -1376,7 +1367,7 @@ public class WSDLToCorbaHelper {
name = createQNameCorbaNamespace(schematypeName.getLocalPart());
}
- corbaUnion = new Union();
+ Union corbaUnion = new Union();
corbaUnion.setName(name.getLocalPart());
corbaUnion.setQName(name);
String id = REPO_STRING + name.getLocalPart().replace('.', '/') +
IDL_VERSION;
@@ -1387,8 +1378,8 @@ public class WSDLToCorbaHelper {
Iterator<XmlSchemaSequenceMember> it = stype.getItems().iterator();
XmlSchemaParticle st1 = (XmlSchemaParticle)it.next();
XmlSchemaParticle st2 = (XmlSchemaParticle)it.next();
- XmlSchemaElement discEl = null;
- XmlSchemaChoice choice = null;
+ final XmlSchemaElement discEl;
+ final XmlSchemaChoice choice;
if (st1 instanceof XmlSchemaElement) {
discEl = (XmlSchemaElement)st1;
@@ -1446,7 +1437,7 @@ public class WSDLToCorbaHelper {
private CorbaType processRegularUnion(XmlSchemaComplexType complex,
QName defaultName) throws
Exception {
//NEED TO DO
- QName name = null;
+ final QName name;
QName schematypeName = complex.getQName();
if (schematypeName == null) {
@@ -1463,15 +1454,14 @@ public class WSDLToCorbaHelper {
QName schematypeName)
throws Exception {
- Union corbaUnion = null;
if (recursionMap.get(name) instanceof Union) {
- corbaUnion = (Union)recursionMap.get(name);
+ Union corbaUnion = (Union)recursionMap.get(name);
if (corbaUnion != null) {
return corbaUnion;
}
}
- corbaUnion = new Union();
+ Union corbaUnion = new Union();
corbaUnion.setName(name.getLocalPart());
corbaUnion.setQName(name);
corbaUnion.setType(schematypeName);
@@ -1611,7 +1601,7 @@ public class WSDLToCorbaHelper {
if (schemaName.getNamespaceURI().isEmpty()) {
schemaName = new QName(uri, schemaName.getLocalPart());
}
- boolean qualified = false;
+ boolean qualified;
if (element.getForm() == XmlSchemaForm.QUALIFIED) {
qualified = true;
} else {
@@ -1623,7 +1613,7 @@ public class WSDLToCorbaHelper {
private boolean getAttributeQualification(XmlSchemaAttribute attr, String
uri) {
QName schemaName = attr.getQName();
- boolean qualified = false;
+ boolean qualified;
if (attr.getForm() == XmlSchemaForm.QUALIFIED) {
qualified = true;
} else {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaProcessor.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaProcessor.java
index ea67dfc..63539de 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaProcessor.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToCorbaProcessor.java
@@ -155,9 +155,8 @@ public class WSDLToCorbaProcessor extends WSDLToProcessor {
idlAction.setBindingName(env.get("binding").toString());
} else {
if (wsdlToCorbaBinding != null) {
- String portType = null;
if (env.optionSet(ToolConstants.CFG_PORTTYPE)) {
- portType = env.get("porttype").toString();
+ String portType = env.get("porttype").toString();
if (portType != null) {
String bindingName =
wsdlToCorbaBinding.getMappedBindingName(portType);
if (bindingName != null) {
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToIDLAction.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToIDLAction.java
index 49fa4f7..3c7de6a 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToIDLAction.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLToIDLAction.java
@@ -59,6 +59,7 @@ import org.apache.cxf.binding.corba.wsdl.Union;
import org.apache.cxf.binding.corba.wsdl.Unionbranch;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.tools.common.ToolException;
import org.apache.cxf.tools.corba.common.idltypes.CorbaUtils;
import org.apache.cxf.tools.corba.common.idltypes.IdlAnonArray;
import org.apache.cxf.tools.corba.common.idltypes.IdlAnonFixed;
@@ -123,7 +124,7 @@ public class WSDLToIDLAction {
if (binding == null) {
String msgStr = "Binding " + bindingName + " doesn't
exists in WSDL.";
org.apache.cxf.common.i18n.Message msg = new
org.apache.cxf.common.i18n.Message(msgStr, LOG);
- throw new Exception(msg.toString());
+ throw new ToolException(msg.toString());
}
generateIDL(def, binding);
} else {
@@ -133,7 +134,7 @@ public class WSDLToIDLAction {
if (bindings.isEmpty()) {
String msgStr = "No bindings exists within this WSDL.";
org.apache.cxf.common.i18n.Message msg = new
org.apache.cxf.common.i18n.Message(msgStr, LOG);
- throw new Exception(msg.toString());
+ throw new ToolException(msg.toString());
}
List<QName> portTypes = new ArrayList<>();
for (Binding binding : bindings) {
@@ -205,13 +206,12 @@ public class WSDLToIDLAction {
private void addOperation(BindingOperation bindingOperation,
boolean isOneway) throws Exception {
- String name = null;
Iterator<?> i = bindingOperation.getExtensibilityElements().iterator();
while (i.hasNext()) {
org.apache.cxf.binding.corba.wsdl.OperationType opType =
(org.apache.cxf.binding.corba.wsdl.OperationType)i
.next();
- name = opType.getName();
+ String name = opType.getName();
if (name.startsWith("_get_") || name.startsWith("_set_")) {
createIdlAttribute(opType, name);
@@ -456,7 +456,7 @@ public class WSDLToIDLAction {
scope = (IdlScopeBase)idlDef;
}
- IdlType result = null;
+ IdlType result;
String local = name[name.length - 1];
if (corbaTypeImpl instanceof Enum) {
@@ -542,7 +542,7 @@ public class WSDLToIDLAction {
private IdlType
createIdlException(org.apache.cxf.binding.corba.wsdl.Exception e, IdlScopeBase
scope,
String local) throws Exception {
- IdlType result = null;
+ final IdlType result;
Object obj = scope.lookup(local);
@@ -645,77 +645,69 @@ public class WSDLToIDLAction {
private IdlType createTypedef(Alias a, IdlScopeBase scope,
String local) throws Exception {
- IdlType idlType = null;
IdlType base = findType(a.getBasetype());
- idlType = IdlTypedef.create(scope, local, base);
+ IdlType idlType = IdlTypedef.create(scope, local, base);
scope.addToScope(idlType);
return idlType;
}
private IdlType createConst(Const c, IdlScopeBase scope,
String local) throws Exception {
- IdlType idlType = null;
IdlType base = findType(c.getIdltype());
String value = c.getValue();
- idlType = IdlConst.create(scope, local, base, value);
+ IdlType idlType = IdlConst.create(scope, local, base, value);
scope.addToScope(idlType);
return idlType;
}
private IdlType createSequence(Sequence s, IdlScopeBase scope,
String local) throws Exception {
- IdlType idlType = null;
IdlType base = findType(s.getElemtype());
int bound = (int)s.getBound();
- idlType = IdlSequence.create(scope, local, base, bound);
+ IdlType idlType = IdlSequence.create(scope, local, base, bound);
scope.addToScope(idlType);
return idlType;
}
private IdlType createAnonSequence(Anonsequence s, IdlScopeBase scope,
String local) throws Exception {
- IdlType idlType = null;
IdlType base = findType(s.getElemtype());
int bound = (int)s.getBound();
- idlType = IdlAnonSequence.create(scope, base, bound);
+ IdlType idlType = IdlAnonSequence.create(scope, base, bound);
scope.addToScope(idlType);
return idlType;
}
private IdlType createArray(Array s, IdlScopeBase scope, String local)
throws Exception {
- IdlType idlType = null;
IdlType base = findType(s.getElemtype());
int bound = (int)s.getBound();
- idlType = IdlArray.create(scope, local, base, bound);
+ IdlType idlType = IdlArray.create(scope, local, base, bound);
scope.addToScope(idlType);
return idlType;
}
private IdlType createAnonArray(Anonarray s, IdlScopeBase scope, String
local)
throws Exception {
- IdlType idlType = null;
IdlType base = findType(s.getElemtype());
int bound = (int)s.getBound();
- idlType = IdlAnonArray.create(scope, base, bound);
+ IdlType idlType = IdlAnonArray.create(scope, base, bound);
scope.addToScope(idlType);
return idlType;
}
private IdlType createFixed(Fixed f, IdlScopeBase scope, String local) {
- IdlType idlType = null;
long digits = f.getDigits();
long scale = f.getScale();
- idlType = IdlFixed.create(scope, local, (int)digits, (int)scale);
+ IdlType idlType = IdlFixed.create(scope, local, (int)digits,
(int)scale);
scope.addToScope(idlType);
return idlType;
}
private IdlType createAnonFixed(Anonfixed f, IdlScopeBase scope, String
local) {
- IdlType idlType = null;
long digits = f.getDigits();
long scale = f.getScale();
- idlType = IdlAnonFixed.create(scope, (int)digits, (int)scale);
+ IdlType idlType = IdlAnonFixed.create(scope, (int)digits, (int)scale);
scope.addToScope(idlType);
return idlType;
}
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLTypes.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLTypes.java
index 610728d..de55c58 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLTypes.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/processors/wsdl/WSDLTypes.java
@@ -175,7 +175,7 @@ public final class WSDLTypes {
public static CorbaType mapToArray(QName name, QName schematypeName, QName
arrayType,
QName elName, int bound, boolean
anonymous) {
- CorbaType corbatype = null;
+ final CorbaType corbatype;
//schematypeName = checkPrefix(schematypeName);
@@ -208,7 +208,7 @@ public final class WSDLTypes {
public static CorbaType mapToSequence(QName name, QName schematypeName,
QName arrayType,
QName elName, int bound, boolean
anonymous) {
- CorbaType corbaTypeImpl = null;
+ final CorbaType corbaTypeImpl;
//schematypeName = checkPrefix(schematypeName);
if (!anonymous) {
diff --git
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
index a400bd4..0db2678 100644
--- a/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
+++ b/tools/corba/src/test/java/org/apache/cxf/tools/corba/IDLToWSDLTest.java
@@ -19,16 +19,11 @@
package org.apache.cxf.tools.corba;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
@@ -38,137 +33,78 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import org.apache.cxf.helpers.FileUtils;
import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.tools.common.ToolTestBase;
import org.apache.cxf.tools.corba.common.ToolCorbaConstants;
-import org.apache.cxf.tools.corba.common.ToolTestBase;
import org.apache.cxf.tools.corba.utils.TestUtils;
import org.apache.cxf.tools.corba.utils.WSDLGenerationTester;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class IDLToWSDLTest extends ToolTestBase {
- private static StringBuffer usageBuf;
- private static int noError;
- private static int error = -1;
- ByteArrayOutputStream bout;
- PrintStream newOut;
- private File output;
+ @Rule
+ public TemporaryFolder output = new TemporaryFolder();
+
private WSDLGenerationTester wsdlGenTester;
public IDLToWSDLTest() {
wsdlGenTester = new WSDLGenerationTester();
}
- @Before
- public void setUp() throws Exception {
- super.setUp();
- try {
- TestUtils utils = new TestUtils(IDLToWSDL.TOOL_NAME,
IDLToWSDL.class
- .getResourceAsStream("/toolspecs/idl2wsdl.xml"));
- usageBuf = new StringBuffer(utils.getUsage());
- bout = new ByteArrayOutputStream();
- newOut = new PrintStream(bout);
- System.setOut(newOut);
- System.setErr(newOut);
- } catch (Exception e) {
- // complete
- }
-
- try {
- output = new File(getClass().getResource(".").toURI());
- output = new File(output, "generated-wsdl");
- FileUtils.mkDir(output);
- } catch (Exception e) {
- // complete
- }
- }
-
- @After
- public void tearDown() throws Exception {
- // super.tearDown();
- try {
- FileUtils.removeDir(output);
- } catch (Exception e) {
- //ignore
- }
- output = null;
- }
-
- private int execute(String[] args) {
+ private static String execute(String[] args) {
try {
IDLToWSDL.run(args);
} catch (Throwable t) {
- return error;
+ return t.getMessage();
}
- return noError;
- }
-
- private void checkStrings(byte[] orig, byte[] generated) throws Exception {
- try (BufferedReader origReader = new BufferedReader(new
InputStreamReader(new ByteArrayInputStream(orig)));
- BufferedReader genReader = new BufferedReader(
- new InputStreamReader(new
ByteArrayInputStream(generated)))) {
-
- String sorig = origReader.readLine();
- String sgen = genReader.readLine();
-
- while (sorig != null && sgen != null) {
- if (!sorig.equals(sgen)) {
- //assertEquals(sorig, sgen);
- //sorig = origReader.readLine();
- sgen = genReader.readLine();
- } else {
- assertEquals(sorig, sgen);
- sorig = null;
- sgen = null;
- break;
- }
- }
- }
+ return null;
}
@Test
public void testNoArgs() throws Exception {
String[] cmdArgs = {};
- int exc = execute(cmdArgs);
- assertEquals("IDLToWSDL Failed", error, exc);
- StringBuilder strBuf = new StringBuilder(64);
- strBuf.append("Missing argument: idl\n\n");
- strBuf.append(usageBuf.toString());
- checkStrings(strBuf.toString().getBytes(), bout.toByteArray());
+ String error = execute(cmdArgs);
+ assertNotNull("IDLToWSDL Failed", error);
+
+ String generated = new String(errOut.toByteArray());
+ assertTrue(generated.contains("Missing argument: idl"));
+ TestUtils utils = new TestUtils(IDLToWSDL.TOOL_NAME, IDLToWSDL.class
+ .getResourceAsStream(ToolCorbaConstants.TOOLSPECS_BASE +
"idl2wsdl.xml"));
+ assertTrue(generated.contains(utils.getUsage()));
}
@Test
public void testDetailOutput() throws Exception {
String[] args = new String[] {"-?"};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
- assertNotNull(bout.toByteArray());
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
+ assertNotNull(errOut.toByteArray());
}
@Test
public void testVersionOutput() throws Exception {
String[] args = new String[] {"-v"};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
- assertNotNull(bout.toByteArray());
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
+ assertNotNull(errOut.toByteArray());
}
@Test
public void testHelpOutput() throws Exception {
String[] args = new String[] {"-help"};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
- assertNotNull(bout.toByteArray());
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
+ assertNotNull(errOut.toByteArray());
}
@Test
@@ -184,24 +120,24 @@ public class IDLToWSDLTest extends ToolTestBase {
// test "-s base64Binary" and "-s hexBinary" options
public void doTestSequenceOctetMappingOption(String encoding) throws
Exception {
File input = new
File(getClass().getResource("/idl/sequence_octet.idl").toURI());
- File actual = new File(output, "sequence_octet.wsdl");
+ File actual = new File(output.getRoot(), "sequence_octet.wsdl");
File expected = new File(getClass().getResource("/idl/expected_"
+ encoding +
"_sequence_octet.wsdl").toURI());
String[] args = new String[] {"-s", encoding,
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
private void doTestGeneratedWsdl(File expected, File actual)
throws FileNotFoundException, XMLStreamException, Exception {
//For testing, esp. in AIX, we need to write out both the defn &
schema to see if it matches
- File expectedWsdlFile = wsdlGenTester.writeDefinition(output,
expected);
- File actualWsdlFile = wsdlGenTester.writeDefinition(output, actual);
+ File expectedWsdlFile =
wsdlGenTester.writeDefinition(output.getRoot(), expected);
+ File actualWsdlFile = wsdlGenTester.writeDefinition(output.getRoot(),
actual);
try (InputStream actualFileStream = new
FileInputStream(actualWsdlFile);
InputStream expectedFileStream = new
FileInputStream(expectedWsdlFile)) {
@@ -219,16 +155,16 @@ public class IDLToWSDLTest extends ToolTestBase {
@Test
public void testSchemaNamespace() throws Exception {
File input = new
File(getClass().getResource("/idl/HelloWorld.idl").toURI());
- File actual = new File(output, "HelloWorld.wsdl");
+ File actual = new File(output.getRoot(), "HelloWorld.wsdl");
File expected =
new
File(getClass().getResource("/idl/expected_HelloWorld_schema_namespace.wsdl").toURI());
String[] args = new String[] {"-x",
"http://cxf.apache.org/foobar/schema",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@@ -236,12 +172,12 @@ public class IDLToWSDLTest extends ToolTestBase {
@Test
public void testCorbaAddressFile() throws Exception {
File input = new
File(getClass().getResource("/idl/HelloWorld.idl").toURI());
- File actual = new File(output, "HelloWorld.wsdl");
+ File actual = new File(output.getRoot(), "HelloWorld.wsdl");
File expected =
new
File(getClass().getResource("/idl/expected_HelloWorld_corba_address_file.wsdl").toURI());
// create temporary file containing ior
- File addressFile = new File(output, "HelloWorld.idl");
+ File addressFile = new File(output.getRoot(), "HelloWorld.idl");
try (FileWriter addressFileWriter = new FileWriter(addressFile)) {
addressFileWriter.write(
"IOR:010000001400000049444c3a48656c6c6f576f726c64493a312e300002"
@@ -256,11 +192,11 @@ public class IDLToWSDLTest extends ToolTestBase {
addressFile.deleteOnExit();
String[] args = new String[] {"-f", addressFile.toString(),
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@@ -268,16 +204,16 @@ public class IDLToWSDLTest extends ToolTestBase {
@Test
public void testCorbaTypeMapTargetNamespace() throws Exception {
File input = new
File(getClass().getResource("/idl/sequence_octet.idl").toURI());
- File actual = new File(output, "sequence_octet.wsdl");
+ File actual = new File(output.getRoot(), "sequence_octet.wsdl");
File expected =
new
File(getClass().getResource("/idl/expected_sequence_octet_corba_typemap_tns.wsdl").toURI());
String[] args = new String[] {"-t",
"http://cxf.apache.org/foobar/typemap",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@@ -285,15 +221,15 @@ public class IDLToWSDLTest extends ToolTestBase {
@Test
public void testTreatBoundedStringsAsUnbounded() throws Exception {
File input = new
File(getClass().getResource("/idl/String.idl").toURI());
- File actual = new File(output, "String.wsdl");
+ File actual = new File(output.getRoot(), "String.wsdl");
File expected = new
File(getClass().getResource("/idl/expected_String_unbounded.wsdl").toURI());
String[] args = new String[] {"-b",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@@ -301,53 +237,53 @@ public class IDLToWSDLTest extends ToolTestBase {
@Test
public void testTreatBoundedAnonStringsAsUnbounded() throws Exception {
File input = new
File(getClass().getResource("/idl/Anonstring.idl").toURI());
- File actual = new File(output, "Anonstring.wsdl");
+ File actual = new File(output.getRoot(), "Anonstring.wsdl");
File expected = new
File(getClass().getResource("/idl/expected_Anonstring_unbounded.wsdl").toURI());
String[] args = new String[] {"-b",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@Test
public void testExceptionsWithSchemasInDifferentNS() throws Exception {
File input = new
File(getClass().getResource("/idl/Exception.idl").toURI());
- File actual = new File(output, "Exception.wsdl");
+ File actual = new File(output.getRoot(), "Exception.wsdl");
File expected = new
File(getClass().getResource("/idl/expected_Exception_DiffNS.wsdl").toURI());
String[] args = new String[] {"-x",
"http://cxf.apache.org/bindings/corba/idl/Exception/types",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@Test
public void testOutputWSDLFileName() throws Exception {
File input = new
File(getClass().getResource("/idl/HelloWorld.idl").toURI());
- File actual = new File(output, "ArtixHelloWorld.wsdl");
+ File actual = new File(output.getRoot(), "ArtixHelloWorld.wsdl");
File expected =
new
File(getClass().getResource("/idl/expected_HelloWorld.wsdl").toURI());
String[] args = new String[] {"-ow", "ArtixHelloWorld.wsdl",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@Test
public void testMultipleIncludes() throws Exception {
File input = new
File(getClass().getResource("/idl/Parent.idl").toURI());
- File actual = new File(output, "Parent.wsdl");
+ File actual = new File(output.getRoot(), "Parent.wsdl");
File expected =
new
File(getClass().getResource("/idl/expected_Parent.wsdl").toURI());
File include0Dir = new File(getClass().getResource("/idl").toURI());
@@ -355,21 +291,21 @@ public class IDLToWSDLTest extends ToolTestBase {
File include2Dir = new
File(getClass().getResource("/idl/subdir2").toURI());
String[] args = new String[] {"-ow", "Parent.wsdl",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
"-I", include0Dir.toString(),
"-I", include1Dir.toString(),
"-I", include2Dir.toString(),
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@Test
public void testExternalInterfaceRef() throws Exception {
File input = new
File(getClass().getResource("/idl/ExternalInterfaceRef.idl").toURI());
- File actual = new File(output, "ExternalInterfaceRef.wsdl");
+ File actual = new File(output.getRoot(), "ExternalInterfaceRef.wsdl");
File expected =
new
File(getClass().getResource("/idl/expected_ExternalInterfaceRef.wsdl").toURI());
@@ -377,13 +313,13 @@ public class IDLToWSDLTest extends ToolTestBase {
File include1Dir = new File(getClass().getResource("/idl").toURI());
String[] args = new String[] {"-ow", "ExternalInterfaceRef.wsdl",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
"-I", include1Dir.toString(),
"-verbose",
input.toString()
};
- int exc = execute(args);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
doTestGeneratedWsdl(expected, actual);
}
@@ -394,14 +330,14 @@ public class IDLToWSDLTest extends ToolTestBase {
new
File(getClass().getResource("/idl/expected_duplicateAttribute.wsdl").toURI());
String[] args = new String[] {"-ow", "duplicateAttribute.wsdl",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
"-verbose",
input.toString()
};
- int exc = execute(args);
- File actual = new File(output, "duplicateAttribute.wsdl");
+ String error = execute(args);
+ assertNull("IDLToWSDL Failed", error);
- assertEquals("IDLToWSDL Failed", noError, exc);
+ File actual = new File(output.getRoot(), "duplicateAttribute.wsdl");
doTestGeneratedWsdl(expected, actual);
}
@@ -411,7 +347,7 @@ public class IDLToWSDLTest extends ToolTestBase {
File include1Dir = new File(getClass().getResource("/idl").toURI());
String[] args = new String[] {"-ow", "ExternalInterfaceRef.wsdl",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
"-I", include1Dir.toString(),
"-verbose",
input.toString()
@@ -429,11 +365,11 @@ public class IDLToWSDLTest extends ToolTestBase {
File input = new
File(getClass().getResource("/idl/missing_struct_member.idl").toURI());
String[] args = new String[] {
"-mns[org::bash=http://www.bash.org]",
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
IDLToWSDL.run(args);
- File fs = new File(output, "org_bash.xsd");
+ File fs = new File(output.getRoot(), "org_bash.xsd");
assertTrue(fs.getName() + " was not created.", fs.exists());
Document doc = StaxUtils.read(new FileInputStream(fs));
NodeList l =
doc.getDocumentElement().getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
"element");
@@ -450,11 +386,11 @@ public class IDLToWSDLTest extends ToolTestBase {
public void testCXF3329() throws Exception {
File input = new
File(getClass().getResource("/idl/CXF3329.idl").toURI());
String[] args = new String[] {
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
input.toString()
};
IDLToWSDL.run(args);
- File fs = new File(output, "CXF3329.wsdl");
+ File fs = new File(output.getRoot(), "CXF3329.wsdl");
assertTrue(fs.getName() + " was not created.", fs.exists());
Document doc = StaxUtils.read(new FileInputStream(fs));
String s = StaxUtils.toString(doc.getDocumentElement());
@@ -465,12 +401,12 @@ public class IDLToWSDLTest extends ToolTestBase {
public void testCXF5340() throws Exception {
File input = new
File(getClass().getResource("/idl/CXF5340.idl").toURI());
String[] args = new String[] {
- "-o", output.toString(),
+ "-o", output.getRoot().toString(),
"-verbose", "-qualified",
input.toString()
};
IDLToWSDL.run(args);
- File fs = new File(output, "CXF5340.wsdl");
+ File fs = new File(output.getRoot(), "CXF5340.wsdl");
assertTrue(fs.getName() + " was not created.", fs.exists());
String corbaNs = "http://cxf.apache.org/bindings/corba";
@@ -496,4 +432,4 @@ public class IDLToWSDLTest extends ToolTestBase {
assertEquals("string", message.getAttribute("idltype").split(":")[1]);
assertEquals("m_message", message.getAttribute("name"));
}
-}
\ No newline at end of file
+}
diff --git
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
index 2f02afe..48200ad 100644
--- a/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
+++ b/tools/corba/src/test/java/org/apache/cxf/tools/corba/WSDLToIDLTest.java
@@ -19,29 +19,19 @@
package org.apache.cxf.tools.corba;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
+import java.io.File;
import javax.wsdl.Definition;
import javax.xml.namespace.QName;
-import org.apache.cxf.tools.corba.common.ToolTestBase;
+import org.apache.cxf.tools.common.ToolTestBase;
+import org.apache.cxf.tools.corba.common.ToolCorbaConstants;
import org.apache.cxf.tools.corba.processors.wsdl.WSDLToProcessor;
import org.apache.cxf.tools.corba.utils.TestUtils;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -51,43 +41,8 @@ import static org.junit.Assert.fail;
public class WSDLToIDLTest extends ToolTestBase {
- private static String usage;
- ByteArrayOutputStream bout;
- private Path output;
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
-
- TestUtils utils = new TestUtils(WSDLToIDL.TOOL_NAME, WSDLToIDL.class
- .getResourceAsStream("/toolspecs/wsdl2idl.xml"));
- usage = utils.getUsage();
- bout = new ByteArrayOutputStream();
- PrintStream newOut = new PrintStream(bout);
- System.setOut(newOut);
- System.setErr(newOut);
-
- output = Files.createTempDirectory("wsdl2idl");
- }
-
- @After
- public void tearDown() throws Exception {
- super.tearDown();
-
- Files.walkFileTree(output, new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes
attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException
exc) throws IOException {
- Files.delete(dir);
- return FileVisitResult.CONTINUE;
- }
- });
- output = null;
- }
+ @Rule
+ public TemporaryFolder output = new TemporaryFolder();
private static String execute(String[] args) {
try {
@@ -98,41 +53,20 @@ public class WSDLToIDLTest extends ToolTestBase {
return null;
}
- private static void checkStrings(byte[] orig, byte[] generated) throws
IOException {
- try (BufferedReader origReader = new BufferedReader(new
InputStreamReader(new ByteArrayInputStream(orig)));
- BufferedReader genReader = new BufferedReader(
- new InputStreamReader(new
ByteArrayInputStream(generated)))) {
-
- String sorig = origReader.readLine();
- String sgen = genReader.readLine();
-
- while (sorig != null && sgen != null) {
- if (!sorig.equals(sgen)) {
- // assertEquals(sorig, sgen);
- // sorig = origReader.readLine();
- sgen = genReader.readLine();
- } else {
- assertEquals(sorig, sgen);
- sorig = origReader.readLine();
- }
- }
- }
- }
-
@Test
public void testBindingGenDefault() throws Exception {
String[] cmdArgs = {"-corba", "-i", "BasePortType",
- "-d", output.toString(),
+ "-d", output.getRoot().toString(),
getClass().getResource("/wsdl/simpleList.wsdl").toString()};
String error = execute(cmdArgs);
assertNull("WSDLToIDL Failed", error);
- Path f = output.resolve("simpleList-corba.wsdl");
- assertTrue("simpleList-corba.wsdl should be generated",
Files.exists(f));
+ File f = new File(output.getRoot(), "simpleList-corba.wsdl");
+ assertTrue("simpleList-corba.wsdl should be generated", f.exists());
WSDLToProcessor proc = new WSDLToProcessor();
try {
- proc.parseWSDL(f.toString());
+ proc.parseWSDL(f.getAbsolutePath());
Definition model = proc.getWSDLDefinition();
assertNotNull("WSDL Definition Should not be Null", model);
QName bindingName = new QName("http://schemas.apache.org/tests",
"BaseCORBABinding");
@@ -147,13 +81,13 @@ public class WSDLToIDLTest extends ToolTestBase {
String[] cmdArgs = {"-corba", "-i", "BasePortType",
"-w", "simpleList-corba_gen.wsdl",
- "-d", output.toString(),
+ "-d", output.getRoot().toString(),
getClass().getResource("/wsdl/simpleList.wsdl").toString()};
String error = execute(cmdArgs);
assertNull("WSDLToIDL Failed", error);
- Path f = output.resolve("simpleList-corba_gen.wsdl");
- assertTrue("simpleList-corba_gen.wsdl should be generated",
Files.exists(f));
+ File f = new File(output.getRoot(), "simpleList-corba_gen.wsdl");
+ assertTrue("simpleList-corba_gen.wsdl should be generated",
f.exists());
WSDLToProcessor proc = new WSDLToProcessor();
try {
@@ -171,32 +105,30 @@ public class WSDLToIDLTest extends ToolTestBase {
@Test
public void testIDLGenDefault() throws Exception {
String[] cmdArgs = {"-idl", "-b", "BaseCORBABinding",
- "-d", output.toString(),
+ "-d", output.getRoot().toString(),
getClass().getResource("/wsdl/simple-binding.wsdl").toString()};
String error = execute(cmdArgs);
assertNull("WSDLToIDL Failed", error);
- Path path = output.resolve("simple-binding.idl");
- assertTrue("simple-binding.idl should be generated",
Files.isReadable(path));
+ File f = new File(output.getRoot(), "simple-binding.idl");
+ assertTrue("simple-binding.idl should be generated", f.exists());
- String line = new String(Files.readAllBytes(path),
StandardCharsets.UTF_8);
- assertTrue("Invalid Idl File Generated", line.length() > 0);
+ assertTrue("Invalid Idl File Generated", f.length() > 0);
}
@Test
public void testIDLGenSpecifiedFile() throws Exception {
String[] cmdArgs = {"-idl", "-b", "BaseCORBABinding",
"-o", "simple-binding_gen.idl",
- "-d", output.toString(),
+ "-d", output.getRoot().toString(),
getClass().getResource("/wsdl/simple-binding.wsdl").toString()};
String error = execute(cmdArgs);
assertNull("WSDLToIDL Failed in Idl Generation", error);
- Path path = output.resolve("simple-binding_gen.idl");
- assertTrue("simple-binding_gen.idl should be generated",
Files.isReadable(path));
+ File f = new File(output.getRoot(), "simple-binding_gen.idl");
+ assertTrue("simple-binding_gen.idl should be generated", f.exists());
- String line = new String(Files.readAllBytes(path),
StandardCharsets.UTF_8);
- assertTrue("Invalid Idl File Generated", line.length() > 0);
+ assertTrue("Invalid Idl File Generated", f.length() > 0);
}
// tests generating corba and idl in default wsdl and idl files
@@ -205,19 +137,19 @@ public class WSDLToIDLTest extends ToolTestBase {
public void testBindAndIDLGen() throws Exception {
String[] cmdArgs = {"-i", "BasePortType",
"-b", "BaseOneCORBABinding",
- "-d", output.toString(),
+ "-d", output.getRoot().toString(),
getClass().getResource("/wsdl/simple-binding.wsdl").toString()};
String error = execute(cmdArgs);
assertNull("WSDLToIDL Failed", error);
- Path path1 = output.resolve("simple-binding-corba.wsdl");
- assertTrue("simple-binding-corba.wsdl should be generated",
Files.isReadable(path1));
- Path path2 = output.resolve("simple-binding.idl");
- assertTrue("simple-binding.idl should be generated",
Files.isReadable(path2));
+ File f1 = new File(output.getRoot(), "simple-binding-corba.wsdl");
+ assertTrue("simple-binding-corba.wsdl should be generated",
f1.exists());
+ File f2 = new File(output.getRoot(), "simple-binding.idl");
+ assertTrue("simple-binding.idl should be generated", f2.exists());
WSDLToProcessor proc = new WSDLToProcessor();
try {
- proc.parseWSDL(path1.toString());
+ proc.parseWSDL(f1.getAbsolutePath());
Definition model = proc.getWSDLDefinition();
assertNotNull("WSDL Definition Should not be Null", model);
QName bindingName = new QName("http://schemas.apache.org/tests",
"BaseOneCORBABinding");
@@ -226,8 +158,7 @@ public class WSDLToIDLTest extends ToolTestBase {
fail("WSDLToIDL generated an invalid simple-binding-corba.wsdl");
}
- String line = new String(Files.readAllBytes(path2),
StandardCharsets.UTF_8);
- assertTrue("Invalid Idl File Generated", line.length() > 0);
+ assertTrue("Invalid Idl File Generated", f2.length() > 0);
}
@Test
@@ -235,10 +166,13 @@ public class WSDLToIDLTest extends ToolTestBase {
String[] cmdArgs = {};
String error = execute(cmdArgs);
assertNotNull("WSDLToIDL Failed", error);
- StringBuilder strBuf = new StringBuilder(128);
- strBuf.append("Missing argument: wsdlurl\n\n");
- strBuf.append(usage);
- checkStrings(strBuf.toString().getBytes(), bout.toByteArray());
+
+ String generated = new String(errOut.toByteArray());
+ assertTrue(generated.contains("Missing argument: wsdlurl"));
+
+ TestUtils utils = new TestUtils(WSDLToIDL.TOOL_NAME, WSDLToIDL.class
+ .getResourceAsStream(ToolCorbaConstants.TOOLSPECS_BASE +
"wsdl2idl.xml"));
+ assertTrue(generated.contains(utils.getUsage()));
}
@Test
@@ -246,10 +180,13 @@ public class WSDLToIDLTest extends ToolTestBase {
String[] cmdArgs = {"-i", " interfaceName"};
String error = execute(cmdArgs);
assertNotNull("WSDLToIDL Failed", error);
- StringBuilder expected = new StringBuilder(128);
- expected.append("Missing argument: wsdlurl\n\n");
- expected.append(usage);
- checkStrings(expected.toString().getBytes(), bout.toByteArray());
+
+ String generated = new String(errOut.toByteArray());
+ assertTrue(generated.contains("Missing argument: wsdlurl"));
+
+ TestUtils utils = new TestUtils(WSDLToIDL.TOOL_NAME, WSDLToIDL.class
+ .getResourceAsStream(ToolCorbaConstants.TOOLSPECS_BASE +
"wsdl2idl.xml"));
+ assertTrue(generated.contains(utils.getUsage()));
}
@Test
@@ -259,8 +196,8 @@ public class WSDLToIDLTest extends ToolTestBase {
getClass().getResource("/wsdl/simpleList.wsdl").toString()};
String error = execute(cmdArgs);
assertNotNull("WSDLToIDL Failed", error);
- String expected = "Error : PortType TestInterface doesn't exist in
WSDL.";
- checkStrings(expected.getBytes(), bout.toByteArray());
+ String generated = new String(errOut.toByteArray());
+ assertTrue(generated.contains("Error : PortType TestInterface doesn't
exist in WSDL."));
}
@Test
@@ -271,36 +208,32 @@ public class WSDLToIDLTest extends ToolTestBase {
getClass().getResource("/wsdl/simple-binding.wsdl").toString()};
String error = execute(cmdArgs);
assertNotNull("WSDLToIDL Failed", error);
- String expected = "Error : Binding BaseCORBABinding already exists in
WSDL.";
- checkStrings(expected.getBytes(), bout.toByteArray());
+ String generated = new String(errOut.toByteArray());
+ assertTrue(generated.contains("Error : Binding BaseCORBABinding
already exists in WSDL."));
}
@Test
public void testIdlGenMissingBinding() throws Exception {
- String[] cmdArgs = {"-d", output.toString(),
+ String[] cmdArgs = {"-d", output.getRoot().toString(),
"-idl",
getClass().getResource("/wsdl/simpleList.wsdl").toString()};
String error = execute(cmdArgs);
- assertNotNull("WSDLToIDL Failed", error);
- String expected = "Error : Binding Name required for generating IDL";
- checkStrings(expected.getBytes(), bout.toByteArray());
+ assertEquals("No bindings exists within this WSDL.", error);
}
@Test
public void testIdlGenInvalidBinding() throws Exception {
- String[] cmdArgs = {"-d", output.toString(),
+ String[] cmdArgs = {"-d", output.getRoot().toString(),
"-idl", "-b", "TestBinding",
getClass().getResource("/wsdl/simpleList.wsdl").toString()};
String error = execute(cmdArgs);
- assertNotNull("WSDLToCORBA Failed", error);
- String expected = "Error : Binding TestBinding doesn't exist in WSDL.";
- checkStrings(expected.getBytes(), bout.toByteArray());
+ assertEquals("Binding TestBinding doesn't exists in WSDL.", error);
}
@Test
public void testMissingBindingName() throws Exception {
- String[] cmdArgs = {"-d", output.toString(),
+ String[] cmdArgs = {"-d", output.getRoot().toString(),
"-i", "BasePortType",
getClass().getResource("/wsdl/simpleList.wsdl").toString()};
assertNull("WSDLToIDL should succeed even without Binding name. "
diff --git
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/common/ToolTestBase.java
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/common/ToolTestBase.java
deleted file mode 100644
index a05df41..0000000
---
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/common/ToolTestBase.java
+++ /dev/null
@@ -1,67 +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.tools.corba.common;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-import java.net.URL;
-
-import org.junit.After;
-import org.junit.Before;
-
-public abstract class ToolTestBase {
-
- protected PrintStream oldStdErr;
- protected PrintStream oldStdOut;
- protected URL wsdlLocation;
- protected URL idlLocation;
-
- protected ByteArrayOutputStream errOut = new ByteArrayOutputStream();
- protected ByteArrayOutputStream stdOut = new ByteArrayOutputStream();
-
- @Before
- public void setUp() throws Exception {
-
- oldStdErr = System.err;
- oldStdOut = System.out;
-
- System.setErr(new PrintStream(errOut));
- System.setOut(new PrintStream(stdOut));
-
- wsdlLocation =
ToolTestBase.class.getResource("/wsdl/hello_world.wsdl");
- idlLocation = ToolTestBase.class.getResource("/idl/HelloWorld.idl");
- }
-
- @After
- public void tearDown() throws Exception {
-
- System.setErr(oldStdErr);
- System.setOut(oldStdOut);
- }
-
- protected String getStdOut() {
- return new String(stdOut.toByteArray());
- }
- protected String getStdErr() {
- return new String(errOut.toByteArray());
- }
-
-}
-
diff --git
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
index 6f55b31..33107e2 100644
---
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
+++
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
@@ -26,7 +26,7 @@ import java.io.LineNumberReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.regex.Pattern;
import org.junit.Test;
@@ -112,7 +112,7 @@ public class IdlPreprocessorReaderTest {
final File dir = new File(origFile.getAbsolutePath()
.substring(0,
origFile.getAbsolutePath().indexOf(location)));
final DefaultIncludeResolver includeResolver = new
DefaultIncludeResolver(dir);
- final DefineState defineState = new DefineState(new HashMap<String,
String>());
+ final DefineState defineState = new
DefineState(Collections.emptyMap());
final IdlPreprocessorReader includeReader = new
IdlPreprocessorReader(orig,
location,
@@ -125,7 +125,7 @@ public class IdlPreprocessorReaderTest {
private IdlPreprocessorReader createPreprocessorReader(final String
location) throws IOException {
final URL orig = findTestResource(location);
final ClassPathIncludeResolver includeResolver = new
ClassPathIncludeResolver();
- final DefineState defineState = new DefineState(new HashMap<String,
String>());
+ final DefineState defineState = new
DefineState(Collections.emptyMap());
return new IdlPreprocessorReader(orig, location, includeResolver,
defineState);
}
@@ -136,7 +136,7 @@ public class IdlPreprocessorReaderTest {
InputStream resolved =
findTestResource(expectedResultLocation).openStream();
try (LineNumberReader rReader
= new LineNumberReader(new InputStreamReader(resolved,
"ISO-8859-1"))) {
- boolean eof = false;
+ boolean eof;
do {
int line = rReader.getLineNumber() + 1;
String actualLine = oReader.readLine();
@@ -147,11 +147,6 @@ public class IdlPreprocessorReaderTest {
}
}
- private void consumeReader(final Reader includeReader) throws IOException {
- LineNumberReader oReader = new LineNumberReader(includeReader);
- String line = null;
- do {
- line = oReader.readLine();
- } while (line != null);
+ private static void consumeReader(final Reader includeReader) throws
IOException {
}
}
\ No newline at end of file
diff --git
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
index 5bad1e6..0f466ba 100644
---
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
+++
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/processors/IDLToWSDLGenerationTest.java
@@ -107,7 +107,6 @@ public class IDLToWSDLGenerationTest extends
ProcessorTestBase {
URL orig = getClass().getResource(expectedWsdlFilename);
InputStream actualStream = new
ByteArrayInputStream(out.toString().getBytes());
- System.out.println(out.toString());
assertWsdlEquals(orig.openStream(), actualStream, DEFAULT_IGNORE_ATTR,
DEFAULT_IGNORE_TAG);
}
diff --git
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java
index 4b43b0c..c2c776c 100644
---
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java
+++
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/utils/WSDLGenerationTester.java
@@ -20,13 +20,12 @@
package org.apache.cxf.tools.corba.utils;
import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
+import java.io.Writer;
+import java.nio.file.Files;
import javax.wsdl.Definition;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
-import javax.wsdl.xml.WSDLWriter;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
@@ -34,15 +33,11 @@ import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.wsdl.WSDLManager;
import org.apache.cxf.wsdl11.CatalogWSDLLocator;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.junit.Assert;
public class WSDLGenerationTester {
- private XmlSchemaCollection schemaCol = new XmlSchemaCollection();
-
public WSDLGenerationTester() {
}
@@ -129,7 +124,7 @@ public class WSDLGenerationTester {
private String mapToQName(XMLStreamReader reader, String s2) {
int idx = s2.indexOf(':');
- String ns = null;
+ String ns;
if (idx == -1) {
ns = reader.getNamespaceURI("");
} else {
@@ -156,8 +151,6 @@ public class WSDLGenerationTester {
public File writeDefinition(File targetDir, File defnFile) throws
Exception {
WSDLManager wm =
BusFactory.getThreadDefaultBus().getExtension(WSDLManager.class);
- File bkFile = new File(targetDir, "bk_" + defnFile.getName());
- FileWriter writer = new FileWriter(bkFile);
WSDLFactory factory
=
WSDLFactory.newInstance("org.apache.cxf.tools.corba.utils.TestWSDLCorbaFactoryImpl");
WSDLReader reader = factory.newWSDLReader();
@@ -168,24 +161,11 @@ public class WSDLGenerationTester {
Definition wsdlDefn = reader.readWSDL(locator);
- WSDLWriter wsdlWriter = factory.newWSDLWriter();
- wsdlWriter.writeWSDL(wsdlDefn, writer);
- writer.close();
- writer = null;
- reader = null;
+ File bkFile = new File(targetDir, "bk_" + defnFile.getName());
+ try (Writer writer = Files.newBufferedWriter(bkFile.toPath())) {
+ factory.newWSDLWriter().writeWSDL(wsdlDefn, writer);
+ }
return bkFile;
}
- public File writeSchema(File targetDir, File schemaFile) throws Exception {
- File bkFile = new File(targetDir, "bk_" + schemaFile.getName());
- FileWriter writer = new FileWriter(bkFile);
- FileReader reader = new FileReader(schemaFile);
- XmlSchema schema = schemaCol.read(reader);
- schema.write(writer);
- reader.close();
- writer.close();
- writer = null;
- reader = null;
- return bkFile;
- }
}
diff --git a/tools/corba/src/test/resources/toolspecs/idl2wsdl.xml
b/tools/corba/src/test/resources/toolspecs/idl2wsdl.xml
deleted file mode 100644
index 78ed99c..0000000
--- a/tools/corba/src/test/resources/toolspecs/idl2wsdl.xml
+++ /dev/null
@@ -1,184 +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.
--->
-<!-- The xhtml namespace is for usage documentation -->
-<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
xmlns="http://cxf.apache.org/Xutil/ToolSpecification"
xmlns:ts="http://cxf.apache.org/Xutil/ToolSpecification"
xsi:schemaLocation="http://cxf.apache.org/Xutil/ToolSpecification
http://cxf.apache.org/schema/xutil/tool-specification.xsd">
- <annotation> Examples :
- idl2wsdl HelloWorld.idl
- idl2wsdl -o HelloWorld HelloWorld.idl
- idl2wsdl -w http://www.mycompany.com/schemas HelloWorld.idl
- idl2wsdl -f HelloWorld.ior -interface HelloWorld HellowWorld.idl
- </annotation>
- <usage>
- <optionGroup id="options">
- <option id="includedir" maxOccurs="unbounded">
- <annotation>Specify a directory to be included in the search
path for the IDL preprocessor.</annotation>
- <switch>I</switch>
- <associatedArgument placement="afterSpace">
- <annotation>idl-include-directory</annotation>
- </associatedArgument>
- </option>
- <option id="outputdir" maxOccurs="1">
- <annotation>The wsdl output directory.</annotation>
- <switch>o</switch>
- <switch>output</switch>
- <associatedArgument placement="afterSpace">
- <annotation>output-directory</annotation>
- </associatedArgument>
- </option>
- <option id="address" maxOccurs="1">
- <annotation>Specify the value to be used for the corba:address
location attribute.</annotation>
- <switch>a</switch>
- <switch>address</switch>
- <associatedArgument placement="afterSpace">
- <annotation>corba-address</annotation>
- </associatedArgument>
- </option>
- <option id="boundedstrings" maxOccurs="1">
- <annotation>Treat bounded strings as unbounded.</annotation>
- <switch>b</switch>
- </option>
- <option id="addressfile" maxOccurs="1">
- <annotation>Use the contents of file as the value for the
corba:address locationattribute.</annotation>
- <switch>f</switch>
- <associatedArgument placement="afterSpace">
- <annotation>corba-address-file</annotation>
- </associatedArgument>
- </option>
- <option id="importschema" maxOccurs="1">
- <annotation>Do not generate schema types, but instead import
them from file.</annotation>
- <switch>n</switch>
- <associatedArgument placement="afterSpace">
- <annotation>schema-import-file</annotation>
- </associatedArgument>
- </option>
- <option id="sequencetype" maxOccurs="1">
- <annotation>Specify the XML Schema type used for the IDL
sequence octet type.
- Valid option values for type are base64Binary and
hexBinary. The default is base64Binary.</annotation>
- <switch>s</switch>
- <associatedArgument placement="afterSpace">
- <annotation>idl-sequence-type</annotation>
- </associatedArgument>
- </option>
- <option id="tns" maxOccurs="1">
- <annotation>Specify the target namespace to use in the
wsdl.</annotation>
- <switch>w</switch>
- <associatedArgument placement="afterSpace">
- <annotation>target-namespace</annotation>
- </associatedArgument>
- </option>
- <option id="schemans" maxOccurs="1">
- <annotation>Specify the schema namespace to use in the
wsdl.</annotation>
- <switch>x</switch>
- <associatedArgument placement="afterSpace">
- <annotation>schema-namespace</annotation>
- </associatedArgument>
- </option>
- <option id="corbatypemapns" maxOccurs="1">
- <annotation>Specify the corba type map target namespace to use
in the wsdl.</annotation>
- <switch>t</switch>
- <associatedArgument placement="afterSpace">
- <annotation>corba-type-map target-namespace</annotation>
- </associatedArgument>
- </option>
- <option id="referenceimport" maxOccurs="1">
- <annotation>Specify the pathname of the schema file imported
to define the Reference type.</annotation>
- <switch>r</switch>
- <associatedArgument placement="afterSpace">
- <annotation>reference-schema-file</annotation>
- </associatedArgument>
- </option>
- <option id="logical" maxOccurs="1">
- <annotation>Split the generated WSDL into two files.
- The logical portion of the WSDL is generated into the
specified file.
- The physical portion is generated into the default output
file, unless -P is also used.</annotation>
- <switch>L</switch>
- <associatedArgument placement="afterSpace">
- <annotation>logical-wsdl-filename</annotation>
- </associatedArgument>
- </option>
- <option id="physical" maxOccurs="1">
- <annotation>Split the generated WSDL into two files.
- The physical portion of the WSDL is generated into
specified file.
- The logical portion is generated into the default output
file, unless -L is also used.</annotation>
- <switch>P</switch>
- <associatedArgument placement="afterSpace">
- <annotation>physical-wsdl-filename</annotation>
- </associatedArgument>
- </option>
- <option id="schema" maxOccurs="1">
- <annotation>Generate schema types into the specified file.
- The file is then imported back into the logical portion of
the generated WSDL.
- This option cannot be used with -n.</annotation>
- <switch>T</switch>
- <associatedArgument placement="afterSpace">
- <annotation>schema-file-name</annotation>
- </associatedArgument>
- </option>
- <option id="interface" maxOccurs="1">
- <annotation>Specify the interface name within idl to use
during fast track process.</annotation>
- <switch>interface</switch>
- <associatedArgument placement="afterSpace">
- <annotation>interface-name</annotation>
- </associatedArgument>
- </option>
- <option id="qualified" maxOccurs="1">
- <annotation>Generate qualified wsdl contract</annotation>
- <switch>qualified</switch>
- </option>
- <option id="inline" maxOccurs="1">
- <annotation>In-line imported schema</annotation>
- <switch>inline</switch>
- </option>
- <option id="encoding" maxOccurs="1">
- <annotation>Use specified encoding as the value of the
generated WSDL xml encoding attribute.
- Defaults to UTF-8.</annotation>
- <switch>e</switch>
- <associatedArgument placement="afterSpace">
- <annotation>xml-encoding-type</annotation>
- </associatedArgument>
- </option>
- </optionGroup>
- <optionGroup id="common_options">
- <option id="help" maxOccurs="1">
- <annotation>Display detailed information for
options.</annotation>
- <switch>h</switch>
- <switch>?</switch>
- <switch>help</switch>
- </option>
- <option id="version">
- <annotation>Display the version of the tool.</annotation>
- <switch>v</switch>
- </option>
- <option id="verbose">
- <annotation>Verbose mode</annotation>
- <switch>verbose</switch>
- <switch>V</switch>
- </option>
- <option id="quiet">
- <annotation>Quiet mode</annotation>
- <switch>quiet</switch>
- <switch>q</switch>
- </option>
- </optionGroup>
- <argument id="idl" minOccurs="1" maxOccurs="1">
- <annotation>idl-file-name</annotation>
- </argument>
- </usage>
-</toolspec>
diff --git a/tools/corba/src/test/resources/toolspecs/wsdl2idl.xml
b/tools/corba/src/test/resources/toolspecs/wsdl2idl.xml
deleted file mode 100644
index 4b754ae..0000000
--- a/tools/corba/src/test/resources/toolspecs/wsdl2idl.xml
+++ /dev/null
@@ -1,112 +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.
--->
-<!-- The xhtml namespace is for usage documentation -->
-<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
xmlns="http://cxf.apache.org/Xutil/ToolSpecification"
xmlns:ts="http://cxf.apache.org/Xutil/ToolSpecification"
xsi:schemaLocation="http://cxf.apache.org/Xutil/ToolSpecification
http://cxf.apache.org/schema/xutil/tool-specification.xsd">
- <annotation> Examples :
- wsdltoidl HelloWorld.wsdl
- wsdltoidl -corba -i GreetPortType -o Greeting.wsdl TestGreeting.wsdl
- wsdltoidl -idl -b TestBinding Test.wsdl
- </annotation>
- <usage>
- <optionGroup id="options">
- <option id="corba" maxOccurs="1">
- <annotation>Generates CORBA Binding.</annotation>
- <switch>corba</switch>
- </option>
- <option id="idl" maxOccurs="1">
- <annotation>Generates a idl from a wsdl.</annotation>
- <switch>idl</switch>
- </option>
- <option id="porttype" maxOccurs="1">
- <annotation>Specify the portType to use.</annotation>
- <switch>i</switch>
- <associatedArgument placement="afterSpace">
- <annotation>port-type-name</annotation>
- </associatedArgument>
- </option>
- <option id="binding" maxOccurs="1">
- <annotation>Specify the binding to use.</annotation>
- <switch>b</switch>
- <associatedArgument placement="afterSpace">
- <annotation>binding-name</annotation>
- </associatedArgument>
- </option>
- <option id="outputdir" maxOccurs="1">
- <annotation>The directory in which the generated wsdl/idl is
placed</annotation>
- <switch>d</switch>
- <associatedArgument placement="afterSpace">
- <annotation>output-directory</annotation>
- </associatedArgument>
- </option>
- <option id="outputfile" maxOccurs="2">
- <annotation>The wsdl/idl output file name.(can be specified
twice)</annotation>
- <switch>o</switch>
- <switch>output</switch>
- <associatedArgument placement="afterSpace">
- <annotation>output-file</annotation>
- </associatedArgument>
- </option>
- <option id="namespace" maxOccurs="1">
- <annotation>The corba type-map namespace.</annotation>
- <switch>props</switch>
- <associatedArgument placement="afterSpace">
- <annotation>corba-typemap-namespace</annotation>
- </associatedArgument>
- </option>
- <option id="wrapped" maxOccurs="1">
- <annotation>Generate corba binding operation using wrapper
types instead of unwrapping into separa
-te parameters.</annotation>
- <switch>wrapped</switch>
- </option>
- <option id="license" maxOccurs="1">
- <annotation>Specify the license file</annotation>
- <switch>L</switch>
- <associatedArgument placement="afterSpace">
- <annotation>license-file</annotation>
- </associatedArgument>
- </option>
- </optionGroup>
- <optionGroup id="common_options">
- <option id="help" maxOccurs="1">
- <annotation>Display detailed information for
options.</annotation>
- <switch>h</switch>
- <switch>?</switch>
- <switch>help</switch>
- </option>
- <option id="version">
- <annotation>Display the version of the tool.</annotation>
- <switch>v</switch>
- </option>
- <option id="verbose">
- <annotation>Verbose mode</annotation>
- <switch>verbose</switch>
- <switch>V</switch>
- </option>
- <option id="quiet">
- <annotation>Quiet mode</annotation>
- <switch>quiet</switch>
- <switch>q</switch>
- </option>
- </optionGroup>
- <argument id="wsdlurl" minOccurs="1" maxOccurs="1">
- <annotation>WSDL URL</annotation>
- </argument>
- </usage>
-</toolspec>
diff --git
a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java
b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java
index de7c3ea..6f09bc4 100644
---
a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java
+++
b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java
@@ -19,6 +19,7 @@
package org.apache.cxf.tools.wadlto.jaxb;
import java.io.File;
+import java.io.Writer;
import java.net.URL;
import java.nio.file.Files;
import java.util.ArrayList;
@@ -65,11 +66,9 @@ public final class CustomizationParser {
public void parse(ToolContext env) {
// JAXB schema customizations
- String[] bindingFiles = getBindingFiles(env);
-
- for (int i = 0; i < bindingFiles.length; i++) {
+ for (String bindingFile : getBindingFiles(env)) {
try {
- addBinding(bindingFiles[i]);
+ addBinding(bindingFile);
} catch (XMLStreamException xse) {
Message msg = new Message("STAX_PARSER_ERROR", LOG);
throw new ToolException(msg, xse);
@@ -115,7 +114,7 @@ public final class CustomizationParser {
private void addBinding(String bindingFile) throws XMLStreamException {
- Element root = null;
+ final Element root;
try (URIResolver resolver = new URIResolver(bindingFile)) {
root =
StaxUtils.read(resolver.getInputStream()).getDocumentElement();
} catch (Exception e1) {
@@ -128,18 +127,15 @@ public final class CustomizationParser {
String schemaLocation = root.getAttribute("schemaLocation");
String resolvedSchemaLocation = resolveByCatalog(schemaLocation);
if (resolvedSchemaLocation == null) {
- resolvedSchemaLocation = schemaLocation.length() == 0
+ resolvedSchemaLocation = schemaLocation.isEmpty()
? wadlPath : getBaseWadlPath() + schemaLocation;
}
- InputSource tmpIns = null;
try {
- tmpIns = convertToTmpInputSource(root, resolvedSchemaLocation);
+ jaxbBindings.add(convertToTmpInputSource(root,
resolvedSchemaLocation));
} catch (Exception e1) {
Message msg = new Message("FAILED_TO_ADD_SCHEMALOCATION", LOG,
bindingFile);
throw new ToolException(msg, e1);
}
- jaxbBindings.add(tmpIns);
-
}
}
@@ -148,14 +144,14 @@ public final class CustomizationParser {
return lastSep != -1 ? wadlPath.substring(0, lastSep + 1) : wadlPath;
}
- private InputSource convertToTmpInputSource(Element ele, String schemaLoc)
throws Exception {
- InputSource result = null;
+ private static InputSource convertToTmpInputSource(Element ele, String
schemaLoc) throws Exception {
ele.setAttribute("schemaLocation", schemaLoc);
File tmpFile = FileUtils.createTempFile("jaxbbinding", ".xml");
- StaxUtils.writeTo(ele, Files.newOutputStream(tmpFile.toPath()));
- result = new
InputSource(URIParserUtil.getAbsoluteURI(tmpFile.getAbsolutePath()));
+ try (Writer w = Files.newBufferedWriter(tmpFile.toPath())) {
+ StaxUtils.writeTo(ele, w);
+ }
tmpFile.deleteOnExit();
- return result;
+ return new
InputSource(URIParserUtil.getAbsoluteURI(tmpFile.getAbsolutePath()));
}
private String resolveByCatalog(String url) {
diff --git
a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
index 7ac8164..e04d0f7 100644
---
a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
+++
b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
@@ -517,8 +517,8 @@ public class SourceGenerator {
}
}
- private QName convertToQName(String resourceId, boolean expandedQName) {
- QName qname = null;
+ private static QName convertToQName(String resourceId, boolean
expandedQName) {
+ final QName qname;
if (expandedQName) {
qname = JAXRSUtils.convertStringToQName(resourceId);
} else {
@@ -535,7 +535,7 @@ public class SourceGenerator {
}
private String getClassName(String clsName, boolean interfaceIsGenerated,
Set<String> typeClassNames) {
- String name = null;
+ String name;
if (interfaceIsGenerated) {
name = clsName;
} else {