Sanity tests for the IPv4Address.withMask*() syntactic sugars
diff --git a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java
index 9f3025c..9b18a62 100644
--- a/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java
+++ b/java_gen/pre-written/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java
@@ -9,6 +9,9 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+
import org.hamcrest.CoreMatchers;
import org.jboss.netty.buffer.ChannelBuffers;
import org.junit.Test;
@@ -269,6 +272,38 @@
}
@Test
+ public void testWithMask() throws Exception {
+ // Sanity tests for the withMask*() syntactic sugars
+
+ IPv4Address original = IPv4Address.of("192.168.1.101");
+ IPv4Address expectedValue = IPv4Address.of("192.168.1.0");
+ IPv4Address expectedMask = IPv4Address.of("255.255.255.0");
+
+ IPv4AddressWithMask v;
+
+ v = original.withMask(new byte[] {-1, -1, -1, 0});
+ assertEquals(v.getValue(), expectedValue);
+ assertEquals(v.getMask(), expectedMask);
+
+ v = original.withMask(0xFFFF_FF00);
+ assertEquals(v.getValue(), expectedValue);
+ assertEquals(v.getMask(), expectedMask);
+
+ v = original.withMask("255.255.255.0");
+ assertEquals(v.getValue(), expectedValue);
+ assertEquals(v.getMask(), expectedMask);
+
+ Inet4Address i4a = (Inet4Address) InetAddress.getByName("255.255.255.0");
+ v = original.withMask(i4a);
+ assertEquals(v.getValue(), expectedValue);
+ assertEquals(v.getMask(), expectedMask);
+
+ v = original.withMaskOfLength(24);
+ assertEquals(v.getValue(), expectedValue);
+ assertEquals(v.getMask(), expectedMask);
+ }
+
+ @Test
public void testReadFrom() throws OFParseError {
for(int i=0; i < testAddresses.length; i++ ) {
IPv4Address ip = IPv4Address.read4Bytes(ChannelBuffers.copiedBuffer(testAddresses[i]));