From 826defa6bf7e0c014bea54479e6e9ac27058abc8 Mon Sep 17 00:00:00 2001 From: Frank Maritato Date: Tue, 16 Mar 2010 16:55:58 +0000 Subject: [PATCH] fixed the bug with getting an IPAddress; added test cases git-svn-id: https://lwes.svn.sourceforge.net/svnroot/lwes/lwes-java/trunk@414 a2f82657-cdd2-4550-bd36-68a8e7111808 --- src/test/java/org/lwes/util/IPAddressTest.java | 40 +++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/lwes/util/IPAddressTest.java b/src/test/java/org/lwes/util/IPAddressTest.java index 3f87790..cf6dd8a 100644 --- a/src/test/java/org/lwes/util/IPAddressTest.java +++ b/src/test/java/org/lwes/util/IPAddressTest.java @@ -3,15 +3,18 @@ package org.lwes.util; * @author fmaritato */ -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; import org.junit.Test; +import org.lwes.Event; +import org.lwes.EventSystemException; import java.net.InetAddress; import java.net.UnknownHostException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + public class IPAddressTest { @Test @@ -57,4 +60,33 @@ public class IPAddressTest { assertFalse("InetAddress.getByName not equal", one.equals(two)); assertNotSame("hash codes equal", one.hashCode(), two.hashCode()); } + + @Test + public void testGetSet() throws EventSystemException, UnknownHostException { + Event e = new Event("TestEvent", null); + IPAddress ip = new IPAddress("127.0.0.1"); + e.setIPAddress("ipaddr", ip); + assertEquals("Type fail", + ip.getClass().getName(), + e.getIPAddressObj("ipaddr").getClass().getName()); + assertEquals("Type fail", + new byte[]{}.getClass().getName(), + e.getIPAddress("ipaddr").getClass().getName()); + + e.setIPAddress("inetaddr", InetAddress.getLocalHost()); + assertEquals("Type fail", + ip.getClass().getName(), + e.getIPAddressObj("inetaddr").getClass().getName()); + assertEquals("Type fail", + new byte[]{}.getClass().getName(), + e.getIPAddress("inetaddr").getClass().getName()); + + e.setIPAddress("bytesaddr", new byte[]{(byte) 127, (byte) 0, (byte) 0, (byte) 1}); + assertEquals("Type fail", + ip.getClass().getName(), + e.getIPAddressObj("bytesaddr").getClass().getName()); + assertEquals("Type fail", + new byte[]{}.getClass().getName(), + e.getIPAddress("bytesaddr").getClass().getName()); + } } -- 2.11.4.GIT