4 package jp.sfjp.mikutoga.corelib;
7 import java.util.Locale;
8 import org.junit.After;
9 import org.junit.AfterClass;
10 import org.junit.Before;
11 import org.junit.BeforeClass;
12 import org.junit.Test;
13 import static org.junit.Assert.*;
18 public class I18nTextTest {
20 public I18nTextTest() {
24 public static void setUpClass() {
28 public static void tearDownClass() {
36 public void tearDown() {
40 * Test of setPrimaryText method, of class I18nText.
43 public void testSetPrimaryText() {
44 System.out.println("setPrimaryText");
48 text = new I18nText();
49 text.setPrimaryText("pri");
50 assertEquals("pri", text.getPrimaryText());
52 text.setPrimaryText(null);
53 assertNull(text.getPrimaryText());
59 * Test of setGlobalText method, of class I18nText.
62 public void testSetGlobalText() {
63 System.out.println("setGlobalText");
67 text = new I18nText();
68 text.setGlobalText("glo");
70 assertEquals("glo", text.getGlobalText());
72 text.setGlobalText(null);
73 assertNull(text.getGlobalText());
79 * Test of setI18nText method, of class I18nText.
82 public void testSetI18nText_Locale_CharSequence() {
83 System.out.println("setI18nText");
87 text = new I18nText();
88 text.setI18nText(Locale.JAPANESE, "pri");
89 assertEquals("pri", text.getPrimaryText());
91 text.setI18nText(Locale.JAPANESE, null);
92 assertNull(text.getPrimaryText());
98 * Test of setI18nText method, of class I18nText.
101 public void testSetI18nText_String_CharSequence() {
102 System.out.println("setI18nText");
106 text = new I18nText();
107 text.setI18nText("ja", "pri");
108 assertEquals("pri", text.getPrimaryText());
110 text.setI18nText("ja", null);
111 assertNull(text.getPrimaryText());
117 * Test of getPrimaryText method, of class I18nText.
120 public void testGetPrimaryText() {
121 System.out.println("getPrimaryText");
125 text = new I18nText();
126 assertNull(text.getPrimaryText());
128 text.setPrimaryText("pri");
129 assertEquals("pri", text.getPrimaryText());
135 * Test of getGlobalText method, of class I18nText.
138 public void testGetGlobalText() {
139 System.out.println("getGlobalText");
143 text = new I18nText();
144 assertNull(text.getGlobalText());
146 text.setGlobalText("glo");
147 assertEquals("glo", text.getGlobalText());
153 * Test of getI18nText method, of class I18nText.
156 public void testGetI18nText_Locale() {
157 System.out.println("getI18nText");
161 text = new I18nText();
162 text.setPrimaryText("pri");
164 assertEquals("pri", text.getI18nText(Locale.JAPANESE));
165 assertNull(text.getI18nText(Locale.ENGLISH));
171 * Test of getI18nText method, of class I18nText.
174 public void testGetI18nText_String() {
175 System.out.println("getI18nText");
179 text = new I18nText();
180 text.setPrimaryText("pri");
182 assertEquals("pri", text.getI18nText("ja"));
183 assertNull(text.getI18nText("en"));
189 * Test of getText method, of class I18nText.
192 public void testGetText() {
193 System.out.println("getText");
197 text = new I18nText();
198 assertEquals("", text.getText());
200 text.setPrimaryText("pri");
201 assertEquals("pri", text.getText());
207 * Test of getLocalizedText method, of class I18nText.
210 public void testGetLocalizedText() {
211 System.out.println("getLocalizedText");
215 text = new I18nText();
216 assertEquals("", text.getLocalizedText());
218 text = new I18nText();
219 text.setPrimaryText("pri");
220 assertEquals("pri", text.getLocalizedText());
222 text = new I18nText();
223 text.setGlobalText("glo");
224 assertEquals("glo", text.getLocalizedText());
226 text = new I18nText();
227 text.setI18nText(Locale.CHINESE, "chi");
228 assertEquals("chi", text.getLocalizedText());
236 * Test of clearI18nText method, of class I18nText.
239 public void testClearI18nText() {
240 System.out.println("clearI18nText");
244 text = new I18nText();
246 text.setPrimaryText("pri");
247 text.setGlobalText("glo");
249 assertNotNull(text.getPrimaryText());
250 assertNotNull(text.getGlobalText());
252 text.clearI18nText();
254 assertNull(text.getPrimaryText());
255 assertNull(text.getGlobalText());
261 * Test of lang639CodeList method, of class I18nText.
264 public void testLang639CodeList() {
265 System.out.println("lang639CodeList");
270 text = new I18nText();
272 list = text.lang639CodeList();
273 assertTrue(list.isEmpty());
275 text.setI18nText(Locale.CHINA, "chi");
276 text.setPrimaryText("pri");
277 text.setGlobalText("glo");
279 list = text.lang639CodeList();
281 assertEquals(3, list.size());
282 assertEquals("ja", list.get(0));
283 assertEquals("en", list.get(1));
284 assertEquals("zh", list.get(2));
290 * Test of hasPrimaryText method, of class I18nText.
293 public void testHasPrimaryText() {
294 System.out.println("hasPrimaryText");
298 text = new I18nText();
299 assertFalse(text.hasPrimaryText());
301 text.setPrimaryText("pri");
302 assertTrue(text.hasPrimaryText());
304 text.setPrimaryText(null);
305 assertFalse(text.hasPrimaryText());
307 text.setGlobalText("glo");
308 assertFalse(text.hasPrimaryText());
314 * Test of hasGlobalText method, of class I18nText.
317 public void testHasGlobalText() {
318 System.out.println("hasGlobalText");
322 text = new I18nText();
323 assertFalse(text.hasGlobalText());
325 text.setGlobalText("glo");
326 assertTrue(text.hasGlobalText());
328 text.setGlobalText(null);
329 assertFalse(text.hasGlobalText());
331 text.setPrimaryText("pri");
332 assertFalse(text.hasGlobalText());
338 * Test of charAt method, of class I18nText.
341 public void testCharAt() {
342 System.out.println("charAt");
346 text = new I18nText();
348 text.setPrimaryText("pri");
349 text.setGlobalText("glo");
350 text.setI18nText(Locale.CHINA, "chi");
352 assertEquals('r', text.charAt(1));
358 * Test of length method, of class I18nText.
361 public void testLength() {
362 System.out.println("length");
366 text = new I18nText();
368 text.setPrimaryText("pri");
369 text.setGlobalText("glob");
370 text.setI18nText(Locale.CHINA, "china");
372 assertEquals(3, text.length());
378 * Test of subSequence method, of class I18nText.
381 public void testSubSequence() {
382 System.out.println("subSequence");
386 text = new I18nText();
388 text.setPrimaryText("pri");
389 text.setGlobalText("glo");
390 text.setI18nText(Locale.CHINA, "chi");
392 assertEquals("p", text.subSequence(0, 1));
398 * Test of toString method, of class I18nText.
401 public void testToString() {
402 System.out.println("toString");
406 text = new I18nText();
408 text.setPrimaryText("pri");
409 text.setGlobalText("glo");
410 text.setI18nText(Locale.CHINA, "chi");
412 assertEquals("pri", text.toString());