Fixed test cases
This commit is contained in:
parent
9a2d191443
commit
decf114f49
3 changed files with 27 additions and 24 deletions
|
|
@ -11,8 +11,8 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.dom4j:dom4j:2.1.3'
|
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 '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'
|
compileOnly 'javax.servlet:javax.servlet-api:3.1.0'
|
||||||
|
|
||||||
|
|
|
||||||
26
pom.xml
26
pom.xml
|
|
@ -48,17 +48,17 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>org.xerial</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
<version>1.4</version>
|
<version>3.8.11.2</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>2.7</version>
|
<version>8.0.16</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
|
|
@ -92,15 +92,15 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
<version>8.0.16</version>
|
<version>1.4</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xerial</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>3.8.11.2</version>
|
<version>2.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,16 +53,16 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
|
||||||
|
|
||||||
private Executor executor = Executors.newCachedThreadPool();
|
private Executor executor = Executors.newCachedThreadPool();
|
||||||
private final int port;
|
private final int port;
|
||||||
private ServerSocket serverSocket;
|
private ServerSocketFactory serverSocketFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the sever.
|
* Creates a new instance of the sever.
|
||||||
*
|
*
|
||||||
* @param port the port that the server should listen to
|
* @param port the port that the server should listen to
|
||||||
*/
|
*/
|
||||||
public ThreadedTCPNetworkServer(int port) throws IOException {
|
public ThreadedTCPNetworkServer(int port) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.serverSocket = ServerSocketFactory.getDefault().createServerSocket(port);
|
this.serverSocketFactory = ServerSocketFactory.getDefault();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Creates a new SSL instance of the sever.
|
* 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 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
|
* @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.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 privateKey the private key for the certificate
|
||||||
* @param certificate the certificate for the server domain.
|
* @param certificate the certificate for the server domain.
|
||||||
|
|
@ -113,7 +113,7 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
|
||||||
return keyStore;
|
return keyStore;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initiates a SSLServerSocket
|
* Initiates a SSLServerSocketFactory
|
||||||
*
|
*
|
||||||
* @param keyStoreFile the cert file location
|
* @param keyStoreFile the cert file location
|
||||||
* @param keyStorePass the password for the cert file, null if there is no password set
|
* @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() {
|
public void run() {
|
||||||
|
ServerSocket serverSocket = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
serverSocket = serverSocketFactory.createServerSocket(port);
|
||||||
|
|
||||||
logger.info("Accepting TCP Connections on port: " + port);
|
logger.info("Accepting TCP Connections on port: " + port);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
@ -173,15 +177,14 @@ public abstract class ThreadedTCPNetworkServer extends Thread {
|
||||||
try {
|
try {
|
||||||
logger.info("Closing TCP socket listener (Port: " + port + ").");
|
logger.info("Closing TCP socket listener (Port: " + port + ").");
|
||||||
serverSocket.close();
|
serverSocket.close();
|
||||||
serverSocket = null;
|
|
||||||
} catch(IOException e) { logger.log(Level.SEVERE, null, e); }
|
} catch(IOException e) { logger.log(Level.SEVERE, null, e); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns an new instance of the ThreadedTCPNetworkServerThread
|
* This method returns a new instance of the ThreadedTCPNetworkServerThread
|
||||||
* that will handle the newly made connection, if an null value is returned
|
* that will handle the newly made connection, if a null value is returned
|
||||||
* then the ThreadedTCPNetworkServer will close the new connection.
|
* then the ThreadedTCPNetworkServer will close the new connection.
|
||||||
*
|
*
|
||||||
* @param socket is an new connection to an host
|
* @param socket is an new connection to an host
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue