diff --git a/.classpath b/.classpath index 784786d..e5bd6c8 100644 --- a/.classpath +++ b/.classpath @@ -1,9 +1,9 @@ - - - - - - - - - + + + + + + + + + diff --git a/dist/tcpscript.jar b/dist/tcpscript.jar index 3feff24..a0ba5cb 100644 Binary files a/dist/tcpscript.jar and b/dist/tcpscript.jar differ diff --git a/dist/tcpserver.jar b/dist/tcpserver.jar index ac18911..a47932d 100644 Binary files a/dist/tcpserver.jar and b/dist/tcpserver.jar differ diff --git a/manifest.txt b/manifest.txt index 74b9b18..79f04fe 100644 --- a/manifest.txt +++ b/manifest.txt @@ -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 diff --git a/src/cfh/tcpscript/Channel.java b/src/cfh/tcpscript/Channel.java index 8122d0a..e3ad3d0 100644 --- a/src/cfh/tcpscript/Channel.java +++ b/src/cfh/tcpscript/Channel.java @@ -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(); } diff --git a/src/cfh/tcpscript/ColumnIndicator.java b/src/cfh/tcpscript/ColumnIndicator.java index 2abf80d..848db73 100644 --- a/src/cfh/tcpscript/ColumnIndicator.java +++ b/src/cfh/tcpscript/ColumnIndicator.java @@ -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(); diff --git a/src/cfh/tcpscript/Main.java b/src/cfh/tcpscript/Main.java index 0216f35..bff1492 100644 --- a/src/cfh/tcpscript/Main.java +++ b/src/cfh/tcpscript/Main.java @@ -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; @@ -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; @@ -597,7 +605,7 @@ private void doClear() { } private void doMonitor() { - monitor.toggleVisible();; + monitor.toggleVisible(); } private void doQuit() { @@ -664,6 +672,7 @@ 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" + @@ -671,13 +680,7 @@ private void listAbout(JTextArea text) { "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"); } diff --git a/src/cfh/tcpscript/ScriptEngine.java b/src/cfh/tcpscript/ScriptEngine.java index d08a980..e85f844 100644 --- a/src/cfh/tcpscript/ScriptEngine.java +++ b/src/cfh/tcpscript/ScriptEngine.java @@ -128,6 +128,7 @@ public synchronized void stop() { tmp.interrupt(); } + @Override public void run() { String line; try { @@ -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); } @@ -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); } diff --git a/tcpscript.jardesc b/tcpscript.jardesc index dd2467a..ae16bfb 100644 --- a/tcpscript.jardesc +++ b/tcpscript.jardesc @@ -1,16 +1,16 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/test/cfh/tcpscript/ServerChannelTest.java b/test/cfh/tcpscript/ServerChannelTest.java index 6fd853d..f2cf8e2 100644 --- a/test/cfh/tcpscript/ServerChannelTest.java +++ b/test/cfh/tcpscript/ServerChannelTest.java @@ -58,6 +58,7 @@ public void testStart() throws Exception { socket.connect(new InetSocketAddress("localhost", port), 200); fail("expected SocketTimeoutException"); } catch (SocketTimeoutException expected) { + // } socket.close(); @@ -85,6 +86,7 @@ public void testStop() throws Exception { socket.connect(new InetSocketAddress("localhost",port), 200); fail("expected SocketTimeoutException"); } catch (SocketTimeoutException expected) { + // } socket.close(); } @@ -94,6 +96,7 @@ public void testWaitConnect() throws Exception { channel.start(); Callable waitConnection = new Callable() { + @Override public Long call() throws Exception { channel.waitConnect(null); return System.currentTimeMillis(); @@ -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); @@ -116,6 +120,7 @@ public Long call() throws Exception { try { socket.close(); } catch (IOException ignored) { + // } } @@ -125,6 +130,7 @@ public void testWaitPattern() throws Exception { channel.start(); Callable waitPattern = new Callable() { + @Override public Long call() throws Exception { channel.waitPattern(regex, null); return System.currentTimeMillis(); @@ -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); @@ -147,6 +154,7 @@ public Long call() throws Exception { try { socket.close(); } catch (IOException ignored) { + // } } diff --git a/test/cfh/tcpscript/TestServListener.java b/test/cfh/tcpscript/TestServListener.java index 5774916..30ac375 100644 --- a/test/cfh/tcpscript/TestServListener.java +++ b/test/cfh/tcpscript/TestServListener.java @@ -71,20 +71,24 @@ public List getConnections() { return connections; } + @Override public void connected(Server server, Connection connection) { connections.add(connection); received.put(connection, new ArrayList()); 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; } @@ -114,6 +118,7 @@ static void sleep() { try { Thread.sleep(10); } catch (InterruptedException ignored) { + // } } }