| 21,62 → 21,63 |
| */ |
| public class Nio2NioTwoWayTest extends BasicConnectionTest { |
| |
| public void testSendNio2Nio() { |
| TestUtil.COMMENT("demarre une config puis apres 3s"); |
| TestUtil |
| .COMMENT("Simule envoi un msg depuis deux connexion nio contextuelles avec contextes personnalises "); |
| TestUtil |
| .COMMENT("compteur verifie qu'il le recoit via une connexion nio"); |
| TestUtil.TRACE(this); |
| String config = "contextual2Nio2Nio.xml"; |
| runContextualTwo2One("-i NIO/nio.xml -add NIO/" + config, new Context( |
| "pincemi@localhost", "4500"), new Context("pincemoi@localhost", |
| "4500")); |
| } |
| public void testSendNio2Nio() { |
| TestUtil.COMMENT("demarre une config puis apres 3s"); |
| TestUtil.COMMENT("Simule envoi un msg depuis deux connexions" |
| + " nio contextuelles avec contextes personnalises "); |
| TestUtil.COMMENT("compteur verifie qu'il le recoit via une connexion nio"); |
| TestUtil.TRACE(this); |
| String config = "contextual2Nio2Nio.xml"; |
| runContextualTwo2One("-i NIO/nio.xml -add NIO/" + config, new Context( |
| "pincemi@localhost", "4500"), new Context("pincemoi@localhost", |
| "4500")); |
| } |
| |
| // TODO: test with responses. |
| |
| public void runContextualTwo2One(String config, Context context1, |
| Context context2) { |
| Launch instance = Launch.getInstance(); |
| LanceThread lance = new LanceThread(instance, config); |
| new Thread(lance).start(); |
| try { |
| Thread.sleep(3000); |
| } catch (InterruptedException ex) { |
| ex.printStackTrace(); |
| } |
| Node nodeSimu1 = NodeManager.getInstance().getNode( |
| "SimulateurContextuel1"); |
| Node nodeSimu2 = NodeManager.getInstance().getNode( |
| "SimulateurContextuel2"); |
| Node nodeCompteur = NodeManager.getInstance().getNode("Compteur"); |
| assertNotNull("Node Compteur not created", nodeCompteur); |
| assertNotNull("Node SimulateurContextuel1 not created", nodeSimu1); |
| assertNotNull("Node SimulateurContextuel2 not created", nodeSimu2); |
| |
| SimulateurContextual simu = (SimulateurContextual) nodeSimu1 |
| .getEngineProceed().getAttribute().getProceedInstance(); |
| simu.context = context1; |
| ProceedManager.getInstance().activeProceed(simu); |
| simu = (SimulateurContextual) nodeSimu2.getEngineProceed() |
| .getAttribute().getProceedInstance(); |
| simu.context = context2; |
| ProceedManager.getInstance().activeProceed(simu); |
| try { |
| Thread.sleep(5000); |
| } catch (InterruptedException ex) { |
| ex.printStackTrace(); |
| } |
| IProceed compt = nodeCompteur.getEngineProceed().getAttribute() |
| .getProceedInstance(); |
| try { |
| instance.stop(); |
| } catch (StateException e) { |
| e.printStackTrace(); |
| } |
| System.out.println("receive " + ((Compteur) compt).getCount() + " msg"); |
| assertEquals("Error in the number of waited messages", 2, |
| ((Compteur) compt).getCount()); |
| } |
| // TODO: test with responses. |
| public void runContextualTwo2One(String config, Context context1, |
| Context context2) { |
| Launch instance = Launch.getInstance(); |
| LanceThread lance = new LanceThread(instance, config); |
| new Thread(lance).start(); |
| try { |
| Thread.sleep(3000); |
| } catch (InterruptedException ex) { |
| ex.printStackTrace(); |
| } |
| System.out.println("step 1"); |
| Node nodeSimu1 = NodeManager.getInstance().getNode( |
| "SimulateurContextuel1"); |
| Node nodeSimu2 = NodeManager.getInstance().getNode( |
| "SimulateurContextuel2"); |
| |
| Node nodeCompteur = NodeManager.getInstance().getNode("Compteur"); |
| assertNotNull("Node Compteur not created", nodeCompteur); |
| assertNotNull("Node SimulateurContextuel1 not created", nodeSimu1); |
| assertNotNull("Node SimulateurContextuel2 not created", nodeSimu2); |
| System.out.println("step 2"); |
| SimulateurContextual simu = (SimulateurContextual) nodeSimu1.getEngineProceed().getAttribute().getProceedInstance(); |
| simu.context = context1; |
| ProceedManager.getInstance().activeProceed(simu); |
| simu = (SimulateurContextual) nodeSimu2.getEngineProceed().getAttribute().getProceedInstance(); |
| simu.context = context2; |
| System.out.println("step 3"); |
| ProceedManager.getInstance().activeProceed(simu); |
| System.out.println("step 4"); |
| try { |
| Thread.sleep(5000); |
| } catch (InterruptedException ex) { |
| ex.printStackTrace(); |
| } |
| System.out.println("step 5"); |
| IProceed compt = nodeCompteur.getEngineProceed().getAttribute().getProceedInstance(); |
| try { |
| instance.stop(); |
| System.out.println("step 6"); |
| } catch (StateException e) { |
| e.printStackTrace(); |
| } |
| System.out.println("receive " + ((Compteur) compt).getCount() + " msg"); |
| assertEquals("Error in the number of waited messages", 2, |
| ((Compteur) compt).getCount()); |
| } |
| } |