diff options
author | bvosburgh | 2009-10-28 17:45:38 +0000 |
---|---|---|
committer | bvosburgh | 2009-10-28 17:45:38 +0000 |
commit | d2c36502c6df4de986267e4ce52baac8434af3bf (patch) | |
tree | 0f643d47a7c84a329737d3ef32ef65c71b2ce303 /jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests | |
parent | a6494b973790a93d715c967aaba4445165959394 (diff) | |
download | webtools.dali-d2c36502c6df4de986267e4ce52baac8434af3bf.tar.gz webtools.dali-d2c36502c6df4de986267e4ce52baac8434af3bf.tar.xz webtools.dali-d2c36502c6df4de986267e4ce52baac8434af3bf.zip |
rework "reference" classes
Diffstat (limited to 'jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests')
8 files changed, 756 insertions, 176 deletions
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanHolderTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanHolderTests.java deleted file mode 100644 index 106eae1a86..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanHolderTests.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.utility.tests.internal; - -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.BooleanHolder; - -public class BooleanHolderTests extends TestCase { - - public BooleanHolderTests(String name) { - super(name); - } - - public void testGetValue() { - BooleanHolder bh = new BooleanHolder(true); - assertTrue(bh.getValue()); - } - - public void testIsTrue() { - BooleanHolder bh = new BooleanHolder(true); - assertTrue(bh.isTrue()); - } - - public void testIsFalse() { - BooleanHolder bh = new BooleanHolder(true); - assertFalse(bh.isFalse()); - } - - public void testIs() { - BooleanHolder bh = new BooleanHolder(true); - assertTrue(bh.is(true)); - assertFalse(bh.is(false)); - } - - public void testSetValue() { - BooleanHolder bh = new BooleanHolder(true); - assertTrue(bh.getValue()); - bh.setValue(false); - assertFalse(bh.getValue()); - } - - public void testSetTrue() { - BooleanHolder bh = new BooleanHolder(false); - assertFalse(bh.getValue()); - bh.setTrue(); - assertTrue(bh.getValue()); - } - - - public void testSetFalse() { - BooleanHolder bh = new BooleanHolder(true); - assertTrue(bh.getValue()); - bh.setFalse(); - assertFalse(bh.getValue()); - } - - public void testClone() { - BooleanHolder bh = new BooleanHolder(true); - BooleanHolder clone = (BooleanHolder) bh.clone(); - assertTrue(clone.getValue()); - assertEquals(bh, clone); - } - - public void testEquals() { - BooleanHolder bh1 = new BooleanHolder(true); - BooleanHolder bh2 = new BooleanHolder(true); - assertEquals(bh1, bh2); - - BooleanHolder bh3 = new BooleanHolder(false); - assertFalse(bh1.equals(bh3)); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanReferenceTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanReferenceTests.java new file mode 100644 index 0000000000..e3380865ef --- /dev/null +++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BooleanReferenceTests.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.utility.tests.internal; + +import junit.framework.TestCase; +import org.eclipse.jpt.utility.internal.BooleanReference; + +@SuppressWarnings("nls") +public class BooleanReferenceTests extends TestCase { + + public BooleanReferenceTests(String name) { + super(name); + } + + public void testGetValue() { + BooleanReference br = new BooleanReference(true); + assertTrue(br.getValue()); + } + + public void testGetValueDefault() { + BooleanReference br = new BooleanReference(); + assertFalse(br.getValue()); + } + + public void testIs() { + BooleanReference br = new BooleanReference(true); + assertTrue(br.is(true)); + assertFalse(br.is(false)); + } + + public void testIsNot() { + BooleanReference br = new BooleanReference(true); + assertFalse(br.isNot(true)); + assertTrue(br.isNot(false)); + } + + public void testIsTrue() { + BooleanReference br = new BooleanReference(true); + assertTrue(br.isTrue()); + } + + public void testIsFalse() { + BooleanReference br = new BooleanReference(true); + assertFalse(br.isFalse()); + br.setFalse(); + assertTrue(br.isFalse()); + } + + public void testSetValue() { + BooleanReference br = new BooleanReference(true); + assertTrue(br.getValue()); + br.setValue(false); + assertFalse(br.getValue()); + } + + public void testFlip() { + BooleanReference br = new BooleanReference(true); + assertTrue(br.getValue()); + assertFalse(br.flip()); + assertFalse(br.getValue()); + assertTrue(br.flip()); + assertTrue(br.getValue()); + } + + public void testSetNotBoolean() { + BooleanReference br = new BooleanReference(false); + assertFalse(br.getValue()); + br.setNot(true); + assertFalse(br.getValue()); + br.setNot(true); + assertFalse(br.getValue()); + br.setNot(false); + assertTrue(br.getValue()); + } + + public void testSetTrue() { + BooleanReference br = new BooleanReference(false); + assertFalse(br.getValue()); + br.setTrue(); + assertTrue(br.getValue()); + } + + public void testSetFalse() { + BooleanReference br = new BooleanReference(true); + assertTrue(br.getValue()); + br.setFalse(); + assertFalse(br.getValue()); + } + + public void testClone() { + BooleanReference br = new BooleanReference(true); + BooleanReference clone = (BooleanReference) br.clone(); + assertTrue(clone.getValue()); + assertEquals(br, clone); + } + + public void testEquals() { + BooleanReference br1 = new BooleanReference(true); + BooleanReference br2 = new BooleanReference(true); + assertEquals(br1, br2); + + BooleanReference br3 = new BooleanReference(false); + assertFalse(br1.equals(br3)); + } + + public void testHashCode() { + BooleanReference br1 = new BooleanReference(true); + assertEquals(1, br1.hashCode()); + br1.setFalse(); + assertEquals(0, br1.hashCode()); + } + + public void testToString() { + BooleanReference br1 = new BooleanReference(true); + assertEquals("[true]", br1.toString()); + br1.setFalse(); + assertEquals("[false]", br1.toString()); + } + +} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CounterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CounterTests.java deleted file mode 100644 index 9953e0ecf8..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CounterTests.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.utility.tests.internal; - -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.Counter; - -public class CounterTests extends TestCase { - - public CounterTests(String name) { - super(name); - } - - public void testCtors() { - Counter counter; - counter = new Counter(); - assertEquals(0, counter.count()); - counter = new Counter(7); - assertEquals(7, counter.count()); - counter = new Counter(-7); - assertEquals(-7, counter.count()); - } - - public void testIncrement() { - Counter counter; - int count; - counter = new Counter(); - assertEquals(0, counter.count()); - - count = counter.increment(3); - assertEquals(3, count); - assertEquals(3, counter.count()); - - count = counter.increment(); - assertEquals(4, count); - assertEquals(4, counter.count()); - - count = counter.increment(-7); - assertEquals(-3, count); - assertEquals(-3, counter.count()); - } - - public void testDecrement() { - Counter counter; - int count; - counter = new Counter(); - assertEquals(0, counter.count()); - - count = counter.decrement(3); - assertEquals(-3, count); - assertEquals(-3, counter.count()); - - count = counter.decrement(); - assertEquals(-4, count); - assertEquals(-4, counter.count()); - - count = counter.decrement(-7); - assertEquals(3, count); - assertEquals(3, counter.count()); - } - - public void testClone() { - Counter counter = new Counter(44); - Counter counter2 = (Counter) counter.clone(); - assertEquals(44, counter2.count()); - assertEquals(counter, counter2); - assertNotSame(counter, counter2); - } - - public void testEquals() { - Counter counter = new Counter(44); - Counter counter2 = new Counter(44); - assertEquals(counter, counter2); - assertEquals(counter.hashCode(), counter2.hashCode()); - } - - public void testSerialization() throws Exception { - Counter counter = new Counter(44); - Counter counter2 = TestTools.serialize(counter); - assertEquals(44, counter2.count()); - assertEquals(counter, counter2); - assertNotSame(counter, counter2); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IntReferenceTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IntReferenceTests.java new file mode 100644 index 0000000000..56de376335 --- /dev/null +++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IntReferenceTests.java @@ -0,0 +1,340 @@ +/******************************************************************************* + * Copyright (c) 2007 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.utility.tests.internal; + +import junit.framework.TestCase; +import org.eclipse.jpt.utility.internal.IntReference; + +@SuppressWarnings("nls") +public class IntReferenceTests extends TestCase { + + public IntReferenceTests(String name) { + super(name); + } + + public void testCtors() { + IntReference ir; + ir = new IntReference(); + assertEquals(0, ir.getValue()); + ir = new IntReference(7); + assertEquals(7, ir.getValue()); + ir = new IntReference(-7); + assertEquals(-7, ir.getValue()); + } + + public void testEqualsInt() { + IntReference ir; + ir = new IntReference(); + assertTrue(ir.equals(0)); + assertFalse(ir.equals(7)); + + ir = new IntReference(7); + assertTrue(ir.equals(7)); + assertFalse(ir.equals(0)); + } + + public void testNotEqualsInt() { + IntReference ir; + ir = new IntReference(); + assertFalse(ir.notEquals(0)); + assertTrue(ir.notEquals(7)); + + ir = new IntReference(7); + assertFalse(ir.notEquals(7)); + assertTrue(ir.notEquals(0)); + } + + public void testIsZero() { + IntReference ir; + ir = new IntReference(); + assertTrue(ir.isZero()); + + ir = new IntReference(7); + assertFalse(ir.isZero()); + } + + public void testIsNotZero() { + IntReference ir; + ir = new IntReference(); + assertFalse(ir.isNotZero()); + + ir = new IntReference(7); + assertTrue(ir.isNotZero()); + } + + public void testIsGreaterThanInt() { + IntReference ir; + ir = new IntReference(); + assertTrue(ir.isGreaterThan(-1)); + assertFalse(ir.isGreaterThan(0)); + assertFalse(ir.isGreaterThan(7)); + } + + public void testIsGreaterThanOrEqualInt() { + IntReference ir; + ir = new IntReference(); + assertTrue(ir.isGreaterThanOrEqual(-1)); + assertTrue(ir.isGreaterThanOrEqual(0)); + assertFalse(ir.isGreaterThanOrEqual(7)); + } + + public void testIsLessThanInt() { + IntReference ir; + ir = new IntReference(); + assertFalse(ir.isLessThan(-1)); + assertFalse(ir.isLessThan(0)); + assertTrue(ir.isLessThan(7)); + } + + public void testIsLessThanOrEqualInt() { + IntReference ir; + ir = new IntReference(); + assertFalse(ir.isLessThanOrEqual(-1)); + assertTrue(ir.isLessThanOrEqual(0)); + assertTrue(ir.isLessThanOrEqual(7)); + } + + public void testIsPositive() { + IntReference ir; + ir = new IntReference(-3); + assertFalse(ir.isPositive()); + + ir = new IntReference(); + assertFalse(ir.isPositive()); + + ir = new IntReference(7); + assertTrue(ir.isPositive()); + } + + public void testIsNotPositive() { + IntReference ir; + ir = new IntReference(-3); + assertTrue(ir.isNotPositive()); + + ir = new IntReference(); + assertTrue(ir.isNotPositive()); + + ir = new IntReference(7); + assertFalse(ir.isNotPositive()); + } + + public void testIsNegative() { + IntReference ir; + ir = new IntReference(-3); + assertTrue(ir.isNegative()); + + ir = new IntReference(); + assertFalse(ir.isNegative()); + + ir = new IntReference(7); + assertFalse(ir.isNegative()); + } + + public void testIsNotNegative() { + IntReference ir; + ir = new IntReference(-3); + assertFalse(ir.isNotNegative()); + + ir = new IntReference(); + assertTrue(ir.isNotNegative()); + + ir = new IntReference(7); + assertTrue(ir.isNotNegative()); + } + + public void testSetValueInt() { + IntReference ir; + ir = new IntReference(-3); + assertEquals(-3, ir.getValue()); + assertEquals(-3, ir.setValue(4)); + assertEquals(4, ir.getValue()); + } + + public void testAbs() { + IntReference ir; + ir = new IntReference(-3); + assertEquals(-3, ir.getValue()); + assertEquals(3, ir.abs()); + assertEquals(3, ir.getValue()); + + ir.setValue(3); + assertEquals(3, ir.getValue()); + assertEquals(3, ir.abs()); + assertEquals(3, ir.getValue()); + } + + public void testNeg() { + IntReference ir; + ir = new IntReference(-3); + assertEquals(-3, ir.getValue()); + assertEquals(3, ir.neg()); + assertEquals(3, ir.getValue()); + + ir.setValue(3); + assertEquals(3, ir.getValue()); + assertEquals(-3, ir.neg()); + assertEquals(-3, ir.getValue()); + } + + public void testSetZero() { + IntReference ir; + ir = new IntReference(-3); + assertEquals(-3, ir.getValue()); + assertEquals(-3, ir.setZero()); + assertEquals(0, ir.getValue()); + } + + public void testAddInt() { + IntReference ir; + int value; + ir = new IntReference(); + assertEquals(0, ir.getValue()); + + value = ir.add(3); + assertEquals(3, value); + assertEquals(3, ir.getValue()); + + value = ir.add(-7); + assertEquals(-4, value); + assertEquals(-4, ir.getValue()); + } + + public void testIncrement() { + IntReference ir; + int value; + ir = new IntReference(); + assertEquals(0, ir.getValue()); + + value = ir.increment(); + assertEquals(1, value); + assertEquals(1, ir.getValue()); + } + + public void testSubtractInt() { + IntReference ir; + int count; + ir = new IntReference(); + assertEquals(0, ir.getValue()); + + count = ir.subtract(3); + assertEquals(-3, count); + assertEquals(-3, ir.getValue()); + + count = ir.subtract(-7); + assertEquals(4, count); + assertEquals(4, ir.getValue()); + } + + public void testDecrement() { + IntReference ir; + int count; + ir = new IntReference(); + assertEquals(0, ir.getValue()); + + count = ir.decrement(); + assertEquals(-1, count); + assertEquals(-1, ir.getValue()); + } + + public void testMultiplyInt() { + IntReference ir; + ir = new IntReference(3); + assertEquals(3, ir.getValue()); + assertEquals(9, ir.multiply(3)); + assertEquals(9, ir.getValue()); + } + + public void testDivideInt() { + IntReference ir; + ir = new IntReference(24); + assertEquals(24, ir.getValue()); + assertEquals(8, ir.divide(3)); + assertEquals(8, ir.getValue()); + } + + public void testRemainderInt() { + IntReference ir; + ir = new IntReference(25); + assertEquals(25, ir.getValue()); + assertEquals(1, ir.remainder(3)); + assertEquals(1, ir.getValue()); + } + + public void testMinInt() { + IntReference ir; + ir = new IntReference(25); + assertEquals(25, ir.getValue()); + assertEquals(3, ir.min(3)); + assertEquals(3, ir.getValue()); + assertEquals(3, ir.min(25)); + assertEquals(3, ir.getValue()); + } + + public void testMaxInt() { + IntReference ir; + ir = new IntReference(25); + assertEquals(25, ir.getValue()); + assertEquals(25, ir.max(3)); + assertEquals(25, ir.getValue()); + assertEquals(30, ir.max(30)); + assertEquals(30, ir.getValue()); + } + + public void testPowInt() { + IntReference ir; + ir = new IntReference(5); + assertEquals(5, ir.getValue()); + assertEquals(25, ir.pow(2)); + assertEquals(25, ir.getValue()); + assertEquals(625, ir.pow(2)); + assertEquals(625, ir.getValue()); + } + + public void testCompareToIntReference() { + IntReference ir1 = new IntReference(44); + IntReference ir2 = new IntReference(44); + assertTrue(ir1.compareTo(ir2) == 0); + ir2 = new IntReference(55); + assertTrue(ir1.compareTo(ir2) < 0); + ir2 = new IntReference(33); + assertTrue(ir1.compareTo(ir2) > 0); + } + + public void testClone() { + IntReference ir1 = new IntReference(44); + IntReference ir2 = (IntReference) ir1.clone(); + assertEquals(44, ir2.getValue()); + assertEquals(ir1, ir2); + assertNotSame(ir1, ir2); + } + + public void testEquals() { + IntReference ir1 = new IntReference(44); + IntReference ir2 = new IntReference(44); + assertEquals(ir1, ir2); + assertEquals(ir1.hashCode(), ir2.hashCode()); + assertFalse(ir1.equals(null)); + } + + public void testSerialization() throws Exception { + IntReference ir1 = new IntReference(44); + IntReference ir2 = TestTools.serialize(ir1); + assertEquals(44, ir2.getValue()); + assertEquals(ir1, ir2); + assertNotSame(ir1, ir2); + } + + public void testToString() { + IntReference ir; + ir = new IntReference(5); + assertEquals("[5]", ir.toString()); + } + +} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java index 46da66fd25..355afc09a0 100644 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java +++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java @@ -36,33 +36,36 @@ public class JptUtilityTests { suite.addTestSuite(ArrayToolsTests.class); suite.addTestSuite(BitToolsTests.class); - suite.addTestSuite(BooleanHolderTests.class); + suite.addTestSuite(BooleanReferenceTests.class); suite.addTestSuite(BooleanToolsTests.class); suite.addTestSuite(ClasspathTests.class); suite.addTestSuite(ClassToolsTests.class); suite.addTestSuite(CollectionToolsTests.class); suite.addTestSuite(CommandExecutorTests.class); suite.addTestSuite(CommandTests.class); - suite.addTestSuite(CounterTests.class); suite.addTestSuite(ExceptionHandlerTests.class); suite.addTestSuite(FileToolsTests.class); suite.addTestSuite(FilterTests.class); suite.addTestSuite(HashBagTests.class); suite.addTestSuite(IdentityHashBagTests.class); suite.addTestSuite(IndentingPrintWriterTests.class); + suite.addTestSuite(IntReferenceTests.class); suite.addTestSuite(JavaTypeTests.class); suite.addTestSuite(JDBCTypeTests.class); suite.addTestSuite(ListenerListTests.class); suite.addTestSuite(MethodSignatureTests.class); suite.addTestSuite(NameToolsTests.class); + suite.addTestSuite(ObjectReferenceTests.class); suite.addTestSuite(RangeTests.class); suite.addTestSuite(ReverseComparatorTests.class); suite.addTestSuite(SimpleAssociationTests.class); + suite.addTestSuite(SimpleQueueTests.class); suite.addTestSuite(SimpleStackTests.class); suite.addTestSuite(StringToolsTests.class); suite.addTestSuite(SynchronizedBooleanTests.class); suite.addTestSuite(SynchronizedIntTests.class); suite.addTestSuite(SynchronizedObjectTests.class); + suite.addTestSuite(SynchronizedQueueTests.class); suite.addTestSuite(SynchronizedStackTests.class); suite.addTestSuite(XMLStringEncoderTests.class); diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ObjectReferenceTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ObjectReferenceTests.java new file mode 100644 index 0000000000..563747227c --- /dev/null +++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ObjectReferenceTests.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. + * + * Contributors: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jpt.utility.tests.internal; + +import junit.framework.TestCase; + +import org.eclipse.jpt.utility.internal.ObjectReference; + +@SuppressWarnings("nls") +public class ObjectReferenceTests extends TestCase { + + public ObjectReferenceTests(String name) { + super(name); + } + + public void testGetValue() { + ObjectReference<String> or = new ObjectReference<String>(); + assertNull(or.getValue()); + or.setValue("foo"); + assertEquals("foo", or.getValue()); + } + + public void testValueEqualsObject() { + ObjectReference<String> or = new ObjectReference<String>(); + assertTrue(or.valueEquals(null)); + assertFalse(or.valueEquals("foo")); + + or.setValue("foo"); + assertFalse(or.valueEquals(null)); + assertTrue(or.valueEquals("foo")); + } + + public void testValueNotEqualObject() { + ObjectReference<String> or = new ObjectReference<String>(); + assertFalse(or.valueNotEqual(null)); + assertTrue(or.valueNotEqual("foo")); + + or.setValue("foo"); + assertTrue(or.valueNotEqual(null)); + assertFalse(or.valueNotEqual("foo")); + } + + public void testIsNull() { + ObjectReference<String> or = new ObjectReference<String>(); + assertTrue(or.isNull()); + or.setValue("foo"); + assertFalse(or.isNull()); + } + + public void testIsNotNull() { + ObjectReference<String> or = new ObjectReference<String>(); + assertFalse(or.isNotNull()); + or.setValue("foo"); + assertTrue(or.isNotNull()); + } + + public void testSetNull() { + ObjectReference<String> or = new ObjectReference<String>(); + assertNull(or.getValue()); + or.setValue("foo"); + assertEquals("foo", or.getValue()); + or.setNull(); + assertNull(or.getValue()); + } + + public void testClone() { + ObjectReference<String> or = new ObjectReference<String>("foo"); + @SuppressWarnings("cast") + ObjectReference<String> clone = (ObjectReference<String>) or.clone(); + assertEquals("foo", clone.getValue()); + assertEquals(or, clone); + } + + public void testEquals() { + ObjectReference<String> or1 = new ObjectReference<String>("foo"); + ObjectReference<String> or2 = new ObjectReference<String>("foo"); + assertTrue(or1.equals(or2)); + ObjectReference<String> or3 = new ObjectReference<String>("bar"); + assertFalse(or1.equals(or3)); + } + + public void testHashCode() { + ObjectReference<String> or = new ObjectReference<String>(); + assertEquals(0, or.hashCode()); + or.setValue("foo"); + assertEquals("foo".hashCode(), or.hashCode()); + } + + public void testToString() { + ObjectReference<String> or = new ObjectReference<String>(); + assertEquals("[null]", or.toString()); + or.setValue("foo"); + assertEquals("[foo]", or.toString()); + } + +} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java index d5bb1c88c2..e5bcf3eb13 100644 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java +++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedBooleanTests.java @@ -40,30 +40,83 @@ public class SynchronizedBooleanTests extends TestCase { super.tearDown(); } - public void testAccessors() throws Exception { + public void testGetValue() throws Exception { + assertFalse(this.sb.getValue()); + } + + public void testIs() throws Exception { + assertTrue(this.sb.is(false)); + } + + public void testIsNot() throws Exception { + assertTrue(this.sb.isNot(true)); + } + + public void testIsTrue() throws Exception { + assertFalse(this.sb.isTrue()); + } + + public void testIsFalse() throws Exception { + assertTrue(this.sb.isFalse()); + } + + public void testSetValueFalse() throws Exception { this.sb.setValue(false); assertFalse(this.sb.getValue()); assertFalse(this.sb.isTrue()); assertTrue(this.sb.isFalse()); + } + public void testSetValueTrue() throws Exception { this.sb.setValue(true); assertTrue(this.sb.getValue()); assertTrue(this.sb.isTrue()); assertFalse(this.sb.isFalse()); + } + public void testFlip() throws Exception { + assertTrue(this.sb.flip()); + assertFalse(this.sb.flip()); + } + + public void testSetNotTrue() throws Exception { + this.sb.setNot(true); + assertFalse(this.sb.getValue()); + assertFalse(this.sb.isTrue()); + assertTrue(this.sb.isFalse()); + } + + public void testSetNotFalse() throws Exception { + this.sb.setNot(false); + assertTrue(this.sb.getValue()); + assertTrue(this.sb.isTrue()); + assertFalse(this.sb.isFalse()); + } + + public void testSetFalse() throws Exception { this.sb.setFalse(); assertFalse(this.sb.getValue()); assertFalse(this.sb.isTrue()); assertTrue(this.sb.isFalse()); + } + public void testSetTrue() throws Exception { this.sb.setTrue(); assertTrue(this.sb.getValue()); assertTrue(this.sb.isTrue()); assertFalse(this.sb.isFalse()); + } + public void testGetMutexThis() throws Exception { assertSame(this.sb, this.sb.getMutex()); } + public void testGetMutexObject() throws Exception { + Object mutex = new Object(); + SynchronizedBoolean syncBool = new SynchronizedBoolean(mutex); + assertSame(mutex, syncBool.getMutex()); + } + public void testEquals() throws Exception { this.sb.setValue(false); SynchronizedBoolean sb2 = new SynchronizedBoolean(false); diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedIntTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedIntTests.java index b10d3321bb..20a2d32051 100644 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedIntTests.java +++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/SynchronizedIntTests.java @@ -44,7 +44,107 @@ public class SynchronizedIntTests extends TestCase { super.tearDown(); } - public void testAccessors() throws Exception { + public void testGetValue() throws Exception { + assertEquals(0, this.si.getValue()); + } + + public void testEqualsInt() throws Exception { + assertTrue(this.si.equals(0)); + this.si.setValue(this.value); + assertTrue(this.si.equals(7)); + } + + public void testNotEqualsInt() throws Exception { + assertTrue(this.si.notEquals(7)); + this.si.setValue(this.value); + assertTrue(this.si.notEquals(0)); + } + + public void testIsZero() throws Exception { + assertTrue(this.si.isZero()); + this.si.setValue(this.value); + assertFalse(this.si.isZero()); + } + + public void testIsNotZero() throws Exception { + assertFalse(this.si.isNotZero()); + this.si.setValue(this.value); + assertTrue(this.si.isNotZero()); + } + + public void testIsGreaterThan() throws Exception { + assertTrue(this.si.isGreaterThan(-1)); + assertFalse(this.si.isGreaterThan(0)); + assertFalse(this.si.isGreaterThan(1)); + this.si.setValue(this.value); + assertTrue(this.si.isGreaterThan(-1)); + assertFalse(this.si.isGreaterThan(7)); + assertFalse(this.si.isGreaterThan(8)); + } + + public void testIsGreaterThanOrEqual() throws Exception { + assertTrue(this.si.isGreaterThanOrEqual(-1)); + assertTrue(this.si.isGreaterThanOrEqual(0)); + assertFalse(this.si.isGreaterThanOrEqual(1)); + this.si.setValue(this.value); + assertTrue(this.si.isGreaterThanOrEqual(-1)); + assertTrue(this.si.isGreaterThanOrEqual(7)); + assertFalse(this.si.isGreaterThanOrEqual(8)); + } + + public void testIsLessThan() throws Exception { + assertFalse(this.si.isLessThan(-1)); + assertFalse(this.si.isLessThan(0)); + assertTrue(this.si.isLessThan(1)); + this.si.setValue(this.value); + assertFalse(this.si.isLessThan(-1)); + assertFalse(this.si.isLessThan(7)); + assertTrue(this.si.isLessThan(8)); + } + + public void testIsLessThanOrEqual() throws Exception { + assertFalse(this.si.isLessThanOrEqual(-1)); + assertTrue(this.si.isLessThanOrEqual(0)); + assertTrue(this.si.isLessThanOrEqual(1)); + this.si.setValue(this.value); + assertFalse(this.si.isLessThanOrEqual(-1)); + assertTrue(this.si.isLessThanOrEqual(7)); + assertTrue(this.si.isLessThanOrEqual(8)); + } + + public void testIsPositive() throws Exception { + assertFalse(this.si.isPositive()); + this.si.setValue(this.value); + assertTrue(this.si.isPositive()); + this.si.setValue(-3); + assertFalse(this.si.isPositive()); + } + + public void testIsNotPositive() throws Exception { + assertTrue(this.si.isNotPositive()); + this.si.setValue(this.value); + assertFalse(this.si.isNotPositive()); + this.si.setValue(-3); + assertTrue(this.si.isNotPositive()); + } + + public void testIsNegative() throws Exception { + assertFalse(this.si.isNegative()); + this.si.setValue(this.value); + assertFalse(this.si.isNegative()); + this.si.setValue(-3); + assertTrue(this.si.isNegative()); + } + + public void testIsNotNegative() throws Exception { + assertTrue(this.si.isNotNegative()); + this.si.setValue(this.value); + assertTrue(this.si.isNotNegative()); + this.si.setValue(-3); + assertFalse(this.si.isNotNegative()); + } + + public void testSetValue() throws Exception { this.si.setValue(0); assertEquals(0, this.si.getValue()); assertFalse(this.si.isNotZero()); @@ -54,12 +154,38 @@ public class SynchronizedIntTests extends TestCase { assertEquals(this.value, this.si.getValue()); assertTrue(this.si.isNotZero()); assertFalse(this.si.isZero()); + } + + public void testAbs() throws Exception { + assertEquals(0, this.si.abs()); + assertEquals(0, this.si.getValue()); + this.si.setValue(this.value); + assertEquals(this.value, this.si.abs()); + assertEquals(this.value, this.si.getValue()); + this.si.setValue(-this.value); + assertEquals(this.value, this.si.abs()); + assertEquals(this.value, this.si.getValue()); + } + public void testNeg() throws Exception { + assertEquals(0, this.si.neg()); + assertEquals(0, this.si.getValue()); + this.si.setValue(this.value); + assertEquals(-this.value, this.si.neg()); + assertEquals(-this.value, this.si.getValue()); + this.si.setValue(-this.value); + assertEquals(this.value, this.si.neg()); + assertEquals(this.value, this.si.getValue()); + } + + public void testSetZero() throws Exception { this.si.setZero(); assertEquals(0, this.si.getValue()); assertFalse(this.si.isNotZero()); assertTrue(this.si.isZero()); + } + public void testGetMutexThis() throws Exception { assertSame(this.si, this.si.getMutex()); } |