mirror of https://github.com/apache/archiva.git
use Base64 from commons-codec
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177567 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5daf80bc20
commit
42b564bb7d
|
@ -28,7 +28,7 @@ import com.meterware.servletunit.ServletUnitClient;
|
|||
import junit.framework.TestCase;
|
||||
import org.apache.commons.codec.Encoder;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -47,6 +47,23 @@ public class RssFeedServletTest
|
|||
client = sr.newClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
if ( client != null )
|
||||
{
|
||||
client.clearContents();
|
||||
}
|
||||
|
||||
if ( sr != null )
|
||||
{
|
||||
sr.shutDown();
|
||||
}
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testRetrieveServlet()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -64,9 +81,9 @@ public class RssFeedServletTest
|
|||
|
||||
WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo" );
|
||||
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
Base64 encoder = new Base64(0, new byte[0]);
|
||||
String userPass = "user1:password1";
|
||||
String encodedUserPass = encoder.encode( userPass.getBytes() );
|
||||
String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
|
||||
request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );
|
||||
|
||||
WebResponse response = client.getResponse( request );
|
||||
|
@ -84,9 +101,9 @@ public class RssFeedServletTest
|
|||
|
||||
WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/artifact-two" );
|
||||
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
Base64 encoder = new Base64(0, new byte[0]);
|
||||
String userPass = "user1:password1";
|
||||
String encodedUserPass = encoder.encode( userPass.getBytes() );
|
||||
String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
|
||||
request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );
|
||||
|
||||
WebResponse response = client.getResponse( request );
|
||||
|
@ -149,9 +166,9 @@ public class RssFeedServletTest
|
|||
|
||||
WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );
|
||||
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
Base64 encoder = new Base64(0, new byte[0]);
|
||||
String userPass = "user1:password1";
|
||||
String encodedUserPass = encoder.encode( userPass.getBytes() );
|
||||
String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
|
||||
request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );
|
||||
|
||||
try
|
||||
|
@ -166,21 +183,6 @@ public class RssFeedServletTest
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown()
|
||||
throws Exception
|
||||
{
|
||||
if ( client != null )
|
||||
{
|
||||
client.clearContents();
|
||||
}
|
||||
|
||||
if ( sr != null )
|
||||
{
|
||||
sr.shutDown();
|
||||
}
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue