1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package org.apache.commons.beanutils.locale; 19 20 21 import java.sql.Date; 22 import java.sql.Time; 23 import java.sql.Timestamp; 24 import java.text.DecimalFormat; 25 import java.text.NumberFormat; 26 import java.util.Locale; 27 28 import junit.framework.Test; 29 import junit.framework.TestCase; 30 import junit.framework.TestSuite; 31 32 import org.apache.commons.beanutils.ConversionException; 33 34 35 /** 36 * <p> 37 * Test Case for the LocaleConvertUtils class. 38 * See unimplemented functionality of the convert utils in the method begining with fixme 39 * </p> 40 * 41 * @version $Id$ 42 */ 43 44 public class LocaleConvertUtilsTestCase extends TestCase { 45 46 // ---------------------------------------------------- Instance Variables 47 48 private char m_decimalSeparator; 49 50 // ---------------------------------------------------------- Constructors 51 52 53 /** 54 * Construct a new instance of this test case. 55 * 56 * @param name Name of the test case 57 */ LocaleConvertUtilsTestCase(final String name)58 public LocaleConvertUtilsTestCase(final String name) { 59 super(name); 60 } 61 62 63 // -------------------------------------------------- Overall Test Methods 64 65 66 /** 67 * Set up instance variables required by this test case. 68 */ 69 @Override setUp()70 public void setUp() { 71 72 LocaleConvertUtils.deregister(); 73 74 final NumberFormat nf = DecimalFormat.getNumberInstance(); 75 final String result = nf.format(1.1); 76 77 // could be commas instead of stops in Europe. 78 m_decimalSeparator = result.charAt(1); 79 80 81 } 82 83 84 /** 85 * Return the tests included in this test suite. 86 */ suite()87 public static Test suite() { 88 return (new TestSuite(LocaleConvertUtilsTestCase.class)); 89 } 90 91 92 /** 93 * Tear down instance variables required by this test case. 94 */ 95 @Override tearDown()96 public void tearDown() { 97 // No action required 98 } 99 100 101 // ------------------------------------------------ Individual Test Methods 102 103 104 /** 105 * Negative String to primitive integer array tests. 106 */ fixmetestNegativeIntegerArray()107 public void fixmetestNegativeIntegerArray() { 108 109 fail("Array conversions not implemented yet."); 110 111 Object value = null; 112 final int intArray[] = new int[0]; 113 114 value = LocaleConvertUtils.convert((String) null, intArray.getClass()); 115 checkIntegerArray(value, intArray); 116 value = LocaleConvertUtils.convert("a", intArray.getClass()); 117 checkIntegerArray(value, intArray); 118 value = LocaleConvertUtils.convert("{ a }", intArray.getClass()); 119 checkIntegerArray(value, intArray); 120 value = LocaleConvertUtils.convert("1a3", intArray.getClass()); 121 checkIntegerArray(value, intArray); 122 value = LocaleConvertUtils.convert("{ 1a3 }", intArray.getClass()); 123 checkIntegerArray(value, intArray); 124 value = LocaleConvertUtils.convert("0,1a3", intArray.getClass()); 125 checkIntegerArray(value, intArray); 126 value = LocaleConvertUtils.convert("{ 0, 1a3 }", intArray.getClass()); 127 checkIntegerArray(value, intArray); 128 129 } 130 131 132 /** 133 * Negative scalar conversion tests. These rely on the standard 134 * default value conversions in LocaleConvertUtils. 135 */ testNegativeScalar()136 public void testNegativeScalar() { 137 138 /* fixme Boolean converters not implemented at this point 139 value = LocaleConvertUtils.convert("foo", Boolean.TYPE); 140 ... 141 142 value = LocaleConvertUtils.convert("foo", Boolean.class); 143 ... 144 */ 145 146 147 try { 148 LocaleConvertUtils.convert("foo", Byte.TYPE); 149 fail("Should have thrown conversion exception (1)"); 150 } catch (final ConversionException e) { 151 // Expected result 152 } 153 154 try { 155 LocaleConvertUtils.convert("foo", Byte.class); 156 fail("Should have thrown conversion exception (2)"); 157 } catch (final ConversionException e) { 158 // Expected result 159 } 160 161 /* fixme - not implemented 162 try { 163 value = LocaleConvertUtils.convert("org.apache.commons.beanutils.Undefined", Class.class); 164 fail("Should have thrown conversion exception"); 165 } catch (ConversionException e) { 166 ; // Expected result 167 } 168 */ 169 170 try { 171 LocaleConvertUtils.convert("foo", Double.TYPE); 172 fail("Should have thrown conversion exception (3)"); 173 } catch (final ConversionException e) { 174 // Expected result 175 } 176 177 try { 178 LocaleConvertUtils.convert("foo", Double.class); 179 fail("Should have thrown conversion exception (4)"); 180 } catch (final ConversionException e) { 181 // Expected result 182 } 183 184 try { 185 LocaleConvertUtils.convert("foo", Float.TYPE); 186 fail("Should have thrown conversion exception (5)"); 187 } catch (final ConversionException e) { 188 // Expected result 189 } 190 191 try { 192 LocaleConvertUtils.convert("foo", Float.class); 193 fail("Should have thrown conversion exception (6)"); 194 } catch (final ConversionException e) { 195 // Expected result 196 } 197 198 try { 199 LocaleConvertUtils.convert("foo", Integer.TYPE); 200 fail("Should have thrown conversion exception (7)"); 201 } catch (final ConversionException e) { 202 // Expected result 203 } 204 205 try { 206 LocaleConvertUtils.convert("foo", Integer.class); 207 fail("Should have thrown conversion exception (8)"); 208 } catch (final ConversionException e) { 209 // Expected result 210 } 211 212 try { 213 LocaleConvertUtils.convert("foo", Byte.TYPE); 214 fail("Should have thrown conversion exception (9)"); 215 } catch (final ConversionException e) { 216 // Expected result 217 } 218 219 try { 220 LocaleConvertUtils.convert("foo", Long.class); 221 fail("Should have thrown conversion exception (10)"); 222 } catch (final ConversionException e) { 223 // Expected result 224 } 225 226 try { 227 LocaleConvertUtils.convert("foo", Short.TYPE); 228 fail("Should have thrown conversion exception (11)"); 229 } catch (final ConversionException e) { 230 // Expected result 231 } 232 233 try { 234 LocaleConvertUtils.convert("foo", Short.class); 235 fail("Should have thrown conversion exception (12)"); 236 } catch (final ConversionException e) { 237 // Expected result 238 } 239 240 } 241 242 243 /** 244 * Negative String to String array tests. 245 */ fixmetestNegativeStringArray()246 public void fixmetestNegativeStringArray() { 247 248 fail("Array conversions not implemented yet."); 249 250 Object value = null; 251 final String stringArray[] = new String[0]; 252 253 value = LocaleConvertUtils.convert((String) null, stringArray.getClass()); 254 checkStringArray(value, stringArray); 255 } 256 257 258 /** 259 * Test conversion of object to string for arrays - . 260 */ fixmetestObjectToStringArray()261 public void fixmetestObjectToStringArray() { 262 263 fail("Array conversions not implemented yet."); 264 final int intArray0[] = new int[0]; 265 final int intArray1[] = {123}; 266 final int intArray2[] = {123, 456}; 267 final String stringArray0[] = new String[0]; 268 final String stringArray1[] = {"abc"}; 269 final String stringArray2[] = {"abc", "def"}; 270 271 assertEquals("intArray0", null, 272 LocaleConvertUtils.convert(intArray0)); 273 assertEquals("intArray1", "123", 274 LocaleConvertUtils.convert(intArray1)); 275 assertEquals("intArray2", "123", 276 LocaleConvertUtils.convert(intArray2)); 277 278 assertEquals("stringArray0", null, 279 LocaleConvertUtils.convert(stringArray0)); 280 assertEquals("stringArray1", "abc", 281 LocaleConvertUtils.convert(stringArray1)); 282 assertEquals("stringArray2", "abc", 283 LocaleConvertUtils.convert(stringArray2)); 284 285 } 286 287 288 /** 289 * Test conversion of object to string for scalars. 290 */ testObjectToStringScalar()291 public void testObjectToStringScalar() { 292 293 assertEquals("Boolean->String", "false", 294 LocaleConvertUtils.convert(Boolean.FALSE)); 295 assertEquals("Boolean->String", "true", 296 LocaleConvertUtils.convert(Boolean.TRUE)); 297 assertEquals("Byte->String", "123", 298 LocaleConvertUtils.convert(new Byte((byte) 123))); 299 assertEquals("Character->String", "a", 300 LocaleConvertUtils.convert(new Character('a'))); 301 assertEquals("Double->String", "123" + m_decimalSeparator + "4", 302 LocaleConvertUtils.convert(new Double(123.4))); 303 assertEquals("Float->String", "123" + m_decimalSeparator + "4", 304 LocaleConvertUtils.convert(new Float((float) 123.4))); 305 assertEquals("Integer->String", "123", 306 LocaleConvertUtils.convert(new Integer(123))); 307 assertEquals("Long->String", "123", 308 LocaleConvertUtils.convert(new Long(123))); 309 assertEquals("Short->String", "123", 310 LocaleConvertUtils.convert(new Short((short) 123))); 311 assertEquals("String->String", "abc", 312 LocaleConvertUtils.convert("abc")); 313 assertEquals("String->String null", null, 314 LocaleConvertUtils.convert(null)); 315 316 } 317 318 319 /** 320 * Positive array conversion tests. 321 */ fixmetestPositiveArray()322 public void fixmetestPositiveArray() { 323 324 fail("Array conversions not implemented yet."); 325 326 final String values1[] = {"10", "20", "30"}; 327 Object value = LocaleConvertUtils.convert(values1, Integer.TYPE); 328 final int shape[] = new int[0]; 329 assertEquals(shape.getClass(), value.getClass()); 330 final int results1[] = (int[]) value; 331 assertEquals(results1[0], 10); 332 assertEquals(results1[1], 20); 333 assertEquals(results1[2], 30); 334 335 final String values2[] = {"100", "200", "300"}; 336 value = LocaleConvertUtils.convert(values2, shape.getClass()); 337 assertEquals(shape.getClass(), value.getClass()); 338 final int results2[] = (int[]) value; 339 assertEquals(results2[0], 100); 340 assertEquals(results2[1], 200); 341 assertEquals(results2[2], 300); 342 } 343 344 345 /** 346 * Positive String to primitive integer array tests. 347 */ fixmetestPositiveIntegerArray()348 public void fixmetestPositiveIntegerArray() { 349 350 fail("Array conversions not implemented yet."); 351 352 Object value = null; 353 final int intArray[] = new int[0]; 354 final int intArray1[] = new int[]{0}; 355 final int intArray2[] = new int[]{0, 10}; 356 357 value = LocaleConvertUtils.convert("{ }", intArray.getClass()); 358 checkIntegerArray(value, intArray); 359 360 value = LocaleConvertUtils.convert("0", intArray.getClass()); 361 checkIntegerArray(value, intArray1); 362 value = LocaleConvertUtils.convert(" 0 ", intArray.getClass()); 363 checkIntegerArray(value, intArray1); 364 value = LocaleConvertUtils.convert("{ 0 }", intArray.getClass()); 365 checkIntegerArray(value, intArray1); 366 367 value = LocaleConvertUtils.convert("0,10", intArray.getClass()); 368 checkIntegerArray(value, intArray2); 369 value = LocaleConvertUtils.convert("0 10", intArray.getClass()); 370 checkIntegerArray(value, intArray2); 371 value = LocaleConvertUtils.convert("{0,10}", intArray.getClass()); 372 checkIntegerArray(value, intArray2); 373 value = LocaleConvertUtils.convert("{0 10}", intArray.getClass()); 374 checkIntegerArray(value, intArray2); 375 value = LocaleConvertUtils.convert("{ 0, 10 }", intArray.getClass()); 376 checkIntegerArray(value, intArray2); 377 value = LocaleConvertUtils.convert("{ 0 10 }", intArray.getClass()); 378 checkIntegerArray(value, intArray2); 379 } 380 381 382 /** 383 * Positive scalar conversion tests. 384 */ testPositiveScalar()385 public void testPositiveScalar() { 386 Object value = null; 387 388 /* fixme Boolean converters not implemented 389 value = LocaleConvertUtils.convert("true", Boolean.TYPE); 390 assertTrue(value instanceof Boolean); 391 assertEquals(((Boolean) value).booleanValue(), true); 392 393 value = LocaleConvertUtils.convert("true", Boolean.class); 394 assertTrue(value instanceof Boolean); 395 assertEquals(((Boolean) value).booleanValue(), true); 396 397 value = LocaleConvertUtils.convert("yes", Boolean.TYPE); 398 assertTrue(value instanceof Boolean); 399 assertEquals(((Boolean) value).booleanValue(), true); 400 401 value = LocaleConvertUtils.convert("yes", Boolean.class); 402 assertTrue(value instanceof Boolean); 403 assertEquals(((Boolean) value).booleanValue(), true); 404 405 value = LocaleConvertUtils.convert("y", Boolean.TYPE); 406 assertTrue(value instanceof Boolean); 407 assertEquals(((Boolean) value).booleanValue(), true); 408 409 value = LocaleConvertUtils.convert("y", Boolean.class); 410 assertTrue(value instanceof Boolean); 411 assertEquals(((Boolean) value).booleanValue(), true); 412 413 value = LocaleConvertUtils.convert("on", Boolean.TYPE); 414 assertTrue(value instanceof Boolean); 415 assertEquals(((Boolean) value).booleanValue(), true); 416 417 value = LocaleConvertUtils.convert("on", Boolean.class); 418 assertTrue(value instanceof Boolean); 419 assertEquals(((Boolean) value).booleanValue(), true); 420 421 value = LocaleConvertUtils.convert("false", Boolean.TYPE); 422 assertTrue(value instanceof Boolean); 423 assertEquals(((Boolean) value).booleanValue(), false); 424 425 value = LocaleConvertUtils.convert("false", Boolean.class); 426 assertTrue(value instanceof Boolean); 427 assertEquals(((Boolean) value).booleanValue(), false); 428 429 value = LocaleConvertUtils.convert("no", Boolean.TYPE); 430 assertTrue(value instanceof Boolean); 431 assertEquals(((Boolean) value).booleanValue(), false); 432 433 value = LocaleConvertUtils.convert("no", Boolean.class); 434 assertTrue(value instanceof Boolean); 435 assertEquals(((Boolean) value).booleanValue(), false); 436 437 value = LocaleConvertUtils.convert("n", Boolean.TYPE); 438 assertTrue(value instanceof Boolean); 439 assertEquals(((Boolean) value).booleanValue(), false); 440 441 value = LocaleConvertUtils.convert("n", Boolean.class); 442 assertTrue(value instanceof Boolean); 443 assertEquals(((Boolean) value).booleanValue(), false); 444 445 value = LocaleConvertUtils.convert("off", Boolean.TYPE); 446 assertTrue(value instanceof Boolean); 447 assertEquals(((Boolean) value).booleanValue(), false); 448 449 value = LocaleConvertUtils.convert("off", Boolean.class); 450 assertTrue(value instanceof Boolean); 451 assertEquals(((Boolean) value).booleanValue(), false); 452 */ 453 454 value = LocaleConvertUtils.convert("123", Byte.TYPE); 455 assertTrue(value instanceof Byte); 456 assertEquals(((Byte) value).byteValue(), (byte) 123); 457 458 value = LocaleConvertUtils.convert("123", Byte.class); 459 assertTrue(value instanceof Byte); 460 assertEquals(((Byte) value).byteValue(), (byte) 123); 461 462 /*fixme Character conversion not implemented yet 463 value = LocaleConvertUtils.convert("a", Character.TYPE); 464 assertTrue(value instanceof Character); 465 assertEquals(((Character) value).charValue(), 'a'); 466 467 value = LocaleConvertUtils.convert("a", Character.class); 468 assertTrue(value instanceof Character); 469 assertEquals(((Character) value).charValue(), 'a'); 470 */ 471 /* fixme - this is a discrepancy with standard converters ( probably not major issue ) 472 value = LocaleConvertUtils.convert("java.lang.String", Class.class); 473 assertTrue(value instanceof Class); 474 assertEquals(String.class, (Class) value); 475 */ 476 477 value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Double.TYPE); 478 assertTrue(value instanceof Double); 479 assertEquals(((Double) value).doubleValue(), 123.456, 0.005); 480 481 value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Double.class); 482 assertTrue(value instanceof Double); 483 assertEquals(((Double) value).doubleValue(), 123.456, 0.005); 484 485 value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Float.TYPE); 486 assertTrue(value instanceof Float); 487 assertEquals(((Float) value).floatValue(), (float) 123.456, 488 (float) 0.005); 489 490 value = LocaleConvertUtils.convert("123" + m_decimalSeparator + "456", Float.class); 491 assertTrue(value instanceof Float); 492 assertEquals(((Float) value).floatValue(), (float) 123.456, 493 (float) 0.005); 494 495 value = LocaleConvertUtils.convert("123", Integer.TYPE); 496 assertTrue(value instanceof Integer); 497 assertEquals(((Integer) value).intValue(), 123); 498 499 value = LocaleConvertUtils.convert("123", Integer.class); 500 assertTrue(value instanceof Integer); 501 assertEquals(((Integer) value).intValue(), 123); 502 503 value = LocaleConvertUtils.convert("123", Long.TYPE); 504 assertTrue(value instanceof Long); 505 assertEquals(((Long) value).longValue(), 123); 506 507 value = LocaleConvertUtils.convert("123456", Long.class); 508 assertTrue(value instanceof Long); 509 assertEquals(((Long) value).longValue(), 123456); 510 511 /* fixme - Short conversion not implemented at this point 512 value = LocaleConvertUtils.convert("123", Short.TYPE); 513 assertTrue(value instanceof Short); 514 assertEquals(((Short) value).shortValue(), (short) 123); 515 516 value = LocaleConvertUtils.convert("123", Short.class); 517 assertTrue(value instanceof Short); 518 assertEquals(((Short) value).shortValue(), (short) 123); 519 */ 520 521 String input = null; 522 523 input = "2002-03-17"; 524 value = LocaleConvertUtils.convert(input, Date.class); 525 assertTrue(value instanceof Date); 526 assertEquals(input, value.toString()); 527 528 input = "20:30:40"; 529 value = LocaleConvertUtils.convert(input, Time.class); 530 assertTrue(value instanceof Time); 531 assertEquals(input, value.toString()); 532 533 input = "2002-03-17 20:30:40.0"; 534 value = LocaleConvertUtils.convert(input, Timestamp.class); 535 assertTrue(value instanceof Timestamp); 536 assertEquals(input, value.toString()); 537 538 } 539 540 541 /** 542 * Positive String to String array tests. 543 */ fixmetestPositiveStringArray()544 public void fixmetestPositiveStringArray() { 545 546 fail("Array conversions not implemented yet."); 547 548 Object value = null; 549 final String stringArray[] = new String[0]; 550 final String stringArray1[] = new String[] 551 {"abc"}; 552 final String stringArray2[] = new String[] 553 {"abc", "de,f"}; 554 555 value = LocaleConvertUtils.convert("", stringArray.getClass()); 556 checkStringArray(value, stringArray); 557 value = LocaleConvertUtils.convert(" ", stringArray.getClass()); 558 checkStringArray(value, stringArray); 559 value = LocaleConvertUtils.convert("{}", stringArray.getClass()); 560 checkStringArray(value, stringArray); 561 value = LocaleConvertUtils.convert("{ }", stringArray.getClass()); 562 checkStringArray(value, stringArray); 563 564 value = LocaleConvertUtils.convert("abc", stringArray.getClass()); 565 checkStringArray(value, stringArray1); 566 value = LocaleConvertUtils.convert("{abc}", stringArray.getClass()); 567 checkStringArray(value, stringArray1); 568 value = LocaleConvertUtils.convert("\"abc\"", stringArray.getClass()); 569 checkStringArray(value, stringArray1); 570 value = LocaleConvertUtils.convert("{\"abc\"}", stringArray.getClass()); 571 checkStringArray(value, stringArray1); 572 value = LocaleConvertUtils.convert("'abc'", stringArray.getClass()); 573 checkStringArray(value, stringArray1); 574 value = LocaleConvertUtils.convert("{'abc'}", stringArray.getClass()); 575 checkStringArray(value, stringArray1); 576 577 value = LocaleConvertUtils.convert("abc 'de,f'", 578 stringArray.getClass()); 579 checkStringArray(value, stringArray2); 580 value = LocaleConvertUtils.convert("{abc, 'de,f'}", 581 stringArray.getClass()); 582 checkStringArray(value, stringArray2); 583 value = LocaleConvertUtils.convert("\"abc\",\"de,f\"", 584 stringArray.getClass()); 585 checkStringArray(value, stringArray2); 586 value = LocaleConvertUtils.convert("{\"abc\" 'de,f'}", 587 stringArray.getClass()); 588 checkStringArray(value, stringArray2); 589 value = LocaleConvertUtils.convert("'abc' 'de,f'", 590 stringArray.getClass()); 591 checkStringArray(value, stringArray2); 592 value = LocaleConvertUtils.convert("{'abc', \"de,f\"}", 593 stringArray.getClass()); 594 checkStringArray(value, stringArray2); 595 596 } 597 598 /** 599 * Test conversion of a String using a Locale and pattern. 600 */ testConvertStringLocaleNull()601 public void testConvertStringLocaleNull() { 602 Object result = null; 603 try { 604 result = LocaleConvertUtils.convert("123", Integer.class, (Locale)null, "#,###"); 605 } catch (final Exception e) { 606 e.printStackTrace(); 607 fail("Threw: " + e); 608 } 609 assertNotNull("Null Result", result); 610 assertEquals("Integer Type", Integer.class, result.getClass()); 611 assertEquals("Integer Value", new Integer(123), result); 612 } 613 614 /** 615 * Test conversion of a String array using a Locale and pattern. 616 */ testConvertStringArrayLocaleNull()617 public void testConvertStringArrayLocaleNull() { 618 Object result = null; 619 try { 620 result = LocaleConvertUtils.convert(new String[] {"123"}, Integer[].class, (Locale)null, "#,###"); 621 } catch (final Exception e) { 622 e.printStackTrace(); 623 fail("Threw: " + e); 624 } 625 assertNotNull("Null Result", result); 626 assertEquals("Integer Array Type", Integer[].class, result.getClass()); 627 assertEquals("Integer Array Length", 1, ((Integer[])result).length); 628 assertEquals("Integer Array Value", new Integer(123), ((Integer[])result)[0]); 629 } 630 631 /** 632 * Tests a conversion if there is no suitable converter registered. In this 633 * case, the string converter is used, and the passed in target type is 634 * ignored. (This test is added to prevent a regression after the locale 635 * converters have been generified.) 636 */ testDefaultToStringConversionUnsupportedType()637 public void testDefaultToStringConversionUnsupportedType() { 638 final Integer value = 20131101; 639 assertEquals("Wrong result", value.toString(), 640 LocaleConvertUtils.convert(value.toString(), getClass())); 641 } 642 643 // -------------------------------------------------------- Private Methods 644 645 checkIntegerArray(final Object value, final int intArray[])646 private void checkIntegerArray(final Object value, final int intArray[]) { 647 648 assertNotNull("Returned value is not null", value); 649 assertEquals("Returned value is int[]", 650 intArray.getClass(), value.getClass()); 651 final int results[] = (int[]) value; 652 assertEquals("Returned array length", intArray.length, results.length); 653 for (int i = 0; i < intArray.length; i++) { 654 assertEquals("Returned array value " + i, 655 intArray[i], results[i]); 656 } 657 658 } 659 660 checkStringArray(final Object value, final String stringArray[])661 private void checkStringArray(final Object value, final String stringArray[]) { 662 663 assertNotNull("Returned value is not null", value); 664 assertEquals("Returned value is String[]", 665 stringArray.getClass(), value.getClass()); 666 final String results[] = (String[]) value; 667 assertEquals("Returned array length", 668 stringArray.length, results.length); 669 for (int i = 0; i < stringArray.length; i++) { 670 assertEquals("Returned array value " + i, 671 stringArray[i], results[i]); 672 } 673 674 } 675 676 677 } 678 679