File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
main/java/org/metafacture/io
test/java/org/metafacture/io Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -108,8 +108,8 @@ public void process(final T obj) {
108108 @ Override
109109 public void resetStream () {
110110 closeStream ();
111- startNewFile ();
112111 ++count ;
112+ startNewFile ();
113113 }
114114
115115 @ Override
Original file line number Diff line number Diff line change 1717package org .metafacture .io ;
1818
1919import static org .junit .Assert .assertArrayEquals ;
20+ import static org .junit .Assert .assertTrue ;
2021import static org .junit .Assume .assumeFalse ;
2122
2223import java .io .File ;
@@ -93,6 +94,17 @@ public void shouldAppendToExistingFile() throws IOException {
9394 assertOutput (DATA + "\n " + DATA + "\n " );
9495 }
9596
97+ @ Test
98+ public void shouldIncrementCountOnResetBeforeStartingNewFile () throws IOException {
99+ final String pathWithVar = tempFolder .getRoot () + "/test-${i}" ;
100+ writer = new ObjectFileWriter <String >(pathWithVar );
101+ writer .process (DATA );
102+ assertTrue (new File (tempFolder .getRoot (), "test-0" ).exists ());
103+ writer .resetStream (); // increments count, starts new file
104+ writer .process (DATA );
105+ assertTrue (new File (tempFolder .getRoot (), "test-1" ).exists ());
106+ }
107+
96108 @ Override
97109 protected ConfigurableObjectWriter <String > getWriter () {
98110 return writer ;
You can’t perform that action at this time.
0 commit comments