Java Code Examples for java.util.Locale#getUnicodeLocaleAttributes()

The following examples show how to use java.util.Locale#getUnicodeLocaleAttributes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocaleEnhanceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 2
Source File: LocaleEnhanceTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 3
Source File: LocaleEnhanceTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 4
Source File: LocaleEnhanceTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 5
Source File: LocaleEnhanceTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 6
Source File: LocaleEnhanceTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 7
Source File: LocaleEnhanceTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 8
Source File: LocaleEnhanceTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 9
Source File: LocaleEnhanceTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 10
Source File: LocaleEnhanceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 11
Source File: LocaleEnhanceTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 12
Source File: LocaleEnhanceTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 13
Source File: LocaleEnhanceTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 14
Source File: LocaleEnhanceTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 15
Source File: LocaleEnhanceTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 16
Source File: LocaleEnhanceTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 17
Source File: LocaleEnhanceTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 18
Source File: LocaleEnhanceTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}
 
Example 19
Source File: LocaleEnhanceTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void testGetUnicodeLocaleAttributes() {
    Locale locale = Locale.forLanguageTag("en-US-u-abc-def");
    Set<String> attributes = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, attributes.size());
    assertTrue("attribute abc", attributes.contains("abc"));
    assertTrue("attribute def", attributes.contains("def"));

    locale = Locale.forLanguageTag("en-US-u-ca-gregory");
    attributes = locale.getUnicodeLocaleAttributes();
    assertTrue("empty attributes", attributes.isEmpty());
}
 
Example 20
Source File: LocaleEnhanceTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testBuilderAddUnicodeLocaleAttribute() {
    Builder builder = new Builder();
    Locale locale = builder
        .addUnicodeLocaleAttribute("def")
        .addUnicodeLocaleAttribute("abc")
        .build();

    Set<String> uattrs = locale.getUnicodeLocaleAttributes();
    assertEquals("number of attributes", 2, uattrs.size());
    assertTrue("attribute abc", uattrs.contains("abc"));
    assertTrue("attribute def", uattrs.contains("def"));

    // remove attribute
    locale = builder.removeUnicodeLocaleAttribute("xxx")
        .build();

    assertEquals("remove bogus", 2, uattrs.size());

    // add duplicate
    locale = builder.addUnicodeLocaleAttribute("abc")
        .build();
    assertEquals("add duplicate", 2, uattrs.size());

    // null attribute throws NPE
    new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};

    // illformed attribute throws IllformedLocaleException
    new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
}