Author: tcunning Date: Tue Jun 15 17:36:30 2010 New Revision: 954977 URL: http://svn.apache.org/viewvc?rev=954977&view=rev Log: SCOUT-95 Add an AOP-based test for the AuthToken cache, fix up the DELETE_ASSOCIATION case. Bring in aspectj into the build so that we can build the AOP test. The new AOP-based tests can be enabled by : mvn -Dtestcache=true clean install
Added: webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/BusinessLifeCycleManagerImplReplacement.java webservices/scout/trunk/src/test/resources/META-INF/ webservices/scout/trunk/src/test/resources/META-INF/aop.xml Modified: webservices/scout/trunk/pom.xml webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java Modified: webservices/scout/trunk/pom.xml URL: http://svn.apache.org/viewvc/webservices/scout/trunk/pom.xml?rev=954977&r1=954976&r2=954977&view=diff ============================================================================== --- webservices/scout/trunk/pom.xml (original) +++ webservices/scout/trunk/pom.xml Tue Jun 15 17:36:30 2010 @@ -269,10 +269,35 @@ <version>1.2.13</version> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>1.6.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>1.5.2</version> + <scope>test</scope> + </dependency> </dependencies> <build> <pluginManagement> - <plugins> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>aspectj-maven-plugin</artifactId> + <version>1.3</version> + <executions> + <execution> + <goals> + <goal>test-compile</goal> <!-- use this goal to weave all your test classes --> + </goals> + </execution> + </executions> + </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> @@ -378,11 +403,31 @@ </dependency> </dependencies> </plugin> - </plugins> </build> </profile> - + <profile> + <id>testcache</id> + <activation> + <activeByDefault>false</activeByDefault> + <property> + <name>testcache</name> + <value>true</value> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <forkMode>pertest</forkMode> + <argLine>-javaagent:${settings.localRepository}/aspectj/aspectjweaver/1.5.2/aspectjweaver-1.5.2.jar</argLine> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> <reporting> Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java?rev=954977&r1=954976&r2=954977&view=diff ============================================================================== --- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java (original) +++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerImpl.java Tue Jun 15 17:36:30 2010 @@ -643,7 +643,7 @@ public class BusinessLifeCycleManagerImp token = getAuthToken(connection, ireg); clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray); - } + } } else if (op.equalsIgnoreCase("DELETE_SERVICE")) { try { @@ -654,7 +654,7 @@ public class BusinessLifeCycleManagerImp AuthTokenSingleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray); } } @@ -667,7 +667,7 @@ public class BusinessLifeCycleManagerImp AuthTokenSingleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray); } } @@ -685,7 +685,7 @@ public class BusinessLifeCycleManagerImp } } else if (op.equalsIgnoreCase("DELETE_ASSOCIATION")) { - int len = ((String[]) dataarray).length; + int len = ((String[]) dataarray).length; PublisherAssertion[] paarr = new PublisherAssertion[len]; for(int i=0;i<len;i++) { @@ -705,7 +705,17 @@ public class BusinessLifeCycleManagerImp } } else if (op.equalsIgnoreCase("DELETE_CLASSIFICATIONSCHEME")) { - regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); + try { + regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); + } catch (RegistryException rve) { + String username = getUsernameFromCredentials(connection.getCredentials()); + if (AuthTokenSingleton.getToken(username) != null) { + AuthTokenSingleton.deleteAuthToken(username); + } + token = getAuthToken(connection, ireg); + clearPublisherAssertions(token.getAuthInfo(), ireg); + regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); + } } else { throw new JAXRException("Unsupported operation:" + op); @@ -749,7 +759,17 @@ public class BusinessLifeCycleManagerImp } catch (RegistryException e) { - throw new RuntimeException(e); + ConnectionImpl connection = registry.getConnection(); + String username = getUsernameFromCredentials(connection.getCredentials()); + if (AuthTokenSingleton.getToken(username) != null) { + AuthTokenSingleton.deleteAuthToken(username); + } + AuthToken token = null; + try { + token = getAuthToken(connection, ireg); + } catch (JAXRException je) { + } + clearPublisherAssertions( token.getAuthInfo(), ireg); } } Modified: webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java?rev=954977&r1=954976&r2=954977&view=diff ============================================================================== --- webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java (original) +++ webservices/scout/trunk/src/main/java/org/apache/ws/scout/registry/BusinessLifeCycleManagerV3Impl.java Tue Jun 15 17:36:30 2010 @@ -639,7 +639,7 @@ public class BusinessLifeCycleManagerV3I AuthTokenV3Singleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteBusiness(token.getAuthInfo(), (String[]) dataarray); } } @@ -652,7 +652,7 @@ public class BusinessLifeCycleManagerV3I AuthTokenV3Singleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteService(token.getAuthInfo(), (String[]) dataarray); } } @@ -665,7 +665,7 @@ public class BusinessLifeCycleManagerV3I AuthTokenV3Singleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteBinding(token.getAuthInfo(), (String[]) dataarray); } } @@ -678,7 +678,7 @@ public class BusinessLifeCycleManagerV3I AuthTokenV3Singleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); } } @@ -698,7 +698,7 @@ public class BusinessLifeCycleManagerV3I AuthTokenV3Singleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deletePublisherAssertions(token.getAuthInfo(), paarr); } } @@ -711,7 +711,7 @@ public class BusinessLifeCycleManagerV3I AuthTokenV3Singleton.deleteAuthToken(username); } token = getAuthToken(connection, ireg); - clearPublisherAssertions(token.getAuthInfo(), ireg); + //clearPublisherAssertions(token.getAuthInfo(), ireg); regobj = ireg.deleteTModel(token.getAuthInfo(), (String[]) dataarray); } } Added: webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/BusinessLifeCycleManagerImplReplacement.java URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/BusinessLifeCycleManagerImplReplacement.java?rev=954977&view=auto ============================================================================== --- webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/BusinessLifeCycleManagerImplReplacement.java (added) +++ webservices/scout/trunk/src/test/java/org/apache/ws/scout/registry/qa/BusinessLifeCycleManagerImplReplacement.java Tue Jun 15 17:36:30 2010 @@ -0,0 +1,111 @@ +package org.apache.ws.scout.registry.qa; + +import java.net.URL; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.Statement; +import java.util.Properties; + +import org.apache.ws.scout.model.uddi.v2.BusinessDetail; +import org.apache.ws.scout.model.uddi.v2.BusinessEntity; + +import org.apache.ws.scout.model.uddi.v2.PublisherAssertion; +import org.apache.ws.scout.model.uddi.v2.PublisherAssertions; + +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +...@aspect +public class BusinessLifeCycleManagerImplReplacement { + private static final String JUDDI_PROPERTIES_FILE = "juddi.properties"; + + private static final String JDBC_DRIVER = "juddi.jdbcDriver"; + private static final String JDBC_URL = "juddi.jdbcUrl"; + private static final String JDBC_USER = "juddi.jdbcUsername"; + private static final String JDBC_PASSWORD = "juddi.jdbcPassword"; + + private Connection conn; + +// @Before(" call(org.apache.ws.scout.model.uddi.v2.BusinessDetail saveBusiness(String,org.apache.ws.scout.model.uddi.v2.BusinessEntity[])) " +// + "&& within(org.apache.ws.scout.registry.BusinessLifeCycleManagerImpl)") + @Before(" call(boolean equalsIgnoreCase(String)) " + + "&& within(org.apache.ws.scout.registry.BusinessLifeCycleManagerImpl)") + public void beforeSaveOrgCall() throws Exception { + System.out.println("Clearing the AUTH_TOKEN table..."); + dbinit(); + clearAuthTokens(); + dbclose(); + } + + public void dbinit () throws Exception { + URL url = this.getClass().getClassLoader().getResource(JUDDI_PROPERTIES_FILE); + Properties prop = new Properties(); + prop.load(url.openStream()); + + String jdbcURL = System.getProperty(JDBC_URL, prop.getProperty(JDBC_URL)); + String jdbcDriver = System.getProperty(JDBC_DRIVER, prop.getProperty(JDBC_DRIVER)); + String jdbcUser = System.getProperty(JDBC_USER, prop.getProperty(JDBC_USER)); + String jdbcPass = System.getProperty(JDBC_PASSWORD, prop.getProperty(JDBC_PASSWORD)); + + Class.forName(jdbcDriver); + conn = DriverManager.getConnection(jdbcURL, jdbcUser, jdbcPass); + } + + public void dbclose() throws Exception { + if (conn != null) { + conn.close(); + conn = null; + } + } + + public void clearAuthTokens() throws Exception { + String delQuery = "delete from AUTH_TOKEN"; + Statement st = conn.createStatement(); + st.executeUpdate(delQuery); + } + +/* + @Before(" call(org.apache.ws.scout.model.uddi.v2.ServiceDetail saveService(String,org.apache.ws.scout.model.uddi.v2.BusinessService[]))" + + "&& within(org.apache.ws.scout.registry.qa.JAXR065AuthTokenCacheTest)") + public void beforeServiceCall() { + System.out.println("POINTCUT: deleteAuthTokens"); + } + + @Before(" call(org.apache.ws.scout.model.uddi.v2.BindingDetail saveBinding(String,org.apache.ws.scout.model.uddi.v2.BindingTemplate[]))" + + "&& within(org.apache.ws.scout.registry.qa.JAXR065AuthTokenCacheTest)") + public void beforeSaveServiceBindingCall() { + System.out.println("POINTCUT: deleteAuthTokens"); + } + + @Before(" call(org.apache.ws.scout.model.uddi.v2.TModelDetail saveTModel(String,org.apache.ws.scout.model.uddi.v2.TModel[]))" + + "&& within(org.apache.ws.scout.registry.qa.JAXR065AuthTokenCacheTest..*)") + public void beforeSaveTModelCall() { + System.out.println("POINTCUT: deleteAuthTokens"); + } + + @Before(" call(org.apache.ws.scout.model.uddi.v2.DispositionReport deleteBusiness(String,String[]))" + + "&& within(org.apache.ws.scout.registry.qa.JAXR065AuthTokenCacheTest..*)") + public void beforeDeleteOrgCall() { + System.out.println("POINTCUT: deleteAuthTokens"); + } + + @Before(" call(org.apache.ws.scout.model.uddi.v2.DispositionReport deleteService(String,String[]))" + + "&& within(org.apache.ws.scout.registry.qa.JAXR065AuthTokenCacheTest..*)") + public void beforeDeleteServiceCall() { + System.out.println("POINTCUT: deleteAuthTokens"); + } + + @Before(" call(org.apache.ws.scout.model.uddi.v2.DispositionReport deleteTModel(String,String[]))" + + "&& within(org.apache.ws.scout.registry.qa.JAXR065AuthTokenCacheTest..*)") + public void beforeDeleteTModelCall() { + System.out.println("POINTCUT: deleteAuthTokens"); + } + + @Before(" call(org.apache.ws.scout.model.uddi.v2.DispositionReport deleteBinding(String,String[]))" + + "&& within(org.apache.ws.scout.registry.qa.JAXR065AuthTokenCacheTest..*)") + public void beforeDeleteServiceBindingCall() { + System.out.println("POINTCUT: deleteAuthTokens"); + } + */ +} \ No newline at end of file Added: webservices/scout/trunk/src/test/resources/META-INF/aop.xml URL: http://svn.apache.org/viewvc/webservices/scout/trunk/src/test/resources/META-INF/aop.xml?rev=954977&view=auto ============================================================================== --- webservices/scout/trunk/src/test/resources/META-INF/aop.xml (added) +++ webservices/scout/trunk/src/test/resources/META-INF/aop.xml Tue Jun 15 17:36:30 2010 @@ -0,0 +1,5 @@ +<aspectj> + <aspects> + <aspect name="org.apache.ws.scout.registry.qa.BusinessLifeCycleManagerImplReplacement"/> + </aspects> +</aspectj> --------------------------------------------------------------------- To unsubscribe, e-mail: scout-dev-unsubscr...@ws.apache.org For additional commands, e-mail: scout-dev-h...@ws.apache.org