Skip to content

Commit 3a73ee3

Browse files
committed
Cleaned up Load UI
Fixed unit tests on Windows
1 parent 5e39b4b commit 3a73ee3

File tree

13 files changed

+77
-80
lines changed

13 files changed

+77
-80
lines changed

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ subprojects {
1818

1919
test{
2020
testLogging{
21-
events 'started','passed', 'skipped'
21+
events 'started','passed', 'skipped', 'failed', 'standardError', 'standardOut'
22+
23+
showStandardStreams true
2224
}
2325
}
2426

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
*/
1616
package com.marklogic.hub;
1717

18-
import java.io.IOException;
1918
import java.util.ArrayList;
2019
import java.util.List;
2120

2221
import javax.xml.stream.XMLStreamException;
2322

24-
import org.codehaus.jettison.json.JSONException;
25-
import org.slf4j.Logger;
26-
import org.slf4j.LoggerFactory;
2723
import org.springframework.batch.core.Job;
2824
import org.springframework.batch.core.JobExecution;
2925
import org.springframework.batch.core.JobExecutionListener;
@@ -67,8 +63,6 @@ public class FlowManager extends ResourceManager {
6763
private static final String NAME = "flow";
6864
private static final int DEFAULT_THREAD_COUNT = 8;
6965

70-
static final private Logger LOGGER = LoggerFactory.getLogger(FlowManager.class);
71-
7266
private DatabaseClient client;
7367

7468
private JobBuilderFactory jobBuilderFactory;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public static void createFlow(String entityName, String flowName,
9595
File flowFile = new File(flowDir, flowName + ".xml");
9696
try(PrintWriter out = new PrintWriter(flowFile)) {
9797
out.println(flow.serialize(false));
98+
out.close();
9899
}
99100
}
100101

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ private static boolean checkIfFileExists(File rootDirectory, String absoluteFile
2424
return true;
2525
}
2626
} else {
27+
absoluteFilePathFilter = absoluteFilePathFilter.replace("\\", "\\\\");
28+
2729
if(Pattern.matches(absoluteFilePathFilter,file.getAbsolutePath())) {
2830
return true;
2931
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import static org.junit.Assert.assertTrue;
66

77
import java.io.IOException;
8+
import java.net.URISyntaxException;
9+
import java.net.URL;
10+
import java.nio.file.Paths;
811

912
import javax.xml.parsers.ParserConfigurationException;
1013

@@ -22,7 +25,7 @@ public class DataHubInstallTest extends HubTestBase {
2225
@BeforeClass
2326
public static void setup() throws IOException {
2427
XMLUnit.setIgnoreWhitespace(true);
25-
dataHub = new DataHub(getHubConfig("./ye-olde-plugins"));
28+
dataHub = new DataHub(getHubConfig(Paths.get(".", "ye-olde-plugins").toString()));
2629
dataHub.install();
2730
}
2831

@@ -41,8 +44,9 @@ public void testInstallHubModules() throws IOException {
4144
}
4245

4346
@Test
44-
public void testInstallUserModules() throws IOException, ParserConfigurationException, SAXException {
45-
String path = DataHubInstallTest.class.getClassLoader().getResource("data-hub-test").getPath();
47+
public void testInstallUserModules() throws IOException, ParserConfigurationException, SAXException, URISyntaxException {
48+
URL url = DataHubInstallTest.class.getClassLoader().getResource("data-hub-test");
49+
String path = Paths.get(url.toURI()).toFile().getAbsolutePath();
4650

4751
PropertiesModuleManager modulesManager = new PropertiesModuleManager();
4852
modulesManager.deletePropertiesFile();

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

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.io.File;
99
import java.io.FileInputStream;
1010
import java.io.IOException;
11+
import java.nio.file.Paths;
1112

1213
import org.apache.commons.io.FileUtils;
1314
import org.apache.commons.io.IOUtils;
@@ -38,20 +39,17 @@ public void teardown() throws IOException {
3839

3940
@Test
4041
public void createEntity() {
41-
assertFalse(pluginsDir.exists());
42-
4342
Scaffolding.createEntity("my-fun-test", pluginsDir);
4443
assertTrue(pluginsDir.exists());
4544

4645
File entityDir = Scaffolding.getEntityDir(pluginsDir, "my-fun-test");
4746
assertTrue(entityDir.exists());
4847
assertEquals(
49-
new File(pluginPath + "/entities/my-fun-test").toPath(),
48+
Paths.get(pluginPath.toString(), "entities", "my-fun-test"),
5049
entityDir.toPath());
5150

5251
File flowDir = Scaffolding.getFlowDir(pluginsDir, "my-fun-test", "blah", FlowType.INPUT);
53-
assertEquals(new File(
54-
pluginPath + "/entities/my-fun-test/input/blah").toPath(),
52+
assertEquals(Paths.get(pluginPath.toString(), "entities", "my-fun-test", "input", "blah"),
5553
flowDir.toPath());
5654
assertFalse(flowDir.exists());
5755
}
@@ -77,24 +75,24 @@ public void createSjsHarmonizeFlow() throws IOException, SAXException {
7775
}
7876

7977
private void createInputFlow(PluginFormat pluginFormat, Format dataFormat) throws IOException, SAXException {
80-
assertFalse(pluginsDir.exists());
81-
8278
Scaffolding.createEntity("my-fun-test", pluginsDir);
8379
assertTrue(pluginsDir.exists());
8480

8581
File entityDir = Scaffolding.getEntityDir(pluginsDir, "my-fun-test");
8682
assertTrue(entityDir.exists());
87-
assertEquals(new File(pluginPath + "/entities/my-fun-test").toPath(), entityDir.toPath());
83+
assertEquals(Paths.get(pluginPath.toString(), "entities", "my-fun-test"), entityDir.toPath());
8884

8985
Scaffolding.createFlow("my-fun-test", "test-input", FlowType.INPUT, pluginFormat, dataFormat, pluginsDir);
9086
File flowDir = Scaffolding.getFlowDir(pluginsDir, "my-fun-test", "test-input", FlowType.INPUT);
91-
assertEquals(new File(pluginPath + "/entities/my-fun-test/input/test-input").toPath(), flowDir.toPath());
87+
assertEquals(Paths.get(pluginPath.toString(), "entities", "my-fun-test", "input", "test-input"), flowDir.toPath());
9288
assertTrue(flowDir.exists());
9389

9490
File flowDescriptor = new File(flowDir, "test-input.xml");
9591
assertTrue(flowDescriptor.exists());
9692
String flowXML ="<flow xmlns=\"http://marklogic.com/data-hub\"><complexity>simple</complexity><data-format>" + dataFormat.getDefaultMimetype() + "</data-format><plugins></plugins></flow>";
97-
assertXMLEqual(flowXML, IOUtils.toString(new FileInputStream(flowDescriptor)));
93+
FileInputStream fs = new FileInputStream(flowDescriptor);
94+
assertXMLEqual(flowXML, IOUtils.toString(fs));
95+
fs.close();
9896

9997
File collectorDir = new File(flowDir, "collector");
10098
assertFalse(collectorDir.exists());
@@ -116,24 +114,24 @@ private void createInputFlow(PluginFormat pluginFormat, Format dataFormat) throw
116114
}
117115

118116
private void createHarmonizeFlow(PluginFormat pluginFormat, Format dataFormat) throws IOException, SAXException {
119-
assertFalse(pluginsDir.exists());
120-
121117
Scaffolding.createEntity("my-fun-test", pluginsDir);
122118
assertTrue(pluginsDir.exists());
123119

124120
File entityDir = Scaffolding.getEntityDir(pluginsDir, "my-fun-test");
125121
assertTrue(entityDir.exists());
126-
assertEquals(new File(pluginPath + "/entities/my-fun-test").toPath(), entityDir.toPath());
122+
assertEquals(Paths.get(pluginPath.toString(), "entities", "my-fun-test"), entityDir.toPath());
127123

128124
Scaffolding.createFlow("my-fun-test", "test-harmonize", FlowType.HARMONIZE, pluginFormat, dataFormat, pluginsDir);
129125
File flowDir = Scaffolding.getFlowDir(pluginsDir, "my-fun-test", "test-harmonize", FlowType.HARMONIZE);
130-
assertEquals(new File(pluginPath + "/entities/my-fun-test/harmonize/test-harmonize").toPath(), flowDir.toPath());
126+
assertEquals(Paths.get(pluginPath.toString(), "entities", "my-fun-test", "harmonize", "test-harmonize"), flowDir.toPath());
131127
assertTrue(flowDir.exists());
132128

133129
File flowDescriptor = new File(flowDir, "test-harmonize.xml");
134130
assertTrue(flowDescriptor.exists());
135131
String flowXML ="<flow xmlns=\"http://marklogic.com/data-hub\"><complexity>simple</complexity><data-format>" + dataFormat.getDefaultMimetype() + "</data-format><plugins></plugins></flow>";
136-
assertXMLEqual(flowXML, IOUtils.toString(new FileInputStream(flowDescriptor)));
132+
FileInputStream fs = new FileInputStream(flowDescriptor);
133+
assertXMLEqual(flowXML, IOUtils.toString(fs));
134+
fs.close();
137135

138136
File collectorDir = new File(flowDir, "collector");
139137
File defaultCollector = new File(collectorDir, "collector." + pluginFormat.toString());
@@ -167,7 +165,7 @@ public void createXqyRestExtension() throws IOException {
167165
} catch (ScaffoldingValidationException e) {
168166
Assert.fail(e.getMessage());
169167
}
170-
File restDir = new File(pluginsDir.getAbsolutePath() + "/entities/"+ entityName + "/"+ flowType.name() +"/REST");
168+
File restDir = Paths.get(pluginsDir.toString(), "entities", entityName, flowType.name(), "REST").toAbsolutePath().normalize().toFile();
171169
assertTrue(restDir.exists());
172170
File restServicesDir = new File(restDir, "services");
173171
assertTrue(restServicesDir.exists());
@@ -190,7 +188,7 @@ public void createSjsRestExtension() throws IOException {
190188
} catch (ScaffoldingValidationException e) {
191189
Assert.fail(e.getMessage());
192190
}
193-
File restDir = new File(pluginsDir.getAbsolutePath() + "/entities/"+ entityName + "/"+ flowType.name() +"/REST");
191+
File restDir = Paths.get(pluginsDir.toString(), "entities", entityName, flowType.name(), "REST").toAbsolutePath().normalize().toFile();
194192
assertTrue(restDir.exists());
195193
File restServicesDir = new File(restDir, "services");
196194
assertTrue(restServicesDir.exists());
@@ -213,7 +211,7 @@ public void createXqyRestTransform() throws IOException {
213211
} catch (ScaffoldingValidationException e) {
214212
Assert.fail(e.getMessage());
215213
}
216-
File restDir = new File(pluginsDir.getAbsolutePath() + "/entities/"+ entityName + "/"+ flowType.name() +"/REST");
214+
File restDir = Paths.get(pluginsDir.toString(), "entities", entityName, flowType.name(), "REST").toAbsolutePath().normalize().toFile();
217215
assertTrue(restDir.exists());
218216
File restTransformDir = new File(restDir, "transforms");
219217
assertTrue(restTransformDir.exists());
@@ -232,7 +230,7 @@ public void createSjsRestTransform() throws IOException {
232230
} catch (ScaffoldingValidationException e) {
233231
Assert.fail(e.getMessage());
234232
}
235-
File restDir = new File(pluginsDir.getAbsolutePath() + "/entities/"+ entityName + "/"+ flowType.name() +"/REST");
233+
File restDir = Paths.get(pluginsDir.toString(), "entities", entityName, flowType.name(), "REST").toAbsolutePath().normalize().toFile();
236234
assertTrue(restDir.exists());
237235
File restTransformDir = new File(restDir, "transforms");
238236
assertTrue(restTransformDir.exists());

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import static org.junit.Assert.assertEquals;
44

55
import java.io.IOException;
6+
import java.net.URISyntaxException;
7+
import java.net.URL;
8+
import java.nio.file.Paths;
69

710
import org.custommonkey.xmlunit.XMLUnit;
811
import org.junit.After;
@@ -18,14 +21,15 @@
1821

1922
public class TracingTest extends HubTestBase {
2023
@BeforeClass
21-
public static void setup() throws IOException {
24+
public static void setup() throws IOException, URISyntaxException {
2225
XMLUnit.setIgnoreWhitespace(true);
2326

2427
installHub();
2528

2629
enableDebugging();
2730

28-
String path = TracingTest.class.getClassLoader().getResource("tracing-test").getPath();
31+
URL url = DataHubInstallTest.class.getClassLoader().getResource("tracing-test");
32+
String path = Paths.get(url.toURI()).toFile().getAbsolutePath();
2933

3034
PropertiesModuleManager modulesManager = new PropertiesModuleManager();
3135
modulesManager.deletePropertiesFile();

quick-start/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies {
3737
compile('org.webjars.bower:angular-swagger-ui:0.3.1')
3838

3939
// Needed for the Upload feature using mlcp
40-
compile('com.marklogic:mlcp-util:0.1.3') {
40+
compile('com.marklogic:mlcp-util:0.2.0') {
4141
exclude module : 'servlet-api'
4242
exclude group: 'com.google.guava', module: 'guava'
4343
}

quick-start/src/main/java/com/marklogic/hub/service/CollectorManagerService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
import java.util.List;
44

5-
import org.slf4j.Logger;
6-
import org.slf4j.LoggerFactory;
75
import org.springframework.stereotype.Service;
86

97
import com.marklogic.hub.collector.Collector;
108

119
@Service
1210
public class CollectorManagerService {
1311

14-
private static final Logger LOGGER = LoggerFactory.getLogger(CollectorManagerService.class);
15-
1612
public List<Collector> getCollectors() {
1713
return null;
1814
}

quick-start/src/main/java/com/marklogic/hub/web/controller/CollectorManagerController.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import java.util.List;
55
import java.util.Map;
66

7-
import org.slf4j.Logger;
8-
import org.slf4j.LoggerFactory;
97
import org.springframework.beans.factory.annotation.Autowired;
108
import org.springframework.stereotype.Controller;
119
import org.springframework.web.bind.annotation.PathVariable;
@@ -20,8 +18,6 @@
2018
@RequestMapping("/collectors")
2119
public class CollectorManagerController extends BaseController {
2220

23-
private static final Logger LOGGER = LoggerFactory.getLogger(CollectorManagerController.class);
24-
2521
@Autowired
2622
private CollectorManagerService collectorManagerService;
2723

0 commit comments

Comments
 (0)