You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2012/10/18 15:04:14 UTC
svn commit: r1399647 - in /incubator/syncope/trunk: ./ core/
core/src/main/java/org/apache/syncope/core/init/
core/src/main/java/org/apache/syncope/core/workflow/
core/src/test/java/org/apache/syncope/core/
core/src/test/java/org/apache/syncope/core/re...
Author: ilgrosso
Date: Thu Oct 18 13:04:13 2012
New Revision: 1399647
URL: http://svn.apache.org/viewvc?rev=1399647&view=rev
Log:
Merge from 1_0_X
Added:
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java
- copied unchanged from r1399638, incubator/syncope/branches/1_0_X/core/src/main/java/org/apache/syncope/core/init/WorkflowLoader.java
incubator/syncope/trunk/core/src/test/resources/noopworkflow/
- copied from r1399638, incubator/syncope/branches/1_0_X/core/src/test/resources/noopworkflow/
Modified:
incubator/syncope/trunk/ (props changed)
incubator/syncope/trunk/core/pom.xml
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java
incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java
incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java
incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
Propchange: incubator/syncope/trunk/
------------------------------------------------------------------------------
Merged /incubator/syncope/branches/1_0_X:r1399187-1399638
Modified: incubator/syncope/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/pom.xml?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/pom.xml (original)
+++ incubator/syncope/trunk/core/pom.xml Thu Oct 18 13:04:13 2012
@@ -864,7 +864,9 @@ under the License.
<phase>process-test-resources</phase>
<configuration>
<target>
- <copy tofile="${project.build.directory}/classes/META-INF/orm.xml" file="${basedir}/src/main/resources/META-INF/orm.xml.oracle" overwrite="true" />
+ <copy tofile="${project.build.directory}/classes/META-INF/orm.xml"
+ file="${basedir}/src/main/resources/META-INF/orm.xml.oracle"
+ overwrite="true" />
</target>
</configuration>
<goals>
@@ -890,6 +892,90 @@ under the License.
</testResources>
</build>
</profile>
+
+ <profile>
+ <id>noopworkflow</id>
+ <properties>
+ <javaagent />
+ </properties>
+ <build>
+ <defaultGoal>clean verify</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>remove-activiti</id>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <target>
+ <copy tofile="${project.build.directory}/classes/workflowContext.xml"
+ file="${basedir}/src/test/resources/noopworkflow/workflowContext.xml"
+ overwrite="true" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Strip Activiti-related entries from content.xml -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>xml-maven-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>transform</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <forceCreation>true</forceCreation>
+ <transformationSets>
+ <transformationSet>
+ <dir>${project.build.directory}/test-classes</dir>
+ <includes>
+ <include>content.xml</include>
+ </includes>
+ <outputDir>${project.build.directory}/test-classes/</outputDir>
+ <stylesheet>${basedir}/src/test/resources/noopworkflow/stripActivitiFromContent.xsl</stylesheet>
+ <outputProperties>
+ <outputProperty>
+ <name>indent</name>
+ <value>yes</value>
+ </outputProperty>
+ </outputProperties>
+ </transformationSet>
+ </transformationSets>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ <excludes>
+ <exclude>workflow.properties</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources/noopworkflow</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ </build>
+ </profile>
<profile>
<id>sqlserver-it</id>
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ActivitiWorkflowLoader.java Thu Oct 18 13:04:13 2012
@@ -27,16 +27,15 @@ import org.apache.syncope.core.workflow.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-@Component
-public class ActivitiWorkflowLoader {
+public class ActivitiWorkflowLoader implements WorkflowLoader {
private static final Logger LOG = LoggerFactory.getLogger(ActivitiWorkflowLoader.class);
@Autowired
private RepositoryService repositoryService;
+ @Override
public void load() {
List<ProcessDefinition> processes = repositoryService.createProcessDefinitionQuery().processDefinitionKey(
ActivitiUserWorkflowAdapter.WF_PROCESS_ID).list();
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/ContentLoader.java Thu Oct 18 13:04:13 2012
@@ -38,7 +38,7 @@ import org.springframework.transaction.a
/**
* If empty, load default content to Syncope database by reading from
- * <code>content.xml</code>.
+ * <code>ckasspath:/content.xml</code>.
*/
@Component
public class ContentLoader {
@@ -65,7 +65,8 @@ public class ContentLoader {
boolean existingData = false;
try {
final String queryContent = "SELECT * FROM " + SyncopeConf.class.getSimpleName();
- statement = conn.prepareStatement(queryContent, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
+ statement = conn.prepareStatement(
+ queryContent, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultSet = statement.executeQuery();
resultSet.last();
@@ -155,17 +156,20 @@ public class ContentLoader {
LOG.error("While creating indexes", e);
}
- try {
- statement = conn.prepareStatement("DELETE FROM ACT_GE_PROPERTY");
- statement.executeUpdate();
- } catch (SQLException e) {
- LOG.error("Error during ACT_GE_PROPERTY delete rows", e);
- } finally {
- if (statement != null) {
- try {
- statement.close();
- } catch (SQLException e) {
- LOG.error("Error closing statement of ACT_GE_PROPERTY delete rows", e);
+ // Can't test wfAdapter.getClass() because it is @Autowired
+ if (SpringContextInitializer.isActivitiConfigured()) {
+ try {
+ statement = conn.prepareStatement("DELETE FROM ACT_GE_PROPERTY");
+ statement.executeUpdate();
+ } catch (SQLException e) {
+ LOG.error("Error during ACT_GE_PROPERTY delete rows", e);
+ } finally {
+ if (statement != null) {
+ try {
+ statement.close();
+ } catch (SQLException e) {
+ LOG.error("Error closing statement of ACT_GE_PROPERTY delete rows", e);
+ }
}
}
}
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/JobInstanceLoader.java Thu Oct 18 13:04:13 2012
@@ -74,9 +74,9 @@ public class JobInstanceLoader {
private ConfDAO confDAO;
private DefaultListableBeanFactory getBeanFactory() {
- ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
+ ConfigurableApplicationContext ctx = ApplicationContextProvider.getApplicationContext();
- return (DefaultListableBeanFactory) context.getBeanFactory();
+ return (DefaultListableBeanFactory) ctx.getBeanFactory();
}
private static Long getIdFromJobName(final String name, final String pattern, final int prefixLength) {
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/init/SpringContextInitializer.java Thu Oct 18 13:04:13 2012
@@ -18,12 +18,21 @@
*/
package org.apache.syncope.core.init;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
import javax.servlet.ServletContext;
+import org.apache.syncope.core.workflow.ActivitiUserWorkflowAdapter;
+import org.apache.syncope.core.workflow.UserWorkflowAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.ServletContextAware;
@@ -33,6 +42,51 @@ import org.springframework.web.context.S
@Component
public class SpringContextInitializer implements ServletContextAware, BeanFactoryAware, InitializingBean {
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(SpringContextInitializer.class);
+
+ private static String wfAdapterClassName;
+
+ static {
+ try {
+ initWFAdapterClassName();
+ } catch (IOException e) {
+ LOG.error("Could not init wfAdapterClassName", e);
+ }
+ }
+
+ /**
+ * Read classpath:/workflow.properties in order to determine the configured workflow adapter class name.
+ *
+ * @throws IOException if anything goes wrong
+ */
+ public static void initWFAdapterClassName() throws IOException {
+ Properties props = new java.util.Properties();
+ InputStream propStream = null;
+ try {
+ propStream = ContentLoader.class.getResourceAsStream("/workflow.properties");
+ props.load(propStream);
+ wfAdapterClassName = props.getProperty("wfAdapter");
+ } catch (Exception e) {
+ LOG.error("Could not load workflow.properties", e);
+ } finally {
+ if (propStream != null) {
+ propStream.close();
+ }
+ }
+ }
+
+ /**
+ * Check if the configured user workflow adapter is Activiti's.
+ *
+ * @return whether Activiti is configured for workflow or not
+ */
+ public static boolean isActivitiConfigured() {
+ return wfAdapterClassName != null && wfAdapterClassName.equals(ActivitiUserWorkflowAdapter.class.getName());
+ }
+
@Autowired
private ConnInstanceLoader connInstanceLoader;
@@ -43,7 +97,7 @@ public class SpringContextInitializer im
private JobInstanceLoader jobInstanceLoader;
@Autowired
- private ActivitiWorkflowLoader activitiWorkflowLoader;
+ private UserWorkflowAdapter wfAdapter;
@Autowired
private LoggerLoader loggerLoader;
@@ -51,22 +105,29 @@ public class SpringContextInitializer im
@Autowired
private ImplementationClassNamesLoader classNamesLoader;
+ private DefaultListableBeanFactory beanFactory;
+
@Override
public void setServletContext(final ServletContext servletContext) {
}
@Override
public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
+ this.beanFactory = (DefaultListableBeanFactory) beanFactory;
}
@Override
public void afterPropertiesSet() throws Exception {
-
contentLoader.load();
connInstanceLoader.load();
jobInstanceLoader.load();
- activitiWorkflowLoader.load();
loggerLoader.load();
classNamesLoader.load();
+
+ if (wfAdapter.getLoaderClass() != null) {
+ final WorkflowLoader wfLoader = (WorkflowLoader) beanFactory.createBean(
+ wfAdapter.getLoaderClass(), AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
+ wfLoader.load();
+ }
}
}
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/AbstractUserWorkflowAdapter.java Thu Oct 18 13:04:13 2012
@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.apache.syncope.client.mod.UserMod;
import org.apache.syncope.client.to.UserTO;
+import org.apache.syncope.core.init.WorkflowLoader;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.persistence.dao.UserDAO;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
@@ -30,7 +31,7 @@ import org.apache.syncope.core.util.NotF
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
-@Transactional(rollbackFor = { Throwable.class })
+@Transactional(rollbackFor = {Throwable.class})
public abstract class AbstractUserWorkflowAdapter implements UserWorkflowAdapter {
@Autowired
@@ -40,6 +41,11 @@ public abstract class AbstractUserWorkfl
protected UserDAO userDAO;
@Override
+ public Class<? extends WorkflowLoader> getLoaderClass() {
+ return null;
+ }
+
+ @Override
public WorkflowResult<Entry<Long, Boolean>> create(final UserTO userTO)
throws UnauthorizedRoleException, WorkflowException {
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/ActivitiUserWorkflowAdapter.java Thu Oct 18 13:04:13 2012
@@ -59,6 +59,8 @@ import org.apache.syncope.client.to.User
import org.apache.syncope.client.to.WorkflowDefinitionTO;
import org.apache.syncope.client.to.WorkflowFormPropertyTO;
import org.apache.syncope.client.to.WorkflowFormTO;
+import org.apache.syncope.core.init.ActivitiWorkflowLoader;
+import org.apache.syncope.core.init.WorkflowLoader;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.propagation.PropagationByResource;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
@@ -129,6 +131,11 @@ public class ActivitiUserWorkflowAdapter
@Autowired
private RepositoryService repositoryService;
+ @Override
+ public Class<? extends WorkflowLoader> getLoaderClass() {
+ return ActivitiWorkflowLoader.class;
+ }
+
private void updateStatus(final SyncopeUser user) {
List<Task> tasks = taskService.createTaskQuery().processInstanceId(user.getWorkflowId()).list();
if (tasks.isEmpty() || tasks.size() > 1) {
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/NoOpUserWorkflowAdapter.java Thu Oct 18 13:04:13 2012
@@ -40,8 +40,8 @@ import org.springframework.transaction.a
@Transactional(rollbackFor = {Throwable.class})
public class NoOpUserWorkflowAdapter extends AbstractUserWorkflowAdapter {
- private static final List<String> TASKS = Arrays.asList(new String[]{
- "create", "activate", "update", "suspend", "reactivate", "delete"});
+ private static final List<String> TASKS =
+ Arrays.asList(new String[]{"create", "activate", "update", "suspend", "reactivate", "delete"});
public static final String ENABLED = "enabled";
@@ -66,16 +66,15 @@ public class NoOpUserWorkflowAdapter ext
}
String status;
- boolean propagate_enable;
-
+ boolean propagateEnable;
if (enabled == null) {
status = "created";
- propagate_enable = true;
+ propagateEnable = true;
} else {
status = enabled
? "active"
: "suspended";
- propagate_enable = enabled;
+ propagateEnable = enabled;
}
user.setStatus(status);
@@ -84,7 +83,7 @@ public class NoOpUserWorkflowAdapter ext
final PropagationByResource propByRes = new PropagationByResource();
propByRes.set(PropagationOperation.CREATE, user.getResourceNames());
- return new WorkflowResult<Map.Entry<Long, Boolean>>(new DefaultMapEntry(user.getId(), propagate_enable),
+ return new WorkflowResult<Map.Entry<Long, Boolean>>(new DefaultMapEntry(user.getId(), propagateEnable),
propByRes, "create");
}
Modified: incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java (original)
+++ incubator/syncope/trunk/core/src/main/java/org/apache/syncope/core/workflow/UserWorkflowAdapter.java Thu Oct 18 13:04:13 2012
@@ -24,6 +24,8 @@ import org.apache.syncope.client.mod.Use
import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.client.to.WorkflowDefinitionTO;
import org.apache.syncope.client.to.WorkflowFormTO;
+import org.apache.syncope.core.init.SpringContextInitializer;
+import org.apache.syncope.core.init.WorkflowLoader;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.rest.controller.UnauthorizedRoleException;
import org.apache.syncope.core.util.NotFoundException;
@@ -34,6 +36,15 @@ import org.apache.syncope.core.util.NotF
public interface UserWorkflowAdapter {
/**
+ * Give the class to be instantiated and invoked by SpringContextInitializer for loading anything needed by this
+ * adapter.
+ *
+ * @return null if no init is needed or the WorkflowLoader class for handling initialization
+ * @see SpringContextInitializer
+ */
+ Class<? extends WorkflowLoader> getLoaderClass();
+
+ /**
* Create an user.
*
* @param userTO user to be created and wether to propagate it as active
Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/AbstractTest.java Thu Oct 18 13:04:13 2012
@@ -21,12 +21,13 @@ package org.apache.syncope.core;
import static org.junit.Assert.*;
import java.io.InputStream;
+import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
-import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,8 +35,8 @@ import org.springframework.test.context.
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:syncopeContext.xml", "classpath:persistenceContext.xml",
- "classpath:schedulingContext.xml", "classpath:workflowContext.xml" })
+@ContextConfiguration(locations = {"classpath:syncopeContext.xml", "classpath:persistenceContext.xml",
+ "classpath:schedulingContext.xml", "classpath:workflowContext.xml"})
public abstract class AbstractTest {
/**
@@ -76,16 +77,21 @@ public abstract class AbstractTest {
}
}
- @Before
- public void setUpIdentityConnectorsBundles() {
+ @BeforeClass
+ public static void setUpIdentityConnectorsBundles() throws IOException {
Properties props = new java.util.Properties();
+ InputStream propStream = null;
try {
- InputStream propStream = getClass().getResourceAsStream("/bundles.properties");
+ propStream = AbstractTest.class.getResourceAsStream("/bundles.properties");
props.load(propStream);
connidSoapVersion = props.getProperty("connid.soap.version");
bundlesDirectory = props.getProperty("bundles.directory");
} catch (Exception e) {
LOG.error("Could not load bundles.properties", e);
+ } finally {
+ if (propStream != null) {
+ propStream.close();
+ }
}
assertNotNull(connidSoapVersion);
assertNotNull(bundlesDirectory);
Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/AbstractTest.java Thu Oct 18 13:04:13 2012
@@ -21,6 +21,7 @@ package org.apache.syncope.core.rest;
import javax.sql.DataSource;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -29,7 +30,6 @@ import org.springframework.beans.factory
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.RestTemplate;
-import org.apache.syncope.client.http.PreemptiveAuthHttpRequestFactory;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:restClientContext.xml", "classpath:testJDBCContext.xml"})
Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Thu Oct 18 13:04:13 2012
@@ -39,6 +39,7 @@ import org.apache.syncope.client.to.Sync
import org.apache.syncope.client.to.TaskTO;
import org.apache.syncope.client.to.UserTO;
import org.apache.syncope.core.scheduling.SyncJob;
+import org.apache.syncope.core.init.SpringContextInitializer;
import org.apache.syncope.types.PropagationTaskExecStatus;
import org.apache.syncope.core.scheduling.TestSyncJobActions;
import org.apache.syncope.types.IntMappingType;
@@ -317,7 +318,7 @@ public class TaskTestITCase extends Abst
assertNotNull(userTO);
assertEquals("test9", userTO.getUsername());
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
assertEquals("test9@syncope.apache.org", userTO.getAttributeMap().get("email").getValues().get(0));
assertEquals("test9@syncope.apache.org", userTO.getAttributeMap().get("userId").getValues().get(0));
assertTrue(Integer.valueOf(userTO.getAttributeMap().get("fullname").getValues().get(0)) <= 10);
Modified: incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java
URL: http://svn.apache.org/viewvc/incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java?rev=1399647&r1=1399646&r2=1399647&view=diff
==============================================================================
--- incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java (original)
+++ incubator/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/UserTestITCase.java Thu Oct 18 13:04:13 2012
@@ -60,10 +60,12 @@ import org.apache.syncope.client.to.Work
import org.apache.syncope.client.util.AttributableOperations;
import org.apache.syncope.client.validation.SyncopeClientCompositeErrorException;
import org.apache.syncope.client.validation.SyncopeClientException;
+import org.apache.syncope.core.init.SpringContextInitializer;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.types.CipherAlgorithm;
import org.apache.syncope.types.PropagationTaskExecStatus;
import org.apache.syncope.types.SyncopeClientExceptionType;
+import org.junit.Assume;
import org.springframework.util.StringUtils;
public class UserTestITCase extends AbstractTest {
@@ -665,6 +667,8 @@ public class UserTestITCase extends Abst
@Test
public void createWithReject() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
UserTO userTO = getSampleTO("createWithReject@syncope.apache.org");
// User with role 9 are defined in workflow as subject to approval
@@ -727,6 +731,8 @@ public class UserTestITCase extends Abst
@Test
public void createWithApproval() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
UserTO userTO = getSampleTO("createWithApproval@syncope.apache.org");
@@ -1330,6 +1336,8 @@ public class UserTestITCase extends Abst
@Test
public void createActivate() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
UserTO userTO = getSampleTO("createActivate@syncope.apache.org");
MembershipTO membershipTO = new MembershipTO();
@@ -1356,6 +1364,8 @@ public class UserTestITCase extends Abst
@Test
public void createActivateByUsername() {
+ Assume.assumeTrue(SpringContextInitializer.isActivitiConfigured());
+
UserTO userTO = getSampleTO("createActivateByUsername@syncope.apache.org");
MembershipTO membershipTO = new MembershipTO();
@@ -1392,7 +1402,7 @@ public class UserTestITCase extends Abst
userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
userTO = restTemplate.getForObject(BASE_URL + "user/suspend/" + userTO.getId(), UserTO.class);
@@ -1416,7 +1426,7 @@ public class UserTestITCase extends Abst
userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
userTO = restTemplate.getForObject(
BASE_URL + "user/suspendByUsername/{username}.json", UserTO.class, userTO.getUsername());
@@ -1453,7 +1463,7 @@ public class UserTestITCase extends Abst
userTO = restTemplate.postForObject(BASE_URL + "user/create", userTO, UserTO.class);
assertNotNull(userTO);
- assertEquals("active", userTO.getStatus());
+ assertEquals(SpringContextInitializer.isActivitiConfigured() ? "active" : "created", userTO.getStatus());
String query = "?resourceNames=" + dbTable.getName() + "&resourceNames=" + ldap.getName()
+ "&performLocally=true"; // check also performLocally