1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.integration.beans;
21
22 import java.net.InetAddress;
23 import java.net.UnknownHostException;
24
25 import junit.framework.TestCase;
26
27
28
29
30
31
32 public class InetAddressEditorTest extends TestCase {
33 InetAddressEditor editor;
34
35 @Override
36 protected void setUp() throws Exception {
37 editor = new InetAddressEditor();
38 }
39
40 public void testSetAsTextWithHostName() throws Exception {
41 try {
42 InetAddress expected = InetAddress.getByName("www.google.com");
43 editor.setAsText("www.google.com");
44 assertEquals(expected, editor.getValue());
45 } catch (UnknownHostException uhe) {
46
47 }
48
49 editor.setAsText("localhost");
50 assertEquals(InetAddress.getByName("localhost"), editor.getValue());
51 }
52
53 public void testSetAsTextWithIpAddress() throws Exception {
54 editor.setAsText("127.0.0.1");
55 assertEquals(InetAddress.getByName("127.0.0.1"), editor.getValue());
56 }
57 }