Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/InMemoryStateImplTest.java ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL
Modified: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/NodeTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/NodeTest.java?view=diff&r1=155449&r2=155450 ============================================================================== --- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/NodeTest.java (original) +++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/NodeTest.java Sat Feb 26 05:22:31 2005 @@ -1,161 +1,161 @@ -/* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.id.uuid.state; - -import java.util.Arrays; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -/** - * Unit tests for [EMAIL PROTECTED] Node}. - * - * @version $Revision: 1.2 $ $Date: 2004/05/31 07:13:30 $ - * @author Commons-Id team - */ -public class NodeTest extends TestCase { - - /** - * Constructor for test - * - * @param name String name of the test - */ - public NodeTest(String name) { - super(name); - } - - /** - * Main application method - * - * @param args String arguments array - */ - public static void main(String[] args) { - TestRunner.run(suite()); - } - - /** @see junit.framework.TestCase#suite() */ - public static Test suite() { - TestSuite suite = new TestSuite(NodeTest.class); - suite.setName("Node Tests"); - return suite; - } - - /** @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); - } - - /** @see junit.framework.TestCase#tearDown() */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - /** - * <p>Tests the Node hashCode contract - for same id return same hashCode.</p> - */ - public void testHashCode() { - Node one = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-50")); - Node two = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-50")); - // Assert hashCodes equal on same values - assertEquals(one.hashCode(), two.hashCode()); - // Assert hashCode different on different values - two = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-55")); - assertTrue(two.hashCode() != one.hashCode()); - } - - /** - * <p>Test for constructor Node(byte[])</p> - * - * @throws Exception a test exception. - */ - public void testNodebyteArray() throws Exception { - byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - Node test = new Node(bytz); - assertTrue(Arrays.equals(bytz, test.getNodeIdentifier())); - assertTrue(test.getClockSequence() != 0); - long last = test.getUUIDTime(); - assertEquals(last, test.getLastTimestamp()); - } - - /** - * Test for constructor Node(byte[], long, short) - */ - public void testNodebyteArraylongshort() { - byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - Node test = new Node(bytz, 10L, (short) 20); - assertTrue(Arrays.equals(bytz, test.getNodeIdentifier())); - assertEquals(test.getClockSequence(), 20); - assertEquals(test.getLastTimestamp(), 10L); - } - - /** - * Test for byte[] getNodeIdentifier - */ - public void testGetNodeIdentifier() { - byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - Node test = new Node(bytz, 10L, (short) 20); - assertTrue(Arrays.equals(bytz, test.getNodeIdentifier())); - } - - /** - * <p>Test for short getClockSequence.</p> - */ - public void testGetClockSequence() { - byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - Node test = new Node(bytz, 10L, (short) 20); - assertEquals(20, test.getClockSequence()); - } - - /** - * Test for long getUUIDTime - * - * @throws Exception a test exception. - */ - public void testGetUUIDTime() throws Exception { - byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - Node test = new Node(bytz, 10L, (short) 20); - assertTrue(132962443266870000L < test.getUUIDTime()); - } - - /** - * Test for boolean equals(Object) - */ - public void testEqualsObject() { - byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - byte[] byts = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - Node one = new Node(bytz); - Node two = new Node(byts); - assertTrue(one.equals(two)); - assertTrue(two.equals(one)); - two = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-55")); - assertFalse(two.equals(one)); - } - - /** - * Test for getLastTimestamp. - * - * @throws Exception a test exception. - */ - public void testGetLastTimestamp() throws Exception { - byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); - Node test = new Node(bytz); - long last = test.getUUIDTime(); - assertEquals(last, test.getLastTimestamp()); - } -} +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.id.uuid.state; + +import java.util.Arrays; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +/** + * Unit tests for [EMAIL PROTECTED] Node}. + * + * @version $Revision$ $Date$ + * @author Commons-Id team + */ +public class NodeTest extends TestCase { + + /** + * Constructor for test + * + * @param name String name of the test + */ + public NodeTest(String name) { + super(name); + } + + /** + * Main application method + * + * @param args String arguments array + */ + public static void main(String[] args) { + TestRunner.run(suite()); + } + + /** @see junit.framework.TestCase#suite() */ + public static Test suite() { + TestSuite suite = new TestSuite(NodeTest.class); + suite.setName("Node Tests"); + return suite; + } + + /** @see junit.framework.TestCase#setUp() */ + protected void setUp() throws Exception { + super.setUp(); + } + + /** @see junit.framework.TestCase#tearDown() */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * <p>Tests the Node hashCode contract - for same id return same hashCode.</p> + */ + public void testHashCode() { + Node one = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-50")); + Node two = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-50")); + // Assert hashCodes equal on same values + assertEquals(one.hashCode(), two.hashCode()); + // Assert hashCode different on different values + two = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-55")); + assertTrue(two.hashCode() != one.hashCode()); + } + + /** + * <p>Test for constructor Node(byte[])</p> + * + * @throws Exception a test exception. + */ + public void testNodebyteArray() throws Exception { + byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + Node test = new Node(bytz); + assertTrue(Arrays.equals(bytz, test.getNodeIdentifier())); + assertTrue(test.getClockSequence() != 0); + long last = test.getUUIDTime(); + assertEquals(last, test.getLastTimestamp()); + } + + /** + * Test for constructor Node(byte[], long, short) + */ + public void testNodebyteArraylongshort() { + byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + Node test = new Node(bytz, 10L, (short) 20); + assertTrue(Arrays.equals(bytz, test.getNodeIdentifier())); + assertEquals(test.getClockSequence(), 20); + assertEquals(test.getLastTimestamp(), 10L); + } + + /** + * Test for byte[] getNodeIdentifier + */ + public void testGetNodeIdentifier() { + byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + Node test = new Node(bytz, 10L, (short) 20); + assertTrue(Arrays.equals(bytz, test.getNodeIdentifier())); + } + + /** + * <p>Test for short getClockSequence.</p> + */ + public void testGetClockSequence() { + byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + Node test = new Node(bytz, 10L, (short) 20); + assertEquals(20, test.getClockSequence()); + } + + /** + * Test for long getUUIDTime + * + * @throws Exception a test exception. + */ + public void testGetUUIDTime() throws Exception { + byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + Node test = new Node(bytz, 10L, (short) 20); + assertTrue(132962443266870000L < test.getUUIDTime()); + } + + /** + * Test for boolean equals(Object) + */ + public void testEqualsObject() { + byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + byte[] byts = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + Node one = new Node(bytz); + Node two = new Node(byts); + assertTrue(one.equals(two)); + assertTrue(two.equals(one)); + two = new Node(StateHelper.decodeMACAddress("02-00-4C-4F-4F-55")); + assertFalse(two.equals(one)); + } + + /** + * Test for getLastTimestamp. + * + * @throws Exception a test exception. + */ + public void testGetLastTimestamp() throws Exception { + byte[] bytz = StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"); + Node test = new Node(bytz); + long last = test.getUUIDTime(); + assertEquals(last, test.getLastTimestamp()); + } +} Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/NodeTest.java ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL Modified: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadOnlyResourceStateImplTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadOnlyResourceStateImplTest.java?view=diff&r1=155449&r2=155450 ============================================================================== --- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadOnlyResourceStateImplTest.java (original) +++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadOnlyResourceStateImplTest.java Sat Feb 26 05:22:31 2005 @@ -1,134 +1,134 @@ -/* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.id.uuid.state; - -import java.util.Iterator; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -/** - * Unit tests for [EMAIL PROTECTED] ReadOnlyResourceStateImpl}. - * - * @version $Revision: 1.2 $ $Date: 2004/05/31 07:12:40 $ - * @author Commons-Id team - */ -public class ReadOnlyResourceStateImplTest extends TestCase { - - /** Pre test value for ReadOnlyResourceStateImpl.CONFIG_FILE_KEY */ - private String currentConfigFile; - - /** - * Constructor for test - * - * @param name String name of the test - */ - public ReadOnlyResourceStateImplTest(String name) { - super(name); - } - - /** - * Main application method - * - * @param args String arguments array - */ - public static void main(String[] args) { - TestRunner.run(suite()); - } - - /** @see junit.framework.TestCase#suite() */ - public static Test suite() { - TestSuite suite = new TestSuite(ReadOnlyResourceStateImplTest.class); - suite.setName("ReadOnlyResourceStateImpl Tests"); - return suite; - } - - /** @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); - currentConfigFile = System.getProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY); - } - - /** @see junit.framework.TestCase#tearDown() */ - protected void tearDown() throws Exception { - if (currentConfigFile != null) { - System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, currentConfigFile); - } - super.tearDown(); - } - - /** - * <p>Test the ReadOnlyResourceStateImpl constructor.</p> - */ - public void testReadOnlyResourceStateImpl() { - ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); - assertNotNull(impl); - } - - /** - * <p>Test the void load method.</p> - * - * @throws Exception a test exception. - */ - public void testLoad() throws Exception { - System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); - ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); - impl.load(); - assertEquals(2, impl.getNodes().size()); - } - - /** - * <p>Test the void load method.</p> - */ - public void testGetSynchInterval() { - ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); - assertEquals(Long.MAX_VALUE, impl.getSynchInterval()); - } - - /** - * <p>Test the Set getNodes method.</p> - */ - public void testGetNodes() { - System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); - ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); - impl.load(); - byte[] node1 = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x50}; - Node one = new Node(node1); - byte[] node2 = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x55}; - Node two = new Node(node2); - Iterator it = impl.getNodes().iterator(); - while (it.hasNext()) { - Node n = (Node) it.next(); - assertTrue(n.equals(one) || n.equals(two)); - } - } - - /** - * <p>Test the void store method.</p> - * @throws Exception a test Exception. - */ - public void testStore() throws Exception { - // No operation, just make sure no exception is raised - System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); - ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); - impl.load(); - impl.store(impl.getNodes()); - impl.store(impl.getNodes(), 100L); - } -} +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.id.uuid.state; + +import java.util.Iterator; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +/** + * Unit tests for [EMAIL PROTECTED] ReadOnlyResourceStateImpl}. + * + * @version $Revision$ $Date$ + * @author Commons-Id team + */ +public class ReadOnlyResourceStateImplTest extends TestCase { + + /** Pre test value for ReadOnlyResourceStateImpl.CONFIG_FILE_KEY */ + private String currentConfigFile; + + /** + * Constructor for test + * + * @param name String name of the test + */ + public ReadOnlyResourceStateImplTest(String name) { + super(name); + } + + /** + * Main application method + * + * @param args String arguments array + */ + public static void main(String[] args) { + TestRunner.run(suite()); + } + + /** @see junit.framework.TestCase#suite() */ + public static Test suite() { + TestSuite suite = new TestSuite(ReadOnlyResourceStateImplTest.class); + suite.setName("ReadOnlyResourceStateImpl Tests"); + return suite; + } + + /** @see junit.framework.TestCase#setUp() */ + protected void setUp() throws Exception { + super.setUp(); + currentConfigFile = System.getProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY); + } + + /** @see junit.framework.TestCase#tearDown() */ + protected void tearDown() throws Exception { + if (currentConfigFile != null) { + System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, currentConfigFile); + } + super.tearDown(); + } + + /** + * <p>Test the ReadOnlyResourceStateImpl constructor.</p> + */ + public void testReadOnlyResourceStateImpl() { + ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); + assertNotNull(impl); + } + + /** + * <p>Test the void load method.</p> + * + * @throws Exception a test exception. + */ + public void testLoad() throws Exception { + System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); + ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); + impl.load(); + assertEquals(2, impl.getNodes().size()); + } + + /** + * <p>Test the void load method.</p> + */ + public void testGetSynchInterval() { + ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); + assertEquals(Long.MAX_VALUE, impl.getSynchInterval()); + } + + /** + * <p>Test the Set getNodes method.</p> + */ + public void testGetNodes() { + System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); + ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); + impl.load(); + byte[] node1 = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x50}; + Node one = new Node(node1); + byte[] node2 = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x55}; + Node two = new Node(node2); + Iterator it = impl.getNodes().iterator(); + while (it.hasNext()) { + Node n = (Node) it.next(); + assertTrue(n.equals(one) || n.equals(two)); + } + } + + /** + * <p>Test the void store method.</p> + * @throws Exception a test Exception. + */ + public void testStore() throws Exception { + // No operation, just make sure no exception is raised + System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); + ReadOnlyResourceStateImpl impl = new ReadOnlyResourceStateImpl(); + impl.load(); + impl.store(impl.getNodes()); + impl.store(impl.getNodes(), 100L); + } +} Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadOnlyResourceStateImplTest.java ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL Modified: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadWriteFileStateImplTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadWriteFileStateImplTest.java?view=diff&r1=155449&r2=155450 ============================================================================== --- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadWriteFileStateImplTest.java (original) +++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadWriteFileStateImplTest.java Sat Feb 26 05:22:31 2005 @@ -1,85 +1,85 @@ -/* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.id.uuid.state; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -/** - * Unit tests for [EMAIL PROTECTED] ReadWriteFileStateImpl}. - * - * @version $Revision: 1.2 $ $Date: 2004/05/31 07:12:07 $ - * @author Commons-Id team - */ -public class ReadWriteFileStateImplTest extends TestCase { - - /** Pre test value for ReadOnlyResourceStateImpl.CONFIG_FILE_KEY */ - private String currentConfigFile; - - /** - * Constructor for test - * - * @param name String name of the test - */ - public ReadWriteFileStateImplTest(String name) { - super(name); - } - - /** - * Main application method - * - * @param args String arguments array - */ - public static void main(String[] args) { - TestRunner.run(suite()); - } - - /** @see junit.framework.TestCase#suite() */ - public static Test suite() { - TestSuite suite = new TestSuite(ReadWriteFileStateImplTest.class); - suite.setName("ReadWriteFileStateImpl Tests"); - return suite; - } - - /** @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); - currentConfigFile = System.getProperty(ReadWriteFileStateImpl.CONFIG_FILENAME_KEY); - } - - /** @see junit.framework.TestCase#tearDown() */ - protected void tearDown() throws Exception { - if (currentConfigFile != null) { - System.setProperty(ReadWriteFileStateImpl.CONFIG_FILENAME_KEY, currentConfigFile); - } - super.tearDown(); - } - - /** - * <p>Tests the void store method.</p> - * @throws Exception a testing Exception. - */ - public void testStore() throws Exception { - System.setProperty(ReadWriteFileStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); - ReadWriteFileStateImpl impl = new ReadWriteFileStateImpl(); - impl.load(); - impl.store(impl.getNodes()); - } - -} +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.id.uuid.state; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +/** + * Unit tests for [EMAIL PROTECTED] ReadWriteFileStateImpl}. + * + * @version $Revision$ $Date$ + * @author Commons-Id team + */ +public class ReadWriteFileStateImplTest extends TestCase { + + /** Pre test value for ReadOnlyResourceStateImpl.CONFIG_FILE_KEY */ + private String currentConfigFile; + + /** + * Constructor for test + * + * @param name String name of the test + */ + public ReadWriteFileStateImplTest(String name) { + super(name); + } + + /** + * Main application method + * + * @param args String arguments array + */ + public static void main(String[] args) { + TestRunner.run(suite()); + } + + /** @see junit.framework.TestCase#suite() */ + public static Test suite() { + TestSuite suite = new TestSuite(ReadWriteFileStateImplTest.class); + suite.setName("ReadWriteFileStateImpl Tests"); + return suite; + } + + /** @see junit.framework.TestCase#setUp() */ + protected void setUp() throws Exception { + super.setUp(); + currentConfigFile = System.getProperty(ReadWriteFileStateImpl.CONFIG_FILENAME_KEY); + } + + /** @see junit.framework.TestCase#tearDown() */ + protected void tearDown() throws Exception { + if (currentConfigFile != null) { + System.setProperty(ReadWriteFileStateImpl.CONFIG_FILENAME_KEY, currentConfigFile); + } + super.tearDown(); + } + + /** + * <p>Tests the void store method.</p> + * @throws Exception a testing Exception. + */ + public void testStore() throws Exception { + System.setProperty(ReadWriteFileStateImpl.CONFIG_FILENAME_KEY, "uuid1.state"); + ReadWriteFileStateImpl impl = new ReadWriteFileStateImpl(); + impl.load(); + impl.store(impl.getNodes()); + } + +} Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/ReadWriteFileStateImplTest.java ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL Modified: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/StateHelperTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/StateHelperTest.java?view=diff&r1=155449&r2=155450 ============================================================================== --- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/StateHelperTest.java (original) +++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/StateHelperTest.java Sat Feb 26 05:22:31 2005 @@ -1,171 +1,171 @@ -/* - * Copyright 2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.commons.id.uuid.state; - -import java.util.Arrays; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; -import junit.textui.TestRunner; - -import org.apache.commons.id.uuid.clock.Clock; -import org.apache.commons.id.uuid.clock.SystemClockImpl; -import org.apache.commons.id.uuid.clock.ThreadClockImpl; - -/** - * Unit tests for [EMAIL PROTECTED] StateHelper}. - * - * @version $Revision: 1.2 $ $Date: 2004/05/31 07:11:17 $ - * @author Commons-Id team - */ -public class StateHelperTest extends TestCase { - - /** - * Constructor for test - * - * @param name String name of the test - */ - public StateHelperTest(String name) { - super(name); - } - - /** - * Main application method - * - * @param args String arguments array - */ - public static void main(String[] args) { - TestRunner.run(suite()); - } - - /** @see junit.framework.TestCase#suite() */ - public static Test suite() { - TestSuite suite = new TestSuite(StateHelperTest.class); - suite.setName("StateHelper Tests"); - return suite; - } - - /** @see junit.framework.TestCase#setUp() */ - protected void setUp() throws Exception { - super.setUp(); - } - - /** @see junit.framework.TestCase#tearDown() */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - /** - * <p>Test the randomNodeIdentifier method.</p> - */ - public void testRandomNodeIdentifier() { - byte[] nodeId = StateHelper.randomNodeIdentifier(); - // Check proper length - assertTrue(nodeId.length == StateHelper.NODE_ID_BYTE_LENGTH); - // Check multicast bit is set ( -1 since java is always signed and we shifted) - assertEquals(-1, nodeId[0] >> 7); - } - - /** Test newClockSequence method */ - public void testNewClockSequence() { - short clockSq = StateHelper.newClockSequence(); - //Nothing to assert, it worked. - } - - /** Test getClockImpl method */ - public void testGetClockImpl() { - // Change the value for our tests only, then put it back. - String currentClockImpl = System.getProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY); - Clock ck = null; - try { - System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.clock.SystemClockImpl"); - ck = StateHelper.getClockImpl(); - assertTrue(ck instanceof SystemClockImpl); - System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.clock.ThreadClockImpl"); - ck = StateHelper.getClockImpl(); - assertTrue(ck instanceof ThreadClockImpl); - // Test native only if Windows OS - if (System.getProperty("os.name").indexOf("Windows") != -1) { - boolean runTest = true; - try { - System.loadLibrary("JNativeWin32Clock"); - } catch (UnsatisfiedLinkError usle) { - runTest = false; - } - if (runTest) { - //System.out.println("Running Native Test."); - System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, - "org.apache.commons.id.uuid.clock.SystemClockImpl"); - ck = StateHelper.getClockImpl(); - assertTrue(ck instanceof SystemClockImpl); - } - } - } catch (Exception e) { - fail(e.getMessage()); - } finally { - // Make sure to put it back. - if (currentClockImpl != null) { - System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, currentClockImpl); - } - } - } - - /** Test getStateImpl method */ - public void testGetStateImpl() { - // Change the value for our tests only, then put it back. - String currentStateImpl = System.getProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY); - State st = null; - try { - System.setProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.state.InMemoryStateImpl"); - st = StateHelper.getStateImpl(); - assertTrue(st instanceof InMemoryStateImpl); - System.setProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY, - "org.apache.commons.id.uuid.state.ReadOnlyResourceStateImpl"); - st = StateHelper.getStateImpl(); - assertTrue(st instanceof ReadOnlyResourceStateImpl); - System.setProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.state.ReadWriteFileStateImpl"); - st = StateHelper.getStateImpl(); - assertTrue(st instanceof ReadWriteFileStateImpl); - } catch (Exception e) { - fail(e.getMessage()); - } finally { - // Make sure to put it back. - if (currentStateImpl != null) { - System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, currentStateImpl); - } - } - } - - /** Test the decodeMACAddress method. */ - public void testDecodeMACAddress() { - // Test MAC address 02-00-4C-4F-4F-50 - byte[] macAsBytes = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x50}; - assertTrue(Arrays.equals(macAsBytes, StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"))); - } - - /** - * <p>Test the encodeMACAddress method.</p> - * @throws Exception a test Exception. - */ - public void testEncodeMACAddress() throws Exception { - // Test MAC address 02-00-4C-4F-4F-50 - byte[] macAsBytes = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x50}; - assertEquals("02-00-4C-4F-4F-50", StateHelper.encodeMACAddress(macAsBytes)); - } - -} +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.id.uuid.state; + +import java.util.Arrays; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.apache.commons.id.uuid.clock.Clock; +import org.apache.commons.id.uuid.clock.SystemClockImpl; +import org.apache.commons.id.uuid.clock.ThreadClockImpl; + +/** + * Unit tests for [EMAIL PROTECTED] StateHelper}. + * + * @version $Revision$ $Date$ + * @author Commons-Id team + */ +public class StateHelperTest extends TestCase { + + /** + * Constructor for test + * + * @param name String name of the test + */ + public StateHelperTest(String name) { + super(name); + } + + /** + * Main application method + * + * @param args String arguments array + */ + public static void main(String[] args) { + TestRunner.run(suite()); + } + + /** @see junit.framework.TestCase#suite() */ + public static Test suite() { + TestSuite suite = new TestSuite(StateHelperTest.class); + suite.setName("StateHelper Tests"); + return suite; + } + + /** @see junit.framework.TestCase#setUp() */ + protected void setUp() throws Exception { + super.setUp(); + } + + /** @see junit.framework.TestCase#tearDown() */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * <p>Test the randomNodeIdentifier method.</p> + */ + public void testRandomNodeIdentifier() { + byte[] nodeId = StateHelper.randomNodeIdentifier(); + // Check proper length + assertTrue(nodeId.length == StateHelper.NODE_ID_BYTE_LENGTH); + // Check multicast bit is set ( -1 since java is always signed and we shifted) + assertEquals(-1, nodeId[0] >> 7); + } + + /** Test newClockSequence method */ + public void testNewClockSequence() { + short clockSq = StateHelper.newClockSequence(); + //Nothing to assert, it worked. + } + + /** Test getClockImpl method */ + public void testGetClockImpl() { + // Change the value for our tests only, then put it back. + String currentClockImpl = System.getProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY); + Clock ck = null; + try { + System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.clock.SystemClockImpl"); + ck = StateHelper.getClockImpl(); + assertTrue(ck instanceof SystemClockImpl); + System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.clock.ThreadClockImpl"); + ck = StateHelper.getClockImpl(); + assertTrue(ck instanceof ThreadClockImpl); + // Test native only if Windows OS + if (System.getProperty("os.name").indexOf("Windows") != -1) { + boolean runTest = true; + try { + System.loadLibrary("JNativeWin32Clock"); + } catch (UnsatisfiedLinkError usle) { + runTest = false; + } + if (runTest) { + //System.out.println("Running Native Test."); + System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, + "org.apache.commons.id.uuid.clock.SystemClockImpl"); + ck = StateHelper.getClockImpl(); + assertTrue(ck instanceof SystemClockImpl); + } + } + } catch (Exception e) { + fail(e.getMessage()); + } finally { + // Make sure to put it back. + if (currentClockImpl != null) { + System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, currentClockImpl); + } + } + } + + /** Test getStateImpl method */ + public void testGetStateImpl() { + // Change the value for our tests only, then put it back. + String currentStateImpl = System.getProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY); + State st = null; + try { + System.setProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.state.InMemoryStateImpl"); + st = StateHelper.getStateImpl(); + assertTrue(st instanceof InMemoryStateImpl); + System.setProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY, + "org.apache.commons.id.uuid.state.ReadOnlyResourceStateImpl"); + st = StateHelper.getStateImpl(); + assertTrue(st instanceof ReadOnlyResourceStateImpl); + System.setProperty(StateHelper.UUID_STATE_IMPL_PROPERTY_KEY, "org.apache.commons.id.uuid.state.ReadWriteFileStateImpl"); + st = StateHelper.getStateImpl(); + assertTrue(st instanceof ReadWriteFileStateImpl); + } catch (Exception e) { + fail(e.getMessage()); + } finally { + // Make sure to put it back. + if (currentStateImpl != null) { + System.setProperty(StateHelper.UUID_CLOCK_IMPL_PROPERTY_KEY, currentStateImpl); + } + } + } + + /** Test the decodeMACAddress method. */ + public void testDecodeMACAddress() { + // Test MAC address 02-00-4C-4F-4F-50 + byte[] macAsBytes = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x50}; + assertTrue(Arrays.equals(macAsBytes, StateHelper.decodeMACAddress("02-00-4C-4F-4F-50"))); + } + + /** + * <p>Test the encodeMACAddress method.</p> + * @throws Exception a test Exception. + */ + public void testEncodeMACAddress() throws Exception { + // Test MAC address 02-00-4C-4F-4F-50 + byte[] macAsBytes = {0x02, 0x00, 0x4C, 0x4F, 0x4F, 0x50}; + assertEquals("02-00-4C-4F-4F-50", StateHelper.encodeMACAddress(macAsBytes)); + } + +} Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/state/StateHelperTest.java ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL Propchange: jakarta/commons/sandbox/id/trunk/xdocs/downloads.xml ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL Modified: jakarta/commons/sandbox/id/trunk/xdocs/index.xml URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/xdocs/index.xml?view=diff&r1=155449&r2=155450 ============================================================================== --- jakarta/commons/sandbox/id/trunk/xdocs/index.xml (original) +++ jakarta/commons/sandbox/id/trunk/xdocs/index.xml Sat Feb 26 05:22:31 2005 @@ -19,7 +19,7 @@ <properties> <title>Overview</title> <author email="commons-dev@jakarta.apache.org">Commons Documentation team</author> - <revision>$Id: index.xml,v 1.6 2004/12/14 12:39:59 rwinston Exp $</revision> + <revision>$Id$</revision> </properties> <body> Propchange: jakarta/commons/sandbox/id/trunk/xdocs/index.xml ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL Propchange: jakarta/commons/sandbox/id/trunk/xdocs/navigation.xml ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL Propchange: jakarta/commons/sandbox/id/trunk/xdocs/uuid.xml ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords Sat Feb 26 05:22:31 2005 @@ -1 +1 @@ -author date id revision +Date Author Id Revision HeadURL --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]