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

The following examples show how to use java.util.Locale#getUnicodeLocaleAttributes() . These examples are extracted from open source projects. 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
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
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
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
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
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
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
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 8
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
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
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 11
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
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 13
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
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
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 16
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
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
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
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
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"); }};
}