/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.base;
import java.util.Locale;
import de.odysseus.calyxo.base.test.TestI18nSupport;
import junit.framework.TestCase;
/**
*
* @author Christoph Beck
*/
public class MessageTest extends TestCase {
/**
* Constructor for MessageTest.
* @param arg0
*/
public MessageTest(String arg0) {
super(arg0);
}
public void testNoArgs() {
Message message = new Message("bundle", "msg0");
String string = message.format(Locale.ENGLISH, new TestI18nSupport());
assertEquals("en.bundle.msg0()", string);
}
public void testValueArg() {
Message message = new Message("bundle", "msg1");
Message.Arg arg = new Message.ValueArg("arg");
message.add(arg);
String string = message.format(Locale.ENGLISH, new TestI18nSupport());
assertEquals("en.bundle.msg1(arg)", string);
}
public void testResourceArg() {
Message message = new Message("bundle", "msg1");
Message.Arg arg = new Message.ResourceArg("bundle", "arg");
message.add(arg);
String string = message.format(Locale.ENGLISH, new TestI18nSupport());
assertEquals("en.bundle.msg1(en.bundle.arg)", string);
}
public void testArgs() {
Message message = new Message("bundle", "msg2");
Message.Arg arg1 = new Message.ResourceArg("bundle", "arg1");
message.add(arg1);
Message.Arg arg2 = new Message.ValueArg("arg2");
message.add(arg2);
String string = message.format(Locale.ENGLISH, new TestI18nSupport());
assertEquals("en.bundle.msg2(en.bundle.arg1,arg2)", string);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(MessageTest.class);
}
}