Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 68079 invoked from network); 12 Jun 2005 20:35:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Jun 2005 20:35:53 -0000 Received: (qmail 74605 invoked by uid 500); 12 Jun 2005 20:35:50 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 74493 invoked by uid 500); 12 Jun 2005 20:35:49 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 74479 invoked by uid 500); 12 Jun 2005 20:35:49 -0000 Received: (qmail 74474 invoked by uid 99); 12 Jun 2005 20:35:49 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 12 Jun 2005 13:35:48 -0700 Received: (qmail 68071 invoked by uid 65534); 12 Jun 2005 20:35:46 -0000 Message-ID: <20050612203546.68070.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r190316 - /jakarta/commons/proper/betwixt/branches/RELEASE_0_6_1_BRANCH/src/test/org/apache/commons/betwixt/schema/TestSchemaGeneration.java Date: Sun, 12 Jun 2005 20:35:46 -0000 To: commons-cvs@jakarta.apache.org From: rdonkin@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: rdonkin Date: Sun Jun 12 13:35:45 2005 New Revision: 190316 URL: http://svn.apache.org/viewcvs?rev=3D190316&view=3Drev Log: Improved consistency across JVMs. Modified: jakarta/commons/proper/betwixt/branches/RELEASE_0_6_1_BRANCH/src/test/o= rg/apache/commons/betwixt/schema/TestSchemaGeneration.java Modified: jakarta/commons/proper/betwixt/branches/RELEASE_0_6_1_BRANCH/src/= test/org/apache/commons/betwixt/schema/TestSchemaGeneration.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/branches/= RELEASE_0_6_1_BRANCH/src/test/org/apache/commons/betwixt/schema/TestSchemaG= eneration.java?rev=3D190316&r1=3D190315&r2=3D190316&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- jakarta/commons/proper/betwixt/branches/RELEASE_0_6_1_BRANCH/src/test/o= rg/apache/commons/betwixt/schema/TestSchemaGeneration.java (original) +++ jakarta/commons/proper/betwixt/branches/RELEASE_0_6_1_BRANCH/src/test/o= rg/apache/commons/betwixt/schema/TestSchemaGeneration.java Sun Jun 12 13:35= :45 2005 @@ -17,6 +17,9 @@ =20 package org.apache.commons.betwixt.schema; =20 +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; import java.io.StringWriter; =20 import org.apache.commons.betwixt.AbstractTestCase; @@ -130,83 +133,188 @@ =20 String xsd =3D out.getBuffer().toString(); =20 - String expected =3D"" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - ""; + // different JVMs may return different orders during reflection + StringBuffer buffer =3D new StringBuffer("<= xsd:schema xmlns:xsd=3D'http://www.w3.org/2001/XMLSchema'>" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""); + =20 + PropertyDescriptor[] propertyDescriptors =3D Introspector.getBeanI= nfo(ProductBean.class).getPropertyDescriptors(); + for (int i=3D0; i"); + } + else if ("code".equals(propertyDescriptor.getName())) + { + buffer.append(""); + } + else if ("displayName".equals(propertyDescriptor.getName())) + { + buffer.append(""); + } + else if ("name".equals(propertyDescriptor.getName())) + { + buffer.append(""); + } + } + buffer.append("" + + ""); + =20 + String expected =3D buffer.toString(); =20 - =20 xmlAssertIsomorphicContent(parseString(expected), parseString(xsd)= , true); } =20 public void testOrder() throws Exception { SchemaTranscriber transcriber =3D new SchemaTranscriber(); - transcriber.getXMLIntrospector().getConfiguration().setElementName= Mapper(new HyphenatedNameMapper()); - transcriber.getXMLIntrospector().getConfiguration().setAttributeNa= meMapper(new HyphenatedNameMapper()); - transcriber.getXMLIntrospector().getConfiguration().setAttributesF= orPrimitives(true); - transcriber.getXMLIntrospector().getConfiguration().setWrapCollect= ionsInElement(false); + transcriber.getXMLIntrospector().getConfiguration() + .setElementNameMapper(new HyphenatedNameMapper()); + transcriber.getXMLIntrospector().getConfiguration() + .setAttributeNameMapper(new HyphenatedNameMapper()); + transcriber.getXMLIntrospector().getConfiguration() + .setAttributesForPrimitives(true); + transcriber.getXMLIntrospector().getConfiguration() + .setWrapCollectionsInElement(false); Schema schema =3D transcriber.generate(OrderBean.class); - =20 + StringWriter out =3D new StringWriter(); out.write(""); BeanWriter writer =3D new BeanWriter(out); - writer.setBindingConfiguration(transcriber.createSchemaBindingConf= iguration()); - writer.getXMLIntrospector().setConfiguration(transcriber.createSch= emaIntrospectionConfiguration()); + writer.setBindingConfiguration(transcriber + .createSchemaBindingConfiguration()); + writer.getXMLIntrospector().setConfiguration( + transcriber.createSchemaIntrospectionConfiguration()); writer.write(schema); - =20 + String xsd =3D out.getBuffer().toString(); + + PropertyDescriptor[] propertyDescriptors =3D Introspector.getBeanI= nfo( + OrderBean.class).getPropertyDescriptors(); + boolean linesFirst =3D false; + for (int i =3D 0; i < propertyDescriptors.length; i++) { + PropertyDescriptor propertyDescriptor =3D propertyDescriptors[= i]; + if ("lines".equals(propertyDescriptor.getName())) { + linesFirst =3D true; + break; + } else if ("customer".equals(propertyDescriptor.getName())) { + linesFirst =3D false; + break; + } + } + =20 - String expected =3D "" + - "" + - "" + - "" + - " " + - " " + - " " + - " " + - " " + - "" + - "" + - "" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - "" + - "" + - "" + - " " + - " " + - " " + - " " + - "" + - "" + - "" + - " " + - " " + - " " + - " " + - " " + - " " + - "" + - ""; - =20 + StringBuffer buffer =3D new StringBuffer( + "" + + "" + + "" + + "" + + " "); + + if (linesFirst) { + buffer.append(" "); + buffer.append(" "); + } else { + buffer.append(" "); + buffer.append(" "); + } + + buffer.append(" " + + " " + + "" + + ""); + =20 + if (linesFirst) { + writeExpectedOrderLineBeanType(buffer); + writeExpectedCustomerBeanType(buffer); =20 + } else { + writeExpectedCustomerBeanType(buffer); =20 + writeExpectedOrderLineBeanType(buffer); + } + =20 + buffer.append(""); + + String expected =3D buffer.toString(); + xmlAssertIsomorphicContent(parseString(xsd), parseString(expected= ), true); + } + + /** + * @param buffer + * @throws IntrospectionException + */ + private void writeExpectedOrderLineBeanType(StringBuffer buffer) throw= s IntrospectionException { + PropertyDescriptor[] propertyDescriptors; + buffer.append("" + + " " + + " " + + " " + + " " + + "" + + "" + + "" + + " "); + + propertyDescriptors =3D Introspector.getBeanInfo(ProductBean.class) + .getPropertyDescriptors(); + for (int i =3D 0; i < propertyDescriptors.length; i++) { + PropertyDescriptor propertyDescriptor =3D propertyDescriptors[= i]; + if ("barcode".equals(propertyDescriptor.getName())) { + buffer + .append(""); + } else if ("code".equals(propertyDescriptor.getName())) { + buffer.append(""); + } else if ("displayName".equals(propertyDescriptor.getName()))= { + buffer + .append(""); + } else if ("name".equals(propertyDescriptor.getName())) { + buffer.append(""); + } + } + buffer.append(" "); + } + + /** + * @param buffer + * @throws IntrospectionException + */ + private void writeExpectedCustomerBeanType(StringBuffer buffer) throws= IntrospectionException { + PropertyDescriptor[] propertyDescriptors; + buffer.append("" + + " "); + + propertyDescriptors =3D Introspector.getBeanInfo(CustomerBean.clas= s) + .getPropertyDescriptors(); + for (int i =3D 0; i < propertyDescriptors.length; i++) { + PropertyDescriptor propertyDescriptor =3D propertyDescriptors[= i]; + if ("code".equals(propertyDescriptor.getName())) { + buffer.append(""); + } else if ("country".equals(propertyDescriptor.getName())) { + buffer + .append(""); + } else if ("name".equals(propertyDescriptor.getName())) { + buffer.append(""); + } else if ("postcode".equals(propertyDescriptor.getName())) { + buffer + .append(""); + } else if ("street".equals(propertyDescriptor.getName())) { + buffer + .append(""); + } else if ("town".equals(propertyDescriptor.getName())) { + buffer.append(""); + } + } + + buffer.append("" + + ""); } =20 } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org