Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 90432 invoked from network); 5 Jul 2005 03:44:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 5 Jul 2005 03:44:15 -0000 Received: (qmail 27757 invoked by uid 500); 5 Jul 2005 03:44:11 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 27737 invoked by uid 500); 5 Jul 2005 03:44:11 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 27724 invoked by uid 500); 5 Jul 2005 03:44:11 -0000 Received: (qmail 27720 invoked by uid 99); 5 Jul 2005 03:44:11 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 04 Jul 2005 20:44:10 -0700 Received: (qmail 90372 invoked by uid 65534); 5 Jul 2005 03:44:08 -0000 Message-ID: <20050705034408.90370.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r209204 - in /jakarta/commons/sandbox/id/trunk/src: java/org/apache/commons/id/uuid/NodeManagerImpl.java test/org/apache/commons/id/uuid/NodeManagerImplTest.java Date: Tue, 05 Jul 2005 03:44:08 -0000 To: commons-cvs@jakarta.apache.org From: psteitz@apache.org X-Mailer: svnmailer-1.0.2 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: psteitz Date: Mon Jul 4 20:44:07 2005 New Revision: 209204 URL: http://svn.apache.org/viewcvs?rev=209204&view=rev Log: Fixed NodeManagerImpl index increment bug. BZ #35601. Reported by John Gregg. Added: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java (with props) Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/NodeManagerImpl.java Modified: jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/NodeManagerImpl.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/NodeManagerImpl.java?rev=209204&r1=209203&r2=209204&view=diff ============================================================================== --- jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/NodeManagerImpl.java (original) +++ jakarta/commons/sandbox/id/trunk/src/java/org/apache/commons/id/uuid/NodeManagerImpl.java Mon Jul 4 20:44:07 2005 @@ -67,7 +67,7 @@ allNodes = new Node[nodesSet.size()]; int i = 0; while (it.hasNext()) { - allNodes[i] = (Node) it.next(); + allNodes[i++] = (Node) it.next(); } isInit = true; } Added: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java?rev=209204&view=auto ============================================================================== --- jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java (added) +++ jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java Mon Jul 4 20:44:07 2005 @@ -0,0 +1,82 @@ +/* + * Copyright 2005 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; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.textui.TestRunner; + +import org.apache.commons.id.uuid.state.ReadOnlyResourceStateImpl; +import org.apache.commons.id.uuid.state.Node; + +/** + * Unit tests for {@link NodeManagerImpl}. + * + * @version $Revision$ $Date$ + * @author Commons-id team + */ +public class NodeManagerImplTest extends TestCase { + + /** Pre test value for ReadOnlyResourceStateImpl.CONFIG_FILE_KEY */ + private String currentConfigFile; + + + public NodeManagerImplTest(String name) { + super(name); + } + + public static void main(String[] args) { + TestRunner.run(suite()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(NodeManagerImplTest.class); + suite.setName("NodeManagerImpl Tests"); + return suite; + } + + protected void setUp() throws Exception { + super.setUp(); + currentConfigFile = System.getProperty( + ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY); + } + + protected void tearDown() throws Exception { + if (currentConfigFile != null) { + System.setProperty( + ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, + currentConfigFile); + } + super.tearDown(); + } + + public void testInit() throws Exception { + System.setProperty(ReadOnlyResourceStateImpl.CONFIG_FILENAME_KEY, + "uuid1.state"); // sets up 2 different nodes + NodeManagerImpl nodeManager = new NodeManagerImpl(); + nodeManager.init(); + Node node1 = nodeManager.currentNode(); + assertNotNull(node1); + Node node2 = nodeManager.nextAvailableNode(); + assertNotNull(node2); + assertFalse(node1.equals(node2)); + node2 = nodeManager.nextAvailableNode(); // should wrap back to node 1 + assertEquals(node1, node2); + } + +} Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: jakarta/commons/sandbox/id/trunk/src/test/org/apache/commons/id/uuid/NodeManagerImplTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org