KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > common > propertyeditor > ArrayPropertyEditorAdapterTest


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.common.propertyeditor;
19
20 import java.beans.PropertyEditor JavaDoc;
21 import java.net.URL JavaDoc;
22
23 import junit.framework.TestCase;
24
25 /**
26  * Unit test for {@link org.apache.geronimo.common.propertyeditor.ArrayPropertyEditorAdapter} class.
27  *
28  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
29  */

30 public class ArrayPropertyEditorAdapterTest
31     extends TestCase
32 {
33     PropertyEditor JavaDoc editor;
34
35     protected void setUp()
36     {
37         editor = PropertyEditors.findEditor(URL JavaDoc[].class);
38     }
39
40     public void testGetValue_Simple()
41     {
42         String JavaDoc input = "http://apache.org";
43
44         editor.setAsText(input);
45         Object JavaDoc output = editor.getValue();
46
47         assertNotNull(output);
48         assertEquals(URL JavaDoc[].class, output.getClass());
49
50         URL JavaDoc[] urls = (URL JavaDoc[])output;
51         assertEquals(1, urls.length);
52         assertEquals(input, urls[0].toString());
53     }
54
55     public void testGetValue_2URLs()
56     {
57         String JavaDoc input = "http://apache.org, http://google.com";
58
59         editor.setAsText(input);
60         Object JavaDoc output = editor.getValue();
61
62         assertNotNull(output);
63         assertEquals(URL JavaDoc[].class, output.getClass());
64
65         URL JavaDoc[] urls = (URL JavaDoc[])output;
66         assertEquals(2, urls.length);
67         assertEquals("http://apache.org", urls[0].toString());
68         assertEquals("http://google.com", urls[1].toString());
69     }
70 }
71
Popular Tags