Author: rfscholte Date: Sat Feb 18 12:43:16 2017 New Revision: 1783526 URL: http://svn.apache.org/viewvc?rev=1783526&view=rev Log: [MSHARED-617] (FreeBSD) StreamFeeder.java should flush OutputStream Add unittest
Added: maven/shared/branches/maven-shared-utils-0.9.x/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java Modified: maven/shared/branches/maven-shared-utils-0.9.x/pom.xml Modified: maven/shared/branches/maven-shared-utils-0.9.x/pom.xml URL: http://svn.apache.org/viewvc/maven/shared/branches/maven-shared-utils-0.9.x/pom.xml?rev=1783526&r1=1783525&r2=1783526&view=diff ============================================================================== --- maven/shared/branches/maven-shared-utils-0.9.x/pom.xml (original) +++ maven/shared/branches/maven-shared-utils-0.9.x/pom.xml Sat Feb 18 12:43:16 2017 @@ -103,6 +103,12 @@ <version>1.1</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> </dependencies> <build> Added: maven/shared/branches/maven-shared-utils-0.9.x/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java URL: http://svn.apache.org/viewvc/maven/shared/branches/maven-shared-utils-0.9.x/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java?rev=1783526&view=auto ============================================================================== --- maven/shared/branches/maven-shared-utils-0.9.x/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java (added) +++ maven/shared/branches/maven-shared-utils-0.9.x/src/test/java/org/apache/maven/shared/utils/cli/StreamFeederTest.java Sat Feb 18 12:43:16 2017 @@ -0,0 +1,53 @@ +package org.apache.maven.shared.utils.cli; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.junit.Test; + +public class StreamFeederTest +{ + + /** + * [MSHARED-617] (FreeBSD) StreamFeeder.java should flush OutputStream + * + * @throws IOException + */ + @Test + public void testRun() throws IOException + { + InputStream input = mock( InputStream.class); + when( input.read() ).thenReturn( 0, -1 ); + OutputStream output = mock(OutputStream.class); + StreamFeeder feeder = new StreamFeeder( input, output ); + + feeder.run(); + + verify( output ).flush(); + } + +}