rdonkin 2002/11/30 09:16:37
Modified: betwixt project.xml
betwixt/src/java/org/apache/commons/betwixt
XMLIntrospector.java
betwixt/src/test/org/apache/commons/betwixt/dotbetwixt
TestBeanToXml.java
Added: betwixt/src/test/org/apache/commons/betwixt/dotbetwixt
SimpleTestBean.betwixt SimpleTestBean.java
simpletestone.xml
Log:
Added xml creation test case
Revision Changes Path
1.17 +14 -1 jakarta-commons/betwixt/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/betwixt/project.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- project.xml 28 Oct 2002 21:13:34 -0000 1.16
+++ project.xml 30 Nov 2002 17:16:37 -0000 1.17
@@ -98,5 +98,18 @@
</dependency>
</dependencies>
-
+ <build>
+
+ <!-- T E S T R E S O U R C E S -->
+ <!-- Resources that are copied into the test-classes directory -->
+ <testResources>
+ <testResource>
+ <directory>${pom.build.unitTestSourceDirectory}</directory>
+ <includes>
+ <include>**/*.betwixt</include>
+ </includes>
+ </testResource>
+ </testResources>
+ </build>
+
</project>
1.12 +4 -0
jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
Index: XMLIntrospector.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XMLIntrospector.java 27 Nov 2002 22:19:12 -0000 1.11
+++ XMLIntrospector.java 30 Nov 2002 17:16:37 -0000 1.12
@@ -480,6 +480,10 @@
log.warn( "Caught exception trying to parse: " + name, e );
}
}
+
+ if ( log.isTraceEnabled() ) {
+ log.trace( "Could not find betwixt file " + name );
+ }
return null;
}
1.3 +29 -4
jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/TestBeanToXml.java
Index: TestBeanToXml.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/TestBeanToXml.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestBeanToXml.java 28 Oct 2002 21:13:34 -0000 1.2
+++ TestBeanToXml.java 30 Nov 2002 17:16:37 -0000 1.3
@@ -70,6 +70,7 @@
import org.apache.commons.betwixt.io.BeanWriter;
import org.apache.commons.logging.impl.SimpleLog;
+import org.apache.commons.logging.LogFactory;
/**
@@ -103,6 +104,30 @@
parseFile("src/test/org/apache/commons/betwixt/dotbetwixt/rbean-result.xml"));
}
+ public void testSimpleBean() throws Exception {
+ StringWriter out = new StringWriter();
+ out.write("<?xml version='1.0' encoding='UTF-8'?>");
+ SimpleLog log = new SimpleLog("LOG");
+ log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
+ BeanWriter writer = new BeanWriter(out);
+ writer.getXMLIntrospector().setLog(log);
+
+ writer.setWriteIDs(false);
+ SimpleTestBean bean = new
SimpleTestBean("alpha-value","beta-value","gamma-value");
+ writer.write(bean);
+ out.flush();
+ String xml = out.toString();
+
+ if (debug) {
+ System.out.println("************testSimpleBean************");
+ System.out.println(xml);
+ }
+
+ xmlAssertIsomorphicContent(
+
parseFile("src/test/org/apache/commons/betwixt/dotbetwixt/simpletestone.xml"),
+ parseString(xml));
+
+ }
public void testWriteRecursiveBean() throws Exception {
/*
1.1
jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/SimpleTestBean.betwixt
Index: SimpleTestBean.betwixt
===================================================================
<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
<element name='foo'>
<attribute name='version' value='1.0'/>
<element name='bar'>
<attribute name='attribute-one' value='value one'/>
<attribute name='attribute-two' value='value two'/>
<element name='pub' property='alpha'/>
</element>
<hide property='gamma'/>
<addDefaults/>
</element>
</info>
1.1
jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/SimpleTestBean.java
Index: SimpleTestBean.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/SimpleTestBean.java,v
1.1 2002/11/30 17:16:37 rdonkin Exp $
* $Revision: 1.1 $
* $Date: 2002/11/30 17:16:37 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* $Id: SimpleTestBean.java,v 1.1 2002/11/30 17:16:37 rdonkin Exp $
*/
package org.apache.commons.betwixt.dotbetwixt;
/**
* This is a simple bean used in testing id-attribute custom mapping.
*
* @author Robert Burrell Donkin
*/
public class SimpleTestBean {
//-------------------------- Attributes
private String alpha;
private String beta;
private String gamma;
//-------------------------- Constructors
public SimpleTestBean(String alpha, String beta, String gamma) {
setAlpha(alpha);
setBeta(beta);
setGamma(gamma);
}
//--------------------------- Properties
public String getAlpha() {
return alpha;
}
public void setAlpha(String alpha) {
this.alpha = alpha;
}
public String getBeta() {
return beta;
}
public void setBeta(String beta) {
this.beta = beta;
}
public String getGamma() {
return gamma;
}
public void setGamma(String gamma) {
this.gamma = gamma;
}
}
1.1
jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/dotbetwixt/simpletestone.xml
Index: simpletestone.xml
===================================================================
<?xml version='1.0' encoding='UTF-8'?>
<foo version="1.0">
<bar attribute-one="value one" attribute-two="value two">
<pub>alpha-value</pub>
</bar>
<beta>beta-value</beta>
</foo>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>