[SYNCOPE-652] Upgrade Spring to 4.2.0.RELEASE + various cleanup
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/88061761 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/88061761 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/88061761 Branch: refs/heads/SYNCOPE-156 Commit: 88061761ea78bfe822f653c899a4ad9c4f4e3493 Parents: 4b2dc4d Author: Francesco Chicchiriccò <[email protected]> Authored: Mon Aug 17 13:30:27 2015 +0200 Committer: Francesco Chicchiriccò <[email protected]> Committed: Mon Aug 17 13:30:27 2015 +0200 ---------------------------------------------------------------------- .travis.yml | 6 +- .../cli/commands/ConfigurationCommand.java | 8 +- .../console/rest/ConfigurationRestClient.java | 10 +- .../syncope/common/lib/mod/StatusMod.java | 2 +- .../apache/syncope/common/lib/to/AttrTO.java | 2 + .../apache/syncope/common/lib/to/LoggerTO.java | 2 +- .../rest/api/service/ConfigurationService.java | 25 +- core/logic/pom.xml | 86 +-- .../syncope/core/logic/ConfigurationLogic.java | 16 +- .../apache/syncope/core/logic/TaskLogic.java | 4 +- .../core/logic/init/JobInstanceLoaderImpl.java | 85 +-- .../logic/notification/NotificationJob.java | 21 +- .../notification/NotificationJobDelegate.java | 5 +- .../syncope/core/logic/report/ReportJob.java | 22 +- .../apache/syncope/core/logic/AbstractTest.java | 40 -- .../syncope/core/logic/NotificationTest.java | 659 ------------------- core/logic/src/test/resources/logicTest.xml | 59 -- .../core/misc/security/AuthContextUtils.java | 8 +- .../misc/spring/ApplicationContextProvider.java | 11 + .../spring/DomainTransactionInterceptor.java | 70 ++ .../spring/DomainTransactionInterceptor.java | 70 -- .../jpa/spring/SpringComponentReplacer.java | 42 -- .../core/persistence/jpa/AbstractTest.java | 2 - .../persistence/jpa/inner/AnyObjectTest.java | 2 +- .../persistence/jpa/inner/AnySearchTest.java | 2 +- .../persistence/jpa/inner/AnyTypeClassTest.java | 2 +- .../core/persistence/jpa/inner/AnyTypeTest.java | 2 +- .../core/persistence/jpa/inner/ConfTest.java | 2 +- .../persistence/jpa/inner/ConnInstanceTest.java | 2 +- .../core/persistence/jpa/inner/DerAttrTest.java | 2 +- .../persistence/jpa/inner/DerSchemaTest.java | 2 +- .../core/persistence/jpa/inner/DomainTest.java | 2 +- .../core/persistence/jpa/inner/GroupTest.java | 2 +- .../persistence/jpa/inner/MultitenancyTest.java | 6 +- .../persistence/jpa/inner/NotificationTest.java | 2 +- .../persistence/jpa/inner/PlainAttrTest.java | 2 +- .../persistence/jpa/inner/PlainSchemaTest.java | 2 +- .../core/persistence/jpa/inner/PolicyTest.java | 2 +- .../core/persistence/jpa/inner/RealmTest.java | 2 +- .../jpa/inner/RelationshipTypeTest.java | 2 +- .../core/persistence/jpa/inner/ReportTest.java | 2 +- .../persistence/jpa/inner/ResourceTest.java | 2 +- .../core/persistence/jpa/inner/RoleTest.java | 2 +- .../jpa/inner/SecurityQuestionTest.java | 2 +- .../persistence/jpa/inner/TaskExecTest.java | 2 +- .../core/persistence/jpa/inner/TaskTest.java | 2 +- .../core/persistence/jpa/inner/UserTest.java | 2 +- .../core/persistence/jpa/inner/VirAttrTest.java | 2 +- .../persistence/jpa/inner/VirSchemaTest.java | 2 +- .../persistence/jpa/outer/AnySearchTest.java | 2 +- .../persistence/jpa/outer/AnyTypeClassTest.java | 2 +- .../core/persistence/jpa/outer/AnyTypeTest.java | 2 +- .../persistence/jpa/outer/ConnInstanceTest.java | 2 +- .../persistence/jpa/outer/DerSchemaTest.java | 2 +- .../core/persistence/jpa/outer/GroupTest.java | 3 +- .../persistence/jpa/outer/PlainAttrTest.java | 2 +- .../persistence/jpa/outer/PlainSchemaTest.java | 2 +- .../core/persistence/jpa/outer/RealmTest.java | 2 +- .../core/persistence/jpa/outer/ReportTest.java | 2 +- .../persistence/jpa/outer/ResourceTest.java | 3 +- .../core/persistence/jpa/outer/RoleTest.java | 2 +- .../jpa/outer/SecurityQuestionTest.java | 2 +- .../core/persistence/jpa/outer/TaskTest.java | 2 +- .../core/persistence/jpa/outer/UserTest.java | 2 +- .../test/resources/domains/MasterContent.xml | 4 +- .../src/test/resources/domains/TwoContent.xml | 14 - .../provisioning/java/ConnectorManager.java | 21 +- .../core/provisioning/java/job/TaskJob.java | 32 +- .../notification/NotificationManagerImpl.java | 10 +- .../core/provisioning/java/AbstractTest.java | 2 - .../provisioning/java/ConnectorManagerTest.java | 2 +- .../core/provisioning/java/MappingTest.java | 2 +- .../java/ResourceDataBinderTest.java | 2 +- .../cxf/service/ConfigurationServiceImpl.java | 11 +- fit/core-reference/pom.xml | 5 + .../src/main/resources/mail.properties | 25 + .../fit/core/reference/AbstractTaskITCase.java | 37 +- .../fit/core/reference/ConfigurationITCase.java | 20 +- .../fit/core/reference/MultitenancyITCase.java | 2 +- .../core/reference/NotificationTaskITCase.java | 317 ++++++++- .../syncope/fit/core/reference/UserITCase.java | 27 +- .../fit/core/reference/UserSelfITCase.java | 9 +- pom.xml | 2 +- 83 files changed, 663 insertions(+), 1224 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index 4ec5ae7..b46adc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,11 +20,11 @@ language: java jdk: - openjdk7 # default install is mvn install --quiet -DskipTests=true -install: mvn --show-version --quiet -P all,skipTests +install: mvn --show-version --quiet -T 1C -P all,skipTests #invoker.streamLogs: we cannot access to log files through Travis web ui, so display everything in the console script: - sudo rm /etc/mavenrc - - export MAVEN_OPTS="-Xmx2469m -XX:MaxPermSize=512m" - - mvn --show-version --quiet clean install -Dinvoker.streamLogs=true + - export MAVEN_OPTS="-Xmx2469m -XX:MaxPermSize=512m -XX:+TieredCompilation -XX:TieredStopAtLevel=1" + - mvn --show-version --quiet -T 1C clean install -Dinvoker.streamLogs=true notifications: webhooks: http://rovere.tirasa.net/cgi-bin/travis.cgi http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/client/cli/src/main/java/org/apache/syncope/client/cli/commands/ConfigurationCommand.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/ConfigurationCommand.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/ConfigurationCommand.java index 54eea17..70c532d 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/ConfigurationCommand.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/ConfigurationCommand.java @@ -113,7 +113,7 @@ public class ConfigurationCommand extends AbstractCommand { } else if (StringUtils.isNotBlank(confNameToRead)) { LOG.debug("- configuration read {} command", confNameToRead); try { - final AttrTO attrTO = configurationService.read(confNameToRead); + final AttrTO attrTO = configurationService.get(confNameToRead); System.out.println(" - Conf " + attrTO.getSchema() + " has value(s) " + attrTO.getValues() + " - readonly: " + attrTO.isReadonly()); } catch (final SyncopeClientException ex) { @@ -123,10 +123,10 @@ public class ConfigurationCommand extends AbstractCommand { LOG.debug("- configuration update command with params {}", updateConf); try { for (final Map.Entry<String, String> entrySet : updateConf.entrySet()) { - final AttrTO attrTO = configurationService.read(entrySet.getKey()); + final AttrTO attrTO = configurationService.get(entrySet.getKey()); attrTO.getValues().clear(); attrTO.getValues().add(entrySet.getValue()); - configurationService.set(entrySet.getKey(), attrTO); + configurationService.set(attrTO); System.out.println(" - Conf " + attrTO.getSchema() + " has value(s) " + attrTO.getValues() + " - readonly: " + attrTO.isReadonly()); } @@ -140,7 +140,7 @@ public class ConfigurationCommand extends AbstractCommand { final AttrTO attrTO = new AttrTO(); attrTO.setSchema(entrySet.getKey()); attrTO.getValues().add(entrySet.getValue()); - configurationService.set(entrySet.getKey(), attrTO); + configurationService.set(attrTO); System.out.println(" - Conf " + attrTO.getSchema() + " created with value(s) " + attrTO.getValues() + " - readonly: " + attrTO.isReadonly()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/client/console/src/main/java/org/apache/syncope/client/console/rest/ConfigurationRestClient.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/rest/ConfigurationRestClient.java b/client/console/src/main/java/org/apache/syncope/client/console/rest/ConfigurationRestClient.java index 36b0d1c..ade9408 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/rest/ConfigurationRestClient.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/rest/ConfigurationRestClient.java @@ -53,9 +53,9 @@ public class ConfigurationRestClient extends BaseRestClient { return conf; } - public AttrTO read(final String key) { + public AttrTO get(final String key) { try { - return getService(ConfigurationService.class).read(key); + return getService(ConfigurationService.class).get(key); } catch (SyncopeClientException e) { LOG.error("While reading a configuration schema", e); } @@ -67,7 +67,7 @@ public class ConfigurationRestClient extends BaseRestClient { return null; } - AttrTO attrLayout = read(type.getConfKey()); + AttrTO attrLayout = get(type.getConfKey()); if (attrLayout == null) { attrLayout = new AttrTO(); attrLayout.setSchema(type.getConfKey()); @@ -79,8 +79,8 @@ public class ConfigurationRestClient extends BaseRestClient { return attrLayout; } - public void set(final AttrTO attributeTO) { - getService(ConfigurationService.class).set(attributeTO.getSchema(), attributeTO); + public void set(final AttrTO attrTO) { + getService(ConfigurationService.class).set(attrTO); } public void delete(final String key) { http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/common/lib/src/main/java/org/apache/syncope/common/lib/mod/StatusMod.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/mod/StatusMod.java b/common/lib/src/main/java/org/apache/syncope/common/lib/mod/StatusMod.java index f989ecf..e3fc901 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/mod/StatusMod.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/mod/StatusMod.java @@ -67,11 +67,11 @@ public class StatusMod extends AbstractBaseBean { */ private final List<String> resourceNames = new ArrayList<>(); - @PathParam("key") public long getKey() { return key; } + @PathParam("key") public void setKey(final long key) { this.key = key; } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java index cf385b4..c3b468c 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/AttrTO.java @@ -22,6 +22,7 @@ import org.apache.syncope.common.lib.AbstractBaseBean; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.ArrayList; import java.util.List; +import javax.ws.rs.PathParam; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlRootElement; @@ -58,6 +59,7 @@ public class AttrTO extends AbstractBaseBean { /** * @param schema name to be set */ + @PathParam("schema") public void setSchema(final String schema) { this.schema = schema; http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/common/lib/src/main/java/org/apache/syncope/common/lib/to/LoggerTO.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/to/LoggerTO.java b/common/lib/src/main/java/org/apache/syncope/common/lib/to/LoggerTO.java index 6e1ce1d..0dfa8b5 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/to/LoggerTO.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/to/LoggerTO.java @@ -42,11 +42,11 @@ public class LoggerTO extends AbstractBaseBean { this.level = level; } - @PathParam("key") public String getKey() { return key; } + @PathParam("key") public void setKey(final String key) { this.key = key; } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConfigurationService.java ---------------------------------------------------------------------- diff --git a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConfigurationService.java b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConfigurationService.java index 3fa5f8a..875ebc5 100644 --- a/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConfigurationService.java +++ b/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/service/ConfigurationService.java @@ -56,34 +56,33 @@ public interface ConfigurationService extends JAXRSService { ConfTO list(); /** - * Returns configuration parameter with matching key. + * Returns configuration parameter with matching schema. * - * @param key identifier of configuration to be read - * @return configuration parameter with matching key + * @param schema identifier of configuration to be read + * @return configuration parameter with matching schema */ @GET - @Path("{key}") + @Path("{schema}") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - AttrTO read(@NotNull @PathParam("key") String key); + AttrTO get(@NotNull @PathParam("schema") String schema); /** - * Creates / updates the configuration parameter with the given key. + * Creates / updates the configuration parameter with the given schema. * - * @param key parameter key * @param value parameter value */ @PUT - @Path("{key}") + @Path("{schema}") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - void set(@NotNull @PathParam("key") String key, @NotNull AttrTO value); + void set(@NotNull AttrTO value); /** - * Deletes the configuration parameter with matching key. + * Deletes the configuration parameter with matching schema. * - * @param key configuration parameter key + * @param schema configuration parameter schema */ @DELETE - @Path("{key}") + @Path("{schema}") @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - void delete(@NotNull @PathParam("key") String key); + void delete(@NotNull @PathParam("schema") String schema); } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/pom.xml ---------------------------------------------------------------------- diff --git a/core/logic/pom.xml b/core/logic/pom.xml index d652f3e..7b25e9b 100644 --- a/core/logic/pom.xml +++ b/core/logic/pom.xml @@ -93,51 +93,6 @@ under the License. <artifactId>syncope-core-provisioning-java</artifactId> <version>${project.version}</version> </dependency> - - <!-- TEST --> - <dependency> - <groupId>com.icegreen</groupId> - <artifactId>greenmail</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.syncope.core</groupId> - <artifactId>syncope-core-workflow-java</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>javax.el</groupId> - <artifactId>javax.el-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.syncope.core</groupId> - <artifactId>syncope-core-persistence-jpa</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <version>${slf4j.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> </dependencies> <build> @@ -147,49 +102,10 @@ under the License. <filtering>true</filtering> </resource> </resources> - <testResources> - <testResource> - <directory>${basedir}/src/test/resources</directory> - <filtering>true</filtering> - </testResource> - <testResource> - <directory>${basedir}/../persistence-jpa/src/main/resources</directory> - <includes> - <include>persistence.properties</include> - </includes> - <filtering>true</filtering> - </testResource> - <testResource> - <directory>${basedir}/../persistence-jpa/src/test/resources</directory> - <filtering>true</filtering> - </testResource> - <testResource> - <directory>${basedir}/../provisioning-java/src/main/resources</directory> - <includes> - <include>connid.properties</include> - </includes> - <filtering>true</filtering> - </testResource> - </testResources> - + <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <inherited>true</inherited> - <executions> - <execution> - <id>set-bundles</id> - <phase>process-test-resources</phase> - <goals> - <goal>copy</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> </plugin> </plugins> http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java index 1598498..b36c4ea 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/ConfigurationLogic.java @@ -60,8 +60,8 @@ public class ConfigurationLogic extends AbstractTransactionalLogic<ConfTO> { private GroupWorkflowAdapter gwfAdapter; @PreAuthorize("hasRole('" + Entitlement.CONFIGURATION_DELETE + "')") - public void delete(final String key) { - confDAO.delete(key); + public void delete(final String schema) { + confDAO.delete(schema); } @PreAuthorize("hasRole('" + Entitlement.CONFIGURATION_LIST + "')") @@ -70,18 +70,18 @@ public class ConfigurationLogic extends AbstractTransactionalLogic<ConfTO> { } @PreAuthorize("isAuthenticated()") - public AttrTO read(final String key) { + public AttrTO get(final String schema) { AttrTO result; - CPlainAttr conf = confDAO.find(key); + CPlainAttr conf = confDAO.find(schema); if (conf == null) { - PlainSchema schema = plainSchemaDAO.find(key); - if (schema == null) { - throw new NotFoundException("Configuration key " + key); + PlainSchema plainSchema = plainSchemaDAO.find(schema); + if (plainSchema == null) { + throw new NotFoundException("Configuration schema " + schema); } result = new AttrTO(); - result.setSchema(key); + result.setSchema(schema); } else { result = binder.getAttrTO(conf); } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/main/java/org/apache/syncope/core/logic/TaskLogic.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/TaskLogic.java b/core/logic/src/main/java/org/apache/syncope/core/logic/TaskLogic.java index 9c119f3..9c436ac 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/TaskLogic.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/TaskLogic.java @@ -196,12 +196,12 @@ public class TaskLogic extends AbstractJobLogic<AbstractTaskTO> { TaskExecTO result = null; switch (taskUtils.getType()) { case PROPAGATION: - final TaskExec propExec = taskExecutor.execute((PropagationTask) task); + TaskExec propExec = taskExecutor.execute((PropagationTask) task); result = binder.getTaskExecTO(propExec); break; case NOTIFICATION: - final TaskExec notExec = notificationJobDelegate.executeSingle((NotificationTask) task); + TaskExec notExec = notificationJobDelegate.executeSingle((NotificationTask) task); result = binder.getTaskExecTO(notExec); break; http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java b/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java index 3e7e90f..33cb920 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/init/JobInstanceLoaderImpl.java @@ -25,6 +25,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; import org.apache.syncope.common.lib.SyncopeConstants; import org.apache.syncope.common.lib.types.TaskType; import org.apache.syncope.core.persistence.api.dao.ConfDAO; @@ -229,59 +231,66 @@ public class JobInstanceLoaderImpl implements JobInstanceLoader, SyncopeLoader { @Transactional @Override public void load() { - AuthContextUtils.setFakeAuth(SyncopeConstants.MASTER_DOMAIN); - String notificationJobCronExpression = StringUtils.EMPTY; - long interruptMaxRetries = 1; - try { - CPlainAttr notificationJobCronExp = - confDAO.find("notificationjob.cronExpression", NotificationJob.DEFAULT_CRON_EXP); - if (!notificationJobCronExp.getValuesAsStrings().isEmpty()) { - notificationJobCronExpression = notificationJobCronExp.getValuesAsStrings().get(0); - } + final Pair<String, Long> notificationConf = AuthContextUtils.execWithAuthContext(SyncopeConstants.MASTER_DOMAIN, + new AuthContextUtils.Executable<Pair<String, Long>>() { - interruptMaxRetries = confDAO.find("tasks.interruptMaxRetries", "1").getValues().get(0).getLongValue(); - } finally { - AuthContextUtils.clearFakeAuth(); - } + @Override + public Pair<String, Long> exec() { + String notificationJobCronExpression = StringUtils.EMPTY; - for (String domain : domainsHolder.getDomains().keySet()) { - AuthContextUtils.setFakeAuth(domain); + CPlainAttr notificationJobCronExp = + confDAO.find("notificationjob.cronExpression", NotificationJob.DEFAULT_CRON_EXP); + if (!notificationJobCronExp.getValuesAsStrings().isEmpty()) { + notificationJobCronExpression = notificationJobCronExp.getValuesAsStrings().get(0); + } - try { - // 1. jobs for SchedTasks - Set<SchedTask> tasks = new HashSet<>(taskDAO.<SchedTask>findAll(TaskType.SCHEDULED)); - tasks.addAll(taskDAO.<SyncTask>findAll(TaskType.SYNCHRONIZATION)); - tasks.addAll(taskDAO.<PushTask>findAll(TaskType.PUSH)); - for (SchedTask task : tasks) { - try { - registerJob(task, interruptMaxRetries); - } catch (Exception e) { - LOG.error("While loading job instance for task " + task.getKey(), e); + long interruptMaxRetries = confDAO.find("tasks.interruptMaxRetries", "1").getValues().get(0). + getLongValue(); + + return ImmutablePair.of(notificationJobCronExpression, interruptMaxRetries); + } + }); + + for (String domain : domainsHolder.getDomains().keySet()) { + AuthContextUtils.execWithAuthContext(domain, new AuthContextUtils.Executable<Void>() { + + @Override + public Void exec() { + // 1. jobs for SchedTasks + Set<SchedTask> tasks = new HashSet<>(taskDAO.<SchedTask>findAll(TaskType.SCHEDULED)); + tasks.addAll(taskDAO.<SyncTask>findAll(TaskType.SYNCHRONIZATION)); + tasks.addAll(taskDAO.<PushTask>findAll(TaskType.PUSH)); + for (SchedTask task : tasks) { + try { + registerJob(task, notificationConf.getRight()); + } catch (Exception e) { + LOG.error("While loading job instance for task " + task.getKey(), e); + } } - } - // 2. ReportJobs - for (Report report : reportDAO.findAll()) { - try { - registerJob(report); - } catch (Exception e) { - LOG.error("While loading job instance for report " + report.getName(), e); + // 2. ReportJobs + for (Report report : reportDAO.findAll()) { + try { + registerJob(report); + } catch (Exception e) { + LOG.error("While loading job instance for report " + report.getName(), e); + } } + + return null; } - } finally { - AuthContextUtils.clearFakeAuth(); - } + }); } // 3. NotificationJob - if (StringUtils.isBlank(notificationJobCronExpression)) { + if (StringUtils.isBlank(notificationConf.getLeft())) { LOG.debug("Empty value provided for NotificationJob's cron, not registering anything on Quartz"); } else { LOG.debug("NotificationJob's cron expression: {} - registering Quartz job and trigger", - notificationJobCronExpression); + notificationConf.getLeft()); try { - registerNotificationJob(notificationJobCronExpression); + registerNotificationJob(notificationConf.getLeft()); } catch (Exception e) { LOG.error("While loading NotificationJob instance", e); } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJob.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJob.java b/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJob.java index a0f21f3..adba78d 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJob.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJob.java @@ -60,13 +60,22 @@ public class NotificationJob implements Job { LOG.debug("Waking up..."); for (String domain : domainsHolder.getDomains().keySet()) { - AuthContextUtils.setFakeAuth(domain); try { - delegate.execute(); - } catch (Exception e) { - throw new JobExecutionException(e); - } finally { - AuthContextUtils.clearFakeAuth(); + AuthContextUtils.execWithAuthContext(domain, new AuthContextUtils.Executable<Void>() { + + @Override + public Void exec() { + try { + delegate.execute(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + return null; + } + }); + } catch (RuntimeException e) { + throw new JobExecutionException(e.getCause()); } } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJobDelegate.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJobDelegate.java b/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJobDelegate.java index aaebe77..763bab5 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJobDelegate.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/notification/NotificationJobDelegate.java @@ -187,8 +187,9 @@ public class NotificationJobDelegate { if (hasToBeRegistered(execution)) { execution = notificationManager.storeExec(execution); - if (retryPossible && (NotificationJob.Status.valueOf(execution.getStatus()) - == NotificationJob.Status.NOT_SENT)) { + if (retryPossible + && (NotificationJob.Status.valueOf(execution.getStatus()) == NotificationJob.Status.NOT_SENT)) { + handleRetries(execution); } } else { http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJob.java ---------------------------------------------------------------------- diff --git a/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJob.java b/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJob.java index 8e5af91..686953c 100644 --- a/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJob.java +++ b/core/logic/src/main/java/org/apache/syncope/core/logic/report/ReportJob.java @@ -51,13 +51,23 @@ public class ReportJob implements Job { @Override public void execute(final JobExecutionContext context) throws JobExecutionException { - AuthContextUtils.setFakeAuth(context.getMergedJobDataMap().getString(JobInstanceLoader.DOMAIN)); try { - delegate.execute(reportKey); - } catch (Exception e) { - throw new JobExecutionException(e); - } finally { - AuthContextUtils.clearFakeAuth(); + AuthContextUtils.execWithAuthContext(context.getMergedJobDataMap().getString(JobInstanceLoader.DOMAIN), + new AuthContextUtils.Executable<Void>() { + + @Override + public Void exec() { + try { + delegate.execute(reportKey); + } catch (Exception e) { + throw new RuntimeException(e); + } + + return null; + } + }); + } catch (RuntimeException e) { + throw new JobExecutionException(e.getCause()); } } } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/test/java/org/apache/syncope/core/logic/AbstractTest.java ---------------------------------------------------------------------- diff --git a/core/logic/src/test/java/org/apache/syncope/core/logic/AbstractTest.java b/core/logic/src/test/java/org/apache/syncope/core/logic/AbstractTest.java deleted file mode 100644 index 32ae367..0000000 --- a/core/logic/src/test/java/org/apache/syncope/core/logic/AbstractTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.logic; - -import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { - "classpath:provisioningContext.xml", - "classpath:logicContext.xml", - "classpath:workflowContext.xml", - "classpath:logicTest.xml" -}) -@TransactionConfiguration(transactionManager = "MasterTransactionManager") -public abstract class AbstractTest { - - protected static final Logger LOG = LoggerFactory.getLogger(AbstractTest.class); - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/test/java/org/apache/syncope/core/logic/NotificationTest.java ---------------------------------------------------------------------- diff --git a/core/logic/src/test/java/org/apache/syncope/core/logic/NotificationTest.java b/core/logic/src/test/java/org/apache/syncope/core/logic/NotificationTest.java deleted file mode 100644 index 6c208a2..0000000 --- a/core/logic/src/test/java/org/apache/syncope/core/logic/NotificationTest.java +++ /dev/null @@ -1,659 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.logic; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import com.icegreen.greenmail.util.GreenMail; -import com.icegreen.greenmail.util.ServerSetup; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Random; -import java.util.Set; -import java.util.UUID; -import javax.annotation.Resource; -import javax.mail.Flags.Flag; -import javax.mail.Folder; -import javax.mail.Message; -import javax.mail.Session; -import javax.mail.Store; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.Transformer; -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.lib.SyncopeConstants; -import org.apache.syncope.common.lib.search.GroupFiqlSearchConditionBuilder; -import org.apache.syncope.common.lib.search.UserFiqlSearchConditionBuilder; -import org.apache.syncope.common.lib.to.AttrTO; -import org.apache.syncope.common.lib.to.MembershipTO; -import org.apache.syncope.common.lib.to.NotificationTaskTO; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.syncope.common.lib.types.Entitlement; -import org.apache.syncope.common.lib.types.IntMappingType; -import org.apache.syncope.common.lib.types.TaskType; -import org.apache.syncope.common.lib.types.TraceLevel; -import org.apache.syncope.core.persistence.api.dao.ConfDAO; -import org.apache.syncope.core.persistence.api.dao.NotificationDAO; -import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO; -import org.apache.syncope.core.persistence.api.dao.TaskDAO; -import org.apache.syncope.core.persistence.api.entity.EntityFactory; -import org.apache.syncope.core.persistence.api.entity.Notification; -import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttr; -import org.apache.syncope.core.persistence.api.entity.task.NotificationTask; -import org.apache.syncope.core.logic.notification.NotificationJob; -import org.apache.syncope.core.misc.security.SyncopeGrantedAuthority; -import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO; -import org.apache.syncope.core.persistence.api.entity.AnyAbout; -import org.apache.syncope.core.persistence.api.entity.conf.CPlainAttrValue; -import org.apache.syncope.core.provisioning.api.notification.NotificationManager; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.mail.javamail.JavaMailSenderImpl; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.transaction.annotation.Transactional; - -@Transactional -public class NotificationTest extends AbstractTest { - - private static final String SMTP_HOST = "localhost"; - - private static final int SMTP_PORT = 2525; - - private static final String POP3_HOST = "localhost"; - - private static final int POP3_PORT = 1110; - - private static final String MAIL_ADDRESS = "[email protected]"; - - private static final String MAIL_PASSWORD = "password"; - - private static GreenMail greenMail; - - @Resource(name = "adminUser") - private String adminUser; - - @Autowired - private NotificationDAO notificationDAO; - - @Autowired - private AnyTypeDAO anyTypeDAO; - - @Autowired - private TaskDAO taskDAO; - - @Autowired - private PlainSchemaDAO plainSchemaDAO; - - @Autowired - private ConfDAO confDAO; - - @Autowired - private UserLogic userLogic; - - @Autowired - private GroupLogic groupLogic; - - @Autowired - private TaskLogic taskLogic; - - @Autowired - private NotificationJob notificationJob; - - @Autowired - private NotificationManager notificationManager; - - @Autowired - private JavaMailSender mailSender; - - @Autowired - private EntityFactory entityFactory; - - @BeforeClass - public static void startGreenMail() { - ServerSetup[] config = new ServerSetup[2]; - config[0] = new ServerSetup(SMTP_PORT, SMTP_HOST, ServerSetup.PROTOCOL_SMTP); - config[1] = new ServerSetup(POP3_PORT, POP3_HOST, ServerSetup.PROTOCOL_POP3); - greenMail = new GreenMail(config); - greenMail.setUser(MAIL_ADDRESS, MAIL_PASSWORD); - greenMail.start(); - } - - @AfterClass - public static void stopGreenMail() { - if (greenMail != null) { - greenMail.stop(); - } - } - - private static UserTO getUniqueSampleTO(final String email) { - return getSampleTO(UUID.randomUUID().toString().substring(0, 8) + email); - } - - private static AttrTO attributeTO(final String schema, final String value) { - AttrTO attr = new AttrTO(); - attr.setSchema(schema); - attr.getValues().add(value); - return attr; - } - - private static UserTO getSampleTO(final String email) { - String uid = UUID.randomUUID().toString().substring(0, 8) + email; - UserTO userTO = new UserTO(); - userTO.setPassword("password123"); - userTO.setUsername(uid); - userTO.setRealm("/even/two"); - - userTO.getPlainAttrs().add(attributeTO("fullname", uid)); - userTO.getPlainAttrs().add(attributeTO("firstname", uid)); - userTO.getPlainAttrs().add(attributeTO("surname", "surname")); - userTO.getPlainAttrs().add(attributeTO("type", "a type")); - userTO.getPlainAttrs().add(attributeTO("userId", uid)); - userTO.getPlainAttrs().add(attributeTO("email", email)); - userTO.getPlainAttrs().add(attributeTO("loginDate", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))); - userTO.getDerAttrs().add(attributeTO("cn", null)); - userTO.getVirAttrs().add(attributeTO("virtualdata", "virtualvalue")); - return userTO; - } - - @Before - public void setupSecurity() { - List<GrantedAuthority> authorities = CollectionUtils.collect(Entitlement.values(), - new Transformer<String, GrantedAuthority>() { - - @Override - public GrantedAuthority transform(final String entitlement) { - return new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM); - } - }, new ArrayList<GrantedAuthority>()); - - UserDetails userDetails = new User(adminUser, "FAKE_PASSWORD", authorities); - Authentication authentication = new TestingAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities); - SecurityContextHolder.getContext().setAuthentication(authentication); - } - - @Before - public void setupSMTP() throws Exception { - JavaMailSenderImpl sender = (JavaMailSenderImpl) mailSender; - sender.setDefaultEncoding(SyncopeConstants.DEFAULT_ENCODING); - sender.setHost(SMTP_HOST); - sender.setPort(SMTP_PORT); - } - - private boolean verifyMail(final String sender, final String subject) throws Exception { - LOG.info("Waiting for notification to be sent..."); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - - boolean found = false; - Session session = Session.getDefaultInstance(System.getProperties()); - Store store = session.getStore("pop3"); - store.connect(POP3_HOST, POP3_PORT, MAIL_ADDRESS, MAIL_PASSWORD); - - Folder inbox = store.getFolder("INBOX"); - assertNotNull(inbox); - inbox.open(Folder.READ_WRITE); - - Message[] messages = inbox.getMessages(); - for (Message message : messages) { - if (sender.equals(message.getFrom()[0].toString()) && subject.equals(message.getSubject())) { - found = true; - message.setFlag(Flag.DELETED, true); - } - } - - inbox.close(true); - store.close(); - return found; - } - - @Test - public void notifyByMail() throws Exception { - // 1. create suitable notification for subsequent tests - Notification notification = entityFactory.newEntity(Notification.class); - notification.getEvents().add("[REST]:[UserLogic]:[]:[create]:[SUCCESS]"); - - AnyAbout about = entityFactory.newEntity(AnyAbout.class); - about.setNotification(notification); - notification.add(about); - about.setAnyType(anyTypeDAO.findUser()); - about.set(new UserFiqlSearchConditionBuilder().inGroups(7L).query()); - - notification.setRecipients(new UserFiqlSearchConditionBuilder().inGroups(8L).query()); - notification.setSelfAsRecipient(true); - - notification.setRecipientAttrName("email"); - notification.setRecipientAttrType(IntMappingType.UserPlainSchema); - - Random random = new Random(System.currentTimeMillis()); - String sender = "syncopetest-" + random.nextLong() + "@syncope.apache.org"; - notification.setSender(sender); - String subject = "Test notification " + random.nextLong(); - notification.setSubject(subject); - notification.setTemplate("optin"); - - Notification actual = notificationDAO.save(notification); - assertNotNull(actual); - - notificationDAO.flush(); - - // 2. create user - UserTO userTO = getSampleTO(MAIL_ADDRESS); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(7); - userTO.getMemberships().add(membershipTO); - - userLogic.create(userTO, true); - - // 3. force Quartz job execution and verify e-mail - notificationJob.execute(null); - assertTrue(verifyMail(sender, subject)); - - // 4. get NotificationTask id and text body - Long taskId = null; - String textBody = null; - for (NotificationTask task : taskDAO.<NotificationTask>findAll(TaskType.NOTIFICATION)) { - if (sender.equals(task.getSender())) { - taskId = task.getKey(); - textBody = task.getTextBody(); - } - } - assertNotNull(taskId); - assertNotNull(textBody); - assertTrue("Notification mail text doesn't contain expected content.", - textBody.contains("Your email address is [email protected].")); - assertTrue("Notification mail text doesn't contain expected content.", - textBody.contains("Your email address inside a link: " - + "http://localhost/?email=notificationtest%40syncope.apache.org .")); - - // 5. execute Notification task and verify e-mail - taskLogic.execute(taskId, false); - assertTrue(verifyMail(sender, subject)); - } - - @Test - public void issueSYNCOPE192() throws Exception { - // 1. create suitable notification for subsequent tests - Notification notification = entityFactory.newEntity(Notification.class); - notification.getEvents().add("[REST]:[UserLogic]:[]:[create]:[SUCCESS]"); - - AnyAbout about = entityFactory.newEntity(AnyAbout.class); - about.setNotification(notification); - notification.add(about); - about.setAnyType(anyTypeDAO.findUser()); - about.set(new UserFiqlSearchConditionBuilder().inGroups(7L).query()); - - notification.setRecipients(new UserFiqlSearchConditionBuilder().inGroups(8L).query()); - notification.setSelfAsRecipient(true); - - notification.setRecipientAttrName("email"); - notification.setRecipientAttrType(IntMappingType.UserPlainSchema); - - Random random = new Random(System.currentTimeMillis()); - String sender = "syncope192-" + random.nextLong() + "@syncope.apache.org"; - notification.setSender(sender); - String subject = "Test notification " + random.nextLong(); - notification.setSubject(subject); - notification.setTemplate("optin"); - notification.setTraceLevel(TraceLevel.NONE); - - Notification actual = notificationDAO.save(notification); - assertNotNull(actual); - - // 2. create user - UserTO userTO = getSampleTO(MAIL_ADDRESS); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(7); - userTO.getMemberships().add(membershipTO); - - userLogic.create(userTO, true); - - // 3. force Quartz job execution and verify e-mail - notificationJob.execute(null); - assertTrue(verifyMail(sender, subject)); - - // 4. get NotificationTask id - Long taskId = null; - for (NotificationTask task : taskDAO.<NotificationTask>findAll(TaskType.NOTIFICATION)) { - if (sender.equals(task.getSender())) { - taskId = task.getKey(); - } - } - assertNotNull(taskId); - - // 5. verify that last exec status was updated - NotificationTaskTO task = (NotificationTaskTO) taskLogic.read(taskId); - assertNotNull(task); - assertTrue(task.getExecutions().isEmpty()); - assertTrue(task.isExecuted()); - assertTrue(StringUtils.isNotBlank(task.getLatestExecStatus())); - } - - @Test - public void notifyByMailEmptyAbout() throws Exception { - // 1. create suitable notification for subsequent tests - Notification notification = entityFactory.newEntity(Notification.class); - notification.getEvents().add("[REST]:[UserLogic]:[]:[create]:[SUCCESS]"); - notification.setRecipients(new UserFiqlSearchConditionBuilder().inGroups(8L).query()); - notification.setSelfAsRecipient(true); - - notification.setRecipientAttrName("email"); - notification.setRecipientAttrType(IntMappingType.UserPlainSchema); - - Random random = new Random(System.currentTimeMillis()); - String sender = "syncopetest-" + random.nextLong() + "@syncope.apache.org"; - notification.setSender(sender); - String subject = "Test notification " + random.nextLong(); - notification.setSubject(subject); - notification.setTemplate("optin"); - - Notification actual = notificationDAO.save(notification); - assertNotNull(actual); - - notificationDAO.flush(); - - // 2. create user - UserTO userTO = getSampleTO(MAIL_ADDRESS); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(7); - userTO.getMemberships().add(membershipTO); - - userLogic.create(userTO, true); - - // 3. force Quartz job execution and verify e-mail - notificationJob.execute(null); - assertTrue(verifyMail(sender, subject)); - - // 4. get NotificationTask id - Long taskId = null; - for (NotificationTask task : taskDAO.<NotificationTask>findAll(TaskType.NOTIFICATION)) { - if (sender.equals(task.getSender())) { - taskId = task.getKey(); - } - } - assertNotNull(taskId); - - // 5. execute Notification task and verify e-mail - taskLogic.execute(taskId, false); - assertTrue(verifyMail(sender, subject)); - } - - @Test - public void notifyByMailWithRetry() throws Exception { - // 1. create suitable notification for subsequent tests - Notification notification = entityFactory.newEntity(Notification.class); - notification.getEvents().add("[REST]:[UserLogic]:[]:[create]:[SUCCESS]"); - notification.setRecipients(new UserFiqlSearchConditionBuilder().inGroups(8L).query()); - notification.setSelfAsRecipient(true); - - notification.setRecipientAttrName("email"); - notification.setRecipientAttrType(IntMappingType.UserPlainSchema); - - Random random = new Random(System.currentTimeMillis()); - String sender = "syncopetest-" + random.nextLong() + "@syncope.apache.org"; - notification.setSender(sender); - String subject = "Test notification " + random.nextLong(); - notification.setSubject(subject); - notification.setTemplate("optin"); - - Notification actual = notificationDAO.save(notification); - assertNotNull(actual); - - notificationDAO.flush(); - - // 2. create user - UserTO userTO = getSampleTO(MAIL_ADDRESS); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(7); - userTO.getMemberships().add(membershipTO); - - userLogic.create(userTO, true); - - // 3. Set number of retries - CPlainAttr maxRetries = entityFactory.newEntity(CPlainAttr.class); - maxRetries.setSchema(plainSchemaDAO.find("notification.maxRetries")); - CPlainAttrValue maxRetriesValue = entityFactory.newEntity(CPlainAttrValue.class); - maxRetries.add("5", maxRetriesValue); - confDAO.save(maxRetries); - confDAO.flush(); - - // 4. Stop mail server to force error sending mail - stopGreenMail(); - - // 5. force Quartz job execution multiple times - for (int i = 0; i < 10; i++) { - notificationJob.execute(null); - } - - // 6. get NotificationTask, count number of executions - NotificationTask foundTask = null; - for (NotificationTask task : taskDAO.<NotificationTask>findAll(TaskType.NOTIFICATION)) { - if (sender.equals(task.getSender())) { - foundTask = task; - } - } - assertNotNull(foundTask); - assertEquals(6, notificationManager.countExecutionsWithStatus(foundTask.getKey(), - NotificationJob.Status.NOT_SENT.name())); - - // 7. start mail server again - startGreenMail(); - - // 8. reset number of retries - maxRetries = entityFactory.newEntity(CPlainAttr.class); - maxRetries.setSchema(plainSchemaDAO.find("notification.maxRetries")); - maxRetriesValue = entityFactory.newEntity(CPlainAttrValue.class); - maxRetries.add("0", maxRetriesValue); - confDAO.save(maxRetries); - confDAO.flush(); - } - - @Test - public void issueSYNCOPE445() throws Exception { - // 1. create suitable notification for subsequent tests - Notification notification = entityFactory.newEntity(Notification.class); - notification.getEvents().add("[REST]:[UserLogic]:[]:[create]:[SUCCESS]"); - - AnyAbout about = entityFactory.newEntity(AnyAbout.class); - about.setNotification(notification); - notification.add(about); - about.setAnyType(anyTypeDAO.findUser()); - about.set(new UserFiqlSearchConditionBuilder().inGroups(7L).query()); - - notification.setRecipients(new UserFiqlSearchConditionBuilder().inGroups(8L).query()); - notification.setSelfAsRecipient(true); - - notification.setRecipientAttrName("email"); - notification.setRecipientAttrType(IntMappingType.UserPlainSchema); - - notification.getStaticRecipients().add("[email protected]"); - - Random random = new Random(System.currentTimeMillis()); - String sender = "syncopetest-" + random.nextLong() + "@syncope.apache.org"; - notification.setSender(sender); - String subject = "Test notification " + random.nextLong(); - notification.setSubject(subject); - notification.setTemplate("optin"); - - Notification actual = notificationDAO.save(notification); - assertNotNull(actual); - - notificationDAO.flush(); - - // 2. create user - UserTO userTO = getSampleTO(MAIL_ADDRESS); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(7); - userTO.getMemberships().add(membershipTO); - - userLogic.create(userTO, true); - - // 3. force Quartz job execution and verify e-mail - notificationJob.execute(null); - assertTrue(verifyMail(sender, subject)); - - // 4. get NotificationTask id and text body - Long taskId = null; - String textBody = null; - Set<String> recipients = null; - for (NotificationTask task : taskDAO.<NotificationTask>findAll(TaskType.NOTIFICATION)) { - if (sender.equals(task.getSender())) { - taskId = task.getKey(); - textBody = task.getTextBody(); - recipients = task.getRecipients(); - } - } - - assertNotNull(taskId); - assertNotNull(textBody); - assertNotNull(recipients); - assertTrue(recipients.contains("[email protected]")); - - // 5. execute Notification task and verify e-mail - taskLogic.execute(taskId, false); - assertTrue(verifyMail(sender, subject)); - } - - @Test - public void issueSYNCOPE492() throws Exception { - // 1. create suitable disabled notification for subsequent tests - Notification notification = entityFactory.newEntity(Notification.class); - notification.getEvents().add("[REST]:[UserLogic]:[]:[create]:[SUCCESS]"); - - AnyAbout about = entityFactory.newEntity(AnyAbout.class); - about.setNotification(notification); - notification.add(about); - about.setAnyType(anyTypeDAO.findUser()); - about.set(new UserFiqlSearchConditionBuilder().inGroups(7L).query()); - - notification.setSelfAsRecipient(true); - - notification.setRecipientAttrName("email"); - notification.setRecipientAttrType(IntMappingType.UserPlainSchema); - - notification.getStaticRecipients().add("[email protected]"); - - Random random = new Random(System.currentTimeMillis()); - String sender = "syncopetest-" + random.nextLong() + "@syncope.apache.org"; - notification.setSender(sender); - String subject = "Test notification " + random.nextLong(); - notification.setSubject(subject); - notification.setTemplate("optin"); - notification.setActive(false); - - Notification actual = notificationDAO.save(notification); - assertNotNull(actual); - - notificationDAO.flush(); - - final int tasksNumberBefore = taskDAO.findAll(TaskType.NOTIFICATION).size(); - - // 2. create user - UserTO userTO = getUniqueSampleTO(MAIL_ADDRESS); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(7); - userTO.getMemberships().add(membershipTO); - - userLogic.create(userTO, true); - - // 3. force Quartz job execution - notificationJob.execute(null); - - // 4. check if number of tasks is not incremented - assertEquals(tasksNumberBefore, taskDAO.findAll(TaskType.NOTIFICATION).size()); - } - - @Test - public void issueSYNCOPE446() throws Exception { - // 1. create suitable notification for subsequent tests - Notification notification = entityFactory.newEntity(Notification.class); - notification.getEvents().add("[REST]:[GroupLogic]:[]:[create]:[SUCCESS]"); - - AnyAbout about = entityFactory.newEntity(AnyAbout.class); - about.setNotification(notification); - notification.add(about); - about.setAnyType(anyTypeDAO.findGroup()); - about.set(new GroupFiqlSearchConditionBuilder().is("name").equalTo("group446").query()); - - notification.setSelfAsRecipient(false); - - notification.setRecipientAttrName("email"); - notification.setRecipientAttrType(IntMappingType.UserPlainSchema); - - notification.getStaticRecipients().add(MAIL_ADDRESS); - - Random random = new Random(System.currentTimeMillis()); - String sender = "syncopetest-" + random.nextLong() + "@syncope.apache.org"; - notification.setSender(sender); - String subject = "Test notification " + random.nextLong(); - notification.setSubject(subject); - notification.setTemplate("optin"); - - Notification actual = notificationDAO.save(notification); - assertNotNull(actual); - - notificationDAO.flush(); - - // 2. create group - GroupTO groupTO = new GroupTO(); - groupTO.setName("group446"); - groupTO.setRealm("/even/two"); - - GroupTO createdGroup = groupLogic.create(groupTO); - assertNotNull(createdGroup); - - // 3. force Quartz job execution and verify e-mail - notificationJob.execute(null); - assertTrue(verifyMail(sender, subject)); - - // 4. get NotificationTask id and text body - Long taskId = null; - String textBody = null; - Set<String> recipients = null; - for (NotificationTask task : taskDAO.<NotificationTask>findAll(TaskType.NOTIFICATION)) { - if (sender.equals(task.getSender())) { - taskId = task.getKey(); - textBody = task.getTextBody(); - recipients = task.getRecipients(); - } - } - - assertNotNull(taskId); - assertNotNull(textBody); - assertTrue(recipients != null && recipients.contains(MAIL_ADDRESS)); - - // 5. execute Notification task and verify e-mail - taskLogic.execute(taskId, false); - assertTrue(verifyMail(sender, subject)); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/logic/src/test/resources/logicTest.xml ---------------------------------------------------------------------- diff --git a/core/logic/src/test/resources/logicTest.xml b/core/logic/src/test/resources/logicTest.xml deleted file mode 100644 index fd6edd6..0000000 --- a/core/logic/src/test/resources/logicTest.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:context="http://www.springframework.org/schema/context" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context.xsd"> - - <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> - <property name="locations"> - <list> - <value>classpath:persistence.properties</value> - <value>classpath:domains/*.properties</value> - <value>classpath:security.properties</value> - <value>classpath:connid.properties</value> - <value>classpath:mail.properties</value> - <value>classpath:logic.properties</value> - <value>classpath:workflow.properties</value> - <value>classpath:provisioning.properties</value> - </list> - </property> - <property name="ignoreResourceNotFound" value="true"/> - <property name="ignoreUnresolvablePlaceholders" value="true"/> - </bean> - - <bean class="org.apache.syncope.core.misc.spring.ApplicationContextProvider"/> - - <bean id="adminUser" class="java.lang.String"> - <constructor-arg value="${adminUser}"/> - </bean> - <bean id="anonymousUser" class="java.lang.String"> - <constructor-arg value="${anonymousUser}"/> - </bean> - - <context:component-scan base-package="org.apache.syncope.core.misc.policy"/> - <context:component-scan base-package="org.apache.syncope.core.misc.security"/> - - <import resource="persistenceContext.xml"/> - -</beans> http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthContextUtils.java ---------------------------------------------------------------------- diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthContextUtils.java b/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthContextUtils.java index 4586ee3..595dda3 100644 --- a/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthContextUtils.java +++ b/core/misc/src/main/java/org/apache/syncope/core/misc/security/AuthContextUtils.java @@ -90,7 +90,7 @@ public final class AuthContextUtils { return domainKey; } - public static void setFakeAuth(final String domain) { + private static void setFakeAuth(final String domain) { List<GrantedAuthority> authorities = CollectionUtils.collect(Entitlement.values(), new Transformer<String, GrantedAuthority>() { @@ -107,17 +107,13 @@ public final class AuthContextUtils { SecurityContextHolder.getContext().setAuthentication(auth); } - public static void clearFakeAuth() { - SecurityContextHolder.clearContext(); - } - public static <T> T execWithAuthContext(final String domainKey, final Executable<T> executable) { SecurityContext ctx = SecurityContextHolder.getContext(); setFakeAuth(domainKey); try { return executable.exec(); } finally { - clearFakeAuth(); + SecurityContextHolder.clearContext(); SecurityContextHolder.setContext(ctx); } } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java ---------------------------------------------------------------------- diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java index e67dcd6..2a21281 100644 --- a/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java +++ b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/ApplicationContextProvider.java @@ -18,10 +18,12 @@ */ package org.apache.syncope.core.misc.spring; +import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.transaction.interceptor.TransactionInterceptor; public class ApplicationContextProvider implements ApplicationContextAware { @@ -41,8 +43,16 @@ public class ApplicationContextProvider implements ApplicationContextAware { : BEAN_FACTORY; } + private static void enableDomainTransactionInterceptor() { + for (String name : getBeanFactory().getBeanNamesForType(TransactionInterceptor.class)) { + BeanDefinition bd = getBeanFactory().getBeanDefinition(name); + bd.setBeanClassName(DomainTransactionInterceptor.class.getName()); + } + } + public static void setBeanFactory(final DefaultListableBeanFactory beanFactory) { BEAN_FACTORY = beanFactory; + enableDomainTransactionInterceptor(); } /** @@ -53,5 +63,6 @@ public class ApplicationContextProvider implements ApplicationContextAware { @Override public void setApplicationContext(final ApplicationContext ctx) { CTX = (ConfigurableApplicationContext) ctx; + enableDomainTransactionInterceptor(); } } http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptor.java ---------------------------------------------------------------------- diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptor.java b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptor.java new file mode 100644 index 0000000..e239002 --- /dev/null +++ b/core/misc/src/main/java/org/apache/syncope/core/misc/spring/DomainTransactionInterceptor.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.syncope.core.misc.spring; + +import java.lang.reflect.Method; +import org.aopalliance.intercept.MethodInvocation; +import org.apache.syncope.core.misc.security.AuthContextUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.transaction.interceptor.DefaultTransactionAttribute; +import org.springframework.transaction.interceptor.TransactionAttribute; +import org.springframework.transaction.interceptor.TransactionAttributeSource; +import org.springframework.transaction.interceptor.TransactionInterceptor; + +/** + * Extends the standard {@link TransactionInterceptor} by dynamically setting the appropriate + * {@link TransactionAttribute} qualifier according to the authentication domain of the caller - retrieved via + * {@link AuthContextUtils#getDomain()}. + */ +public class DomainTransactionInterceptor extends TransactionInterceptor { + + private static final long serialVersionUID = 5113728988680448551L; + + private static final Logger LOG = LoggerFactory.getLogger(DomainTransactionInterceptor.class); + + @Override + public TransactionAttributeSource getTransactionAttributeSource() { + final TransactionAttributeSource origTxAttrSource = super.getTransactionAttributeSource(); + + return new TransactionAttributeSource() { + + @Override + public TransactionAttribute getTransactionAttribute(final Method method, final Class<?> targetClass) { + TransactionAttribute txAttr = origTxAttrSource.getTransactionAttribute(method, targetClass); + + if (txAttr instanceof DefaultTransactionAttribute) { + ((DefaultTransactionAttribute) txAttr).setQualifier(AuthContextUtils.getDomain()); + } + + return txAttr; + } + }; + } + + @Override + public Object invoke(final MethodInvocation invocation) throws Throwable { + try { + return super.invoke(invocation); + } catch (Throwable e) { + LOG.debug("Error during {} invocation", invocation.getMethod(), e); + throw e; + } + } +} http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainTransactionInterceptor.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainTransactionInterceptor.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainTransactionInterceptor.java deleted file mode 100644 index 42779ed..0000000 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainTransactionInterceptor.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.persistence.jpa.spring; - -import java.lang.reflect.Method; -import org.aopalliance.intercept.MethodInvocation; -import org.apache.syncope.core.misc.security.AuthContextUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.transaction.interceptor.DefaultTransactionAttribute; -import org.springframework.transaction.interceptor.TransactionAttribute; -import org.springframework.transaction.interceptor.TransactionAttributeSource; -import org.springframework.transaction.interceptor.TransactionInterceptor; - -/** - * Extends the standard {@link TransactionInterceptor} by dynamically setting the appropriate - * {@link TransactionAttribute} qualifier according to the authentication domain of the caller - retrieved via - * {@link AuthContextUtils#getDomain()}. - */ -public class DomainTransactionInterceptor extends TransactionInterceptor { - - private static final long serialVersionUID = 5113728988680448551L; - - private static final Logger LOG = LoggerFactory.getLogger(DomainTransactionInterceptor.class); - - @Override - public TransactionAttributeSource getTransactionAttributeSource() { - final TransactionAttributeSource origTxAttrSource = super.getTransactionAttributeSource(); - - return new TransactionAttributeSource() { - - @Override - public TransactionAttribute getTransactionAttribute(final Method method, final Class<?> targetClass) { - TransactionAttribute txAttr = origTxAttrSource.getTransactionAttribute(method, targetClass); - - if (txAttr instanceof DefaultTransactionAttribute) { - ((DefaultTransactionAttribute) txAttr).setQualifier(AuthContextUtils.getDomain()); - } - - return txAttr; - } - }; - } - - @Override - public Object invoke(final MethodInvocation invocation) throws Throwable { - try { - return super.invoke(invocation); - } catch (Throwable e) { - LOG.debug("Error during {} invocation", invocation.getMethod(), e); - throw e; - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/SpringComponentReplacer.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/SpringComponentReplacer.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/SpringComponentReplacer.java deleted file mode 100644 index e983426..0000000 --- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/SpringComponentReplacer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.core.persistence.jpa.spring; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanDefinition; -import org.springframework.beans.factory.config.BeanFactoryPostProcessor; -import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; -import org.springframework.stereotype.Component; -import org.springframework.transaction.interceptor.TransactionInterceptor; - -/** - * Hack for dynamically replacing standard {@link TransactionInterceptor} with - * {@link DomainTransactionInterceptor} in Spring context. - */ -@Component -public class SpringComponentReplacer implements BeanFactoryPostProcessor { - - @Override - public void postProcessBeanFactory(final ConfigurableListableBeanFactory factory) throws BeansException { - for (String name : factory.getBeanNamesForType(TransactionInterceptor.class)) { - BeanDefinition bd = factory.getBeanDefinition(name); - bd.setBeanClassName(DomainTransactionInterceptor.class.getName()); - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java index 201708f..bffe55f 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java @@ -28,11 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.jpa.EntityManagerFactoryUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:persistenceTest.xml" }) -@TransactionConfiguration(transactionManager = "MasterTransactionManager") public abstract class AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java index 5130c28..cd6b535 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyObjectTest.java @@ -33,7 +33,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class AnyObjectTest extends AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java index 37aef3c..b5f99ce 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnySearchTest.java @@ -53,7 +53,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class AnySearchTest extends AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeClassTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeClassTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeClassTest.java index ed83f65..1bdae2d 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeClassTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeClassTest.java @@ -32,7 +32,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class AnyTypeClassTest extends AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeTest.java index be60f46..05026a2 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/AnyTypeTest.java @@ -34,7 +34,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class AnyTypeTest extends AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java index 1e90e5c..38332b6 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConfTest.java @@ -38,7 +38,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class ConfTest extends AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java index 70665ed..f3ade5e 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/ConnInstanceTest.java @@ -37,7 +37,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class ConnInstanceTest extends AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java index cd336ae..3fb15b7 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerAttrTest.java @@ -43,7 +43,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class DerAttrTest extends AbstractTest { @Autowired http://git-wip-us.apache.org/repos/asf/syncope/blob/88061761/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java index c62ab6e..abe3de3 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/DerSchemaTest.java @@ -34,7 +34,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -@Transactional +@Transactional("Master") public class DerSchemaTest extends AbstractTest { @Autowired
