You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by br...@apache.org on 2007/03/28 15:43:49 UTC
svn commit: r523376 - in /incubator/yoko/trunk/tools/src:
main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java
test/java/org/apache/yoko/tools/IDLToWSDLTest.java
Author: bravi
Date: Wed Mar 28 08:43:49 2007
New Revision: 523376
URL: http://svn.apache.org/viewvc?view=rev&rev=523376
Log:
[YOKO-314] - Fix to the ScopedNameVisitor to properly find the alias types in a scoped idl. Also, cleaned up the IDLToWSDLTest.
Modified:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java
incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java
Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java?view=diff&rev=523376&r1=523375&r2=523376
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/ScopedNameVisitor.java Wed Mar 28 08:43:49 2007
@@ -74,62 +74,22 @@
stype = primitiveVisitor.getSchemaType();
ctype = primitiveVisitor.getCorbaType();
} else {
- // declared type
- Scope currentScope = getScope();
- while (stype == null
- && currentScope != currentScope.getParent()) {
- // A name can be used in an unqualified form within a particular scope;
- // it will be resolved by successvely searching farther out in enclosing
- // scopes, while taking into consideration inheritance relationships
- // among interfaces.
- // INHERITANCE NOT IMPLEMENTED YET
- Scope scopedName = new Scope(currentScope, node);
- QName schemaQName = new QName(schema.getTargetNamespace(), scopedName.toString());
-
- stype = schema.getTypeByName(schemaQName);
-
- currentScope = currentScope.getParent();
- }
- if (stype == null) {
- // Global scope is our last chance to resolve the node
- QName schemaQName = new QName(schema.getTargetNamespace(), node.toString());
- stype = schema.getTypeByName(schemaQName);
- }
-
- // handle special case of simple string alias
- // a plain xsd:string has no corresponding XmlSchemaType in the XmlSchema
- // so the previous findType() method would return null.
- // As a temporary workaround, we query the typeMap for a corba:string with
- // same name. If the string is there, then it had been previously properly
- // declared and we can use it here.
- if (stype == null) {
- QName corbaQName = null;
- currentScope = getScope();
- while (ctype == null
- && currentScope != currentScope.getParent()) {
- Scope scopedName = new Scope(currentScope, node);
- corbaQName = new QName(typeMap.getTargetNamespace(), scopedName.toString());
- ctype = findCorbaType(typeMap, corbaQName);
-
- currentScope = currentScope.getParent();
- }
- if (ctype == null) {
- corbaQName = new QName(typeMap.getTargetNamespace(), node.toString());
- ctype = findCorbaType(typeMap, corbaQName);
- }
- if (ctype != null && ctype.getType() == Constants.XSD_STRING) {
- stype = schemas.getTypeByQName(Constants.XSD_STRING);
+ stype = findSchemaType(getScope(), schemas, schema, typeMap, node);
+ if (stype != null) {
+ if (stype.getQName().equals(Constants.XSD_STRING)) {
ctype = new CorbaTypeImpl();
ctype.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
ctype.setQName(CorbaConstants.NT_CORBA_STRING);
ctype.setType(Constants.XSD_STRING);
} else {
- throw new RuntimeException("[ScopedNameVisitor: Corba type "
- + corbaQName.toString()
- + " not found in typeMap]");
+ ctype = findCorbaType(typeMap, stype.getQName());
}
} else {
- ctype = findCorbaType(typeMap, stype.getQName());
+ Scope scopedName = new Scope(getScope(), node);
+ QName qname = new QName(schema.getTargetNamespace(), scopedName.toString());
+ throw new RuntimeException("[ScopedNameVisitor: Corba type "
+ + qname
+ + " not found in typeMap]");
}
}
@@ -174,7 +134,8 @@
currentScope = scope;
while (ctype == null
&& currentScope != currentScope.getParent()) {
- QName corbaStringQname = new QName(typeMap.getTargetNamespace(), currentScope.toString());
+ Scope scopedName = new Scope(currentScope, node);
+ QName corbaStringQname = new QName(typeMap.getTargetNamespace(), scopedName.toString());
ctype = findCorbaType(typeMap, corbaStringQname);
currentScope = currentScope.getParent();
}
Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java?view=diff&rev=523376&r1=523375&r2=523376
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java (original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java Wed Mar 28 08:43:49 2007
@@ -26,6 +26,7 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
@@ -63,27 +64,42 @@
usageBuf = new StringBuffer(utils.getUsage());
bout = new ByteArrayOutputStream();
newOut = new PrintStream(bout);
- //System.setOut(newOut);
- //System.setErr(newOut);
+ System.setOut(newOut);
+ System.setErr(newOut);
} catch (Exception e) {
// complete
}
try {
- URL url = IDLToWSDLTest.class.getResource(".");
- output = new File(url.getFile());
- output = new File(output, "/resources");
-
+ File file = File.createTempFile("IDLToWSDLTest", "");
+ output = new File(file.getAbsolutePath() + ".dir");
+ file.delete();
+
if (!output.exists()) {
output.mkdir();
- }
+ }
} catch (Exception e) {
// complete
}
}
+ private void deleteDir(File dir) throws IOException {
+ for (File f : dir.listFiles()) {
+ if (f.isDirectory()) {
+ deleteDir(f);
+ } else {
+ f.delete();
+ }
+ }
+ dir.delete();
+ }
+
public void tearDown() {
- output.deleteOnExit();
+ try {
+ deleteDir(output);
+ } catch (IOException ex) {
+ //ignore
+ }
output = null;
}
@@ -130,13 +146,7 @@
}
}
- }
-
- public void testIDLToWSDL() throws Exception {
- String[] cmdArgs = {getClass().getResource("/idl/HelloWorld.idl").toString()};
- int exc = execute(cmdArgs);
- //assertEquals("IDLToWSDL Failed", noError, exc);
- }
+ }
public void testNoArgs() throws Exception {
String[] cmdArgs = {};
@@ -150,29 +160,35 @@
public void testDetailOutput() throws Exception {
String[] args = new String[] {"-?"};
- IDLToWSDL.main(args);
- assertNotNull(getStdOut());
+ int exc = execute(args);
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ assertNotNull(bout.toByteArray());
}
public void testVersionOutput() throws Exception {
String[] args = new String[] {"-v"};
- IDLToWSDL.main(args);
- assertNotNull(getStdOut());
+ int exc = execute(args);
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ assertNotNull(bout.toByteArray());
}
public void testHelpOutput() throws Exception {
String[] args = new String[] {"-help"};
- IDLToWSDL.main(args);
- assertNotNull(getStdOut());
+ int exc = execute(args);
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ assertNotNull(bout.toByteArray());
}
- public void testSequenceOctetMappingOption() throws Exception {
- testSequenceOctetMappingOption(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_BASE64BINARY);
- testSequenceOctetMappingOption(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_HEXBINARY);
+ public void testBase64SequenceOctetMappingOption() throws Exception {
+ doTestSequenceOctetMappingOption(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_BASE64BINARY);
+ }
+
+ public void testHexBinarySequenceOctetMappingOption() throws Exception {
+ doTestSequenceOctetMappingOption(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE_HEXBINARY);
}
// test "-s base64Binary" and "-s hexBinary" options
- public void testSequenceOctetMappingOption(String encoding) throws Exception {
+ public void doTestSequenceOctetMappingOption(String encoding) throws Exception {
File input = new File(getClass().getResource("/idl/sequence_octet.idl").getFile());
File actual = new File(output, "sequence_octet.wsdl");
File expected = new File(getClass().getResource("/idl/expected_" + encoding + "_sequence_octet.wsdl").getFile());
@@ -181,11 +197,12 @@
"-o", output.toString(),
input.toString()
};
- IDLToWSDL.main(args);
- testGeneratedWsdl(expected, actual);
+ int exc = execute(args);
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ doTestGeneratedWsdl(expected, actual);
}
- private void testGeneratedWsdl(File expected, File actual) throws FileNotFoundException, XMLStreamException, Exception {
+ private void doTestGeneratedWsdl(File expected, File actual) throws FileNotFoundException, XMLStreamException, Exception {
InputStream actualFileStream = new FileInputStream(actual);
InputStream expectedFileStream = new FileInputStream(expected);
@@ -207,8 +224,9 @@
"-o", output.toString(),
input.toString()
};
- IDLToWSDL.main(args);
- testGeneratedWsdl(expected, actual);
+ int exc = execute(args);
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ doTestGeneratedWsdl(expected, actual);
}
// test "-f <corba-address-file>"
@@ -234,8 +252,9 @@
"-o", output.toString(),
input.toString()
};
- IDLToWSDL.main(args);
- testGeneratedWsdl(expected, actual);
+ int exc = execute(args);
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ doTestGeneratedWsdl(expected, actual);
}
// test "-t <corba-type-map target-namespace>"
@@ -248,8 +267,9 @@
"-o", output.toString(),
input.toString()
};
- IDLToWSDL.main(args);
- testGeneratedWsdl(expected, actual);
+ int exc = execute(args);
+ assertEquals("IDLToWSDL Failed", noError, exc);
+ doTestGeneratedWsdl(expected, actual);
}
}