@Test public void testFlowVarNamesAddImmutable() throws Exception { CoreEvent event = getEventBuilder() .message(of("whatever")) .addVariable("test", "val") .build(); expectedException.expect(UnsupportedOperationException.class); event.getVariables().keySet().add("other"); }
@Test public void testMuleEventSerializationWithRawPayload() throws Exception { StringBuilder payload = new StringBuilder(); // to reproduce issue we must try to serialize something with a payload bigger than 1020 bytes for (int i = 0; i < 108; i++) { payload.append("1234567890"); } PrivilegedEvent testEvent = this.<PrivilegedEvent.Builder>getEventBuilder() .message(of(new ByteArrayInputStream(payload.toString().getBytes()))).build(); currentMuleContext.set(muleContext); byte[] serializedEvent = muleContext.getObjectSerializer().getExternalProtocol().serialize(testEvent); testEvent = muleContext.getObjectSerializer().getExternalProtocol().deserialize(serializedEvent); assertArrayEquals((byte[]) testEvent.getMessage().getPayload().getValue(), payload.toString().getBytes()); }
@Test public void testFlowVarNamesRemoveImmutable() throws Exception { CoreEvent event = getEventBuilder() .message(of("whatever")) .addVariable("test", "val") .build(); event = CoreEvent.builder(event).addVariable("test", "val").build(); expectedException.expect(UnsupportedOperationException.class); event.getVariables().keySet().remove("test"); }
@Test public void testFlowVarsNotShared() throws Exception { CoreEvent event = getEventBuilder() .message(of("whatever")) .addVariable("foo", "bar") .build(); event = CoreEvent.builder(event).addVariable("foo", "bar").build(); CoreEvent copy = CoreEvent.builder(event).build(); copy = CoreEvent.builder(copy).addVariable("foo", "bar2").build(); assertEquals("bar", event.getVariables().get("foo").getValue()); assertEquals("bar2", copy.getVariables().get("foo").getValue()); }
@Test public void testMuleEventSerializationWithRawPayload() throws Exception { StringBuilder payload = new StringBuilder(); // to reproduce issue we must try to serialize something with a payload bigger than 1020 bytes for (int i = 0; i < 108; i++) { payload.append("1234567890"); } PrivilegedEvent testEvent = this.<PrivilegedEvent.Builder>getEventBuilder() .message(of(new ByteArrayInputStream(payload.toString().getBytes()))).build(); currentMuleContext.set(muleContext); byte[] serializedEvent = muleContext.getObjectSerializer().getExternalProtocol().serialize(testEvent); testEvent = muleContext.getObjectSerializer().getExternalProtocol().deserialize(serializedEvent); assertArrayEquals((byte[]) testEvent.getMessage().getPayload().getValue(), payload.toString().getBytes()); }
@Test public void testFlowVarNamesAddImmutable() throws Exception { CoreEvent event = getEventBuilder() .message(of("whatever")) .addVariable("test", "val") .build(); expectedException.expect(UnsupportedOperationException.class); event.getVariables().keySet().add("other"); }
@Test public void testFlowVarNamesRemoveImmutable() throws Exception { CoreEvent event = getEventBuilder() .message(of("whatever")) .addVariable("test", "val") .build(); event = CoreEvent.builder(event).addVariable("test", "val").build(); expectedException.expect(UnsupportedOperationException.class); event.getVariables().keySet().remove("test"); }
@Test public void testFlowVarsNotShared() throws Exception { CoreEvent event = getEventBuilder() .message(of("whatever")) .addVariable("foo", "bar") .build(); event = CoreEvent.builder(event).addVariable("foo", "bar").build(); CoreEvent copy = CoreEvent.builder(event).build(); copy = CoreEvent.builder(copy).addVariable("foo", "bar2").build(); assertEquals("bar", event.getVariables().get("foo").getValue()); assertEquals("bar2", copy.getVariables().get("foo").getValue()); }