cleanup work and starting new tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package org.baeldung.java;
|
||||
package org.baeldung.java.io;
|
||||
|
||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -25,7 +25,7 @@ import com.google.common.base.Charsets;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.common.io.InputSupplier;
|
||||
|
||||
public class CoreJavaIoUnitTest {
|
||||
public class JavaInputStreamToXUnitTest {
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
private static final int DEFAULT_SIZE = 150000000;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.baeldung.java.io;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.io.CharSource;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class JavaXToInputStreamUnitTest {
|
||||
protected final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Test
|
||||
public void givenUsingPlainJava_whenConvertingStringToInputStream_thenCorrect() throws IOException {
|
||||
final String initialString = "text";
|
||||
final InputStream targetStream = new ByteArrayInputStream(initialString.getBytes());
|
||||
final byte[] buffer = new byte[targetStream.available()];
|
||||
targetStream.read(buffer);
|
||||
final String targetString = new String(buffer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUsingGuava_whenConvertingStringToInputStream_thenCorrect() throws IOException {
|
||||
final String initialString = "text";
|
||||
final CharSource source = CharSource.wrap(initialString);
|
||||
final Reader targetStream = source.openStream();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenUsingCommonsIO_whenConvertingStringToInputStream_thenCorrect() throws IOException {
|
||||
final String initialString = "text";
|
||||
final InputStream targetStream = IOUtils.toInputStream(initialString);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user