Skip to content

Commit

Permalink
minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFHeuberger committed Aug 17, 2020
1 parent a575a13 commit 57cdc10
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 35 deletions.
18 changes: 9 additions & 9 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry combineaccessrules="false" kind="src" path="/TCPserver"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry combineaccessrules="false" kind="src" path="/TCPserver"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
Binary file modified dist/tcpscript.jar
Binary file not shown.
Binary file modified dist/tcpserver.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Manifest-Version: 1.0
Main-Class: cfh.tcpscript.Main
Class-Path: tcpserver.jar
Implementation-Vendor: Carlos F. Heuberger

Implementation-Version: 1.0
2 changes: 2 additions & 0 deletions src/cfh/tcpscript/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,12 @@ public int getSubchannelCount() {
return server.getConnections().size();
}

@Override
public void addConnectionListener(ConnectionListener listener) {
new RuntimeException("not implemented").printStackTrace();
}

@Override
public void removeConnectionListener(ConnectionListener listener) {
new RuntimeException("not implemented").printStackTrace();
}
Expand Down
1 change: 1 addition & 0 deletions src/cfh/tcpscript/ColumnIndicator.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public ColumnIndicator(JLabel statusColumn) {
this.output = statusColumn;
}

@Override
public void caretUpdate(CaretEvent ev) {
if (ev.getSource() instanceof JTextComponent) {
JTextComponent comp = (JTextComponent) ev.getSource();
Expand Down
21 changes: 12 additions & 9 deletions src/cfh/tcpscript/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
*/
public class Main implements Appendable {

private static final String VERSION = "v 0.7";
private static final String VERSION;
static {
String v = Main.class.getPackage().getImplementationVersion();
VERSION = v == null ? "dev" : "v " + v;
}

private static final String AUTHOR = "by Carlos Heuberger - " + VERSION;
static final String TITLE = "TCP Script - " + VERSION;
Expand Down Expand Up @@ -130,21 +134,25 @@ private Main() {
initPreferences();
initActions();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
initGUI();
}
});
}

@Override
public Appendable append(CharSequence seq) {
append0(seq.toString());
return this;
}

@Override
public Appendable append(CharSequence seq, int start, int end) {
return append(seq.subSequence(start, end));
}

@Override
public Appendable append(char ch) {
append0(Character.toString(ch));
return this;
Expand Down Expand Up @@ -597,7 +605,7 @@ private void doClear() {
}

private void doMonitor() {
monitor.toggleVisible();;
monitor.toggleVisible();
}

private void doQuit() {
Expand Down Expand Up @@ -664,20 +672,15 @@ private void doHelp() {
}

private void listAbout(JTextArea text) {
String v = Connection.class.getPackage().getImplementationVersion();
text.append(
"==================== TCP SCRIPT by Carlos Heuberger - " + VERSION + "\n" +
"A program to execute scripts for openning TCP connections to\n" +
"send and receive data packets through them.\n" +
"Usefull to help testing communications software where repetitive\n" +
"sending of data packets is needed.\n" +
"\n" +
"Revisions: " + getClass().getName() + " $Revision: 1.26 $\n" +
" " + ScriptEngine.getRevision() + "\n" +
" " + Command.getRevision() + "\n" +
" " + Channel.getRevision() + "\n" +
" " + Monitor.getRevision() + "\n" +
" " + Server.getRevision() + "\n" +
" " + Connection.getRevision() + "\n" +
"Server: " + (v==null ? "dev" : "v " + v) + "\n" +
"\n\n");
}

Expand Down
10 changes: 10 additions & 0 deletions src/cfh/tcpscript/ScriptEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public synchronized void stop() {
tmp.interrupt();
}

@Override
public void run() {
String line;
try {
Expand Down Expand Up @@ -246,18 +247,22 @@ protected LogServListener(String prefix) {
logConListener = new LogConnListener(prefix);
}

@Override
public void started(Server server) {
println(prefix + " started server");
}

@Override
public void connected(Server server, Connection connection) {
connection.addListener(logConListener);
}

@Override
public void shutdown(Server server) {
println(prefix + " server shut down");
}

@Override
public void handleException(Server server, Exception ex) {
println(prefix + " ERROR: " + ex);
}
Expand All @@ -273,22 +278,27 @@ public LogConnListener(String prefix) {
this.prefix = prefix;
}

@Override
public void started(Connection connection) {
println(prefix + "\u21AD" + "started connection " + connection.getRemoteAddress());
}

@Override
public void sentData(Connection connection, byte[] data) {
println(prefix + "\u21A4" + StringHelper.toString(data));
}

@Override
public void receivedData(Connection connection, byte[] data) {
println(prefix + "\u21E5" + StringHelper.toString(data));
}

@Override
public void shutdown(Connection connection) {
println(prefix + "\u2022" + "shutdown connection " + connection.getRemoteAddress());
}

@Override
public void handleException(Connection connection, Exception ex) {
println(prefix + " ERROR: " + ex);
}
Expand Down
32 changes: 16 additions & 16 deletions tcpscript.jardesc
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="WINDOWS-1252"?>
<jardesc>
<jar path="D:/develop/eclipse/TCPscript/dist/tcpscript.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/TCPscript/tcpscript.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="false" mainClassHandleIdentifier="=TCPscript/src&lt;cfh.tcpscript{Main.java[Main" manifestLocation="/TCPscript/manifest.txt" manifestVersion="1.0" reuseManifest="false" saveManifest="true" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<javaElement handleIdentifier="=TCPscript/src"/>
</selectedElements>
</jardesc>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc>
<jar path="TCPscript/dist/tcpscript.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/TCPscript/tcpscript.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="false" mainClassHandleIdentifier="=TCPscript/src&lt;cfh.tcpscript{Main.java[Main" manifestLocation="/TCPscript/manifest.txt" manifestVersion="1.0" reuseManifest="false" saveManifest="true" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<javaElement handleIdentifier="=TCPscript/src"/>
</selectedElements>
</jardesc>
8 changes: 8 additions & 0 deletions test/cfh/tcpscript/ServerChannelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void testStart() throws Exception {
socket.connect(new InetSocketAddress("localhost", port), 200);
fail("expected SocketTimeoutException");
} catch (SocketTimeoutException expected) {
//
}
socket.close();

Expand Down Expand Up @@ -85,6 +86,7 @@ public void testStop() throws Exception {
socket.connect(new InetSocketAddress("localhost",port), 200);
fail("expected SocketTimeoutException");
} catch (SocketTimeoutException expected) {
//
}
socket.close();
}
Expand All @@ -94,6 +96,7 @@ public void testWaitConnect() throws Exception {
channel.start();

Callable<Long> waitConnection = new Callable<Long>() {
@Override
public Long call() throws Exception {
channel.waitConnect(null);
return System.currentTimeMillis();
Expand All @@ -104,6 +107,7 @@ public Long call() throws Exception {
future.get(500, MILLISECONDS);
fail("Timeout expected: no connection");
} catch (TimeoutException expected) {
//
}

Socket socket = new Socket("localhost", port);
Expand All @@ -116,6 +120,7 @@ public Long call() throws Exception {
try {
socket.close();
} catch (IOException ignored) {
//
}
}

Expand All @@ -125,6 +130,7 @@ public void testWaitPattern() throws Exception {
channel.start();

Callable<Long> waitPattern = new Callable<Long>() {
@Override
public Long call() throws Exception {
channel.waitPattern(regex, null);
return System.currentTimeMillis();
Expand All @@ -135,6 +141,7 @@ public Long call() throws Exception {
future.get(500, MILLISECONDS);
fail("Timeout expected: not connected");
} catch (TimeoutException expected) {
//
}

Socket socket = new Socket("localhost", port);
Expand All @@ -147,6 +154,7 @@ public Long call() throws Exception {
try {
socket.close();
} catch (IOException ignored) {
//
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/cfh/tcpscript/TestServListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,24 @@ public List<Connection> getConnections() {
return connections;
}

@Override
public void connected(Server server, Connection connection) {
connections.add(connection);
received.put(connection, new ArrayList<byte[]>());
connection.addListener(connListener);
}

@Override
public void handleException(Server server, Exception ex) {
exceptions.add(ex);
}

@Override
public void shutdown(Server server) {
wasShutdown = true;
}

@Override
public void started(Server server) {
wasStarted = true;
}
Expand Down Expand Up @@ -114,6 +118,7 @@ static void sleep() {
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {
//
}
}
}

0 comments on commit 57cdc10

Please sign in to comment.