You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by to...@apache.org on 2002/08/16 22:28:53 UTC
cvs commit: xml-axis/java/test/encoding PackageTests.java TestDay.java TestDuration.java TestMonth.java TestMonthDay.java TestName.java TestNCName.java TestNMToken.java TestNormalizedString.java TestToken.java TestUnsignedByte.java TestUnsignedInt.java TestUnsignedLong.java TestUnsignedShort.java TestYear.java TestYearMonth.java
tomj 2002/08/16 13:28:52
Modified: java/test/encoding PackageTests.java
Added: java/test/types buildComponent.xml PackageTests.java
TestDay.java TestDuration.java TestMonth.java
TestMonthDay.java TestName.java TestNCName.java
TestNMToken.java TestNormalizedString.java
TestToken.java TestUnsignedByte.java
TestUnsignedInt.java TestUnsignedLong.java
TestUnsignedShort.java TestYear.java
TestYearMonth.java
Removed: java/test/encoding TestDay.java TestDuration.java
TestMonth.java TestMonthDay.java TestName.java
TestNCName.java TestNMToken.java
TestNormalizedString.java TestToken.java
TestUnsignedByte.java TestUnsignedInt.java
TestUnsignedLong.java TestUnsignedShort.java
TestYear.java TestYearMonth.java
Log:
Move unit tests for Axis schema types to its own package (types) and out of
encoding test suite.
NOTE: Added a buildComponent.xml, duplicated from the encoding directory.
Since there doesn't seem to be anything test specific in this file.
Revision Changes Path
1.1 xml-axis/java/test/types/buildComponent.xml
Index: buildComponent.xml
===================================================================
<?xml version="1.0" ?>
<!DOCTYPE project [
<!ENTITY properties SYSTEM "file:../../xmls/properties.xml">
<!ENTITY paths SYSTEM "file:../../xmls/path_refs.xml">
<!ENTITY taskdefs SYSTEM "file:../../xmls/taskdefs.xml">
<!ENTITY taskdefs_post_compile SYSTEM "file:../../xmls/taskdefs_post_compile.xml">
<!ENTITY targets SYSTEM "file:../../xmls/targets.xml">
]>
<!-- ===================================================================
==================================================================== -->
<project default="compile">
<property name="axis.home" location="../.." />
<property name="componentName" value="test/encoding" />
&properties;
&paths;
&taskdefs;
&taskdefs_post_compile;
&targets;
<target name="clean"/>
<target name="copy" depends="setenv">
<echo message="Compiling samples.echo"/>
<ant antfile="${axis.home}/samples/echo/buildComponent.xml"/>
</target>
<target name="compile" depends="copy">
<echo message="Compiling test.encoding.*"/>
<javac srcdir="${axis.home}" destdir="${build.dest}" debug="${debug}">
<classpath>
<path refid="classpath"/>
</classpath>
<include name="test/encoding/*.java"/>
</javac>
</target>
<target name="run" >
<antcall target="execute-Component" />
</target>
</project>
1.1 xml-axis/java/test/types/PackageTests.java
Index: PackageTests.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* test the axis specific type classes
*/
public class PackageTests extends TestCase
{
public PackageTests(String name)
{
super(name);
}
public static Test suite() throws Exception
{
TestSuite suite = new TestSuite();
suite.addTestSuite(TestNormalizedString.class);
suite.addTestSuite(TestToken.class);
suite.addTestSuite(TestUnsignedLong.class);
suite.addTestSuite(TestUnsignedInt.class);
suite.addTestSuite(TestUnsignedShort.class);
suite.addTestSuite(TestUnsignedByte.class);
suite.addTestSuite(TestYearMonth.class);
suite.addTestSuite(TestYear.class);
suite.addTestSuite(TestMonth.class);
suite.addTestSuite(TestMonthDay.class);
suite.addTestSuite(TestDay.class);
suite.addTestSuite(TestName.class);
suite.addTestSuite(TestNCName.class);
suite.addTestSuite(TestNMToken.class);
suite.addTestSuite(TestDuration.class);
return suite;
}
}
1.1 xml-axis/java/test/types/TestDay.java
Index: TestDay.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Day;
import java.text.NumberFormat;
/**
* Test validation of types.Day
*/
public class TestDay extends TestCase {
public TestDay(String name) {
super(name);
}
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int day, String tz) throws Exception {
Day oDay = null;
try {
oDay = new Day(day, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ day=" + String.valueOf(day) +
",tz=" + tz + "]. did not restrict bad value.", oDay);
}
private void runFailTest(String source) throws Exception {
Day oDay = null;
try {
oDay = new Day(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oDay);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int day, String tz) throws Exception {
Day oDay = null;
try {
oDay = new Day(day, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Day day not equal", day, oDay.getDay());
assertEquals("Day timezone not equal", tz, oDay.getTimezone());
}
private void runPassTest(String source) throws Exception {
Day oDay = null;
try {
oDay = new Day(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Day.toString() not equal", source, oDay.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
// test all days
for (int d=1; d < 32; d++) {
runPassTest(d, null);
}
}
public void testNormalString() throws Exception {
// test all 31 days
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int d=1; d < 13; d++) {
String s = "---" + nf.format(d);
runPassTest(s);
}
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("---01");
}
public void testNormalTimezone() throws Exception {
runPassTest("---01Z");
}
public void testNormalPositiveTimezone() throws Exception {
runPassTest("---11+05:00");
}
public void testNormalNegativeTimezone() throws Exception {
runPassTest("---11-11:00");
}
/**
* Test that badly formatted strings fail
*/
public void testBadString() throws Exception {
runFailTest("13Z");
runFailTest("-13");
runFailTest("--13");
runFailTest("xxx13");
runFailTest("garbage");
}
/**
* Test that a bad day fails
*/
public void testBadDay() throws Exception {
runFailTest(32, null);
}
public void testBadDayString() throws Exception {
runFailTest("---32");
}
public void testBadDayString2() throws Exception {
runFailTest("---1");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest( 31, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("---23+EDT");
}
}
1.1 xml-axis/java/test/types/TestDuration.java
Index: TestDuration.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Duration;
public class TestDuration extends TestCase
{
public TestDuration( String name )
{
super( name );
}
public void testDurations()
throws Exception
{
// invoke the web service as if it was a local java object
String[] durationStrings = new String[ 11 ];
durationStrings[ 0 ] = "P2Y3M8DT8H1M3.3S";
durationStrings[ 1 ] = "P2Y3M8DT8H1M3S";
durationStrings[ 2 ] = "PT8H1M3.3S";
durationStrings[ 3 ] = "P2Y3M8D";
durationStrings[ 4 ] = "P2YT8H";
durationStrings[ 5 ] = "P8DT3.3S";
durationStrings[ 6 ] = "P3MT1M";
durationStrings[ 7 ] = "PT0.3S";
durationStrings[ 8 ] = "P1M";
durationStrings[ 9 ] = "-P1M";
durationStrings[ 10 ] = "-P2Y3M8DT8H1M3.3S";
for( int i = 0; i < durationStrings.length; i++ )
{
String durationString = durationStrings[ i ];
Duration duration =
new Duration( durationString );
assertTrue( "Duration string \"" + durationString +
"\" not equal to returned: " + duration.toString(),
durationString.equals( duration.toString() ) );
}
}
}
1.1 xml-axis/java/test/types/TestMonth.java
Index: TestMonth.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Month;
import java.text.NumberFormat;
/**
* Test validation of types.Month
*/
public class TestMonth extends TestCase {
public TestMonth(String name) {
super(name);
}
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int month, String tz) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(month, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ month=" + String.valueOf(month) +
",tz=" + tz + "]. did not restrict bad value.", oMonth);
}
private void runFailTest(String source) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oMonth);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int month, String tz) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(month, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Month month not equal", month, oMonth.getMonth());
assertEquals("Month timezone not equal", tz, oMonth.getTimezone());
}
private void runPassTest(String source) throws Exception {
Month oMonth = null;
try {
oMonth = new Month(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Month.toString() not equal", source, oMonth.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
// test all twelve months
for (int m=1; m < 13; m++) {
runPassTest(m, null);
}
}
public void testNormalString() throws Exception {
// test all twelve months
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int m=1; m < 13; m++) {
String s = "--" + nf.format(m) + "--";
runPassTest(s);
}
}
public void testNormalTimezone() throws Exception {
runPassTest("--01--Z");
}
public void testNormalPositiveTimezone() throws Exception {
runPassTest("--11--+05:00");
}
public void testNormalNegativeTimezone() throws Exception {
runPassTest("--11---11:00");
}
/**
* Test that badly formatted strings fail
*/
public void testBadString() throws Exception {
runFailTest("11--");
runFailTest("-11--");
runFailTest("--11-");
runFailTest("--11");
runFailTest("xx07-13");
runFailTest("garbage");
}
/**
* Test that a bad month fails
*/
public void testBadMonth() throws Exception {
runFailTest(13, null);
}
public void testBadMonthString() throws Exception {
runFailTest("--13--");
}
public void testBadMonthString2() throws Exception {
runFailTest("--1--");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(7, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("--07--+EDT");
}
}
1.1 xml-axis/java/test/types/TestMonthDay.java
Index: TestMonthDay.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.MonthDay;
import java.text.NumberFormat;
/**
* Test validation of types.MonthDay
*/
public class TestMonthDay extends TestCase {
public TestMonthDay(String name) {
super(name);
}
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int month, int day, String tz) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(month, day, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ month=" +
String.valueOf(month) + ",day=" + String.valueOf(day) +
",tz=" + tz + "]. did not restrict bad value.", oMonthDay);
}
private void runFailTest(String source) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oMonthDay);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int month, int day, String tz) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(month, day, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("MonthDay month not equal", month, oMonthDay.getMonth());
assertEquals("MonthDay day not equal", day, oMonthDay.getDay());
assertEquals("MonthDay timezone not equal", tz, oMonthDay.getTimezone());
}
private void runPassTest(String source) throws Exception {
MonthDay oMonthDay = null;
try {
oMonthDay = new MonthDay(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("MonthDay.toString() not equal", source, oMonthDay.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
// test all twelve months (1/1, 2/2, etc)
for (int m=1; m < 13; m++) {
runPassTest(m, m, null);
}
}
public void testNormalString() throws Exception {
// test all twelve months
// use NumberFormat to ensure leading zeros
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumIntegerDigits(2);
for (int m=1; m < 13; m++) {
String s = "--" + nf.format(m) + "-05";
runPassTest(s);
}
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("--01-01");
}
public void testNormalTimezone() throws Exception {
runPassTest("--01-01Z");
}
public void testNormalPositiveTimezone() throws Exception {
runPassTest("--02-11+05:00");
}
public void testNormalNegativeTimezone() throws Exception {
runPassTest("--03-11-11:00");
}
/**
* Test that badly formatted strings fail
*/
public void testBadString() throws Exception {
runFailTest("07-13Z");
runFailTest("-07-13");
runFailTest("xx07-13");
runFailTest("garbage");
}
/**
* Test that a bad month fails
*/
public void testBadMonth() throws Exception {
runFailTest(13, 20, null);
}
public void testBadMonthString() throws Exception {
runFailTest("--13-13");
}
public void testBadMonthString2() throws Exception {
runFailTest("--1-01");
}
/**
* Test that a bad day fails
*/
public void testBadDay() throws Exception {
runFailTest(1, 32, null);
}
public void testBadDayString() throws Exception {
runFailTest("--08-32");
}
public void testBadDayString2() throws Exception {
runFailTest("--1-01");
}
public void testEndOfMonthDays() throws Exception {
runFailTest(1, 32, null);
runPassTest(1, 31, null);
runFailTest(2, 30, null);
runPassTest(2, 29, null);
runFailTest(3, 32, null);
runPassTest(3, 31, null);
runFailTest(4, 31, null);
runPassTest(4, 30, null);
runFailTest(5, 32, null);
runPassTest(5, 30, null);
runFailTest(6, 31, null);
runPassTest(6, 30, null);
runFailTest(7, 32, null);
runPassTest(7, 31, null);
runFailTest(8, 32, null);
runPassTest(8, 31, null);
runFailTest(9, 31, null);
runPassTest(9, 30, null);
runFailTest(10, 32, null);
runPassTest(10, 31, null);
runFailTest(11, 31, null);
runPassTest(11, 30, null);
runFailTest(12, 32, null);
runPassTest(12, 31, null);
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(12, 31, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("--07-23+EDT");
}
}
1.1 xml-axis/java/test/types/TestName.java
Index: TestName.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Name;
/**
* Test validation of types.Name
*/
public class TestName extends TestCase {
public TestName(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
Name oToken = null;
try {
oToken = new Name(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"Name validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
Name oToken = null;
try {
oToken = new Name(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("Name strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("Atlanta");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testPunctuationString() throws Exception {
runPassTest("Atlanta:_Braves.Home-Team10");
}
/**
* Test a start character ':'
*/
public void testStartColon() throws Exception {
runPassTest(":_Braves.Home-Team:1");
}
/**
* Test a start character '_'
*/
public void testStartUnderscore() throws Exception {
runPassTest("_Braves.Home-Team:1");
}
/**
* Test a start Digit
*/
public void testStartDigit() throws Exception {
runFailTest("1_Braves");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
1.1 xml-axis/java/test/types/TestNCName.java
Index: TestNCName.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NCName;
/**
* Test validation of types.NCName
*/
public class TestNCName extends TestCase {
public TestNCName(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NCName oToken = null;
try {
oToken = new NCName(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"NCName validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NCName oToken = null;
try {
oToken = new NCName(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("NCName strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("Atlanta");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testPunctuationString() throws Exception {
runPassTest("Atlanta_Braves.Home-Team10");
}
/**
* Test a start character '_'
*/
public void testStartUnderscore() throws Exception {
runPassTest("_Braves");
}
/**
* Test a simple string with allowed punctuation.
*/
public void testMidColon() throws Exception {
runFailTest("Atlanta:_Braves.Home-Team10");
}
/**
* Test a start Digit
*/
public void testStartDigit() throws Exception {
runFailTest("1_Braves");
}
/**
* Test a start character ':'
*/
public void testStartColon() throws Exception {
runFailTest(":_Braves.Home-Team:1");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
1.1 xml-axis/java/test/types/TestNMToken.java
Index: TestNMToken.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NMToken;
/**
* Test validation of types.NMToken
*/
public class TestNMToken extends TestCase {
public TestNMToken(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NMToken oToken = null;
try {
oToken = new NMToken(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"NMToken validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NMToken oToken = null;
try {
oToken = new NMToken(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("NMToken strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("Atlanta1234567890");
}
/**
* Test a simple string.
*/
public void testPunctuationString() throws Exception {
runPassTest("Atlanta.-_:");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
1.1 xml-axis/java/test/types/TestNormalizedString.java
Index: TestNormalizedString.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.NormalizedString;
/**
* Test validation of encoding.NormalizedString
*/
public class TestNormalizedString extends TestCase {
public TestNormalizedString(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
NormalizedString oNormalizedString = null;
try {
oNormalizedString = new NormalizedString(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
value + "]. did not restrict bad value.", oNormalizedString);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
NormalizedString oNormalizedString = null;
try {
oNormalizedString = new NormalizedString(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("normalized string not equal" +
value, oNormalizedString.toString(), value);
}
/**
* Test that "a simple string" succeeds.
*/
public void testNsSimpleString() throws Exception {
runPassTest("a simple string");
}
/**
* Test that "this has \r carriage return" fails.
*/
public void testNsCarriageReturn() throws Exception {
runFailTest("this has \r carriage return");
}
/**
* Test that "this has \n line feed" fails.
*/
public void testNsLineFeed() throws Exception {
runFailTest("this has \n line feed");
}
/**
* Test that "this has \t a tab" fails.
*/
public void testNsStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* differentiate from xsd:token
*/
public void testNsStringWithLeadingSpaces() throws Exception {
runPassTest(" a failure case");
}
/*
* differentiate from xsd:token
*/
public void testNsStringWithTrailingSpaces() throws Exception {
runPassTest("this is a ");
}
/*
* differentiate from xsd:token
*/
public void testNsStringWithLeadingAndTrailingSpaces() throws Exception {
runPassTest(" centered ");
}
/*
* differentiate from xsd:token
*/
public void testNsDoubleSpace() throws Exception {
runPassTest("a B"); // note: \r fails
}
}
1.1 xml-axis/java/test/types/TestToken.java
Index: TestToken.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Token;
/**
* Test validation of encoding.Token
*/
public class TestToken extends TestCase {
public TestToken(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(String value) throws Exception {
Token oToken = null;
try {
oToken = new Token(value);
}
catch (Exception e) { // catch the validation exception
}
assertNull(
"Token validation restriction failed. did not restrict bad value [" +
value + "] did not restrict bad value", oToken);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(String value) throws Exception {
Token oToken = null;
try {
oToken = new Token(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("Token strings not equal. orig value:" + value, oToken.toString(), value);
}
/**
* Test a simple string.
*/
public void testSimpleString() throws Exception {
runPassTest("a simple string");
}
/**
* this is to differentiate from normalized string which cannot accept a CR
*/
public void testCarriageString() throws Exception {
runPassTest("a carriage return\r string\r");
}
/**
* this is to differentiate from normalized string which cannot accept a \n
*/
public void testLineFeed() throws Exception {
runFailTest("line one\n line two");
}
/**
* this is to differentiate from normalized string which cannot accept a \t
*/
public void testStringWithTabs() throws Exception {
runFailTest("this has \t a tab");
}
/**
* this is to differentiate from normalized string which cannot accept leading spaces.
*/
public void testStringWithLeadingSpaces() throws Exception {
runFailTest(" a failure case");
}
/**
* this is to differentiate from normalized string which cannot accept trailing spaces.
*/
public void testStringWithTrailingSpaces() throws Exception {
runFailTest("this is a ");
}
/**
* this is to differentiate from normalized string which cannot accept
* leading and trailing spaces.
*/
public void testStringWithLeadingAndTrailingSpaces() throws Exception {
runFailTest(" centered ");
}
/**
* this is to differentiate from normalized string which cannot accept double spaces.
*/
public void testDoubleSpace() throws Exception {
runFailTest("a B"); // note: \r fails
}
}
1.1 xml-axis/java/test/types/TestUnsignedByte.java
Index: TestUnsignedByte.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedByte;
/**
* Test validation of types.UnsignedByte
*/
public class TestUnsignedByte extends TestCase {
public TestUnsignedByte(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(long value) throws Exception {
UnsignedByte oUnsignedByte = null;
try {
oUnsignedByte = new UnsignedByte(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.", oUnsignedByte);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(long value) throws Exception {
UnsignedByte oUnsignedByte = null;
try {
oUnsignedByte = new UnsignedByte(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned byte not equal" +
String.valueOf(value), oUnsignedByte.toString(), String.valueOf(value));
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(100);
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(-100);
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest(255);
}
/**
* Test that a number over MaxInclusive fails
*/
public void testMaxOver() throws Exception {
runFailTest(256);
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(0L);
}
}
1.1 xml-axis/java/test/types/TestUnsignedInt.java
Index: TestUnsignedInt.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedInt;
/**
* Test validation of types.UnsignedInt
*/
public class TestUnsignedInt extends TestCase {
public TestUnsignedInt(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(long value) throws Exception {
UnsignedInt oUnsignedInt = null;
try {
oUnsignedInt = new UnsignedInt(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.", oUnsignedInt);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(long value) throws Exception {
UnsignedInt oUnsignedInt = null;
try {
oUnsignedInt = new UnsignedInt(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned int not equal" +
String.valueOf(value), oUnsignedInt.toString(), String.valueOf(value));
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(100);
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(-100);
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest(4294967295L);
}
/**
* Test that a number over MaxInclusive fails
*/
public void testMaxOver() throws Exception {
runFailTest(4294967296L);
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(0L);
}
}
1.1 xml-axis/java/test/types/TestUnsignedLong.java
Index: TestUnsignedLong.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedLong;
/**
* Test validation of types.UnsignedLong
*/
public class TestUnsignedLong extends TestCase {
public TestUnsignedLong(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(double value) throws Exception {
UnsignedLong oUnsignedLong = null;
try {
oUnsignedLong = new UnsignedLong(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.", oUnsignedLong);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(double value) throws Exception {
UnsignedLong oUnsignedLong = null;
try {
oUnsignedLong = new UnsignedLong(value);
}
catch (Exception e) { // catch the validation exception
}
String stRetval = String.valueOf(value); // contains .0
stRetval = stRetval.substring(0,stRetval.lastIndexOf('.'));
assertEquals("unsigned long not equal" +
String.valueOf(value), oUnsignedLong.toString(),stRetval);
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(100);
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(-100);
}
/**
* Test that a number over MaxInclusive fails
*/
public void testMaxInclusive() throws Exception {
runPassTest(18446744073709551615D);
}
/**
* Test that a number at MaxInclusive succeeds
*/
// public void testMaxOver() throws Exception {
// actual MaxOver should be 18446744073709551615D
// but we are running into a precision issue
// runFailTest(18446744073709551616D);
// }
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(0L);
}
}
1.1 xml-axis/java/test/types/TestUnsignedShort.java
Index: TestUnsignedShort.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.UnsignedShort;
/**
* Test validation of types.UnsignedShort
*/
public class TestUnsignedShort extends TestCase {
public TestUnsignedShort(String name) {
super(name);
}
/**
* Run a failure test. value should be invalid.
*/
private void runFailTest(long value) throws Exception {
UnsignedShort oUnsignedShort = null;
try {
oUnsignedShort = new UnsignedShort(value);
}
catch (Exception e) { // catch the validation exception
}
// object is not iNstantiated on bad data value
assertNull("validation restriction failed [" +
String.valueOf(value) + "]. did not restrict bad value.", oUnsignedShort);
}
/**
* Run a successful test. value should be valid.
*/
private void runPassTest(long value) throws Exception {
UnsignedShort oUnsignedShort = null;
try {
oUnsignedShort = new UnsignedShort(value);
}
catch (Exception e) { // catch the validation exception
}
assertEquals("unsigned short not equal" +
String.valueOf(value), oUnsignedShort.toString(), String.valueOf(value));
}
/**
* Test that a positive value succeeeds
*/
public void testPositiveValue() throws Exception {
runPassTest(100);
}
/**
* Test that a negative number fails
*/
public void testNegativeValue() throws Exception {
runFailTest(-100);
}
/**
* Test that a number at MaxInclusive succeeds
*/
public void testMaxInclusive() throws Exception {
runPassTest(65535);
}
/**
* Test that a number over MaxInclusive fails
*/
public void testMaxOver() throws Exception {
runFailTest(65536);
}
/**
* Test that a number at MinInclusive succeeds
*/
public void testMinExclusive() throws Exception {
runPassTest(0L);
}
}
1.1 xml-axis/java/test/types/TestYear.java
Index: TestYear.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.Year;
/**
* Test validation of types.Year
*/
public class TestYear extends TestCase {
public TestYear(String name) {
super(name);
}
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int year, String tz) throws Exception {
Year oYear = null;
try {
oYear = new Year(year, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ year=" +
String.valueOf(year) +
",tz=" + tz + "]. did not restrict bad value.", oYear);
}
private void runFailTest(String source) throws Exception {
Year oYear = null;
try {
oYear = new Year(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oYear);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int year, String tz) throws Exception {
Year oYear = null;
try {
oYear = new Year(year, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", true);
}
assertEquals("Year year not equal", year, oYear.getYear());
assertEquals("Year timezone not equal", tz, oYear.getTimezone());
}
private void runPassTest(String source) throws Exception {
Year oYear = null;
try {
oYear = new Year(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("Year.toString() not equal", source, oYear.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
runPassTest(2002, null);
}
public void testNormalString() throws Exception {
runPassTest("9999");
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("0001Z");
}
public void testNegativeYear() throws Exception {
runPassTest(-1955, null);
}
public void testNegativeYearString() throws Exception {
runPassTest("-1955+05:00");
}
public void testNegativeYearString2() throws Exception {
// negative year with leading zeros
runPassTest("-0055+05:00");
}
public void testBigYear() throws Exception {
// Big year should be allowed (per Schema, not ISO).
runPassTest(12000, null);
}
public void testBigYearString() throws Exception {
runPassTest("-27000+05:00");
}
/**
* Test that a bad year fails
* Schema says the year can have any number of digits
*/
public void testBadYear() throws Exception {
runFailTest(0, null);
}
public void testBadYearString() throws Exception {
runFailTest("0000");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(1966, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("1966+EDT");
}
/**
* Test that a year at MaxInclusive succeeds
*/
public void testMaxYear() throws Exception {
runPassTest(9999, null);
}
}
1.1 xml-axis/java/test/types/TestYearMonth.java
Index: TestYearMonth.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 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 acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" 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 name, 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 test.types;
import junit.framework.TestCase;
import org.apache.axis.types.YearMonth;
/**
* Test validation of types.YearMonth
*/
public class TestYearMonth extends TestCase {
public TestYearMonth(String name) {
super(name);
}
/**
* Run a failure test. values should be invalid.
*/
private void runFailTest(int year, int month, String tz) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(year, month, tz);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ year=" +
String.valueOf(year) + ",month=" + String.valueOf(month) +
",tz=" + tz + "]. did not restrict bad value.", oYearMonth);
}
private void runFailTest(String source) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(source);
}
catch (Exception e) { // catch the validation exception
}
// object is not instantiated on bad data value
assertNull("validation restriction failed [ " + source +
"]. did not restrict bad value.", oYearMonth);
}
/**
* Run a successful test. values should be valid.
*/
private void runPassTest(int year, int month, String tz) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(year, month, tz);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("YearMonth year not equal", year, oYearMonth.getYear());
assertEquals("YearMonth month not equal", month, oYearMonth.getMonth());
assertEquals("YearMonth timezone not equal", tz, oYearMonth.getTimezone());
}
private void runPassTest(String source) throws Exception {
YearMonth oYearMonth = null;
try {
oYearMonth = new YearMonth(source);
}
catch (Exception e) { // catch the validation exception
assertTrue("Validation exception thrown on valid input", false);
}
assertEquals("YearMonth.toString() not equal", source, oYearMonth.toString());
}
/**
* Test that a normal date succeeeds
*/
public void testNormal() throws Exception {
runPassTest(2002, 8, null);
}
public void testNormalString() throws Exception {
runPassTest("9999-12");
}
public void testNormalString2() throws Exception {
// check for leading zeros in toString().
runPassTest("0001-01Z");
}
public void testNegativeYear() throws Exception {
runPassTest(-1955, 4, null);
}
public void testNegativeYearString() throws Exception {
runPassTest("-1955-04+05:00");
}
public void testNegativeYearString2() throws Exception {
// negative year with leading zeros
runPassTest("-0055-04+05:00");
}
public void testBigYear() throws Exception {
// Big year should be allowed (per Schema, not ISO).
runPassTest(12000, 4, null);
}
public void testBigYearString() throws Exception {
runPassTest("-27000-04+05:00");
}
/**
* Test that a bad year fails
* Schema says the year can have any number of digits
*/
public void testBadYear() throws Exception {
runFailTest(0, 7, null);
}
public void testBadYearString() throws Exception {
runFailTest("0000-7");
}
/**
* Test that a bad month fails
*/
public void testBadMonth() throws Exception {
runFailTest(1999, 13, null);
}
public void testBadMonthString() throws Exception {
runFailTest("1999-13");
}
/**
* Test that a bad timezone fails
*/
public void testBadTimezone() throws Exception {
runFailTest(1966, 7, "badzone");
}
public void testBadTimezoneString() throws Exception {
runFailTest("1966-07+EDT");
}
/**
* Test that a year at MaxInclusive succeeds
*/
public void testMaxYear() throws Exception {
runPassTest(9999, 1, null);
}
}
1.23 +1 -0 xml-axis/java/test/encoding/PackageTests.java
Index: PackageTests.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/encoding/PackageTests.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- PackageTests.java 13 Aug 2002 06:03:28 -0000 1.22
+++ PackageTests.java 16 Aug 2002 20:28:52 -0000 1.23
@@ -51,6 +51,7 @@
suite.addTestSuite(TestName.class);
suite.addTestSuite(TestNCName.class);
suite.addTestSuite(TestNMToken.class);
+ suite.addTestSuite(TestDuration.class);
return suite;
}
}