8
8
import java .io .File ;
9
9
import java .io .FileInputStream ;
10
10
import java .io .IOException ;
11
+ import java .nio .file .Paths ;
11
12
12
13
import org .apache .commons .io .FileUtils ;
13
14
import org .apache .commons .io .IOUtils ;
@@ -38,20 +39,17 @@ public void teardown() throws IOException {
38
39
39
40
@ Test
40
41
public void createEntity () {
41
- assertFalse (pluginsDir .exists ());
42
-
43
42
Scaffolding .createEntity ("my-fun-test" , pluginsDir );
44
43
assertTrue (pluginsDir .exists ());
45
44
46
45
File entityDir = Scaffolding .getEntityDir (pluginsDir , "my-fun-test" );
47
46
assertTrue (entityDir .exists ());
48
47
assertEquals (
49
- new File (pluginPath + "/ entities/ my-fun-test"). toPath ( ),
48
+ Paths . get (pluginPath . toString (), " entities" , " my-fun-test" ),
50
49
entityDir .toPath ());
51
50
52
51
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" ),
55
53
flowDir .toPath ());
56
54
assertFalse (flowDir .exists ());
57
55
}
@@ -77,24 +75,24 @@ public void createSjsHarmonizeFlow() throws IOException, SAXException {
77
75
}
78
76
79
77
private void createInputFlow (PluginFormat pluginFormat , Format dataFormat ) throws IOException , SAXException {
80
- assertFalse (pluginsDir .exists ());
81
-
82
78
Scaffolding .createEntity ("my-fun-test" , pluginsDir );
83
79
assertTrue (pluginsDir .exists ());
84
80
85
81
File entityDir = Scaffolding .getEntityDir (pluginsDir , "my-fun-test" );
86
82
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 ());
88
84
89
85
Scaffolding .createFlow ("my-fun-test" , "test-input" , FlowType .INPUT , pluginFormat , dataFormat , pluginsDir );
90
86
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 ());
92
88
assertTrue (flowDir .exists ());
93
89
94
90
File flowDescriptor = new File (flowDir , "test-input.xml" );
95
91
assertTrue (flowDescriptor .exists ());
96
92
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 ();
98
96
99
97
File collectorDir = new File (flowDir , "collector" );
100
98
assertFalse (collectorDir .exists ());
@@ -116,24 +114,24 @@ private void createInputFlow(PluginFormat pluginFormat, Format dataFormat) throw
116
114
}
117
115
118
116
private void createHarmonizeFlow (PluginFormat pluginFormat , Format dataFormat ) throws IOException , SAXException {
119
- assertFalse (pluginsDir .exists ());
120
-
121
117
Scaffolding .createEntity ("my-fun-test" , pluginsDir );
122
118
assertTrue (pluginsDir .exists ());
123
119
124
120
File entityDir = Scaffolding .getEntityDir (pluginsDir , "my-fun-test" );
125
121
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 ());
127
123
128
124
Scaffolding .createFlow ("my-fun-test" , "test-harmonize" , FlowType .HARMONIZE , pluginFormat , dataFormat , pluginsDir );
129
125
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 ());
131
127
assertTrue (flowDir .exists ());
132
128
133
129
File flowDescriptor = new File (flowDir , "test-harmonize.xml" );
134
130
assertTrue (flowDescriptor .exists ());
135
131
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 ();
137
135
138
136
File collectorDir = new File (flowDir , "collector" );
139
137
File defaultCollector = new File (collectorDir , "collector." + pluginFormat .toString ());
@@ -167,7 +165,7 @@ public void createXqyRestExtension() throws IOException {
167
165
} catch (ScaffoldingValidationException e ) {
168
166
Assert .fail (e .getMessage ());
169
167
}
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 ( );
171
169
assertTrue (restDir .exists ());
172
170
File restServicesDir = new File (restDir , "services" );
173
171
assertTrue (restServicesDir .exists ());
@@ -190,7 +188,7 @@ public void createSjsRestExtension() throws IOException {
190
188
} catch (ScaffoldingValidationException e ) {
191
189
Assert .fail (e .getMessage ());
192
190
}
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 ( );
194
192
assertTrue (restDir .exists ());
195
193
File restServicesDir = new File (restDir , "services" );
196
194
assertTrue (restServicesDir .exists ());
@@ -213,7 +211,7 @@ public void createXqyRestTransform() throws IOException {
213
211
} catch (ScaffoldingValidationException e ) {
214
212
Assert .fail (e .getMessage ());
215
213
}
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 ( );
217
215
assertTrue (restDir .exists ());
218
216
File restTransformDir = new File (restDir , "transforms" );
219
217
assertTrue (restTransformDir .exists ());
@@ -232,7 +230,7 @@ public void createSjsRestTransform() throws IOException {
232
230
} catch (ScaffoldingValidationException e ) {
233
231
Assert .fail (e .getMessage ());
234
232
}
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 ( );
236
234
assertTrue (restDir .exists ());
237
235
File restTransformDir = new File (restDir , "transforms" );
238
236
assertTrue (restTransformDir .exists ());
0 commit comments