Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 3a2c1f9

Browse files
committed
#273 Added test for verifying that invalid REST modules cause a deploy to fail
1 parent c976756 commit 3a2c1f9

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
group=com.marklogic
22
javadocsDir=../gh-pages-marklogic-java/javadocs
33
version=3.7.0
4-
mlJavaclientUtilVersion=3.6.0
4+
mlJavaclientUtilVersion=3.7.0
55
mlJunitVersion=3.1.0
66

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.marklogic.appdeployer.command.modules;
2+
3+
import com.marklogic.appdeployer.AbstractAppDeployerTest;
4+
import com.marklogic.appdeployer.command.CommandContext;
5+
import com.marklogic.appdeployer.command.databases.DeployContentDatabasesCommand;
6+
import com.marklogic.appdeployer.command.restapis.DeployRestApiServersCommand;
7+
import com.marklogic.client.ext.modulesloader.impl.DefaultModulesLoader;
8+
import org.junit.Test;
9+
10+
import java.io.File;
11+
import java.util.Arrays;
12+
13+
public class LoadInvalidRestModulesTest extends AbstractAppDeployerTest {
14+
15+
@Test
16+
public void test() {
17+
appConfig.getFirstConfigDir().setBaseDir(new File("src/test/resources/sample-app/db-only-config"));
18+
19+
appConfig.setModulePaths(Arrays.asList("src/test/resources/sample-app/bad-modules"));
20+
21+
LoadModulesCommand loadModulesCommand = new LoadModulesCommand();
22+
loadModulesCommand.initializeDefaultModulesLoader(new CommandContext(appConfig, manageClient, null));
23+
DefaultModulesLoader modulesLoader = (DefaultModulesLoader) loadModulesCommand.getModulesLoader();
24+
modulesLoader.setModulesManager(null);
25+
26+
initializeAppDeployer(new DeployRestApiServersCommand(), new DeployContentDatabasesCommand(1), loadModulesCommand);
27+
28+
try {
29+
deploySampleApp();
30+
fail("The invalid search options file should have caused the LoadModulesCommand to fail");
31+
} catch (RuntimeException re) {
32+
logger.info("Caught expected error: " + re.getMessage());
33+
assertTrue(re.getMessage().contains("Unexpected character"));
34+
} finally {
35+
undeploySampleApp();
36+
}
37+
}
38+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<options xmlns="http://marklogic.com/appservices/search">
2+
<TheseAre>invalid</TheseAre
3+
</options>

0 commit comments

Comments
 (0)