Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 36307 invoked from network); 4 Jan 2008 15:49:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Jan 2008 15:49:46 -0000 Received: (qmail 47289 invoked by uid 500); 4 Jan 2008 15:49:35 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 47234 invoked by uid 500); 4 Jan 2008 15:49:34 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 47225 invoked by uid 99); 4 Jan 2008 15:49:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jan 2008 07:49:34 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jan 2008 15:49:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 549E91A9860; Fri, 4 Jan 2008 07:49:00 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r608894 [10/10] - in /incubator/cxf/trunk: ./ buildtools/src/main/resources/ common/schemas/src/main/resources/schemas/wsdl/ etc/eclipse/ maven-plugins/corba/ parent/ rt/bindings/corba/ rt/bindings/corba/src/main/java/org/apache/yoko/bindin... Date: Fri, 04 Jan 2008 15:47:53 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080104154900.549E91A9860@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaHelper.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors.wsdl; @@ -53,11 +53,14 @@ import org.apache.ws.commons.schema.XmlSchemaChoice; import org.apache.ws.commons.schema.XmlSchemaComplexContent; import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension; +import org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction; import org.apache.ws.commons.schema.XmlSchemaComplexType; import org.apache.ws.commons.schema.XmlSchemaElement; import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet; +import org.apache.ws.commons.schema.XmlSchemaExternal; import org.apache.ws.commons.schema.XmlSchemaFacet; import org.apache.ws.commons.schema.XmlSchemaForm; +import org.apache.ws.commons.schema.XmlSchemaImport; import org.apache.ws.commons.schema.XmlSchemaLengthFacet; import org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet; import org.apache.ws.commons.schema.XmlSchemaParticle; @@ -135,20 +138,18 @@ // need to determine if its a primitive type. if (stype.getBaseSchemaType() != null) { corbaTypeImpl = processPrimitiveType(stype.getQName()); - } - - if (stype instanceof XmlSchemaComplexType) { - return corbaTypeImpl = processComplexType((XmlSchemaComplexType)stype, - defaultName, annotation, anonymous); + } else if (stype instanceof XmlSchemaComplexType) { + corbaTypeImpl = processComplexType((XmlSchemaComplexType)stype, + defaultName, annotation, anonymous); } else if (stype instanceof XmlSchemaSimpleType) { - return corbaTypeImpl = processSimpleType((XmlSchemaSimpleType)stype, - defaultName, anonymous); + corbaTypeImpl = processSimpleType((XmlSchemaSimpleType)stype, + defaultName, anonymous); } else if (xmlSchemaType.getElementByName(stype.getQName()) != null) { XmlSchemaElement el = xmlSchemaType.getElementByName(stype.getQName()); //REVISIT, passing ns uri because of a bug in XmlSchema (Bug: WSCOMMONS-69) - return corbaTypeImpl = processElementType(el, - defaultName, - stype.getQName().getNamespaceURI()); + corbaTypeImpl = processElementType(el, + defaultName, + stype.getQName().getNamespaceURI()); } else { throw new Exception("Couldn't convert schema " + stype.getQName() + " to corba type"); } @@ -384,9 +385,13 @@ XmlSchemaType type = null; Iterator i = xmlSchemaList.iterator(); while (i.hasNext()) { - XmlSchema xmlSchema = (XmlSchema)i.next(); - String nspace = xmlSchema.getTargetNamespace(); - QName tname = createQName(nspace, name.getLocalPart(), "xsd"); + XmlSchema xmlSchema = (XmlSchema)i.next(); + String nspace = name.getNamespaceURI(); + if (nspace == null) { + nspace = xmlSchema.getTargetNamespace(); + } + //QName tname = createQName(nspace, name.getLocalPart(), "xsd"); + QName tname = createQName(nspace, name.getLocalPart(), ""); type = findSchemaType(tname); if (type != null) { break; @@ -515,7 +520,7 @@ attrName = new QName(uri, attrName.getLocalPart()); } CorbaTypeImpl membertype = null; - boolean attrQualified = getAttributeQualification(attribute); + boolean attrQualified = getAttributeQualification(attribute, uri); if (attribute.getUse().getValue().equals("none") || attribute.getUse().getValue().equals(W3CConstants.USE_OPTIONAL)) { CorbaTypeImpl attType = null; @@ -649,13 +654,23 @@ if (itemType != null) { return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false); - } + } return itemType; } QName ltypeName = createQNameXmlSchemaNamespace(ltype.getItemTypeName().getLocalPart()); itemType = processPrimitiveType(ltypeName); - return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), + if (itemType != null) { + return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false); + } else { + // if the type of the simpleContent is a list with another simple type. + XmlSchemaType base = getSchemaType(ltype.getItemTypeName()); + itemType = convertSchemaToCorbaType(base, base.getQName(), base, null, false); + if (itemType != null) { + return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), + itemType.getQName(), null, 0, false); + } + } } else if (stype.getContent() == null) { // elements primitive type QName stypeName = createQNameXmlSchemaNamespace(stype.getName()); @@ -799,22 +814,53 @@ private XmlSchemaType findSchemaType(QName typeName) { XmlSchemaType schemaType = null; + + + Iterator i = xmlSchemaList.iterator(); while (i.hasNext()) { - XmlSchema xmlSchema = (XmlSchema)i.next(); - if (xmlSchema.getElementByName(typeName) != null) { - XmlSchemaElement schemaElement = xmlSchema.getElementByName(typeName); - schemaType = schemaElement.getSchemaType(); - } else if (xmlSchema.getTypeByName(typeName) != null) { - schemaType = xmlSchema.getTypeByName(typeName); - } + XmlSchema xmlSchema = (XmlSchema)i.next(); + // if the schema includes other schemas need to search there. + schemaType = findTypeInSchema(xmlSchema, typeName); if (schemaType != null) { return schemaType; - } + } } return schemaType; } + private XmlSchemaType findTypeInSchema(XmlSchema xmlSchema, QName typeName) { + XmlSchemaType schemaType = null; + + if (xmlSchema.getElementByName(typeName) != null) { + XmlSchemaElement schemaElement = xmlSchema.getElementByName(typeName); + schemaType = schemaElement.getSchemaType(); + } else if (xmlSchema.getTypeByName(typeName) != null) { + schemaType = xmlSchema.getTypeByName(typeName); + } + if (schemaType != null) { + return schemaType; + } else { + if (xmlSchema.getIncludes() != null) { + Iterator schemas = xmlSchema.getIncludes().getIterator(); + while (schemas.hasNext()) { + Object obj = schemas.next(); + if (obj instanceof XmlSchemaExternal) { + XmlSchemaExternal extSchema = (XmlSchemaExternal) obj; + if (!(extSchema instanceof XmlSchemaImport)) { + schemaType = findTypeInSchema(extSchema.getSchema(), typeName); + if (schemaType != null) { + return schemaType; + } + } + } + } + } + } + + return null; + } + protected boolean isSchemaTypeException(XmlSchemaType stype) { boolean exception = false; XmlSchemaComplexType complex = null; @@ -929,9 +975,14 @@ QName name; Struct corbaStruct = null; QName schematypeName = checkPrefix(complex.getQName()); - if (schematypeName == null) { - schematypeName = checkPrefix(defaultName); - name = checkPrefix(createQNameCorbaNamespace(defaultName.getLocalPart())); + if (schematypeName == null) { + schematypeName = createQNameTargetNamespace(defaultName.getLocalPart()); + if (defaultName.getNamespaceURI().equals("")) { + schematypeName = checkPrefix(schematypeName); + } else { + schematypeName = checkPrefix(defaultName); + } + name = checkPrefix(createQNameCorbaNamespace(defaultName.getLocalPart())); } else { name = checkPrefix(createQNameCorbaNamespace(schematypeName.getLocalPart())); } @@ -1031,10 +1082,15 @@ = (XmlSchemaSimpleContentRestriction)simpleContent.getContent(); base = restrict.getBaseType(); - if (base == null) { - base = getSchemaType(restrict.getBaseTypeName()); + + if (restrict.getBaseTypeName() != null) { + basetype = processPrimitiveType(restrict.getBaseTypeName()); + } + + if (basetype == null) { + base = getSchemaType(restrict.getBaseTypeName()); + basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false); } - basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false); MemberType basemember = new MemberType(); basemember.setName("_simpleTypeValue"); @@ -1060,93 +1116,126 @@ Struct corbaStruct, QName schematypeName) throws Exception { + if (complex.getContent() instanceof XmlSchemaComplexContentExtension) { + XmlSchemaComplexContentExtension extype + = (XmlSchemaComplexContentExtension)complex.getContent(); + QName extName = extype.getBaseTypeName(); + Iterator attrs = extype.getAttributes().getIterator(); + corbaStruct = processComplexContentStructParticle(extype.getParticle(), defaultName, corbaStruct, + schematypeName, extName, attrs); + } else { + if (complex.getContent() instanceof XmlSchemaComplexContentRestriction) { + XmlSchemaComplexContentRestriction extype + = (XmlSchemaComplexContentRestriction)complex.getContent(); + QName extName = extype.getBaseTypeName(); + Iterator attrs = extype.getAttributes().getIterator(); + corbaStruct = + processComplexContentStructParticle(extype.getParticle(), defaultName, + corbaStruct, schematypeName, + extName, attrs); + } + } + return corbaStruct; + } + + private Struct processComplexContentStructParticle(XmlSchemaParticle extype, + QName defaultName, Struct corbaStruct, + QName schematypeName, QName extName, + Iterator attrs) + throws Exception { + String uri; if (schematypeName != null) { uri = schematypeName.getNamespaceURI(); } else { uri = defaultName.getNamespaceURI(); } - - if (complex.getContent() instanceof XmlSchemaComplexContentExtension) { - XmlSchemaComplexContentExtension extype - = (XmlSchemaComplexContentExtension)complex.getContent(); - - // Add base as a member of this struct - MemberType memberType = new MemberType(); - QName extName = extype.getBaseTypeName(); - memberType.setName(extName.getLocalPart() + "_f"); - if (extName.getLocalPart().equals("anyType")) { - memberType.setIdltype(processPrimitiveType(extName).getQName()); - } else { - memberType.setIdltype(createQNameCorbaNamespace(extName.getLocalPart())); - } - corbaStruct.getMember().add(memberType); + + // Add base as a member of this struct + MemberType memberType = new MemberType(); + memberType.setName(extName.getLocalPart() + "_f"); + if (extName.getLocalPart().equals("anyType")) { + memberType.setIdltype(processPrimitiveType(extName).getQName()); + } else { + memberType.setIdltype(createQNameCorbaNamespace(extName.getLocalPart())); + } + corbaStruct.getMember().add(memberType); - // process attributes at complexContent level - List attlist1 = processAttributesAsMembers(extype.getAttributes().getIterator(), uri); - for (int i = 0; i < attlist1.size(); i++) { - MemberType member = (MemberType)attlist1.get(i); - corbaStruct.getMember().add(member); - } + // process attributes at complexContent level + List attlist1 = processAttributesAsMembers(attrs, uri); + for (int i = 0; i < attlist1.size(); i++) { + MemberType member = (MemberType)attlist1.get(i); + corbaStruct.getMember().add(member); + } - // Process members of Current Type - if (extype.getParticle() instanceof XmlSchemaChoice) { - XmlSchemaChoice choice = (XmlSchemaChoice)extype.getParticle(); - MemberType choicemem = processComplexContentStructChoice(choice, schematypeName, defaultName); - choicemem.setAnonschematype(true); - corbaStruct.getMember().add(choicemem); - } else if (extype.getParticle() instanceof XmlSchemaSequence) { - XmlSchemaSequence seq = (XmlSchemaSequence)extype.getParticle(); - CorbaTypeImpl seqtype = - processSequenceType(seq, defaultName, schematypeName); - - if (seqtype != null) { - MemberType seqmem = new MemberType(); - seqmem.setName(seqtype.getQName().getLocalPart() + "_f"); - QName type = createQNameCorbaNamespace(seqtype.getQName().getLocalPart()); - seqmem.setIdltype(type); - seqmem.setAnonschematype(true); - if (seqtype.isSetQualified() && seqtype.isQualified()) { - seqmem.setQualified(true); - } - corbaStruct.getMember().add(seqmem); - if (!isDuplicate(seqtype)) { - typeMappingType.getStructOrExceptionOrUnion().add(seqtype); - } - } else { - LOG.log(Level.WARNING, "Couldnt map Sequence inside extension"); - } + // Process members of Current Type + if (extype instanceof XmlSchemaChoice) { + XmlSchemaChoice choice = (XmlSchemaChoice)extype; + MemberType choicemem = processComplexContentStructChoice(choice, schematypeName, defaultName); + choicemem.setAnonschematype(true); + corbaStruct.getMember().add(choicemem); + } else if (extype instanceof XmlSchemaSequence) { + XmlSchemaSequence seq = (XmlSchemaSequence)extype; + corbaStruct = processComplexContentStructSequence(corbaStruct, seq, defaultName, schematypeName); + } else if (extype instanceof XmlSchemaAll) { + XmlSchemaAll all = (XmlSchemaAll)extype; + corbaStruct = processComplexContentStructSchemaAll(corbaStruct, all, + defaultName, schematypeName); + } + return corbaStruct; + } + + private Struct processComplexContentStructSequence(Struct corbaStruct, XmlSchemaSequence seq, + QName defaultName, QName schematypeName) + throws Exception { + + CorbaTypeImpl seqtype = + processSequenceType(seq, defaultName, schematypeName); - } else if (extype.getParticle() instanceof XmlSchemaAll) { - XmlSchemaAll all = (XmlSchemaAll)extype.getParticle(); - - CorbaTypeImpl alltype = processAllType(all, defaultName, schematypeName); - if (alltype != null) { - MemberType allmem = new MemberType(); - allmem.setName(alltype.getQName().getLocalPart() + "_f"); - allmem.setIdltype(alltype.getQName()); - allmem.setAnonschematype(true); - if (alltype.isSetQualified() && alltype.isQualified()) { - allmem.setQualified(true); - } - corbaStruct.getMember().add(allmem); - if (!isDuplicate(alltype)) { - typeMappingType.getStructOrExceptionOrUnion().add(alltype); - } - } else { - LOG.log(Level.WARNING, "Couldnt map All inside extension"); - } + if (seqtype != null) { + MemberType seqmem = new MemberType(); + seqmem.setName(seqtype.getQName().getLocalPart() + "_f"); + QName type = createQNameCorbaNamespace(seqtype.getQName().getLocalPart()); + seqmem.setIdltype(type); + seqmem.setAnonschematype(true); + if (seqtype.isSetQualified() && seqtype.isQualified()) { + seqmem.setQualified(true); + } + corbaStruct.getMember().add(seqmem); + if (!isDuplicate(seqtype)) { + typeMappingType.getStructOrExceptionOrUnion().add(seqtype); + } + } else { + LOG.log(Level.WARNING, "Couldnt map Sequence inside extension"); + } + + return corbaStruct; + } + + private Struct processComplexContentStructSchemaAll(Struct corbaStruct, XmlSchemaAll all, + QName defaultName, QName schematypeName) + throws Exception { + + CorbaTypeImpl alltype = processAllType(all, defaultName, schematypeName); + if (alltype != null) { + MemberType allmem = new MemberType(); + allmem.setName(alltype.getQName().getLocalPart() + "_f"); + allmem.setIdltype(alltype.getQName()); + allmem.setAnonschematype(true); + if (alltype.isSetQualified() && alltype.isQualified()) { + allmem.setQualified(true); + } + corbaStruct.getMember().add(allmem); + if (!isDuplicate(alltype)) { + typeMappingType.getStructOrExceptionOrUnion().add(alltype); } - } else { - org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message( - "Restriction inside ComplexContent is not yet Supported.", LOG); - //throw new Exception(msg.toString()); - return null; + LOG.log(Level.WARNING, "Couldnt map All inside extension"); } - + return corbaStruct; } + protected MemberType processComplexContentStructChoice(XmlSchemaChoice choice, QName schematypeName, QName defaultName) @@ -1381,10 +1470,14 @@ protected Union createUnion(QName name, XmlSchemaChoice choice, QName defaultName, QName schematypeName) throws Exception { - Union corbaUnion = (Union)recursionMap.get(name); - if (corbaUnion != null) { - return corbaUnion; - } + + Union corbaUnion = null; + if (recursionMap.get(name) instanceof Union) { + corbaUnion = (Union)recursionMap.get(name); + if (corbaUnion != null) { + return corbaUnion; + } + } corbaUnion = new Union(); corbaUnion.setName(name.getLocalPart()); @@ -1411,6 +1504,9 @@ corbaUnion = WSDLTypes.processUnionBranches(corbaUnion, fields, caselist); recursionMap.remove(name); + if (!isDuplicate(corbaUnion)) { + typeMappingType.getStructOrExceptionOrUnion().add(corbaUnion); + } return corbaUnion; } @@ -1542,15 +1638,16 @@ return qualified; } - private boolean getAttributeQualification(XmlSchemaAttribute attr) { + private boolean getAttributeQualification(XmlSchemaAttribute attr, String uri) { QName schemaName = attr.getQName(); /* // workaround for now - sent bug to WSCommons - the attribute - // QName should have its namespace included. + // QName should have its namespace included. */ + if (schemaName.getNamespaceURI().equals("")) { schemaName = new QName(uri, schemaName.getLocalPart()); } - */ + boolean qualified = false; if (attr.getForm().getValue().equals(XmlSchemaForm.QUALIFIED)) { qualified = true; Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors.wsdl; Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors.wsdl; Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToProcessor.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors.wsdl; @@ -157,13 +157,15 @@ schemaElem = elem; } } + if (schemaElem != null) { schematype = schemaCol.read(schemaElem); - schematypeList.add(schematype); + schematypeList.add(schematype); } } } - } + + } public void process() throws ToolException { if (env == null) { Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToTypeProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToTypeProcessor.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToTypeProcessor.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToTypeProcessor.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors.wsdl; Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLTypes.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors.wsdl; Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/FileOutputStreamFactory.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/FileOutputStreamFactory.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/FileOutputStreamFactory.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/FileOutputStreamFactory.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.utils; Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/OutputStreamFactory.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/OutputStreamFactory.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/OutputStreamFactory.java (original) +++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/utils/OutputStreamFactory.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.utils; Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/IDLToWSDLTest.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools; @@ -36,7 +36,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; - +import org.apache.cxf.helpers.FileUtils; import org.apache.yoko.tools.common.ToolCorbaConstants; import org.apache.yoko.tools.common.ToolTestBase; import org.apache.yoko.tools.utils.TestUtils; @@ -71,27 +71,16 @@ } try { - File file = File.createTempFile("IDLToWSDLTest", ""); - output = new File(file.getAbsolutePath() + ".dir"); - file.delete(); - - if (!output.exists()) { - output.mkdir(); - } + output = new File(getClass().getResource(".").toURI()); + output = new File(output, "generated-wsdl"); + FileUtils.mkDir(output); } 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(); + FileUtils.removeDir(dir); } public void tearDown() { @@ -145,7 +134,8 @@ break; } } - + origReader.close(); + genReader.close(); } public void testNoArgs() throws Exception { @@ -205,8 +195,12 @@ private void doTestGeneratedWsdl(File expected, File actual) throws FileNotFoundException, XMLStreamException, Exception { - InputStream actualFileStream = new FileInputStream(actual); - InputStream expectedFileStream = new FileInputStream(expected); + //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); + + InputStream actualFileStream = new FileInputStream(actualWsdlFile); + InputStream expectedFileStream = new FileInputStream(expectedWsdlFile); XMLInputFactory factory = XMLInputFactory.newInstance(); @@ -315,6 +309,21 @@ File expected = new File(getClass().getResource("/idl/expected_Exception_DiffNS.wsdl").getFile()); String[] args = new String[] {"-x", "http://schemas.apache.org/yoko/idl/Exception/types", + "-o", output.toString(), + input.toString() + }; + int exc = execute(args); + assertEquals("IDLToWSDL Failed", noError, exc); + doTestGeneratedWsdl(expected, actual); + } + + public void testOutputWSDLFileName() throws Exception { + File input = new File(getClass().getResource("/idl/HelloWorld.idl").getFile()); + File actual = new File(output, "ArtixHelloWorld.wsdl"); + File expected = + new File(getClass().getResource("/idl/expected_HelloWorld.wsdl").getFile()); + + String[] args = new String[] {"-ow", "ArtixHelloWorld.wsdl", "-o", output.toString(), input.toString() }; Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/WSDLToIDLTest.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools; @@ -34,6 +34,7 @@ import javax.wsdl.Definition; import javax.xml.namespace.QName; +import org.apache.cxf.helpers.FileUtils; import org.apache.yoko.tools.common.ToolTestBase; import org.apache.yoko.tools.processors.wsdl.WSDLToProcessor; import org.apache.yoko.tools.utils.TestUtils; @@ -62,27 +63,16 @@ } try { - File file = File.createTempFile("WSDLToIDLTest", ""); - output = new File(file.getAbsolutePath() + ".dir"); - file.delete(); - - if (!output.exists()) { - output.mkdir(); - } + output = new File(getClass().getResource(".").toURI()); + output = new File(output, "generated-idl"); + FileUtils.mkDir(output); } 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(); + FileUtils.removeDir(dir); } public void tearDown() { @@ -136,7 +126,8 @@ break; } } - + origReader.close(); + genReader.close(); } public void testBindingGenDefault() throws Exception { @@ -158,8 +149,6 @@ assertNotNull("Binding Node not found in WSDL", model.getBinding(bindingName)); } catch (Exception e) { fail("WSDLToCORBA generated an invalid simpleList-corba.wsdl"); - } finally { - f.deleteOnExit(); } } @@ -184,8 +173,6 @@ assertNotNull("Binding Node not found in WSDL", model.getBinding(bindingName)); } catch (Exception e) { fail("WSDLToIDL generated an invalid simpleList-corba.wsdl"); - } finally { - f.deleteOnExit(); } } @@ -199,15 +186,12 @@ File f = new File(output, "simple-binding.idl"); assertTrue("simple-binding.idl should be generated", f.exists()); - try { - FileInputStream stream = new FileInputStream(f); - BufferedInputStream bis = new BufferedInputStream(stream); - DataInputStream dis = new DataInputStream(bis); - String line = dis.toString(); - assertTrue("Invalid Idl File Generated", line.length() > 0); - } finally { - f.deleteOnExit(); - } + FileInputStream stream = new FileInputStream(f); + BufferedInputStream bis = new BufferedInputStream(stream); + DataInputStream dis = new DataInputStream(bis); + String line = dis.toString(); + assertTrue("Invalid Idl File Generated", line.length() > 0); + stream.close(); } public void testIDLGenSpecifiedFile() throws Exception { @@ -221,15 +205,12 @@ File f = new File(output, "simple-binding_gen.idl"); assertTrue("simple-binding_gen.idl should be generated", f.exists()); - try { - FileInputStream stream = new FileInputStream(f); - BufferedInputStream bis = new BufferedInputStream(stream); - DataInputStream dis = new DataInputStream(bis); - String line = dis.toString(); - assertTrue("Invalid Idl File Generated", line.length() > 0); - } finally { - f.deleteOnExit(); - } + FileInputStream stream = new FileInputStream(f); + BufferedInputStream bis = new BufferedInputStream(stream); + DataInputStream dis = new DataInputStream(bis); + String line = dis.toString(); + assertTrue("Invalid Idl File Generated", line.length() > 0); + stream.close(); } // tests generating corba and idl in default wsdl and idl files @@ -256,19 +237,14 @@ assertNotNull("Binding Node not found in WSDL", model.getBinding(bindingName)); } catch (Exception e) { fail("WSDLToIDL generated an invalid simple-binding-corba.wsdl"); - } finally { - f1.deleteOnExit(); } - try { - FileInputStream stream = new FileInputStream(f2); - BufferedInputStream bis = new BufferedInputStream(stream); - DataInputStream dis = new DataInputStream(bis); - String line = dis.toString(); - assertTrue("Invalid Idl File Generated", line.length() > 0); - } finally { - f2.deleteOnExit(); - } + FileInputStream stream = new FileInputStream(f2); + BufferedInputStream bis = new BufferedInputStream(stream); + DataInputStream dis = new DataInputStream(bis); + String line = dis.toString(); + assertTrue("Invalid Idl File Generated", line.length() > 0); + stream.close(); } public void testNoArgs() throws Exception { Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/CorbaPrimitiveMapTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/CorbaPrimitiveMapTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/CorbaPrimitiveMapTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/CorbaPrimitiveMapTest.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.common; Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/ToolTestBase.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/ToolTestBase.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/ToolTestBase.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/common/ToolTestBase.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.common; Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReaderTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReaderTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReaderTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/idlpreprocessor/IdlPreprocessorReaderTest.java Fri Jan 4 07:47:28 2008 @@ -1,5 +1,24 @@ +/** + * 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.yoko.tools.idlpreprocessor; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -74,6 +93,23 @@ assertEquals(1, ex.getLine()); assertTrue(ex.getUrl().getPath().endsWith("/UnresolvableInclude.idl")); } + } + + public void testDefaultIncludeResolver() throws Exception { + final String location = "B.idl"; + // uses <> notation for include + final URL orig = findTestResource(location); + final File dir = new File(orig.getPath().substring(0, + orig.getPath().indexOf(location))); + final DefaultIncludeResolver includeResolver = new DefaultIncludeResolver(dir); + final DefineState defineState = new DefineState(new HashMap()); + + final IdlPreprocessorReader includeReader = new IdlPreprocessorReader(orig, + location, + includeResolver, + defineState); + final String expectedResultLocation = "B-resolved.idl"; + assertExpectedPreprocessingResult(expectedResultLocation, includeReader); } private IdlPreprocessorReader createPreprocessorReader(final String location) throws IOException { Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/IDLToWSDLGenerationTest.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors; @@ -310,7 +310,7 @@ String userdir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); - File file = file = new File(userdir + sep + importName); + File file = new File(userdir + sep + importName); String location = file.toURI().toString(); File schemaFile = new File(userdir + sep + schemaFilename); String schemaLocation = schemaFile.toURI().toString(); Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTest.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors; Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToCorbaBindingTypeTest.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors; Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.processors; @@ -23,7 +23,6 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestUtils.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestUtils.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestUtils.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestUtils.java Fri Jan 4 07:47:28 2008 @@ -15,7 +15,7 @@ * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.apache.yoko.tools.utils; Added: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaFactoryImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaFactoryImpl.java?rev=608894&view=auto ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaFactoryImpl.java (added) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaFactoryImpl.java Fri Jan 4 07:47:28 2008 @@ -0,0 +1,33 @@ +/** + * 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.yoko.tools.utils; + +import javax.wsdl.xml.WSDLWriter; + +import com.ibm.wsdl.factory.WSDLFactoryImpl; + +public class TestWSDLCorbaFactoryImpl extends WSDLFactoryImpl { + + /** + * Create a new instance of a WSDLWriter. + */ + public WSDLWriter newWSDLWriter() { + return new TestWSDLCorbaWriterImpl(); + } +} Propchange: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaFactoryImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaFactoryImpl.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaWriterImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaWriterImpl.java?rev=608894&view=auto ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaWriterImpl.java (added) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaWriterImpl.java Fri Jan 4 07:47:28 2008 @@ -0,0 +1,119 @@ +/** + * 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.yoko.tools.utils; + +import java.util.Map; +import java.util.TreeMap; + +import javax.wsdl.Definition; +import javax.wsdl.PortType; +import javax.wsdl.WSDLException; + +import javax.xml.namespace.QName; + +import com.ibm.wsdl.xml.WSDLWriterImpl; + + /* + * This class is extending the wsdl4j RI class to print out the + * maps in a particular order + * + */ +public class TestWSDLCorbaWriterImpl extends WSDLWriterImpl { + + private TestComparator comparator = new TestComparator(); + + protected void printBindingFaults(java.util.Map bindingFaults, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map bfaults = new TreeMap(comparator); + bfaults.putAll(bindingFaults); + super.printBindingFaults(bfaults, def, pw); + } + + protected void printBindings(java.util.Map bindings, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(bindings); + super.printBindings(map, def, pw); + } + + protected void printFaults(java.util.Map faults, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(faults); + super.printFaults(map, def, pw); + } + + protected void printImports(java.util.Map imports, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(imports); + super.printImports(map, def, pw); + } + + protected void printMessages(java.util.Map messages, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(messages); + super.printMessages(map, def, pw); + } + + protected void printNamespaceDeclarations(java.util.Map namespaces, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(namespaces); + super.printNamespaceDeclarations(map, pw); + } + + protected void printPorts(java.util.Map ports, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(ports); + super.printPorts(map, def, pw); + } + protected void printPortTypes(java.util.Map portTypes, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(portTypes); + super.printPortTypes(map, def, pw); + } + + protected void printServices(java.util.Map services, Definition def, java.io.PrintWriter pw) + throws WSDLException { + Map map = new TreeMap(comparator); + map.putAll(services); + super.printServices(map, def, pw); + } + + public class TestComparator implements java.util.Comparator { + + private java.text.Collator collator; + + public TestComparator() { + collator = java.text.Collator.getInstance(); + } + + public int compare(Object o1, Object o2) { + return collator.compare(o1.toString(), o2.toString()); + } + + public boolean equals(Object o1, Object o2) { + return collator.equals(o1.toString(), o2.toString()); + } + } +} Propchange: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaWriterImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/TestWSDLCorbaWriterImpl.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Modified: incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/WSDLGenerationTester.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/WSDLGenerationTester.java?rev=608894&r1=608893&r2=608894&view=diff ============================================================================== --- incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/WSDLGenerationTester.java (original) +++ incubator/cxf/trunk/tools/corba/src/test/java/org/apache/yoko/tools/utils/WSDLGenerationTester.java Fri Jan 4 07:47:28 2008 @@ -1,12 +1,53 @@ +/** + * 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.yoko.tools.utils; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; + +import javax.wsdl.Binding; +import javax.wsdl.BindingOperation; +import javax.wsdl.Definition; +import javax.wsdl.Port; + +import javax.wsdl.extensions.ExtensionRegistry; +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; import junit.framework.Assert; +import org.apache.cxf.wsdl.JAXBExtensionHelper; +import org.apache.schemas.yoko.bindings.corba.TypeMappingType; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaCollection; +import org.apache.yoko.wsdl.CorbaConstants; + public class WSDLGenerationTester { - + + private XmlSchemaCollection schemaCol = new XmlSchemaCollection(); + public WSDLGenerationTester() { } @@ -52,16 +93,33 @@ private void compareStartElement(XMLStreamReader orig, XMLStreamReader actual) throws Exception { Assert.assertEquals("Start element is not matched", orig.getName(), actual.getName()); - Assert.assertEquals("Attribute count is not matched for element " + orig.getName(), - orig.getAttributeCount(), - actual.getAttributeCount()); - int count = orig.getAttributeCount(); - for (int i = 0; i < count; i++) { - QName attrName = orig.getAttributeName(i); - Assert.assertEquals("Attribute " + attrName + " not found or value not matching", - orig.getAttributeValue(attrName.getNamespaceURI(), attrName.getLocalPart()), - actual.getAttributeValue(attrName.getNamespaceURI(), attrName.getLocalPart())); + int origAttrCount = orig.getAttributeCount(); + int actualAttrCount = actual.getAttributeCount(); + for (int i = 0; i < origAttrCount; i++) { + QName origAttrName = orig.getAttributeName(i); + if ((origAttrName.getLocalPart().equals("location")) + || (origAttrName.getLocalPart().equals("schemaLocation"))) { + //skip this atribute + origAttrCount--; + } else { + Assert.assertEquals("Attribute " + origAttrName + " not found or value not matching", + orig.getAttributeValue(origAttrName.getNamespaceURI(), + origAttrName.getLocalPart()), + actual.getAttributeValue(origAttrName.getNamespaceURI(), + origAttrName.getLocalPart())); + } } + for (int i = 0; i < actualAttrCount; i++) { + QName actualAttrName = actual.getAttributeName(i); + if ((actualAttrName.getLocalPart().equals("location")) + || (actualAttrName.getLocalPart().equals("schemaLocation"))) { + //skip this atribute + actualAttrCount--; + } + } + Assert.assertEquals("Attribute count is not matched for element " + orig.getName(), + origAttrCount, + actualAttrCount); } private void compareEndElement(XMLStreamReader orig, XMLStreamReader actual) @@ -72,5 +130,54 @@ private void compareCharacters(XMLStreamReader orig, XMLStreamReader actual) throws Exception { Assert.assertEquals("Element Characters not matched", orig.getText(), actual.getText()); - } + } + + public File writeDefinition(File targetDir, File defnFile) throws Exception { + File bkFile = new File(targetDir, "bk_" + defnFile.getName()); + FileWriter writer = new FileWriter(bkFile); + WSDLFactory factory = WSDLFactory.newInstance("org.apache.yoko.tools.utils.TestWSDLCorbaFactoryImpl"); + WSDLReader reader = factory.newWSDLReader(); + reader.setFeature("javax.wsdl.importDocuments", false); + ExtensionRegistry extReg = new ExtensionRegistry(); + addExtensions(extReg); + reader.setExtensionRegistry(extReg); + Definition wsdlDefn = reader.readWSDL(defnFile.toString()); + WSDLWriter wsdlWriter = factory.newWSDLWriter(); + wsdlWriter.writeWSDL(wsdlDefn, writer); + writer.close(); + writer = null; + reader = null; + 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, null); + schema.write(writer); + reader.close(); + writer.close(); + writer = null; + reader = null; + return bkFile; + } + + private void addExtensions(ExtensionRegistry extReg) throws Exception { + JAXBExtensionHelper.addExtensions(extReg, Binding.class, BindingType.class); + JAXBExtensionHelper.addExtensions(extReg, BindingOperation.class, + org.apache.schemas.yoko.bindings.corba.OperationType.class); + JAXBExtensionHelper.addExtensions(extReg, Definition.class, TypeMappingType.class); + JAXBExtensionHelper.addExtensions(extReg, Port.class, + org.apache.schemas.yoko.bindings.corba.AddressType.class); + + extReg.mapExtensionTypes(Binding.class, CorbaConstants.NE_CORBA_BINDING, BindingType.class); + extReg.mapExtensionTypes(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION, + org.apache.schemas.yoko.bindings.corba.OperationType.class); + extReg.mapExtensionTypes(Definition.class, CorbaConstants.NE_CORBA_TYPEMAPPING, + TypeMappingType.class); + extReg.mapExtensionTypes(Port.class, CorbaConstants.NE_CORBA_ADDRESS, + org.apache.schemas.yoko.bindings.corba.AddressType.class); + } + }