From 13a6e2c5e6f0d23988b1177c461b2aaf0e5ae1ea Mon Sep 17 00:00:00 2001 From: Bruce Eckel Date: Sat, 3 Sep 2016 13:24:33 -0600 Subject: [PATCH] Put necessary files in packages Also fixed a small compile bug (can't use static in @BeforeEach) --- go.bat | 3 ++- network/ChatterClient.java | 1 + network/ChatterServer.java | 1 + network/Dgram.java | 1 + network/MultiSimpleClient.java | 1 + network/MultiSimpleServer.java | 1 + network/SimpleClient.java | 1 + network/SimpleServer.java | 1 + network/WhoAmI.java | 3 +-- network/tests/SimpleTcpTests.java | 45 +++++++++++++++++++++++++++++++ 10 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 network/tests/SimpleTcpTests.java diff --git a/go.bat b/go.bat index cd399474..957d931c 100644 --- a/go.bat +++ b/go.bat @@ -1,2 +1,3 @@ -gradlew --no-daemon run > output.txt 2> errors.txt +gradlew --parallel --daemon run > output.txt 2> errors.txt +START /min "C:\Program Files\Windows Media Player\wmplayer.exe" %windir%\media\Alarm07.wav rem find . -size 0 -type f diff --git a/network/ChatterClient.java b/network/ChatterClient.java index 1ef77057..964adba3 100644 --- a/network/ChatterClient.java +++ b/network/ChatterClient.java @@ -5,6 +5,7 @@ // {ValidateByHand} // Tests the ChatterServer by starting multiple // clients, each of which sends datagrams. +package network; import java.net.*; import java.io.*; import onjava.*; diff --git a/network/ChatterServer.java b/network/ChatterServer.java index e56d234e..669f45dc 100644 --- a/network/ChatterServer.java +++ b/network/ChatterServer.java @@ -4,6 +4,7 @@ // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // {ValidateByHand} // A server that echoes datagrams +package network; import java.net.*; import java.io.*; import onjava.*; diff --git a/network/Dgram.java b/network/Dgram.java index fdb92abe..e1544ae6 100644 --- a/network/Dgram.java +++ b/network/Dgram.java @@ -3,6 +3,7 @@ // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Converts between Strings and DataGramPackets +package network; import java.net.*; public class Dgram { diff --git a/network/MultiSimpleClient.java b/network/MultiSimpleClient.java index 334808b2..2c0be630 100644 --- a/network/MultiSimpleClient.java +++ b/network/MultiSimpleClient.java @@ -4,6 +4,7 @@ // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Testing MultiSimpleServer with multiple clients. // {ValidateByHand} +package network; import java.net.*; import java.io.*; import onjava.*; diff --git a/network/MultiSimpleServer.java b/network/MultiSimpleServer.java index 2a068852..c8b891cc 100644 --- a/network/MultiSimpleServer.java +++ b/network/MultiSimpleServer.java @@ -4,6 +4,7 @@ // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Uses threads to handle any number of clients. // {ValidateByHand} +package network; import java.io.*; import java.net.*; import onjava.*; diff --git a/network/SimpleClient.java b/network/SimpleClient.java index 41e05dad..f943a6e0 100644 --- a/network/SimpleClient.java +++ b/network/SimpleClient.java @@ -5,6 +5,7 @@ // Sends lines to the server and // reads lines the server sends. // {ValidateByHand} +package network; import java.net.*; import java.io.*; diff --git a/network/SimpleServer.java b/network/SimpleServer.java index 01c4905f..a325d8b9 100644 --- a/network/SimpleServer.java +++ b/network/SimpleServer.java @@ -4,6 +4,7 @@ // Visit http://mindviewinc.com/Books/OnJava/ for more book information. // Echoes what the client sends. // {ValidateByHand} +package network; import java.io.*; import java.net.*; diff --git a/network/WhoAmI.java b/network/WhoAmI.java index 5cc8ff99..5ded836f 100644 --- a/network/WhoAmI.java +++ b/network/WhoAmI.java @@ -2,8 +2,7 @@ // (c)2016 MindView LLC: see Copyright.txt // We make no guarantees that this code is fit for any purpose. // Visit http://mindviewinc.com/Books/OnJava/ for more book information. -// Finds out your machine name and network address -// when you're connected to the Internet +// Discovers your machine name and network address. import java.net.*; public class WhoAmI { diff --git a/network/tests/SimpleTcpTests.java b/network/tests/SimpleTcpTests.java new file mode 100644 index 00000000..3113f0e0 --- /dev/null +++ b/network/tests/SimpleTcpTests.java @@ -0,0 +1,45 @@ +// network/tests/SimpleTcpTests.java +// (c)2016 MindView LLC: see Copyright.txt +// We make no guarantees that this code is fit for any purpose. +// Visit http://mindviewinc.com/Books/OnJava/ for more book information. +package network; +import java.util.*; +import java.util.stream.*; +import org.junit.jupiter.api.*; +import static org.junit.jupiter.api.Assertions.*; +import onjava.*; + +public class SimpleTcpTests { + + @BeforeAll + static void startMsg() { + System.out.println(">>> Network Tests <<<"); + } + + @BeforeEach + void setupServer () { } + + @Test + void basicTest() throws Exception { + SimpleServer server = new SimpleServer(); + SimpleClient client = new SimpleClient(); + client.main(null); + assertTrue(false); // Fail until there are good assertions in the test + } + + @Test + void multiTest() throws Exception { + MultiSimpleClient client = new MultiSimpleClient(); + MultiSimpleServer server = new MultiSimpleServer(); + client.main(null); + assertTrue(false); // Fail until there are good assertions in the test + } + + @Test + void chatterTest() throws Exception { + ChatterServer server = new ChatterServer(); + ChatterClient.main(null); + assertTrue(false); // Fail until there are good assertions in the test + } + +}