< prev index next >

test/jdk/java/util/PluggableLocale/DateFormatProviderTest.java

Print this page


   1 /*
   2  * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */

  23 /*
  24  *









  25  */
  26 
  27 import java.text.*;
  28 import java.util.*;
  29 import sun.util.locale.provider.*;
  30 import sun.util.resources.*;













  31 
  32 public class DateFormatProviderTest extends ProviderTest {
  33 
  34     com.foo.DateFormatProviderImpl dfp = new com.foo.DateFormatProviderImpl();
  35     List<Locale> availloc = Arrays.asList(DateFormat.getAvailableLocales());
  36     List<Locale> providerloc = Arrays.asList(dfp.getAvailableLocales());
  37     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  38     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getDateFormatProvider().getAvailableLocales());
  39 
  40     public static void main(String[] s) {
  41         new DateFormatProviderTest();
  42     }
  43 
  44     DateFormatProviderTest() {
  45         availableLocalesTest();
  46         objectValidityTest();
  47         extendedVariantTest();
  48         messageFormatTest();
  49     }
  50 
  51     void availableLocalesTest() {
  52         Set<Locale> localesFromAPI = new HashSet<>(availloc);
  53         Set<Locale> localesExpected = new HashSet<>(jreloc);
  54         localesExpected.addAll(providerloc);


   1 /*
   2  * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 4052440 7003643 8062588 8210406
  27  * @summary DateFormatProvider tests
  28  * @library providersrc/foobarutils
  29  *          providersrc/fooprovider
  30  * @modules java.base/sun.util.locale.provider
  31  *          java.base/sun.util.resources
  32  * @build com.foobar.Utils
  33  *        com.foo.*
  34  * @run main/othervm -Djava.locale.providers=JRE,SPI DateFormatProviderTest
  35  */
  36 
  37 import java.text.DateFormat;
  38 import java.text.Format;
  39 import java.text.MessageFormat;
  40 import java.text.SimpleDateFormat;
  41 import java.util.Arrays;
  42 import java.util.Calendar;
  43 import java.util.HashSet;
  44 import java.util.List;
  45 import java.util.Locale;
  46 import java.util.MissingResourceException;
  47 import java.util.ResourceBundle;
  48 import java.util.Set;
  49 
  50 import com.foo.DateFormatProviderImpl;
  51 
  52 import sun.util.locale.provider.LocaleProviderAdapter;
  53 import sun.util.locale.provider.ResourceBundleBasedAdapter;
  54 
  55 public class DateFormatProviderTest extends ProviderTest {
  56 
  57     DateFormatProviderImpl dfp = new DateFormatProviderImpl();
  58     List<Locale> availloc = Arrays.asList(DateFormat.getAvailableLocales());
  59     List<Locale> providerloc = Arrays.asList(dfp.getAvailableLocales());
  60     List<Locale> jreloc = Arrays.asList(LocaleProviderAdapter.forJRE().getAvailableLocales());
  61     List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getDateFormatProvider().getAvailableLocales());
  62 
  63     public static void main(String[] s) {
  64         new DateFormatProviderTest();
  65     }
  66 
  67     DateFormatProviderTest() {
  68         availableLocalesTest();
  69         objectValidityTest();
  70         extendedVariantTest();
  71         messageFormatTest();
  72     }
  73 
  74     void availableLocalesTest() {
  75         Set<Locale> localesFromAPI = new HashSet<>(availloc);
  76         Set<Locale> localesExpected = new HashSet<>(jreloc);
  77         localesExpected.addAll(providerloc);


< prev index next >