Author: ate
Date: Mon Apr 30 16:56:07 2007
New Revision: 533888
URL: http://svn.apache.org/viewvc?view=rev&rev=533888
Log:
Fixing test run for the Capabilities component.
This uses the new JetspeedSerializer for seeding (and clearing) the database.
As the database setup really only needs to be run once before the tests, and
clearing again only afterwards,
I've implemented this as two separate test methods, testSetup and testTeardown
which are defined as first and last (test) methods.
Note: you can now actually *debug* the TestCapability right from within Eclipse
using the m2eclipse plugin running the project as external execution.
For this to work though, I had to configure the surefire plugin to *not* fork
the tests (see root pom.xml).
But now by setting a breakpoint in TestCapability and running the project with
goal test allows you to nicely step through the test code :)
Added:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/datasource.xml
(with props)
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/serializer.xml
(with props)
Modified:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/pom.xml
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/java/org/apache/jetspeed/capabilities/TestCapability.java
Modified:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/pom.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/pom.xml?view=diff&rev=533888&r1=533887&r2=533888
==============================================================================
---
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/pom.xml
(original)
+++
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/pom.xml
Mon Apr 30 16:56:07 2007
@@ -56,8 +56,56 @@
<artifactId>jetspeed-serializer</artifactId>
</dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>jetspeed-cm</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${org.apache.jetspeed.test.jdbc.driver.groupId}</groupId>
+
<artifactId>${org.apache.jetspeed.test.jdbc.driver.artifactId}</artifactId>
+ <version>${org.apache.jetspeed.test.jdbc.driver.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
- <!-- TODO: test setup configuration -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>jetspeed-maven-plugins</artifactId>
+ <version>${pom.version}</version>
+ <dependencies>
+ </dependencies>
+ <executions>
+ <execution>
+ <id>unpack-test-resources</id>
+ <goals>
+ <goal>unpack-resources</goal>
+ </goals>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+
<resourceBundle>${groupId}:jetspeed-portal-resources:${pom.version}</resourceBundle>
+
<targetBaseDirectory>${project.build.outputDirectory}</targetBaseDirectory>
+ <resources>
+ <unpack>
+ <entryset dir="webapp/WEB-INF/assembly"
includes="capabilities.xml,transaction.xml"/>
+ <entryset dir="db-ojb"/>
+ <entryset dir="seed/min" includes="j2-seed.xml"/>
+ </unpack>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ </build>
-</project>
+</project>
\ No newline at end of file
Modified:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/java/org/apache/jetspeed/capabilities/TestCapability.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/java/org/apache/jetspeed/capabilities/TestCapability.java?view=diff&rev=533888&r1=533887&r2=533888
==============================================================================
---
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/java/org/apache/jetspeed/capabilities/TestCapability.java
(original)
+++
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/java/org/apache/jetspeed/capabilities/TestCapability.java
Mon Apr 30 16:56:07 2007
@@ -25,7 +25,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
+import org.apache.jetspeed.components.test.AbstractSpringTestCase;
+import org.apache.jetspeed.serializer.JetspeedSerializer;
/**
@@ -34,7 +35,7 @@
* @author <a href="[EMAIL PROTECTED]">Roger Ruttimann</a>
* @version $Id$
*/
-public class TestCapability extends DatasourceEnabledSpringTestCase
+public class TestCapability extends AbstractSpringTestCase
{
private Capabilities capabilities = null;
@@ -61,6 +62,19 @@
// All methods starting with "test" will be executed in the test suite.
return new TestSuite(TestCapability.class);
}
+
+ /**
+ * First test defined is used to setup the data(base)
+ * <b>DO NOT ADD TESTS ABOVE THIS ONE</b>
+ *
+ */
+ public void testSetup() throws Exception
+ {
+ System.out.println("testSetup");
+ JetspeedSerializer serializer =
(JetspeedSerializer)ctx.getBean("serializer");
+ serializer.deleteData();
+ serializer.importData("target/classes/j2-seed.xml");
+ }
/**
* Tests categories
@@ -518,7 +532,22 @@
protected String[] getConfigurations()
{
return new String[]
- { "capabilities.xml", "transaction.xml" };
+ { "capabilities.xml", "transaction.xml", "serializer.xml" };
}
+ protected String[] getBootConfigurations()
+ {
+ return new String[]
+ { "boot/datasource.xml"};
+ }
+ /**
+ * Last test defined is used to cleanup the data(base)
+ * <b>DO NOT ADD TESTS BELOW THIS ONE</b>
+ */
+ public void testTeardown() throws Exception
+ {
+ System.out.println("testTeardown");
+ JetspeedSerializer serializer =
(JetspeedSerializer)ctx.getBean("serializer");
+ serializer.deleteData();
+ }
}
Added:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/datasource.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/datasource.xml?view=auto&rev=533888
==============================================================================
---
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/datasource.xml
(added)
+++
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/datasource.xml
Mon Apr 30 16:56:07 2007
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
+<beans>
+
+ <bean id="ojbConfigurer"
class="org.springmodules.orm.ojb.support.LocalOjbConfigurer"/>
+
+ <bean id="PlatformConfigurator"
class="org.apache.jetspeed.components.rdbms.ojb.DatabasePlatformConfigurator"
init-method="init">
+ <constructor-arg index='0'>
+ <ref bean="JetspeedDS"/>
+ </constructor-arg>
+ <!-- JNDI Name -->
+ <constructor-arg index='1'>
+ <value>JetspeedDS</value>
+ </constructor-arg>
+ </bean>
+
+ <bean id="JetspeedDS" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
+ <property
name="driverClassName"><value>${org.apache.jetspeed.test.database.driver}</value></property>
+ <property
name="url"><value>${org.apache.jetspeed.test.database.url}</value></property>
+ <property
name="username"><value>${org.apache.jetspeed.test.database.user}</value></property>
+ <property
name="password"><value>${org.apache.jetspeed.test.database.password}</value></property>
+ </bean>
+
+</beans>
Propchange:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/datasource.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/boot/datasource.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/serializer.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/serializer.xml?view=auto&rev=533888
==============================================================================
---
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/serializer.xml
(added)
+++
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/serializer.xml
Mon Apr 30 16:56:07 2007
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+
+ <bean id="serializer"
class="org.apache.jetspeed.serializer.JetspeedSerializerImpl">
+ <constructor-arg index="0">
+ <list>
+ <bean
class="org.apache.jetspeed.serializer.JetspeedCapabilitiesSerializer">
+ <constructor-arg
ref="org.apache.jetspeed.capabilities.Capabilities"/>
+ </bean>
+ </list>
+ </constructor-arg>
+ <constructor-arg index="1">
+ <map>
+ <entry key="process_capabilities"><value
type="java.lang.Boolean">true</value></entry>
+ </map>
+ </constructor-arg>
+ </bean>
+
+</beans>
Propchange:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/serializer.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
portals/jetspeed-2/branches/J2-M2-REDUX/components/jetspeed-capability/src/test/resources/serializer.xml
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]