You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2004/02/18 00:11:25 UTC
cvs commit: jakarta-commons/betwixt/src/test/org/apache/commons/betwixt TestConversion.java
rdonkin 2004/02/17 15:11:25
Added: betwixt/src/test/org/apache/commons/betwixt
TestConversion.java
Log:
Altered default behaviour for object string conversions so that nulls and empty strings are no longer passed to convert utils for conversion.
Revision Changes Path
1.1 jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestConversion.java
Index: TestConversion.java
===================================================================
/*
* $Header: /home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestConversion.java,v 1.1 2004/02/17 23:11:25 rdonkin Exp $
* $Revision: 1.1 $
* $Date: 2004/02/17 23:11:25 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2004 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 acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "Apache", "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 Software Foundation.
*
* 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/>.
*
*/
package org.apache.commons.betwixt;
import junit.framework.TestCase;
import java.io.StringReader;
import org.apache.commons.betwixt.io.BeanReader;
/**
* Tests conversions.
* @author <a href='http://jakarta.apache.org/'>Jakarta Commons Team</a>
* @version $Revision: 1.1 $
*/
public class TestConversion extends TestCase{
public TestConversion(String name) {
super(name);
}
/**
* Betwixt does not (by default) try to convert nulls and empty strings
* @throws Exception
*/
public void testNullTimestampConversion() throws Exception {
String xml = "<?xml version='1.0'?>" +
"<EventBean>" +
"<type>WARNING</type>" +
"<start>2004-02-10 00:00:00.0</start>" +
"<end/>" +
"</EventBean>";
StringReader in = new StringReader(xml);
BeanReader reader = new BeanReader();
reader.registerBeanClass(EventBean.class);
EventBean bean = (EventBean) reader.parse(in);
assertNotNull("Parsing should work", bean);
assertEquals("Type property", "WARNING", bean.getType());
assertEquals("Start property", "2004-02-10 00:00:00.0", bean.getStart().toString());
assertNull("End property", bean.getEnd());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org