use of org.springframework.util.IdGenerator in project spring-integration by spring-projects.
the class MessageIdGenerationTests method testCustomIdGenerationWithChildRegistrarClosed.
@Test
public void testCustomIdGenerationWithChildRegistrarClosed() throws Exception {
ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext("MessageIdGenerationTests-context.xml", this.getClass());
ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext(new String[] { "MessageIdGenerationTests-context-withGenerator.xml" }, this.getClass(), parent);
IdGenerator idGenerator = child.getBean("idGenerator", IdGenerator.class);
Mockito.reset(idGenerator);
MessageChannel inputChannel = child.getBean("input", MessageChannel.class);
inputChannel.send(new GenericMessage<Integer>(0));
verify(idGenerator, atLeastOnce()).generateId();
child.close();
parent.close();
this.assertDestroy();
}
use of org.springframework.util.IdGenerator in project spring-integration by spring-projects.
the class MessageIdGenerationTests method testCustomIdGenerationWithParentRegistrar.
@Test
public void testCustomIdGenerationWithParentRegistrar() throws Exception {
ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext("MessageIdGenerationTests-context-withGenerator.xml", this.getClass());
ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext(new String[] { "MessageIdGenerationTests-context.xml" }, this.getClass(), parent);
IdGenerator idGenerator = child.getBean("idGenerator", IdGenerator.class);
MessageChannel inputChannel = child.getBean("input", MessageChannel.class);
inputChannel.send(new GenericMessage<Integer>(0));
verify(idGenerator, atLeastOnce()).generateId();
child.close();
parent.close();
this.assertDestroy();
}
use of org.springframework.util.IdGenerator in project spring-integration by spring-projects.
the class MessageIdGenerationTests method testCustomIdGenerationWithChildRegistrar.
@Test
public void testCustomIdGenerationWithChildRegistrar() throws Exception {
ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext("MessageIdGenerationTests-context.xml", this.getClass());
ClassPathXmlApplicationContext child = new ClassPathXmlApplicationContext(new String[] { "MessageIdGenerationTests-context-withGenerator.xml" }, this.getClass(), parent);
IdGenerator idGenerator = child.getBean("idGenerator", IdGenerator.class);
Mockito.reset(idGenerator);
MessageChannel inputChannel = child.getBean("input", MessageChannel.class);
inputChannel.send(new GenericMessage<Integer>(0));
verify(idGenerator, atLeastOnce()).generateId();
child.close();
parent.close();
this.assertDestroy();
}
use of org.springframework.util.IdGenerator in project spring-integration by spring-projects.
the class IdGeneratorConfigurerTests method testJdk.
@Test
public void testJdk() {
GenericApplicationContext context = new GenericApplicationContext();
context.registerBeanDefinition("bfpp", new RootBeanDefinition(DefaultConfiguringBeanFactoryPostProcessor.class));
context.registerBeanDefinition("foo", new RootBeanDefinition(JdkIdGenerator.class));
context.refresh();
MessageHeaders headers = new MessageHeaders(null);
assertSame(context.getBean(IdGenerator.class), TestUtils.getPropertyValue(headers, "idGenerator"));
context.close();
}
use of org.springframework.util.IdGenerator in project spring-integration by spring-projects.
the class IdGeneratorConfigurerTests method testIncrementing.
@Test
public void testIncrementing() {
GenericApplicationContext context = new GenericApplicationContext();
context.registerBeanDefinition("bfpp", new RootBeanDefinition(DefaultConfiguringBeanFactoryPostProcessor.class));
context.registerBeanDefinition("foo", new RootBeanDefinition(SimpleIncrementingIdGenerator.class));
context.refresh();
IdGenerator idGenerator = context.getBean(IdGenerator.class);
MessageHeaders headers = new MessageHeaders(null);
assertEquals(0, headers.getId().getMostSignificantBits());
assertEquals(1, headers.getId().getLeastSignificantBits());
headers = new MessageHeaders(null);
assertEquals(0, headers.getId().getMostSignificantBits());
assertEquals(2, headers.getId().getLeastSignificantBits());
AtomicLong bottomBits = TestUtils.getPropertyValue(idGenerator, "bottomBits", AtomicLong.class);
bottomBits.set(0xffffffff);
headers = new MessageHeaders(null);
assertEquals(1, headers.getId().getMostSignificantBits());
assertEquals(0, headers.getId().getLeastSignificantBits());
headers = new MessageHeaders(null);
assertEquals(1, headers.getId().getMostSignificantBits());
assertEquals(1, headers.getId().getLeastSignificantBits());
context.close();
}
Aggregations