01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.translator;
16:
17: import org.apache.tapestry.Translator;
18: import org.apache.tapestry.internal.test.InternalBaseTestCase;
19: import org.apache.tapestry.ioc.Messages;
20: import org.testng.annotations.Test;
21:
22: /**
23: * Tests for the {@link StringTranslator} class.
24: */
25: public class StringTranslatorTest extends InternalBaseTestCase {
26: @Test
27: public void from_client_normal() throws Exception {
28: Messages messages = validationMessages();
29:
30: Translator<String> translator = new StringTranslator();
31:
32: assertEquals(translator.parseClient("abc", messages), "abc");
33: }
34:
35: @Test
36: public void from_client_blank_to_null() throws Exception {
37: Messages messages = validationMessages();
38:
39: Translator<String> translator = new StringTranslator();
40:
41: assertNull(translator.parseClient("", messages));
42: }
43:
44: @Test
45: public void to_client_normal() {
46: Translator<String> translator = new StringTranslator();
47:
48: assertEquals(translator.toClient("abc"), "abc");
49: }
50:
51: @Test
52: public void to_client_null_to_blank() {
53: Translator<String> translator = new StringTranslator();
54:
55: assertEquals(translator.toClient(null), "");
56: }
57: }
|