You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jv...@apache.org on 2002/06/01 03:40:19 UTC
cvs commit: jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab GlobalAttribute.java GlobalAttributeOption.java GlobalIssue.java Module.java ScarabSettings.java TestScarabSettings.java scarab-settings.xml
jvanzyl 2002/05/31 18:40:19
Modified: betwixt/src/test/org/apache/commons/betwixt/scarab
scarab-settings.xml
Added: betwixt/src/test/org/apache/commons/betwixt/scarab
GlobalAttribute.java GlobalAttributeOption.java
GlobalIssue.java Module.java ScarabSettings.java
TestScarabSettings.java
Log:
The start of a little test suite for mapping the scarab settings XML
file to an object model. Not quite working yet: the rules are being
constructed with Java variable naming conventions instead of the
hyphenated naming convention.
Revision Changes Path
1.2 +10 -2 jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/scarab-settings.xml
Index: scarab-settings.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/scarab-settings.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- scarab-settings.xml 31 May 2002 23:37:37 -0000 1.1
+++ scarab-settings.xml 1 Jun 2002 01:40:19 -0000 1.2
@@ -1,5 +1,9 @@
<?xml version="1.0" standalone="no"?>
+
+<!--
<!DOCTYPE scarab SYSTEM "/scarab/dtd/scarab-settings.dtd">
+-->
+
<scarab-settings>
<global-attribute>
@@ -21,7 +25,7 @@
<weight>1</weight>
<preferred-order>1</preferred-order>
</global-attribute-option>
- <global-attribute>
+ </global-attribute>
<global-issue-type>
<name>Defect</name>
@@ -34,7 +38,9 @@
<description>Improvement to an existing feature.</description>
<template>Enhancement Template</template>
</global-issue-type>
-
+
+ <modules>
+
<module>
<id>5</id>
<parent>1</parent>
@@ -46,4 +52,6 @@
<code>PACS</code>
</module>
+ </modules>
+
</scarab-settings>
1.1 jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/GlobalAttribute.java
Index: GlobalAttribute.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/GlobalAttribute.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
* $Revision: 1.1 $
* $Date: 2002/06/01 01:40:19 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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: GlobalAttribute.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
*/
package org.apache.commons.betwixt.scarab;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.IteratorEnumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <p>
*
* <code>CustomerBean</code> is a sample bean for use by the test cases.</p>
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class GlobalAttribute implements Serializable
{
/**
* Logger
*/
private final static Log log = LogFactory.getLog(GlobalAttribute.class);
private GlobalAttributeOption globalAttributeOption;
private String name;
/**
* Constructor for the ScarabSettings object
*/
public GlobalAttribute()
{
}
public void setGlobalAttributeOption(GlobalAttributeOption globalAttributeOption)
{
this.globalAttributeOption = globalAttributeOption;
}
public GlobalAttributeOption getGlobalAttributeOption()
{
return globalAttributeOption;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
1.1 jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/GlobalAttributeOption.java
Index: GlobalAttributeOption.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/GlobalAttributeOption.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
* $Revision: 1.1 $
* $Date: 2002/06/01 01:40:19 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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: GlobalAttributeOption.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
*/
package org.apache.commons.betwixt.scarab;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.IteratorEnumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <p>
*
* <code>CustomerBean</code> is a sample bean for use by the test cases.</p>
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class GlobalAttributeOption implements Serializable
{
private String name;
/**
* Constructor for the ScarabSettings object
*/
public GlobalAttributeOption()
{
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
1.1 jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/GlobalIssue.java
Index: GlobalIssue.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/GlobalIssue.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
* $Revision: 1.1 $
* $Date: 2002/06/01 01:40:19 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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: GlobalIssue.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
*/
package org.apache.commons.betwixt.scarab;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.IteratorEnumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <p>
*
* <code>CustomerBean</code> is a sample bean for use by the test cases.</p>
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class GlobalIssue implements Serializable
{
private String name;
/**
* Constructor for the ScarabSettings object
*/
public GlobalIssue()
{
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
1.1 jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/Module.java
Index: Module.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/Module.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
* $Revision: 1.1 $
* $Date: 2002/06/01 01:40:19 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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: Module.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
*/
package org.apache.commons.betwixt.scarab;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.IteratorEnumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <p>
*
* <code>CustomerBean</code> is a sample bean for use by the test cases.</p>
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class Module implements Serializable
{
private String name;
/**
* Constructor for the ScarabSettings object
*/
public Module()
{
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}
1.1 jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/ScarabSettings.java
Index: ScarabSettings.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/ScarabSettings.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
* $Revision: 1.1 $
* $Date: 2002/06/01 01:40:19 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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: ScarabSettings.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
*/
package org.apache.commons.betwixt.scarab;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.IteratorEnumeration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <p>
*
* <code>CustomerBean</code> is a sample bean for use by the test cases.</p>
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
* @version $Revision: 1.1 $
*/
public class ScarabSettings implements Serializable
{
/**
* Logger
*/
private final static Log log = LogFactory.getLog(ScarabSettings.class);
private List globalAttributes = new ArrayList();
private List modules = new ArrayList();
/**
* Constructor for the ScarabSettings object
*/
public ScarabSettings()
{
}
public List getGlobalAttributes()
{
return globalAttributes;
}
public void addGlobalAttribute(GlobalAttribute globalAttribute)
{
globalAttributes.add(globalAttribute);
}
public List getModules()
{
return modules;
}
public void addModule(Module module)
{
modules.add(module);
}
}
1.1 jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/TestScarabSettings.java
Index: TestScarabSettings.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/scarab/TestScarabSettings.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
* $Revision: 1.1 $
* $Date: 2002/06/01 01:40:19 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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: TestScarabSettings.java,v 1.1 2002/06/01 01:40:19 jvanzyl Exp $
*/
package org.apache.commons.betwixt.scarab;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.InputStream;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
import org.apache.commons.betwixt.AbstractTestCase;
import org.apache.commons.betwixt.XMLIntrospector;
import org.apache.commons.betwixt.io.BeanReader;
import org.apache.commons.betwixt.io.BeanWriter;
import org.apache.commons.betwixt.strategy.HyphenatedNameMapper;
import org.apache.maven.project.Dependency;
import org.apache.maven.project.Developer;
import org.apache.maven.project.Project;
/**
* Test harness which round trips a Scarab's settings xml file
*
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
* @version $Revision: 1.1 $
*/
public class TestScarabSettings extends AbstractTestCase
{
public static void main( String[] args ) {
TestRunner.run( suite() );
}
/**
* A unit test suite for JUnit
*/
public static Test suite()
{
return new TestSuite(TestScarabSettings.class);
}
/**
* Constructor for the TestScarabSettings object
*
* @param testName
*/
public TestScarabSettings(String testName)
{
super(testName);
}
/**
* Tests we can round trip from the XML -> bean -> XML -> bean. Ideally this
* method should test both Project objects are identical
*/
public void testRoundTrip()
throws Exception
{
BeanReader reader = createBeanReader();
ScarabSettings ss = (ScarabSettings) reader.parse(
new FileInputStream("src/test/org/apache/commons/betwixt/scarab/scarab-settings.xml"));
/*
// now lets output it to a buffer
StringWriter buffer = new StringWriter();
write(ss, buffer);
// create a new BeanReader
reader = createBeanReader();
// now lets try parse the output sing the BeanReader
String text = buffer.toString();
System.out.println(text);
ScarabSettings newScarabSettings = (ScarabSettings) reader.parse(new StringReader(text));
// managed to parse it again!
testScarabSettings(newScarabSettings);
*/
testScarabSettings(ss);
// #### should now test the old and new Project instances for equality.
}
// Implementation methods
//-------------------------------------------------------------------------
/**
* Description of the Method
*/
protected BeanReader createBeanReader()
throws Exception
{
BeanReader reader = new BeanReader();
reader.setXMLIntrospector(createXMLIntrospector());
reader.registerBeanClass(ScarabSettings.class);
return reader;
}
/**
* ### it would be really nice to move this somewhere shareable across Maven
* / Turbine projects. Maybe a static helper method - question is what to
* call it???
*/
protected XMLIntrospector createXMLIntrospector()
{
XMLIntrospector introspector = new XMLIntrospector();
// set elements for attributes to true
introspector.setAttributesForPrimitives(false);
// wrap collections in an XML element
//introspector.setWrapCollectionsInElement(true);
// turn bean elements into lower case
introspector.setNameMapper(new HyphenatedNameMapper());
return introspector;
}
/**
* Tests the value of the Project object that has just been parsed
*/
protected void testScarabSettings(ScarabSettings ss)
throws Exception
{
//List globalAttributes = ss.getGlobalAttributes();
//GlobalAttribute ga = (GlobalAttribute) globalAttributes.get(0);
//assertEquals("Description", ga.getName());
List modules = ss.getModules();
Module m = (Module) modules.get(0);
assertEquals("Source", m.getName());
}
/**
* Description of the Method
*/
protected void write(Object bean, Writer out)
throws Exception
{
BeanWriter writer = new BeanWriter(out);
writer.setXMLIntrospector(createXMLIntrospector());
writer.enablePrettyPrint();
writer.write(bean);
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>