This project has retired. For details please refer to its
Attic page.
LocalizedStringTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ws.scout.registry.infomodel;
18
19 import java.util.Locale;
20
21 import javax.xml.registry.JAXRException;
22 import javax.xml.registry.infomodel.LocalizedString;
23
24 import junit.framework.TestCase;
25
26
27
28
29 public class LocalizedStringTest extends TestCase {
30 public void testEquals() {
31 LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "Equal", "UTF-8");
32 LocalizedString ls2 = new LocalizedStringImpl(Locale.US, "Equal", "UTF-8");
33 assertTrue(ls1.equals(ls2));
34 assertTrue(ls2.equals(ls1));
35 ls2 = new LocalizedStringImpl(Locale.US, "NotEqual", "UTF-8");
36 assertFalse(ls1.equals(ls2));
37 assertFalse(ls2.equals(ls1));
38 ls2 = new LocalizedStringImpl(Locale.US, "Equal", "US-ASCII");
39 assertFalse(ls1.equals(ls2));
40 assertFalse(ls2.equals(ls1));
41 }
42
43 public void testNullEquals() {
44 LocalizedString ls1 = new LocalizedStringImpl(Locale.US, null, "UTF-8");
45 LocalizedString ls2 = new LocalizedStringImpl(Locale.US, null, "UTF-8");
46 assertTrue(ls1.equals(ls2));
47 assertTrue(ls2.equals(ls1));
48 ls2 = new LocalizedStringImpl(Locale.US, "NotEqual", "UTF-8");
49 assertFalse(ls1.equals(ls2));
50 assertFalse(ls2.equals(ls1));
51 ls2 = new LocalizedStringImpl(Locale.US, null, "US-ASCII");
52 assertFalse(ls1.equals(ls2));
53 assertFalse(ls2.equals(ls1));
54 }
55
56 public void testSetCharsetName() throws JAXRException {
57 LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "USA", "UTF-8");
58 assertEquals("UTF-8", ls1.getCharsetName());
59 ls1.setCharsetName("US-ASCII");
60 assertEquals("US-ASCII", ls1.getCharsetName());
61 try {
62 ls1.setCharsetName(null);
63 fail("expected IllegalArgumentException for null charsetName");
64 } catch (IllegalArgumentException e) {
65
66 }
67 }
68
69 public void testSetLocale() throws JAXRException {
70 LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "USA", "UTF-8");
71 assertEquals(Locale.US, ls1.getLocale());
72 ls1.setLocale(Locale.CANADA);
73 assertEquals(Locale.CANADA, ls1.getLocale());
74 try {
75 ls1.setLocale(null);
76 fail("expected IllegalArgumentException for null locale");
77 } catch (IllegalArgumentException e) {
78
79 }
80 }
81
82 public void testSetValue() throws JAXRException {
83 LocalizedString ls1 = new LocalizedStringImpl(Locale.US, "USA", "UTF-8");
84 assertEquals("USA", ls1.getValue());
85 ls1.setValue("Foo");
86 assertEquals("Foo", ls1.getValue());
87 ls1.setValue(null);
88 assertNull(ls1.getValue());
89 }
90 }