import junit.framework.TestCase;
import org.apache.commons.codec.Encoder;
import org.apache.commons.codec.binary.Base64;
-import org.apache.jackrabbit.core.RepositoryImpl;
-import org.apache.jackrabbit.core.util.RepositoryLock;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
-
-import java.io.File;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+@RunWith( BlockJUnit4ClassRunner.class )
public class RssFeedServletTest
extends TestCase
{
private ServletUnitClient client;
+ static String PREVIOUS_ARCHIVA_PATH;
+
+ @BeforeClass
+ public static void initConfigurationPath()
+ throws Exception
+ {
+ PREVIOUS_ARCHIVA_PATH = System.getProperty( "archiva.user.configFileName" );
+ System.setProperty( "archiva.user.configFileName",
+ System.getProperty( "test.resources.path/" ) + "empty-archiva.xml" );
+ }
+
+ @AfterClass
+ public static void restoreConfigurationPath()
+ throws Exception
+ {
+ System.setProperty( "archiva.user.configFileName", PREVIOUS_ARCHIVA_PATH );
+ }
+
+ @Before
public void setUp()
throws Exception
{
client = sr.newClient();
}
- @Override
- protected void tearDown()
+ @After
+ public void tearDown()
throws Exception
{
if ( client != null )
super.tearDown();
}
+ @Test
public void testRetrieveServlet()
throws Exception
{
- RssFeedServlet servlet = (RssFeedServlet) client.newInvocation(
- "http://localhost/feeds/test-repo" ).getServlet();
+ RssFeedServlet servlet =
+ (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet();
assertNotNull( servlet );
}
+ @Test
public void testRequestNewArtifactsInRepo()
throws Exception
{
- RssFeedServlet servlet = (RssFeedServlet) client.newInvocation(
- "http://localhost/feeds/test-repo" ).getServlet();
+ RssFeedServlet servlet =
+ (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet();
assertNotNull( servlet );
WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo" );
- Base64 encoder = new Base64(0, new byte[0]);
+ Base64 encoder = new Base64( 0, new byte[0] );
String userPass = "user1:password1";
String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );
}
+ @Test
public void testRequestNewVersionsOfArtifact()
throws Exception
{
WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/artifact-two" );
- Base64 encoder = new Base64(0, new byte[0]);
+ Base64 encoder = new Base64( 0, new byte[0] );
String userPass = "user1:password1";
String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );
assertEquals( "Should have been an OK response code.", HttpServletResponse.SC_OK, response.getResponseCode() );
}
+ @Ignore
public void XXX_testInvalidRequest()
throws Exception
{
- RssFeedServlet servlet = (RssFeedServlet) client.newInvocation(
- "http://localhost/feeds?invalid_param=xxx" ).getServlet();
+ RssFeedServlet servlet =
+ (RssFeedServlet) client.newInvocation( "http://localhost/feeds?invalid_param=xxx" ).getServlet();
assertNotNull( servlet );
try
}
}
+ @Ignore
public void XXX_testInvalidAuthenticationRequest()
throws Exception
{
- RssFeedServlet servlet = (RssFeedServlet) client.newInvocation(
- "http://localhost/feeds/unauthorized-repo" ).getServlet();
+ RssFeedServlet servlet =
+ (RssFeedServlet) client.newInvocation( "http://localhost/feeds/unauthorized-repo" ).getServlet();
assertNotNull( servlet );
WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );
}
}
+ @Ignore
public void XXX_testUnauthorizedRequest()
throws Exception
{
- RssFeedServlet servlet = (RssFeedServlet) client.newInvocation(
- "http://localhost/feeds/unauthorized-repo" ).getServlet();
+ RssFeedServlet servlet =
+ (RssFeedServlet) client.newInvocation( "http://localhost/feeds/unauthorized-repo" ).getServlet();
assertNotNull( servlet );
WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );
- Base64 encoder = new Base64(0, new byte[0]);
+ Base64 encoder = new Base64( 0, new byte[0] );
String userPass = "user1:password1";
String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );
}
-
}