Skip to content

Commit 9b7f875

Browse files
rahulvudutalaMarkLogic Builder
authored andcommitted
DHFPROD-3581: Fixing tests
1 parent 4b31e7e commit 9b7f875

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

marklogic-data-hub/src/test/java/com/marklogic/bootstrap/Installer.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
package com.marklogic.bootstrap;
22

3-
4-
import java.io.IOException;
5-
import java.nio.file.Path;
6-
import java.nio.file.Paths;
7-
83
import com.marklogic.hub.ApplicationConfig;
94
import com.marklogic.hub.HubTestBase;
105
import com.marklogic.mgmt.api.API;
116
import com.marklogic.mgmt.api.security.User;
127

13-
import org.apache.commons.io.FileUtils;
148
import org.slf4j.Logger;
159
import org.slf4j.LoggerFactory;
1610
import org.springframework.boot.SpringApplication;
@@ -46,7 +40,6 @@ public void bootstrapHub() {
4640
}
4741

4842
if (!isInstalled) {
49-
copyTestIndexesFileToProject();
5043
dataHub.install();
5144

5245
User dataHubDeveloper = new User(new API(adminHubConfig.getManageClient()), "test-data-hub-developer");
@@ -72,16 +65,6 @@ public void bootstrapHub() {
7265
}
7366
}
7467

75-
private void copyTestIndexesFileToProject() {
76-
try {
77-
Path srcDir = Paths.get("src", "test", "ml-config", "databases","final-database.json");
78-
Path dstDir = Paths.get(adminHubConfig.getUserDatabaseDir().toString(), "test-final-database.json");
79-
FileUtils.copyFile(srcDir.toAbsolutePath().toFile(), dstDir.toAbsolutePath().toFile());
80-
} catch (IOException ioe) {
81-
throw new RuntimeException("Unable to copy test indexes file to project", ioe);
82-
}
83-
}
84-
8568
public static void main(String[] args) {
8669
SpringApplication app = new SpringApplication(Installer.class, ApplicationConfig.class);
8770
app.setWebApplicationType(WebApplicationType.NONE);

marklogic-data-hub/src/test/java/com/marklogic/hub_unit_test/RunMarkLogicUnitTestsTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.marklogic.hub_unit_test;
22

3+
import java.io.IOException;
4+
import java.nio.file.Path;
5+
import java.nio.file.Paths;
6+
37
import com.marklogic.appdeployer.impl.SimpleAppDeployer;
48
import com.marklogic.hub.ApplicationConfig;
59
import com.marklogic.hub.HubTestBase;
@@ -8,8 +12,13 @@
812
import com.marklogic.test.unit.TestModule;
913
import com.marklogic.test.unit.TestResult;
1014
import com.marklogic.test.unit.TestSuiteResult;
15+
16+
import org.apache.commons.io.FileUtils;
1117
import org.junit.jupiter.api.Assertions;
18+
import org.junit.jupiter.api.BeforeAll;
1219
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.TestInstance;
21+
import org.junit.jupiter.api.TestInstance.Lifecycle;
1322
import org.junit.jupiter.api.extension.ExtendWith;
1423
import org.junit.jupiter.params.ParameterizedTest;
1524
import org.junit.jupiter.params.provider.ArgumentsSource;
@@ -30,6 +39,7 @@
3039
*/
3140
@ExtendWith(SpringExtension.class)
3241
@ContextConfiguration(classes = {ApplicationConfig.class, TestConfig.class})
42+
@TestInstance(Lifecycle.PER_CLASS)
3343
public class RunMarkLogicUnitTestsTest extends HubTestBase {
3444

3545
private static boolean loadedHubArtifacts = false;
@@ -47,6 +57,17 @@ public void setup() {
4757
}
4858
}
4959

60+
@BeforeAll
61+
public void setupIndexes() {
62+
try {
63+
Path srcDir = Paths.get("src", "test", "ml-config", "databases","final-database.json");
64+
Path dstDir = Paths.get(adminHubConfig.getUserDatabaseDir().toString(), "test-final-database.json");
65+
FileUtils.copyFile(srcDir.toAbsolutePath().toFile(), dstDir.toAbsolutePath().toFile());
66+
} catch (IOException ioe) {
67+
throw new RuntimeException("Unable to copy test indexes file to project", ioe);
68+
}
69+
dataHub.updateIndexes();
70+
}
5071
/**
5172
* This is overridden so that the test class is only initialized once, which is sufficient. Otherwise, it's invoked
5273
* for every unit test module, which is unnecessary.

0 commit comments

Comments
 (0)