Merge pull request #6346 from amit2103/BAEL-12668
[BAEL-12668] - Make sure the tutorials build doesn't generate any un-…
This commit is contained in:
commit
8734cdf5ce
|
@ -66,3 +66,10 @@ jmeter/src/main/resources/*-JMeter.csv
|
||||||
**/nb-configuration.xml
|
**/nb-configuration.xml
|
||||||
core-scala/.cache-main
|
core-scala/.cache-main
|
||||||
core-scala/.cache-tests
|
core-scala/.cache-tests
|
||||||
|
|
||||||
|
|
||||||
|
persistence-modules/hibernate5/transaction.log
|
||||||
|
apache-avro/src/main/java/com/baeldung/avro/model/
|
||||||
|
jta/transaction-logs/
|
||||||
|
software-security/sql-injection-samples/derby.log
|
||||||
|
spring-soap/src/main/java/com/baeldung/springsoap/gen/
|
|
@ -5,6 +5,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,7 +18,6 @@ import org.slf4j.LoggerFactory;
|
||||||
public class WriteCsvFileExampleUnitTest {
|
public class WriteCsvFileExampleUnitTest {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(WriteCsvFileExampleUnitTest.class);
|
private static final Logger LOG = LoggerFactory.getLogger(WriteCsvFileExampleUnitTest.class);
|
||||||
|
|
||||||
private static final String CSV_FILE_NAME = "src/test/resources/exampleOutput.csv";
|
|
||||||
private WriteCsvFileExample csvExample;
|
private WriteCsvFileExample csvExample;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -65,12 +65,12 @@ public class WriteCsvFileExampleUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenDataArray_whenConvertToCSV_thenOutputCreated() {
|
public void givenDataArray_whenConvertToCSV_thenOutputCreated() throws IOException {
|
||||||
List<String[]> dataLines = new ArrayList<String[]>();
|
List<String[]> dataLines = new ArrayList<String[]>();
|
||||||
dataLines.add(new String[] { "John", "Doe", "38", "Comment Data\nAnother line of comment data" });
|
dataLines.add(new String[] { "John", "Doe", "38", "Comment Data\nAnother line of comment data" });
|
||||||
dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" });
|
dataLines.add(new String[] { "Jane", "Doe, Jr.", "19", "She said \"I'm being quoted\"" });
|
||||||
|
|
||||||
File csvOutputFile = new File(CSV_FILE_NAME);
|
File csvOutputFile = File.createTempFile("exampleOutput", ".csv");
|
||||||
try (PrintWriter pw = new PrintWriter(csvOutputFile)) {
|
try (PrintWriter pw = new PrintWriter(csvOutputFile)) {
|
||||||
dataLines.stream()
|
dataLines.stream()
|
||||||
.map(csvExample::convertToCSV)
|
.map(csvExample::convertToCSV)
|
||||||
|
@ -80,5 +80,6 @@ public class WriteCsvFileExampleUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(csvOutputFile.exists());
|
assertTrue(csvOutputFile.exists());
|
||||||
|
csvOutputFile.deleteOnExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
John,Doe,38,Comment Data Another line of comment data
|
|
||||||
Jane,"Doe, Jr.",19,"She said ""I'm being quoted"""
|
|
|
Loading…
Reference in New Issue