diff options
author | slewis | 2008-05-14 05:54:59 +0000 |
---|---|---|
committer | slewis | 2008-05-14 05:54:59 +0000 |
commit | 3695f8197e14acee7a609a85954758d3ad221d75 (patch) | |
tree | dca316b82b29a8f8f81789b4e4a495eeab42c514 | |
parent | bded75abdf05d9b089e147cd4e99f2f4ecfde942 (diff) | |
download | org.eclipse.ecf-3695f8197e14acee7a609a85954758d3ad221d75.tar.gz org.eclipse.ecf-3695f8197e14acee7a609a85954758d3ad221d75.tar.xz org.eclipse.ecf-3695f8197e14acee7a609a85954758d3ad221d75.zip |
Fix for 231969
4 files changed, 129 insertions, 108 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java index 96acacf16..3e766c743 100755 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java +++ b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/GUIDTest.java @@ -28,80 +28,86 @@ public class GUIDTest extends IDAbstractTestCase { protected ID createID() throws IDCreateException { return createGUID(GUID.DEFAULT_BYTE_LENGTH); } - + protected ID createGUID(int length) throws IDCreateException { return IDFactory.getDefault().createGUID(length); } - + public void testCreate() throws Exception { - ID newID = createID(); + final ID newID = createID(); assertNotNull(newID); } public void testCreateLong() throws Exception { - ID newID = createGUID(40); + final ID newID = createGUID(40); assertNotNull(newID); } - + public void testGetName() throws Exception { - ID id = createID(); + final ID id = createID(); assertNotNull(id.getName()); } - + public void testToExternalForm() throws Exception { - ID id = createID(); + final ID id = createID(); assertNotNull(id.toExternalForm()); } - + public void testToString() throws Exception { - ID id = createID(); + final ID id = createID(); assertNotNull(id.toString()); } - + public void testNotEqual() throws Exception { - ID id1 = createID(); - ID id2 = createID(); + final ID id1 = createID(); + final ID id2 = createID(); assertFalse(id1.equals(id2)); } - + public void testHashCode() throws Exception { - ID id1 = createID(); - ID id2 = createID(); + final ID id1 = createID(); + final ID id2 = createID(); assertTrue(id1.hashCode() != id2.hashCode()); } - + public void testCompareToNotEqual() throws Exception { - ID id1 = createID(); - ID id2 = createID(); - assertTrue(id1.compareTo(id2) != 0); - assertTrue(id2.compareTo(id1) != 0); + final ID id1 = createID(); + final ID id2 = createID(); + assertTrue(id1.compareTo(id2) != 0); + assertTrue(id2.compareTo(id1) != 0); } public void testGetNamespace() throws Exception { - ID id = createID(); - Namespace ns = id.getNamespace(); + final ID id = createID(); + final Namespace ns = id.getNamespace(); assertNotNull(ns); } - + public void testEqualNamespaces() throws Exception { - ID id1 = createID(); - ID id2 = createID(); - Namespace ns1 = id1.getNamespace(); - Namespace ns2 = id2.getNamespace(); + final ID id1 = createID(); + final ID id2 = createID(); + final Namespace ns1 = id1.getNamespace(); + final Namespace ns2 = id2.getNamespace(); assertTrue(ns1.equals(ns2)); assertTrue(ns2.equals(ns2)); } - + public void testSerializable() throws Exception { - ByteArrayOutputStream buf = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(buf); + final ByteArrayOutputStream buf = new ByteArrayOutputStream(); + final ObjectOutputStream out = new ObjectOutputStream(buf); try { out.writeObject(createID()); - } catch (NotSerializableException ex) { + } catch (final NotSerializableException ex) { fail(ex.getLocalizedMessage()); } finally { out.close(); } } + public void testCreateFromExternalForm() throws Exception { + final ID id1 = createID(); + final String externalForm = id1.toExternalForm(); + final ID id2 = IDFactory.getDefault().createID(id1.getNamespace(), externalForm); + assertTrue(id1.equals(id2)); + } } diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java index 61cea8935..b2b77974c 100755 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java +++ b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/IDAbstractTestCase.java @@ -18,9 +18,9 @@ import org.eclipse.ecf.tests.ECFAbstractTestCase; public abstract class IDAbstractTestCase extends ECFAbstractTestCase { private ID fixture; - + protected abstract ID createID() throws IDCreateException; - + /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ @@ -29,7 +29,7 @@ public abstract class IDAbstractTestCase extends ECFAbstractTestCase { fixture = createID(); assertNotNull(fixture); } - + /* (non-Javadoc) * @see junit.framework.TestCase#tearDown() */ @@ -37,8 +37,9 @@ public abstract class IDAbstractTestCase extends ECFAbstractTestCase { super.tearDown(); fixture = null; } - + protected ID getFixture() { return fixture; } + } diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java index ecbb8af74..9266a1d8c 100755 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java +++ b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/LongIDTest.java @@ -27,98 +27,104 @@ public class LongIDTest extends IDAbstractTestCase { protected ID createID() throws IDCreateException { return createLongID(Long.MAX_VALUE); } - + protected ID createLongID(long val) throws IDCreateException { return IDFactory.getDefault().createLongID(val); } - + public void testCreate() throws Exception { - ID newID = createID(); + final ID newID = createID(); assertNotNull(newID); } public void testMinCreate() throws Exception { - ID newID = createLongID(Long.MIN_VALUE); + final ID newID = createLongID(Long.MIN_VALUE); assertNotNull(newID); } public void testMAXCreate() throws Exception { - ID newID = createLongID(Long.MAX_VALUE); + final ID newID = createLongID(Long.MAX_VALUE); assertNotNull(newID); } public void testZeroCreate() throws Exception { - ID id = createLongID(0); + final ID id = createLongID(0); assertTrue(id.getName().equals(String.valueOf(0))); } - + public void testGetName() throws Exception { - ID id1 = createID(); - ID id2 = createID(); + final ID id1 = createID(); + final ID id2 = createID(); assertTrue(id1.getName().equals(id2.getName())); } - + public void testToExternalForm() throws Exception { - ID id = createID(); + final ID id = createID(); assertNotNull(id.toExternalForm()); } - + public void testToString() throws Exception { - ID id = createID(); + final ID id = createID(); assertNotNull(id.toString()); } - + public void testIsEqual() throws Exception { - ID id1 = createID(); - ID id2 = createID(); + final ID id1 = createID(); + final ID id2 = createID(); assertTrue(id1.equals(id2)); } - + public void testHashCode() throws Exception { - ID id1 = createID(); - ID id2 = createID(); + final ID id1 = createID(); + final ID id2 = createID(); assertTrue(id1.hashCode() == id2.hashCode()); } - + public void testCompareToEqual() throws Exception { - ID id1 = createID(); - ID id2 = createID(); - assertTrue(id1.compareTo(id2) == 0); - assertTrue(id2.compareTo(id1) == 0); + final ID id1 = createID(); + final ID id2 = createID(); + assertTrue(id1.compareTo(id2) == 0); + assertTrue(id2.compareTo(id1) == 0); } public void testCompareToNotEqual() throws Exception { - ID id1 = createLongID(0); - ID id2 = createLongID(1); + final ID id1 = createLongID(0); + final ID id2 = createLongID(1); assertTrue(id1.compareTo(id2) < 0); assertTrue(id2.compareTo(id1) > 0); } - + public void testGetNamespace() throws Exception { - ID id = createID(); - Namespace ns = id.getNamespace(); + final ID id = createID(); + final Namespace ns = id.getNamespace(); assertNotNull(ns); } - + public void testEqualNamespaces() throws Exception { - ID id1 = createID(); - ID id2 = createID(); - Namespace ns1 = id1.getNamespace(); - Namespace ns2 = id2.getNamespace(); + final ID id1 = createID(); + final ID id2 = createID(); + final Namespace ns1 = id1.getNamespace(); + final Namespace ns2 = id2.getNamespace(); assertTrue(ns1.equals(ns2)); assertTrue(ns2.equals(ns2)); } - + public void testSerializable() throws Exception { - ByteArrayOutputStream buf = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(buf); + final ByteArrayOutputStream buf = new ByteArrayOutputStream(); + final ObjectOutputStream out = new ObjectOutputStream(buf); try { out.writeObject(createID()); - } catch (NotSerializableException ex) { + } catch (final NotSerializableException ex) { fail(ex.getLocalizedMessage()); } finally { out.close(); } } + public void testCreateFromExternalForm() throws Exception { + final ID id1 = createID(); + final String externalForm = id1.toExternalForm(); + final ID id2 = IDFactory.getDefault().createID(id1.getNamespace(), externalForm); + assertTrue(id1.equals(id2)); + } } diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java index 4819769c3..826944cdb 100755 --- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java +++ b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/core/identity/StringIDTest.java @@ -27,13 +27,13 @@ public class StringIDTest extends IDAbstractTestCase { protected ID createID() throws IDCreateException { return createStringID(this.getClass().getName()); } - + protected ID createStringID(String val) throws IDCreateException { return IDFactory.getDefault().createStringID(val); } - + public void testCreate() throws Exception { - ID newID = createID(); + final ID newID = createID(); assertNotNull(newID); } @@ -41,75 +41,83 @@ public class StringIDTest extends IDAbstractTestCase { try { createStringID(null); fail(); - } catch (IDCreateException e) { + } catch (final IDCreateException e) { // success } } + public void testGetName() throws Exception { - ID id = createStringID(this.getClass().getName()); + final ID id = createStringID(this.getClass().getName()); assertTrue(id.getName().equals(this.getClass().getName())); } - + public void testToExternalForm() throws Exception { - ID id = createStringID(this.getClass().getName()); + final ID id = createStringID(this.getClass().getName()); assertNotNull(id.toExternalForm()); } - + public void testToString() throws Exception { - ID id = createStringID(this.getClass().getName()); + final ID id = createStringID(this.getClass().getName()); assertNotNull(id.toString()); } - + public void testIsEqual() throws Exception { - ID id1 = createID(); - ID id2 = createID(); + final ID id1 = createID(); + final ID id2 = createID(); assertTrue(id1.equals(id2)); } - + public void testHashCode() throws Exception { - ID id1 = createID(); - ID id2 = createID(); + final ID id1 = createID(); + final ID id2 = createID(); assertTrue(id1.hashCode() == id2.hashCode()); } - + public void testCompareToEqual() throws Exception { - ID id1 = createID(); - ID id2 = createID(); - assertTrue(id1.compareTo(id2) == 0); - assertTrue(id2.compareTo(id1) == 0); + final ID id1 = createID(); + final ID id2 = createID(); + assertTrue(id1.compareTo(id2) == 0); + assertTrue(id2.compareTo(id1) == 0); } public void testCompareToNotEqual() throws Exception { - ID id1 = createStringID("abcdefghijkl"); - ID id2 = createStringID("abcdefghijklm"); + final ID id1 = createStringID("abcdefghijkl"); + final ID id2 = createStringID("abcdefghijklm"); assertTrue(id1.compareTo(id2) < 0); assertTrue(id2.compareTo(id1) > 0); } - + public void testGetNamespace() throws Exception { - ID id = createID(); - Namespace ns = id.getNamespace(); + final ID id = createID(); + final Namespace ns = id.getNamespace(); assertNotNull(ns); } - + public void testEqualNamespaces() throws Exception { - ID id1 = createID(); - ID id2 = createID(); - Namespace ns1 = id1.getNamespace(); - Namespace ns2 = id2.getNamespace(); + final ID id1 = createID(); + final ID id2 = createID(); + final Namespace ns1 = id1.getNamespace(); + final Namespace ns2 = id2.getNamespace(); assertTrue(ns1.equals(ns2)); assertTrue(ns2.equals(ns2)); } - + public void testSerializable() throws Exception { - ByteArrayOutputStream buf = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(buf); + final ByteArrayOutputStream buf = new ByteArrayOutputStream(); + final ObjectOutputStream out = new ObjectOutputStream(buf); try { out.writeObject(createID()); - } catch (NotSerializableException ex) { + } catch (final NotSerializableException ex) { fail(ex.getLocalizedMessage()); } finally { out.close(); } } + + public void testCreateFromExternalForm() throws Exception { + final ID id1 = createID(); + final String externalForm = id1.toExternalForm(); + final ID id2 = IDFactory.getDefault().createID(id1.getNamespace(), externalForm); + assertTrue(id1.equals(id2)); + } } |