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

Commit e25d0db

Browse files
authored
Merge pull request #454 from marklogic-community/feature/test-fixes
Fixes for failing tests
2 parents 3d3b469 + ccc834f commit e25d0db

File tree

11 files changed

+32
-33
lines changed

11 files changed

+32
-33
lines changed

src/test/java/com/marklogic/appdeployer/AbstractAppDeployerTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public abstract class AbstractAppDeployerTest extends AbstractMgmtTest {
2020

2121
public final static String SAMPLE_APP_NAME = "sample-app";
2222

23-
protected final static Integer SAMPLE_APP_REST_PORT = 8540;
24-
protected final static Integer SAMPLE_APP_TEST_REST_PORT = 8541;
23+
protected final static Integer SAMPLE_APP_REST_PORT = 8004;
24+
protected final static Integer SAMPLE_APP_TEST_REST_PORT = 8005;
2525

2626
// Intended to be used by subclasses
2727
protected AppDeployer appDeployer;
@@ -38,13 +38,15 @@ protected void initializeAppConfig() {
3838

3939
protected void initializeAppConfig(File projectDir) {
4040
appConfig = new AppConfig(projectDir);
41-
41+
appConfig.setHost(this.manageConfig.getHost());
4242
appConfig.setName(SAMPLE_APP_NAME);
4343
appConfig.setRestPort(SAMPLE_APP_REST_PORT);
4444

4545
// Assume that the manager user can also be used as the REST admin user
4646
appConfig.setRestAdminUsername(manageConfig.getUsername());
4747
appConfig.setRestAdminPassword(manageConfig.getPassword());
48+
appConfig.setAppServicesUsername(manageConfig.getUsername());
49+
appConfig.setAppServicesPassword(manageConfig.getPassword());
4850
}
4951

5052
/**

src/test/java/com/marklogic/appdeployer/command/modules/LoadInvalidRestModulesTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public void test() {
3232
deploySampleApp();
3333
fail("The invalid search options file should have caused the LoadModulesCommand to fail");
3434
} catch (RuntimeException re) {
35-
logger.info("Caught expected error: " + re.getMessage());
36-
assertTrue(re.getMessage().contains("Unexpected character"));
35+
assertTrue(re.getMessage().contains("RESTAPI-INVALIDCONTENT"), "Unexpected message: " + re.getMessage());
3736
} finally {
3837
undeploySampleApp();
3938
}

src/test/java/com/marklogic/appdeployer/command/modules/LoadModulesTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ public void customModuleTimestampsPath() {
8888
public void loadModulesFromMultiplePaths() {
8989
// Setting batch size just to verify that nothing blows up when doing so
9090
appConfig.setModulesLoaderBatchSize(1);
91-
appConfig.getModulePaths().add("src/test/resources/sample-app/build/mlRestApi/some-library/ml-modules");
91+
appConfig.getModulePaths().add("src/test/resources/sample-app/other-modules");
9292

9393
initializeAppDeployer(new DeployRestApiServersCommand(true), buildLoadModulesCommand());
9494
appDeployer.deploy(appConfig);
9595

9696
assertModuleExistsWithDefaultPermissions("sample-lib is loaded from /ext in the default path",
9797
"/ext/sample-lib.xqy");
98-
assertModuleExistsWithDefaultPermissions("some-lib.xqy is loaded from the path added at the start of the test",
99-
"/ext/some-lib.xqy");
98+
assertModuleExistsWithDefaultPermissions("other-lib.xqy is loaded from the path added at the start of the test",
99+
"/other-lib.xqy");
100100
}
101101

102102
@Test

src/test/java/com/marklogic/appdeployer/command/plugins/InstallPluginsTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.marklogic.appdeployer.command.databases.DeployOtherDatabasesCommand;
66
import com.marklogic.appdeployer.command.restapis.DeployRestApiServersCommand;
77
import com.marklogic.client.DatabaseClient;
8+
import com.marklogic.client.FailedRequestException;
89
import com.marklogic.client.document.GenericDocumentManager;
910
import com.marklogic.client.document.JSONDocumentManager;
1011
import com.marklogic.client.io.DocumentMetadataHandle;
@@ -37,7 +38,7 @@ public void test() {
3738

3839
deploySampleApp();
3940

40-
DatabaseClient contentClient = appConfig.newAppServicesDatabaseClient(appConfig.getContentDatabaseName());
41+
DatabaseClient contentClient = appConfig.newDatabaseClient();
4142
assertNotNull(contentClient.newDocumentManager().exists("/com.marklogic/plugins/varianceplugin.zip"),
4243
"The plugin zip should have been written to the content database so that it can be installed");
4344

@@ -60,7 +61,18 @@ public void test() {
6061
object.put("amount", 30);
6162
jsonDocumentManager.write("test3.json", new JacksonHandle(object));
6263

63-
assertTrue(invokePlugin(contentClient).startsWith("22.22"));
64+
try {
65+
String pluginResponse = invokePlugin(contentClient);
66+
assertTrue(pluginResponse.startsWith("22.22"), "Unexpected plugin response: " + pluginResponse);
67+
} catch (FailedRequestException ex) {
68+
String message = ex.getMessage();
69+
if (message.contains("invalid ELF header")) {
70+
logger.warn("Could not verify that the plugin works as the platform that the plugin was built on does " +
71+
"not match that of the platform running MarkLogic; error: " + message);
72+
} else {
73+
throw ex;
74+
}
75+
}
6476

6577
// Now uninstall the plugin and make sure the plugin can't be invoked
6678
initializeAppDeployer(new InstallPluginsCommand());

src/test/java/com/marklogic/appdeployer/command/schemas/LoadSchemasTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ public void tdeValidationEnabled() {
118118
deploySampleApp();
119119
fail("The deploy should have failed because of a bad TDE template");
120120
} catch (Exception ex) {
121+
// With tde.templateBatchInsert being used starting with ML 10.0-9, we unfortunately do not get an error
122+
// message that is helpful at all. JAVA-224 has been created to capture this.
121123
String message = ex.getCause().getMessage();
122-
assertTrue(message.startsWith("TDE template failed validation"));
123-
assertTrue(message.contains("TDE-REPEATEDCOLUMN"));
124+
assertTrue(message.contains("failed to apply resource at eval: Internal Server Error"), "Unexpected message: " + message);
125+
// Previous assertions for < ML 10.0-9
126+
// assertTrue(message.startsWith("TDE template failed validation"), "Unexpected message: " + message);
127+
// assertTrue(message.contains("TDE-REPEATEDCOLUMN"), "Unexpected message: " + message);
124128
}
125129
}
126130

src/test/java/com/marklogic/appdeployer/command/security/ManageAmpsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ public void twoAmpsWithDifferentModulesDatabase() {
113113
" \"role\": [\"rest-writer\"]\n" +
114114
"}";
115115

116-
ManageClient client = new ManageClient();
117-
AmpManager mgr = new AmpManager(client);
116+
AmpManager mgr = new AmpManager(super.manageClient);
118117

119118
try {
120119
// Create and verify

src/test/java/com/marklogic/appdeployer/export/ExportAmpsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public void test() throws Exception {
3838
" \"role\": [\"rest-writer\"]\n" +
3939
"}";
4040

41-
ManageClient client = new ManageClient();
42-
AmpManager mgr = new AmpManager(client);
41+
AmpManager mgr = new AmpManager(super.manageClient);
4342

4443
try {
4544
mgr.save(amp1);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<options xmlns="http://marklogic.com/appservices/search">
2-
<TheseAre>invalid</TheseAre
2+
<TheseAre>invalid</TheseAre>
33
</options>

src/test/resources/sample-app/more-modules/app/hello-lib.xqy

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/test/resources/sample-app/more-modules/app/models/world-lib.xqy

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)