1 20 package org.apache.mina.integration.spring; 21 22 import java.net.InetAddress ; 23 import java.net.UnknownHostException ; 24 25 import junit.framework.TestCase; 26 27 33 public class InetAddressEditorTest extends TestCase { 34 InetAddressEditor editor; 35 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 } 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 } 58 | Popular Tags |