88import java .io .File ;
99import java .io .FileInputStream ;
1010import java .io .IOException ;
11+ import java .nio .file .Paths ;
1112
1213import org .apache .commons .io .FileUtils ;
1314import 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 ());
0 commit comments