Skip to content
Snippets Groups Projects
Commit c542555a authored by Herwin van Welbergen's avatar Herwin van Welbergen
Browse files

Merge branch 'master' of ../../git_bare/ipaaca

Conflicts:
	ipaacalib/python/test/src/testnotifier.py
parents 81724039 7656d4c6
No related branches found
No related tags found
No related merge requests found
...@@ -315,7 +315,10 @@ public class OutputBuffer extends Buffer ...@@ -315,7 +315,10 @@ public class OutputBuffer extends Buffer
{ {
throw new IUPublishedException(iu); throw new IUPublishedException(iu);
} }
iuStore.put(iu.getUid(), iu); if(!(iu instanceof LocalMessageIU))
{
iuStore.put(iu.getUid(), iu);
}
iu.setBuffer(this); iu.setBuffer(this);
publishIU(iu); publishIU(iu);
} }
......
...@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableSet; ...@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableSet;
/** /**
* Test communication of the 'MESSAGE' type between IUs * Test communication of the 'MESSAGE' type between IUs
* @author hvanwelbergen * @author hvanwelbergen
* *
*/ */
public class ComponentMessageCommunicationIntegrationTest public class ComponentMessageCommunicationIntegrationTest
{ {
...@@ -29,118 +29,140 @@ public class ComponentMessageCommunicationIntegrationTest ...@@ -29,118 +29,140 @@ public class ComponentMessageCommunicationIntegrationTest
{ {
Initializer.initializeIpaacaRsb(); Initializer.initializeIpaacaRsb();
} }
private OutputBuffer outBuffer; private OutputBuffer outBuffer;
private InputBuffer inBuffer; private InputBuffer inBuffer;
private LocalMessageIU localIU; private LocalMessageIU localIU;
private CountingEventHandler component1EventHandler; private CountingEventHandler component1EventHandler;
private CountingEventHandler component2EventHandler; private CountingEventHandler component2EventHandler;
private StoringEventHandler component1StoreHandler = new StoringEventHandler(); private StoringEventHandler component1StoreHandler = new StoringEventHandler();
private StoringEventHandler component2StoreHandler = new StoringEventHandler(); private StoringEventHandler component2StoreHandler = new StoringEventHandler();
private static final String CATEGORY = "category1"; private static final String CATEGORY = "category1";
@Before @Before
public void setup() public void setup()
{ {
outBuffer = new OutputBuffer("component1"); outBuffer = new OutputBuffer("component1");
Set<String> categories = new ImmutableSet.Builder<String>().add(CATEGORY).build(); Set<String> categories = new ImmutableSet.Builder<String>().add(CATEGORY).build();
inBuffer = new InputBuffer("component2", categories); inBuffer = new InputBuffer("component2", categories);
EnumSet<IUEventType> types = EnumSet.of(IUEventType.ADDED,IUEventType.COMMITTED,IUEventType.UPDATED); EnumSet<IUEventType> types = EnumSet.of(IUEventType.ADDED, IUEventType.COMMITTED, IUEventType.UPDATED);
component2EventHandler = new CountingEventHandler(); component2EventHandler = new CountingEventHandler();
component1EventHandler = new CountingEventHandler(); component1EventHandler = new CountingEventHandler();
inBuffer.registerHandler(new IUEventHandler(component2EventHandler,types,categories)); inBuffer.registerHandler(new IUEventHandler(component2EventHandler, types, categories));
outBuffer.registerHandler(new IUEventHandler(component1EventHandler,types,categories)); outBuffer.registerHandler(new IUEventHandler(component1EventHandler, types, categories));
inBuffer.registerHandler(new IUEventHandler(component2StoreHandler,types,categories)); inBuffer.registerHandler(new IUEventHandler(component2StoreHandler, types, categories));
outBuffer.registerHandler(new IUEventHandler(component1StoreHandler,types,categories)); outBuffer.registerHandler(new IUEventHandler(component1StoreHandler, types, categories));
localIU = new LocalMessageIU(); localIU = new LocalMessageIU();
localIU.setCategory(CATEGORY); localIU.setCategory(CATEGORY);
localIU.getPayload().put("key1", "item1"); localIU.getPayload().put("key1", "item1");
localIU.addLinks("INIT", ImmutableSet.of("init1","init2")); localIU.addLinks("INIT", ImmutableSet.of("init1", "init2"));
} }
@After @After
public void tearDown() public void tearDown()
{ {
inBuffer.close(); inBuffer.close();
outBuffer.close(); outBuffer.close();
} }
@Test @Test
public void testAddedIU() throws InterruptedException public void testAddedIU() throws InterruptedException
{ {
outBuffer.add(localIU); outBuffer.add(localIU);
Thread.sleep(200); Thread.sleep(200);
AbstractIU iuIn = inBuffer.getIU(localIU.getUid()); AbstractIU iuIn = inBuffer.getIU(localIU.getUid());
assertNull(iuIn); assertNull(iuIn);
assertThat(localIU.getLinks("INIT"),containsInAnyOrder("init1","init2")); assertThat(localIU.getLinks("INIT"), containsInAnyOrder("init1", "init2"));
assertEquals(1,component2EventHandler.getNumberOfAddEvents(localIU.getUid())); assertEquals(1, component2EventHandler.getNumberOfAddEvents(localIU.getUid()));
assertEquals(0,component1EventHandler.getNumberOfAddEvents(localIU.getUid())); assertEquals(0, component1EventHandler.getNumberOfAddEvents(localIU.getUid()));
assertEquals(1,component2EventHandler.getNumberOfAddEvents(localIU.getUid())); assertEquals(1, component2EventHandler.getNumberOfAddEvents(localIU.getUid()));
assertEquals(0,component1EventHandler.getNumberOfAddEvents(localIU.getUid())); assertEquals(0, component1EventHandler.getNumberOfAddEvents(localIU.getUid()));
assertEquals(localIU.getUid(), component2StoreHandler.getAddedIUs().get(0).getUid()); assertEquals(localIU.getUid(), component2StoreHandler.getAddedIUs().get(0).getUid());
} }
@Test @Test
public void testIUCommit() throws InterruptedException public void testIUCommit() throws InterruptedException
{ {
outBuffer.add(localIU); outBuffer.add(localIU);
localIU.commit(); localIU.commit();
Thread.sleep(200); Thread.sleep(200);
assertEquals(0,component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertEquals(0, component1EventHandler.getNumberOfCommitEvents(localIU.getUid()));
assertEquals(0,component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertEquals(0, component2EventHandler.getNumberOfCommitEvents(localIU.getUid()));
assertFalse(component2StoreHandler.getAddedIUs().get(0).isCommitted()); assertFalse(component2StoreHandler.getAddedIUs().get(0).isCommitted());
} }
@Test @Test
public void testIUCommitBeforePublish() throws InterruptedException public void testIUCommitBeforePublish() throws InterruptedException
{ {
localIU.commit(); localIU.commit();
outBuffer.add(localIU); outBuffer.add(localIU);
Thread.sleep(200); Thread.sleep(200);
assertEquals(0,component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertEquals(0, component1EventHandler.getNumberOfCommitEvents(localIU.getUid()));
assertEquals(0,component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertEquals(0, component2EventHandler.getNumberOfCommitEvents(localIU.getUid()));
assertTrue(component2StoreHandler.getAddedIUs().get(0).isCommitted()); assertTrue(component2StoreHandler.getAddedIUs().get(0).isCommitted());
} }
@Test @Test
public void testIUCommitFromInputBuffer() throws InterruptedException public void testIUCommitFromInputBuffer() throws InterruptedException
{ {
outBuffer.add(localIU); outBuffer.add(localIU);
Thread.sleep(200); Thread.sleep(200);
AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0); AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0);
iuIn.commit(); iuIn.commit();
Thread.sleep(200); Thread.sleep(200);
assertFalse(localIU.isCommitted()); assertFalse(localIU.isCommitted());
assertEquals(0,component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertEquals(0, component1EventHandler.getNumberOfCommitEvents(localIU.getUid()));
assertEquals(0,component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertEquals(0, component2EventHandler.getNumberOfCommitEvents(localIU.getUid()));
} }
@Test @Test
public void testIUUpdate() throws InterruptedException public void testIUUpdate() throws InterruptedException
{ {
outBuffer.add(localIU); outBuffer.add(localIU);
Thread.sleep(200); Thread.sleep(200);
AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0); AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0);
assertNull(iuIn.getPayload().get("key2")); assertNull(iuIn.getPayload().get("key2"));
localIU.getPayload().put("key2", "value2"); localIU.getPayload().put("key2", "value2");
Thread.sleep(200); Thread.sleep(200);
assertEquals(null, iuIn.getPayload().get("key2")); assertEquals(null, iuIn.getPayload().get("key2"));
assertEquals(0,component2EventHandler.getNumberOfUpdateEvents(localIU.getUid())); assertEquals(0, component2EventHandler.getNumberOfUpdateEvents(localIU.getUid()));
assertEquals(0,component1EventHandler.getNumberOfUpdateEvents(localIU.getUid())); assertEquals(0, component1EventHandler.getNumberOfUpdateEvents(localIU.getUid()));
} }
@Test @Test
public void testIUUpdateBeforePublish() throws InterruptedException public void testIUUpdateBeforePublish() throws InterruptedException
{ {
localIU.getPayload().put("key2", "value2"); localIU.getPayload().put("key2", "value2");
outBuffer.add(localIU); outBuffer.add(localIU);
Thread.sleep(200); Thread.sleep(200);
AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0); AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0);
assertEquals("value2", iuIn.getPayload().get("key2")); assertEquals("value2", iuIn.getPayload().get("key2"));
}
private void fillBuffer(int val)
{
LocalMessageIU iu = new LocalMessageIU();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < 1000000; i++)
{
buffer.append(val);
}
iu.setCategory("");
iu.getPayload().put("x", buffer.toString());
outBuffer.add(iu);
}
@Test
public void testManyMessages()
{
for (int i = 0; i < 1000; i++)
{
fillBuffer(i);
}
} }
} }
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<artifact type="py.zip" ext="py.zip"/> <artifact type="py.zip" ext="py.zip"/>
</publications> </publications>
<dependencies> <dependencies>
<dependency org="google" name="protobuf" rev="latest.release"/> <dependency org="google" name="protobuf-python" rev="latest.release"/>
<dependency org="rsb" name="rsb" rev="latest.release"/> <dependency org="rsb" name="rsb-python" rev="latest.release"/>
</dependencies> </dependencies>
</ivy-module> </ivy-module>
<ivy-module version="2.0"> <ivy-module version="2.0">
<info organisation="ipaaca" module="IpaacaPythonTest"/> <info organisation="ipaaca" module="IpaacaPythonTest"/>
<dependencies> <dependencies>
<dependency org="hamcrest" name="hamcrest" rev="latest.release"/> <dependency org="hamcrest" name="hamcrest-python" rev="latest.release"/>
<dependency org="mockito" name="mockito" rev="latest.release" /> <dependency org="mockito" name="mockito-python" rev="latest.release" />
</dependencies> </dependencies>
</ivy-module> </ivy-module>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment