Skip to content

Commit 8eb524d

Browse files
committed
fixing tests
1 parent fb2286b commit 8eb524d

File tree

8 files changed

+65
-14
lines changed

8 files changed

+65
-14
lines changed

marklogic-data-hub/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ plugins {
55
id 'com.jfrog.bintray' version '1.7.2'
66
id 'com.marklogic.ml-gradle' version '2.3.4'
77
id 'com.moowork.node' version '0.13'
8-
id 'com.github.hauner.jarTest' version '1.0'
98
}
109

1110
repositories {

marklogic-data-hub/src/main/java/com/marklogic/hub/HubProject.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public void init() {
100100
writeResourceFileWithReplace("ml-config/security/roles/data-hub-user.json", rolesDir.resolve("data-hub-user.json"));
101101
writeResourceFileWithReplace("ml-config/security/users/data-hub-user.json", usersDir.resolve("data-hub-user.json"));
102102

103-
104103
writeResourceFile("scaffolding/build_gradle", projectDir.resolve("build.gradle"));
105104
writeResourceFileWithReplace("scaffolding/gradle_properties", projectDir.resolve("gradle.properties"));
106105
writeResourceFile("scaffolding/gradle-local_properties", projectDir.resolve("gradle-local.properties"));
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"role-name": "%%mlHubUserRole%%",
3+
"description": "A role that allows the user to read and write from MarkLogic Data Hub databases",
4+
"privilege": [
5+
{
6+
"privilege-name": "rest-admin",
7+
"action": "http://marklogic.com/xdmp/privileges/rest-admin",
8+
"kind": "execute"
9+
},
10+
{
11+
"privilege-name": "manage-admin",
12+
"action": "http://marklogic.com/xdmp/privileges/manage-admin",
13+
"kind": "execute"
14+
}
15+
]
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"user-name": "%%mlHubUserName%%",
3+
"description": "A user that is used for reading and writing from MarkLogic Data Hub databases",
4+
"password": "%%mlHubUserPassword%%",
5+
"role": ["%%mlHubUserRole%%"]
6+
}

marklogic-data-hub/src/test/java/com/marklogic/hub/HubTestBase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ protected static HubConfig getHubConfig(String projectDir) {
161161
hubConfig.jobPort = jobPort;
162162
hubConfig.username = user;
163163
hubConfig.password = password;
164+
hubConfig.adminUsername = user;
165+
hubConfig.adminPassword = password;
164166
return hubConfig;
165167
}
166168

ml-data-hub-plugin/src/test/groovy/com/marklogic/gradle/task/BaseTest.groovy

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ class BaseTest extends Specification {
4949
plugins {
5050
id 'com.marklogic.ml-data-hub'
5151
}
52-
53-
workingDir = ${testProjectDir.root}
5452
"""
5553
}
5654

@@ -94,9 +92,6 @@ class BaseTest extends Specification {
9492

9593
def setup() {
9694
createBuildFile()
97-
98-
if (makeProperties) {
99-
createFullPropertiesFile()
100-
}
95+
createFullPropertiesFile()
10196
}
10297
}

quick-start/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ dependencies {
5555

5656
testCompile("junit:junit")
5757
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
58-
testCompile project (path: ':marklogic-data-hub', configuration: 'testArchives')
5958
}
6059

6160
configurations {
Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,62 @@
11
package com.marklogic.quickstart.service;
22

3-
import com.marklogic.hub.HubTestBase;
3+
import com.marklogic.client.DatabaseClient;
4+
import com.marklogic.client.DatabaseClientFactory;
5+
import com.marklogic.hub.DataHub;
6+
import com.marklogic.hub.HubConfig;
7+
import org.apache.commons.io.FileUtils;
48
import org.junit.AfterClass;
59
import org.junit.BeforeClass;
610
import org.junit.Test;
711

12+
import java.io.File;
813
import java.io.IOException;
914

10-
public class TraceServiceTest extends HubTestBase {
15+
public class TraceServiceTest {
16+
public static final String PROJECT_PATH = "ye-olde-project";
17+
1118
@BeforeClass
1219
public static void setup() throws IOException {
13-
HubTestBase.installHub();
20+
installHub();
1421
}
1522

1623
@AfterClass
1724
public static void teardown() throws IOException {
18-
HubTestBase.uninstallHub();
25+
uninstallHub();
1926
}
2027

2128
@Test
2229
public void getTraces() throws Exception {
23-
TraceService tm = new TraceService(HubTestBase.traceClient);
30+
DatabaseClient traceClient = DatabaseClientFactory.newClient("localhost", 8012, "admin", "admin", DatabaseClientFactory.Authentication.DIGEST);
31+
TraceService tm = new TraceService(traceClient);
2432
tm.getTraces(null, 1, 10);
2533
}
2634

35+
protected static void installHub() throws IOException {
36+
new DataHub(getHubConfig()).install();
37+
}
38+
39+
protected static void uninstallHub() throws IOException {
40+
new DataHub(getHubConfig()).uninstall();
41+
FileUtils.deleteDirectory(new File(PROJECT_PATH));
42+
}
43+
44+
protected static HubConfig getHubConfig() {
45+
return getHubConfig(PROJECT_PATH);
46+
}
47+
48+
protected static HubConfig getHubConfig(String projectDir) {
49+
HubConfig hubConfig = new HubConfig(projectDir);
50+
hubConfig.host = "localhost";
51+
hubConfig.stagingPort = 8010;
52+
hubConfig.finalPort = 8011;
53+
hubConfig.tracePort = 8012;
54+
hubConfig.jobPort = 8013;
55+
hubConfig.username = "admin";
56+
hubConfig.password = "admin";
57+
hubConfig.adminUsername = "admin";
58+
hubConfig.adminPassword = "admin";
59+
return hubConfig;
60+
}
61+
2762
}

0 commit comments

Comments
 (0)