empty gsa.hostname is invalid
this is an additional check to it being necessary
diff --git a/src/com/google/enterprise/adaptor/Config.java b/src/com/google/enterprise/adaptor/Config.java
index dd187ea..56db897 100644
--- a/src/com/google/enterprise/adaptor/Config.java
+++ b/src/com/google/enterprise/adaptor/Config.java
@@ -720,6 +720,9 @@
public void validate() {
validate(config);
+ if ("".equals(getGsaHostname().trim())) {
+ throw new InvalidConfigurationException("gsa.hostname cannot be empty");
+ }
}
private void validate(Properties config) {
diff --git a/test/com/google/enterprise/adaptor/ConfigTest.java b/test/com/google/enterprise/adaptor/ConfigTest.java
index 639d0f4..df4ca4c 100644
--- a/test/com/google/enterprise/adaptor/ConfigTest.java
+++ b/test/com/google/enterprise/adaptor/ConfigTest.java
@@ -49,6 +49,22 @@
}
@Test
+ public void testEmptyGsaHostname() {
+ // Requires gsa.hostname to be non-empty
+ config.setValue("gsa.hostname", "");
+ thrown.expect(InvalidConfigurationException.class);
+ config.validate();
+ }
+
+ @Test
+ public void testWhitespaceOnlyGsaHostname() {
+ // Requires gsa.hostname to be non-empty
+ config.setValue("gsa.hostname", " ");
+ thrown.expect(InvalidConfigurationException.class);
+ config.validate();
+ }
+
+ @Test
public void testAddDuplicateKeyWithValue() {
config.addKey("somekey", "value");
thrown.expect(IllegalStateException.class);