01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.base;
17:
18: import java.util.Locale;
19:
20: import de.odysseus.calyxo.base.test.TestI18nSupport;
21:
22: import junit.framework.TestCase;
23:
24: /**
25: *
26: * @author Christoph Beck
27: */
28: public class MessageTest extends TestCase {
29:
30: /**
31: * Constructor for MessageTest.
32: * @param arg0
33: */
34: public MessageTest(String arg0) {
35: super (arg0);
36: }
37:
38: public void testNoArgs() {
39: Message message = new Message("bundle", "msg0");
40: String string = message.format(Locale.ENGLISH,
41: new TestI18nSupport());
42: assertEquals("en.bundle.msg0()", string);
43: }
44:
45: public void testValueArg() {
46: Message message = new Message("bundle", "msg1");
47: Message.Arg arg = new Message.ValueArg("arg");
48: message.add(arg);
49: String string = message.format(Locale.ENGLISH,
50: new TestI18nSupport());
51: assertEquals("en.bundle.msg1(arg)", string);
52: }
53:
54: public void testResourceArg() {
55: Message message = new Message("bundle", "msg1");
56: Message.Arg arg = new Message.ResourceArg("bundle", "arg");
57: message.add(arg);
58: String string = message.format(Locale.ENGLISH,
59: new TestI18nSupport());
60: assertEquals("en.bundle.msg1(en.bundle.arg)", string);
61: }
62:
63: public void testArgs() {
64: Message message = new Message("bundle", "msg2");
65: Message.Arg arg1 = new Message.ResourceArg("bundle", "arg1");
66: message.add(arg1);
67: Message.Arg arg2 = new Message.ValueArg("arg2");
68: message.add(arg2);
69: String string = message.format(Locale.ENGLISH,
70: new TestI18nSupport());
71: assertEquals("en.bundle.msg2(en.bundle.arg1,arg2)", string);
72: }
73:
74: public static void main(String[] args) {
75: junit.textui.TestRunner.run(MessageTest.class);
76: }
77: }
|