You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2003/08/30 22:59:17 UTC
cvs commit: incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable MuBooleanTest.java MuByteTest.java MuCharacterTest.java MuDoubleTest.java
jdillon 2003/08/30 13:59:17
Modified: modules/common/src/test/org/apache/geronimo/common
MockThrowableListener.java
ThrowableHandlerTest.java
modules/common/src/test/org/apache/geronimo/common/mutable
MuBooleanTest.java MuByteTest.java
MuCharacterTest.java MuDoubleTest.java
Log:
o cleansed sources
Revision Changes Path
1.2 +2 -2 incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/MockThrowableListener.java
Index: MockThrowableListener.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/MockThrowableListener.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MockThrowableListener.java 18 Aug 2003 16:54:41 -0000 1.1
+++ MockThrowableListener.java 30 Aug 2003 20:59:16 -0000 1.2
@@ -100,4 +100,4 @@
errorList.add(t);
}
}
-}
\ No newline at end of file
+}
1.2 +2 -2 incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/ThrowableHandlerTest.java
Index: ThrowableHandlerTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/ThrowableHandlerTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ThrowableHandlerTest.java 18 Aug 2003 16:54:41 -0000 1.1
+++ ThrowableHandlerTest.java 30 Aug 2003 20:59:16 -0000 1.2
@@ -127,4 +127,4 @@
super.tearDown();
}
-}
\ No newline at end of file
+}
1.2 +205 -205 incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuBooleanTest.java
Index: MuBooleanTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuBooleanTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MuBooleanTest.java 26 Aug 2003 08:53:51 -0000 1.1
+++ MuBooleanTest.java 30 Aug 2003 20:59:16 -0000 1.2
@@ -1,205 +1,205 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
- * "Apache Geronimo" 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",
- * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for {@link MuBoolean} class.
- *
- * @version $Revision$ $Date$
- */
-public class MuBooleanTest
- extends TestCase
-{
- public void testDefaultConstructor() {
- MuBoolean mutable = new MuBoolean();
- assertFalse(mutable.booleanValue());
- }
-
- public void testPrimativeConstructorTrue() {
- MuBoolean mutable = new MuBoolean(true);
- assertTrue(mutable.booleanValue());
- }
-
- public void testPrimativeConstructorFalse() {
- MuBoolean mutable = new MuBoolean(false);
- assertFalse(mutable.booleanValue());
- }
-
- public void testObjectConstructorNull() {
- MuBoolean mutable = new MuBoolean(null);
- assertFalse(mutable.booleanValue());
- }
-
- public void testObjectConstructorMuBoolean() {
- MuBoolean control = new MuBoolean(true);
- MuBoolean mutable = new MuBoolean(control);
- assertEquals(mutable.booleanValue(), control.booleanValue());
- }
-
- public void testObjectConstructorBoolean() {
- Boolean control = Boolean.TRUE;
- MuBoolean mutable = new MuBoolean(control);
- assertEquals(mutable.booleanValue(), control.booleanValue());
- }
-
- public void testObjectConstructorObject() {
- Object control = new byte[0];
- MuBoolean mutable = new MuBoolean(control);
- assertTrue(mutable.booleanValue());
- }
-
- public void testStringConstructor() {
- MuBoolean mutable = new MuBoolean("TRUE");
- assertTrue(mutable.booleanValue());
- }
-
- public void testSetPrimative() {
- MuBoolean first = new MuBoolean(false);
- assertFalse(first.booleanValue());
- boolean old = first.set(true);
- assertFalse(old);
- assertTrue(first.booleanValue());
- }
-
- public void testSetBoolean() {
- MuBoolean first = new MuBoolean(Boolean.FALSE);
- assertFalse(first.booleanValue());
- boolean old = first.set(Boolean.TRUE);
- assertFalse(old);
- assertTrue(first.booleanValue());
- }
-
- public void testSetMuBoolean() {
- MuBoolean first = new MuBoolean(new MuBoolean(false));
- assertFalse(first.booleanValue());
- boolean old = first.set(new MuBoolean(true));
- assertFalse(old);
- assertTrue(first.booleanValue());
- }
-
- public void testGet() {
- MuBoolean mutable = new MuBoolean(true);
- assertTrue(mutable.get());
- mutable.set(false);
- assertFalse(mutable.get());
- }
-
- public void testCommit() {
- MuBoolean mutable = new MuBoolean(true);
- boolean success = mutable.commit(false, true);
- assertFalse(success);
- assertTrue(mutable.booleanValue());
-
- success = mutable.commit(true, false);
- assertTrue(success);
- assertFalse(mutable.booleanValue());
- }
-
- public void testSwap() {
- MuBoolean t = new MuBoolean(true);
- MuBoolean f = new MuBoolean(false);
-
- boolean newT = t.swap(f);
- assertFalse(newT);
- assertFalse(t.booleanValue());
- assertTrue(f.booleanValue());
- }
-
- public void testComplement() {
- MuBoolean t = new MuBoolean(true);
- boolean c = t.complement();
- assertFalse(c);
- assertFalse(t.booleanValue());
- }
-
- public void testAnd() {
- MuBoolean t = new MuBoolean(true);
- boolean and = t.and(true);
- assertTrue(and);
- assertTrue(t.booleanValue());
-
- and = t.and(false);
- assertFalse(and);
- assertFalse(t.booleanValue());
- }
-
- public void testOr() {
- MuBoolean t = new MuBoolean(false);
-
- boolean or = t.or(false);
- assertFalse(or);
- assertFalse(t.booleanValue());
-
- or = t.or(true);
- assertTrue(or);
- assertTrue(t.booleanValue());
- }
-
- public void testXor() {
- MuBoolean t = new MuBoolean(false);
-
- boolean xor = t.xor(false);
- assertFalse(xor);
- assertFalse(t.booleanValue());
-
- xor = t.xor(true);
- assertTrue(xor);
- assertTrue(t.booleanValue());
- }
-}
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
+ * "Apache Geronimo" 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",
+ * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test for {@link MuBoolean} class.
+ *
+ * @version $Revision$ $Date$
+ */
+public class MuBooleanTest
+ extends TestCase
+{
+ public void testDefaultConstructor() {
+ MuBoolean mutable = new MuBoolean();
+ assertFalse(mutable.booleanValue());
+ }
+
+ public void testPrimativeConstructorTrue() {
+ MuBoolean mutable = new MuBoolean(true);
+ assertTrue(mutable.booleanValue());
+ }
+
+ public void testPrimativeConstructorFalse() {
+ MuBoolean mutable = new MuBoolean(false);
+ assertFalse(mutable.booleanValue());
+ }
+
+ public void testObjectConstructorNull() {
+ MuBoolean mutable = new MuBoolean(null);
+ assertFalse(mutable.booleanValue());
+ }
+
+ public void testObjectConstructorMuBoolean() {
+ MuBoolean control = new MuBoolean(true);
+ MuBoolean mutable = new MuBoolean(control);
+ assertEquals(mutable.booleanValue(), control.booleanValue());
+ }
+
+ public void testObjectConstructorBoolean() {
+ Boolean control = Boolean.TRUE;
+ MuBoolean mutable = new MuBoolean(control);
+ assertEquals(mutable.booleanValue(), control.booleanValue());
+ }
+
+ public void testObjectConstructorObject() {
+ Object control = new byte[0];
+ MuBoolean mutable = new MuBoolean(control);
+ assertTrue(mutable.booleanValue());
+ }
+
+ public void testStringConstructor() {
+ MuBoolean mutable = new MuBoolean("TRUE");
+ assertTrue(mutable.booleanValue());
+ }
+
+ public void testSetPrimative() {
+ MuBoolean first = new MuBoolean(false);
+ assertFalse(first.booleanValue());
+ boolean old = first.set(true);
+ assertFalse(old);
+ assertTrue(first.booleanValue());
+ }
+
+ public void testSetBoolean() {
+ MuBoolean first = new MuBoolean(Boolean.FALSE);
+ assertFalse(first.booleanValue());
+ boolean old = first.set(Boolean.TRUE);
+ assertFalse(old);
+ assertTrue(first.booleanValue());
+ }
+
+ public void testSetMuBoolean() {
+ MuBoolean first = new MuBoolean(new MuBoolean(false));
+ assertFalse(first.booleanValue());
+ boolean old = first.set(new MuBoolean(true));
+ assertFalse(old);
+ assertTrue(first.booleanValue());
+ }
+
+ public void testGet() {
+ MuBoolean mutable = new MuBoolean(true);
+ assertTrue(mutable.get());
+ mutable.set(false);
+ assertFalse(mutable.get());
+ }
+
+ public void testCommit() {
+ MuBoolean mutable = new MuBoolean(true);
+ boolean success = mutable.commit(false, true);
+ assertFalse(success);
+ assertTrue(mutable.booleanValue());
+
+ success = mutable.commit(true, false);
+ assertTrue(success);
+ assertFalse(mutable.booleanValue());
+ }
+
+ public void testSwap() {
+ MuBoolean t = new MuBoolean(true);
+ MuBoolean f = new MuBoolean(false);
+
+ boolean newT = t.swap(f);
+ assertFalse(newT);
+ assertFalse(t.booleanValue());
+ assertTrue(f.booleanValue());
+ }
+
+ public void testComplement() {
+ MuBoolean t = new MuBoolean(true);
+ boolean c = t.complement();
+ assertFalse(c);
+ assertFalse(t.booleanValue());
+ }
+
+ public void testAnd() {
+ MuBoolean t = new MuBoolean(true);
+ boolean and = t.and(true);
+ assertTrue(and);
+ assertTrue(t.booleanValue());
+
+ and = t.and(false);
+ assertFalse(and);
+ assertFalse(t.booleanValue());
+ }
+
+ public void testOr() {
+ MuBoolean t = new MuBoolean(false);
+
+ boolean or = t.or(false);
+ assertFalse(or);
+ assertFalse(t.booleanValue());
+
+ or = t.or(true);
+ assertTrue(or);
+ assertTrue(t.booleanValue());
+ }
+
+ public void testXor() {
+ MuBoolean t = new MuBoolean(false);
+
+ boolean xor = t.xor(false);
+ assertFalse(xor);
+ assertFalse(t.booleanValue());
+
+ xor = t.xor(true);
+ assertTrue(xor);
+ assertTrue(t.booleanValue());
+ }
+}
1.2 +205 -205 incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuByteTest.java
Index: MuByteTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuByteTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MuByteTest.java 27 Aug 2003 09:02:12 -0000 1.1
+++ MuByteTest.java 30 Aug 2003 20:59:16 -0000 1.2
@@ -1,205 +1,205 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
- * "Apache Geronimo" 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",
- * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for {@link MuByte} class.
- *
- * @version $Revision$ $Date$
- */
-public class MuByteTest
- extends TestCase
-{
- public void testDefaultConstructor() {
- MuByte muByte = new MuByte();
- assertEquals(0,muByte.get());
- }
-
- public void testPrimitiveConstructor() {
- byte b = 127;
- MuByte muByte = new MuByte(b);
- assertEquals(127,muByte.get());
- }
-
- public void testObjectConstructor() {
- Object obj = new Integer(10);
- MuByte muByte = new MuByte(obj);
- assertEquals(10,muByte.get());
- }
-
- public void testCommit() {
- byte b = 10;
- MuByte muByte = new MuByte(b);
-
- byte assumed = 10;
- byte newVal = 20;
- assertTrue(muByte.commit(assumed,newVal));
- assertFalse(muByte.commit(assumed,newVal));
- }
-
- public void testSwap() {
- MuByte six = new MuByte(new Integer(6));
- MuByte nine = new MuByte(new Integer(9));
-
- assertEquals(9,nine.swap(nine));
- assertEquals(9,six.swap(nine));
- assertEquals(9,six.get());
- }
-
- public void testIncDec() {
- MuByte muByte = new MuByte(new Integer(5));
-
- assertEquals(6,muByte.increment());
- assertEquals(6,muByte.get());
-
- assertEquals(5,muByte.decrement());
- assertEquals(5,muByte.get());
- }
-
- public void testPlusMinusMultiDivide() {
- byte val = 2;
- MuByte muByte = new MuByte(new Integer(9));
-
- assertEquals(11,muByte.add(val));
- assertEquals(11,muByte.get());
-
- assertEquals(9,muByte.subtract(val));
- assertEquals(9,muByte.get());
-
- assertEquals(18,muByte.multiply(val));
- assertEquals(18,muByte.get());
-
- assertEquals(9,muByte.divide(val));
- assertEquals(9,muByte.get());
- }
-
- public void testLogicalOperations() {
- byte value;
-
- MuByte muByte = new MuByte(new Integer(2));
-
- assertEquals(-2,muByte.negate());
- assertEquals(2,muByte.negate());
-
- assertEquals(-3,muByte.complement());
- assertEquals(2,muByte.complement());
-
- value = 7;
- assertEquals(2,muByte.and(value));
-
- value = 5;
- assertEquals(7,muByte.or(value));
-
- value = 3;
- assertEquals(4,muByte.xor(value));
- }
-
- public void testShift() {
- MuByte muByte = new MuByte(new Integer(2));
-
- assertEquals(8,muByte.shiftLeft(2));
- assertEquals(4,muByte.shiftRight(1));
- assertEquals(2,muByte.shiftRightZero(1));
- }
-
- public void testCompare() {
- byte equal = 2;
- byte greater = 3;
- byte lesser = 1;
- MuByte muByte = new MuByte(new Integer(2));
-
- assertEquals(0,muByte.compareTo(equal));
- assertTrue(muByte.compareTo(greater) < 0);
- assertTrue(muByte.compareTo(lesser) > 0);
-
- muByte.compareTo(muByte);
- }
-
- public void testEquals() {
- MuByte two = new MuByte(new Integer(2));
- MuByte due = new MuByte(new Integer(2));
- Integer integerTwo = new Integer(2);
-
- assertTrue(two.equals(due));
- assertTrue(two.equals(two));
- assertFalse(two.equals(integerTwo));
- }
-
- public void testMutable() {
- MuByte muByte = new MuByte(new Integer(2));
- muByte.setValue(new Integer(10));
- assertEquals(10,muByte.get());
-
- byte b = 10;
- Byte byteObj = new Byte(b);
- assertEquals(byteObj,muByte.getValue());
-
- byte max = 127;
- assertEquals(10,muByte.set(max));
- assertEquals(max,muByte.get());
- }
-
- public void testMisc() {
- MuByte muByte1 = new MuByte(new Integer(2));
- MuByte muByte2 = new MuByte(new Integer(2));
-
- assertEquals(new String("2"),muByte1.toString());
- assertEquals(muByte1.hashCode(),muByte2.hashCode());
- }
-}
\ No newline at end of file
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
+ * "Apache Geronimo" 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",
+ * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test for {@link MuByte} class.
+ *
+ * @version $Revision$ $Date$
+ */
+public class MuByteTest
+ extends TestCase
+{
+ public void testDefaultConstructor() {
+ MuByte muByte = new MuByte();
+ assertEquals(0,muByte.get());
+ }
+
+ public void testPrimitiveConstructor() {
+ byte b = 127;
+ MuByte muByte = new MuByte(b);
+ assertEquals(127,muByte.get());
+ }
+
+ public void testObjectConstructor() {
+ Object obj = new Integer(10);
+ MuByte muByte = new MuByte(obj);
+ assertEquals(10,muByte.get());
+ }
+
+ public void testCommit() {
+ byte b = 10;
+ MuByte muByte = new MuByte(b);
+
+ byte assumed = 10;
+ byte newVal = 20;
+ assertTrue(muByte.commit(assumed,newVal));
+ assertFalse(muByte.commit(assumed,newVal));
+ }
+
+ public void testSwap() {
+ MuByte six = new MuByte(new Integer(6));
+ MuByte nine = new MuByte(new Integer(9));
+
+ assertEquals(9,nine.swap(nine));
+ assertEquals(9,six.swap(nine));
+ assertEquals(9,six.get());
+ }
+
+ public void testIncDec() {
+ MuByte muByte = new MuByte(new Integer(5));
+
+ assertEquals(6,muByte.increment());
+ assertEquals(6,muByte.get());
+
+ assertEquals(5,muByte.decrement());
+ assertEquals(5,muByte.get());
+ }
+
+ public void testPlusMinusMultiDivide() {
+ byte val = 2;
+ MuByte muByte = new MuByte(new Integer(9));
+
+ assertEquals(11,muByte.add(val));
+ assertEquals(11,muByte.get());
+
+ assertEquals(9,muByte.subtract(val));
+ assertEquals(9,muByte.get());
+
+ assertEquals(18,muByte.multiply(val));
+ assertEquals(18,muByte.get());
+
+ assertEquals(9,muByte.divide(val));
+ assertEquals(9,muByte.get());
+ }
+
+ public void testLogicalOperations() {
+ byte value;
+
+ MuByte muByte = new MuByte(new Integer(2));
+
+ assertEquals(-2,muByte.negate());
+ assertEquals(2,muByte.negate());
+
+ assertEquals(-3,muByte.complement());
+ assertEquals(2,muByte.complement());
+
+ value = 7;
+ assertEquals(2,muByte.and(value));
+
+ value = 5;
+ assertEquals(7,muByte.or(value));
+
+ value = 3;
+ assertEquals(4,muByte.xor(value));
+ }
+
+ public void testShift() {
+ MuByte muByte = new MuByte(new Integer(2));
+
+ assertEquals(8,muByte.shiftLeft(2));
+ assertEquals(4,muByte.shiftRight(1));
+ assertEquals(2,muByte.shiftRightZero(1));
+ }
+
+ public void testCompare() {
+ byte equal = 2;
+ byte greater = 3;
+ byte lesser = 1;
+ MuByte muByte = new MuByte(new Integer(2));
+
+ assertEquals(0,muByte.compareTo(equal));
+ assertTrue(muByte.compareTo(greater) < 0);
+ assertTrue(muByte.compareTo(lesser) > 0);
+
+ muByte.compareTo(muByte);
+ }
+
+ public void testEquals() {
+ MuByte two = new MuByte(new Integer(2));
+ MuByte due = new MuByte(new Integer(2));
+ Integer integerTwo = new Integer(2);
+
+ assertTrue(two.equals(due));
+ assertTrue(two.equals(two));
+ assertFalse(two.equals(integerTwo));
+ }
+
+ public void testMutable() {
+ MuByte muByte = new MuByte(new Integer(2));
+ muByte.setValue(new Integer(10));
+ assertEquals(10,muByte.get());
+
+ byte b = 10;
+ Byte byteObj = new Byte(b);
+ assertEquals(byteObj,muByte.getValue());
+
+ byte max = 127;
+ assertEquals(10,muByte.set(max));
+ assertEquals(max,muByte.get());
+ }
+
+ public void testMisc() {
+ MuByte muByte1 = new MuByte(new Integer(2));
+ MuByte muByte2 = new MuByte(new Integer(2));
+
+ assertEquals(new String("2"),muByte1.toString());
+ assertEquals(muByte1.hashCode(),muByte2.hashCode());
+ }
+}
1.2 +150 -150 incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuCharacterTest.java
Index: MuCharacterTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuCharacterTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MuCharacterTest.java 30 Aug 2003 08:00:10 -0000 1.1
+++ MuCharacterTest.java 30 Aug 2003 20:59:16 -0000 1.2
@@ -1,150 +1,150 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
- * "Apache Geronimo" 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",
- * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
-
-import junit.framework.TestCase;
-import org.apache.geronimo.common.coerce.NotCoercibleException;
-
-/**
- * Unit test for {@link MuCharacter} class.
- *
- * @version $Revision$ $Date$
- */
-public class MuCharacterTest extends TestCase {
-
- public void testConstructors() {
- char c = 0;
-
- MuCharacter muCharacter = new MuCharacter();
- assertEquals(c,muCharacter.get());
-
- c = 'a';
- muCharacter = new MuCharacter(c);
- assertEquals(c,muCharacter.get());
-
- muCharacter = new MuCharacter(new Character(c));
- assertEquals(c,muCharacter.get());
- }
-
- public void testSetAndGet() {
- char oldChar = 'A';
- char newChar = 'Z';
-
- MuCharacter muCharacter = new MuCharacter(oldChar);
- assertEquals(oldChar,muCharacter.set(newChar));
- assertEquals(newChar,muCharacter.get());
- }
-
- public void testSetObject() {
- MuCharacter muCharacter = new MuCharacter();
-
- Character charObj = new Character('S');
- muCharacter.setValue(charObj);
- assertEquals(charObj,muCharacter.getValue());
-
- // $ = 36
- Integer integerObj = new Integer(36);
- muCharacter.setValue(integerObj);
- assertEquals(36,muCharacter.get());
- assertEquals(new Character('$'),muCharacter.getValue());
-
- muCharacter.setValue(new MuCharacter('C'));
- assertEquals(new Character('C'),muCharacter.getValue());
-
- try {
- muCharacter.setValue(new String("QWERTY"));
- fail("Expected NotCoercibleException");
- } catch (NotCoercibleException ignore) {
- }
- }
-
- public void testCompare() {
- char lesser = 'A';
- char equal = 'B';
- char greater = 'C';
-
- MuCharacter muCharacter = new MuCharacter(equal);
- assertTrue(muCharacter.compareTo(equal) == 0);
- assertTrue(muCharacter.compareTo(lesser) > 0);
- assertTrue(muCharacter.compareTo(greater) < 0 );
-
- assertTrue(muCharacter.compareTo(new MuCharacter(equal)) == 0);
- try {
- muCharacter.compareTo(new String());
- fail("Expected ClassCastException");
- } catch (ClassCastException ignore) {
- }
- }
-
- public void testEquals() {
- MuCharacter muCharacter = new MuCharacter('A');
- assertTrue(muCharacter.equals(muCharacter));
- assertTrue(muCharacter.equals(new MuCharacter('A')));
- assertFalse(muCharacter.equals(null));
- assertFalse(muCharacter.equals(new String()));
- }
-
- public void testMisc() {
- char c = 'A';
- MuCharacter muCharacter = new MuCharacter(c);
- assertEquals(c,muCharacter.charValue());
-
- assertEquals("A",muCharacter.toString());
-
- assertEquals(muCharacter.hashCode(),new MuCharacter(c).hashCode());
- }
-}
\ No newline at end of file
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
+ * "Apache Geronimo" 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",
+ * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.common.coerce.NotCoercibleException;
+
+/**
+ * Unit test for {@link MuCharacter} class.
+ *
+ * @version $Revision$ $Date$
+ */
+public class MuCharacterTest extends TestCase {
+
+ public void testConstructors() {
+ char c = 0;
+
+ MuCharacter muCharacter = new MuCharacter();
+ assertEquals(c,muCharacter.get());
+
+ c = 'a';
+ muCharacter = new MuCharacter(c);
+ assertEquals(c,muCharacter.get());
+
+ muCharacter = new MuCharacter(new Character(c));
+ assertEquals(c,muCharacter.get());
+ }
+
+ public void testSetAndGet() {
+ char oldChar = 'A';
+ char newChar = 'Z';
+
+ MuCharacter muCharacter = new MuCharacter(oldChar);
+ assertEquals(oldChar,muCharacter.set(newChar));
+ assertEquals(newChar,muCharacter.get());
+ }
+
+ public void testSetObject() {
+ MuCharacter muCharacter = new MuCharacter();
+
+ Character charObj = new Character('S');
+ muCharacter.setValue(charObj);
+ assertEquals(charObj,muCharacter.getValue());
+
+ // $ = 36
+ Integer integerObj = new Integer(36);
+ muCharacter.setValue(integerObj);
+ assertEquals(36,muCharacter.get());
+ assertEquals(new Character('$'),muCharacter.getValue());
+
+ muCharacter.setValue(new MuCharacter('C'));
+ assertEquals(new Character('C'),muCharacter.getValue());
+
+ try {
+ muCharacter.setValue(new String("QWERTY"));
+ fail("Expected NotCoercibleException");
+ } catch (NotCoercibleException ignore) {
+ }
+ }
+
+ public void testCompare() {
+ char lesser = 'A';
+ char equal = 'B';
+ char greater = 'C';
+
+ MuCharacter muCharacter = new MuCharacter(equal);
+ assertTrue(muCharacter.compareTo(equal) == 0);
+ assertTrue(muCharacter.compareTo(lesser) > 0);
+ assertTrue(muCharacter.compareTo(greater) < 0 );
+
+ assertTrue(muCharacter.compareTo(new MuCharacter(equal)) == 0);
+ try {
+ muCharacter.compareTo(new String());
+ fail("Expected ClassCastException");
+ } catch (ClassCastException ignore) {
+ }
+ }
+
+ public void testEquals() {
+ MuCharacter muCharacter = new MuCharacter('A');
+ assertTrue(muCharacter.equals(muCharacter));
+ assertTrue(muCharacter.equals(new MuCharacter('A')));
+ assertFalse(muCharacter.equals(null));
+ assertFalse(muCharacter.equals(new String()));
+ }
+
+ public void testMisc() {
+ char c = 'A';
+ MuCharacter muCharacter = new MuCharacter(c);
+ assertEquals(c,muCharacter.charValue());
+
+ assertEquals("A",muCharacter.toString());
+
+ assertEquals(muCharacter.hashCode(),new MuCharacter(c).hashCode());
+ }
+}
1.2 +179 -179 incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuDoubleTest.java
Index: MuDoubleTest.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/mutable/MuDoubleTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MuDoubleTest.java 30 Aug 2003 08:00:10 -0000 1.1
+++ MuDoubleTest.java 30 Aug 2003 20:59:16 -0000 1.2
@@ -1,179 +1,179 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
- * "Apache Geronimo" 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",
- * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
-
-import junit.framework.TestCase;
-import org.apache.geronimo.common.coerce.NotCoercibleException;
-
-/**
- * Unit test for {@link MuDouble} class.
- *
- * @version $Revision$ $Date$
- */
-public class MuDoubleTest extends TestCase {
-
- public void testConstructors() {
- double d = 10;
- MuDouble muDouble = new MuDouble();
- assertEquals(0, muDouble.get(), 0);
-
- muDouble = new MuDouble(d);
- assertEquals(d, muDouble.get(), 0);
-
- muDouble = new MuDouble(new Integer(10));
- assertEquals(10, muDouble.get(), 0);
- }
-
- public void testCommit() {
- double assumed = 10;
- double newVal = 20;
-
- MuDouble muDouble = new MuDouble(10);
- assertTrue(muDouble.commit(assumed, newVal));
- assertFalse(muDouble.commit(assumed, newVal));
- }
-
- public void testSwap() {
- MuDouble six = new MuDouble(6);
- MuDouble nine = new MuDouble(9);
-
- assertEquals(9, nine.swap(nine), 0);
- assertEquals(9, six.swap(nine), 0);
- assertEquals(9, six.get(), 0);
- }
-
- public void testPlusMinusMultiDivide() {
- MuDouble muDouble = new MuDouble(9);
- double val = 2;
-
- assertEquals(11, muDouble.add(val), 0);
- assertEquals(11, muDouble.get(), 0);
-
- assertEquals(9, muDouble.subtract(val), 0);
- assertEquals(9, muDouble.get(), 0);
-
- assertEquals(18, muDouble.multiply(val), 0);
- assertEquals(18, muDouble.get(), 0);
-
- assertEquals(9, muDouble.divide(val), 0);
- assertEquals(9, muDouble.get(), 0);
- }
-
- public void testNegate() {
- MuDouble muDouble = new MuDouble(9);
- assertEquals(-9, muDouble.negate(), 0);
- }
-
- public void testCompare() {
- double lesser = 1.2;
- double equal = 2.3;
- double greater = 3.4;
-
- MuDouble muDouble = new MuDouble(equal);
-
- assertTrue(muDouble.compareTo(equal) == 0);
- assertTrue(muDouble.compareTo(lesser) > 0);
- assertTrue(muDouble.compareTo(greater) < 0);
-
- assertTrue(muDouble.compareTo(new MuDouble(2.3)) == 0);
- assertTrue(muDouble.compareTo(new MuDouble(5.0)) < 0);
- assertTrue(muDouble.compareTo(new MuDouble(1.2)) > 0);
- try {
- muDouble.compareTo(new String());
- fail("Expected ClassCastException");
- } catch (ClassCastException e) {
- }
- }
-
- public void testEquals() {
- MuDouble muDouble = new MuDouble(5.0);
-
- assertTrue(muDouble.equals(muDouble));
- assertTrue(muDouble.equals(new MuDouble(5.0)));
- assertFalse(muDouble.equals(null));
- assertFalse(muDouble.equals(new String()));
- }
-
- public void testMisc() {
- MuDouble muDouble = new MuDouble(10);
-
- assertEquals("10.0", muDouble.toString());
- assertEquals(muDouble.hashCode(), (new MuDouble(10)).hashCode());
- }
-
- public void testSetObject() {
- MuDouble muDouble = new MuDouble();
-
- muDouble.setValue(new Integer(5));
- assertEquals(new Double(5), muDouble.getValue());
- assertEquals(5, muDouble.get(), 0);
-
- muDouble.setValue(new Double(5.5));
- assertEquals(new Double(5.5), muDouble.getValue());
- assertEquals(5.5, muDouble.get(), 0);
-
- muDouble = new MuDouble();
- muDouble.set(2.2);
- assertEquals(2.2, muDouble.get(), 0);
-
- try {
- muDouble.setValue(new String("5.5"));
- fail("Expected NotCoercibleException");
- } catch (NotCoercibleException ignore) {
- }
- }
-}
\ No newline at end of file
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 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 "Apache" and "Apache Software Foundation" and
+ * "Apache Geronimo" 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",
+ * "Apache Geronimo", 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 org.apache.geronimo.common.mutable;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.common.coerce.NotCoercibleException;
+
+/**
+ * Unit test for {@link MuDouble} class.
+ *
+ * @version $Revision$ $Date$
+ */
+public class MuDoubleTest extends TestCase {
+
+ public void testConstructors() {
+ double d = 10;
+ MuDouble muDouble = new MuDouble();
+ assertEquals(0, muDouble.get(), 0);
+
+ muDouble = new MuDouble(d);
+ assertEquals(d, muDouble.get(), 0);
+
+ muDouble = new MuDouble(new Integer(10));
+ assertEquals(10, muDouble.get(), 0);
+ }
+
+ public void testCommit() {
+ double assumed = 10;
+ double newVal = 20;
+
+ MuDouble muDouble = new MuDouble(10);
+ assertTrue(muDouble.commit(assumed, newVal));
+ assertFalse(muDouble.commit(assumed, newVal));
+ }
+
+ public void testSwap() {
+ MuDouble six = new MuDouble(6);
+ MuDouble nine = new MuDouble(9);
+
+ assertEquals(9, nine.swap(nine), 0);
+ assertEquals(9, six.swap(nine), 0);
+ assertEquals(9, six.get(), 0);
+ }
+
+ public void testPlusMinusMultiDivide() {
+ MuDouble muDouble = new MuDouble(9);
+ double val = 2;
+
+ assertEquals(11, muDouble.add(val), 0);
+ assertEquals(11, muDouble.get(), 0);
+
+ assertEquals(9, muDouble.subtract(val), 0);
+ assertEquals(9, muDouble.get(), 0);
+
+ assertEquals(18, muDouble.multiply(val), 0);
+ assertEquals(18, muDouble.get(), 0);
+
+ assertEquals(9, muDouble.divide(val), 0);
+ assertEquals(9, muDouble.get(), 0);
+ }
+
+ public void testNegate() {
+ MuDouble muDouble = new MuDouble(9);
+ assertEquals(-9, muDouble.negate(), 0);
+ }
+
+ public void testCompare() {
+ double lesser = 1.2;
+ double equal = 2.3;
+ double greater = 3.4;
+
+ MuDouble muDouble = new MuDouble(equal);
+
+ assertTrue(muDouble.compareTo(equal) == 0);
+ assertTrue(muDouble.compareTo(lesser) > 0);
+ assertTrue(muDouble.compareTo(greater) < 0);
+
+ assertTrue(muDouble.compareTo(new MuDouble(2.3)) == 0);
+ assertTrue(muDouble.compareTo(new MuDouble(5.0)) < 0);
+ assertTrue(muDouble.compareTo(new MuDouble(1.2)) > 0);
+ try {
+ muDouble.compareTo(new String());
+ fail("Expected ClassCastException");
+ } catch (ClassCastException e) {
+ }
+ }
+
+ public void testEquals() {
+ MuDouble muDouble = new MuDouble(5.0);
+
+ assertTrue(muDouble.equals(muDouble));
+ assertTrue(muDouble.equals(new MuDouble(5.0)));
+ assertFalse(muDouble.equals(null));
+ assertFalse(muDouble.equals(new String()));
+ }
+
+ public void testMisc() {
+ MuDouble muDouble = new MuDouble(10);
+
+ assertEquals("10.0", muDouble.toString());
+ assertEquals(muDouble.hashCode(), (new MuDouble(10)).hashCode());
+ }
+
+ public void testSetObject() {
+ MuDouble muDouble = new MuDouble();
+
+ muDouble.setValue(new Integer(5));
+ assertEquals(new Double(5), muDouble.getValue());
+ assertEquals(5, muDouble.get(), 0);
+
+ muDouble.setValue(new Double(5.5));
+ assertEquals(new Double(5.5), muDouble.getValue());
+ assertEquals(5.5, muDouble.get(), 0);
+
+ muDouble = new MuDouble();
+ muDouble.set(2.2);
+ assertEquals(2.2, muDouble.get(), 0);
+
+ try {
+ muDouble.setValue(new String("5.5"));
+ fail("Expected NotCoercibleException");
+ } catch (NotCoercibleException ignore) {
+ }
+ }
+}