From 024b3df483c29a9c2f470d7f5fa15d895eb22e3c Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 16 Nov 2016 17:26:39 +0200 Subject: [PATCH] Rename test --- .../interfaces/NetworkInterfaceTest.java | 122 ------------------ 1 file changed, 122 deletions(-) delete mode 100644 core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java diff --git a/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java b/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java deleted file mode 100644 index 4a8ef57b8f..0000000000 --- a/core-java/src/test/java/com/baeldung/java/networking/interfaces/NetworkInterfaceTest.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.baeldung.java.networking.interfaces; - -import static org.junit.Assert.*; - -import java.net.InetAddress; -import java.net.InterfaceAddress; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.Enumeration; -import java.util.List; - -import org.junit.Test; - -public class NetworkInterfaceTest { - @Test - public void givenName_whenReturnsNetworkInterface_thenCorrect() throws SocketException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - assertNotNull(nif); - } - - @Test - public void givenInExistentName_whenReturnsNull_thenCorrect() throws SocketException { - NetworkInterface nif = NetworkInterface.getByName("inexistent_name"); - assertNull(nif); - } - - @Test - public void givenIP_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException { - byte[] ip = new byte[] { 127, 0, 0, 1 }; - NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getByAddress(ip)); - assertNotNull(nif); - } - - @Test - public void givenHostName_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getByName("localhost")); - assertNotNull(nif); - } - - @Test - public void givenLocalHost_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()); - assertNotNull(nif); - } - - @Test - public void givenLoopBack_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByInetAddress(InetAddress.getLoopbackAddress()); - assertNotNull(nif); - } - - @Test - public void givenIndex_whenReturnsNetworkInterface_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByIndex(0); - assertNotNull(nif); - } - - @Test - public void givenInterface_whenReturnsInetAddresses_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - Enumeration addressEnum = nif.getInetAddresses(); - InetAddress address = addressEnum.nextElement(); - assertEquals("127.0.0.1", address.getHostAddress()); - } - - @Test - public void givenInterface_whenReturnsInterfaceAddresses_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - - List addressEnum = nif.getInterfaceAddresses(); - InterfaceAddress address = addressEnum.get(0); - InetAddress localAddress = address.getAddress(); - InetAddress broadCastAddress = address.getBroadcast(); - assertEquals("127.0.0.1", localAddress.getHostAddress()); - assertEquals("127.255.255.255", broadCastAddress.getHostAddress()); - } - - @Test - public void givenInterface_whenChecksIfLoopback_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - assertTrue(nif.isLoopback()); - } - - @Test - public void givenInterface_whenChecksIfUp_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - assertTrue(nif.isUp()); - } - - @Test - public void givenInterface_whenChecksIfPointToPoint_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - assertFalse(nif.isPointToPoint()); - } - - @Test - public void givenInterface_whenChecksIfVirtual_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - assertFalse(nif.isVirtual()); - } - - @Test - public void givenInterface_whenChecksMulticastSupport_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - assertTrue(nif.supportsMulticast()); - } - - @Test - public void givenInterface_whenGetsMacAddress_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("lo"); - byte[] bytes = nif.getHardwareAddress(); - assertNotNull(bytes); - } - - @Test - public void givenInterface_whenGetsMTU_thenCorrect() throws SocketException, UnknownHostException { - NetworkInterface nif = NetworkInterface.getByName("net0"); - int mtu = nif.getMTU(); - assertEquals(1500, mtu); - } -}