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