modules/plugins/netservices/pom.xml | 4 ---- modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/PortNetServiceComponentTest.java | 9 +++++---- 2 files changed, 5 insertions(+), 8 deletions(-)
New commits: commit 04cdaa393c5b10441d246d09a3290504fb289c3e Author: Thomas Segismont tsegismont@gmail.com Date: Tue Mar 5 10:39:39 2013 +0100
Fix netservices itest failure INetAddress.getLocalhostAddress was used to bind the server socket instead of INetAddress.getLoopbackAddress
Removed pom commented section and let unit and integration tests be deactivated by default like in all other modules
diff --git a/modules/plugins/netservices/pom.xml b/modules/plugins/netservices/pom.xml index 8a69866..03a4cbd 100644 --- a/modules/plugins/netservices/pom.xml +++ b/modules/plugins/netservices/pom.xml @@ -101,10 +101,6 @@ <plugin> <artifactId>maven-failsafe-plugin</artifactId> <configuration> - <!-- TODO: Move this test execution to a profile or respect skipTests - <skipTests>false</skipTests> - <skipITs>false</skipITs> - --> <includes> <!-- only include integration tests; normal unit tests are handled above by surefire plugin --> <include>org/rhq/plugins/netservices/itest/**/*Test.java</include> diff --git a/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/PortNetServiceComponentTest.java b/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/PortNetServiceComponentTest.java index f97b222..75a9370 100644 --- a/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/PortNetServiceComponentTest.java +++ b/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/PortNetServiceComponentTest.java @@ -60,7 +60,7 @@ public class PortNetServiceComponentTest extends NetServiceComponentTest {
private static final String SERVICE_NAME = "PortService";
- private static final String LOOPBACK = "127.0.0.1"; + private static final InetAddress LOOPBACK_ADDRESS = InetAddress.getLoopbackAddress();
private PortNetServiceComponent portNetServiceComponent;
@@ -76,10 +76,11 @@ public class PortNetServiceComponentTest extends NetServiceComponentTest { public void startSocketServer() throws Exception { LOG.info("Setting up a socket server"); // Let's bind a server socket to any available port - serverSocket = new ServerSocket(0, 50, InetAddress.getLocalHost()); + serverSocket = new ServerSocket(0, 50, LOOPBACK_ADDRESS); // Do not block indefinitely on call to #accept serverSocket.setSoTimeout(1000); serverSocketLocalPort = serverSocket.getLocalPort(); + LOG.info("Using port " + serverSocketLocalPort + " for socket server"); acceptorThread = new Thread(new Runnable() { @Override public void run() { @@ -109,7 +110,7 @@ public class PortNetServiceComponentTest extends NetServiceComponentTest { @Test(dependsOnMethods = "testPluginLoad") public void testManualAdd() throws Exception { Configuration configuration = new Configuration(); - configuration.setSimpleValue(ConfigKeys.ADDRESS, LOOPBACK); + configuration.setSimpleValue(ConfigKeys.ADDRESS, LOOPBACK_ADDRESS.getHostAddress()); configuration.setSimpleValue(ConfigKeys.PORT, String.valueOf(serverSocketLocalPort)); MergeResourceResponse response = getInventoryManager().manuallyAddResource( getPluginManager().getMetadataManager().getType(SERVICE_NAME, PLUGIN_NAME), getPlatform().getId(), @@ -143,7 +144,7 @@ public class PortNetServiceComponentTest extends NetServiceComponentTest { for (MeasurementData data : report.getTraitData()) { datas.put(data.getName(), data.getValue()); } - assertEquals(getTrait(datas, "ipAddress"), LOOPBACK); + assertEquals(getTrait(datas, "ipAddress"), LOOPBACK_ADDRESS.getHostAddress()); assertTrue(StringUtil.isNotBlank(getTrait(datas, "hostName"))); assertTrue(getMetric(datas, "connectTime") >= 0); }
rhq-commits@lists.fedorahosted.org