BAEL-1033 Introduction to StreamUtils (#2341)

* Evaluation article: Different Types of Bean Injection in Spring

* added tests & changed configuration to Java-based config

* removed xml config files

* rename unit tests

* BAEL-972 - Apache Commons Text

* remove code from evaluation article

* remove code from evaluation article

* BAEL-972 - Apache Commons Text - added another example

* BAEL-972 - Apache Commons Text - just indentation

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java

* BAEL-994 - TemporalAdjuster in Java - fix problems

* BAEL-1033 Introduction to StreamUtils

* BAEL-1033 Introduction to StreamUtils

* BAEL-1033 Introduction to StreamUtils

* fix formatting

* BAEL-1033 minor refactor
This commit is contained in:
Ahmed Tawila 2017-07-31 15:57:52 +03:00 committed by Grzegorz Piwowarek
parent 585597f11d
commit 4b53c00bca
7 changed files with 762 additions and 621 deletions

View File

@ -1,497 +1,497 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>parent-modules</artifactId> <artifactId>parent-modules</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>libraries</artifactId> <artifactId>libraries</artifactId>
<name>libraries</name> <name>libraries</name>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version> <version>3.3.0</version>
<type>maven-plugin</type> <type>maven-plugin</type>
</dependency> </dependency>
</dependencies> </dependencies>
<extensions>true</extensions> <extensions>true</extensions>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version> <version>2.20</version>
<configuration> <configuration>
<systemProperties> <systemProperties>
<webdriver.chrome.driver>chromedriver</webdriver.chrome.driver> <webdriver.chrome.driver>chromedriver</webdriver.chrome.driver>
</systemProperties> </systemProperties>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId> <groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId> <artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.plugin.version}</version> <version>${serenity.plugin.version}</version>
<executions> <executions>
<execution> <execution>
<id>serenity-reports</id> <id>serenity-reports</id>
<phase>post-integration-test</phase> <phase>post-integration-test</phase>
<goals> <goals>
<goal>aggregate</goal> <goal>aggregate</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- JDO Plugin --> <!-- JDO Plugin -->
<plugin> <plugin>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId> <artifactId>datanucleus-maven-plugin</artifactId>
<version>5.0.2</version> <version>5.0.2</version>
<configuration> <configuration>
<api>JDO</api> <api>JDO</api>
<props>${basedir}/datanucleus.properties</props> <props>${basedir}/datanucleus.properties</props>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration> <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose> <verbose>true</verbose>
<fork>false</fork> <fork>false</fork>
<!-- Solve windows line too long error --> <!-- Solve windows line too long error -->
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<phase>process-classes</phase> <phase>process-classes</phase>
<goals> <goals>
<goal>enhance</goal> <goal>enhance</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- Neuroph --> <!-- Neuroph -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version> <version>3.0.2</version>
<configuration> <configuration>
<excludes> <excludes>
<exclude>**/log4j.properties</exclude> <exclude>**/log4j.properties</exclude>
</excludes> </excludes>
<archive> <archive>
<manifest> <manifest>
<mainClass>com.baeldung.neuroph.NeurophXOR</mainClass> <mainClass>com.baeldung.neuroph.NeurophXOR</mainClass>
</manifest> </manifest>
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version> <version>2.18.1</version>
<executions> <executions>
<execution> <execution>
<id>test</id> <id>test</id>
<phase>test</phase> <phase>test</phase>
<goals> <goals>
<goal>test</goal> <goal>test</goal>
</goals> </goals>
<configuration> <configuration>
<includes> <includes>
<include>test/java/com/baeldung/neuroph/XORTest.java</include> <include>test/java/com/baeldung/neuroph/XORTest.java</include>
</includes> </includes>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- /Neuroph --> <!-- /Neuroph -->
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/org.beykery/neuroph/2.92 --> <!-- https://mvnrepository.com/artifact/org.beykery/neuroph/2.92 -->
<dependency> <dependency>
<groupId>org.beykery</groupId> <groupId>org.beykery</groupId>
<artifactId>neuroph</artifactId> <artifactId>neuroph</artifactId>
<version>${neuroph.version}</version> <version>${neuroph.version}</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/cglib/cglib --> <!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency> <dependency>
<groupId>cglib</groupId> <groupId>cglib</groupId>
<artifactId>cglib</artifactId> <artifactId>cglib</artifactId>
<version>${cglib.version}</version> <version>${cglib.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-beanutils</groupId> <groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId> <artifactId>commons-beanutils</artifactId>
<version>${commons-beanutils.version}</version> <version>${commons-beanutils.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>${commons-lang.version}</version> <version>${commons-lang.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId> <artifactId>commons-text</artifactId>
<version>${commons-text.version}</version> <version>${commons-text.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId> <artifactId>commons-collections4</artifactId>
<version>${commons.collections.version}</version> <version>${commons.collections.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jasypt</groupId> <groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId> <artifactId>jasypt</artifactId>
<version>${jasypt.version}</version> <version>${jasypt.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.javatuples</groupId> <groupId>org.javatuples</groupId>
<artifactId>javatuples</artifactId> <artifactId>javatuples</artifactId>
<version>${javatuples.version}</version> <version>${javatuples.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.javassist</groupId> <groupId>org.javassist</groupId>
<artifactId>javassist</artifactId> <artifactId>javassist</artifactId>
<version>${javaassist.version}</version> <version>${javaassist.version}</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core --> <!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<version>${assertj.version}</version> <version>${assertj.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.skyscreamer</groupId> <groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId> <artifactId>jsonassert</artifactId>
<version>${jsonassert.version}</version> <version>${jsonassert.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.javers</groupId> <groupId>org.javers</groupId>
<artifactId>javers-core</artifactId> <artifactId>javers-core</artifactId>
<version>${javers.version}</version> <version>${javers.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId> <artifactId>jetty-server</artifactId>
<version>${jetty.version}</version> <version>${jetty.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId> <artifactId>jetty-servlet</artifactId>
<version>${jetty.version}</version> <version>${jetty.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>${httpclient.version}</version> <version>${httpclient.version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>commons-logging</artifactId> <artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>${commons.io.version}</version> <version>${commons.io.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-chain</groupId> <groupId>commons-chain</groupId>
<artifactId>commons-chain</artifactId> <artifactId>commons-chain</artifactId>
<version>${commons-chain.version}</version> <version>${commons-chain.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-dbutils</groupId> <groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId> <artifactId>commons-dbutils</artifactId>
<version>${commons.dbutils.version}</version> <version>${commons.dbutils.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.flink</groupId> <groupId>org.apache.flink</groupId>
<artifactId>flink-core</artifactId> <artifactId>flink-core</artifactId>
<version>${flink.version}</version> <version>${flink.version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>commons-logging</artifactId> <artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.flink</groupId> <groupId>org.apache.flink</groupId>
<artifactId>flink-java</artifactId> <artifactId>flink-java</artifactId>
<version>${flink.version}</version> <version>${flink.version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>commons-logging</artifactId> <artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId> <groupId>commons-logging</groupId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.flink</groupId> <groupId>org.apache.flink</groupId>
<artifactId>flink-test-utils_2.10</artifactId> <artifactId>flink-test-utils_2.10</artifactId>
<version>${flink.version}</version> <version>${flink.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId> <artifactId>commons-math3</artifactId>
<version>3.6.1</version> <version>3.6.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId> <artifactId>serenity-core</artifactId>
<version>${serenity.version}</version> <version>${serenity.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId> <artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version> <version>${serenity.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-jbehave</artifactId> <artifactId>serenity-jbehave</artifactId>
<version>${serenity.jbehave.version}</version> <version>${serenity.jbehave.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-rest-assured</artifactId> <artifactId>serenity-rest-assured</artifactId>
<version>${serenity.version}</version> <version>${serenity.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-jira-requirements-provider</artifactId> <artifactId>serenity-jira-requirements-provider</artifactId>
<version>${serenity.jira.version}</version> <version>${serenity.jira.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version> <version>${jackson.version}</version>
</dependency> </dependency>
<!-- JDO --> <!-- JDO -->
<dependency> <dependency>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>javax.jdo</artifactId> <artifactId>javax.jdo</artifactId>
<version>3.2.0-m6</version> <version>3.2.0-m6</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId> <artifactId>datanucleus-core</artifactId>
<version>5.1.0-m1</version> <version>5.1.0-m1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId> <artifactId>datanucleus-api-jdo</artifactId>
<version>5.1.0-m1</version> <version>5.1.0-m1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId> <artifactId>datanucleus-rdbms</artifactId>
<version>5.1.0-m1</version> <version>5.1.0-m1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId> <artifactId>datanucleus-maven-plugin</artifactId>
<version>5.0.2</version> <version>5.0.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.datanucleus</groupId> <groupId>org.datanucleus</groupId>
<artifactId>datanucleus-xml</artifactId> <artifactId>datanucleus-xml</artifactId>
<version>5.0.0-release</version> <version>5.0.0-release</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.openhft</groupId> <groupId>net.openhft</groupId>
<artifactId>chronicle</artifactId> <artifactId>chronicle</artifactId>
<version>3.6.4</version> <version>3.6.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId> <artifactId>spring-web</artifactId>
<version>4.3.8.RELEASE</version> <version>4.3.8.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-spring</artifactId> <artifactId>serenity-spring</artifactId>
<version>${serenity.version}</version> <version>${serenity.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId> <artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version> <version>${serenity.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.serenity-bdd</groupId> <groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId> <artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version> <version>${serenity.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.rest-assured</groupId> <groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId> <artifactId>spring-mock-mvc</artifactId>
<version>3.0.3</version> <version>3.0.3</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.multiverse</groupId> <groupId>org.multiverse</groupId>
<artifactId>multiverse-core</artifactId> <artifactId>multiverse-core</artifactId>
<version>${multiverse.version}</version> <version>${multiverse.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>2.6.1</version> <version>2.6.1</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<version>${h2.version}</version> <version>${h2.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>pl.pragmatists</groupId> <groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId> <artifactId>JUnitParams</artifactId>
<version>${jUnitParams.version}</version> <version>${jUnitParams.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.quartz-scheduler</groupId> <groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId> <artifactId>quartz</artifactId>
<version>2.3.0</version> <version>2.3.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>one.util</groupId> <groupId>one.util</groupId>
<artifactId>streamex</artifactId> <artifactId>streamex</artifactId>
<version>0.6.5</version> <version>0.6.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jooq</groupId> <groupId>org.jooq</groupId>
<artifactId>jool</artifactId> <artifactId>jool</artifactId>
<version>0.9.12</version> <version>0.9.12</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.openjdk.jmh</groupId> <groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId> <artifactId>jmh-core</artifactId>
<version>1.19</version> <version>1.19</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.openjdk.jmh</groupId> <groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId> <artifactId>jmh-generator-annprocess</artifactId>
<version>1.19</version> <version>1.19</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-all</artifactId> <artifactId>netty-all</artifactId>
<version>${netty.version}</version> <version>${netty.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>${junit.version}</version> <version>${junit.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>info.debatty</groupId> <groupId>info.debatty</groupId>
<artifactId>java-lsh</artifactId> <artifactId>java-lsh</artifactId>
<version>${java-lsh.version}</version> <version>${java-lsh.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>au.com.dius</groupId> <groupId>au.com.dius</groupId>
<artifactId>pact-jvm-consumer-junit_2.11</artifactId> <artifactId>pact-jvm-consumer-junit_2.11</artifactId>
<version>${pact.version}</version> <version>${pact.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.groovy</groupId> <groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId> <artifactId>groovy-all</artifactId>
<version>2.4.10</version> <version>2.4.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.awaitility</groupId> <groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId> <artifactId>awaitility</artifactId>
<version>${awaitility.version}</version> <version>${awaitility.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.awaitility</groupId> <groupId>org.awaitility</groupId>
<artifactId>awaitility-proxy</artifactId> <artifactId>awaitility-proxy</artifactId>
<version>${awaitility.version}</version> <version>${awaitility.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.hamcrest</groupId> <groupId>org.hamcrest</groupId>
<artifactId>java-hamcrest</artifactId> <artifactId>java-hamcrest</artifactId>
<version>${org.hamcrest.java-hamcrest.version}</version> <version>${org.hamcrest.java-hamcrest.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.agkn</groupId> <groupId>net.agkn</groupId>
<artifactId>hll</artifactId> <artifactId>hll</artifactId>
<version>${hll.version}</version> <version>${hll.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bytebuddy</groupId> <groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId> <artifactId>byte-buddy</artifactId>
<version>${bytebuddy.version}</version> <version>${bytebuddy.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.bytebuddy</groupId> <groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId> <artifactId>byte-buddy-agent</artifactId>
<version>${bytebuddy.version}</version> <version>${bytebuddy.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.pcollections</groupId> <groupId>org.pcollections</groupId>
<artifactId>pcollections</artifactId> <artifactId>pcollections</artifactId>
<version>${pcollections.version}</version> <version>${pcollections.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>
<multiverse.version>0.7.0</multiverse.version> <multiverse.version>0.7.0</multiverse.version>
<cglib.version>3.2.4</cglib.version> <cglib.version>3.2.4</cglib.version>
<commons-lang.version>3.5</commons-lang.version> <commons-lang.version>3.5</commons-lang.version>
<commons-text.version>1.1</commons-text.version> <commons-text.version>1.1</commons-text.version>
<commons-beanutils.version>1.9.3</commons-beanutils.version> <commons-beanutils.version>1.9.3</commons-beanutils.version>
<commons-chain.version>1.2</commons-chain.version> <commons-chain.version>1.2</commons-chain.version>
<jasypt.version>1.9.2</jasypt.version> <jasypt.version>1.9.2</jasypt.version>
<javatuples.version>1.2</javatuples.version> <javatuples.version>1.2</javatuples.version>
<javaassist.version>3.21.0-GA</javaassist.version> <javaassist.version>3.21.0-GA</javaassist.version>
<assertj.version>3.6.2</assertj.version> <assertj.version>3.6.2</assertj.version>
<jsonassert.version>1.5.0</jsonassert.version> <jsonassert.version>1.5.0</jsonassert.version>
<javers.version>3.1.0</javers.version> <javers.version>3.1.0</javers.version>
<jetty.version>9.4.3.v20170317</jetty.version> <jetty.version>9.4.3.v20170317</jetty.version>
<httpclient.version>4.5.3</httpclient.version> <httpclient.version>4.5.3</httpclient.version>
<commons.io.version>2.5</commons.io.version> <commons.io.version>2.5</commons.io.version>
<commons.dbutils.version>1.6</commons.dbutils.version> <commons.dbutils.version>1.6</commons.dbutils.version>
<h2.version>1.4.196</h2.version> <h2.version>1.4.196</h2.version>
<jetty.version>9.4.2.v20170220</jetty.version> <jetty.version>9.4.2.v20170220</jetty.version>
<httpclient.version>4.5.3</httpclient.version> <httpclient.version>4.5.3</httpclient.version>
<commons.io.version>2.5</commons.io.version> <commons.io.version>2.5</commons.io.version>
<flink.version>1.2.0</flink.version> <flink.version>1.2.0</flink.version>
<jackson.version>2.8.5</jackson.version> <jackson.version>2.8.5</jackson.version>
<neuroph.version>2.92</neuroph.version> <neuroph.version>2.92</neuroph.version>
<serenity.version>1.4.0</serenity.version> <serenity.version>1.4.0</serenity.version>
<serenity.jbehave.version>1.24.0</serenity.jbehave.version> <serenity.jbehave.version>1.24.0</serenity.jbehave.version>
<serenity.jira.version>1.1.3-rc.5</serenity.jira.version> <serenity.jira.version>1.1.3-rc.5</serenity.jira.version>
<serenity.plugin.version>1.4.0</serenity.plugin.version> <serenity.plugin.version>1.4.0</serenity.plugin.version>
<jUnitParams.version>1.1.0</jUnitParams.version> <jUnitParams.version>1.1.0</jUnitParams.version>
<netty.version>4.1.10.Final</netty.version> <netty.version>4.1.10.Final</netty.version>
<commons.collections.version>4.1</commons.collections.version> <commons.collections.version>4.1</commons.collections.version>
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
<java-lsh.version>0.10</java-lsh.version> <java-lsh.version>0.10</java-lsh.version>
<pact.version>3.5.0</pact.version> <pact.version>3.5.0</pact.version>
<awaitility.version>3.0.0</awaitility.version> <awaitility.version>3.0.0</awaitility.version>
<org.hamcrest.java-hamcrest.version>2.0.0.0</org.hamcrest.java-hamcrest.version> <org.hamcrest.java-hamcrest.version>2.0.0.0</org.hamcrest.java-hamcrest.version>
<hll.version>1.6.0</hll.version> <hll.version>1.6.0</hll.version>
<bytebuddy.version>1.7.1</bytebuddy.version> <bytebuddy.version>1.7.1</bytebuddy.version>
<pcollections.version>2.1.2</pcollections.version> <pcollections.version>2.1.2</pcollections.version>
</properties> </properties>
</project> </project>

View File

@ -1,141 +1,147 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>spring-core</name> <name>spring-core</name>
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId> <artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-all</artifactId>
<version>${mockito.version}</version> <version>${mockito.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId> <artifactId>spring-beans</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId> <artifactId>spring-context</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.inject</groupId> <groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId> <artifactId>javax.inject</artifactId>
<version>${javax.inject.version}</version> <version>${javax.inject.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>${guava.version}</version> <version>${guava.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>${lombok.version}</version> <version>${lombok.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>
<version>1.5.2.RELEASE</version> <version>1.5.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId> <artifactId>spring-boot-test</artifactId>
<version>${mockito.spring.boot.version}</version> <version>${mockito.spring.boot.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version> <version>${maven-war-plugin.version}</version>
<configuration> <configuration>
<failOnMissingWebXml>false</failOnMissingWebXml> <failOnMissingWebXml>false</failOnMissingWebXml>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<profiles> <profiles>
<profile> <profile>
<id>integration</id> <id>integration</id>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<executions> <executions>
<execution> <execution>
<phase>integration-test</phase> <phase>integration-test</phase>
<goals> <goals>
<goal>test</goal> <goal>test</goal>
</goals> </goals>
<configuration> <configuration>
<excludes> <excludes>
<exclude>**/*LiveTest.java</exclude> <exclude>**/*LiveTest.java</exclude>
</excludes> </excludes>
<includes> <includes>
<include>**/*IntegrationTest.java</include> <include>**/*IntegrationTest.java</include>
</includes> </includes>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<test.mime>json</test.mime> <test.mime>json</test.mime>
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</profile> </profile>
</profiles> </profiles>
<properties> <properties>
<mockito.version>1.10.19</mockito.version> <mockito.version>1.10.19</mockito.version>
<mockito.spring.boot.version>1.4.4.RELEASE</mockito.spring.boot.version> <mockito.spring.boot.version>1.4.4.RELEASE</mockito.spring.boot.version>
<spring.version>4.3.4.RELEASE</spring.version> <spring.version>4.3.4.RELEASE</spring.version>
<javax.inject.version>1</javax.inject.version> <javax.inject.version>1</javax.inject.version>
<guava.version>20.0</guava.version> <guava.version>20.0</guava.version>
<maven-war-plugin.version>2.6</maven-war-plugin.version> <maven-war-plugin.version>2.6</maven-war-plugin.version>
<lombok.version>1.16.12</lombok.version> <lombok.version>1.16.12</lombok.version>
</properties> <commons.io.version>2.5</commons.io.version>
</properties>
<repositories> <repositories>
<repository> <repository>
<id>java.net</id> <id>java.net</id>
<url>https://maven.java.net/content/repositories/releases/</url> <url>https://maven.java.net/content/repositories/releases/</url>
</repository> </repository>
</repositories> </repositories>
</project> </project>

View File

@ -0,0 +1,22 @@
package com.baeldung.streamutils;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import org.apache.commons.io.IOUtils;
import org.springframework.util.StreamUtils;
public class CopyStream {
public static String getStringFromInputStream(InputStream input) throws IOException {
StringWriter writer = new StringWriter();
IOUtils.copy(input, writer, "UTF-8");
return writer.toString();
}
public InputStream getNonClosingInputStream() throws IOException {
InputStream in = new FileInputStream("src/test/resources/input.txt");
return StreamUtils.nonClosing(in);
}
}

View File

@ -0,0 +1,11 @@
package com.baeldung.streamutils;
import java.io.InputStream;
import org.springframework.util.StreamUtils;
public class DrainStream {
public InputStream getInputStream() {
return StreamUtils.emptyInput();
}
}

View File

@ -0,0 +1,100 @@
package com.baeldung.streamutils;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.util.StreamUtils;
import static com.baeldung.streamutils.CopyStream.getStringFromInputStream;
public class CopyStreamTest {
@Test
public void whenCopyInputStreamToOutputStream_thenCorrect() throws IOException {
String inputFileName = "src/test/resources/input.txt";
String outputFileName = "src/test/resources/output.txt";
File outputFile = new File(outputFileName);
InputStream in = new FileInputStream(inputFileName);
OutputStream out = new FileOutputStream(outputFileName);
StreamUtils.copy(in, out);
assertTrue(outputFile.exists());
String inputFileContent = getStringFromInputStream(new FileInputStream(inputFileName));
String outputFileContent = getStringFromInputStream(new FileInputStream(outputFileName));
assertEquals(inputFileContent, outputFileContent);
}
@Test
public void whenCopyRangeOfInputStreamToOutputStream_thenCorrect() throws IOException {
String inputFileName = "src/test/resources/input.txt";
String outputFileName = "src/test/resources/output.txt";
File outputFile = new File(outputFileName);
InputStream in = new FileInputStream(inputFileName);
OutputStream out = new FileOutputStream(outputFileName);
StreamUtils.copyRange(in, out, 1, 10);
assertTrue(outputFile.exists());
String inputFileContent = getStringFromInputStream(new FileInputStream(inputFileName));
String outputFileContent = getStringFromInputStream(new FileInputStream(outputFileName));
assertEquals(inputFileContent.substring(1, 11), outputFileContent);
}
@Test
public void whenCopyStringToOutputStream_thenCorrect() throws IOException {
String string = "Should be copied to OutputStream.";
String outputFileName = "src/test/resources/output.txt";
File outputFile = new File(outputFileName);
OutputStream out = new FileOutputStream("src/test/resources/output.txt");
StreamUtils.copy(string, StandardCharsets.UTF_8, out);
assertTrue(outputFile.exists());
String outputFileContent = getStringFromInputStream(new FileInputStream(outputFileName));
assertEquals(outputFileContent, string);
}
@Test
public void whenCopyInputStreamToString_thenCorrect() throws IOException {
String inputFileName = "src/test/resources/input.txt";
InputStream is = new FileInputStream(inputFileName);
String content = StreamUtils.copyToString(is, StandardCharsets.UTF_8);
String inputFileContent = getStringFromInputStream(new FileInputStream(inputFileName));
assertEquals(inputFileContent, content);
}
@Test
public void whenCopyByteArrayToOutputStream_thenCorrect() throws IOException {
String outputFileName = "src/test/resources/output.txt";
String string = "Should be copied to OutputStream.";
byte[] byteArray = string.getBytes();
OutputStream out = new FileOutputStream("src/test/resources/output.txt");
StreamUtils.copy(byteArray, out);
String outputFileContent = getStringFromInputStream(new FileInputStream(outputFileName));
assertEquals(outputFileContent, string);
}
@Test
public void whenCopyInputStreamToByteArray_thenCorrect() throws IOException {
String inputFileName = "src/test/resources/input.txt";
InputStream in = new FileInputStream(inputFileName);
byte[] out = StreamUtils.copyToByteArray(in);
String content = new String(out);
String inputFileContent = getStringFromInputStream(new FileInputStream(inputFileName));
assertEquals(inputFileContent, content);
}
}

View File

@ -0,0 +1 @@
This file is merely for testing.

View File

@ -0,0 +1 @@
Should be copied to OutputStream.