Package net.emaze.dysfunctional.dispatching.delegates

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

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 LongToInet4AddressTest {

    private final LongToInet4Address transformer = new LongToInet4Address();

    @Test(expected = IllegalArgumentException.class)
    public void transformingNullYieldsException() {
        transformer.perform(null);
    }

    @Test
    public void canTransformAnAddress() throws UnknownHostException {
        final Inet4Address got = transformer.perform(0x7f000001L);
        Assert.assertEquals(InetAddress.getByName("127.0.0.1"), got);
    }

    @Test
    public void canTransformNegativeBytes() throws UnknownHostException {
        final Inet4Address got = transformer.perform(0xffffffffL);
        Assert.assertEquals(InetAddress.getByName("255.255.255.255"), got);
    }
}
TOP

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

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.