Fixed test cases

This commit is contained in:
Ziver Koc 2021-08-22 16:04:53 +02:00
parent 9a2d191443
commit decf114f49
3 changed files with 27 additions and 24 deletions

View file

@ -11,8 +11,8 @@ repositories {
dependencies {
implementation 'org.dom4j:dom4j:2.1.3'
implementation 'org.xerial:sqlite-jdbc:3.8.11.2'
compileOnly 'mysql:mysql-connector-java:8.0.16'
compileOnly 'org.xerial:sqlite-jdbc:3.8.11.2'
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'

26
pom.xml
View file

@ -48,17 +48,17 @@
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<scope>provided</scope>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
@ -92,15 +92,15 @@
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.8.11.2</version>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<scope>provided</scope>
</dependency>

View file

@ -53,16 +53,16 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
private Executor executor = Executors.newCachedThreadPool();
private final int port;
private ServerSocket serverSocket;
private ServerSocketFactory serverSocketFactory;
/**
* Creates a new instance of the sever.
*
* @param port the port that the server should listen to
*/
public ThreadedTCPNetworkServer(int port) throws IOException {
public ThreadedTCPNetworkServer(int port) {
this.port = port;
this.serverSocket = ServerSocketFactory.getDefault().createServerSocket(port);
this.serverSocketFactory = ServerSocketFactory.getDefault();
}
/**
* Creates a new SSL instance of the sever.
@ -91,13 +91,13 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
* @param keyStore the KeyStore that contains the certificate to be used by the server
* @param keyStorePass the password to decrypt the key store file, null if there is no password set
*/
public ThreadedTCPNetworkServer(int port, KeyStore keyStore, char[] keyStorePass) throws IOException, GeneralSecurityException {
public ThreadedTCPNetworkServer(int port, KeyStore keyStore, char[] keyStorePass) throws GeneralSecurityException {
this.port = port;
this.serverSocket = getSSLServerSocketFactory(keyStore, keyStorePass).createServerSocket(port);
this.serverSocketFactory = getSSLServerSocketFactory(keyStore, keyStorePass);
}
/**
* Initiates a SSLServerSocket
* Initiates a SSLServerSocketFactory
*
* @param privateKey the private key for the certificate
* @param certificate the certificate for the server domain.
@ -113,7 +113,7 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
return keyStore;
}
/**
* Initiates a SSLServerSocket
* Initiates a SSLServerSocketFactory
*
* @param keyStoreFile the cert file location
* @param keyStorePass the password for the cert file, null if there is no password set
@ -152,7 +152,11 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
}
public void run() {
ServerSocket serverSocket = null;
try {
serverSocket = serverSocketFactory.createServerSocket(port);
logger.info("Accepting TCP Connections on port: " + port);
while (true) {
@ -173,15 +177,14 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
try {
logger.info("Closing TCP socket listener (Port: " + port + ").");
serverSocket.close();
serverSocket = null;
} catch(IOException e) { logger.log(Level.SEVERE, null, e); }
}
}
}
/**
* This method returns an new instance of the ThreadedTCPNetworkServerThread
* that will handle the newly made connection, if an null value is returned
* This method returns a new instance of the ThreadedTCPNetworkServerThread
* that will handle the newly made connection, if a null value is returned
* then the ThreadedTCPNetworkServer will close the new connection.
*
* @param socket is an new connection to an host