Package net.emaze.dysfunctional.dispatching.delegates

Source Code of net.emaze.dysfunctional.dispatching.delegates.Inet4AddressToLongTest

package net.emaze.dysfunctional.dispatching.delegates;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.junit.Assert;
import org.junit.Test;

/**
*
* @author rferranti
*/
public class Inet4AddressToLongTest {

    private final Inet4AddressToLong transformer = new Inet4AddressToLong();
   
    @Test(expected=IllegalArgumentException.class)
    public void transformingNullYieldsException() {
        transformer.perform(null);
    }
   
    @Test
    public void canTransformAnAddress() throws UnknownHostException {
        final Inet4Address address = (Inet4Address) InetAddress.getByName("127.0.0.1");
        long got = transformer.perform(address);
        Assert.assertEquals(0x7f000001L, got);
    }
    @Test
    public void canTransformNegativeBytes() throws UnknownHostException {
        final Inet4Address address = (Inet4Address) InetAddress.getByName("255.255.255.255");
        long got = transformer.perform(address);
        Assert.assertEquals(0xffffffffL, got);
    }
}
TOP

Related Classes of net.emaze.dysfunctional.dispatching.delegates.Inet4AddressToLongTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.