ServiceReference inOnly = new ServiceReferenceImpl(
new QName("exchange-copy"), new InOnlyService(), _domain, null);
ExchangeDispatcher dispatch = _provider.createDispatcher(inOnly);
Exchange ex = dispatch.createExchange(null, ExchangePattern.IN_ONLY);
Context ctx = ex.getContext();
ctx.setProperty("message-prop", "message-val", Scope.MESSAGE);
ctx.setProperty("exchange-prop", "exchange-val", Scope.EXCHANGE).addLabels(BehaviorLabel.TRANSIENT.label());
Assert.assertEquals(ctx.getProperty("message-prop", Scope.MESSAGE).getValue(), "message-val");
Assert.assertEquals(ctx.getProperty("exchange-prop", Scope.EXCHANGE).getValue(), "exchange-val");
Assert.assertTrue(ctx.getProperty("exchange-prop", Scope.EXCHANGE).getLabels().contains(BehaviorLabel.TRANSIENT.label()));
// Merge the context from ex into the context for ex2
Exchange ex2 = dispatch.createExchange(null, ExchangePattern.IN_ONLY);
Context ctx2 = ex2.getContext();
ctx.mergeInto(ctx2);
Assert.assertNotNull(ctx2.getProperty("message-prop", Scope.MESSAGE));
Assert.assertNull(ctx2.getProperty("exchange-prop", Scope.EXCHANGE));
}