Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 64729 invoked from network); 28 Aug 2005 20:23:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 28 Aug 2005 20:23:31 -0000 Received: (qmail 32377 invoked by uid 500); 28 Aug 2005 20:23:31 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 32320 invoked by uid 500); 28 Aug 2005 20:23:29 -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 32307 invoked by uid 500); 28 Aug 2005 20:23:29 -0000 Received: (qmail 32303 invoked by uid 99); 28 Aug 2005 20:23:29 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,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; Sun, 28 Aug 2005 13:23:28 -0700 Received: (qmail 64714 invoked by uid 65534); 28 Aug 2005 20:23:28 -0000 Message-ID: <20050828202328.64713.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r263912 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/text/StrTokenizer.java test/org/apache/commons/lang/text/StrTokenizerTest.java Date: Sun, 28 Aug 2005 20:23:27 -0000 To: commons-cvs@jakarta.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ggregory Date: Sun Aug 28 13:23:22 2005 New Revision: 263912 URL: http://svn.apache.org/viewcvs?rev=263912&view=rev Log: clone method is now full covered in unit tests. Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrTokenizerTest.java Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java?rev=263912&r1=263911&r2=263912&view=diff ============================================================================== --- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java (original) +++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/StrTokenizer.java Sun Aug 28 13:23:22 2005 @@ -1048,22 +1048,32 @@ //----------------------------------------------------------------------- /** - * Creates a new instance of this Tokenizer. - * The new instance is reset so that it will be at the start of the token list. + * Creates a new instance of this Tokenizer. The new instance is reset so that it will be at the start of the token + * list. If a {@link CloneNotSupportedException} is caught, return null. + * * @return a new instance of this Tokenizer which has been reset. */ public Object clone() { try { - StrTokenizer cloned = (StrTokenizer) super.clone(); - if (cloned.chars != null) { - cloned.chars = (char[]) cloned.chars.clone(); - } - cloned.reset(); - return cloned; - + return cloneReset(); } catch (CloneNotSupportedException ex) { return null; } + } + + /** + * Creates a new instance of this Tokenizer. The new instance is reset so that it will be at the start of the token + * list. + * + * @return a new instance of this Tokenizer which has been reset. + */ + protected Object cloneReset() throws CloneNotSupportedException { + StrTokenizer cloned = (StrTokenizer) super.clone(); + if (cloned.chars != null) { + cloned.chars = (char[]) cloned.chars.clone(); + } + cloned.reset(); + return cloned; } } Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrTokenizerTest.java URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrTokenizerTest.java?rev=263912&r1=263911&r2=263912&view=diff ============================================================================== --- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrTokenizerTest.java (original) +++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/StrTokenizerTest.java Sun Aug 28 13:23:22 2005 @@ -542,6 +542,19 @@ assertEquals(tok, tok.setIgnoreEmptyTokens(false)); } + /** + * Tests that the {@link StrTokenizer#clone()} clone method catches {@link CloneNotSupportedException} and returns + * null. + */ + public void testCloneNotSupportedException() { + Object notCloned = (new StrTokenizer() { + public Object cloneReset() throws CloneNotSupportedException { + throw new CloneNotSupportedException("test"); + } + }).clone(); + assertNull(notCloned); + } + public void testCloneNull() { StrTokenizer tokenizer = new StrTokenizer((char[]) null); // Start sanity check --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org