Skip to content

Commit e78e391

Browse files
committed
Re estructured everything using now maven for packaging, started unit testing philosophy, added a few more commands
0 parents  commit e78e391

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+6027
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target/
2+
src/test/files

pom.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.nerox.client</groupId>
8+
<artifactId>clients</artifactId>
9+
<version>2.4.1</version>
10+
11+
<name>clients</name>
12+
<url>https://www.godjango.dev</url>
13+
14+
<properties>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
18+
</properties>
19+
20+
<dependencies>
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<version>4.11</version>
25+
<scope>test</scope>
26+
</dependency>
27+
</dependencies>
28+
29+
<build>
30+
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
31+
<plugins>
32+
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
33+
<plugin>
34+
<artifactId>maven-clean-plugin</artifactId>
35+
<version>3.1.0</version>
36+
</plugin>
37+
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
38+
<plugin>
39+
<artifactId>maven-resources-plugin</artifactId>
40+
<version>3.0.2</version>
41+
</plugin>
42+
<plugin>
43+
<artifactId>maven-compiler-plugin</artifactId>
44+
<version>3.8.0</version>
45+
</plugin>
46+
<plugin>
47+
<artifactId>maven-surefire-plugin</artifactId>
48+
<version>2.22.1</version>
49+
</plugin>
50+
<plugin>
51+
<artifactId>maven-jar-plugin</artifactId>
52+
<version>3.0.2</version>
53+
</plugin>
54+
<plugin>
55+
<artifactId>maven-install-plugin</artifactId>
56+
<version>2.5.2</version>
57+
</plugin>
58+
<plugin>
59+
<artifactId>maven-deploy-plugin</artifactId>
60+
<version>2.8.2</version>
61+
</plugin>
62+
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
63+
<plugin>
64+
<artifactId>maven-site-plugin</artifactId>
65+
<version>3.7.1</version>
66+
</plugin>
67+
<plugin>
68+
<artifactId>maven-project-info-reports-plugin</artifactId>
69+
<version>3.0.0</version>
70+
</plugin>
71+
</plugins>
72+
</pluginManagement>
73+
</build>
74+
</project>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.nerox.client;
2+
3+
import com.nerox.client.misc.StatusInfo;
4+
import com.nerox.client.misc.StatusServer;
5+
6+
public final class TFExceptions extends RuntimeException {
7+
public enum ErrorCodes {
8+
ON_WRITE_OR_RECEIVE_TO_SOCKET,
9+
ILLEGAL_ARGUMENTS,
10+
UNHANDLED_EXCEPTION,
11+
CAN_PUT,
12+
ON_COMMAND_EXECUTION,
13+
FILE_NOT_FOUND
14+
}
15+
16+
private StatusInfo status_info;
17+
private Exception originalException;
18+
19+
public TFExceptions(Exception ex){
20+
this.status_info = new StatusInfo(StatusServer.FAILED,
21+
ex.hashCode(), ex.getClass().getName() + ": " + ex.getMessage() + "\n");
22+
this.originalException = ex;
23+
}
24+
public TFExceptions(Exception ex, String message){
25+
this.status_info = new StatusInfo(StatusServer.FAILED,
26+
ex.hashCode(), ex.getClass().getName() + ": " + ex.getMessage() + "\n" + message);
27+
this.originalException = ex;
28+
}
29+
public TFExceptions(StatusInfo status_info){
30+
this.status_info = status_info;
31+
}
32+
public TFExceptions(Exception exception, int code){
33+
this.status_info = new StatusInfo(StatusServer.FAILED,code,
34+
exception.getClass().getName() + ": " + exception.getMessage() + "\n");
35+
this.originalException = exception;
36+
}
37+
public TFExceptions(int code, String message){
38+
this.status_info = new StatusInfo(StatusServer.FAILED, code, message);
39+
}
40+
public TFExceptions(StatusServer statusServer, ErrorCodes errorCodes, String message){
41+
this.status_info = new StatusInfo(statusServer, errorCodes.ordinal(), message);
42+
}
43+
44+
public StatusInfo getStatusInfo(){
45+
return this.status_info;
46+
}
47+
public byte[] getPayload(){
48+
return this.status_info.getPayload() == null ?
49+
this.status_info.getMessage().getBytes():
50+
this.status_info.getPayload();
51+
}
52+
public long getCode(){
53+
return this.status_info.getCode();
54+
}
55+
public Exception getOriginalException(){
56+
return this.originalException;
57+
}
58+
@Override
59+
public String toString() {
60+
return "\n--------------------------------------------------\n" +
61+
this.status_info.getStatus() + "\n" +
62+
this.status_info.getCode() + "\n" +
63+
this.status_info.getMessage() + "\n" +
64+
"--------------------------------------------------\n";
65+
}
66+
67+
@Override
68+
public String getMessage() {
69+
return this.status_info.getMessage();
70+
}
71+
}

0 commit comments

Comments
 (0)