modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
| 6
modules/plugins/apache/src/test/java/org/rhq/plugins/apache/RuntimeConfigurationTest.java
| 66 +---
modules/plugins/apache/src/test/java/org/rhq/plugins/apache/SnmpMappingTest.java
| 140 ++++++++++
modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-defined.conf
| 2
modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-undefined.conf
| 2
modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-loaded.conf
| 4
modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-not-loaded.conf
| 4
modules/plugins/apache/src/test/resources/runtime-config/conditional/ifversion.conf
| 43 +++
modules/plugins/apache/src/test/resources/runtime-config/conditional/nested-mess.conf
| 18 -
modules/plugins/apache/src/test/resources/runtime-config/vhost-names/httpd.conf
| 5
modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-ip.conf
| 3
modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-unresolvable-hostname.conf
| 3
modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-resolvable-ip.conf
| 3
modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-unresolvable-ip.conf
| 3
modules/plugins/apache/src/test/resources/snmp-mapping/httpd.conf
| 5
modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-ip.conf
| 3
modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-unresolvable-hostname.conf
| 3
modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-resolvable-ip.conf
| 3
modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-hostname.conf
| 3
modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-ip.conf
| 3
20 files changed, 240 insertions(+), 82 deletions(-)
New commits:
commit 7fa1e7d9ad55391e989e9c4ea4276e5c8a13049e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue May 3 16:21:25 2011 +0200
Adding tests for the ability to produce the same server and port identifications as
advertised by SNMP module in various scenarios.
diff --git
a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/SnmpMappingTest.java
b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/SnmpMappingTest.java
new file mode 100644
index 0000000..0716ade
--- /dev/null
+++ b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/SnmpMappingTest.java
@@ -0,0 +1,140 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.plugins.apache;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import org.rhq.core.pluginapi.util.FileUtils;
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
+import org.rhq.plugins.apache.parser.ApacheConfigReader;
+import org.rhq.plugins.apache.parser.ApacheDirective;
+import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
+import org.rhq.plugins.apache.parser.ApacheParser;
+import org.rhq.plugins.apache.parser.ApacheParserImpl;
+import org.rhq.plugins.apache.util.HttpdAddressUtility;
+import org.rhq.plugins.apache.util.MockApacheBinaryInfo;
+import org.rhq.plugins.apache.util.MockProcessInfo;
+
+/**
+ *
+ *
+ * @author Lukas Krejci
+ */
+@Test
+public class SnmpMappingTest {
+
+ private File tmpDir;
+
+ private static final String[] VHOST_NAMES_CONFIGURATION_TEST_FILES = {
+ "snmp-mapping/httpd.conf",
+ "snmp-mapping/vhost-with-servername-by-ip.conf",
+ "snmp-mapping/vhost-with-servername-by-unresolvable-hostname.conf",
+ "snmp-mapping/vhost-without-servername-resolvable-ip.conf",
+ "snmp-mapping/vhost-without-servername-unresolvable-hostname.conf",
+ "snmp-mapping/vhost-without-servername-unresolvable-ip.conf"
+ };
+
+ private static final String[] EXPECTED_SNMP_NAMES = {
+ "the-main-server-name:42", //httpd.conf
+ "12.34.56.78:0", //vhost-with-servername-by-ip.conf
+ "this-will-never-resolve.weird-server.net:90",
//vhost-with-servername-by-unresolvable-hostname.conf
+ "<<<LOCALHOST>>>:1002",
//vhost-without-servernama-resolvable-ip.conf
+ "bogus_host_without_forward_dns:42",
//vhost-without-servername-unresolvable-hostname.conf
+ "bogus_host_without_reverse_dns:1003"
//vhost-without-servername-unresolvable-ip.conf
+ };
+
+ @BeforeClass
+ public void copyConfigurationFiles() throws Exception {
+ tmpDir = FileUtil.createTempDirectory("apache-runtime-config-tests",
null, null);
+
+ for(String path : VHOST_NAMES_CONFIGURATION_TEST_FILES) {
+ copyResourceToFile(path, new File(tmpDir, path));
+ }
+ }
+
+ @BeforeClass
+ public void initExpectedResults() throws Exception {
+ String localhost = InetAddress.getLocalHost().getHostName();
+ for(int i = 0; i < EXPECTED_SNMP_NAMES.length; ++i) {
+ EXPECTED_SNMP_NAMES[i] =
EXPECTED_SNMP_NAMES[i].replaceAll("<<<LOCALHOST>>>",
localhost);
+ }
+ }
+
+ @AfterClass
+ public void deleteConfigurationFiles() throws IOException {
+ FileUtils.purge(tmpDir, true);
+ }
+
+
+ public void testVhostNames() {
+ MockApacheBinaryInfo binfo = new MockApacheBinaryInfo();
+ binfo.setVersion("2.2.17");
+ MockProcessInfo pinfo = new MockProcessInfo();
+ pinfo.setCommandLine(new String[] {"blahblah"});
+
+ ApacheDirectiveTree tree = new ApacheDirectiveTree();
+ ApacheParser parser = new ApacheParserImpl(tree, new File(tmpDir,
"snmp-mapping").getAbsolutePath());
+ ApacheConfigReader.buildTree(new File(tmpDir,
"snmp-mapping/httpd.conf").getAbsolutePath(), parser);
+
+ HttpdAddressUtility addrUtil = HttpdAddressUtility.get("2.2.17");
+ List<ApacheDirective> vhosts = tree.search("/<VirtualHost");
+ List<String> snmpNames = new ArrayList<String>(vhosts.size() + 1);
+
snmpNames.add(addrUtil.getHttpdInternalMainServerAddressRepresentation(tree).toString(false,
false));
+ for(ApacheDirective vhost : vhosts) {
+ String vhostDef = vhost.getValues().get(0);
+ String serverName = null;
+ List<ApacheDirective> serverNames =
vhost.getChildByName("ServerName");
+ if (serverNames.size() > 0) {
+ serverName = serverNames.get(serverNames.size() -
1).getValuesAsString();
+ }
+
+ snmpNames.add(addrUtil.getHttpdInternalVirtualHostAddressRepresentation(tree,
vhostDef, serverName).toString(false, false));
+ }
+
+ assertEquals(snmpNames, Arrays.asList(EXPECTED_SNMP_NAMES));
+ }
+
+
+ private void copyResourceToFile(String resourcePath, File destination) throws
IOException {
+ InputStream input =
getClass().getClassLoader().getResourceAsStream(resourcePath);
+
+ if (input != null) {
+ destination.getParentFile().mkdirs();
+ destination.createNewFile();
+
+ StreamUtil.copy(input, new BufferedOutputStream(new
FileOutputStream(destination)), true);
+ }
+ }
+}
diff --git a/modules/plugins/apache/src/test/resources/snmp-mapping/httpd.conf
b/modules/plugins/apache/src/test/resources/snmp-mapping/httpd.conf
new file mode 100644
index 0000000..29a43eb
--- /dev/null
+++ b/modules/plugins/apache/src/test/resources/snmp-mapping/httpd.conf
@@ -0,0 +1,5 @@
+Listen 80
+Listen 127.0.0.1:90
+ServerName the-main-server-name:42
+
+Include vhost-*.conf
diff --git
a/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-ip.conf
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-ip.conf
new file mode 100644
index 0000000..978892c
--- /dev/null
+++
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-ip.conf
@@ -0,0 +1,3 @@
+<VirtualHost 127.0.0.1:1000>
+ ServerName 12.34.56.78
+</VirtualHost>
diff --git
a/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-unresolvable-hostname.conf
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-unresolvable-hostname.conf
new file mode 100644
index 0000000..d38cfc3
--- /dev/null
+++
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-with-servername-by-unresolvable-hostname.conf
@@ -0,0 +1,3 @@
+<VirtualHost 127.0.0.1:1001>
+ ServerName this-will-never-resolve.weird-server.net:90
+</VirtualHost>
diff --git
a/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-resolvable-ip.conf
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-resolvable-ip.conf
new file mode 100644
index 0000000..16586d1
--- /dev/null
+++
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-resolvable-ip.conf
@@ -0,0 +1,3 @@
+<VirtualHost 127.0.0.1:1002>
+
+</VirtualHost>
diff --git
a/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-hostname.conf
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-hostname.conf
new file mode 100644
index 0000000..3ec4c24
--- /dev/null
+++
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-hostname.conf
@@ -0,0 +1,3 @@
+<VirtualHost unresolvable-hostname.weird-domain.net:1004>
+
+</VirtualHost>
diff --git
a/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-ip.conf
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-ip.conf
new file mode 100644
index 0000000..1637446
--- /dev/null
+++
b/modules/plugins/apache/src/test/resources/snmp-mapping/vhost-without-servername-unresolvable-ip.conf
@@ -0,0 +1,3 @@
+<VirtualHost 12.34.56.78:1003>
+
+</VirtualHost>
commit 08fff40554c621710e947990b80b06734ebced6e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue May 3 16:18:18 2011 +0200
Adding IfVersion detection tests, removed the vhost-names test that will come in as
standalone test because their not part of the runtime configuration extraction
diff --git
a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/RuntimeConfigurationTest.java
b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/RuntimeConfigurationTest.java
index 260c4c6..0b7e52e 100644
---
a/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/RuntimeConfigurationTest.java
+++
b/modules/plugins/apache/src/test/java/org/rhq/plugins/apache/RuntimeConfigurationTest.java
@@ -36,6 +36,7 @@ import org.testng.annotations.Test;
import org.rhq.core.pluginapi.util.FileUtils;
import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.plugins.apache.parser.ApacheConfigReader;
import org.rhq.plugins.apache.parser.ApacheDirective;
import org.rhq.plugins.apache.parser.ApacheDirectiveTree;
@@ -61,6 +62,7 @@ public class RuntimeConfigurationTest {
"runtime-config/conditional/ifdefine-undefined.conf",
"runtime-config/conditional/ifmodule-loaded.conf",
"runtime-config/conditional/ifmodule-not-loaded.conf",
+ "runtime-config/conditional/ifversion.conf",
"runtime-config/conditional/nested-mess.conf"
};
@@ -71,29 +73,17 @@ public class RuntimeConfigurationTest {
"runtime-config/incl-order/httpd.conf"
};
- private static final String[] VHOST_NAMES_CONFIGURATION_TEST_FILES = {
- "runtime-config/vhost-names/httpd.conf",
- "runtime-config/vhost-names/vhost-with-servername-by-ip.conf",
-
"runtime-config/vhost-names/vhost-with-servername-by-unresolvable-hostname.conf",
-
"runtime-config/vhost-names/vhost-without-servername-resolvable-ip.conf",
-
"runtime-config/vhost-names/vhost-without-servername-unresolvable-ip.conf"
- };
-
@BeforeClass
public void copyConfigurationFiles() throws Exception {
tmpDir = FileUtil.createTempDirectory("apache-runtime-config-tests",
null, null);
- for(String path : CONDITIONAL_CONFIGURATION_TEST_FILES) {
+ for(String path : CONDITIONAL_CONFIGURATION_TEST_FILES) {
copyResourceToFile(path, new File(tmpDir, path));
}
for(String path : INCLUSION_ORDER_CONFIGURATION_TEST_FILES) {
copyResourceToFile(path, new File(tmpDir, path));
}
-
- for(String path : VHOST_NAMES_CONFIGURATION_TEST_FILES) {
- copyResourceToFile(path, new File(tmpDir, path));
- }
}
@AfterClass
@@ -102,12 +92,10 @@ public class RuntimeConfigurationTest {
}
public void testConditionalInclusion() {
- //TODO add tests for IfVersion!!!
-
MockApacheBinaryInfo binfo = new MockApacheBinaryInfo();
binfo.setVersion("2.2.17");
MockProcessInfo pinfo = new MockProcessInfo();
- pinfo.setCommandLine(new String[] {"/usr/sbin/httpd", "-D",
"DEFINED"});
+ pinfo.setCommandLine(new String[] {"blahblah", "-D",
"DEFINED"});
ApacheDirectiveTree tree = new ApacheDirectiveTree();
ApacheParser parser = new ApacheParserImpl(tree, new File(tmpDir,
"runtime-config/conditional").getAbsolutePath());
@@ -119,11 +107,16 @@ public class RuntimeConfigurationTest {
List<VhostSpec> expectedVhosts = new ArrayList<VhostSpec>();
- expectedVhosts.add(new VhostSpec(Collections.singleton("127.0.0.1:80"),
"ifdefine.defined"));
- expectedVhosts.add(new VhostSpec(Collections.singleton("127.0.0.1:82"),
"ifmodule.loaded.source-file"));
- expectedVhosts.add(new VhostSpec(Collections.singleton("127.0.0.1:83"),
"ifmodule.loaded.module-name"));
- expectedVhosts.add(new VhostSpec(Collections.singleton("127.0.0.1:88"),
"ifdefine.ifmodule.loaded.source-file"));
- expectedVhosts.add(new VhostSpec(Collections.singleton("127.0.0.1:89"),
"ifdefine.ifmodule.loaded.module-name"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:100"),
"ifdefine.defined"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:300"),
"ifmodule.loaded.source-file"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:301"),
"ifmodule.loaded.module-name"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:501"),
"ifversion.module-loaded.implied-equals"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:502"),
"ifversion.module-loaded.equals"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:503"),
"ifversion.module-loaded.not-equals"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:504"),
"ifversion.module-loaded.regex"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:505"),
"ifversion.module-loaded.implied-regex"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:602"),
"ifdefine.ifmodule.loaded.source-file"));
+ expectedVhosts.add(new
VhostSpec(Collections.singleton("127.0.0.1:603"),
"ifdefine.ifmodule.loaded.module-name"));
assertEquals(vhosts, expectedVhosts);
}
@@ -132,7 +125,7 @@ public class RuntimeConfigurationTest {
MockApacheBinaryInfo binfo = new MockApacheBinaryInfo();
binfo.setVersion("2.2.17");
MockProcessInfo pinfo = new MockProcessInfo();
- pinfo.setCommandLine(new String[] {"/usr/sbin/httpd"});
+ pinfo.setCommandLine(new String[] {"blahblah"});
ApacheDirectiveTree tree = new ApacheDirectiveTree();
ApacheParser parser = new ApacheParserImpl(tree, new File(tmpDir,
"runtime-config/incl-order").getAbsolutePath());
@@ -149,39 +142,14 @@ public class RuntimeConfigurationTest {
assertEquals(listens.get(2).getValuesAsString(), "82");
}
- public void testVhostNames() {
- MockApacheBinaryInfo binfo = new MockApacheBinaryInfo();
- binfo.setVersion("2.2.17");
- MockProcessInfo pinfo = new MockProcessInfo();
- pinfo.setCommandLine(new String[] {"/usr/sbin/httpd"});
-
- ApacheDirectiveTree tree = new ApacheDirectiveTree();
- ApacheParser parser = new ApacheParserImpl(tree, new File(tmpDir,
"runtime-config/vhost-names").getAbsolutePath());
- ApacheConfigReader.buildTree(new File(tmpDir,
"runtime-config/vhost-names/httpd.conf").getAbsolutePath(), parser);
-
- tree = RuntimeApacheConfiguration.extract(tree, pinfo, binfo,
ApacheServerDiscoveryComponent.MODULE_SOURCE_FILE_TO_MODULE_NAME_20);
-
- //TODO implement this
- }
-
- private void copyResourceToFile(String resourcePath, File destination) throws
IOException {
+ private void copyResourceToFile(String resourcePath, File destination) throws
IOException {
InputStream input =
getClass().getClassLoader().getResourceAsStream(resourcePath);
if (input != null) {
destination.getParentFile().mkdirs();
destination.createNewFile();
- BufferedOutputStream output = new BufferedOutputStream(new
FileOutputStream(destination));
-
- try {
- int data;
- while((data = input.read()) != -1) {
- output.write(data);
- }
- } finally {
- input.close();
- output.close();
- }
+ StreamUtil.copy(input, new BufferedOutputStream(new
FileOutputStream(destination)), true);
}
}
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-defined.conf
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-defined.conf
index 7631a5c..c098499 100644
---
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-defined.conf
+++
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-defined.conf
@@ -1,5 +1,5 @@
<IfDefine DEFINED>
- <VirtualHost 127.0.0.1:80>
+ <VirtualHost 127.0.0.1:100>
ServerName ifdefine.defined
</VirtualHost>
</IfDefine>
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-undefined.conf
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-undefined.conf
index 6acd1a5..03d0c07 100644
---
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-undefined.conf
+++
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifdefine-undefined.conf
@@ -1,5 +1,5 @@
<IfDefine UNDEFINED>
- <VirtualHost 127.0.0.1:81>
+ <VirtualHost 127.0.0.1:200>
ServerName ifdefine.undefined
</VirtualHost>
</IfDefine>
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-loaded.conf
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-loaded.conf
index f9aba0a..a977465 100644
---
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-loaded.conf
+++
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-loaded.conf
@@ -1,13 +1,13 @@
LoadModule alias_module
<IfModule mod_alias.c>
- <VirtualHost 127.0.0.1:82>
+ <VirtualHost 127.0.0.1:300>
ServerName ifmodule.loaded.source-file
</VirtualHost>
</IfModule>
<IfModule alias_module>
- <VirtualHost 127.0.0.1:83>
+ <VirtualHost 127.0.0.1:301>
ServerName ifmodule.loaded.module-name
</VirtualHost>
</IfModule>
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-not-loaded.conf
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-not-loaded.conf
index 611ba1a..fffb61d 100644
---
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-not-loaded.conf
+++
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifmodule-not-loaded.conf
@@ -1,11 +1,11 @@
<IfModule mod_not_loaded.c>
- <VirtualHost 127.0.0.1:84>
+ <VirtualHost 127.0.0.1:400>
ServerName ifmodule.not-loaded.source-file
</VirtualHost>
</IfModule>
<IfModule not_loaded_module>
- <VirtualHost 127.0.0.1:85>
+ <VirtualHost 127.0.0.1:401>
ServerName ifmodule.not-loaded.module-name
</VirtualHost>
</IfModule>
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifversion.conf
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifversion.conf
new file mode 100644
index 0000000..46413de
--- /dev/null
+++ b/modules/plugins/apache/src/test/resources/runtime-config/conditional/ifversion.conf
@@ -0,0 +1,43 @@
+<IfVersion 2.2.17>
+ <VirtualHost 127.0.0.1:500>
+ ServerName ifversion.module-not-loaded
+ </VirtualHost>
+</IfVersion>
+
+LoadModule version_module
+
+<IfVersion 2.2.17>
+ <VirtualHost 127.0.0.1:501>
+ ServerName ifversion.module-loaded.implied-equals
+ </VirtualHost>
+</IfVersion>
+
+<IfVersion = 2.2.17>
+ <VirtualHost 127.0.0.1:502>
+ ServerName ifversion.module-loaded.equals
+ </VirtualHost>
+</IfVersion>
+
+<IfVersion != 2.2.18>
+ <VirtualHost 127.0.0.1:503>
+ ServerName ifversion.module-loaded.not-equals
+ </VirtualHost>
+</IfVersion>
+
+<IfVersion ~ 2\.2\.1[7-9]>
+ <VirtualHost 127.0.0.1:504>
+ ServerName ifversion.module-loaded.regex
+ </VirtualHost>
+</IfVersion>
+
+<IfVersion /2\.2\.1[7-9]/>
+ <VirtualHost 127.0.0.1:505>
+ ServerName ifversion.module-loaded.implied-regex
+ </VirtualHost>
+</IfVersion>
+
+<IfVersion /2\.2\.1[8-9]/>
+ <VirtualHost 127.0.0.1:506>
+ ServerName ifversion.module-loaded.implied-regex.unmatched
+ </VirtualHost>
+</IfVersion>
\ No newline at end of file
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/nested-mess.conf
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/nested-mess.conf
index 5a2ab62..edde513 100644
---
a/modules/plugins/apache/src/test/resources/runtime-config/conditional/nested-mess.conf
+++
b/modules/plugins/apache/src/test/resources/runtime-config/conditional/nested-mess.conf
@@ -1,24 +1,24 @@
<IfDefine DEFINED>
<IfModule mod_not_loaded.c>
- <VirtualHost 127.0.0.1:86>
+ <VirtualHost 127.0.0.1:600>
ServerName ifdefine.ifmodule.not-loaded.source-file
</VirtualHost>
</IfModule>
<IfModule not_loaded_module>
- <VirtualHost 127.0.0.1:87>
+ <VirtualHost 127.0.0.1:601>
ServerName ifdefine.ifmodule.not-loaded.module-name
</VirtualHost>
</IfModule>
<IfModule mod_alias.c>
- <VirtualHost 127.0.0.1:88>
+ <VirtualHost 127.0.0.1:602>
ServerName ifdefine.ifmodule.loaded.source-file
</VirtualHost>
</IfModule>
<IfModule alias_module>
- <VirtualHost 127.0.0.1:89>
+ <VirtualHost 127.0.0.1:603>
ServerName ifdefine.ifmodule.loaded.module-name
</VirtualHost>
</IfModule>
@@ -26,28 +26,26 @@
<IfDefine UNDEFINED>
<IfModule mod_not_loaded.c>
- <VirtualHost 127.0.0.1:90>
+ <VirtualHost 127.0.0.1:604>
ServerName not-ifdefine.ifmodule.not-loaded.source-file
</VirtualHost>
</IfModule>
<IfModule not_loaded_module>
- <VirtualHost 127.0.0.1:91>
+ <VirtualHost 127.0.0.1:605>
ServerName not-ifdefine.ifmodule.not-loaded.module-name
</VirtualHost>
</IfModule>
<IfModule mod_alias.c>
- <VirtualHost 127.0.0.1:92>
+ <VirtualHost 127.0.0.1:606>
ServerName not-ifdefine.ifmodule.loaded.source-file
</VirtualHost>
</IfModule>
<IfModule alias_module>
- <VirtualHost 127.0.0.1:93>
+ <VirtualHost 127.0.0.1:607>
ServerName not-ifdefine.ifmodule.loaded.module-name
</VirtualHost>
</IfModule>
</IfDefine>
-
-
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/httpd.conf
b/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/httpd.conf
deleted file mode 100644
index 29a43eb..0000000
--- a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/httpd.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-Listen 80
-Listen 127.0.0.1:90
-ServerName the-main-server-name:42
-
-Include vhost-*.conf
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-ip.conf
b/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-ip.conf
deleted file mode 100644
index 978892c..0000000
---
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-ip.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-<VirtualHost 127.0.0.1:1000>
- ServerName 12.34.56.78
-</VirtualHost>
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-unresolvable-hostname.conf
b/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-unresolvable-hostname.conf
deleted file mode 100644
index d38cfc3..0000000
---
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-with-servername-by-unresolvable-hostname.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-<VirtualHost 127.0.0.1:1001>
- ServerName this-will-never-resolve.weird-server.net:90
-</VirtualHost>
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-resolvable-ip.conf
b/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-resolvable-ip.conf
deleted file mode 100644
index 16586d1..0000000
---
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-resolvable-ip.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-<VirtualHost 127.0.0.1:1002>
-
-</VirtualHost>
diff --git
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-unresolvable-ip.conf
b/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-unresolvable-ip.conf
deleted file mode 100644
index 1637446..0000000
---
a/modules/plugins/apache/src/test/resources/runtime-config/vhost-names/vhost-without-servername-unresolvable-ip.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-<VirtualHost 12.34.56.78:1003>
-
-</VirtualHost>
commit 7d71991e8df59f75bdfe5c9c2929f8d27956b05c
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Tue May 3 16:16:22 2011 +0200
BZ 700616 - behave the same as apache when handling the corner case of unresolvable
hostnames in virtual host address definition.
diff --git
a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
index 61fc5b9..ebb315b 100644
---
a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
+++
b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/util/HttpdAddressUtility.java
@@ -410,6 +410,12 @@ public enum HttpdAddressUtility {
}
} catch (UnknownHostException e) {
ret.host = BOGUS_HOST_WITHOUT_FORWARD_DNS;
+
+ //weird, as it seems, apache uses the port of the main server
+ //with the unknown host even if the port was specified in the vhost
+ //definition
+ Address mainAddress =
getHttpdInternalMainServerAddressRepresentation(runtimeConfig);
+ ret.port = mainAddress.port;
}
}