< prev index next >

test/jdk/java/text/Format/MessageFormat/MessageTest.java

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 21,12 ***
   * questions.
   */
  
  /*
   * @test
-  * @library /java/text/testlib
   * @summary test MessageFormat
   */
  /*
  (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
  (C) Copyright IBM Corp. 1996 - All Rights Reserved
  
--- 21,12 ---
   * questions.
   */
  
  /*
   * @test
   * @summary test MessageFormat
+  * @run junit MessageTest
   */
  /*
  (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
  (C) Copyright IBM Corp. 1996 - All Rights Reserved
  

*** 41,17 ***
  
  import java.util.*;
  import java.io.*;
  import java.text.*;
  
! public class MessageTest extends IntlTest {
  
!     public static void main(String[] args) throws Exception {
!         new MessageTest().run(args);
!     }
  
  
     public void TestMSGPatternTest() {
          Object[] testArgs = {
               1D, 3456D,
              "Disk", new Date(10000000000L)};
  
--- 41,18 ---
  
  import java.util.*;
  import java.io.*;
  import java.text.*;
  
! import org.junit.jupiter.api.Test;
  
! import static org.junit.jupiter.api.Assertions.fail;
! 
! public class MessageTest {
  
  
+     @Test
     public void TestMSGPatternTest() {
          Object[] testArgs = {
               1D, 3456D,
              "Disk", new Date(10000000000L)};
  

*** 69,27 ***
  
          for (int i = 0; i < testCases.length; ++i) {
              Locale save = Locale.getDefault();
              try {
                  Locale.setDefault(Locale.US);
!                 logln("");
!                 logln( i + " Pat in:  " + testCases[i]);
                  MessageFormat form = new MessageFormat(testCases[i]);
!                 logln( i + " Pat out: " + form.toPattern());
                  String result = form.format(testArgs);
!                 logln( i + " Result:  " + result);
                  Object[] values = form.parse(result);
                  for (int j = 0; j < testArgs.length; ++j) {
                      Object testArg = testArgs[j];
                      Object value = null;
                      if (j < values.length) {
                          value = values[j];
                      }
                      if ((testArg == null && value != null)
                          || (testArg != null && !testArg.equals(value))) {
!                        logln( i + " " + j + " old: " + testArg);
!                        logln( i + " " + j + " new: " + value);
                      }
                  }
              }
              catch(java.text.ParseException pe ) {
                  throw new RuntimeException("Error: MessageFormat.parse throws ParseException");
--- 70,27 ---
  
          for (int i = 0; i < testCases.length; ++i) {
              Locale save = Locale.getDefault();
              try {
                  Locale.setDefault(Locale.US);
!                 System.out.println("");
!                 System.out.println( i + " Pat in:  " + testCases[i]);
                  MessageFormat form = new MessageFormat(testCases[i]);
!                 System.out.println( i + " Pat out: " + form.toPattern());
                  String result = form.format(testArgs);
!                 System.out.println( i + " Result:  " + result);
                  Object[] values = form.parse(result);
                  for (int j = 0; j < testArgs.length; ++j) {
                      Object testArg = testArgs[j];
                      Object value = null;
                      if (j < values.length) {
                          value = values[j];
                      }
                      if ((testArg == null && value != null)
                          || (testArg != null && !testArg.equals(value))) {
!                        System.out.println( i + " " + j + " old: " + testArg);
!                        System.out.println( i + " " + j + " new: " + value);
                      }
                  }
              }
              catch(java.text.ParseException pe ) {
                  throw new RuntimeException("Error: MessageFormat.parse throws ParseException");
< prev index next >