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.upload.services;
16:
17: import static org.testng.Assert.assertEquals;
18: import static org.testng.Assert.assertFalse;
19: import static org.testng.Assert.assertNull;
20: import static org.testng.Assert.assertTrue;
21:
22: import org.testng.annotations.Test;
23:
24: public class ParameterValueTest {
25:
26: @Test
27: public void singleGivesConstructedParameterByDefault()
28: throws Exception {
29: ParameterValue value = new ParameterValue("foo");
30: assertEquals(value.single(), "foo");
31: }
32:
33: @Test
34: public void multiReturnsArrayWithConstructedParameterByDefault()
35: throws Exception {
36: ParameterValue value = new ParameterValue("foo");
37: assertEquals(value.multi(), new String[] { "foo" });
38: }
39:
40: @Test
41: public void singleGivesFirstValueOfMultiValue() throws Exception {
42: ParameterValue value = new ParameterValue("foo", "blah");
43: assertEquals(value.single(), "foo");
44: }
45:
46: @Test
47: public void multiGivesAllValuesOfMultiValue() throws Exception {
48: ParameterValue value = new ParameterValue("foo");
49: value.add("blah");
50: assertEquals(value.multi(), new String[] { "foo", "blah" });
51: }
52:
53: @Test
54: public void isMultiIsFalseForSingleValue() throws Exception {
55: ParameterValue value = new ParameterValue("foo");
56: assertFalse(value.isMulti());
57: }
58:
59: @Test
60: public void isMultiIsTrueForMultiValue() throws Exception {
61: ParameterValue value = new ParameterValue("foo");
62: value.add("blah");
63: assertTrue(value.isMulti());
64: }
65:
66: @Test
67: public void nullObjectGivesNullForSingleAndMulti() throws Exception {
68: ParameterValue value = ParameterValue.NULL;
69: assertNull(value.single());
70: assertNull(value.multi());
71: assertFalse(value.isMulti());
72: }
73:
74: }
|