Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ED798D4D6 for ; Mon, 10 Sep 2012 23:59:15 +0000 (UTC) Received: (qmail 25720 invoked by uid 500); 10 Sep 2012 23:59:15 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 25663 invoked by uid 500); 10 Sep 2012 23:59:15 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 25653 invoked by uid 99); 10 Sep 2012 23:59:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2012 23:59:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Sep 2012 23:59:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BAB902388A33 for ; Mon, 10 Sep 2012 23:58:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1383170 - /commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java Date: Mon, 10 Sep 2012 23:58:29 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120910235829.BAB902388A33@eris.apache.org> Author: sebb Date: Mon Sep 10 23:58:29 2012 New Revision: 1383170 URL: http://svn.apache.org/viewvc?rev=1383170&view=rev Log: Use valid input for testing byte conversion, as behaviour for invalid input is undefined. Fixes test failure with IBM Java 1.6 Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java?rev=1383170&r1=1383169&r2=1383170&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java (original) +++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java Mon Sep 10 23:58:29 2012 @@ -33,6 +33,12 @@ public class StringUtilsTest { private static final byte[] BYTES_FIXTURE = {'a','b','c'}; + // This is valid input for UTF-16BE + private static final byte[] BYTES_FIXTURE_16BE = {0, 'a', 0, 'b', 0, 'c'}; + + // This is valid for UTF-16LE + private static final byte[] BYTES_FIXTURE_16LE = {'a', 0, 'b', 0, 'c', 0}; + private static final String STRING_FIXTURE = "ABC"; /** @@ -171,8 +177,8 @@ public class StringUtilsTest { public void testNewStringUtf16Be() throws UnsupportedEncodingException { String charsetName = "UTF-16BE"; testNewString(charsetName); - String expected = new String(BYTES_FIXTURE, charsetName); - String actual = StringUtils.newStringUtf16Be(BYTES_FIXTURE); + String expected = new String(BYTES_FIXTURE_16BE, charsetName); + String actual = StringUtils.newStringUtf16Be(BYTES_FIXTURE_16BE); Assert.assertEquals(expected, actual); } @@ -180,8 +186,8 @@ public class StringUtilsTest { public void testNewStringUtf16Le() throws UnsupportedEncodingException { String charsetName = "UTF-16LE"; testNewString(charsetName); - String expected = new String(BYTES_FIXTURE, charsetName); - String actual = StringUtils.newStringUtf16Le(BYTES_FIXTURE); + String expected = new String(BYTES_FIXTURE_16LE, charsetName); + String actual = StringUtils.newStringUtf16Le(BYTES_FIXTURE_16LE); Assert.assertEquals(expected, actual); }