|
@@ -20,15 +20,16 @@ package org.apache.hadoop.service;
|
|
|
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.service.Service.STATE;
|
|
import org.apache.hadoop.service.Service.STATE;
|
|
-import org.junit.Before;
|
|
|
|
-import org.junit.Test;
|
|
|
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
|
+import org.junit.jupiter.api.Timeout;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
|
-import static org.junit.Assert.assertFalse;
|
|
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
|
-import static org.junit.Assert.fail;
|
|
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
+import static org.junit.jupiter.api.Assertions.fail;
|
|
|
|
|
|
public class TestCompositeService {
|
|
public class TestCompositeService {
|
|
|
|
|
|
@@ -47,7 +48,7 @@ public class TestCompositeService {
|
|
private static final boolean STOP_ONLY_STARTED_SERVICES =
|
|
private static final boolean STOP_ONLY_STARTED_SERVICES =
|
|
CompositeServiceImpl.isPolicyToStopOnlyStartedServices();
|
|
CompositeServiceImpl.isPolicyToStopOnlyStartedServices();
|
|
|
|
|
|
- @Before
|
|
|
|
|
|
+ @BeforeEach
|
|
public void setup() {
|
|
public void setup() {
|
|
CompositeServiceImpl.resetCounter();
|
|
CompositeServiceImpl.resetCounter();
|
|
}
|
|
}
|
|
@@ -65,8 +66,8 @@ public class TestCompositeService {
|
|
CompositeServiceImpl[] services = serviceManager.getServices().toArray(
|
|
CompositeServiceImpl[] services = serviceManager.getServices().toArray(
|
|
new CompositeServiceImpl[0]);
|
|
new CompositeServiceImpl[0]);
|
|
|
|
|
|
- assertEquals("Number of registered services ", NUM_OF_SERVICES,
|
|
|
|
- services.length);
|
|
|
|
|
|
+ assertEquals(NUM_OF_SERVICES, services.length,
|
|
|
|
+ "Number of registered services ");
|
|
|
|
|
|
Configuration conf = new Configuration();
|
|
Configuration conf = new Configuration();
|
|
// Initialise the composite service
|
|
// Initialise the composite service
|
|
@@ -77,9 +78,9 @@ public class TestCompositeService {
|
|
|
|
|
|
// Verify the init() call sequence numbers for every service
|
|
// Verify the init() call sequence numbers for every service
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
- assertEquals("For " + services[i]
|
|
|
|
- + " service, init() call sequence number should have been ", i,
|
|
|
|
- services[i].getCallSequenceNumber());
|
|
|
|
|
|
+ assertEquals(i, services[i].getCallSequenceNumber(),
|
|
|
|
+ "For " + services[i] +
|
|
|
|
+ " service, init() call sequence number should have been ");
|
|
}
|
|
}
|
|
|
|
|
|
// Reset the call sequence numbers
|
|
// Reset the call sequence numbers
|
|
@@ -91,9 +92,9 @@ public class TestCompositeService {
|
|
|
|
|
|
// Verify the start() call sequence numbers for every service
|
|
// Verify the start() call sequence numbers for every service
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
- assertEquals("For " + services[i]
|
|
|
|
- + " service, start() call sequence number should have been ", i,
|
|
|
|
- services[i].getCallSequenceNumber());
|
|
|
|
|
|
+ assertEquals(i,
|
|
|
|
+ services[i].getCallSequenceNumber(), "For " + services[i] +
|
|
|
|
+ " service, start() call sequence number should have been ");
|
|
}
|
|
}
|
|
resetServices(services);
|
|
resetServices(services);
|
|
|
|
|
|
@@ -104,18 +105,18 @@ public class TestCompositeService {
|
|
|
|
|
|
// Verify the stop() call sequence numbers for every service
|
|
// Verify the stop() call sequence numbers for every service
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
- assertEquals("For " + services[i]
|
|
|
|
- + " service, stop() call sequence number should have been ",
|
|
|
|
- ((NUM_OF_SERVICES - 1) - i), services[i].getCallSequenceNumber());
|
|
|
|
|
|
+ assertEquals(((NUM_OF_SERVICES - 1) - i), services[i].getCallSequenceNumber(),
|
|
|
|
+ "For " + services[i] +
|
|
|
|
+ " service, stop() call sequence number should have been ");
|
|
}
|
|
}
|
|
|
|
|
|
// Try to stop again. This should be a no-op.
|
|
// Try to stop again. This should be a no-op.
|
|
serviceManager.stop();
|
|
serviceManager.stop();
|
|
// Verify that stop() call sequence numbers for every service don't change.
|
|
// Verify that stop() call sequence numbers for every service don't change.
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
for (int i = 0; i < NUM_OF_SERVICES; i++) {
|
|
- assertEquals("For " + services[i]
|
|
|
|
- + " service, stop() call sequence number should have been ",
|
|
|
|
- ((NUM_OF_SERVICES - 1) - i), services[i].getCallSequenceNumber());
|
|
|
|
|
|
+ assertEquals(((NUM_OF_SERVICES - 1) - i), services[i].getCallSequenceNumber(),
|
|
|
|
+ "For " + services[i] +
|
|
|
|
+ " service, stop() call sequence number should have been ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -155,11 +156,11 @@ public class TestCompositeService {
|
|
for (int i = 0; i < NUM_OF_SERVICES - 1; i++) {
|
|
for (int i = 0; i < NUM_OF_SERVICES - 1; i++) {
|
|
if (i >= FAILED_SERVICE_SEQ_NUMBER && STOP_ONLY_STARTED_SERVICES) {
|
|
if (i >= FAILED_SERVICE_SEQ_NUMBER && STOP_ONLY_STARTED_SERVICES) {
|
|
// Failed service state should be INITED
|
|
// Failed service state should be INITED
|
|
- assertEquals("Service state should have been ", STATE.INITED,
|
|
|
|
- services[NUM_OF_SERVICES - 1].getServiceState());
|
|
|
|
|
|
+ assertEquals(STATE.INITED, services[NUM_OF_SERVICES - 1].getServiceState(),
|
|
|
|
+ "Service state should have been ");
|
|
} else {
|
|
} else {
|
|
- assertEquals("Service state should have been ", STATE.STOPPED,
|
|
|
|
- services[i].getServiceState());
|
|
|
|
|
|
+ assertEquals(STATE.STOPPED, services[i].getServiceState(),
|
|
|
|
+ "Service state should have been ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -223,10 +224,8 @@ public class TestCompositeService {
|
|
}
|
|
}
|
|
|
|
|
|
private void assertInState(STATE expected, Service service) {
|
|
private void assertInState(STATE expected, Service service) {
|
|
- assertEquals("Service state should have been " + expected + " in "
|
|
|
|
- + service,
|
|
|
|
- expected,
|
|
|
|
- service.getServiceState());
|
|
|
|
|
|
+ assertEquals(expected, service.getServiceState(),
|
|
|
|
+ "Service state should have been " + expected + " in " + service);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -313,24 +312,24 @@ public class TestCompositeService {
|
|
assertInState(STATE.INITED, child);
|
|
assertInState(STATE.INITED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test (timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddIfService() {
|
|
public void testAddIfService() {
|
|
CompositeService testService = new CompositeService("TestService") {
|
|
CompositeService testService = new CompositeService("TestService") {
|
|
Service service;
|
|
Service service;
|
|
@Override
|
|
@Override
|
|
public void serviceInit(Configuration conf) {
|
|
public void serviceInit(Configuration conf) {
|
|
Integer notAService = new Integer(0);
|
|
Integer notAService = new Integer(0);
|
|
- assertFalse("Added an integer as a service",
|
|
|
|
- addIfService(notAService));
|
|
|
|
|
|
+ assertFalse(addIfService(notAService), "Added an integer as a service");
|
|
|
|
|
|
service = new AbstractService("Service") {};
|
|
service = new AbstractService("Service") {};
|
|
- assertTrue("Unable to add a service", addIfService(service));
|
|
|
|
|
|
+ assertTrue(addIfService(service), "Unable to add a service");
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
testService.init(new Configuration());
|
|
testService.init(new Configuration());
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, testService.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, testService.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -339,8 +338,7 @@ public class TestCompositeService {
|
|
@Override
|
|
@Override
|
|
public void serviceInit(Configuration conf) {
|
|
public void serviceInit(Configuration conf) {
|
|
Integer notAService = new Integer(0);
|
|
Integer notAService = new Integer(0);
|
|
- assertFalse("Added an integer as a service",
|
|
|
|
- addIfService(notAService));
|
|
|
|
|
|
+ assertFalse(addIfService(notAService), "Added an integer as a service");
|
|
|
|
|
|
Service service1 = new AbstractService("Service1") {};
|
|
Service service1 = new AbstractService("Service1") {};
|
|
addIfService(service1);
|
|
addIfService(service1);
|
|
@@ -356,15 +354,16 @@ public class TestCompositeService {
|
|
};
|
|
};
|
|
|
|
|
|
testService.init(new Configuration());
|
|
testService.init(new Configuration());
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, testService.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, testService.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
//
|
|
// Tests for adding child service to parent
|
|
// Tests for adding child service to parent
|
|
//
|
|
//
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedChildBeforeInit() throws Throwable {
|
|
public void testAddUninitedChildBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -377,7 +376,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, child);
|
|
assertInState(STATE.STOPPED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedChildInInit() throws Throwable {
|
|
public void testAddUninitedChildInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -393,11 +393,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.NOTINITED, child);
|
|
assertInState(STATE.NOTINITED, child);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.NOTINITED, child);
|
|
assertInState(STATE.NOTINITED, child);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedChildInStart() throws Throwable {
|
|
public void testAddUninitedChildInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -409,7 +410,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.NOTINITED, child);
|
|
assertInState(STATE.NOTINITED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedChildInStop() throws Throwable {
|
|
public void testAddUninitedChildInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -420,7 +422,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.NOTINITED, child);
|
|
assertInState(STATE.NOTINITED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedChildBeforeInit() throws Throwable {
|
|
public void testAddInitedChildBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -434,7 +437,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, child);
|
|
assertInState(STATE.STOPPED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedChildInInit() throws Throwable {
|
|
public void testAddInitedChildInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -447,7 +451,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, child);
|
|
assertInState(STATE.STOPPED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedChildInStart() throws Throwable {
|
|
public void testAddInitedChildInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -460,7 +465,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, child);
|
|
assertInState(STATE.STOPPED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedChildInStop() throws Throwable {
|
|
public void testAddInitedChildInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -472,7 +478,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.INITED, child);
|
|
assertInState(STATE.INITED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedChildBeforeInit() throws Throwable {
|
|
public void testAddStartedChildBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -486,11 +493,12 @@ public class TestCompositeService {
|
|
//expected
|
|
//expected
|
|
}
|
|
}
|
|
parent.stop();
|
|
parent.stop();
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedChildInInit() throws Throwable {
|
|
public void testAddStartedChildInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -504,7 +512,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, child);
|
|
assertInState(STATE.STOPPED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedChildInStart() throws Throwable {
|
|
public void testAddStartedChildInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -518,7 +527,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, child);
|
|
assertInState(STATE.STOPPED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedChildInStop() throws Throwable {
|
|
public void testAddStartedChildInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -531,7 +541,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STARTED, child);
|
|
assertInState(STATE.STARTED, child);
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedChildBeforeInit() throws Throwable {
|
|
public void testAddStoppedChildBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -546,11 +557,12 @@ public class TestCompositeService {
|
|
//expected
|
|
//expected
|
|
}
|
|
}
|
|
parent.stop();
|
|
parent.stop();
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedChildInInit() throws Throwable {
|
|
public void testAddStoppedChildInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -567,11 +579,12 @@ public class TestCompositeService {
|
|
}
|
|
}
|
|
assertInState(STATE.STOPPED, child);
|
|
assertInState(STATE.STOPPED, child);
|
|
parent.stop();
|
|
parent.stop();
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedChildInStart() throws Throwable {
|
|
public void testAddStoppedChildInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -584,7 +597,8 @@ public class TestCompositeService {
|
|
parent.stop();
|
|
parent.stop();
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedChildInStop() throws Throwable {
|
|
public void testAddStoppedChildInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService child = new BreakableService();
|
|
BreakableService child = new BreakableService();
|
|
@@ -601,7 +615,8 @@ public class TestCompositeService {
|
|
// Tests for adding sibling service to parent
|
|
// Tests for adding sibling service to parent
|
|
//
|
|
//
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedSiblingBeforeInit() throws Throwable {
|
|
public void testAddUninitedSiblingBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -614,11 +629,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedSiblingInInit() throws Throwable {
|
|
public void testAddUninitedSiblingInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -633,11 +649,12 @@ public class TestCompositeService {
|
|
//expected
|
|
//expected
|
|
}
|
|
}
|
|
parent.stop();
|
|
parent.stop();
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedSiblingInStart() throws Throwable {
|
|
public void testAddUninitedSiblingInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -650,11 +667,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddUninitedSiblingInStop() throws Throwable {
|
|
public void testAddUninitedSiblingInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -667,11 +685,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
assertInState(STATE.NOTINITED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedSiblingBeforeInit() throws Throwable {
|
|
public void testAddInitedSiblingBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -685,11 +704,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.INITED, sibling);
|
|
assertInState(STATE.INITED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.INITED, sibling);
|
|
assertInState(STATE.INITED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedSiblingInInit() throws Throwable {
|
|
public void testAddInitedSiblingInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -703,11 +723,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.STARTED, sibling);
|
|
assertInState(STATE.STARTED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedSiblingInStart() throws Throwable {
|
|
public void testAddInitedSiblingInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -721,11 +742,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.INITED, sibling);
|
|
assertInState(STATE.INITED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddInitedSiblingInStop() throws Throwable {
|
|
public void testAddInitedSiblingInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -736,7 +758,8 @@ public class TestCompositeService {
|
|
parent.init(new Configuration());
|
|
parent.init(new Configuration());
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedSiblingBeforeInit() throws Throwable {
|
|
public void testAddStartedSiblingBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -751,11 +774,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.STARTED, sibling);
|
|
assertInState(STATE.STARTED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STARTED, sibling);
|
|
assertInState(STATE.STARTED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedSiblingInInit() throws Throwable {
|
|
public void testAddStartedSiblingInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -770,12 +794,13 @@ public class TestCompositeService {
|
|
assertInState(STATE.STARTED, sibling);
|
|
assertInState(STATE.STARTED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedSiblingInStart() throws Throwable {
|
|
public void testAddStartedSiblingInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -790,11 +815,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.STARTED, sibling);
|
|
assertInState(STATE.STARTED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStartedSiblingInStop() throws Throwable {
|
|
public void testAddStartedSiblingInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -809,11 +835,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.STARTED, sibling);
|
|
assertInState(STATE.STARTED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STARTED, sibling);
|
|
assertInState(STATE.STARTED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedSiblingBeforeInit() throws Throwable {
|
|
public void testAddStoppedSiblingBeforeInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -829,11 +856,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 1, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(1, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedSiblingInInit() throws Throwable {
|
|
public void testAddStoppedSiblingInInit() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -853,11 +881,12 @@ public class TestCompositeService {
|
|
}
|
|
}
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedSiblingInStart() throws Throwable {
|
|
public void testAddStoppedSiblingInStart() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -873,11 +902,12 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
- @Test(timeout = 10000)
|
|
|
|
|
|
+ @Test
|
|
|
|
+ @Timeout(value = 10)
|
|
public void testAddStoppedSiblingInStop() throws Throwable {
|
|
public void testAddStoppedSiblingInStop() throws Throwable {
|
|
CompositeService parent = new CompositeService("parent");
|
|
CompositeService parent = new CompositeService("parent");
|
|
BreakableService sibling = new BreakableService();
|
|
BreakableService sibling = new BreakableService();
|
|
@@ -893,8 +923,8 @@ public class TestCompositeService {
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
parent.stop();
|
|
parent.stop();
|
|
assertInState(STATE.STOPPED, sibling);
|
|
assertInState(STATE.STOPPED, sibling);
|
|
- assertEquals("Incorrect number of services",
|
|
|
|
- 2, parent.getServices().size());
|
|
|
|
|
|
+ assertEquals(2, parent.getServices().size(),
|
|
|
|
+ "Incorrect number of services");
|
|
}
|
|
}
|
|
|
|
|
|
public static class CompositeServiceAddingAChild extends CompositeService{
|
|
public static class CompositeServiceAddingAChild extends CompositeService{
|