Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Improve message management & test fixes #11

Merged
merged 2 commits into from about 2 years ago

2 participants

Davide Sottara Salaboy
Davide Sottara
Owner
sotty commented March 31, 2012

No description provided.

Salaboy Salaboy merged commit 2cdcf9d into from March 31, 2012
Salaboy Salaboy closed this March 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Mar 31, 2012
Davide Sottara Improve response collection 8b7836b
Davide Sottara Fix tests after drools-grid patch 281e488
This page is out of date. Refresh to see the latest.
16  drools-mas-core/src/main/java/org/drools/mas/core/DroolsAgent.java
@@ -16,6 +16,7 @@
16 16
 package org.drools.mas.core;
17 17
 
18 18
 import java.util.ArrayList;
  19
+import java.util.Collections;
19 20
 import java.util.Iterator;
20 21
 import java.util.List;
21 22
 import org.drools.grid.*;
@@ -28,6 +29,7 @@
28 29
 import org.drools.mas.util.helper.SessionLocator;
29 30
 import org.drools.runtime.rule.QueryResults;
30 31
 import org.drools.runtime.rule.QueryResultsRow;
  32
+import org.drools.runtime.rule.Variable;
31 33
 import org.slf4j.Logger;
32 34
 import org.slf4j.LoggerFactory;
33 35
 
@@ -170,13 +172,15 @@ public StatefulKnowledgeSession getMind() {
170 172
     }
171 173
 
172 174
     public List<ACLMessage> getAgentAnswers(String msgId){
173  
-        List<ACLMessage> answers = new ArrayList<ACLMessage>();
174  
-        QueryResults results = mind.getQueryResults("getAnswers",new Object[]{msgId});
  175
+
  176
+        QueryResults results = mind.getQueryResults( "getAnswers", new Object[] { msgId, Variable.v } );
175 177
         Iterator<QueryResultsRow> iterator = results.iterator();
176  
-        while(iterator.hasNext()){
177  
-            QueryResultsRow row = iterator.next();
178  
-            answers.add((ACLMessage)row.get("$ans"));
  178
+
  179
+        if ( iterator.hasNext() ) {
  180
+            return ( (List<ACLMessage>) iterator.next().get( "$list" ) );
  181
+        } else {
  182
+            return Collections.emptyList();    
179 183
         }
180  
-        return answers;
  184
+        
181 185
     }
182 186
 }
5  drools-mas-core/src/main/resources/org/drools/mas/acl_declares.drl
@@ -82,6 +82,7 @@ declare MessageAnswer
82 82
 end
83 83
 
84 84
 
85  
-query getAnswers(String msgId)
86  
-    MessageAnswer(messageId == msgId, $ans: answer)
  85
+query getAnswers( String $msgId, java.util.List $list )
  86
+    accumulate( MessageAnswer( messageId == $msgId, $ans: answer ),
  87
+                $list : collectList( $ans ) )
87 88
 end
47  drools-mas-core/src/test/java/org/drools/mas/core/tests/GridTests.java
@@ -55,32 +55,42 @@ public GridTests() {
55 55
 
56 56
     @BeforeClass
57 57
     public static void setUpClass() throws Exception {
  58
+        DeleteDbFiles.execute("~", "mydb", false);
  59
+
  60
+        System.out.println("Staring DB for white pages ...");
  61
+
  62
+        try {
  63
+
  64
+            server = Server.createTcpServer(new String[] {"-tcp","-tcpAllowOthers","-tcpDaemon","-trace"}).start();
  65
+        } catch (SQLException ex) {
  66
+            System.out.println("ERROR: "+ex.getMessage());
  67
+
  68
+        }
  69
+        System.out.println("DB for white pages started! ");
  70
+
  71
+        GridHelper.reset();
58 72
     }
59 73
 
60 74
     @AfterClass
61  
-    public static void tearDownClass() throws Exception {
  75
+    public static void tearDownClass() {
  76
+        try {
  77
+            Server.shutdownTcpServer(server.getURL(), "", false, false);
  78
+        } catch (SQLException e) {
  79
+            e.printStackTrace();
  80
+            fail ( e.getMessage() );
  81
+        }
62 82
     }
63 83
     
64  
-     private Map<String, GridServiceDescription> coreServicesMap;
  84
+    private Map<String, GridServiceDescription> coreServicesMap;
65 85
     protected Grid grid1;
66 86
     
67 87
     protected GridNode remoteN1;
68  
-    private Server server;
69  
-    
  88
+    private static Server server;
  89
+
  90
+
  91
+
70 92
     @Before
71 93
     public void setUp() {
72  
-         DeleteDbFiles.execute("~", "mydb", false);
73  
-
74  
-        System.out.println("Staring DB for white pages ...");
75  
-        
76  
-        try {
77  
-            
78  
-            server = Server.createTcpServer(new String[] {"-tcp","-tcpAllowOthers","-tcpDaemon","-trace"}).start(); 
79  
-        } catch (SQLException ex) {
80  
-            System.out.println("ERROR: "+ex.getMessage());
81  
-            
82  
-        }
83  
-        System.out.println("DB for white pages started! ");
84 94
 
85 95
         this.coreServicesMap = new HashMap();
86 96
         createRemoteNode();
@@ -90,8 +100,6 @@ public void setUp() {
90 100
     public void tearDown() {
91 101
         remoteN1.dispose();
92 102
         grid1.get(SocketService.class).close();
93  
-        server.stop();
94  
-        
95 103
     }
96 104
     
97 105
     private void createRemoteNode(){
@@ -112,8 +120,7 @@ private void createRemoteNode(){
112 120
         GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
113 121
         remoteN1 = conn.connect();
114 122
         
115  
-        
116  
-    
  123
+
117 124
     }
118 125
     
119 126
     private void configureGrid1(Grid grid,
121  drools-mas-core/src/test/java/org/drools/mas/core/tests/SemanticACLTest.java
... ...
@@ -1,121 +0,0 @@
1  
-///*
2  
-// * To change this template, choose Tools | Templates
3  
-// * and open the template in the editor.
4  
-// */
5  
-//package org.drools.mas.core.tests;
6  
-//
7  
-//import mock.MockFact;
8  
-//import org.drools.mas.ACLMessage;
9  
-//import org.drools.mas.Act;
10  
-//import org.drools.mas.Encodings;
11  
-//import org.drools.mas.body.acts.InformIf;
12  
-//import org.drools.mas.core.DroolsAgent;
13  
-//import org.drools.mas.core.DroolsAgentConfiguration;
14  
-//import org.drools.mas.core.DroolsAgentFactory;
15  
-//import org.drools.mas.mock.MockResponseInformer;
16  
-//import org.drools.mas.util.ACLMessageFactory;
17  
-//import org.drools.mas.util.MessageContentEncoder;
18  
-//import org.drools.runtime.StatefulKnowledgeSession;
19  
-//import org.junit.*;
20  
-//import static org.junit.Assert.*;
21  
-//
22  
-///**
23  
-// *
24  
-// * @author salaboy
25  
-// */
26  
-//public class SemanticACLTest {
27  
-//
28  
-//    private static DroolsAgent mainAgent;
29  
-//    private static DroolsAgent clientAgent;
30  
-//    private static MockResponseInformer mainResponseInformer;
31  
-//    private static MockResponseInformer clientResponseInformer;
32  
-//
33  
-//    public SemanticACLTest() {
34  
-//    }
35  
-//
36  
-//    @BeforeClass
37  
-//    public static void setUpClass() throws Exception {
38  
-//    }
39  
-//
40  
-//    @AfterClass
41  
-//    public static void tearDownClass() throws Exception {
42  
-//    }
43  
-//
44  
-//    @Before
45  
-//    public void setUp() {
46  
-//        mainResponseInformer = new MockResponseInformer();
47  
-//        clientResponseInformer = new MockResponseInformer();
48  
-//
49  
-//        DroolsAgentConfiguration mainConfig = new DroolsAgentConfiguration();
50  
-//        mainConfig.setAgentId("Mock Test Agent");
51  
-//        mainConfig.setChangeset("mainTestAgent_changeset.xml");
52  
-//        mainConfig.setResponseInformer(mainResponseInformer);
53  
-//        DroolsAgentConfiguration.SubSessionDescriptor subDescr1 = new DroolsAgentConfiguration.SubSessionDescriptor("session1", "sub1.xml", "NOT_USED_YET");
54  
-//        mainConfig.addSubSession(subDescr1);
55  
-//        DroolsAgentConfiguration.SubSessionDescriptor subDescr2 = new DroolsAgentConfiguration.SubSessionDescriptor("session2", "sub2.xml", "NOT_USED_YET");
56  
-//        mainConfig.addSubSession(subDescr2);
57  
-//        mainAgent = DroolsAgentFactory.getInstance().spawn(mainConfig);
58  
-//        assertNotNull(mainAgent);
59  
-//        assertNotNull(mainAgent.getInnerSession("session1"));
60  
-//        assertNotNull(mainAgent.getInnerSession("session2"));
61  
-//
62  
-//        DroolsAgentConfiguration clientConfig = new DroolsAgentConfiguration();
63  
-//        clientConfig.setAgentId("Humble Test Client");
64  
-//        clientConfig.setChangeset("clientTestAgent_changeset.xml");
65  
-//        clientConfig.setResponseInformer(clientResponseInformer);
66  
-//        clientAgent = DroolsAgentFactory.getInstance().spawn(clientConfig);
67  
-//    }
68  
-//
69  
-//    @After
70  
-//    public void tearDown() {
71  
-//    }
72  
-//
73  
-//    /*
74  
-//     * The sender informs the receiver that a given proposition is true.
75  
-//     */
76  
-//    @Test
77  
-//    public void informACLMessageTest() {
78  
-//        // In this case the MockFact represent the proposition
79  
-//        MockFact fact = new MockFact("patient1", 18);
80  
-//
81  
-//        ACLMessageFactory factory = new ACLMessageFactory(Encodings.XML);
82  
-//
83  
-//        ACLMessage info = factory.newInformMessage("me", "you", fact);
84  
-//
85  
-//        mainAgent.tell(info);
86  
-//
87  
-//        assertNull(mainResponseInformer.getResponses(info));
88  
-//
89  
-//        StatefulKnowledgeSession target = mainAgent.getInnerSession("session1");
90  
-//
91  
-//        assertTrue(target.getObjects().contains(fact));
92  
-//
93  
-//    }
94  
-//    
95  
-//    /*
96  
-//     * The action of asking another agent whether or not a given proposition is true.
97  
-//     */
98  
-//    @Test
99  
-//    public void testQueryIf() {
100  
-//        MockFact fact = new MockFact("patient1", 18);
101  
-//        ACLMessageFactory factory = new ACLMessageFactory(Encodings.XML);
102  
-//        
103  
-//        ACLMessage info = factory.newInformMessage("me", "you", fact);
104  
-//        // First we inform a new proposition to the main agent
105  
-//        mainAgent.tell(info);
106  
-//
107  
-//        ACLMessage qryif = factory.newQueryIfMessage("me", "you", fact);
108  
-//        assertNull(mainResponseInformer.getResponses(qryif));
109  
-//        // Now we query for that proposition
110  
-//        mainAgent.tell(qryif);
111  
-//
112  
-//
113  
-//        assertNotNull(mainResponseInformer.getResponses(qryif));
114  
-//        assertEquals(1, mainResponseInformer.getResponses(qryif).size());
115  
-//
116  
-//        ACLMessage answer = mainResponseInformer.getResponses(qryif).get(0);
117  
-//        MessageContentEncoder.decodeBody(answer.getBody(), answer.getEncoding());
118  
-//        assertEquals(Act.INFORM_IF, answer.getPerformative());
119  
-//        assertEquals(((InformIf) answer.getBody()).getProposition().getData(), fact);
120  
-//    }
121  
-//}
47  drools-mas-core/src/test/java/org/drools/mas/core/tests/SpringAgentTest.java
@@ -14,6 +14,7 @@
14 14
 import org.drools.grid.SocketService;
15 15
 import org.drools.grid.conf.GridPeerServiceConfiguration;
16 16
 import org.drools.grid.conf.impl.GridPeerConfiguration;
  17
+import org.drools.grid.helper.GridHelper;
17 18
 import org.drools.grid.impl.GridImpl;
18 19
 import org.drools.grid.impl.MultiplexSocketServerImpl;
19 20
 import org.drools.grid.io.impl.MultiplexSocketServiceCongifuration;
@@ -43,20 +44,15 @@
43 44
     private static int port1 = 8000;
44 45
     private static int port2 = 8010;
45 46
     private static Logger logger = LoggerFactory.getLogger(SpringAgentTest.class);
46  
-    private Server server;
  47
+    private static Server server;
  48
+    private DroolsAgent agent;
  49
+
47 50
     public SpringAgentTest() {
  51
+
48 52
     }
49 53
 
50 54
     @BeforeClass
51 55
     public static void setUpClass() throws Exception {
52  
-    }
53  
-
54  
-    @AfterClass
55  
-    public static void tearDownClass() throws Exception {
56  
-    }
57  
-
58  
-    @Before
59  
-    public void setUp() {
60 56
         DeleteDbFiles.execute("~", "mydb", false);
61 57
         
62 58
         logger.info("Staring DB for white pages ...");
@@ -66,25 +62,40 @@ public void setUp() {
66 62
             logger.error(ex.getMessage());
67 63
         }
68 64
         logger.info("DB for white pages started! ");
  65
+
  66
+        GridHelper.reset();
69 67
     }
70 68
 
71  
-    @After
72  
-    public void tearDown() {
73  
-        
  69
+    @AfterClass
  70
+    public static void tearDownClass() {
74 71
         logger.info("Stopping DB ...");
75  
-        server.stop();
  72
+        try {
  73
+            Server.shutdownTcpServer( server.getURL(), "", false, false);
  74
+        } catch (SQLException e) {
  75
+            e.printStackTrace();
  76
+            fail ( e.getMessage() );
  77
+        }
76 78
         logger.info("DB Stopped!");
  79
+
  80
+    }
  81
+
  82
+    @Before
  83
+    public void setUp() {
  84
+    }
  85
+
  86
+    @After
  87
+    public void tearDown() {
  88
+        agent.dispose();
77 89
     }
78 90
 
79 91
     @Test
80 92
     public void helloAgentSmith() {
81 93
         ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
82 94
 
83  
-        DroolsAgent agent = (DroolsAgent) context.getBean("agent");
  95
+        agent = (DroolsAgent) context.getBean("agent");
  96
+
84 97
 
85  
-        assertNotNull(agent);
86 98
 
87  
-        agent.dispose();
88 99
 
89 100
     }
90 101
 
@@ -103,14 +114,12 @@ public void helloAgentSmithGrid() {
103 114
 
104 115
         ApplicationContext context = new ClassPathXmlApplicationContext("applicationContextGrid.xml");
105 116
 
106  
-        DroolsAgent agent = (DroolsAgent) context.getBean("agent");
  117
+        agent = (DroolsAgent) context.getBean("agent");
107 118
 
108 119
         assertNotNull(agent);
109 120
 
110 121
         agent.tell(ACLMessageFactory.getInstance().newInformMessage("", "", new mock.MockFact("asdasd", 12)));
111 122
 
112  
-        agent.dispose();
113  
-
114 123
 
115 124
         n1.dispose();
116 125
         grid1.get(SocketService.class).close();
81  drools-mas-core/src/test/java/org/drools/mas/core/tests/TestAgent.java
@@ -16,6 +16,8 @@
16 16
  */
17 17
 
18 18
 import java.sql.SQLException;
  19
+
  20
+import org.drools.grid.helper.GridHelper;
19 21
 import org.drools.mas.body.acts.Failure;
20 22
 import org.drools.mas.body.content.Query;
21 23
 import org.drools.mas.body.acts.InformIf;
@@ -49,22 +51,28 @@
49 51
 
50 52
     private static DroolsAgent mainAgent;
51 53
     private static Logger logger = LoggerFactory.getLogger(TestAgent.class);
52  
-    private Server server;
  54
+    private static Server server;
53 55
 
54  
-    @Before
55  
-    public void createAgents() {
56 56
 
  57
+    @BeforeClass
  58
+    public static void setupDB() {
57 59
         DeleteDbFiles.execute("~", "mydb", false);
58 60
 
59 61
         logger.info("Staring DB for white pages ...");
60 62
         try {
61  
-            
62  
-            server = Server.createTcpServer(new String[] {"-tcp","-tcpAllowOthers","-tcpDaemon","-trace"}).start(); 
  63
+
  64
+            server = Server.createTcpServer(new String[] {"-tcp","-tcpAllowOthers","-tcpDaemon","-trace"}).start();
63 65
         } catch (SQLException ex) {
64 66
             logger.error(ex.getMessage());
65 67
         }
66 68
         logger.info("DB for white pages started! ");
67 69
 
  70
+        // force DB initialization
  71
+        GridHelper.reset();
  72
+    }
  73
+
  74
+    @Before
  75
+    public void createAgents() {
68 76
 
69 77
         DroolsAgentConfiguration mainConfig = new DroolsAgentConfiguration();
70 78
         mainConfig.setAgentId("Mock Test Agent");
@@ -86,17 +94,26 @@ public void createAgents() {
86 94
 
87 95
     @After
88 96
     public void cleanUp() {
89  
-        
  97
+
90 98
         if (mainAgent != null) {
91 99
             mainAgent.dispose();
92 100
         }
93 101
 
  102
+    }
  103
+
  104
+    @AfterClass
  105
+    public static void cleanDB() {
94 106
         logger.info("Stopping DB ...");
95  
-        server.stop();
  107
+        try {
  108
+            Server.shutdownTcpServer(server.getURL(), "", false, false);
  109
+        } catch (SQLException e) {
  110
+            e.printStackTrace();
  111
+        }
96 112
         logger.info("DB Stopped!");
  113
+
97 114
     }
98 115
 
99  
-    
  116
+
100 117
     private void waitForAnswers( String id, int expectedSize, long sleep, int maxIters ) {
101 118
         int counter = 0;
102 119
         do {
@@ -113,9 +130,9 @@ private void waitForAnswers( String id, int expectedSize, long sleep, int maxIte
113 130
         }
114 131
 
115 132
     }
116  
-    
117  
-    
118  
-    
  133
+
  134
+
  135
+
119 136
     @Test
120 137
     public void testSimpleInform() throws InterruptedException {
121 138
         MockFact fact = new MockFact( "patient1", 18 );
@@ -123,10 +140,10 @@ public void testSimpleInform() throws InterruptedException {
123 140
 
124 141
         ACLMessage info = factory.newInformMessage( "me", "you", fact );
125 142
         mainAgent.tell( info );
126  
-        
  143
+
127 144
         //Now this is also async
128 145
         waitForAnswers( info.getId(), 0, 250, 50 );
129  
-        
  146
+
130 147
         assertNotNull( mainAgent.getAgentAnswers( info.getId() ) );
131 148
         StatefulKnowledgeSession target = mainAgent.getInnerSession( "session1" );
132 149
         assertTrue( target.getObjects().contains( fact ) );
@@ -174,22 +191,22 @@ public void testInformAsTrigger() throws InterruptedException {
174 191
         ACLMessage info = factory.newInformMessage("me", "you", fact);
175 192
         mainAgent.tell(info);
176 193
 
177  
-        
  194
+
178 195
         waitForAnswers( info.getId(), 0, 250, 50 );
179  
-          
180  
-        
  196
+
  197
+
181 198
         assertNotNull( mainAgent.getAgentAnswers(info.getId() ) );
182 199
         StatefulKnowledgeSession target = mainAgent.getInnerSession("session2");
183  
-        
  200
+
184 201
         for (Object o : target.getObjects()) {
185 202
             System.err.println("\t Inform-Trigger test : " + o);
186 203
         }
187  
-        
  204
+
188 205
         assertTrue(target.getObjects().contains(new Double(22.0)));
189 206
         assertTrue(target.getObjects().contains(new Integer(484)));
190 207
     }
191 208
 
192  
-    
  209
+
193 210
 
194 211
     @Test
195 212
     public void testQueryIf() throws InterruptedException {
@@ -259,7 +276,7 @@ public void testRequest() throws InterruptedException {
259 276
         mainAgent.tell(req);
260 277
 
261 278
         waitForAnswers( req.getId(), 2, 250, 50 );
262  
-        
  279
+
263 280
         assertNotNull( mainAgent.getAgentAnswers(req.getId() ) );
264 281
 
265 282
         assertEquals( 2, mainAgent.getAgentAnswers( req.getId() ).size() );
@@ -369,15 +386,15 @@ public void testRequestWithMultipleOutputs() throws InterruptedException {
369 386
 
370 387
 
371 388
         Action action = MessageContentFactory.newActionContent("randomSum", args);
372  
-        
  389
+
373 390
         ACLMessage req = factory.newRequestMessage("me", "you", action);
374 391
 
375 392
 
376 393
 
377 394
         mainAgent.tell(req);
378  
-        
  395
+
379 396
         Thread.sleep(5000);
380  
-        
  397
+
381 398
         assertNotNull(mainAgent.getAgentAnswers(req.getId()));
382 399
         assertEquals(2, mainAgent.getAgentAnswers(req.getId()).size());
383 400
 
@@ -425,7 +442,7 @@ public void testSimpleInformInNewSession() throws InterruptedException {
425 442
         ACLMessageFactory factory = new ACLMessageFactory( Encodings.XML );
426 443
 
427 444
         ACLMessage info = factory.newInformMessage( "me", "you", fact );
428  
-        
  445
+
429 446
         mainAgent.tell(info);
430 447
 
431 448
         waitForAnswers( info.getId(), 0, 2000, 10 );
@@ -438,7 +455,7 @@ public void testSimpleInformInNewSession() throws InterruptedException {
438 455
         assertTrue( target.getObjects().contains( fact ) );
439 456
 
440 457
         ACLMessage info2 = factory.newInformMessage( "me", "you", fact2 );
441  
-        
  458
+
442 459
         mainAgent.tell( info2 );
443 460
         //Now this is also async
444 461
         waitForAnswers( info.getId(), 0, 250, 50 );
@@ -461,7 +478,7 @@ public void testNotUnderstood() throws InterruptedException {
461 478
         mainAgent.tell(notUnd);
462 479
 
463 480
         waitForAnswers( notUnd.getId(), 0, 250, 50 );
464  
-        
  481
+
465 482
         assertEquals(Act.NOT_UNDERSTOOD, mainAgent.getAgentAnswers(notUnd.getId()).get(0).getPerformative());
466 483
 
467 484
     }
@@ -481,7 +498,7 @@ public void testImplicitRequestFailure() throws InterruptedException {
481 498
         mainAgent.tell( req );
482 499
 
483 500
         waitForAnswers( req.getId(), 2, 250, 50 );
484  
-        
  501
+
485 502
         assertEquals( 2, mainAgent.getAgentAnswers(req.getId()).size() );
486 503
         assertEquals( Act.AGREE, mainAgent.getAgentAnswers(req.getId()).get(0).getPerformative() );
487 504
         assertEquals( Act.FAILURE, mainAgent.getAgentAnswers(req.getId()).get(1).getPerformative() );
@@ -489,11 +506,11 @@ public void testImplicitRequestFailure() throws InterruptedException {
489 506
         Failure fail = (Failure) mainAgent.getAgentAnswers(req.getId()).get(1).getBody();
490 507
         String msg = fail.getCause().getData().toString();
491 508
 
492  
-        
  509
+
493 510
         assertTrue(  msg.contains( "can't extract the square root of -9" ) );
494 511
     }
495 512
 
496  
-       
  513
+
497 514
     @Test
498 515
     public void testExplicitRequestFailure() throws InterruptedException {
499 516
 
@@ -502,14 +519,14 @@ public void testExplicitRequestFailure() throws InterruptedException {
502 519
         ACLMessageFactory factory = new ACLMessageFactory(Encodings.XML);
503 520
 
504 521
         Map<String, Object> args = new LinkedHashMap<String, Object>();
505  
-            args.put( "x", in );
  522
+        args.put( "x", in );
506 523
 
507 524
         Action action = MessageContentFactory.newActionContent( "squareRoot", args );
508 525
         ACLMessage req = factory.newRequestMessage( "me", "you", action );
509 526
         mainAgent.tell( req );
510 527
 
511 528
         waitForAnswers( req.getId(), 2, 250, 50 );
512  
-        
  529
+
513 530
         assertEquals( Act.AGREE, mainAgent.getAgentAnswers(req.getId()).get(0).getPerformative() );
514 531
         assertEquals( Act.FAILURE, mainAgent.getAgentAnswers(req.getId()).get(1).getPerformative() );
515 532
 
@@ -546,7 +563,7 @@ public void testQueryRefFailure() throws InterruptedException {
546 563
         mainAgent.tell( qryref );
547 564
         //Now this is also async
548 565
         waitForAnswers( qryref.getId(), 0, 250, 50 );
549  
-        
  566
+
550 567
         assertEquals( 2, mainAgent.getAgentAnswers(qryref.getId()).size() );
551 568
         assertEquals( Act.AGREE, mainAgent.getAgentAnswers(qryref.getId()).get(0).getPerformative() );
552 569
         assertEquals( Act.FAILURE, mainAgent.getAgentAnswers(qryref.getId()).get(1).getPerformative() );
4  drools-mas-core/src/test/resources/META-INF/persistence.xml
@@ -9,7 +9,7 @@
9 9
     <properties>
10 10
       <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
11 11
       <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
12  
-      <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/~/mydb"/>
  12
+      <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/~/mydb;DB_CLOSE_ON_EXIT=FALSE"/>
13 13
       <!--property name="hibernate.connection.url" value="jdbc:h2:file:/h2/test;AUTO_SERVER=TRUE" /-->
14 14
       <!--  property name="hibernate.connection.url" value="jdbc:h2:file:\dev\drools\trunk7\jbpm-process\jbpm-human-task\mydb"/ -->
15 15
       <!--      <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>-->
@@ -19,7 +19,7 @@
19 19
       <property name="hibernate.connection.password" value="sasa"/>
20 20
       <property name="hibernate.connection.autocommit" value="false"/>
21 21
       <property name="hibernate.max_fetch_depth" value="3"/>
22  
-      <property name="hibernate.hbm2ddl.auto" value="update"/>
  22
+      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
23 23
       <property name="hibernate.show_sql" value="false"/>
24 24
     </properties>
25 25
   </persistence-unit>
4  drools-mas-generic-client/src/main/java/org/drools/mas/helpers/SyncDialogueHelper.java
@@ -138,6 +138,10 @@ private boolean validateRequestResponses( List<ACLMessage> answers, String metho
138 138
         if ( answers.size() != 2 ) {
139 139
             return false;
140 140
         }
  141
+
  142
+        if ( Act.AGREE.equals( answers.get( 1 ).getPerformative() ) ) {
  143
+            throw new IllegalStateException( " TODO : Agree was collected after its response, check rules" );
  144
+        }
141 145
         
142 146
         ACLMessage answer1 = answers.get( 0 );
143 147
         if ( ! Act.AGREE.equals( answer1.getPerformative() ) ) {
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.