You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bi...@apache.org on 2010/10/17 04:29:32 UTC
svn commit: r1023413 - in /cxf/trunk/tools/wsdlto:
databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/
test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/
test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/wsdl11/ test/src/...
Author: bimargulies
Date: Sun Oct 17 02:29:31 2010
New Revision: 1023413
URL: http://svn.apache.org/viewvc?rev=1023413&view=rev
Log:
some clarifications in tests I was debugging
Modified:
cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/wsdl11/JAXWSDefinitionBuilderTest.java
cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/echo_date.xjb
Modified: cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=1023413&r1=1023412&r2=1023413&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java (original)
+++ cxf/trunk/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java Sun Oct 17 02:29:31 2010
@@ -128,7 +128,7 @@ public class JAXBDataBinding implements
boolean isInclude;
int locIdx = -1;
OASISCatalogManager catalog;
-
+
LocationFilterReader(XMLStreamReader read, OASISCatalogManager catalog) {
super(read);
this.catalog = catalog;
@@ -192,11 +192,11 @@ public class JAXBDataBinding implements
}
return index;
}
-
+
private String mapSchemaLocation(String target) {
return JAXBDataBinding.mapSchemaLocation(target, this.getLocation().getSystemId(), catalog);
}
-
+
public String getAttributeValue(String namespaceURI, String localName) {
if (isInclude && "schemaLocation".equals(localName)) {
return mapSchemaLocation(super.getAttributeValue(namespaceURI, localName));
@@ -216,24 +216,24 @@ public class JAXBDataBinding implements
public QName getAttributeName(int index) {
return super.getAttributeName(mapIdx(index));
}
-
+
public String getAttributePrefix(int index) {
return super.getAttributePrefix(mapIdx(index));
}
-
+
public String getAttributeNamespace(int index) {
return super.getAttributeNamespace(mapIdx(index));
}
-
+
public String getAttributeLocalName(int index) {
return super.getAttributeLocalName(mapIdx(index));
}
-
+
public String getAttributeType(int index) {
return super.getAttributeType(mapIdx(index));
}
-
-
+
+
public boolean isAttributeSpecified(int index) {
return super.isAttributeSpecified(mapIdx(index));
}
@@ -241,15 +241,15 @@ public class JAXBDataBinding implements
private static final Logger LOG = LogUtils.getL7dLogger(JAXBDataBinding.class);
-
+
private static final Set<String> DEFAULT_TYPE_MAP = new HashSet<String>();
private static final Map<String, String> JLDEFAULT_TYPE_MAP = new HashMap<String, String>();
-
+
private S2JJAXBModel rawJaxbModelGenCode;
private ToolContext context;
private DefaultValueProvider defaultValues;
private boolean initialized;
-
+
static {
DEFAULT_TYPE_MAP.add("boolean");
DEFAULT_TYPE_MAP.add("int");
@@ -266,7 +266,7 @@ public class JAXBDataBinding implements
DEFAULT_TYPE_MAP.add("java.math.BigDecimal");
DEFAULT_TYPE_MAP.add("javax.xml.datatype.XMLGregorianCalendar");
DEFAULT_TYPE_MAP.add("javax.xml.datatype.Duration");
-
+
JLDEFAULT_TYPE_MAP.put("java.lang.Character", "char");
JLDEFAULT_TYPE_MAP.put("java.lang.Boolean", "boolean");
JLDEFAULT_TYPE_MAP.put("java.lang.Integer", "int");
@@ -276,35 +276,35 @@ public class JAXBDataBinding implements
JLDEFAULT_TYPE_MAP.put("java.lang.Float", "float");
JLDEFAULT_TYPE_MAP.put("java.lang.Double", "double");
DEFAULT_TYPE_MAP.addAll(JLDEFAULT_TYPE_MAP.keySet());
- }
-
+ }
+
public void initialize(ToolContext c) throws ToolException {
this.context = c;
-
+
SchemaCompiler schemaCompiler = XJC.createSchemaCompiler();
Bus bus = context.get(Bus.class);
OASISCatalogManager catalog = bus.getExtension(OASISCatalogManager.class);
hackInNewInternalizationLogic(schemaCompiler, catalog);
-
+
ClassCollector classCollector = context.get(ClassCollector.class);
-
- ClassNameAllocatorImpl allocator
+
+ ClassNameAllocatorImpl allocator
= new ClassNameAllocatorImpl(classCollector,
c.optionSet(ToolConstants.CFG_AUTORESOLVE));
schemaCompiler.setClassNameAllocator(allocator);
-
+
JAXBBindErrorListener listener = new JAXBBindErrorListener(context.isVerbose());
schemaCompiler.setErrorListener(listener);
// Collection<SchemaInfo> schemas = serviceInfo.getSchemas();
List<InputSource> jaxbBindings = context.getJaxbBindingFile();
SchemaCollection schemas = (SchemaCollection) context.get(ToolConstants.XML_SCHEMA_COLLECTION);
-
+
Options opts = null;
opts = getOptions(schemaCompiler);
-
+
List<String> args = new ArrayList<String>();
-
+
if (context.get(ToolConstants.CFG_NO_ADDRESS_BINDING) == null) {
//hard code to enable jaxb extensions
args.add("-extension");
@@ -316,7 +316,7 @@ public class JAXBDataBinding implements
InputSource ins = new InputSource(bindingFileUrl.toString());
opts.addBindFile(ins);
}
-
+
if (context.get(ToolConstants.CFG_XJC_ARGS) != null) {
Object o = context.get(ToolConstants.CFG_XJC_ARGS);
if (o instanceof String) {
@@ -359,25 +359,25 @@ public class JAXBDataBinding implements
throw new ToolException(msg, e);
}
}
-
+
addSchemas(opts, schemaCompiler, schemas);
addBindingFiles(opts, jaxbBindings, schemas);
-
+
for (String ns : context.getNamespacePackageMap().keySet()) {
File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, context.mapPackageName(ns));
try {
InputSource ins = new InputSource(file.toURI().toString());
schemaCompiler.parseSchema(ins);
} finally {
- FileUtils.delete(file);
+ FileUtils.delete(file);
}
}
-
+
if (context.getPackageName() != null) {
schemaCompiler.setDefaultPackageName(context.getPackageName());
- }
-
+ }
+
rawJaxbModelGenCode = schemaCompiler.bind();
addedEnumClassToCollector(schemas, allocator);
@@ -400,7 +400,7 @@ public class JAXBDataBinding implements
}
initialized = true;
}
-
+
private boolean isJAXB22() {
Target t = XmlElement.class.getAnnotation(Target.class);
//JAXB 2.2 allows XmlElement on params.
@@ -415,19 +415,19 @@ public class JAXBDataBinding implements
private static final class ReferenceFinder extends AbstractReferenceFinderImpl {
private Locator locator;
private OASISCatalogManager catalog;
-
+
ReferenceFinder(DOMForest parent, OASISCatalogManager cat) {
super(parent);
catalog = cat;
}
-
+
public void setDocumentLocator(Locator loc) {
super.setDocumentLocator(loc);
this.locator = loc;
}
protected String findExternalResource(String nsURI, String localName, Attributes atts) {
- if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(nsURI)
- && ("import".equals(localName)
+ if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(nsURI)
+ && ("import".equals(localName)
|| "include".equals(localName))) {
String s = atts.getValue("schemaLocation");
if (!StringUtils.isEmpty(s)) {
@@ -479,7 +479,7 @@ public class JAXBDataBinding implements
binding = null;
}
}
- }
+ }
} catch (Exception ex) {
//ignore, just pass to jaxb
} finally {
@@ -514,12 +514,12 @@ public class JAXBDataBinding implements
tmpFile.deleteOnExit();
return result;
}
-
+
@SuppressWarnings("unchecked")
- private void addSchemas(Options opts,
+ private void addSchemas(Options opts,
SchemaCompiler schemaCompiler,
SchemaCollection schemaCollection) {
-
+
Set<String> ids = new HashSet<String>();
List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
for (ServiceInfo si : serviceList) {
@@ -560,7 +560,7 @@ public class JAXBDataBinding implements
//ignore - DOM level 3
}
validateSchema(ele, uri, catalog);
- }
+ }
try {
docs[0].setDocumentURI(key);
} catch (Throwable t) {
@@ -594,7 +594,7 @@ public class JAXBDataBinding implements
} else {
in = new URL(key).openStream();
}
-
+
XMLStreamReader reader = StaxUtils.createXMLStreamReader(key, in);
reader = new LocationFilterReader(reader, catalog);
InputSource is = new InputSource(key);
@@ -628,7 +628,7 @@ public class JAXBDataBinding implements
ele = removeImportElement(ele, key, catalog);
if (context.get(ToolConstants.CFG_VALIDATE_WSDL) != null) {
validateSchema(ele, sci.getSystemId(), catalog);
- }
+ }
InputSource is = new InputSource((InputStream)null);
//key = key.replaceFirst("#types[0-9]+$", "");
is.setSystemId(key);
@@ -637,8 +637,7 @@ public class JAXBDataBinding implements
try {
schemaCompiler.parseSchema(key, StaxUtils.createXMLStreamReader(ele, key));
} catch (XMLStreamException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new RuntimeException(e);
}
}
}
@@ -663,7 +662,7 @@ public class JAXBDataBinding implements
// JAXB bug. JAXB ClassNameCollector may not be invoked when generated
// class is an enum. We need to use this method to add the missed file
// to classCollector.
- private void addedEnumClassToCollector(SchemaCollection schemaCollection,
+ private void addedEnumClassToCollector(SchemaCollection schemaCollection,
ClassNameAllocatorImpl allocator) {
//for (Element schemaElement : schemaList.values()) {
for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
@@ -768,11 +767,11 @@ public class JAXBDataBinding implements
}
private Element removeImportElement(Element element, String sysId, OASISCatalogManager catalog) {
- List<Element> impElemList = DOMUtils.findAllElementsByTagNameNS(element,
- ToolConstants.SCHEMA_URI,
+ List<Element> impElemList = DOMUtils.findAllElementsByTagNameNS(element,
+ ToolConstants.SCHEMA_URI,
"import");
- List<Element> incElemList = DOMUtils.findAllElementsByTagNameNS(element,
- ToolConstants.SCHEMA_URI,
+ List<Element> incElemList = DOMUtils.findAllElementsByTagNameNS(element,
+ ToolConstants.SCHEMA_URI,
"include");
boolean hasJAXB = DOMUtils.hasElementInNS(element, ToolConstants.NS_JAXB_BINDINGS);
if (impElemList.size() == 0 && incElemList.size() == 0 && !hasJAXB) {
@@ -780,9 +779,9 @@ public class JAXBDataBinding implements
}
element = (Element)cloneNode(element.getOwnerDocument(), element, true);
List<Node> ns = new ArrayList<Node>();
-
- impElemList = DOMUtils.findAllElementsByTagNameNS(element,
- ToolConstants.SCHEMA_URI,
+
+ impElemList = DOMUtils.findAllElementsByTagNameNS(element,
+ ToolConstants.SCHEMA_URI,
"import");
for (Element elem : impElemList) {
Node importNode = elem;
@@ -792,15 +791,15 @@ public class JAXBDataBinding implements
Node schemaNode = item.getParentNode();
schemaNode.removeChild(item);
}
-
- incElemList = DOMUtils.findAllElementsByTagNameNS(element,
- ToolConstants.SCHEMA_URI,
+
+ incElemList = DOMUtils.findAllElementsByTagNameNS(element,
+ ToolConstants.SCHEMA_URI,
"include");
for (Element elem : incElemList) {
Attr val = elem.getAttributeNode("schemaLocation");
val.setNodeValue(mapSchemaLocation(val.getNodeValue(), sysId, catalog));
}
-
+
if (hasJAXB) {
//need to add ns and version
String pfx = DOMUtils.getPrefix(element, ToolConstants.NS_JAXB_BINDINGS);
@@ -858,15 +857,15 @@ public class JAXBDataBinding implements
return clone;
}
-
- public void validateSchema(Element ele, String uri,
+
+ public void validateSchema(Element ele, String uri,
final OASISCatalogManager catalog) throws ToolException {
SchemaFactory schemaFact = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
schemaFact.setResourceResolver(new LSResourceResolver() {
- public LSInput resolveResource(String type,
+ public LSInput resolveResource(String type,
String namespaceURI,
String publicId,
- String systemId,
+ String systemId,
String baseURI) {
String s = JAXBDataBinding.mapSchemaLocation(systemId, baseURI, catalog);
return new LSInputSAXWrapper(new InputSource(s));
@@ -883,7 +882,7 @@ public class JAXBDataBinding implements
}
}
}
-
+
public DefaultValueWriter createDefaultValueWriter(QName qname, boolean element) {
if (defaultValues == null) {
return null;
@@ -905,10 +904,10 @@ public class JAXBDataBinding implements
if (typeAnno != null) {
final JType type = typeAnno.getTypeClass();
return new JAXBDefaultValueWriter(type);
- }
+ }
return null;
}
-
+
public DefaultValueWriter createDefaultValueWriterForWrappedElement(QName wrapperElement, QName item) {
if (defaultValues != null) {
Mapping mapping = rawJaxbModelGenCode.get(wrapperElement);
@@ -917,7 +916,7 @@ public class JAXBDataBinding implements
for (Property pro : propList) {
if (pro.elementName().getNamespaceURI().equals(item.getNamespaceURI())
&& pro.elementName().getLocalPart().equals(item.getLocalPart())) {
-
+
JType type = pro.type();
if (type instanceof JDefinedClass
&& ((JDefinedClass)type).isAbstract()) {
@@ -943,7 +942,7 @@ public class JAXBDataBinding implements
path = path + "/" + varName;
writeDefaultValue(writer, indent, path, varName, type);
}
-
+
public void writeDefaultValue(Writer writer, String indent,
String path, String varName,
JType tp) throws IOException {
@@ -961,17 +960,17 @@ public class JAXBDataBinding implements
} else if (tp instanceof JDefinedClass) {
JDefinedClass jdc = (JDefinedClass)tp;
if (jdc.getClassType() == ClassType.ENUM) {
- //no way to get the field list as it's private with
+ //no way to get the field list as it's private with
//no accessors :-(
try {
Field f = jdc.getClass().getDeclaredField("enumConstantsByName");
f.setAccessible(true);
Map map = (Map)f.get(jdc);
- Set<String> values = CastUtils.cast(map.keySet());
+ Set<String> values = CastUtils.cast(map.keySet());
String first = defaultValues.chooseEnumValue(path, values);
writer.write(tp.fullName());
- writer.write(".");
- writer.write(first);
+ writer.write(".");
+ writer.write(first);
writer.write(";");
} catch (Exception e) {
IOException ex = new IOException(e.getMessage());
@@ -999,12 +998,12 @@ public class JAXBDataBinding implements
writer.write("new ");
writer.write(tp.fullName().replace("java.util.List", "java.util.ArrayList"));
writer.write("();");
-
+
f = tp.getClass().getDeclaredField("args");
f.setAccessible(true);
List<JClass> lcl = CastUtils.cast((List)f.get(tp));
JClass cl = lcl.get(0);
-
+
int cnt = defaultValues.getListLength(path + "/" + varName);
for (int x = 0; x < cnt; x++) {
@@ -1023,7 +1022,7 @@ public class JAXBDataBinding implements
} catch (Exception e) {
//ignore
}
-
+
if (!found) {
//System.err.println("No idea what to do with " + tp.fullName());
//System.err.println(" class " + tp.getClass().getName());
@@ -1038,7 +1037,7 @@ public class JAXBDataBinding implements
if (sp instanceof JDefinedClass) {
fillInFields(writer, indent, path, varName, (JDefinedClass)sp);
}
-
+
Collection<JMethod> methods = tp.methods();
for (JMethod m : methods) {
if (m.name().startsWith("set")) {
@@ -1090,15 +1089,15 @@ public class JAXBDataBinding implements
writer.write(m.name());
writer.write("().addAll(");
writer.write(varName + m.name().substring(3));
- writer.write(");");
+ writer.write(");");
}
}
}
private void writeDefaultType(Writer writer, JType t, String path) throws IOException {
String name = t.fullName();
writeDefaultType(writer, name, path);
-
- }
+
+ }
private void writeDefaultType(Writer writer, String name, String path) throws IOException {
if (JLDEFAULT_TYPE_MAP.containsKey(name)) {
writer.append(name.substring("java.lang.".length())).append(".valueOf(");
@@ -1158,7 +1157,7 @@ public class JAXBDataBinding implements
if (catalog != null) {
try {
String resolvedLocation = catalog.resolveSystem(target);
-
+
if (resolvedLocation == null) {
resolvedLocation = catalog.resolveURI(target);
}
@@ -1168,7 +1167,7 @@ public class JAXBDataBinding implements
if (resolvedLocation != null) {
return resolvedLocation;
}
-
+
} catch (Exception ex) {
//ignore
}
@@ -1181,7 +1180,7 @@ public class JAXBDataBinding implements
}
} catch (Exception ex) {
//ignore
- }
+ }
return target;
}
Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=1023413&r1=1023412&r2=1023413&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java (original)
+++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java Sun Oct 17 02:29:31 2010
@@ -53,10 +53,10 @@ import org.junit.Test;
public class CodeGenBugTest extends AbstractCodeGenTest {
-
+
@Test
public void testCXF2944() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf2944/cxf2944.wsdl"));
env.put(ToolConstants.CFG_ALLOW_ELEMENT_REFS, "true");
processor.setContext(env);
@@ -64,40 +64,38 @@ public class CodeGenBugTest extends Abst
Class<?> clz = classLoader.loadClass("org.apache.cxf.tools.fortest.cxf2944.WebResultService");
WebResult webResult = AnnotationUtil.getWebResult(clz.getMethods()[0]);
assertEquals("hello/name", webResult.targetNamespace());
- assertEquals("name", webResult.name());
+ assertEquals("name", webResult.name());
}
-
+
@Test
public void testCXF2935() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf2935/webservice.wsdl"));
env.put(ToolConstants.CFG_ALLOW_ELEMENT_REFS, "true");
processor.setContext(env);
processor.execute();
Class<?> clz = classLoader.loadClass("org.apache.cxf.WebParamWebService");
- WebParam webParam = AnnotationUtil.getWebParam(clz.getMethods()[0], "Name");
+ WebParam webParam = AnnotationUtil.getWebParam(clz.getMethods()[0], "Name");
assertEquals("helloString/Name", webParam.targetNamespace());
-
- }
-
-
+ }
+
@Test
public void testCXF1969() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf1969/report_incident.wsdl"));
processor.setContext(env);
-
+
try {
processor.execute();
} catch (WSDLRuntimeException wrex) {
assertEquals("BINDING_MISSING_TYPE", wrex.getMessage());
- }
+ }
}
@Test
// Test for CXF-1678
public void testLogicalOnlyWSDL() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf-1678/hello_world_logical_only.wsdl"));
processor.setContext(env);
processor.execute();
@@ -416,7 +414,7 @@ public class CodeGenBugTest extends Abst
.getPrivClassAnnotation(clz, WebServiceClient.class);
assertEquals("http://cxf.apache.org/w2j/hello_world_soap_http/service",
webServiceClient.targetNamespace());
- File file = new File(output,
+ File file = new File(output,
"org/apache/cxf/w2j/hello_world_soap_http/Greeter_SoapPortTest1_Client.java");
FileInputStream fin = new FileInputStream(file);
byte[] buffer = new byte[30000];
@@ -552,10 +550,10 @@ public class CodeGenBugTest extends Abst
String str2 = "javax.xml.ws.Holder";
String str3 = "org.apache.cxf.mime.Address";
String str4 = "http://cxf.apache.org/w2j/hello_world_mime/types";
-
- String file = getStringFromFile(new File(output.getCanonicalPath()
+
+ String file = getStringFromFile(new File(output.getCanonicalPath()
+ "/org/apache/cxf/w2j/hello_world_mime/Hello.java"));
-
+
assertTrue(file.contains(str1));
assertTrue(file.contains(str2));
assertTrue(file.contains(str3));
@@ -569,11 +567,11 @@ public class CodeGenBugTest extends Abst
processor.setContext(env);
processor.execute();
- String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),
+ String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),
"org/apache/sayhi/SayHi.java"));
assertTrue(results.trim().length() > 0);
-
- assertTrue(results.indexOf("@WebResult(name = \"return\", "
+
+ assertTrue(results.indexOf("@WebResult(name = \"return\", "
+ "targetNamespace = \"http://apache.org/sayHi\")") != -1);
assertTrue(results.indexOf("@WebResult(name = \"return\", targetNamespace = \"\")") != -1);
}
@@ -621,7 +619,7 @@ public class CodeGenBugTest extends Abst
file = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/Greeter_GreeterPort_Server.java");
assertTrue("Greeter_GreeterPort_Server is not found", file.exists());
}
-
+
@Test
public void testRecursiveImport() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf778/hello_world_recursive.wsdl"));
@@ -629,36 +627,36 @@ public class CodeGenBugTest extends Abst
processor.execute();
assertNotNull("Process recursive import wsdl error ", output);
}
-
+
@Test
public void testCXF804() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf804/hello_world_contains_import.wsdl"));
// env.put(ToolConstants.CFG_SERVICENAME, "SOAPService");
processor.setContext(env);
processor.execute();
-
+
File file = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/MyService.java");
assertTrue("MyService is not found", file.exists());
-
+
}
-
+
@Test
public void testDefinieServiceName() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf804/hello_world_contains_import.wsdl"));
env.put(ToolConstants.CFG_SERVICENAME, "SOAPService");
processor.setContext(env);
processor.execute();
-
+
File file = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/SOAPService.java");
assertTrue("SOAPService is not found", file.exists());
-
+
file = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/MyService.java");
assertFalse("MyService should not be generated", file.exists());
-
+
}
-
+
@Test
public void testCXF805() throws Exception {
try {
@@ -669,8 +667,8 @@ public class CodeGenBugTest extends Abst
processor.execute();
fail("exception should be thrown");
} catch (Exception e) {
- String expectedErrorMsg = "Part <in> in Message "
- + "<{http://cxf.apache.org/w2j/hello_world_soap_http}greetMeRequest> referenced Type "
+ String expectedErrorMsg = "Part <in> in Message "
+ + "<{http://cxf.apache.org/w2j/hello_world_soap_http}greetMeRequest> referenced Type "
+ "<{http://cxf.apache.org/w2j/hello_world_soap_http/types}greetMee> can not be "
+ "found in the schemas";
assertTrue("Fail to create java parameter exception should be thrown",
@@ -678,15 +676,15 @@ public class CodeGenBugTest extends Abst
}
}
-
-
+
+
@Test
public void testAntFile() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
env.put(ToolConstants.CFG_ANT, ToolConstants.CFG_ANT);
env.put(ToolConstants.CFG_SERVICENAME, "SOAPService_Test1");
processor.setContext(env);
-
+
processor.execute();
File file = new File(output.getCanonicalPath() + "/build.xml");
String str = FileUtils.getStringFromFile(file);
@@ -695,7 +693,7 @@ public class CodeGenBugTest extends Abst
assertTrue(str.indexOf("org.apache.cxf.w2j.hello_world_soap_http.Greeter_SoapPortTest1_Server") > -1);
assertTrue(str.indexOf("org.apache.cxf.w2j.hello_world_soap_http.Greeter_SoapPortTest2_Server") > -1);
}
-
+
@Test
public void testNonUniqueBody() throws Exception {
try {
@@ -732,7 +730,7 @@ public class CodeGenBugTest extends Abst
QName stringName = new QName(ns2, "string");
QName intName = new QName(ns2, "int");
- Message msg = new Message("WRAPPER_STYLE_NAME_COLLISION", UniqueBodyValidator.LOG,
+ Message msg = new Message("WRAPPER_STYLE_NAME_COLLISION", UniqueBodyValidator.LOG,
elementName, stringName, intName);
assertEquals(msg.toString().trim(), e.getMessage().trim());
}
@@ -747,7 +745,7 @@ public class CodeGenBugTest extends Abst
fail("The cxf918/bug2.wsdl should not have generated code");
} catch (Exception e) {
assertTrue(e.getMessage(), e.getMessage().contains("theSameNameFieldDifferentDataType"));
- }
+ }
}
@Test
@@ -770,11 +768,11 @@ public class CodeGenBugTest extends Abst
processor.setContext(env);
processor.execute();
- String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),
+ String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),
"org/tempuri/GreeterRPCLit.java"));
assertTrue(results.indexOf("@WebParam(partName = \"inInt\", name = \"inInt\")") != -1);
assertTrue(results.indexOf("Style.RPC") != -1);
-
+
} catch (Exception e) {
fail("The cxf978.wsdl is a valid wsdl, should pass the test, caused by: " + e.getMessage());
}
@@ -805,18 +803,18 @@ public class CodeGenBugTest extends Abst
processor.setContext(env);
processor.execute();
- String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),
+ String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),
"soapinterface/ems/esendex/com/AccountServiceSoap.java"));
assertTrue(results.indexOf("public int getMessageLimit") != -1);
assertTrue(results.indexOf("name = \"MessengerHeader") != -1);
assertTrue(results.indexOf("header = true") != -1);
}
-
+
@Test
public void testBindingForImportWSDL() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf1095/hello_world_services.wsdl"));
- env.put(ToolConstants.CFG_BINDING,
+ env.put(ToolConstants.CFG_BINDING,
new String[] {getLocation("/wsdl2java_wsdl/cxf1095/binding.xml")
, getLocation("/wsdl2java_wsdl/cxf1095/binding1.xml")});
processor.setContext(env);
@@ -829,40 +827,40 @@ public class CodeGenBugTest extends Abst
assertNotNull("Customization Fault Class is not generated", serviceClz);
}
-
+
@Test
public void testReuseJaxwsBindingFile() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf1094/hello_world.wsdl"));
env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/async_binding.xml"));
processor.setContext(env);
processor.execute();
-
+
Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.hello_world_soap_http.Greeter");
-
+
Method method1 = clz.getMethod("greetMeSometimeAsync", new Class[] {java.lang.String.class,
javax.xml.ws.AsyncHandler.class});
-
+
assertNotNull("jaxws binding file does not take effect for hello_world.wsdl", method1);
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf1094/echo_date.wsdl"));
env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/async_binding.xml"));
processor.setContext(env);
processor.execute();
clz = classLoader.loadClass("org.apache.cxf.tools.fortest.date.EchoDate");
-
+
Method method2 = clz.getMethod("echoDateAsync",
new Class[] {javax.xml.datatype.XMLGregorianCalendar.class,
- javax.xml.ws.AsyncHandler.class});
+ javax.xml.ws.AsyncHandler.class});
assertNotNull("jaxws binding file does not take effect for echo_date.wsdl", method2);
}
-
+
// See CXF-2135
@Test
public void testReuseJaxbBindingFile1() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf1094/hello_world.wsdl"));
env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/jaxbbinding.xml"));
processor.setContext(env);
@@ -870,20 +868,20 @@ public class CodeGenBugTest extends Abst
Class clz = classLoader
.loadClass("org.apache.cxf.w2j.hello_world_soap_http.types.CreateProcess$MyProcess");
assertNotNull("Failed to generate customized class for hello_world.wsdl" , clz);
-
- env.put(ToolConstants.CFG_WSDLURL,
+
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/cxf1094/hello_world_oneway.wsdl"));
env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1094/jaxbbinding.xml"));
processor.setContext(env);
processor.execute();
Class customizedClz = classLoader.loadClass("org.apache.oneway.types.CreateProcess$MyProcess");
- assertNotNull("Failed to generate customized class for hello_world_oneway.wsdl",
- customizedClz);
- }
-
+ assertNotNull("Failed to generate customized class for hello_world_oneway.wsdl",
+ customizedClz);
+ }
+
@Test
public void testBindingXPath() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
+ env.put(ToolConstants.CFG_WSDLURL,
getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
env.put(ToolConstants.CFG_BINDING, getLocation("/wsdl2java_wsdl/cxf1106/binding.xml"));
processor.setContext(env);
@@ -894,17 +892,17 @@ public class CodeGenBugTest extends Abst
Method[] methods = clz.getMethods();
assertEquals("jaxws binding file parse error, number of generated method is not expected"
, 14, methods.length);
-
+
boolean existSayHiAsyn = false;
for (Method m : methods) {
if (m.getName().equals("sayHiAsyn")) {
existSayHiAsyn = true;
- }
+ }
}
assertFalse("sayHiAsyn method should not be generated", existSayHiAsyn);
}
-
-
+
+
@Test
public void testJaxbCatalog() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/cxf1112/myservice.wsdl"));
@@ -915,8 +913,8 @@ public class CodeGenBugTest extends Abst
Class clz = classLoader.loadClass("org.mytest.ObjectFactory");
assertNotNull("Customization types class should be generated", clz);
}
-
-
+
+
@Test
public void testCatalog2() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, "http://example.org/wsdl");
@@ -925,7 +923,7 @@ public class CodeGenBugTest extends Abst
processor.setContext(env);
processor.execute();
}
-
+
@Test
public void testCatalog3() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, "http://example.org/wsdl");
@@ -934,7 +932,7 @@ public class CodeGenBugTest extends Abst
processor.setContext(env);
processor.execute();
}
-
+
@Test
public void testServer() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/InvoiceServer.wsdl"));
@@ -942,10 +940,10 @@ public class CodeGenBugTest extends Abst
getLocation("/wsdl2java_wsdl/cxf1141/jaxb.xml")});
processor.setContext(env);
processor.execute();
-
+
File file = new File(output, "org/mytest");
assertEquals(13, file.list().length);
-
+
}
@Test
public void testCxf1137() {
@@ -958,7 +956,7 @@ public class CodeGenBugTest extends Abst
assertTrue(e.getMessage().indexOf("Summary: Failures: 5, Warnings: 0") != -1);
}
}
-
+
@Test
public void testTwoJaxwsBindingFile() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
@@ -976,8 +974,8 @@ public class CodeGenBugTest extends Abst
assertNotNull("Customized method 'myGreetMe' in MyGreeter.class is not found", customizedMethod);
}
-
-
+
+
@Test
public void testJaxwsBindingJavaDoc() throws Exception {
env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
@@ -985,16 +983,16 @@ public class CodeGenBugTest extends Abst
processor.setContext(env);
processor.execute();
- List<String> results1 = FileUtils.readLines(new File(output.getCanonicalPath(),
+ List<String> results1 = FileUtils.readLines(new File(output.getCanonicalPath(),
"org/mypkg/MyGreeter.java"));
-
+
assertTrue(results1.contains(" * this is package javadoc"));
assertTrue(results1.contains(" * this is class javadoc"));
assertTrue(results1.contains(" * this is method javadoc"));
-
- List<String> results2 = FileUtils.readLines(new File(output.getCanonicalPath(),
- "org/mypkg/SOAPServiceTest1.java"));
-
+
+ List<String> results2 = FileUtils.readLines(new File(output.getCanonicalPath(),
+ "org/mypkg/SOAPServiceTest1.java"));
+
boolean match1 = false;
boolean match2 = false;
for (String str : results2) {
@@ -1007,46 +1005,46 @@ public class CodeGenBugTest extends Abst
}
assertTrue(results1.toString(), match1);
assertTrue(results2.toString(), match2);
-
+
}
-
+
@Test
public void testWSAActionAnno() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
- getLocation("/wsdl2java_wsdl/cxf1209/hello_world_fault.wsdl"));
+ env.put(ToolConstants.CFG_WSDLURL,
+ getLocation("/wsdl2java_wsdl/cxf1209/hello_world_fault.wsdl"));
processor.setContext(env);
processor.execute();
}
-
+
@Test
public void testCXF964() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
- getLocation("/wsdl2java_wsdl/cxf964/hello_world_fault.wsdl"));
+ env.put(ToolConstants.CFG_WSDLURL,
+ getLocation("/wsdl2java_wsdl/cxf964/hello_world_fault.wsdl"));
processor.setContext(env);
processor.execute();
Class<?> clz = classLoader.loadClass("org.apache.intfault.BadRecordLitFault");
WebFault webFault = AnnotationUtil.getPrivClassAnnotation(clz, WebFault.class);
assertEquals("int", webFault.name());
}
-
+
@Test
public void testCXF1620() throws Exception {
- env.put(ToolConstants.CFG_WSDLURL,
- getLocation("/wsdl2java_wsdl/jaxb_custom_extensors.wsdl"));
+ env.put(ToolConstants.CFG_WSDLURL,
+ getLocation("/wsdl2java_wsdl/jaxb_custom_extensors.wsdl"));
env.put(ToolConstants.CFG_BINDING,
getLocation("/wsdl2java_wsdl/jaxb_custom_extensors.xjb"));
processor.setContext(env);
processor.execute();
Class<?> clz = classLoader.loadClass("org.apache.cxf.w2j.jaxb_custom_ext.types.Foo");
-
+
assertEquals(3, clz.getDeclaredFields().length);
-
+
clz = classLoader.loadClass("org.apache.cxf.w2j.jaxb_custom_ext.types.Foo2");
assertEquals(1, clz.getDeclaredFields().length);
}
-
-
+
+
@Test
public void testCXF1048() throws Exception {
@@ -1065,7 +1063,7 @@ public class CodeGenBugTest extends Abst
assertEquals("PingSoapPort", webServiceAnn.portName());
}
-
+
@Test
public void testCXF1694() throws Exception {
@@ -1077,7 +1075,7 @@ public class CodeGenBugTest extends Abst
assertTrue(ex.getMessage().contains("{http://child/}Binding is not correct"));
}
}
-
+
@Test
public void testCXF1662() throws Exception {
String[] args = new String[] {"-d", output.getCanonicalPath(), "-p", "org.cxf",
@@ -1088,11 +1086,11 @@ public class CodeGenBugTest extends Abst
} catch (ToolException tex) {
assertTrue(tex.getMessage().contains(" -p option cannot be used when "
+ "wsdl contains mutiple schemas"));
- }
-
-
+ }
+
+
String[] args2 = new String[] {"-d", output.getCanonicalPath(), "-p", "org.cxf",
- getLocation("/wsdl2java_wsdl/cxf1662/test2.wsdl")};
+ getLocation("/wsdl2java_wsdl/cxf1662/test2.wsdl")};
try {
WSDLToJava.main(args2);
} catch (ToolException tex) {
@@ -1104,7 +1102,7 @@ public class CodeGenBugTest extends Abst
String str = FileUtils.getStringFromFile(file);
assertTrue(str.contains("http://child/xsd"));
}
-
+
@Test
public void testMultiXjcArgs() throws Exception {
String[] args = new String[] {"-d", output.getCanonicalPath(),
@@ -1113,26 +1111,26 @@ public class CodeGenBugTest extends Abst
getLocation("/wsdl2java_wsdl/hello_world.wsdl")};
WSDLToJava.main(args);
File file = new File(output, "org/apache/cxf/w2j/hello_world_soap_http/types/SayHi.java");
-
+
assertTrue(file.exists());
String str = FileUtils.getStringFromFile(file);
assertTrue(str.contains("@XmlLocation"));
assertTrue(str.contains("synchronized"));
}
-
+
@Test
public void testCXF1939() throws Exception {
String[] args = new String[] {"-d", output.getCanonicalPath(),
"-impl", "-server", "-client", "-autoNameResolution",
getLocation("/wsdl2java_wsdl/cxf1939/hello_world.wsdl")};
WSDLToJava.main(args);
-
+
assertNotNull(output);
assertTrue(new File(output, "org/apache/cxf/w2j/hello_world_soap_http/GreeterImpl.java").exists());
assertTrue(new File(output, "org/apache/cxf/w2j/hello_world_soap_http/GreeterImpl1.java").exists());
- assertTrue(new File(output,
+ assertTrue(new File(output,
"org/apache/cxf/w2j/hello_world_soap_http/TestServiceName.java").exists());
- assertTrue(new File(output,
+ assertTrue(new File(output,
"org/apache/cxf/w2j/hello_world_soap_http/TestServiceName1.java").exists());
}
Modified: cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/wsdl11/JAXWSDefinitionBuilderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/wsdl11/JAXWSDefinitionBuilderTest.java?rev=1023413&r1=1023412&r2=1023413&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/wsdl11/JAXWSDefinitionBuilderTest.java (original)
+++ cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/wsdl11/JAXWSDefinitionBuilderTest.java Sun Oct 17 02:29:31 2010
@@ -57,13 +57,13 @@ public class JAXWSDefinitionBuilderTest
builder.setContext(env);
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
-
+
Map services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
Service service = (Service)services.get(new QName(qname, "XMLService"));
assertNotNull(service);
-
+
Map ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
@@ -71,7 +71,7 @@ public class JAXWSDefinitionBuilderTest
assertNotNull(port);
assertEquals(1, port.getExtensibilityElements().size());
- assertTrue(port.getExtensibilityElements().get(0).getClass().getName(),
+ assertTrue(port.getExtensibilityElements().get(0).getClass().getName() + " is an HTTPAddress",
port.getExtensibilityElements().get(0) instanceof HTTPAddress);
Binding binding = port.getBinding();
@@ -97,13 +97,13 @@ public class JAXWSDefinitionBuilderTest
builder.setContext(env);
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
-
+
Map services = def.getServices();
assertNotNull(services);
assertEquals(8, services.size());
Service service = (Service)services.get(new QName(qname, "HelloWorldQueueBinMsgService"));
assertNotNull(service);
-
+
Map ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Modified: cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/echo_date.xjb
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/echo_date.xjb?rev=1023413&r1=1023412&r2=1023413&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/echo_date.xjb (original)
+++ cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/echo_date.xjb Sun Oct 17 02:29:31 2010
@@ -22,7 +22,7 @@
* The reason we generate this file is that
* we detected java.util.Date or java.util.Calendar classes in your SEI
*
- * Useage:
+ * Usage:
* wsdl2java [-b <the path of this file>] wsdl
* To customize the generated date types
-->
@@ -31,8 +31,8 @@
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://date.fortest.tools.cxf.apache.org/']">
- <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://date.fortest.tools.cxf.apache.org/']">
+ <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jxb:javaType name="java.util.Date" xmlType="xs:dateTime"
parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime"
printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime"/>