Author: olamy
Date: Fri Nov 4 16:58:51 2011
New Revision: 1197664
URL: http://svn.apache.org/viewvc?rev=1197664&view=rev
Log:
fix unit tests in webapp those lucene locks kills me :-)
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml?rev=1197664&r1=1197663&r2=1197664&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/pom.xml Fri Nov 4
16:58:51 2011
@@ -579,6 +579,9 @@
<archiva.baseRestUrl>${archiva.baseRestUrl}</archiva.baseRestUrl>
<rest.admin.pwd>${rest.admin.pwd}</rest.admin.pwd>
<archiva.user.configFileName>${basedir}/target/archiva.xml</archiva.user.configFileName>
+
<test.resources.path>${project.build.testOutputDirectory}</test.resources.path>
+
<redback.jdbc.url>jdbc:derby:memory:users-test;create=true</redback.jdbc.url>
+
<redback.jdbc.driver.name>org.apache.derby.jdbc.EmbeddedDriver</redback.jdbc.driver.name>
<basedir>${basedir}</basedir>
</systemPropertyVariables>
</configuration>
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java?rev=1197664&r1=1197663&r2=1197664&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RssFeedServletTest.java
Fri Nov 4 16:58:51 2011
@@ -28,13 +28,19 @@ import com.meterware.servletunit.Servlet
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
{
@@ -42,6 +48,25 @@ public class RssFeedServletTest
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
{
@@ -49,8 +74,8 @@ public class RssFeedServletTest
client = sr.newClient();
}
- @Override
- protected void tearDown()
+ @After
+ public void tearDown()
throws Exception
{
if ( client != null )
@@ -66,25 +91,27 @@ public class RssFeedServletTest
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 );
@@ -96,6 +123,7 @@ public class RssFeedServletTest
}
+ @Test
public void testRequestNewVersionsOfArtifact()
throws Exception
{
@@ -105,7 +133,7 @@ public class RssFeedServletTest
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 );
@@ -116,11 +144,12 @@ public class RssFeedServletTest
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
@@ -135,11 +164,12 @@ public class RssFeedServletTest
}
}
+ @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" );
@@ -161,16 +191,17 @@ public class RssFeedServletTest
}
}
+ @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 );
@@ -188,5 +219,4 @@ public class RssFeedServletTest
}
-
}
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml
URL:
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml?rev=1197664&r1=1197663&r2=1197664&view=diff
==============================================================================
---
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml
(original)
+++
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml
Fri Nov 4 16:58:51 2011
@@ -43,4 +43,25 @@
<alias name="securitySystem#test" alias="securitySystem"/>
+ <bean name="archivaConfiguration#default"
class="org.apache.archiva.configuration.DefaultArchivaConfiguration">
+ <property name="registry" ref="registry#default"/>
+ </bean>
+
+ <alias name="archivaConfiguration#default" alias="archivaConfiguration"/>
+
+ <bean name="registry#default"
class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <system/>
+ <xml fileName="${test.resources.path}/empty-archiva.xml"
config-forceCreate="true"
+ config-optional="true"
+ config-name="org.apache.archiva.base"
config-at="org.apache.archiva"/>
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
</beans>
\ No newline at end of file