Author: olamy
Date: Thu Oct  6 11:14:12 2011
New Revision: 1179573

URL: http://svn.apache.org/viewvc?rev=1179573&view=rev
Log:
[WAGON-353] StreamWagon.putFromStream() fails with IllegalStateExceptio
add a unit with non authorized put

Modified:
    
maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java

Modified: 
maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
URL: 
http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java?rev=1179573&r1=1179572&r2=1179573&view=diff
==============================================================================
--- 
maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
 (original)
+++ 
maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
 Thu Oct  6 11:14:12 2011
@@ -877,16 +877,25 @@ public abstract class HttpWagonTestCase
         testPreemptiveAuthentication( sh );
     }
 
+    public void testNonSecuredPutFromStream( )
+        throws Exception
+    {
+        AuthenticationInfo authInfo = new AuthenticationInfo( );
+        authInfo.setUserName( "user" );
+        authInfo.setPassword( "secret" );
+        runTestSecuredPutFromStream( authInfo, 1, false );
+    }
+
     public void testSecuredPutFromStream( )
         throws Exception
     {
         AuthenticationInfo authInfo = new AuthenticationInfo( );
         authInfo.setUserName( "user" );
         authInfo.setPassword( "secret" );
-        runTestSecuredPutFromStream( authInfo, 1 );
+        runTestSecuredPutFromStream( authInfo, 1, true );
     }
 
-    public void runTestSecuredPutFromStream( AuthenticationInfo authInfo, int 
putNumber )
+    public void runTestSecuredPutFromStream( AuthenticationInfo authInfo, int 
putNumber, boolean addSecurityHandler )
         throws Exception
     {
         String localRepositoryPath = FileTestUtils.getTestOutputDir( 
).toString( );
@@ -897,7 +906,7 @@ public abstract class HttpWagonTestCase
         PutHandler putHandler = new PutHandler( new File( localRepositoryPath 
) );
 
         HandlerCollection handlers = new HandlerCollection( );
-        handlers.setHandlers( new Handler[]{ sh, putHandler } );
+        handlers.setHandlers( addSecurityHandler ? new Handler[]{ sh, 
putHandler } : new Handler[]{ putHandler } );
 
         server.setHandler( handlers );
         addConnectors( server );
@@ -905,7 +914,14 @@ public abstract class HttpWagonTestCase
 
         StreamingWagon wagon = (StreamingWagon) getWagon( );
         Repository testRepository = new Repository( "id", getRepositoryUrl( 
server ) );
-        wagon.connect( testRepository, authInfo );
+        if ( addSecurityHandler )
+        {
+            wagon.connect( testRepository, authInfo );
+        }
+        else
+        {
+            wagon.connect( testRepository );
+        }
         try
         {
             for ( int i = 0; i < putNumber; i++ )
@@ -925,7 +941,7 @@ public abstract class HttpWagonTestCase
                 }
                 finally
                 {
-                    fileInputStream.close();
+                    fileInputStream.close( );
                     tempFile.delete( );
 
                 }
@@ -939,7 +955,10 @@ public abstract class HttpWagonTestCase
             server.stop( );
         }
         assertEquals( putNumber, putHandler.putCallNumber );
-        testPreemptiveAuthentication( sh );
+        if ( addSecurityHandler )
+        {
+            testPreemptiveAuthentication( sh );
+        }
     }
 
 


Reply via email to