diff --git a/ipaacalib/java/src/ipaaca/OutputBuffer.java b/ipaacalib/java/src/ipaaca/OutputBuffer.java index 02cbd557851006945d1250ae49ef50a49fa265ac..de5e64652e465c3376522d9007183ccdc48b236e 100644 --- a/ipaacalib/java/src/ipaaca/OutputBuffer.java +++ b/ipaacalib/java/src/ipaaca/OutputBuffer.java @@ -315,7 +315,10 @@ public class OutputBuffer extends Buffer { throw new IUPublishedException(iu); } - iuStore.put(iu.getUid(), iu); + if(!(iu instanceof LocalMessageIU)) + { + iuStore.put(iu.getUid(), iu); + } iu.setBuffer(this); publishIU(iu); } diff --git a/ipaacalib/java/test/src/ipaaca/ComponentMessageCommunicationIntegrationTest.java b/ipaacalib/java/test/src/ipaaca/ComponentMessageCommunicationIntegrationTest.java index 40d23e87bb8c51b65dad5a81eb3db15c5971a942..f678a1245019332a3594e503ff1c346e27c3ff8b 100644 --- a/ipaacalib/java/test/src/ipaaca/ComponentMessageCommunicationIntegrationTest.java +++ b/ipaacalib/java/test/src/ipaaca/ComponentMessageCommunicationIntegrationTest.java @@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableSet; /** * Test communication of the 'MESSAGE' type between IUs * @author hvanwelbergen - * + * */ public class ComponentMessageCommunicationIntegrationTest { @@ -29,118 +29,140 @@ public class ComponentMessageCommunicationIntegrationTest { Initializer.initializeIpaacaRsb(); } - + private OutputBuffer outBuffer; private InputBuffer inBuffer; private LocalMessageIU localIU; - private CountingEventHandler component1EventHandler; + private CountingEventHandler component1EventHandler; private CountingEventHandler component2EventHandler; private StoringEventHandler component1StoreHandler = new StoringEventHandler(); private StoringEventHandler component2StoreHandler = new StoringEventHandler(); private static final String CATEGORY = "category1"; - + @Before public void setup() { 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); - 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(); component1EventHandler = new CountingEventHandler(); - inBuffer.registerHandler(new IUEventHandler(component2EventHandler,types,categories)); - outBuffer.registerHandler(new IUEventHandler(component1EventHandler,types,categories)); - inBuffer.registerHandler(new IUEventHandler(component2StoreHandler,types,categories)); - outBuffer.registerHandler(new IUEventHandler(component1StoreHandler,types,categories)); - + inBuffer.registerHandler(new IUEventHandler(component2EventHandler, types, categories)); + outBuffer.registerHandler(new IUEventHandler(component1EventHandler, types, categories)); + inBuffer.registerHandler(new IUEventHandler(component2StoreHandler, types, categories)); + outBuffer.registerHandler(new IUEventHandler(component1StoreHandler, types, categories)); + localIU = new LocalMessageIU(); localIU.setCategory(CATEGORY); localIU.getPayload().put("key1", "item1"); - localIU.addLinks("INIT", ImmutableSet.of("init1","init2")); + localIU.addLinks("INIT", ImmutableSet.of("init1", "init2")); } - + @After public void tearDown() { inBuffer.close(); outBuffer.close(); } - + @Test public void testAddedIU() throws InterruptedException { outBuffer.add(localIU); - Thread.sleep(200); + Thread.sleep(200); AbstractIU iuIn = inBuffer.getIU(localIU.getUid()); assertNull(iuIn); - assertThat(localIU.getLinks("INIT"),containsInAnyOrder("init1","init2")); - assertEquals(1,component2EventHandler.getNumberOfAddEvents(localIU.getUid())); - assertEquals(0,component1EventHandler.getNumberOfAddEvents(localIU.getUid())); - assertEquals(1,component2EventHandler.getNumberOfAddEvents(localIU.getUid())); - assertEquals(0,component1EventHandler.getNumberOfAddEvents(localIU.getUid())); + assertThat(localIU.getLinks("INIT"), containsInAnyOrder("init1", "init2")); + assertEquals(1, component2EventHandler.getNumberOfAddEvents(localIU.getUid())); + assertEquals(0, component1EventHandler.getNumberOfAddEvents(localIU.getUid())); + assertEquals(1, component2EventHandler.getNumberOfAddEvents(localIU.getUid())); + assertEquals(0, component1EventHandler.getNumberOfAddEvents(localIU.getUid())); assertEquals(localIU.getUid(), component2StoreHandler.getAddedIUs().get(0).getUid()); - } - + } + @Test public void testIUCommit() throws InterruptedException { outBuffer.add(localIU); localIU.commit(); Thread.sleep(200); - assertEquals(0,component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); - assertEquals(0,component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); + assertEquals(0, component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); + assertEquals(0, component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertFalse(component2StoreHandler.getAddedIUs().get(0).isCommitted()); } - + @Test public void testIUCommitBeforePublish() throws InterruptedException { localIU.commit(); - outBuffer.add(localIU); + outBuffer.add(localIU); Thread.sleep(200); - assertEquals(0,component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); - assertEquals(0,component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); + assertEquals(0, component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); + assertEquals(0, component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); assertTrue(component2StoreHandler.getAddedIUs().get(0).isCommitted()); } - + @Test public void testIUCommitFromInputBuffer() throws InterruptedException { outBuffer.add(localIU); Thread.sleep(200); AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0); - + iuIn.commit(); Thread.sleep(200); assertFalse(localIU.isCommitted()); - assertEquals(0,component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); - assertEquals(0,component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); + assertEquals(0, component1EventHandler.getNumberOfCommitEvents(localIU.getUid())); + assertEquals(0, component2EventHandler.getNumberOfCommitEvents(localIU.getUid())); } - + @Test public void testIUUpdate() throws InterruptedException { outBuffer.add(localIU); - Thread.sleep(200); + Thread.sleep(200); AbstractIU iuIn = component2StoreHandler.getAddedIUs().get(0); assertNull(iuIn.getPayload().get("key2")); - + localIU.getPayload().put("key2", "value2"); Thread.sleep(200); assertEquals(null, iuIn.getPayload().get("key2")); - assertEquals(0,component2EventHandler.getNumberOfUpdateEvents(localIU.getUid())); - assertEquals(0,component1EventHandler.getNumberOfUpdateEvents(localIU.getUid())); + assertEquals(0, component2EventHandler.getNumberOfUpdateEvents(localIU.getUid())); + assertEquals(0, component1EventHandler.getNumberOfUpdateEvents(localIU.getUid())); } - + @Test public void testIUUpdateBeforePublish() throws InterruptedException { localIU.getPayload().put("key2", "value2"); outBuffer.add(localIU); - - Thread.sleep(200); + + Thread.sleep(200); 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); + } } } diff --git a/ipaacalib/python/ivy.xml b/ipaacalib/python/ivy.xml index e037daf6f2c7ca0073f3be9cfd82cc8c44d00387..6746fd8837a3f96365383a4562a31e1d67238962 100644 --- a/ipaacalib/python/ivy.xml +++ b/ipaacalib/python/ivy.xml @@ -4,8 +4,8 @@ <artifact type="py.zip" ext="py.zip"/> </publications> <dependencies> - <dependency org="google" name="protobuf" rev="latest.release"/> - <dependency org="rsb" name="rsb" rev="latest.release"/> + <dependency org="google" name="protobuf-python" rev="latest.release"/> + <dependency org="rsb" name="rsb-python" rev="latest.release"/> </dependencies> </ivy-module> diff --git a/ipaacalib/python/test/ivy.xml b/ipaacalib/python/test/ivy.xml index bdf74d730b17e7cee2ec18edc742440be1ddda2c..1e4d577a068bb000bea110e43879e11f2dc57063 100644 --- a/ipaacalib/python/test/ivy.xml +++ b/ipaacalib/python/test/ivy.xml @@ -1,7 +1,7 @@ <ivy-module version="2.0"> <info organisation="ipaaca" module="IpaacaPythonTest"/> <dependencies> - <dependency org="hamcrest" name="hamcrest" rev="latest.release"/> - <dependency org="mockito" name="mockito" rev="latest.release" /> + <dependency org="hamcrest" name="hamcrest-python" rev="latest.release"/> + <dependency org="mockito" name="mockito-python" rev="latest.release" /> </dependencies> </ivy-module>