updated libraries

updated to JUNIT5
This commit is contained in:
Joern Muehlencord
2019-07-12 15:07:13 +02:00
parent 3ae4dba8fe
commit 24dc927ab7
57 changed files with 1196 additions and 1083 deletions

View File

@ -25,11 +25,10 @@
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<type>jar</type>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
</dependency>
<dependency>
<groupId>com.enterprisedt</groupId>
<artifactId>edtFTPj</artifactId>

View File

@ -5,8 +5,8 @@
package de.muehlencord.shared.network;
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
@ -18,7 +18,7 @@ public class CidrToolTest {
}
@Test
@Ignore
@Disabled
public void testCidrConversion() {
System.out.println (rangeToCidrList("213.55.64.0", "213.55.127.255"));
}

View File

@ -3,9 +3,9 @@ package de.muehlencord.shared.network;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.commons.net.util.SubnetUtils;
import static org.junit.Assert.assertFalse;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
@ -17,7 +17,7 @@ public class NetworkScannerTest {
}
@Test
@Ignore // takes very long
@Disabled // takes very long
public void testScan() throws UnknownHostException {
String ipAddress = InetAddress.getLocalHost().getHostAddress();
SubnetUtils utils = new SubnetUtils(ipAddress, "255.255.255.0");

View File

@ -1,8 +1,8 @@
package de.muehlencord.shared.network;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
@ -14,7 +14,7 @@ public class PortScannerTest {
}
@Test
@Ignore // takes very long
@Disabled // takes very long
public void testMain() {
PortScanner portScanner = new PortScanner();
List<PortInformation> resultList = portScanner.scan("127.0.0.1");

View File

@ -1,7 +1,7 @@
package de.muehlencord.shared.network;
import static de.muehlencord.shared.network.CidrTool.rangeToCidrList;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
*

View File

@ -7,10 +7,11 @@ import java.net.URL;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,8 +28,8 @@ public class FTPConnectionTest {
/** true, if init is complete to execute test */
boolean initDone = false;
@Before
public void initClass() {
@BeforeEach
public void setup() {
System.out.println("\n[FTPConnectionTest]");
URL testConfigURL = FTPConnectionTest.class.getResource("/test.properties");
FileInputStream fin = null;
@ -80,7 +81,7 @@ public class FTPConnectionTest {
}
@Test
@Ignore
@Disabled
public void testList() throws FTPConnectionException {
System.out.println("list");
String dir = "";
@ -92,7 +93,7 @@ public class FTPConnectionTest {
}
@Test
@Ignore
@Disabled
public void testListDirsOnly() throws FTPConnectionException {
System.out.println("listDirsOnly");
String dir = "";
@ -104,7 +105,7 @@ public class FTPConnectionTest {
}
@Test
@Ignore
@Disabled
public void testListFilesOnly() throws FTPConnectionException {
System.out.println("listFilesOnly");
String dir = "";
@ -116,7 +117,7 @@ public class FTPConnectionTest {
}
@Test
@Ignore
@Disabled
public void testListLinksOnly() throws FTPConnectionException {
System.out.println("listLinksOnly");
String dir = "";
@ -128,7 +129,7 @@ public class FTPConnectionTest {
}
@Test
@Ignore
@Disabled
public void testUploadFile() throws FTPConnectionException {
System.out.println("uploadFile");
String localFilename = "";
@ -138,7 +139,7 @@ public class FTPConnectionTest {
}
@Test
@Ignore
@Disabled
public void testRename() throws FTPConnectionException {
System.out.println("rename");
String remoteOldName = "";

View File

@ -9,8 +9,9 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
@ -19,7 +20,7 @@ import org.junit.Test;
public class HttpLayerTest extends BaseTest {
@Test
@Ignore
@Disabled
public void testPostByMap() throws Exception {
System.out.println("testPostByMap");
Map<String, String[]> map = new HashMap<>();
@ -32,7 +33,7 @@ public class HttpLayerTest extends BaseTest {
}
@Test
@Ignore
@Disabled
public void testPostByMapList() throws Exception {
System.out.println("testPostByMapList");
List<Map<String, String[]>> list = new LinkedList<>();
@ -45,41 +46,43 @@ public class HttpLayerTest extends BaseTest {
map.put("url", urlValue);
list.add(map);
HttpLayer httpLayer = new HttpLayer("http://localhost:8080/HttpPostListener/HttpPostListener");
httpLayer.post(list);
}
@Test
@Ignore
@Disabled
public void testByValue() throws Exception {
System.out.println("testByValue");
HttpLayer httpLayer = new HttpLayer(
"http://localhost:8080/HttpPostListener/HttpPostListener");
HttpLayer httpLayer = new HttpLayer("http://localhost:8080/HttpPostListener/HttpPostListener");
httpLayer.post("message", "Hello World by single parameter");
}
@Test(expected = MessageNotSendException.class)
@Test
public void testWithUnknownURL() throws MessageNotSendException {
System.out.println("testWithUnknownURL");
HttpLayer httpLayer = new HttpLayer(
"http://localhost/thisURLDoesNotExist");
httpLayer.post("message", "Hello World by single parameter");
HttpLayer httpLayer = new HttpLayer("http://localhost/thisURLDoesNotExist");
Assertions.assertThrows(MessageNotSendException.class, () -> {
httpLayer.post("message", "Hello World by single parameter");
});
}
@Test(expected = MessageNotSendException.class)
@Test
public void testInvalidURL() throws MessageNotSendException {
System.out.println("testInvalidURL");
HttpLayer httpLayer = new HttpLayer("joern@muehlencord.de");
httpLayer.post("message", "Hello World by single parameter");
Assertions.assertThrows(MessageNotSendException.class, () -> {
httpLayer.post("message", "Hello World by single parameter");
});
}
@Test(expected = MessageNotSendException.class)
@Test
public void testUnsupportedURL() throws MessageNotSendException {
System.out.println("testUnsupportedURL");
HttpLayer httpLayer = new HttpLayer("ftp://localhost");
httpLayer.post("message", "Hello World by single parameter");
Assertions.assertThrows(MessageNotSendException.class, () -> {
httpLayer.post("message", "Hello World by single parameter");
});
}
}

View File

@ -6,11 +6,11 @@ import de.muehlencord.shared.network.mail.imap.ImapMailReader;
import java.io.File;
import java.net.URL;
import java.util.List;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
@ -18,13 +18,13 @@ import org.junit.Test;
*/
public class MailMessageUtilsTest extends BaseTest {
@Before
@BeforeEach
public void setup() {
System.out.println ("\n[MailMessageUtilsTest]");
}
@Test
@Ignore // depends on environment
@Disabled // depends on environment
public void testGetInstance() throws Exception {
System.out.println("testGetInstance");
URL testConfigURL = MailMessageUtilsTest.class.getResource("/test.properties");

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package de.muehlencord.shared.network.mail;
import java.io.File;
@ -23,8 +18,8 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import org.junit.Assume;
import org.junit.Test;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -42,8 +37,8 @@ public class TestSendMail {
@Test
public void testSendEmail() throws AddressException, MessagingException, IOException {
Assume.assumeFalse(RECEIVER == null);
Assume.assumeFalse(PASSWORD == null);
assumeFalse(RECEIVER == null);
assumeFalse(PASSWORD == null);
Properties props = new Properties();
props.put("mail.smtp.host", "jomu.timelord.de");

View File

@ -6,9 +6,9 @@ import de.muehlencord.shared.network.mail.MailReaderConfiguration;
import de.muehlencord.shared.network.mail.MailReaderConnectionException;
import de.muehlencord.shared.network.mail.MailReaderException;
import java.util.List;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeNotNull;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -33,12 +33,12 @@ public class ExchangeMailReaderTest {
String emailaddress = null;
// disable tests if not all values are set
assumeNotNull(smtpHost);
assumeNotNull(folder);
assumeNotNull(testFolder);
assumeNotNull(userName);
assumeNotNull(emailaddress);
assumeNotNull(password);
assumeFalse(smtpHost == null);
assumeFalse(folder == null);
assumeFalse(testFolder == null);
assumeFalse(userName == null);
assumeFalse(emailaddress == null);
assumeFalse(password == null);
MailReaderConfiguration config = new MailReaderConfiguration(smtpHost, imapHost, userName, password, emailaddress);
MailReader instance = new ExchangeMailReader(config);

View File

@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.muehlencord.shared.network.mail.imap;
import de.muehlencord.shared.network.BaseTest;
@ -10,10 +6,10 @@ import de.muehlencord.shared.network.mail.MailReaderConfiguration;
import de.muehlencord.shared.network.mail.MailReaderConnectionException;
import de.muehlencord.shared.network.mail.MailReaderException;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
@ -28,7 +24,7 @@ public class ImapMailReaderTest extends BaseTest {
* @throws Exception if the tests fails
*/
@Test
@Ignore // depends on environment
@Disabled // depends on environment
public void testConnect() throws Exception {
System.out.println("connect");
String meta = "meta.muehlencord.intra";
@ -40,7 +36,7 @@ public class ImapMailReaderTest extends BaseTest {
}
@Test
@Ignore // depends on environment
@Disabled // depends on environment
public void testGetFolder() throws Exception {
System.out.println("getFolder");
String meta = "meta.muehlencord.intra";
@ -54,7 +50,7 @@ public class ImapMailReaderTest extends BaseTest {
}
@Test
@Ignore // depends on environment
@Disabled // depends on environment
public void testGetMessageCount() throws MailReaderConnectionException, MailReaderException {
System.out.println("testGetMessageCount");
String meta = "meta.muehlencord.intra";
@ -67,7 +63,7 @@ public class ImapMailReaderTest extends BaseTest {
}
@Test
@Ignore // depends on environment
@Disabled // depends on environment
public void testGetSubFolder() throws MailReaderConnectionException, MailReaderException {
System.out.println("getSubFolder");
String meta = "meta.muehlencord.intra";

View File

@ -2,9 +2,9 @@ package de.muehlencord.shared.network.whois;
import de.muehlencord.shared.network.BaseTest;
import java.io.IOException;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Ignore;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
@ -14,7 +14,7 @@ public class ArinWhoisParserTest extends BaseTest {
@Test
@Ignore
@Disabled
public void testParseArinIp() throws IOException, WhoisException {
String whoisInformation = this.readContentFromFile("204.232.209.184.txt");
ArinWhoisParser parser = new ArinWhoisParser();
@ -28,7 +28,7 @@ public class ArinWhoisParserTest extends BaseTest {
}
@Test
@Ignore
@Disabled
public void testParseArinDoubleIp() throws IOException, WhoisException {
String whoisInformation = this.readContentFromFile("108.166.92.167.txt");
ArinWhoisParser parser = new ArinWhoisParser();
@ -42,7 +42,7 @@ public class ArinWhoisParserTest extends BaseTest {
}
@Test
@Ignore // FIXME test broken
@Disabled // FIXME test broken
public void testParseArinUnknown() throws IOException, WhoisException {
String whoisInformation = this.readContentFromFile("74.95.241.217.txt");
ArinWhoisParser parser = new ArinWhoisParser();

View File

@ -1,69 +1,68 @@
package de.muehlencord.shared.network.whois;
import de.muehlencord.shared.network.BaseTest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
*
* @author jomu
*/
public class WhoisTest extends BaseTest {
@Test
@Ignore
@Disabled
public void testDenicWhoIs() throws WhoisException {
Whois whoIsClient = new Whois();
Whois whoIsClient = new Whois();
// Denic answers "status: connect" only
whoIsClient.execute ("whois.denic.de", "-T dn,ace muehlencord.de");
whoIsClient.execute("whois.denic.de", "-T dn,ace muehlencord.de");
}
@Test
@Ignore
public void testInternic() throws WhoisException {
Whois whoIsClient = new Whois();
whoIsClient.execute ("whois.1api.net", "egameladder.com");
}
@Test
@Ignore
@Disabled
public void testInternic() throws WhoisException {
Whois whoIsClient = new Whois();
whoIsClient.execute("whois.1api.net", "egameladder.com");
}
@Test
@Disabled
// TODO 184.173.67.10 whois with referal
public void testArin() throws WhoisException {
Whois whoIsClient = new Whois();
Whois whoIsClient = new Whois();
// WhoisInformation whoisInformation = whoIsClient.execute ("whois.arin.net", "204.232.209.184");
WhoisInformation whoisInformation = whoIsClient.execute ("whois.arin.net", "74.95.241.217");
assertNotNull (whoisInformation);
WhoisInformation whoisInformation = whoIsClient.execute("whois.arin.net", "74.95.241.217");
assertNotNull(whoisInformation);
whoisInformation.validate();
assertEquals ("Country", "US", whoisInformation.getNetworkInformation().getCountry());
System.out.println ("Network: "+whoisInformation.getNetwork());
assertTrue ("Network", whoisInformation.getNetwork().contains("74.95.224.0/19"));
assertEquals("Country", "US", whoisInformation.getNetworkInformation().getCountry());
System.out.println("Network: " + whoisInformation.getNetwork());
assertTrue(whoisInformation.getNetwork().contains("74.95.224.0/19"), "Network");
}
@Test
@Ignore
@Disabled
public void testApnic() throws WhoisException {
Whois whoIsClient = new Whois();
whoIsClient.execute ("whois.apnic.net", "60.247.69.45");
Whois whoIsClient = new Whois();
whoIsClient.execute("whois.apnic.net", "60.247.69.45");
}
@Test
@Ignore
@Disabled
public void testLacnic() throws WhoisException {
Whois whoIsClient = new Whois();
WhoisInformation whoisInformation = whoIsClient.execute ("whois.lacnic.net", "200.29.132.82");
assertNotNull (whoisInformation);
assertEquals ("Country", "CL", whoisInformation.getNetworkInformation().getCountry());
assertTrue ("Network", whoisInformation.getNetwork().contains("200.29.132.80/29"));
Whois whoIsClient = new Whois();
WhoisInformation whoisInformation = whoIsClient.execute("whois.lacnic.net", "200.29.132.82");
assertNotNull(whoisInformation);
assertEquals("Country", "CL", whoisInformation.getNetworkInformation().getCountry());
assertTrue(whoisInformation.getNetwork().contains("200.29.132.80/29"), "Network");
}
@Test
@Ignore
public void testUnkown() throws WhoisException {
@Test
@Disabled
public void testUnkown() throws WhoisException {
Whois whoIsClient = new Whois();
// whoIsClient.execute("whois.arin.net", "174.139.180.10");
// whoIsClient.execute("whois.twnic.net", "60.250.38.39");
@ -72,32 +71,31 @@ public class WhoisTest extends BaseTest {
// whoIsClient.execute("whois.apnic.net", "182.72.111.26");
// whoIsClient.execute("whois.ripe.net", "213.55.95.62"); // Transferred to Afrinic
// whoIsClient.execute("whois.afrinic.net", "213.55.95.62");
whoIsClient.execute("whois.arin.net", "32.64.68.229");
whoIsClient.execute("whois.arin.net", "32.64.68.229");
}
@Test
@Ignore
@Disabled
public void testGeneric() throws WhoisException {
Whois whoIsClient = new Whois();
WhoisInformation info = whoIsClient.execute( "85.185.91.5");
assertNotNull (info);
assertNotNull (info.getNetwork());
assertFalse (info.getNetwork().isEmpty());
System.out.println (info.getNetwork().toString());
System.out.println (info.getRootNetwork().toString());
System.out.println (info.getNetworkInformation().getDescription());
WhoisInformation info = whoIsClient.execute("85.185.91.5");
assertNotNull(info);
assertNotNull(info.getNetwork());
assertFalse(info.getNetwork().isEmpty());
System.out.println(info.getNetwork().toString());
System.out.println(info.getRootNetwork().toString());
System.out.println(info.getNetworkInformation().getDescription());
}
@Test
@Ignore
@Disabled
public void testStepWise() throws WhoisException {
Whois whoIsClient = new Whois();
Whois whoIsClient = new Whois();
// whoIsClient.execute ("whois.ripe.net", "88.198.181.181");
WhoisInformation whoisInformation = whoIsClient.execute ("212.204.60.1");
assertTrue ("network", whoisInformation.getNetwork().contains("212.204.60.0/24"));
WhoisInformation whoisInformation = whoIsClient.execute("212.204.60.1");
assertTrue(whoisInformation.getNetwork().contains("212.204.60.0/24"), "network");
// whoIsClient.execute ("whois.ripe.net", "212.204.60.0");
// whoIsClient.execute ("whois.ripe.net", "212.0.0.0/8");
}
}
}