|
From: <tri...@us...> - 2008-01-21 21:20:54
|
Revision: 261
http://equanda.svn.sourceforge.net/equanda/?rev=261&view=rev
Author: triathlon98
Date: 2008-01-21 13:20:49 -0800 (Mon, 21 Jan 2008)
Log Message:
-----------
EQ-53 extra tests
Modified Paths:
--------------
trunk/equanda-generate/src/main/java/org/equanda/domain/xml/CaseConversion.java
trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Choice.java
trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Type.java
trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValue.java
trunk/equanda-generate/src/test/java/org/equanda/domain/xml/CaseConversionTest.java
Added Paths:
-----------
trunk/equanda-generate/src/test/java/org/equanda/domain/xml/ChoiceTest.java
Removed Paths:
-------------
trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValueConverter.java
Modified: trunk/equanda-generate/src/main/java/org/equanda/domain/xml/CaseConversion.java
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/xml/CaseConversion.java 2008-01-20 19:26:48 UTC (rev 260)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/xml/CaseConversion.java 2008-01-21 21:20:49 UTC (rev 261)
@@ -26,9 +26,7 @@
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
-import com.thoughtworks.xstream.annotations.XStreamConverter;
import org.equanda.domain.xml.aid.CaseConversionValue;
-import org.equanda.domain.xml.aid.CaseConversionValueConverter;
/**
* case conversion tag
@@ -45,7 +43,8 @@
public CaseConversionValue getValue()
{
- if ( value == null ) return null;
+ if ( className != null ) return CaseConversionValue.CLASS;
+ if ( value == null ) return CaseConversionValue.MIXED;
return CaseConversionValue.valueOf( value.toUpperCase() );
}
@@ -56,13 +55,11 @@
public boolean isUpper()
{
- //return className == null && CaseConversionValue.UPPER.equals( value );
- return className == null && "UPPER".equals( value );
+ return className == null && "upper".equals( value );
}
public boolean isLower()
{
- //return className == null && CaseConversionValue.LOWER.equals( value );
- return className == null && "LOWER".equals( value );
+ return className == null && "lower".equals( value );
}
}
Modified: trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Choice.java
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Choice.java 2008-01-20 19:26:48 UTC (rev 260)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Choice.java 2008-01-21 21:20:49 UTC (rev 261)
@@ -76,9 +76,14 @@
public boolean hasDescription()
{
- return !description.equals( "" );
+ return description!=null && !"".equals( description );
}
+ public String getClassName()
+ {
+ return className;
+ }
+
/*
public void transform()
{
Modified: trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Type.java
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Type.java 2008-01-20 19:26:48 UTC (rev 260)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/xml/Type.java 2008-01-21 21:20:49 UTC (rev 261)
@@ -32,8 +32,6 @@
import java.util.List;
import org.equanda.domain.xml.aid.ImplicitBooleanConverter;
-import org.equanda.domain.xml.aid.CaseConversionValueConverter;
-import org.equanda.domain.xml.aid.CaseConversionValue;
/**
* Representation of a generic type which can be used as base field definition
Modified: trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValue.java
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValue.java 2008-01-20 19:26:48 UTC (rev 260)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValue.java 2008-01-21 21:20:49 UTC (rev 261)
@@ -31,10 +31,10 @@
*
* @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
*/
-@XStreamConverter( CaseConversionValueConverter.class )
public enum CaseConversionValue
{
UPPER,
LOWER,
MIXED,
+ CLASS,
}
Deleted: trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValueConverter.java
===================================================================
--- trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValueConverter.java 2008-01-20 19:26:48 UTC (rev 260)
+++ trunk/equanda-generate/src/main/java/org/equanda/domain/xml/aid/CaseConversionValueConverter.java 2008-01-21 21:20:49 UTC (rev 261)
@@ -1,63 +0,0 @@
-/**
- * This file is part of the equanda project.
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
- * ANY KIND, either express or implied. See the License for the specific language governing rights and
- * limitations under the License.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- */
-
-package org.equanda.domain.xml.aid;
-
-import com.thoughtworks.xstream.converters.Converter;
-import com.thoughtworks.xstream.converters.MarshallingContext;
-import com.thoughtworks.xstream.converters.UnmarshallingContext;
-import com.thoughtworks.xstream.io.HierarchicalStreamReader;
-import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
-
-/**
- * ...
- *
- * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
- */
-public class CaseConversionValueConverter
- implements Converter
-{
- public void marshal( Object source, HierarchicalStreamWriter writer,
- MarshallingContext context )
- {
- System.out.println( "---------- marshal" );
- CaseConversionValue value = (CaseConversionValue) source;
- writer.setValue( value.toString().toLowerCase() );
- }
-
- public Object unmarshal( HierarchicalStreamReader reader,
- UnmarshallingContext context )
- {
- System.out.println( "---------- unmarshal" );
- String value = reader.getValue();
- System.out.println( "xxxxxxxxxxxxxxxxxxx CaseConversionValueConverter value " + value );
- return CaseConversionValue.valueOf( value.toUpperCase() );
- }
-
- public boolean canConvert( Class type )
- {
- System.out.println( "zzzzzzzzzzzzzzzz test class "+type.getName()+" - "+type.equals( CaseConversionValue.class ) );
- return type.equals( CaseConversionValue.class );
- }
-}
Modified: trunk/equanda-generate/src/test/java/org/equanda/domain/xml/CaseConversionTest.java
===================================================================
--- trunk/equanda-generate/src/test/java/org/equanda/domain/xml/CaseConversionTest.java 2008-01-20 19:26:48 UTC (rev 260)
+++ trunk/equanda-generate/src/test/java/org/equanda/domain/xml/CaseConversionTest.java 2008-01-21 21:20:49 UTC (rev 261)
@@ -41,12 +41,11 @@
String test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!DOCTYPE equanda SYSTEM \"equanda.dtd\">\n" +
"\n" +
- "<case value=\"UPPER\"/>";
+ "<case value=\"upper\"/>";
XStream stream = getXStreamInstance();
Object res = stream.fromXML( test );
assertTrue( res instanceof CaseConversion );
CaseConversion caseConversion = (CaseConversion) res;
- //assertEquals( "UPPER", caseConversion.getValue() );
assertEquals( CaseConversionValue.UPPER, caseConversion.getValue() );
assertTrue( caseConversion.isUpper() );
assertFalse( caseConversion.isLower() );
@@ -64,7 +63,7 @@
Object res = stream.fromXML( test );
assertTrue( res instanceof CaseConversion );
CaseConversion caseConversion = (CaseConversion) res;
- assertNull( caseConversion.getValue() );
+ assertEquals( CaseConversionValue.CLASS, caseConversion.getValue() );
assertFalse( caseConversion.isUpper() );
assertFalse( caseConversion.isLower() );
assertEquals( "test.class", caseConversion.getClassName() );
Added: trunk/equanda-generate/src/test/java/org/equanda/domain/xml/ChoiceTest.java
===================================================================
--- trunk/equanda-generate/src/test/java/org/equanda/domain/xml/ChoiceTest.java (rev 0)
+++ trunk/equanda-generate/src/test/java/org/equanda/domain/xml/ChoiceTest.java 2008-01-21 21:20:49 UTC (rev 261)
@@ -0,0 +1,74 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (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.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.domain.xml;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * test for choice class
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class ChoiceTest
+ extends XStreamTestAdapter
+{
+ public void testParse1()
+ throws Exception
+ {
+ String test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<!DOCTYPE equanda SYSTEM \"equanda.dtd\">\n" +
+ "\n" +
+ "<choice className=\"my.choiceClass\"/>";
+ XStream stream = getXStreamInstance();
+ Object res = stream.fromXML( test );
+ assertTrue( res instanceof Choice );
+ Choice choice = (Choice) res;
+ assertEquals( "my.choiceClass", choice.getClassName() );
+ assertNull( choice.getName() );
+ assertNull( choice.getValue() );
+ assertNull( choice.getDescription() );
+ assertFalse( choice.hasDescription() );
+ }
+
+ public void testParse2()
+ throws Exception
+ {
+ String test = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<!DOCTYPE equanda SYSTEM \"equanda.dtd\">\n" +
+ "\n" +
+ "<choice name=\"KEY\" value=\"1234\">" +
+ " <description>choice description</description>" +
+ "</choice>";
+ XStream stream = getXStreamInstance();
+ Object res = stream.fromXML( test );
+ assertTrue( res instanceof Choice );
+ Choice choice = (Choice) res;
+ assertNull( choice.getClassName() );
+ assertEquals( "KEY", choice.getName() );
+ assertEquals( "1234", choice.getValue() );
+ assertEquals( "choice description", choice.getDescription() );
+ assertTrue( choice.hasDescription() );
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|