-// @Test
-// Run this test only if demanded because it takes 15s to run
- public void testInitializationThreads() throws Exception {
-
- /*Setting answer which will hold the answer for 5s*/
- Mockito.when(entityOwnershipService.registerCandidate(entity)).thenAnswer(new Answer<EntityOwnershipService>() {
- @Override
- public EntityOwnershipService answer(final InvocationOnMock invocationOnMock) throws Throwable {
- LOG.info("Sleeping this thread for 14s");
- Thread.sleep(14000L);
- return null;
- }
- });
-
- Thread t1 = new Thread(new Runnable() {
- @Override
- public void run() {
- LOG.info("Starting thread 1");
- Assert.assertTrue(roleContext.initialization());
- }
- });
-
- Thread t2 = new Thread(new Runnable() {
- @Override
- public void run() {
- LOG.info("Starting thread 2");
- Assert.assertFalse(roleContext.initialization());
- }
- });
-
- t1.start();
- LOG.info("Sleeping main thread for 1s to prevent race condition.");
- Thread.sleep(1000L);
- t2.start();
-
- while (t2.isAlive()) {
- //Waiting
- }
+ @Test
+ public void testCreateRequestContext() throws Exception {
+ roleContext.createRequestContext();
+ Mockito.verify(deviceInfo).reserveXidForDeviceMessage();
+ }