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 static org.junit.Assert.assertEquals;
23
24 import java.net.InetAddress;
25 import java.net.UnknownHostException;
26
27 import org.junit.Before;
28 import org.junit.Test;
29
30
31
32
33
34
35 public class InetAddressEditorTest {
36 InetAddressEditor editor;
37
38 @Before
39 public void setUp() throws Exception {
40 editor = new InetAddressEditor();
41 }
42
43 @Test
44 public void testSetAsTextWithHostName() throws Exception {
45 try {
46 InetAddress expected = InetAddress.getByName("www.google.com");
47 editor.setAsText("www.google.com");
48 assertEquals(expected, editor.getValue());
49 } catch (UnknownHostException uhe) {
50
51 }
52
53 editor.setAsText("localhost");
54 assertEquals(InetAddress.getByName("localhost"), editor.getValue());
55 }
56
57 @Test
58 public void testSetAsTextWithIpAddress() throws Exception {
59 editor.setAsText("127.0.0.1");
60 assertEquals(InetAddress.getByName(null), editor.getValue());
61 }
62 }