From f2d318d3f7371a76d4b5d9e931cfc4b32335f303 Mon Sep 17 00:00:00 2001 From: gdamms Date: Thu, 2 Dec 2021 22:39:29 +0100 Subject: [PATCH] feat: 1 teste nul fix: des ptits trucs parciparla --- linda/server/LindaServer.java | 5 +---- linda/test/ClientTest1.java | 30 ++++++++++++++++++++++++++++++ linda/test/ServerTest.java | 21 +++++++++++++++++++++ 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 linda/test/ClientTest1.java create mode 100644 linda/test/ServerTest.java diff --git a/linda/server/LindaServer.java b/linda/server/LindaServer.java index bcf4f03..f66d61b 100644 --- a/linda/server/LindaServer.java +++ b/linda/server/LindaServer.java @@ -5,8 +5,6 @@ import java.util.Collection; import java.rmi.server.UnicastRemoteObject; import java.rmi.*; import java.rmi.registry.*; -import java.io.*; - import linda.Callback; import linda.Linda; @@ -23,7 +21,7 @@ public class LindaServer extends UnicastRemoteObject implements LindaRemote { public static void main(String[] args) { try { LindaServer ls = new LindaServer(); - Registry registry = LocateRegistry.createRegistry(Integer.parseInt(args[1])); + LocateRegistry.createRegistry(Integer.parseInt(args[1])); Naming.rebind(args[0], ls); System.out.println("L'instance Linda a été publié sur le registre (" + args[0] + ") !\n"); } catch (Exception e) { @@ -37,7 +35,6 @@ public class LindaServer extends UnicastRemoteObject implements LindaRemote { public void write(Tuple t) { lindaInstance.write(t); - System.out.println("Le tuple " + t + " a été ajouté au TupleSpace !"); } public Tuple take(Tuple template) throws RemoteException { diff --git a/linda/test/ClientTest1.java b/linda/test/ClientTest1.java new file mode 100644 index 0000000..4f3a121 --- /dev/null +++ b/linda/test/ClientTest1.java @@ -0,0 +1,30 @@ +package linda.test; + +import linda.server.LindaClient; +import linda.Tuple; + +public class ClientTest1 { + + public static void main(String[] args) { + + LindaClient lc = new LindaClient(args[0]); + + Tuple t1 = new Tuple(1, "a"); + System.out.print("Tuple " + t1 + " envoyé"); + lc.write(t1); + System.out.print("Tuple " + t1 + " écrit"); + + try { + Thread.sleep(3000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + Tuple template = new Tuple(Integer.class, String.class); + System.out.print("Lecture " + template + " envoyé"); + Tuple t2 = lc.read(template); + System.out.print("Tuple " + t2 + " lu"); + + } + +} diff --git a/linda/test/ServerTest.java b/linda/test/ServerTest.java new file mode 100644 index 0000000..fd6cc70 --- /dev/null +++ b/linda/test/ServerTest.java @@ -0,0 +1,21 @@ +package linda.test; + +import linda.server.LindaServer; + +import java.rmi.*; +import java.rmi.registry.*; + +public class ServerTest { + + public static void main(String[] args) { + try { + LindaServer ls = new LindaServer(); + LocateRegistry.createRegistry(Integer.parseInt(args[1])); + Naming.rebind(args[0], ls); + System.out.println("L'instance Linda a été publié sur le registre (" + args[0] + ") !\n"); + } catch (Exception e) { + e.printStackTrace(); + } + } + +}