diff --git a/pom.xml b/pom.xml index ceeb6e508f..06e609a7ab 100644 --- a/pom.xml +++ b/pom.xml @@ -36,16 +36,15 @@ convert 6.2 - 6.0 - 6.18 + 7.0 6.1 - 7.3 + 8.0 7.0 1.1 - 1.0.4 + 1.0.5 - 3.2.17.RELEASE + 5.0.4.RELEASE 4.5.2 7.7.9 3.17 @@ -87,11 +86,6 @@ - - org.alfresco - alfresco-mbeans - ${dependency.alfresco-mbeans.version} - org.alfresco alfresco-core @@ -100,7 +94,7 @@ org.alfresco alfresco-text-gen - 1.3 + 1.4 org.alfresco.services @@ -224,6 +218,26 @@ rhino 1.7R4-alfresco-patched + + org.springframework + spring-core + ${dependency.spring.version} + + + org.springframework + spring-orm + ${dependency.spring.version} + + + org.springframework + spring-context + ${dependency.spring.version} + + + org.springframework + spring-context-support + ${dependency.spring.version} + org.springframework spring-web @@ -630,7 +644,7 @@ org.springframework.security spring-security-core - 3.1.7.RELEASE + 5.0.1.RELEASE org.springframework @@ -638,6 +652,11 @@ + + org.quartz-scheduler + quartz + 2.3.0 + @@ -747,12 +766,6 @@ ${dependency.mariadb.version} test - - com.h2database - h2 - 1.4.192 - test - xmlunit xmlunit @@ -1014,51 +1027,6 @@ - - - package-h2scripts - package - - run - - - - - - - - - - - - - - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - - attach-h2scripts - package - - attach-artifact - - - - - ${project.build.directory}/h2scripts.jar - jar - h2scripts - - - - diff --git a/src/main/java/org/alfresco/heartbeat/HBDataCollectorServiceImpl.java b/src/main/java/org/alfresco/heartbeat/HBDataCollectorServiceImpl.java index 35ec98d9d6..3f3c77f927 100644 --- a/src/main/java/org/alfresco/heartbeat/HBDataCollectorServiceImpl.java +++ b/src/main/java/org/alfresco/heartbeat/HBDataCollectorServiceImpl.java @@ -28,8 +28,6 @@ package org.alfresco.heartbeat; import java.text.ParseException; import java.util.LinkedList; import java.util.List; - -import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.heartbeat.datasender.HBDataSenderService; import org.alfresco.repo.lock.JobLockService; import org.alfresco.service.cmr.repository.HBDataCollectorService; @@ -37,7 +35,15 @@ import org.alfresco.service.license.LicenseDescriptor; import org.alfresco.service.license.LicenseService.LicenseChangeHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.quartz.*; +import org.quartz.CronScheduleBuilder; +import org.quartz.CronTrigger; +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; public class HBDataCollectorServiceImpl implements HBDataCollectorService, LicenseChangeHandler { @@ -188,18 +194,26 @@ public class HBDataCollectorServiceImpl implements HBDataCollectorService, Licen } - private void scheduleJob(final String jobName, final String triggerName, final HBBaseDataCollector collector) throws ParseException, SchedulerException + private void scheduleJob(final String jobName, final String triggerName, final HBBaseDataCollector collector) throws SchedulerException { - final JobDetail jobDetail = new JobDetail(jobName, Scheduler.DEFAULT_GROUP, HeartBeatJob.class); - final String cronExpression = testMode ? testCronExpression : collector.getCronExpression(); - jobDetail.getJobDataMap().put(HeartBeatJob.COLLECTOR_KEY, collector); - jobDetail.getJobDataMap().put(HeartBeatJob.DATA_SENDER_SERVICE_KEY, hbDataSenderService); - jobDetail.getJobDataMap().put(HeartBeatJob.JOB_LOCK_SERVICE_KEY, jobLockService); + JobDataMap jobDataMap = new JobDataMap(); + jobDataMap.put(HeartBeatJob.COLLECTOR_KEY, collector); + jobDataMap.put(HeartBeatJob.DATA_SENDER_SERVICE_KEY, hbDataSenderService); + jobDataMap.put(HeartBeatJob.JOB_LOCK_SERVICE_KEY, jobLockService); + final JobDetail jobDetail = JobBuilder.newJob() + .withIdentity(jobName) + .usingJobData(jobDataMap) + .ofType(HeartBeatJob.class) + .build(); - // Ensure the job wasn't already scheduled in an earlier retry of this transaction - scheduler.unscheduleJob(triggerName, Scheduler.DEFAULT_GROUP); + final String cronExpression = testMode ? testCronExpression : collector.getCronExpression(); // Schedule job - final CronTrigger cronTrigger = new CronTrigger(triggerName , Scheduler.DEFAULT_GROUP, cronExpression); + final CronTrigger cronTrigger = TriggerBuilder.newTrigger() + .withIdentity(triggerName) + .withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)) + .build(); + // Ensure the job wasn't already scheduled in an earlier retry of this transaction + scheduler.unscheduleJob(cronTrigger.getKey()); scheduler.scheduleJob(jobDetail, cronTrigger); if (logger.isDebugEnabled()) @@ -210,7 +224,7 @@ public class HBDataCollectorServiceImpl implements HBDataCollectorService, Licen private void unscheduleJob(final String triggerName, final HBBaseDataCollector collector) throws SchedulerException { - scheduler.unscheduleJob(triggerName, Scheduler.DEFAULT_GROUP); + scheduler.unscheduleJob(new TriggerKey(triggerName)); if (logger.isDebugEnabled()) { diff --git a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoSybaseAnywhereDialect.java b/src/main/java/org/alfresco/ibatis/BatchingDAO.java similarity index 57% rename from src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoSybaseAnywhereDialect.java rename to src/main/java/org/alfresco/ibatis/BatchingDAO.java index 78de49666e..6203588489 100644 --- a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoSybaseAnywhereDialect.java +++ b/src/main/java/org/alfresco/ibatis/BatchingDAO.java @@ -1,41 +1,49 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.domain.hibernate.dialect; +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; -import java.sql.Types; - -import org.hibernate.dialect.SybaseAnywhereDialect; - -public class AlfrescoSybaseAnywhereDialect extends SybaseAnywhereDialect +/** + * Interface for DAOs that offer batching. This should be provided as an optimization + * and DAO implementations that can't supply batching should just do nothing. + * + * @author Derek Hulley + * @since 3.2.1 + */ +public interface BatchingDAO { - - public AlfrescoSybaseAnywhereDialect() - { - super(); - registerColumnType( Types.VARCHAR, "text" ); - } - + /** + * Start a batch of insert or update commands + * + * @throws RuntimeException wrapping a SQLException + */ + void startBatch(); + /** + * Write a batch of insert or update commands + * + * @throws RuntimeException wrapping a SQLException + */ + void executeBatch(); } diff --git a/src/main/java/org/alfresco/ibatis/ByteArrayTypeHandler.java b/src/main/java/org/alfresco/ibatis/ByteArrayTypeHandler.java new file mode 100644 index 0000000000..fdd3f71241 --- /dev/null +++ b/src/main/java/org/alfresco/ibatis/ByteArrayTypeHandler.java @@ -0,0 +1,151 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.TypeHandler; + +/** + * MyBatis 3.x TypeHandler for _byte[] to BLOB types. + * + * @author sglover + * @since 5.0 + */ +public class ByteArrayTypeHandler implements TypeHandler +{ + /** + * @throws DeserializationException if the object could not be deserialized + */ + public Object getResult(ResultSet rs, String columnName) throws SQLException + { + byte[] ret = null; + try + { + byte[] bytes = rs.getBytes(columnName); + if(bytes != null && !rs.wasNull()) + { + ret = bytes; + } + } + catch (Throwable e) + { + throw new DeserializationException(e); + } + return ret; + } + + @Override + public Object getResult(ResultSet rs, int columnIndex) throws SQLException + { + byte[] ret = null; + try + { + byte[] bytes = rs.getBytes(columnIndex); + if(bytes != null && !rs.wasNull()) + { + ret = bytes; + } + } + catch (Throwable e) + { + throw new DeserializationException(e); + } + return ret; + } + + public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException + { + if (parameter == null) + { + ps.setNull(i, Types.BINARY); + } + else + { + try + { + ps.setBytes(i, (byte[])parameter); + } + catch (Throwable e) + { + throw new SerializationException(e); + } + } + } + + public Object getResult(CallableStatement cs, int columnIndex) throws SQLException + { + throw new UnsupportedOperationException("Unsupported"); + } + + /** + * @return Returns the value given + */ + public Object valueOf(String s) + { + return s; + } + + /** + * Marker exception to allow deserialization issues to be dealt with by calling code. + * If this exception remains uncaught, it will be very difficult to find and rectify + * the data issue. + * + * @author sglover + * @since 5.0 + */ + public static class DeserializationException extends RuntimeException + { + private static final long serialVersionUID = 4673487701048985340L; + + public DeserializationException(Throwable cause) + { + super(cause); + } + } + + /** + * Marker exception to allow serialization issues to be dealt with by calling code. + * Unlike with {@link DeserializationException deserialization}, it is not important + * to handle this exception neatly. + * + * @author sglover + * @since 5.0 + */ + public static class SerializationException extends RuntimeException + { + private static final long serialVersionUID = 962957884262870228L; + + public SerializationException(Throwable cause) + { + super(cause); + } + } +} diff --git a/src/main/java/org/alfresco/ibatis/HierarchicalSqlSessionFactoryBean.java b/src/main/java/org/alfresco/ibatis/HierarchicalSqlSessionFactoryBean.java new file mode 100644 index 0000000000..c5b9b8f014 --- /dev/null +++ b/src/main/java/org/alfresco/ibatis/HierarchicalSqlSessionFactoryBean.java @@ -0,0 +1,557 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import java.io.IOException; +import java.util.Properties; +import javax.sql.DataSource; +import org.alfresco.util.PropertyCheck; +import org.alfresco.util.resource.HierarchicalResourceLoader; +import org.apache.ibatis.builder.xml.XMLMapperBuilder; +import org.apache.ibatis.executor.ErrorContext; +import org.apache.ibatis.logging.Log; +import org.apache.ibatis.logging.LogFactory; +import org.apache.ibatis.mapping.DatabaseIdProvider; +import org.apache.ibatis.mapping.Environment; +import org.apache.ibatis.mapping.VendorDatabaseIdProvider; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.reflection.factory.ObjectFactory; +import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.session.SqlSessionFactory; +import org.apache.ibatis.session.SqlSessionFactoryBuilder; +import org.apache.ibatis.transaction.TransactionFactory; +import org.apache.ibatis.type.TypeHandler; +import org.mybatis.spring.SqlSessionFactoryBean; +import org.mybatis.spring.transaction.SpringManagedTransactionFactory; +import org.springframework.context.ApplicationEvent; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.core.NestedIOException; +import org.springframework.core.io.Resource; +import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; + +import static org.springframework.util.Assert.notNull; +import static org.springframework.util.ObjectUtils.isEmpty; +import static org.springframework.util.StringUtils.hasLength; +import static org.springframework.util.StringUtils.tokenizeToStringArray; + +/** + * Extends the MyBatis-Spring support by allowing a choice of {@link org.springframework.core.io.ResourceLoader}. The + * {@link #setResourceLoader(HierarchicalResourceLoader) ResourceLoader} will be used to load the SqlMapConfig + * file and use a {@link HierarchicalXMLConfigBuilder} to read the individual MyBatis (3.x) resources. + *

+ * Pending a better way to extend/override, much of the implementation is a direct copy of the MyBatis-Spring + * {@link SqlSessionFactoryBean}; some of the protected methods do not have access to the object's state + * and can therefore not be overridden successfully. + *

+ * This is equivalent to HierarchicalSqlMapClientFactoryBean which extended iBatis (2.x). + * See also: IBATIS-589 + * and: + * + * @author Derek Hulley, janv + * @since 4.0 + */ +//note: effectively replaces SqlSessionFactoryBean to use hierarchical resource loader +public class HierarchicalSqlSessionFactoryBean extends SqlSessionFactoryBean +{ + + private HierarchicalResourceLoader resourceLoader; + + private final Log logger = LogFactory.getLog(getClass()); + + private Resource configLocation; + + private Resource[] mapperLocations; + + private DataSource dataSource; + + private TransactionFactory transactionFactory; + + private Properties configurationProperties; + + private SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder(); + + private SqlSessionFactory sqlSessionFactory; + + private String environment = SqlSessionFactoryBean.class.getSimpleName(); // EnvironmentAware requires spring 3.1 + + private boolean failFast; + + private Interceptor[] plugins; + + private TypeHandler[] typeHandlers; + + private String typeHandlersPackage; + + private Class[] typeAliases; + + private String typeAliasesPackage; + + private Class typeAliasesSuperType; + + private DatabaseIdProvider databaseIdProvider = new VendorDatabaseIdProvider(); + + private ObjectFactory objectFactory; + + private ObjectWrapperFactory objectWrapperFactory; + /** + * Default constructor + */ + public HierarchicalSqlSessionFactoryBean() + { + } + + /** + * Set the resource loader to use. To use the #resource.dialect# placeholder, use the + * {@link HierarchicalResourceLoader}. + * + * @param resourceLoader the resource loader to use + */ + public void setResourceLoader(HierarchicalResourceLoader resourceLoader) + { + this.resourceLoader = resourceLoader; + } + + /** + * Sets the ObjectFactory. + * + * @since 1.1.2 + * @param objectFactory ObjectFactory + */ + public void setObjectFactory(ObjectFactory objectFactory) { + this.objectFactory = objectFactory; + } + + /** + * Sets the ObjectWrapperFactory. + * + * @since 1.1.2 + * @param objectWrapperFactory ObjectWrapperFactory + */ + public void setObjectWrapperFactory(ObjectWrapperFactory objectWrapperFactory) { + this.objectWrapperFactory = objectWrapperFactory; + } + + /** + * Sets the DatabaseIdProvider. + * + * @since 1.1.0 + * @return DatabaseIdProvider + */ + public DatabaseIdProvider getDatabaseIdProvider() { + return databaseIdProvider; + } + + /** + * Gets the DatabaseIdProvider + * + * @since 1.1.0 + * @param databaseIdProvider DatabaseIdProvider + */ + public void setDatabaseIdProvider(DatabaseIdProvider databaseIdProvider) { + this.databaseIdProvider = databaseIdProvider; + } + + /** + * Mybatis plugin list. + * + * @since 1.0.1 + * + * @param plugins list of plugins + * + */ + public void setPlugins(Interceptor[] plugins) { + this.plugins = plugins; + } + + /** + * Packages to search for type aliases. + * + * @since 1.0.1 + * + * @param typeAliasesPackage package to scan for domain objects + * + */ + public void setTypeAliasesPackage(String typeAliasesPackage) { + this.typeAliasesPackage = typeAliasesPackage; + } + + /** + * Super class which domain objects have to extend to have a type alias created. + * No effect if there is no package to scan configured. + * + * @since 1.1.2 + * + * @param typeAliasesSuperType super class for domain objects + * + */ + public void setTypeAliasesSuperType(Class typeAliasesSuperType) { + this.typeAliasesSuperType = typeAliasesSuperType; + } + + /** + * Packages to search for type handlers. + * + * @since 1.0.1 + * + * @param typeHandlersPackage package to scan for type handlers + * + */ + public void setTypeHandlersPackage(String typeHandlersPackage) { + this.typeHandlersPackage = typeHandlersPackage; + } + + /** + * Set type handlers. They must be annotated with {@code MappedTypes} and optionally with {@code MappedJdbcTypes} + * + * @since 1.0.1 + * + * @param typeHandlers Type handler list + */ + public void setTypeHandlers(TypeHandler[] typeHandlers) { + this.typeHandlers = typeHandlers; + } + + /** + * List of type aliases to register. They can be annotated with {@code Alias} + * + * @since 1.0.1 + * + * @param typeAliases Type aliases list + */ + public void setTypeAliases(Class[] typeAliases) { + this.typeAliases = typeAliases; + } + + /** + * If true, a final check is done on Configuration to assure that all mapped + * statements are fully loaded and there is no one still pending to resolve + * includes. Defaults to false. + * + * @since 1.0.1 + * + * @param failFast enable failFast + */ + public void setFailFast(boolean failFast) { + this.failFast = failFast; + } + + /** + * Set the location of the MyBatis {@code SqlSessionFactory} config file. A typical value is + * "WEB-INF/mybatis-configuration.xml". + */ + public void setConfigLocation(Resource configLocation) { + this.configLocation = configLocation; + } + + /** + * Set locations of MyBatis mapper files that are going to be merged into the {@code SqlSessionFactory} + * configuration at runtime. + * + * This is an alternative to specifying "<sqlmapper>" entries in an MyBatis config file. + * This property being based on Spring's resource abstraction also allows for specifying + * resource patterns here: e.g. "classpath*:sqlmap/*-mapper.xml". + */ + public void setMapperLocations(Resource[] mapperLocations) { + this.mapperLocations = mapperLocations; + } + + /** + * Set optional properties to be passed into the SqlSession configuration, as alternative to a + * {@code <properties>} tag in the configuration xml file. This will be used to + * resolve placeholders in the config file. + */ + public void setConfigurationProperties(Properties sqlSessionFactoryProperties) { + this.configurationProperties = sqlSessionFactoryProperties; + } + + /** + * Set the JDBC {@code DataSource} that this instance should manage transactions for. The {@code DataSource} + * should match the one used by the {@code SqlSessionFactory}: for example, you could specify the same + * JNDI DataSource for both. + * + * A transactional JDBC {@code Connection} for this {@code DataSource} will be provided to application code + * accessing this {@code DataSource} directly via {@code DataSourceUtils} or {@code DataSourceTransactionManager}. + * + * The {@code DataSource} specified here should be the target {@code DataSource} to manage transactions for, not + * a {@code TransactionAwareDataSourceProxy}. Only data access code may work with + * {@code TransactionAwareDataSourceProxy}, while the transaction manager needs to work on the + * underlying target {@code DataSource}. If there's nevertheless a {@code TransactionAwareDataSourceProxy} + * passed in, it will be unwrapped to extract its target {@code DataSource}. + * + */ + public void setDataSource(DataSource dataSource) { + if (dataSource instanceof TransactionAwareDataSourceProxy) { + // If we got a TransactionAwareDataSourceProxy, we need to perform + // transactions for its underlying target DataSource, else data + // access code won't see properly exposed transactions (i.e. + // transactions for the target DataSource). + this.dataSource = ((TransactionAwareDataSourceProxy) dataSource).getTargetDataSource(); + } else { + this.dataSource = dataSource; + } + } + + /** + * Sets the {@code SqlSessionFactoryBuilder} to use when creating the {@code SqlSessionFactory}. + * + * This is mainly meant for testing so that mock SqlSessionFactory classes can be injected. By + * default, {@code SqlSessionFactoryBuilder} creates {@code DefaultSqlSessionFactory} instances. + * + */ + public void setSqlSessionFactoryBuilder(SqlSessionFactoryBuilder sqlSessionFactoryBuilder) { + this.sqlSessionFactoryBuilder = sqlSessionFactoryBuilder; + } + + /** + * Set the MyBatis TransactionFactory to use. Default is {@code SpringManagedTransactionFactory} + * + * The default {@code SpringManagedTransactionFactory} should be appropriate for all cases: + * be it Spring transaction management, EJB CMT or plain JTA. If there is no active transaction, + * SqlSession operations will execute SQL statements non-transactionally. + * + * It is strongly recommended to use the default {@code TransactionFactory}. If not used, any + * attempt at getting an SqlSession through Spring's MyBatis framework will throw an exception if + * a transaction is active. + * + * @see SpringManagedTransactionFactory + * @param transactionFactory the MyBatis TransactionFactory + */ + public void setTransactionFactory(TransactionFactory transactionFactory) { + this.transactionFactory = transactionFactory; + } + + /** + * NOTE: This class overrides any {@code Environment} you have set in the MyBatis + * config file. This is used only as a placeholder name. The default value is + * {@code SqlSessionFactoryBean.class.getSimpleName()}. + * + * @param environment the environment name + */ + public void setEnvironment(String environment) { + this.environment = environment; + } + + @Override + public void afterPropertiesSet() throws Exception { + + PropertyCheck.mandatory(this, "resourceLoader", resourceLoader); + + notNull(dataSource, "Property 'dataSource' is required"); + notNull(sqlSessionFactoryBuilder, "Property 'sqlSessionFactoryBuilder' is required"); + + this.sqlSessionFactory = buildSqlSessionFactory(); + } + + + + + /** + * Build a {@code SqlSessionFactory} instance. + *

+ * The default implementation uses the standard MyBatis {@code XMLConfigBuilder} API to build a + * {@code SqlSessionFactory} instance based on an Reader. + * + * @return SqlSessionFactory + * @throws IOException if loading the config file failed + */ + protected SqlSessionFactory buildSqlSessionFactory() throws IOException { + + Configuration configuration; + + HierarchicalXMLConfigBuilder xmlConfigBuilder = null; + if (this.configLocation != null) { + try { + xmlConfigBuilder = new HierarchicalXMLConfigBuilder(resourceLoader, this.configLocation.getInputStream(), null, this.configurationProperties); + configuration = xmlConfigBuilder.getConfiguration(); + } catch (Exception ex) { + throw new NestedIOException("Failed to parse config resource: " + this.configLocation, ex); + } finally { + ErrorContext.instance().reset(); + } + } else { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Property 'configLocation' not specified, using default MyBatis Configuration"); + } + configuration = new Configuration(); + configuration.setVariables(this.configurationProperties); + } + + if (this.objectFactory != null) { + configuration.setObjectFactory(this.objectFactory); + } + + if (this.objectWrapperFactory != null) { + configuration.setObjectWrapperFactory(this.objectWrapperFactory); + } + + if (hasLength(this.typeAliasesPackage)) { + String[] typeAliasPackageArray = tokenizeToStringArray(this.typeAliasesPackage, + ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); + for (String packageToScan : typeAliasPackageArray) { + configuration.getTypeAliasRegistry().registerAliases(packageToScan, + typeAliasesSuperType == null ? Object.class : typeAliasesSuperType); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Scanned package: '" + packageToScan + "' for aliases"); + } + } + } + + if (!isEmpty(this.typeAliases)) { + for (Class typeAlias : this.typeAliases) { + configuration.getTypeAliasRegistry().registerAlias(typeAlias); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Registered type alias: '" + typeAlias + "'"); + } + } + } + + if (!isEmpty(this.plugins)) { + for (Interceptor plugin : this.plugins) { + configuration.addInterceptor(plugin); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Registered plugin: '" + plugin + "'"); + } + } + } + + if (hasLength(this.typeHandlersPackage)) { + String[] typeHandlersPackageArray = tokenizeToStringArray(this.typeHandlersPackage, + ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS); + for (String packageToScan : typeHandlersPackageArray) { + configuration.getTypeHandlerRegistry().register(packageToScan); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Scanned package: '" + packageToScan + "' for type handlers"); + } + } + } + + if (!isEmpty(this.typeHandlers)) { + for (TypeHandler typeHandler : this.typeHandlers) { + configuration.getTypeHandlerRegistry().register(typeHandler); + if (this.logger.isDebugEnabled()) { + this.logger.debug("Registered type handler: '" + typeHandler + "'"); + } + } + } + + if (xmlConfigBuilder != null) { + try { + xmlConfigBuilder.parse(); + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Parsed configuration file: '" + this.configLocation + "'"); + } + } catch (Exception ex) { + throw new NestedIOException("Failed to parse config resource: " + this.configLocation, ex); + } finally { + ErrorContext.instance().reset(); + } + } + + if (this.transactionFactory == null) { + this.transactionFactory = new SpringManagedTransactionFactory(); + } + + Environment environment = new Environment(this.environment, this.transactionFactory, this.dataSource); + configuration.setEnvironment(environment); + + //Commented out to be able to use dummy dataSource in tests. + /* + if (this.databaseIdProvider != null) { + try { + configuration.setDatabaseId(this.databaseIdProvider.getDatabaseId(this.dataSource)); + } catch (SQLException e) { + throw new NestedIOException("Failed getting a databaseId", e); + } + } + */ + + if (!isEmpty(this.mapperLocations)) { + for (Resource mapperLocation : this.mapperLocations) { + if (mapperLocation == null) { + continue; + } + + try { + XMLMapperBuilder xmlMapperBuilder = new XMLMapperBuilder(mapperLocation.getInputStream(), + configuration, mapperLocation.toString(), configuration.getSqlFragments()); + xmlMapperBuilder.parse(); + } catch (Exception e) { + throw new NestedIOException("Failed to parse mapping resource: '" + mapperLocation + "'", e); + } finally { + ErrorContext.instance().reset(); + } + + if (this.logger.isDebugEnabled()) { + this.logger.debug("Parsed mapper file: '" + mapperLocation + "'"); + } + } + } else { + if (this.logger.isDebugEnabled()) { + this.logger.debug("Property 'mapperLocations' was not specified, only MyBatis mapper files specified in the config xml were loaded"); + } + } + + return this.sqlSessionFactoryBuilder.build(configuration); + } + + /** + * {@inheritDoc} + */ + public SqlSessionFactory getObject() throws Exception { + if (this.sqlSessionFactory == null) { + afterPropertiesSet(); + } + + return this.sqlSessionFactory; + } + + /** + * {@inheritDoc} + */ + public Class getObjectType() { + return this.sqlSessionFactory == null ? SqlSessionFactory.class : this.sqlSessionFactory.getClass(); + } + + /** + * {@inheritDoc} + */ + public boolean isSingleton() { + return true; + } + + /** + * {@inheritDoc} + */ + public void onApplicationEvent(ApplicationEvent event) { + if (failFast && event instanceof ContextRefreshedEvent) { + // fail-fast -> check all statements are completed + this.sqlSessionFactory.getConfiguration().getMappedStatementNames(); + } + } +} diff --git a/src/main/java/org/alfresco/ibatis/HierarchicalXMLConfigBuilder.java b/src/main/java/org/alfresco/ibatis/HierarchicalXMLConfigBuilder.java new file mode 100644 index 0000000000..f70c0f8912 --- /dev/null +++ b/src/main/java/org/alfresco/ibatis/HierarchicalXMLConfigBuilder.java @@ -0,0 +1,400 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import java.io.InputStream; +import java.util.Properties; +import javax.sql.DataSource; +import org.alfresco.util.resource.HierarchicalResourceLoader; +import org.apache.ibatis.builder.BaseBuilder; +import org.apache.ibatis.builder.BuilderException; +import org.apache.ibatis.builder.xml.XMLMapperBuilder; +import org.apache.ibatis.builder.xml.XMLMapperEntityResolver; +import org.apache.ibatis.datasource.DataSourceFactory; +import org.apache.ibatis.executor.ErrorContext; +import org.apache.ibatis.executor.loader.ProxyFactory; +import org.apache.ibatis.io.Resources; +import org.apache.ibatis.mapping.DatabaseIdProvider; +import org.apache.ibatis.mapping.Environment; +import org.apache.ibatis.parsing.XNode; +import org.apache.ibatis.parsing.XPathParser; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.reflection.DefaultReflectorFactory; +import org.apache.ibatis.reflection.MetaClass; +import org.apache.ibatis.reflection.ReflectorFactory; +import org.apache.ibatis.reflection.factory.ObjectFactory; +import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory; +import org.apache.ibatis.session.AutoMappingBehavior; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.LocalCacheScope; +import org.apache.ibatis.transaction.TransactionFactory; +import org.apache.ibatis.type.JdbcType; +import org.springframework.core.io.Resource; + + +/** + * Extends the MyBatis XMLConfigBuilder to allow the selection of a {@link org.springframework.core.io.ResourceLoader} + * that will be used to load the resources specified in the mapper's resource. + *

+ * By using the resource.dialect placeholder with hierarchical resource loading, + * different resource files can be picked up for different dialects. This reduces duplication + * when supporting multiple database configurations. + *

+ * <configuration>
+ *    <mappers>
+ *        <mapper resource="org/x/y/#resource.dialect#/View1.xml"/>
+ *        <mapper resource="org/x/y/#resource.dialect#/View2.xml"/>
+ *    </mappers>
+ * </configuration>
+ * 

+ * + * Much of the implementation is a direct copy of the MyBatis {@link org.apache.ibatis.builder.xml.XMLConfigBuilder}; some + * of the protected methods do not have access to the object's state and can therefore + * not be overridden successfully: IBATIS-589 + + * Pending a better way to extend/override, much of the implementation is a direct copy of the MyBatis + * {@link org.mybatis.spring.SqlSessionFactoryBean}; some of the protected methods do not have access to the object's state + * and can therefore not be overridden successfully. + * + * This is equivalent to HierarchicalSqlMapConfigParser which extended iBatis (2.x). + * See also: IBATIS-589 + * and: + * + * @author Derek Hulley, janv + * @since 4.0 + */ +// note: effectively extends XMLConfigBuilder to use hierarchical resource loader +public class HierarchicalXMLConfigBuilder extends BaseBuilder +{ + private boolean parsed; + private XPathParser parser; + private String environment; + private ReflectorFactory localReflectorFactory = new DefaultReflectorFactory(); + + // EXTENDED + final private HierarchicalResourceLoader resourceLoader; + + public HierarchicalXMLConfigBuilder(HierarchicalResourceLoader resourceLoader, InputStream inputStream, String environment, Properties props) + { + super(new Configuration()); + + // EXTENDED + this.resourceLoader = resourceLoader; + + ErrorContext.instance().resource("SQL Mapper Configuration"); + this.configuration.setVariables(props); + this.parsed = false; + this.environment = environment; + this.parser = new XPathParser(inputStream, true, props, new XMLMapperEntityResolver()); + } + + public Configuration parse() { + if (parsed) { + throw new BuilderException("Each XMLConfigBuilder can only be used once."); + } + parsed = true; + parseConfiguration(parser.evalNode("/configuration")); + return configuration; + } + + private void parseConfiguration(XNode root) { + try { + //issue #117 read properties first + propertiesElement(root.evalNode("properties")); + typeAliasesElement(root.evalNode("typeAliases")); + pluginElement(root.evalNode("plugins")); + objectFactoryElement(root.evalNode("objectFactory")); + objectWrapperFactoryElement(root.evalNode("objectWrapperFactory")); + reflectionFactoryElement(root.evalNode("reflectionFactory")); + settingsElement(root.evalNode("settings")); + // read it after objectFactory and objectWrapperFactory issue #631 + environmentsElement(root.evalNode("environments")); + databaseIdProviderElement(root.evalNode("databaseIdProvider")); + typeHandlerElement(root.evalNode("typeHandlers")); + mapperElement(root.evalNode("mappers")); + } catch (Exception e) { + throw new BuilderException("Error parsing SQL Mapper Configuration. Cause: " + e, e); + } + } + + private void typeAliasesElement(XNode parent) { + if (parent != null) { + for (XNode child : parent.getChildren()) { + if ("package".equals(child.getName())) { + String typeAliasPackage = child.getStringAttribute("name"); + configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage); + } else { + String alias = child.getStringAttribute("alias"); + String type = child.getStringAttribute("type"); + try { + Class clazz = Resources.classForName(type); + if (alias == null) { + typeAliasRegistry.registerAlias(clazz); + } else { + typeAliasRegistry.registerAlias(alias, clazz); + } + } catch (ClassNotFoundException e) { + throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e); + } + } + } + } + } + + private void pluginElement(XNode parent) throws Exception { + if (parent != null) { + for (XNode child : parent.getChildren()) { + String interceptor = child.getStringAttribute("interceptor"); + Properties properties = child.getChildrenAsProperties(); + Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance(); + interceptorInstance.setProperties(properties); + configuration.addInterceptor(interceptorInstance); + } + } + } + + private void objectFactoryElement(XNode context) throws Exception { + if (context != null) { + String type = context.getStringAttribute("type"); + Properties properties = context.getChildrenAsProperties(); + ObjectFactory factory = (ObjectFactory) resolveClass(type).newInstance(); + factory.setProperties(properties); + configuration.setObjectFactory(factory); + } + } + + private void objectWrapperFactoryElement(XNode context) throws Exception { + if (context != null) { + String type = context.getStringAttribute("type"); + ObjectWrapperFactory factory = (ObjectWrapperFactory) resolveClass(type).newInstance(); + configuration.setObjectWrapperFactory(factory); + } + } + + private void reflectionFactoryElement(XNode context) throws Exception { + if (context != null) { + String type = context.getStringAttribute("type"); + ReflectorFactory factory = (ReflectorFactory) resolveClass(type).newInstance(); + configuration.setReflectorFactory(factory); + } + } + + private void propertiesElement(XNode context) throws Exception { + if (context != null) { + Properties defaults = context.getChildrenAsProperties(); + String resource = context.getStringAttribute("resource"); + String url = context.getStringAttribute("url"); + if (resource != null && url != null) { + throw new BuilderException("The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other."); + } + if (resource != null) { + defaults.putAll(Resources.getResourceAsProperties(resource)); + } else if (url != null) { + defaults.putAll(Resources.getUrlAsProperties(url)); + } + Properties vars = configuration.getVariables(); + if (vars != null) { + defaults.putAll(vars); + } + parser.setVariables(defaults); + configuration.setVariables(defaults); + } + } + + private void settingsElement(XNode context) throws Exception { + if (context != null) { + Properties props = context.getChildrenAsProperties(); + // Check that all settings are known to the configuration class + MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory); + for (Object key : props.keySet()) { + if (!metaConfig.hasSetter(String.valueOf(key))) { + throw new BuilderException("The setting " + key + " is not known. Make sure you spelled it correctly (case sensitive)."); + } + } + configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(props.getProperty("autoMappingBehavior", "PARTIAL"))); + configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true)); + configuration.setProxyFactory((ProxyFactory) createInstance(props.getProperty("proxyFactory"))); + configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false)); + configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true)); + configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true)); + configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true)); + configuration.setUseGeneratedKeys(booleanValueOf(props.getProperty("useGeneratedKeys"), false)); + configuration.setDefaultExecutorType(ExecutorType.valueOf(props.getProperty("defaultExecutorType", "SIMPLE"))); + configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"), null)); + configuration.setDefaultFetchSize(integerValueOf(props.getProperty("defaultFetchSize"), null)); + configuration.setMapUnderscoreToCamelCase(booleanValueOf(props.getProperty("mapUnderscoreToCamelCase"), false)); + configuration.setSafeRowBoundsEnabled(booleanValueOf(props.getProperty("safeRowBoundsEnabled"), false)); + configuration.setLocalCacheScope(LocalCacheScope.valueOf(props.getProperty("localCacheScope", "SESSION"))); + configuration.setJdbcTypeForNull(JdbcType.valueOf(props.getProperty("jdbcTypeForNull", "OTHER"))); + configuration.setLazyLoadTriggerMethods(stringSetValueOf(props.getProperty("lazyLoadTriggerMethods"), "equals,clone,hashCode,toString")); + configuration.setSafeResultHandlerEnabled(booleanValueOf(props.getProperty("safeResultHandlerEnabled"), true)); + configuration.setDefaultScriptingLanguage(resolveClass(props.getProperty("defaultScriptingLanguage"))); + configuration.setCallSettersOnNulls(booleanValueOf(props.getProperty("callSettersOnNulls"), false)); + configuration.setLogPrefix(props.getProperty("logPrefix")); + configuration.setLogImpl(resolveClass(props.getProperty("logImpl"))); + } + } + + private void environmentsElement(XNode context) throws Exception { + if (context != null) { + if (environment == null) { + environment = context.getStringAttribute("default"); + } + for (XNode child : context.getChildren()) { + String id = child.getStringAttribute("id"); + if (isSpecifiedEnvironment(id)) { + TransactionFactory txFactory = transactionManagerElement(child.evalNode("transactionManager")); + DataSourceFactory dsFactory = dataSourceElement(child.evalNode("dataSource")); + DataSource dataSource = dsFactory.getDataSource(); + Environment.Builder environmentBuilder = new Environment.Builder(id) + .transactionFactory(txFactory) + .dataSource(dataSource); + configuration.setEnvironment(environmentBuilder.build()); + } + } + } + } + + private void databaseIdProviderElement(XNode context) throws Exception { + DatabaseIdProvider databaseIdProvider = null; + if (context != null) { + String type = context.getStringAttribute("type"); + Properties properties = context.getChildrenAsProperties(); + databaseIdProvider = (DatabaseIdProvider) resolveClass(type).newInstance(); + databaseIdProvider.setProperties(properties); + } + Environment environment = configuration.getEnvironment(); + if (environment != null && databaseIdProvider != null) { + String databaseId = databaseIdProvider.getDatabaseId(environment.getDataSource()); + configuration.setDatabaseId(databaseId); + } + } + + private TransactionFactory transactionManagerElement(XNode context) throws Exception { + if (context != null) { + String type = context.getStringAttribute("type"); + Properties props = context.getChildrenAsProperties(); + TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance(); + factory.setProperties(props); + return factory; + } + throw new BuilderException("Environment declaration requires a TransactionFactory."); + } + + private DataSourceFactory dataSourceElement(XNode context) throws Exception { + if (context != null) { + String type = context.getStringAttribute("type"); + Properties props = context.getChildrenAsProperties(); + DataSourceFactory factory = (DataSourceFactory) resolveClass(type).newInstance(); + factory.setProperties(props); + return factory; + } + throw new BuilderException("Environment declaration requires a DataSourceFactory."); + } + + private void typeHandlerElement(XNode parent) throws Exception { + if (parent != null) { + for (XNode child : parent.getChildren()) { + if ("package".equals(child.getName())) { + String typeHandlerPackage = child.getStringAttribute("name"); + typeHandlerRegistry.register(typeHandlerPackage); + } else { + String javaTypeName = child.getStringAttribute("javaType"); + String jdbcTypeName = child.getStringAttribute("jdbcType"); + String handlerTypeName = child.getStringAttribute("handler"); + Class javaTypeClass = resolveClass(javaTypeName); + JdbcType jdbcType = resolveJdbcType(jdbcTypeName); + Class typeHandlerClass = resolveClass(handlerTypeName); + if (javaTypeClass != null) { + if (jdbcType == null) { + typeHandlerRegistry.register(javaTypeClass, typeHandlerClass); + } else { + typeHandlerRegistry.register(javaTypeClass, jdbcType, typeHandlerClass); + } + } else { + typeHandlerRegistry.register(typeHandlerClass); + } + } + } + } + } + + private void mapperElement(XNode parent) throws Exception { + if (parent != null) { + for (XNode child : parent.getChildren()) { + if ("package".equals(child.getName())) { + String mapperPackage = child.getStringAttribute("name"); + configuration.addMappers(mapperPackage); + } else { + String resource = child.getStringAttribute("resource"); + String url = child.getStringAttribute("url"); + String mapperClass = child.getStringAttribute("class"); + if (resource != null && url == null && mapperClass == null) { + ErrorContext.instance().resource(resource); + + // // EXTENDED + // inputStream = Resources.getResourceAsStream(resource); + InputStream inputStream = null; + Resource res = resourceLoader.getResource(resource); + if (res != null && res.exists()) + { + inputStream = res.getInputStream(); + } + else { + throw new BuilderException("Failed to get resource: "+resource); + } + + //InputStream inputStream = Resources.getResourceAsStream(resource); + XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments()); + mapperParser.parse(); + } else if (resource == null && url != null && mapperClass == null) { + ErrorContext.instance().resource(url); + InputStream inputStream = Resources.getUrlAsStream(url); + XMLMapperBuilder mapperParser = new XMLMapperBuilder(inputStream, configuration, url, configuration.getSqlFragments()); + mapperParser.parse(); + } else if (resource == null && url == null && mapperClass != null) { + Class mapperInterface = Resources.classForName(mapperClass); + configuration.addMapper(mapperInterface); + } else { + throw new BuilderException("A mapper element may only specify a url, resource or class, but not more than one."); + } + } + } + } + } + + private boolean isSpecifiedEnvironment(String id) { + if (environment == null) { + throw new BuilderException("No environment specified."); + } else if (id == null) { + throw new BuilderException("Environment requires an id attribute."); + } else if (environment.equals(id)) { + return true; + } + return false; + } +} diff --git a/src/main/java/org/alfresco/ibatis/IdsEntity.java b/src/main/java/org/alfresco/ibatis/IdsEntity.java new file mode 100644 index 0000000000..3212b16b2c --- /dev/null +++ b/src/main/java/org/alfresco/ibatis/IdsEntity.java @@ -0,0 +1,83 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import java.util.List; + +/** + * Entity bean to carry ID-style information + * + * @author Derek Hulley + * @since 3.2 + */ +public class IdsEntity +{ + private Long idOne; + private Long idTwo; + private Long idThree; + private Long idFour; + private List ids; + public Long getIdOne() + { + return idOne; + } + public void setIdOne(Long id) + { + this.idOne = id; + } + public Long getIdTwo() + { + return idTwo; + } + public void setIdTwo(Long id) + { + this.idTwo = id; + } + public Long getIdThree() + { + return idThree; + } + public void setIdThree(Long idThree) + { + this.idThree = idThree; + } + public Long getIdFour() + { + return idFour; + } + public void setIdFour(Long idFour) + { + this.idFour = idFour; + } + public List getIds() + { + return ids; + } + public void setIds(List ids) + { + this.ids = ids; + } +} diff --git a/src/main/java/org/alfresco/ibatis/RetryingCallbackHelper.java b/src/main/java/org/alfresco/ibatis/RetryingCallbackHelper.java new file mode 100644 index 0000000000..5aae7a4ef6 --- /dev/null +++ b/src/main/java/org/alfresco/ibatis/RetryingCallbackHelper.java @@ -0,0 +1,161 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A helper that runs a unit of work, transparently retrying the unit of work if + * an error occurs. + *

+ * Defaults: + *

+ * + * @author Derek Hulley + * @since 3.4 + */ +public class RetryingCallbackHelper +{ + private static final Log logger = LogFactory.getLog(RetryingCallbackHelper.class); + + /** The maximum number of retries. -1 for infinity. */ + private int maxRetries; + /** How much time to wait with each retry. */ + private int retryWaitMs; + + /** + * Callback interface + * @author Derek Hulley + */ + public interface RetryingCallback + { + /** + * Perform a unit of work. + * + * @return Return the result of the unit of work + * @throws Throwable This can be anything and will guarantee either a retry or a rollback + */ + public Result execute() throws Throwable; + }; + + /** + * Default constructor. + */ + public RetryingCallbackHelper() + { + this.maxRetries = 5; + this.retryWaitMs = 10; + } + + /** + * Set the maximimum number of retries. -1 for infinity. + */ + public void setMaxRetries(int maxRetries) + { + this.maxRetries = maxRetries; + } + + public void setRetryWaitMs(int retryWaitMs) + { + this.retryWaitMs = retryWaitMs; + } + + /** + * Execute a callback until it succeeds, fails or until a maximum number of retries have + * been attempted. + * + * @param callback The callback containing the unit of work. + * @return Returns the result of the unit of work. + * @throws RuntimeException all checked exceptions are converted + */ + public R doWithRetry(RetryingCallback callback) + { + // Track the last exception caught, so that we can throw it if we run out of retries. + RuntimeException lastException = null; + for (int count = 0; count == 0 || count < maxRetries; count++) + { + try + { + // Do the work. + R result = callback.execute(); + if (logger.isDebugEnabled()) + { + if (count != 0) + { + logger.debug("\n" + + "Retrying work succeeded: \n" + + " Thread: " + Thread.currentThread().getName() + "\n" + + " Iteration: " + count); + } + } + return result; + } + catch (Throwable e) + { + lastException = (e instanceof RuntimeException) ? + (RuntimeException) e : + new AlfrescoRuntimeException("Exception in Transaction.", e); + if (logger.isDebugEnabled()) + { + logger.debug("\n" + + "Retrying work failed: \n" + + " Thread: " + Thread.currentThread().getName() + "\n" + + " Iteration: " + count + "\n" + + " Exception follows:", + e); + } + else if (logger.isInfoEnabled()) + { + String msg = String.format( + "Retrying %s: count %2d; wait: %3dms; msg: \"%s\"; exception: (%s)", + Thread.currentThread().getName(), + count, retryWaitMs, + e.getMessage(), + e.getClass().getName()); + logger.info(msg); + } + try + { + Thread.sleep(retryWaitMs); + } + catch (InterruptedException ie) + { + // Do nothing. + } + // Try again + continue; + } + } + // We've worn out our welcome and retried the maximum number of times. + // So, fail. + throw lastException; + } +} diff --git a/src/main/java/org/alfresco/ibatis/RollupResultHandler.java b/src/main/java/org/alfresco/ibatis/RollupResultHandler.java new file mode 100644 index 0000000000..3fe1d00638 --- /dev/null +++ b/src/main/java/org/alfresco/ibatis/RollupResultHandler.java @@ -0,0 +1,258 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import org.apache.ibatis.executor.result.DefaultResultContext; +import org.apache.ibatis.reflection.MetaObject; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; + +/** + * A {@link ResultHandler} that collapses multiple rows based on a set of properties. + *

+ * This class is derived from earlier RollupRowHandler used to workaround the groupBy and nested ResultMap + * behaviour in iBatis (2.3.4.726) IBATIS-503. + *

+ * The set of properties given act as a unique key. When the unique key changes, the collection + * values from the nested ResultMap are coalesced and the given {@link ResultHandler} is called. It is + * possible to embed several instances of this handler for deeply-nested ResultMap declarations. + *

+ * Use this instance as a regular {@link ResultHandler}, but with one big exception: call {@link #processLastResults()} + * after executing the SQL statement. Remove the groupBy attribute from the iBatis ResultMap + * declaration. + *

+ * Example iBatis 2.x (TODO migrate example to MyBatis 3.x): + *

+    <resultMap id="result_AuditQueryAllValues"
+               extends="alfresco.audit.result_AuditQueryNoValues"
+               class="AuditQueryResult">
+        <result property="auditValues" resultMap="alfresco.propval.result_PropertyIdSearchRow"/>
+    </resultMap>
+ * 
+ * Example usage: + *
+        RowHandler rowHandler = new RowHandler()
+        {
+            public void handleRow(Object valueObject)
+            {
+                // DO SOMETHING
+            }
+        };
+        RollupRowHandler rollupRowHandler = new RollupRowHandler(
+                new String[] {"auditEntryId"},
+                "auditValues",
+                rowHandler,
+                maxResults);
+        
+        if (maxResults > 0)
+        {
+            // Calculate the maximum results required
+            int sqlMaxResults = (maxResults > 0 ? ((maxResults+1) * 20) : Integer.MAX_VALUE);
+            
+            List rows = template.queryForList(SELECT_ENTRIES_WITH_VALUES, params, 0, sqlMaxResults);
+            for (AuditQueryResult row : rows)
+            {
+                rollupRowHandler.handleRow(row);
+            }
+            // Don't process last result:
+            //    rollupRowHandler.processLastResults();
+            //    The last result may be incomplete
+        }
+        else
+        {
+            template.queryWithRowHandler(SELECT_ENTRIES_WITH_VALUES, params, rollupRowHandler);
+            rollupRowHandler.processLastResults();
+        }
+ * 
+ *

+ * This class is not thread-safe; use a new instance for each use. + * + * @author Derek Hulley, janv + * @since 4.0 + */ +public class RollupResultHandler implements ResultHandler +{ + private final String[] keyProperties; + private final String collectionProperty; + private final ResultHandler resultHandler; + private final int maxResults; + + private Object[] lastKeyValues; + private List rawResults; + private int resultCount; + + private Configuration configuration; + + /** + * @param keyProperties the properties that make up the unique key + * @param collectionProperty the property mapped using a nested ResultMap + * @param resultHandler the result handler that will receive the rolled-up results + */ + public RollupResultHandler(Configuration configuration, String[] keyProperties, String collectionProperty, ResultHandler resultHandler) + { + this(configuration, keyProperties, collectionProperty, resultHandler, Integer.MAX_VALUE); + } + + /** + * @param keyProperties the properties that make up the unique key + * @param collectionProperty the property mapped using a nested ResultMap + * @param resultHandler the result handler that will receive the rolled-up results + * @param maxResults the maximum number of results to retrieve (-1 for no limit). + * Make sure that the query result limit is large enough to produce this + * at least this number of results + */ + public RollupResultHandler(Configuration configuration, String[] keyProperties, String collectionProperty, ResultHandler resultHandler, int maxResults) + { + if (keyProperties == null || keyProperties.length == 0) + { + throw new IllegalArgumentException("RollupRowHandler can only be used with at least one key property."); + } + if (collectionProperty == null) + { + throw new IllegalArgumentException("RollupRowHandler must have a collection property."); + } + this.configuration = configuration; + this.keyProperties = keyProperties; + this.collectionProperty = collectionProperty; + this.resultHandler = resultHandler; + this.maxResults = maxResults; + this.rawResults = new ArrayList(100); + } + + public void handleResult(ResultContext context) + { + // Shortcut if we have processed enough results + if (maxResults > 0 && resultCount >= maxResults) + { + return; + } + + Object valueObject = context.getResultObject(); + MetaObject probe = configuration.newMetaObject(valueObject); + + // Check if the key has changed + if (lastKeyValues == null) + { + lastKeyValues = getKeyValues(probe); + resultCount = 0; + } + // Check if it has changed + Object[] currentKeyValues = getKeyValues(probe); + if (!Arrays.deepEquals(lastKeyValues, currentKeyValues)) + { + // Key has changed, so handle the results + Object resultObject = coalesceResults(configuration, rawResults, collectionProperty); + if (resultObject != null) + { + DefaultResultContext resultContext = new DefaultResultContext(); + resultContext.nextResultObject(resultObject); + + resultHandler.handleResult(resultContext); + resultCount++; + } + rawResults.clear(); + lastKeyValues = currentKeyValues; + } + // Add the new value to the results for next time + rawResults.add(valueObject); + // Done + } + + /** + * Client code must call this method once the query returns so that the final results + * can be passed to the inner RowHandler. If a query is limited by size, then it is + * possible that the unprocessed results represent an incomplete final object; in this case + * it would be best to ignore the last results. If the query is complete (i.e. all results + * are returned) then this method should be called. + *

+ * If you want X results and each result is made up of N rows (on average), then set the query + * limit to:
+ * L = X * (N+1)
+ * and don't call this method. + */ + public void processLastResults() + { + // Shortcut if we have processed enough results + if (maxResults > 0 && resultCount >= maxResults) + { + return; + } + // Handle any outstanding results + Object resultObject = coalesceResults(configuration, rawResults, collectionProperty); + if (resultObject != null) + { + DefaultResultContext resultContext = new DefaultResultContext(); + resultContext.nextResultObject(resultObject); + + resultHandler.handleResult(resultContext); + resultCount++; + rawResults.clear(); // Stop it from being used again + } + } + + @SuppressWarnings("unchecked") + private static Object coalesceResults(Configuration configuration, List valueObjects, String collectionProperty) + { + // Take the first result as the base value + Object resultObject = null; + MetaObject probe = null; + Collection collection = null; + for (Object object : valueObjects) + { + if (collection == null) + { + resultObject = object; + probe = configuration.newMetaObject(resultObject); + collection = (Collection) probe.getValue(collectionProperty); + } + else + { + Collection addedValues = (Collection) probe.getValue(collectionProperty); + collection.addAll(addedValues); + } + } + // Done + return resultObject; + } + + /** + * @return Returns the values for the {@link RollupResultHandler#keyProperties} + */ + private Object[] getKeyValues(MetaObject probe) + { + Object[] keyValues = new Object[keyProperties.length]; + for (int i = 0; i < keyProperties.length; i++) + { + keyValues[i] = probe.getValue(keyProperties[i]); + } + return keyValues; + } +} diff --git a/src/main/java/org/alfresco/ibatis/SerializableTypeHandler.java b/src/main/java/org/alfresco/ibatis/SerializableTypeHandler.java new file mode 100644 index 0000000000..25c826df75 --- /dev/null +++ b/src/main/java/org/alfresco/ibatis/SerializableTypeHandler.java @@ -0,0 +1,191 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.TypeHandler; + +/** + * MyBatis 3.x TypeHandler for java.io.Serializable to BLOB types. + * + * @author Derek Hulley, janv + * @since 4.0 + */ +public class SerializableTypeHandler implements TypeHandler +{ + public static final int DEFAULT_SERIALIZABLE_TYPE = Types.LONGVARBINARY; + private static volatile int serializableType = DEFAULT_SERIALIZABLE_TYPE; + + /** + * @see Types + */ + public static void setSerializableType(int serializableType) + { + SerializableTypeHandler.serializableType = serializableType; + } + + /** + * @return Returns the SQL type to use for serializable columns + */ + public static int getSerializableType() + { + return serializableType; + } + + /** + * @throws DeserializationException if the object could not be deserialized + */ + public Object getResult(ResultSet rs, String columnName) throws SQLException + { + final Serializable ret; + try + { + InputStream is = rs.getBinaryStream(columnName); + if (is == null || rs.wasNull()) + { + return null; + } + // Get the stream and deserialize + ObjectInputStream ois = new ObjectInputStream(is); + Object obj = ois.readObject(); + // Success + ret = (Serializable) obj; + } + catch (Throwable e) + { + throw new DeserializationException(e); + } + return ret; + } + + @Override + public Object getResult(ResultSet rs, int columnIndex) throws SQLException + { + final Serializable ret; + try + { + InputStream is = rs.getBinaryStream(columnIndex); + if (is == null || rs.wasNull()) + { + return null; + } + // Get the stream and deserialize + ObjectInputStream ois = new ObjectInputStream(is); + Object obj = ois.readObject(); + // Success + ret = (Serializable) obj; + } + catch (Throwable e) + { + throw new DeserializationException(e); + } + return ret; + } + + public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException + { + if (parameter == null) + { + ps.setNull(i, SerializableTypeHandler.serializableType); + } + else + { + try + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(parameter); + byte[] bytes = baos.toByteArray(); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + ps.setBinaryStream(i, bais, bytes.length); + } + catch (Throwable e) + { + throw new SerializationException(e); + } + } + } + + public Object getResult(CallableStatement cs, int columnIndex) throws SQLException + { + throw new UnsupportedOperationException("Unsupported"); + } + + /** + * @return Returns the value given + */ + public Object valueOf(String s) + { + return s; + } + + /** + * Marker exception to allow deserialization issues to be dealt with by calling code. + * If this exception remains uncaught, it will be very difficult to find and rectify + * the data issue. + * + * @author Derek Hulley + * @since 3.2 + */ + public static class DeserializationException extends RuntimeException + { + private static final long serialVersionUID = 4673487701048985340L; + + public DeserializationException(Throwable cause) + { + super(cause); + } + } + + /** + * Marker exception to allow serialization issues to be dealt with by calling code. + * Unlike with {@link DeserializationException deserialization}, it is not important + * to handle this exception neatly. + * + * @author Derek Hulley + * @since 3.2 + */ + public static class SerializationException extends RuntimeException + { + private static final long serialVersionUID = 962957884262870228L; + + public SerializationException(Throwable cause) + { + super(cause); + } + } +} diff --git a/src/main/java/org/alfresco/mbeans/ConnectorServerFactory.java b/src/main/java/org/alfresco/mbeans/ConnectorServerFactory.java new file mode 100644 index 0000000000..8bee7add64 --- /dev/null +++ b/src/main/java/org/alfresco/mbeans/ConnectorServerFactory.java @@ -0,0 +1,97 @@ +/* + * #%L + * Alfresco MBeans + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.mbeans; + +import java.io.IOException; +import javax.management.JMException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.jmx.support.ConnectorServerFactoryBean; + +/** + * Factory that creates a JSR-160 JMXConnectorServer, + * optionally registers it with the MBeanServer and then starts it. + * + * @author Stas Sokolovsky + */ +public class ConnectorServerFactory extends ConnectorServerFactoryBean +{ + private static Log logger = LogFactory.getLog(ConnectorServerFactory.class); + + private boolean enabled = false; + + public boolean isEnabled() + { + return enabled; + } + + /** + * Enables JMX connectivity during initialization, see {@link ConnectorServerFactory#afterPropertiesSet()} + * @param enabled boolean + */ + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + /** + * Wraps original initialization method to log errors, rather than having + * exceptions occur within the Spring framework itself (this would cause the entire webapp to fail) + * + * @see org.springframework.jmx.support.ConnectorServerFactoryBean#afterPropertiesSet() + */ + @Override + public void afterPropertiesSet() throws JMException, IOException + { + try + { + if (enabled) + { + super.afterPropertiesSet(); + + if (logger.isInfoEnabled()) + { + logger.info("Created JMX serverConnector"); + } + } + else + { + if (logger.isInfoEnabled()) + { + logger.info("JMX serverConnector is disabled."); + } + } + + } + catch (Exception e) + { + if (logger.isWarnEnabled()) + { + logger.warn("JMX ServerConnector can't be initialized due to: ", e); + } + } + } +} diff --git a/src/main/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java b/src/main/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java index e8ccb932fb..4ecb0fbc83 100644 --- a/src/main/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java +++ b/src/main/java/org/alfresco/repo/action/scheduled/AbstractScheduledAction.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.scheduled; import java.util.ArrayList; @@ -38,6 +38,7 @@ import org.alfresco.service.transaction.TransactionService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.quartz.Job; +import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; @@ -366,12 +367,11 @@ public abstract class AbstractScheduledAction implements ScheduledActionDefiniti { JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put(ACTION_JOB_DATA_MAP_KEY, this); - - JobDetail jobDetail = new JobDetail(); - jobDetail.setName(getJobName()); - jobDetail.setGroup(getJobGroup()); - jobDetail.setJobDataMap(jobDataMap); - jobDetail.setJobClass(JobDefinition.class); + final JobDetail jobDetail = JobBuilder.newJob() + .withIdentity(getJobName(), getJobGroup()) + .usingJobData(jobDataMap) + .ofType(JobDefinition.class) + .build(); return jobDetail; } diff --git a/src/main/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinition.java b/src/main/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinition.java index 0d35ee1a9f..69b1bf1177 100644 --- a/src/main/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinition.java +++ b/src/main/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinition.java @@ -1,34 +1,32 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.scheduled; -import java.text.ParseException; import java.util.LinkedList; import java.util.List; - import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; @@ -37,9 +35,10 @@ import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSetRow; import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchService; -import org.quartz.CronTrigger; +import org.quartz.CronScheduleBuilder; import org.quartz.Scheduler; import org.quartz.Trigger; +import org.quartz.TriggerBuilder; /** * A scheduled action for which the trigger is defined in the standard cron format and the nodes to which the action @@ -206,9 +205,13 @@ public class CronScheduledQueryBasedTemplateActionDefinition extends AbstractSch { try { - return new CronTrigger(getTriggerName(), getTriggerGroup(), getCronExpression()); + return TriggerBuilder.newTrigger() + .withIdentity(getTriggerName(), getTriggerGroup()) + .withSchedule(CronScheduleBuilder.cronSchedule(getCronExpression())) + .build(); } - catch (final ParseException e) + // CronScheduleBuilder is throwing RuntimeException which is wrapping ParseException + catch (final RuntimeException e) { throw new InvalidCronExpression("Invalid chron expression: n" + getCronExpression()); } diff --git a/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionImpl.java b/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionImpl.java index 477637bfce..26198b318c 100644 --- a/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionImpl.java +++ b/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionImpl.java @@ -30,9 +30,10 @@ import java.util.Date; import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.scheduled.ScheduledPersistedAction; import org.alfresco.service.cmr.repository.NodeRef; -import org.quartz.DateIntervalTrigger; -import org.quartz.SimpleTrigger; +import org.quartz.CalendarIntervalScheduleBuilder; +import org.quartz.SimpleScheduleBuilder; import org.quartz.Trigger; +import org.quartz.TriggerBuilder; /** * The scheduling wrapper around a persisted @@ -268,13 +269,17 @@ public class ScheduledPersistedActionImpl implements ScheduledPersistedAction // So, don't run it return null; } - + // Based on the start time, when would it next be // due to fire? - DateIntervalTrigger testT = buildDateIntervalTrigger("TEST", scheduleStart, null); + Trigger testT = TriggerBuilder.newTrigger() + .withIdentity("TEST") + .withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule()) + .startAt(scheduleStart) + .build(); Date nextFireFromNow = testT.getFireTimeAfter(new Date()); Date nextFireFromLast = testT.getFireTimeAfter(lastExecutedAt); - + // If the next fire time from the last is before the // next due date, then we missed one if(nextFireFromLast.getTime() < nextFireFromNow.getTime()) @@ -293,38 +298,29 @@ public class ScheduledPersistedActionImpl implements ScheduledPersistedAction } } } - - - // If they don't want it to repeat, just use a simple interval - if(getScheduleInterval() == null) - { - SimpleTrigger trigger = new SimpleTrigger( - triggerName, null, - startAt - ); - trigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW); - return trigger; - } - - return buildDateIntervalTrigger(triggerName, startAt, endAt); - } - - private DateIntervalTrigger buildDateIntervalTrigger(String triggerName, Date startAt, Date endAt) - { - // There are some repeating rules - // Create a Date Interval trigger - DateIntervalTrigger.IntervalUnit quartzInterval = - DateIntervalTrigger.IntervalUnit.valueOf( - intervalPeriod.toString().toUpperCase() - ); - - // Create the interval - DateIntervalTrigger trigger = new DateIntervalTrigger( - triggerName, null, - startAt, endAt, - quartzInterval, intervalCount - ); - trigger.setMisfireInstruction( DateIntervalTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW ); - return trigger; + + Trigger trigger; + if(getScheduleInterval() == null) + { + trigger = TriggerBuilder.newTrigger() + .withIdentity(triggerName) + .startAt(startAt) + .withSchedule( + SimpleScheduleBuilder.simpleSchedule() + .withMisfireHandlingInstructionFireNow()) + .build(); + } + else + { + trigger = TriggerBuilder.newTrigger() + .withIdentity(triggerName) + .startAt(startAt) + .endAt(endAt) + .withSchedule( + CalendarIntervalScheduleBuilder.calendarIntervalSchedule() + .withMisfireHandlingInstructionFireAndProceed()) + .build(); + } + return trigger; } } diff --git a/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceImpl.java b/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceImpl.java index 09be60ed80..94fdd92685 100644 --- a/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceImpl.java +++ b/src/main/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceImpl.java @@ -60,8 +60,11 @@ import org.alfresco.util.transaction.TransactionListenerAdapter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.quartz.Job; +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; +import org.quartz.JobKey; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.Trigger; @@ -409,7 +412,7 @@ public class ScheduledPersistedActionServiceImpl implements ScheduledPersistedAc // Ask to remove it try { - scheduler.deleteJob(schedule.getPersistedAtNodeRef().toString(), SCHEDULER_GROUP); + scheduler.deleteJob(new JobKey(schedule.getPersistedAtNodeRef().toString(), SCHEDULER_GROUP)); } catch (SchedulerException e) { @@ -453,24 +456,14 @@ public class ScheduledPersistedActionServiceImpl implements ScheduledPersistedAc protected JobDetail buildJobDetail(ScheduledPersistedActionImpl schedule) { - // Build the details - JobDetail detail = new JobDetail(schedule.getPersistedAtNodeRef().toString(), - SCHEDULER_GROUP, - ScheduledJobWrapper.class - ); - - // Record the action that is to be executed - detail.getJobDataMap().put( - JOB_ACTION_NODEREF, - schedule.getActionNodeRef().toString() - ); - detail.getJobDataMap().put( - JOB_SCHEDULE_NODEREF, - schedule.getPersistedAtNodeRef().toString() - ); - - // All done - return detail; + JobDataMap jobDataMap = new JobDataMap(); + jobDataMap.put(JOB_ACTION_NODEREF, schedule.getActionNodeRef().toString()); + jobDataMap.put(JOB_SCHEDULE_NODEREF, schedule.getPersistedAtNodeRef().toString()); + return JobBuilder.newJob() + .withIdentity(schedule.getPersistedAtNodeRef().toString(), SCHEDULER_GROUP) + .ofType(ScheduledJobWrapper.class) + .setJobData(jobDataMap) + .build(); } diff --git a/src/main/java/org/alfresco/repo/admin/UnserializerValidatorBootstrap.java b/src/main/java/org/alfresco/repo/admin/UnserializerValidatorBootstrap.java deleted file mode 100644 index 5eb3784336..0000000000 --- a/src/main/java/org/alfresco/repo/admin/UnserializerValidatorBootstrap.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.admin; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Properties; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.context.ApplicationEvent; -import org.springframework.extensions.surf.util.AbstractLifecycleBean; - -/** - * Bootstrap unserializer validator: a bootstrap bean that checks that the - * classes that would favor Java unserialize remote code execution are not - * available. Check is needed because libs could be introduced by the - * application server. - * - *

See MNT-15170 for details. - * - *

Checked conditions:
- * org.apache.xalan.xsltc.trax.TemplatesImpl and - * org.springframework.core.SerializableTypeWrapper;
- * org.apache.commons.collections.functors.InvokerTransformer - * org.apache.commons.collections.functors.InstantiateFactory - * org.apache.commons.collections.functors.InstantiateTransformer - * org.apache.commons.collections.functors.PrototypeCloneFactory - * org.apache.commons.collections.functors.PrototypeSerializationFactory - * org.apache.commons.collections.functors.WhileClosure - * org.apache.commons.collections.functors.CloneTransformer - * org.apache.commons.collections.functors.ForClosure - */ -public class UnserializerValidatorBootstrap extends AbstractLifecycleBean -{ - - private static Log logger = LogFactory.getLog(UnserializerValidatorBootstrap.class); - - /** The name of the global enablement property. */ - public static final String PROPERTY_UNSERIALIZER_VALIDATOR_ENABLED = "unserializer.validator.enabled"; - - private static final String ERR_UNEXPECTED_ERROR = "unserializer.validator.err.unexpectederror"; - - // Bootstrap performed? - private boolean bootstrapPerformed = false; - - private Properties properties = null; - /** - * @deprecated Was never used - */ - public void setLog(boolean logEnabled) - { - // Ignore - } - - /** - * Determine if bootstrap was performed? - * - * @return true => bootstrap was performed - */ - public boolean hasPerformedBootstrap() - { - return bootstrapPerformed; - } - - public void setProperties(Properties properties) - { - this.properties = properties; - } - - private boolean classInPath(String className) - { - try - { - Class.forName(className, false, this.getClass().getClassLoader()); - - // it exists on the classpath - return true; - } - catch (ClassNotFoundException e) - { - - // it does not exist on the classpath - return false; - } - } - - /** - * Check if Java unserialize remote code execution is already fixed on this - * commons collections version. - * - * @return - */ - private boolean isCommonsCollectionsDeserializerFixed() - { - - try - { - Class invokerTransformerClass = Class.forName( - "org.apache.commons.collections.functors.InvokerTransformer", true, this - .getClass().getClassLoader()); - - if (invokerTransformerClass != null) - { - Constructor invokerTransformerConstructor = invokerTransformerClass - .getConstructor(String.class, Class[].class, Object[].class); - - Object invokerTransformerInstance = invokerTransformerConstructor.newInstance(null, - null, null); - - ObjectOutputStream objectOut = null; - ByteArrayOutputStream byteOut = null; - try - { - // Write the object out to a byte array - byteOut = new ByteArrayOutputStream(); - objectOut = new ObjectOutputStream(byteOut); - objectOut.writeObject(invokerTransformerInstance); - objectOut.flush(); - } - catch (UnsupportedOperationException e) - { - // Expected: Serialization support is disabled for security - // reasons. - return true; - } - catch (IOException e) - { - throw new AlfrescoRuntimeException(ERR_UNEXPECTED_ERROR, e); - } - finally - { - if (objectOut != null) - { - try - { - objectOut.close(); - } - catch (Throwable e) - { - } - } - if (byteOut != null) - { - try - { - byteOut.close(); - } - catch (Throwable e) - { - } - } - } - } - } - catch (SecurityException e) - { - // This is and expected, acceptable exception that we can ignore. - } - catch (ClassNotFoundException e) - { - // This is and expected, acceptable exception that we can ignore. - } - catch (InstantiationException e) - { - // This is and expected, acceptable exception that we can ignore. - } - catch (IllegalAccessException e) - { - // This is and expected, acceptable exception that we can ignore. - } - catch (NoSuchMethodException e) - { - throw new AlfrescoRuntimeException(ERR_UNEXPECTED_ERROR, e); - } - catch (IllegalArgumentException e) - { - throw new AlfrescoRuntimeException(ERR_UNEXPECTED_ERROR, e); - } - catch (InvocationTargetException e) - { - // This is and expected, acceptable exception that we can ignore. - } - - return false; - } - - private void validate() - { - if (classInPath("org.apache.xalan.xsltc.trax.TemplatesImpl") && classInPath("org.springframework.core.SerializableTypeWrapper")) - { - throw new AlfrescoRuntimeException( - "Bootstrap failed: both org.apache.xalan.xsltc.trax.TemplatesImpl and org.springframework.core.SerializableTypeWrapper appear at the same time in classpath "); - } - - // Check if Java unserialize remote code execution is available and not - // fixed on this commons collections - if ((classInPath("org.apache.commons.collections.functors.InvokerTransformer") - || classInPath("org.apache.commons.collections.functors.InstantiateFactory") - || classInPath("org.apache.commons.collections.functors.InstantiateTransformer") - || classInPath("org.apache.commons.collections.functors.PrototypeCloneFactory") - || classInPath("org.apache.commons.collections.functors.PrototypeSerializationFactory") - || classInPath("org.apache.commons.collections.functors.WhileClosure") - || classInPath("org.apache.commons.collections.functors.CloneTransformer") || classInPath("org.apache.commons.collections.functors.ForClosure")) - && !isCommonsCollectionsDeserializerFixed()) - { - throw new AlfrescoRuntimeException( - "Bootstrap failed: org.apache.commons.collections.functors.* unsafe serialization classes found in classpath."); - } - } - - private boolean isUnserializerValidatorEnabled() - { - return getBooleanProperty(PROPERTY_UNSERIALIZER_VALIDATOR_ENABLED, true); - } - - private boolean getBooleanProperty(String name, boolean defaultValue) - { - boolean value = defaultValue; - if (properties != null) - { - String property = properties.getProperty(name); - if (property != null) - { - value = !property.trim().equalsIgnoreCase("false"); - } - } - return value; - } - - /** - * Bootstrap unserializer validator. - */ - public void bootstrap() - { - if (isUnserializerValidatorEnabled()) - { - validate(); - } - else - { - logger.warn("Unserializer validator is disabled"); - } - - // a bootstrap was performed - bootstrapPerformed = true; - } - - @Override - protected void onBootstrap(ApplicationEvent event) - { - bootstrap(); - } - - @Override - protected void onShutdown(ApplicationEvent event) - { - // NOOP - } - -} diff --git a/src/main/java/org/alfresco/repo/admin/patch/impl/CalendarAllDayEventDatesCorrectingPatch.java b/src/main/java/org/alfresco/repo/admin/patch/impl/CalendarAllDayEventDatesCorrectingPatch.java index 6543f4ae5f..49aa509b3b 100644 --- a/src/main/java/org/alfresco/repo/admin/patch/impl/CalendarAllDayEventDatesCorrectingPatch.java +++ b/src/main/java/org/alfresco/repo/admin/patch/impl/CalendarAllDayEventDatesCorrectingPatch.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.admin.patch.impl; import java.util.Calendar; diff --git a/src/main/java/org/alfresco/repo/admin/patch/impl/LinkNodeFileExtensionPatch.java b/src/main/java/org/alfresco/repo/admin/patch/impl/LinkNodeFileExtensionPatch.java deleted file mode 100644 index 462441e8d5..0000000000 --- a/src/main/java/org/alfresco/repo/admin/patch/impl/LinkNodeFileExtensionPatch.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.admin.patch.impl; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.sql.Savepoint; -import java.util.Date; -import java.util.List; - -import org.alfresco.model.ContentModel; -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.domain.control.ControlDAO; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.util.Pair; -import org.alfresco.util.TempFileProvider; -import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -/** - * Checks that all names do not end with ' ' or '.' - * - * @author David Caruana - */ -public class LinkNodeFileExtensionPatch extends AbstractPatch -{ - private static final String MSG_SUCCESS = "patch.linkNodeExtension.result"; - private static final String MSG_REWRITTEN = "patch.linkNodeExtension.rewritten"; - private static final String ERR_UNABLE_TO_FIX = "patch.linkNodeExtension.err.unable_to_fix"; - - private PatchDAO patchDAO; - private ControlDAO controlDAO; - private NodeService nodeService; - - /** - * Default constructor - */ - public LinkNodeFileExtensionPatch() - { - } - - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - public void setControlDAO(ControlDAO controlDAO) - { - this.controlDAO = controlDAO; - } - - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - @Override - protected void checkProperties() - { - super.checkProperties(); - checkPropertyNotNull(patchDAO, "patchDAO"); - checkPropertyNotNull(nodeService, "nodeService"); - } - - @Override - protected String applyInternal() throws Exception - { - LinkNodeFileExtensionHelper helper = new LinkNodeFileExtensionHelper(); - - try - { - return helper.fixNames(); - } - finally - { - helper.closeWriter(); - } - } - - private class LinkNodeFileExtensionHelper extends HibernateDaoSupport - { - private File logFile; - private FileChannel channel; - - private LinkNodeFileExtensionHelper() throws IOException - { - // Open a log file - File tempDir = TempFileProvider.getLongLifeTempDir("patches"); - logFile = new File(tempDir, "LinkNodeExtensionPatch.log"); - - RandomAccessFile outputFile = new RandomAccessFile(logFile, "rw"); - channel = outputFile.getChannel(); - - // Append to the end of the file - - channel.position(channel.size()); - - writeLine("").writeLine(""); - writeLine("LinkNodeExtensionPatch executing on " + new Date()); - } - - private LinkNodeFileExtensionHelper write(Object obj) throws IOException - { - channel.write(ByteBuffer.wrap(obj.toString().getBytes())); - return this; - } - private LinkNodeFileExtensionHelper writeLine(Object obj) throws IOException - { - write(obj); - write("\n"); - return this; - } - private void closeWriter() - { - try { channel.close(); } catch (Throwable e) {} - } - - public String fixNames() throws Exception - { - List> names = patchDAO.getNodesOfTypeWithNamePattern(ContentModel.TYPE_LINK, "%.lnk"); - - int updated = 0; - for (Pair pair : names) - { - NodeRef nodeRef = pair.getFirst(); - String name = pair.getSecond(); - // Update the name string, replace '.lnk' with '.url' - String updatedName = name.substring(0, name.length() - 4) + ".url"; - int idx = 0; - boolean applied = false; - while (!applied && idx < 10) - { - Savepoint savepoint = controlDAO.createSavepoint("LinkNodeFileExtensionsFix"); - try - { - nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, updatedName); - controlDAO.releaseSavepoint(savepoint); - applied = true; - } - catch(DuplicateChildNodeNameException e) - { - controlDAO.rollbackToSavepoint(savepoint); - idx++; - updatedName += "_" + idx; - } - } - if (applied) - { - writeLine(I18NUtil.getMessage(MSG_REWRITTEN, name ,updatedName)); - } - else - { - writeLine(I18NUtil.getMessage(ERR_UNABLE_TO_FIX, name, updatedName)); - } - updated++; - } - - String msg = I18NUtil.getMessage(MSG_SUCCESS, updated, logFile); - return msg; - } - } -} diff --git a/src/main/java/org/alfresco/repo/cache/DefaultCacheProvider.java b/src/main/java/org/alfresco/repo/cache/DefaultCacheProvider.java deleted file mode 100644 index e7fa8f5701..0000000000 --- a/src/main/java/org/alfresco/repo/cache/DefaultCacheProvider.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.cache; - -import java.io.Serializable; -import java.util.Properties; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.cache.Cache; -import org.hibernate.cache.CacheException; -import org.hibernate.cache.CacheProvider; -import org.hibernate.cache.Timestamper; - -/** - * A simple {@link CacheProvider} that allows Hibernate to create {@link DefaultSimpleCache} - * based caches. - * - * @author Matt Ward - */ -public class DefaultCacheProvider implements CacheProvider -{ - private final static Log log = LogFactory.getLog(DefaultCacheProvider.class); - // TODO: setup in spring (SystemPropertiesSetterBean) - private int defaultMaxItems = 500; - - @Override - public Cache buildCache(String regionName, Properties properties) throws CacheException - { - if (log.isDebugEnabled()) - { - log.debug("building cache for regionName=" + regionName + ", with properties: " + properties); - } - DefaultSimpleCache cache = new DefaultSimpleCache(defaultMaxItems, null); - Cache hibCache = new HibernateSimpleCacheAdapter(cache, regionName); - return hibCache; - } - - @Override - public long nextTimestamp() - { - return Timestamper.next(); - } - - @Override - public void start(Properties properties) throws CacheException - { - log.debug("Starting cache provider"); - } - - @Override - public void stop() - { - log.debug("Stopping cache provider"); - } - - @Override - public boolean isMinimalPutsEnabledByDefault() - { - return false; - } - -} diff --git a/src/main/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java b/src/main/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java deleted file mode 100644 index 52045550f2..0000000000 --- a/src/main/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.cache; - -import java.io.Serializable; -import java.util.Map; - -import org.hibernate.cache.Cache; -import org.hibernate.cache.CacheException; -import org.hibernate.cache.Timestamper; - -/** - * Adapts a {@link SimpleCache} instance for use as a Hibernate {@link Cache}. - * - * @author Matt Ward - */ -public class HibernateSimpleCacheAdapter implements Cache -{ - private final SimpleCache cache; - private final String regionName; - - /** - * Adapt a - * @param regionName String - */ - public HibernateSimpleCacheAdapter(SimpleCache cache, String regionName) - { - this.cache = cache; - this.regionName = regionName; - } - - @Override - public Object read(Object key) throws CacheException - { - return cache.get(serializable(key)); - } - - @Override - public Object get(Object key) throws CacheException - { - return cache.get(serializable(key)); - } - - @Override - public void put(Object key, Object value) throws CacheException - { - cache.put(serializable(key), value); - } - - @Override - public void update(Object key, Object value) throws CacheException - { - cache.put(serializable(key), value); - } - - @Override - public void remove(Object key) throws CacheException - { - cache.remove(serializable(key)); - } - - @Override - public void clear() throws CacheException - { - cache.clear(); - } - - @Override - public void destroy() throws CacheException - { - // NoOp - } - - @Override - public void lock(Object key) throws CacheException - { - // NoOp - } - - @Override - public void unlock(Object key) throws CacheException - { - // NoOp - } - - @Override - public long nextTimestamp() - { - return Timestamper.next(); - } - - @Override - public int getTimeout() - { - return Timestamper.ONE_MS * 60000; // 1 minute - } - - @Override - public String getRegionName() - { - return regionName; - } - - @Override - public long getSizeInMemory() - { - return -1; - } - - @Override - public long getElementCountInMemory() - { - return -1; - } - - @Override - public long getElementCountOnDisk() - { - return 0; - } - - @Override - public Map toMap() - { - throw new UnsupportedOperationException(); - } - - private Serializable serializable(Object obj) - { - if (!(obj instanceof Serializable)) - { - throw new IllegalArgumentException("Object is not Serializable, class=" + obj.getClass().getName()); - } - return (Serializable) obj; - } - -} diff --git a/src/main/java/org/alfresco/repo/cache/TransactionalCache.java b/src/main/java/org/alfresco/repo/cache/TransactionalCache.java index 7fc9d6f63e..043ad72c1d 100644 --- a/src/main/java/org/alfresco/repo/cache/TransactionalCache.java +++ b/src/main/java/org/alfresco/repo/cache/TransactionalCache.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.cache; import java.io.Serializable; @@ -45,9 +45,10 @@ import org.alfresco.util.PropertyCheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; +import org.springframework.transaction.support.TransactionSynchronizationManager; /** - * A 2-level cache that mainains both a transaction-local cache and + * A 2-level cache that maintains both a transaction-local cache and * wraps a non-transactional (shared) cache. *

* It uses the shared SimpleCache for it's per-transaction @@ -58,7 +59,7 @@ import org.springframework.beans.factory.InitializingBean; * virtually no overhead when running out-of-transaction. *

* The first phase of the commit ensures that any values written to the cache in the - * current transaction are not already superceded by values in the shared cache. In + * current transaction are not already superseded by values in the shared cache. In * this case, the transaction is failed for concurrency reasons and will have to retry. * The second phase occurs post-commit. We are sure that the transaction committed * correctly, but things may have changed in the cache between the commit and post-commit. @@ -273,7 +274,12 @@ public class TransactionalCache // ensure that we get the transaction callbacks as we have bound the unique // transactional caches to a common manager - AlfrescoTransactionSupport.bindListener(this); + // The synchronizations are not available after the txn is committed/rolled back + // the resources are still stored in org.alfresco.util.transaction.TransactionSupportUtil + if (TransactionSynchronizationManager.isSynchronizationActive()) + { + AlfrescoTransactionSupport.bindListener(this); + } AlfrescoTransactionSupport.bindResource(resourceKeyTxnData, data); } return data; @@ -738,17 +744,17 @@ public class TransactionalCache // data by clearing the shared cache after the transaction. Also, the // shared cache needs to be ignored for the rest of the transaction. txnData.isClearOn = true; - if (!txnData.haveIssuedFullWarning) + if (!txnData.haveIssuedFullWarning) { - if (logger.isInfoEnabled()) - { - Exception e = new Exception("Stack: "); - logger.info("Transactional update cache '" + name + "' is full (" + maxCacheSize + ").", e); - } - else if (logger.isWarnEnabled()) - { - logger.warn("Transactional update cache '" + name + "' is full (" + maxCacheSize + ")."); - } + if (logger.isInfoEnabled()) + { + Exception e = new Exception("Stack: "); + logger.info("Transactional update cache '" + name + "' is full (" + maxCacheSize + ").", e); + } + else if (logger.isWarnEnabled()) + { + logger.warn("Transactional update cache '" + name + "' is full (" + maxCacheSize + ")."); + } txnData.haveIssuedFullWarning = true; } } @@ -848,17 +854,17 @@ public class TransactionalCache // data by clearing the shared cache after the transaction. Also, the // shared cache needs to be ignored for the rest of the transaction. txnData.isClearOn = true; - if (!txnData.haveIssuedFullWarning) + if (!txnData.haveIssuedFullWarning) { - if (logger.isInfoEnabled()) - { - Exception e = new Exception("Stack: "); - logger.info("Transactional removal cache '" + name + "' is full (" + maxCacheSize + ").", e); - } - else if (logger.isWarnEnabled()) - { - logger.warn("Transactional removal cache '" + name + "' is full (" + maxCacheSize + ")."); - } + if (logger.isInfoEnabled()) + { + Exception e = new Exception("Stack: "); + logger.info("Transactional removal cache '" + name + "' is full (" + maxCacheSize + ").", e); + } + else if (logger.isWarnEnabled()) + { + logger.warn("Transactional removal cache '" + name + "' is full (" + maxCacheSize + ")."); + } txnData.haveIssuedFullWarning = true; } } diff --git a/src/main/java/org/alfresco/repo/domain/dialect/DB2Dialect.java b/src/main/java/org/alfresco/repo/domain/dialect/DB2Dialect.java new file mode 100644 index 0000000000..aa8036ffeb --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/DB2Dialect.java @@ -0,0 +1,52 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.sql.Types; + +public class DB2Dialect extends Dialect +{ + public DB2Dialect() + { + super(); + registerColumnType( Types.BIT, "smallint" ); + registerColumnType( Types.BIGINT, "bigint" ); + registerColumnType( Types.SMALLINT, "smallint" ); + registerColumnType( Types.TINYINT, "smallint" ); + registerColumnType( Types.INTEGER, "integer" ); + registerColumnType( Types.CHAR, "char(1)" ); + registerColumnType( Types.VARCHAR, "varchar($l)" ); + registerColumnType( Types.FLOAT, "float" ); + registerColumnType( Types.DOUBLE, "double" ); + registerColumnType( Types.DATE, "date" ); + registerColumnType( Types.TIME, "time" ); + registerColumnType( Types.TIMESTAMP, "timestamp" ); + registerColumnType( Types.VARBINARY, "varchar($l) for bit data" ); + registerColumnType( Types.NUMERIC, "numeric($p,$s)" ); + registerColumnType( Types.BLOB, "blob($l)" ); + registerColumnType( Types.CLOB, "clob($l)" ); + } +} diff --git a/src/main/java/org/alfresco/repo/domain/dialect/Dialect.java b/src/main/java/org/alfresco/repo/domain/dialect/Dialect.java new file mode 100644 index 0000000000..45d307933f --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/Dialect.java @@ -0,0 +1,71 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +/** + * Class partially copied from patched hibernate 3.2.6 + * + * @since 6.0 + */ +public class Dialect +{ + private final TypeNames typeNames = new TypeNames(); + + protected Dialect() + { + } + + public String toString() + { + return getClass().getName(); + } + + /** + * Subclasses register a type name for the given type code and maximum + * column length. $l in the type name with be replaced by the + * column length (if appropriate). + * + * @param code The {@link java.sql.Types} typecode + * @param capacity The maximum length of database type + * @param name The database type name + */ + protected void registerColumnType(int code, int capacity, String name) + { + typeNames.put( code, capacity, name ); + } + + /** + * Subclasses register a type name for the given type code. $l in + * the type name with be replaced by the column length (if appropriate). + * + * @param code The {@link java.sql.Types} typecode + * @param name The database type name + */ + protected void registerColumnType(int code, String name) + { + typeNames.put( code, name ); + } +} diff --git a/src/main/java/org/alfresco/repo/domain/dialect/DialectFactory.java b/src/main/java/org/alfresco/repo/domain/dialect/DialectFactory.java new file mode 100644 index 0000000000..bfb746b98b --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/DialectFactory.java @@ -0,0 +1,165 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.util.HashMap; +import java.util.Map; +import org.alfresco.error.AlfrescoRuntimeException; + +/** + * A factory for generating Dialect instances. + *

+ * This class is an Alfresco-specific version of the Hibernate class with the same name. + * + * @author Steve Ebersole + * @author Alfresco + * @since 6.0 + */ +public class DialectFactory +{ + /** + * Builds an appropriate Dialect instance. + *

+ * The JDBC driver, the database name and version + * (obtained from connection metadata) are used to make the determination. + *

+ * An exception is thrown if a dialect was not explicitly set and the database name is not known. + * + + * @param databaseName The name of the database product (obtained from metadata). + * @param databaseMajorVersion The major version of the database product (obtained from metadata). + * @param driverName THe name of the JDBC driver + * + * @return The appropriate dialect. + */ + public static Dialect buildDialect(String databaseName, int databaseMajorVersion, String driverName) + { + if ( databaseName == null ) { + throw new IllegalArgumentException("Database name must be explicitly set"); + } + + DatabaseDialectMapper mapper = MAPPERS.get(driverName) != null ? + MAPPERS.get(driverName) : MAPPERS.get(databaseName); + if ( mapper == null ) + { + throw new IllegalArgumentException( "Dialect must be explicitly set for database: " + databaseName ); + } + + String dialectName = mapper.getDialectClass( databaseMajorVersion ); + return buildDialect( dialectName ); + } + + /** + * Returns a dialect instance given the name of the class to use. + * + * @param dialectName The name of the dialect class. + * + * @return The dialect instance. + */ + public static Dialect buildDialect(String dialectName) + { + try + { + return ( Dialect ) Class.forName( dialectName ).newInstance(); + } + catch ( ClassNotFoundException cnfe ) + { + throw new IllegalArgumentException( "Dialect class not found: " + dialectName ); + } + catch ( Exception e ) + { + throw new AlfrescoRuntimeException( "Could not instantiate dialect class", e ); + } + } + + /** + * For a given database product name, instances of + * DatabaseDialectMapper know which Dialect to use for different versions. + */ + public static interface DatabaseDialectMapper { + public String getDialectClass(int majorVersion); + } + + /** + * A simple DatabaseDialectMapper for dialects which are independent + * of the underlying database product version. + */ + public static class VersionInsensitiveMapper implements DatabaseDialectMapper { + private String dialectClassName; + + public VersionInsensitiveMapper(String dialectClassName) { + this.dialectClassName = dialectClassName; + } + + public String getDialectClass(int majorVersion) { + return dialectClassName; + } + } + + // TODO : this is the stuff it'd be nice to move to a properties file or some other easily user-editable place + private static final Map MAPPERS = new HashMap(); + static { + // detectors... + MAPPERS.put( "PostgreSQL", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.PostgreSQLDialect" ) ); + + MAPPERS.put( "DB2/NT", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2/LINUX", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2/6000", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2/HPUX", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2/SUN", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2/LINUX390", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2/AIX64", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/NT",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/NT64",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2 UDP",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/LINUX",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/LINUX390",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/LINUXZ64",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/400 SQL",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/6000",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2 UDB iSeries",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/AIX64",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/HPUX",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/HP64",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/SUN",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/SUN64",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/PTX",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/2",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + MAPPERS.put( "DB2/LINUXX8664",new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" )); + + MAPPERS.put( "MySQL", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.MySQLInnoDBDialect" ) ); + MAPPERS.put( "DB2/NT64", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "DB2/LINUX", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.DB2Dialect" ) ); + MAPPERS.put( "Microsoft SQL Server Database", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.SQLServerDialect" ) ); + MAPPERS.put( "Microsoft SQL Server", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.SQLServerDialect" ) ); + MAPPERS.put( "Oracle", new VersionInsensitiveMapper( "org.alfresco.repo.domain.dialect.Oracle9Dialect" ) ); + + // MariaDB is distinguished by driver name + MAPPERS.put( "MariaDB connector/J", new VersionInsensitiveMapper("org.alfresco.repo.domain.dialect.MariaDBDialect")); + } +} diff --git a/src/main/java/org/alfresco/repo/domain/dialect/DialectFactoryBean.java b/src/main/java/org/alfresco/repo/domain/dialect/DialectFactoryBean.java new file mode 100644 index 0000000000..b2cd7be819 --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/DialectFactoryBean.java @@ -0,0 +1,88 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; + +import javax.sql.DataSource; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.jdbc.datasource.DataSourceUtils; + +/** + * Factory for the DB dialect. Allows dialect detection logic to be centralized and the dialect to be injected + * where required as a singleton from the container. + * + * @author dward + * @since 6.0 + */ +public class DialectFactoryBean implements FactoryBean +{ + private DataSource dataSource; + + public void setDataSource(DataSource dataSource) + { + this.dataSource = dataSource; + } + + @Override + public Dialect getObject() throws SQLException + { + Connection con = null; + try + { + // make sure that we AUTO-COMMIT + con = DataSourceUtils.getConnection(dataSource); + con.setAutoCommit(true); + DatabaseMetaData meta = con.getMetaData(); + Dialect dialect = DialectFactory.buildDialect(meta.getDatabaseProductName(), meta.getDatabaseMajorVersion(), meta.getDriverName()); + return dialect; + } + finally + { + try + { + con.close(); + } + catch (Exception e) + { + } + } + } + + @Override + public Class getObjectType() + { + return Dialect.class; + } + + @Override + public boolean isSingleton() + { + return true; + } +} diff --git a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoMariaDBDialect.java b/src/main/java/org/alfresco/repo/domain/dialect/MariaDBDialect.java similarity index 84% rename from src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoMariaDBDialect.java rename to src/main/java/org/alfresco/repo/domain/dialect/MariaDBDialect.java index 9361529774..4ffa61b5c6 100644 --- a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoMariaDBDialect.java +++ b/src/main/java/org/alfresco/repo/domain/dialect/MariaDBDialect.java @@ -23,17 +23,15 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.repo.domain.hibernate.dialect; - - -import org.hibernate.dialect.MySQLInnoDBDialect; +package org.alfresco.repo.domain.dialect; /** * @author eknizat + * @since 6.0 */ -public class AlfrescoMariaDBDialect extends MySQLInnoDBDialect +public class MariaDBDialect extends MySQLInnoDBDialect { - public AlfrescoMariaDBDialect() + public MariaDBDialect() { super(); } diff --git a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoMySQLClusterNDBDialect.java b/src/main/java/org/alfresco/repo/domain/dialect/MySQLClusterNDBDialect.java similarity index 82% rename from src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoMySQLClusterNDBDialect.java rename to src/main/java/org/alfresco/repo/domain/dialect/MySQLClusterNDBDialect.java index 7927b6ee41..cb0add228f 100644 --- a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoMySQLClusterNDBDialect.java +++ b/src/main/java/org/alfresco/repo/domain/dialect/MySQLClusterNDBDialect.java @@ -23,11 +23,10 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.repo.domain.hibernate.dialect; +package org.alfresco.repo.domain.dialect; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.dialect.MySQLInnoDBDialect; /** * MySQL Cluster NDB specific DAO overrides @@ -43,19 +42,14 @@ import org.hibernate.dialect.MySQLInnoDBDialect; * */ //note: *not* a dialect of InnoDB but, for now, extends here so that we can override those scripts -public class AlfrescoMySQLClusterNDBDialect extends MySQLInnoDBDialect +public class MySQLClusterNDBDialect extends MySQLInnoDBDialect { - protected Log logger = LogFactory.getLog(AlfrescoMySQLClusterNDBDialect.class); + protected Log logger = LogFactory.getLog(MySQLClusterNDBDialect.class); - public AlfrescoMySQLClusterNDBDialect() + public MySQLClusterNDBDialect() { super(); logger.error("Using NDB with Alfresco is experimental and unsupported (do not use for live/prod envs) !"); } - - public String getTableTypeString() { - return " engine=NDB"; - } - } diff --git a/src/main/java/org/alfresco/repo/domain/dialect/MySQLInnoDBDialect.java b/src/main/java/org/alfresco/repo/domain/dialect/MySQLInnoDBDialect.java new file mode 100644 index 0000000000..52adefd39d --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/MySQLInnoDBDialect.java @@ -0,0 +1,66 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.sql.Types; + +/** + * @since 6.0 + */ +public class MySQLInnoDBDialect extends Dialect +{ + public MySQLInnoDBDialect() + { + super(); + registerColumnType( Types.BIT, "bit" ); + registerColumnType( Types.BIGINT, "bigint" ); + registerColumnType( Types.SMALLINT, "smallint" ); + registerColumnType( Types.TINYINT, "tinyint" ); + registerColumnType( Types.INTEGER, "integer" ); + registerColumnType( Types.CHAR, "char(1)" ); + registerColumnType( Types.FLOAT, "float" ); + registerColumnType( Types.DOUBLE, "double precision" ); + registerColumnType( Types.DATE, "date" ); + registerColumnType( Types.TIME, "time" ); + registerColumnType( Types.TIMESTAMP, "datetime" ); + registerColumnType( Types.VARBINARY, "longblob" ); + registerColumnType( Types.VARBINARY, 16777215, "mediumblob" ); + registerColumnType( Types.VARBINARY, 65535, "blob" ); + registerColumnType( Types.VARBINARY, 255, "tinyblob" ); + registerColumnType( Types.NUMERIC, "decimal($p,$s)" ); + registerColumnType( Types.BLOB, "longblob" ); + registerColumnType( Types.BLOB, 16777215, "mediumblob" ); + registerColumnType( Types.BLOB, 65535, "blob" ); + registerColumnType( Types.CLOB, "longtext" ); + registerColumnType( Types.CLOB, 16777215, "mediumtext" ); + registerColumnType( Types.CLOB, 65535, "text" ); + + registerColumnType( Types.VARCHAR, "longtext" ); + registerColumnType( Types.VARCHAR, 16777215, "mediumtext" ); + registerColumnType( Types.VARCHAR, 65535, "text" ); + registerColumnType( Types.VARCHAR, 255, "varchar($l)" ); + } +} diff --git a/src/main/java/org/alfresco/repo/domain/dialect/Oracle9Dialect.java b/src/main/java/org/alfresco/repo/domain/dialect/Oracle9Dialect.java new file mode 100644 index 0000000000..ba512c3bf9 --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/Oracle9Dialect.java @@ -0,0 +1,65 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.sql.Types; + +/** + * Does away with the deprecated LONG datatype. This extends the deprecated + * Oracle9Dialect for good reason: Hibernate ceased supporting + * right outer join in the Oracle9iDialect. + * + * @since 6.0 + */ +public class Oracle9Dialect extends Dialect +{ + public Oracle9Dialect() + { + super(); + registerColumnType( Types.BIT, "number(1,0)" ); + registerColumnType( Types.BIGINT, "number(19,0)" ); + registerColumnType( Types.SMALLINT, "number(5,0)" ); + registerColumnType( Types.TINYINT, "number(3,0)" ); + registerColumnType( Types.INTEGER, "number(10,0)" ); + registerColumnType( Types.CHAR, "char(1 char)" ); + registerColumnType( Types.VARCHAR, 4000, "varchar2($l char)" ); + registerColumnType( Types.VARCHAR, "long" ); + registerColumnType( Types.FLOAT, "float" ); + registerColumnType( Types.DOUBLE, "double precision" ); + registerColumnType( Types.DATE, "date" ); + registerColumnType( Types.TIME, "date" ); + registerColumnType( Types.TIMESTAMP, "timestamp" ); + registerColumnType( Types.VARBINARY, 2000, "raw($l)" ); + registerColumnType( Types.VARBINARY, "long raw" ); + registerColumnType( Types.NUMERIC, "number($p,$s)" ); + registerColumnType( Types.DECIMAL, "number($p,$s)" ); + registerColumnType( Types.BLOB, "blob" ); + registerColumnType( Types.CLOB, "clob" ); + + registerColumnType( Types.VARBINARY, "blob"); + registerColumnType( Types.NVARCHAR, 4000, "nvarchar2($l)"); + } +} diff --git a/src/main/java/org/alfresco/repo/domain/dialect/PostgreSQLDialect.java b/src/main/java/org/alfresco/repo/domain/dialect/PostgreSQLDialect.java new file mode 100644 index 0000000000..98cfc8434f --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/PostgreSQLDialect.java @@ -0,0 +1,55 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.sql.Types; + +/** + * @since 6.0 + */ +public class PostgreSQLDialect extends Dialect +{ + public PostgreSQLDialect() + { + super(); + registerColumnType( Types.BIT, "bool" ); + registerColumnType( Types.BIGINT, "int8" ); + registerColumnType( Types.SMALLINT, "int2" ); + registerColumnType( Types.TINYINT, "int2" ); + registerColumnType( Types.INTEGER, "int4" ); + registerColumnType( Types.CHAR, "char(1)" ); + registerColumnType( Types.VARCHAR, "varchar($l)" ); + registerColumnType( Types.FLOAT, "float4" ); + registerColumnType( Types.DOUBLE, "float8" ); + registerColumnType( Types.DATE, "date" ); + registerColumnType( Types.TIME, "time" ); + registerColumnType( Types.TIMESTAMP, "timestamp" ); + registerColumnType( Types.VARBINARY, "bytea" ); + registerColumnType( Types.CLOB, "text" ); + registerColumnType( Types.BLOB, "oid" ); + registerColumnType( Types.NUMERIC, "numeric($p, $s)" ); + } +} diff --git a/src/main/java/org/alfresco/repo/domain/dialect/SQLServerDialect.java b/src/main/java/org/alfresco/repo/domain/dialect/SQLServerDialect.java new file mode 100644 index 0000000000..de6534fab3 --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/SQLServerDialect.java @@ -0,0 +1,62 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.sql.Types; + +/** + * @since 6.0 + */ +public class SQLServerDialect extends Dialect +{ + public SQLServerDialect() + { + super(); + registerColumnType( Types.BIT, "tinyint" ); //Sybase BIT type does not support null values + registerColumnType( Types.BIGINT, "numeric(19,0)" ); + registerColumnType( Types.SMALLINT, "smallint" ); + registerColumnType( Types.TINYINT, "tinyint" ); + registerColumnType( Types.INTEGER, "int" ); + registerColumnType( Types.CHAR, "char(1)" ); + registerColumnType( Types.VARCHAR, "varchar($l)" ); + registerColumnType( Types.FLOAT, "float" ); + registerColumnType( Types.DOUBLE, "double precision" ); + registerColumnType( Types.DATE, "datetime" ); + registerColumnType( Types.TIME, "datetime" ); + registerColumnType( Types.TIMESTAMP, "datetime" ); + registerColumnType( Types.VARBINARY, "varbinary($l)" ); + registerColumnType( Types.NUMERIC, "numeric($p,$s)" ); + registerColumnType( Types.BLOB, "image" ); + registerColumnType( Types.CLOB, "text" ); + + registerColumnType( Types.VARBINARY, "image" ); + registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" ); + + registerColumnType( Types.VARCHAR, "nvarchar($l)" ); + registerColumnType( Types.CLOB, "nvarchar(max)"); + } + +} diff --git a/src/main/java/org/alfresco/repo/domain/dialect/TypeNames.java b/src/main/java/org/alfresco/repo/domain/dialect/TypeNames.java new file mode 100644 index 0000000000..a6f7c083f2 --- /dev/null +++ b/src/main/java/org/alfresco/repo/domain/dialect/TypeNames.java @@ -0,0 +1,163 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain.dialect; + +import java.util.Map; +import java.util.HashMap; +import java.util.TreeMap; +import java.util.Iterator; + +/** + * This class maps a type to names. Associations + * may be marked with a capacity. Calling the get() + * method with a type and actual size n will return + * the associated name with smallest capacity >= n, + * if available and an unmarked default type otherwise. + * Eg, setting + *

+ *	names.put(type,        "TEXT" );
+ *	names.put(type,   255, "VARCHAR($l)" );
+ *	names.put(type, 65534, "LONGVARCHAR($l)" );
+ * 
+ * will give you back the following: + *
+ *  names.get(type)         // --> "TEXT" (default)
+ *  names.get(type,    100) // --> "VARCHAR(100)" (100 is in [0:255])
+ *  names.get(type,   1000) // --> "LONGVARCHAR(1000)" (1000 is in [256:65534])
+ *  names.get(type, 100000) // --> "TEXT" (default)
+ * 
+ * On the other hand, simply putting + *
+ *	names.put(type, "VARCHAR($l)" );
+ * 
+ * would result in + *
+ *  names.get(type)        // --> "VARCHAR($l)" (will cause trouble)
+ *  names.get(type, 100)   // --> "VARCHAR(100)"
+ *  names.get(type, 10000) // --> "VARCHAR(10000)"
+ * 
+ * + * Class copied from patched hibernate 3.2.6 + * @since 6.0 + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class TypeNames { + + private HashMap weighted = new HashMap(); + private HashMap defaults = new HashMap(); + + /** + * get default type name for specified type + * @param typecode the type key + * @return the default type name associated with specified key + */ + public String get(int typecode) throws IllegalArgumentException + { + String result = (String) defaults.get( new Integer(typecode) ); + if (result == null) + { + throw new IllegalArgumentException("No Dialect mapping for JDBC type: " + typecode); + } + return result; + } + + /** + * get type name for specified type and size + * @param typecode the type key + * @param size the SQL length + * @param scale the SQL scale + * @param precision the SQL precision + * @return the associated name with smallest capacity >= size, + * if available and the default type name otherwise + */ + public String get(int typecode, int size, int precision, int scale) throws IllegalArgumentException + { + Map map = (Map) weighted.get( new Integer(typecode) ); + if ( map!=null && map.size()>0 ) + { + // iterate entries ordered by capacity to find first fit + Iterator entries = map.entrySet().iterator(); + while ( entries.hasNext() ) + { + Map.Entry entry = (Map.Entry)entries.next(); + if ( size <= ( (Integer) entry.getKey() ).intValue() ) + { + return replace( (String) entry.getValue(), size, precision, scale ); + } + } + } + return replace( get(typecode), size, precision, scale ); + } + + private static String replace(String type, int size, int precision, int scale) + { + type = replaceOnce(type, "$s", Integer.toString(scale) ); + type = replaceOnce(type, "$l", Integer.toString(size) ); + return replaceOnce(type, "$p", Integer.toString(precision) ); + } + + /** + * set a type name for specified type key and capacity + * @param typecode the type key + */ + public void put(int typecode, int capacity, String value) + { + TreeMap map = (TreeMap)weighted.get( new Integer(typecode) ); + if (map == null) + {// add new ordered map + map = new TreeMap(); + weighted.put( new Integer(typecode), map ); + } + map.put(new Integer(capacity), value); + } + + /** + * set a default type name for specified type key + * @param typecode the type key + */ + public void put(int typecode, String value) + { + defaults.put( new Integer(typecode), value ); + } + + private static String replaceOnce(String template, String placeholder, String replacement) + { + int loc = template == null ? -1 : template.indexOf( placeholder ); + if ( loc < 0 ) + { + return template; + } + else + { + return new StringBuffer( template.substring( 0, loc ) ) + .append( replacement ) + .append( template.substring( loc + placeholder.length() ) ) + .toString(); + } + } +} + + diff --git a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoOracle9Dialect.java b/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoOracle9Dialect.java deleted file mode 100644 index d0de3137eb..0000000000 --- a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoOracle9Dialect.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.domain.hibernate.dialect; - -import java.sql.Types; - -import org.hibernate.dialect.Oracle9Dialect; - -/** - * Does away with the deprecated LONG datatype. This extends the deprecated - * Oracle9Dialect for good reason: Hibernate ceased supporting - * right outer join in the Oracle9iDialect. - * - * @author Derek Hulley - * @since 2.2.2 - */ -@SuppressWarnings("deprecation") -public class AlfrescoOracle9Dialect extends Oracle9Dialect -{ - public AlfrescoOracle9Dialect() - { - super(); - registerColumnType(Types.VARBINARY, "blob"); - registerColumnType(Types.NVARCHAR, 4000, "nvarchar2($l)"); - } -} diff --git a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoSQLServerDialect.java b/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoSQLServerDialect.java deleted file mode 100644 index ddccbc0f6a..0000000000 --- a/src/main/java/org/alfresco/repo/domain/hibernate/dialect/AlfrescoSQLServerDialect.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.domain.hibernate.dialect; - -import java.sql.Types; - -import org.hibernate.dialect.SQLServerDialect; - -public class AlfrescoSQLServerDialect extends SQLServerDialect -{ - - public AlfrescoSQLServerDialect() - { - super(); - registerColumnType( Types.VARCHAR, "nvarchar($l)" ); - registerColumnType(Types.CLOB, "nvarchar(max)"); - } - -} diff --git a/src/main/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java b/src/main/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java index b38c13916e..3ab570fca0 100644 --- a/src/main/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java +++ b/src/main/java/org/alfresco/repo/domain/node/ibatis/NodeDAOImpl.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.domain.node.ibatis; import java.util.ArrayList; @@ -220,7 +220,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl */ } - @SuppressWarnings("unchecked") @Override protected ServerEntity selectServer(String ipAddress) { @@ -281,7 +280,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.delete(DELETE_TRANSACTION_BY_ID, transaction); } - @SuppressWarnings("unchecked") @Override protected List selectAllStores() { @@ -377,6 +375,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } @Override + @SuppressWarnings("rawtypes") public Pair getNodeIdsIntervalForType(QName type, Long startTxnTime, Long endTxnTime) { final Pair intervalPair = new Pair(LONG_ZERO, LONG_ZERO); @@ -484,7 +483,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectOne(SELECT_NODE_BY_NODEREF, node); } - @SuppressWarnings("unchecked") @Override protected List selectNodesByUuids(Long storeId, SortedSet uuids) { @@ -497,7 +495,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectList(SELECT_NODES_BY_UUIDS, nodeBatchLoadEntity); } - @SuppressWarnings("unchecked") @Override protected List selectNodesByIds(SortedSet ids) { @@ -555,7 +552,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } @Override - @SuppressWarnings("unchecked") protected Map> selectNodeProperties(Set nodeIds) { if (nodeIds.size() == 0) @@ -568,13 +564,14 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl List rows = template.selectList(SELECT_NODE_PROPERTIES, prop); return makePersistentPropertiesMap(rows); } + @Override protected Map> selectNodeProperties(Long nodeId) { return selectNodeProperties(nodeId, Collections.emptySet()); } + @Override - @SuppressWarnings("unchecked") protected Map> selectNodeProperties(Long nodeId, Set qnameIds) { NodePropertyEntity prop = new NodePropertyEntity(); @@ -599,6 +596,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } @Override + @SuppressWarnings("rawtypes") public List selectNodePropertiesByTypes(Set qnames) { final List properties = new ArrayList(); @@ -623,6 +621,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return properties; } + @SuppressWarnings("rawtypes") @Override public List selectNodePropertiesByDataType(QName dataType, long minNodeId, long maxNodeId) { @@ -721,7 +720,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } } - @SuppressWarnings("unchecked") @Override protected Map> selectNodeAspects(Set nodeIds) { @@ -778,6 +776,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl Long minNodeId, Long maxNodeId, final NodeRefQueryCallback resultsCallback) { + @SuppressWarnings("rawtypes") ResultHandler resultHandler = new ResultHandler() { public void handleResult(ResultContext context) @@ -851,7 +850,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.delete(DELETE_NODE_ASSOCS, param); } - @SuppressWarnings("unchecked") @Override protected List selectNodeAssocs(Long nodeId) { @@ -886,7 +884,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectList(SELECT_NODE_ASSOCS_BY_SOURCE_AND_PROPERTY_VALUE, assoc); } - @SuppressWarnings("unchecked") @Override protected List selectNodeAssocsByTarget(Long targetNodeId, Long typeQNameId) { @@ -989,7 +986,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectOne(SELECT_CHILD_ASSOC_BY_ID, assoc); } - @SuppressWarnings("unchecked") @Override protected List selectChildNodeIds( Long nodeId, @@ -1010,7 +1006,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectList(SELECT_CHILD_NODE_IDS, assoc, rowBounds); } - @SuppressWarnings("unchecked") @Override public List selectPrimaryChildAcls(Long nodeId) { @@ -1025,7 +1020,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectList(SELECT_NODE_PRIMARY_CHILD_ACLS, assoc); } - @SuppressWarnings("unchecked") @Override protected List selectChildAssoc( Long parentNodeId, @@ -1075,6 +1069,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl * @author Derek Hulley * @since 3.4 */ + @SuppressWarnings("rawtypes") private class ChildAssocResultHandler implements ResultHandler { private final ChildAssocResultHandlerFilter filter; @@ -1178,6 +1173,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl resultsCallback.done(); } + @SuppressWarnings("unchecked") @Override public void selectChildAssocs( Long parentNodeId, @@ -1217,6 +1213,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl RowBounds rowBounds = new RowBounds(0, maxResults); List entities = template.selectList(SELECT_CHILD_ASSOCS_OF_PARENT_LIMITED, assoc, rowBounds); + @SuppressWarnings("rawtypes") final DefaultResultContext resultContext = new DefaultResultContext(); for (Object entity : entities) { @@ -1502,7 +1499,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl resultsCallback.done(); } - @SuppressWarnings("unchecked") @Override protected List selectParentAssocs(Long childNodeId) { @@ -1588,7 +1584,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl { } - @SuppressWarnings("unchecked") @Override protected Transaction selectLastTxnBeforeCommitTime(Long maxCommitTime) { @@ -1623,7 +1618,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectOne(SELECT_TXNS, query); } - @SuppressWarnings("unchecked") @Override protected List selectTxnChanges(Long txnId, Long storeId) { @@ -1638,7 +1632,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl return template.selectList(SELECT_TXN_NODES, query); } - @SuppressWarnings("unchecked") @Override protected List selectTxns( Long fromTimeInclusive, @@ -1676,7 +1669,6 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl } } - @SuppressWarnings("unchecked") @Override protected List selectTxnsUnused(Long minTxnId, Long maxCommitTime, Integer count) { @@ -1814,7 +1806,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl /** * MySQL Cluster NDB specific DAO overrides * - * WARNING: Experimental/unsupported - see AlfrescoMySQLClusterNDBDialect ! + * WARNING: Experimental/unsupported - see MySQLClusterNDBDialect ! * * @author janv */ @@ -1823,38 +1815,38 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl @Override protected Long newNodeImplInsert(NodeEntity node) { - Long id = null; + Long id = null; try { - // We need to handle existing deleted nodes. + // We need to handle existing deleted nodes. NodeRef targetNodeRef = node.getNodeRef(); Node dbTargetNode = selectNodeByNodeRef(targetNodeRef); if (dbTargetNode != null) { - if (dbTargetNode.getDeleted(qnameDAO)) - { - Long dbTargetNodeId = dbTargetNode.getId(); - // This is OK. It happens when we create a node that existed in the past. - // Remove the row completely - deleteNodeProperties(dbTargetNodeId, (Set) null); - deleteNodeById(dbTargetNodeId); - } - else - { - // A live node exists. - throw new NodeExistsException(dbTargetNode.getNodePair(), null); - } + if (dbTargetNode.getDeleted(qnameDAO)) + { + Long dbTargetNodeId = dbTargetNode.getId(); + // This is OK. It happens when we create a node that existed in the past. + // Remove the row completely + deleteNodeProperties(dbTargetNodeId, (Set) null); + deleteNodeById(dbTargetNodeId); + } + else + { + // A live node exists. + throw new NodeExistsException(dbTargetNode.getNodePair(), null); + } } id = insertNode(node); } catch (Throwable e) { - if (e instanceof NodeExistsException) - { - throw e; - } - + if (e instanceof NodeExistsException) + { + throw e; + } + // There does not appear to be any row that could prevent an insert throw new AlfrescoRuntimeException("Failed to insert new node: " + node, e); } diff --git a/src/main/java/org/alfresco/repo/domain/schema/DataSourceCheck.java b/src/main/java/org/alfresco/repo/domain/schema/DataSourceCheck.java index 0f19d1dc41..31aff9b9be 100644 --- a/src/main/java/org/alfresco/repo/domain/schema/DataSourceCheck.java +++ b/src/main/java/org/alfresco/repo/domain/schema/DataSourceCheck.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.domain.schema; import java.sql.Connection; @@ -31,14 +31,12 @@ import java.sql.DatabaseMetaData; import javax.sql.DataSource; import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.hibernate.DialectFactory; +import org.alfresco.repo.domain.dialect.SQLServerDialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.DialectFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.cfg.Configuration; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.SQLServerDialect; import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.orm.hibernate3.LocalSessionFactoryBean; /** * Bean to log connection details and attempt to ensure that the connection is OK. @@ -58,17 +56,11 @@ public class DataSourceCheck /** The required transaction isolation */ private static final int SQL_SERVER_TRANSACTION_ISOLATION = 4096; - private Configuration cfg; private String dbUrl; private String dbUsername; private int transactionIsolation; private DataSource dataSource; - public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory) - { - this.cfg = localSessionFactory.getConfiguration(); - } - public void setDbUrl(String dbUrl) { this.dbUrl = dbUrl; @@ -104,9 +96,9 @@ public class DataSourceCheck meta.getDatabaseProductName(), meta.getDatabaseProductVersion())); Dialect dialect = DialectFactory.buildDialect( - cfg.getProperties(), meta.getDatabaseProductName(), - meta.getDatabaseMajorVersion()); + meta.getDatabaseMajorVersion(), + meta.getDriverName()); // Check MS SQL Server specific settings if (dialect instanceof SQLServerDialect) diff --git a/src/main/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java b/src/main/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java index 23866b1c73..ef2238936f 100644 --- a/src/main/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java +++ b/src/main/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java @@ -1,51 +1,47 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.domain.schema; import java.io.BufferedInputStream; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; -import java.io.Writer; import java.sql.Array; import java.sql.Blob; import java.sql.CallableStatement; import java.sql.Clob; import java.sql.Connection; import java.sql.DatabaseMetaData; -import java.sql.DriverManager; import java.sql.NClob; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -76,10 +72,13 @@ import org.alfresco.repo.admin.patch.AppliedPatch; import org.alfresco.repo.admin.patch.Patch; import org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch; import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoMySQLClusterNDBDialect; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSybaseAnywhereDialect; +import org.alfresco.repo.domain.dialect.MySQLClusterNDBDialect; +import org.alfresco.repo.domain.dialect.Oracle9Dialect; +import org.alfresco.repo.domain.dialect.SQLServerDialect; +import org.alfresco.repo.domain.dialect.DB2Dialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; +import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.repo.domain.patch.AppliedPatchDAO; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.descriptor.DescriptorService; @@ -97,26 +96,6 @@ import org.alfresco.util.schemacomp.XMLToSchema; import org.alfresco.util.schemacomp.model.Schema; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.hibernate.cfg.Environment; -import org.hibernate.connection.UserSuppliedConnectionProvider; -import org.hibernate.dialect.DB2Dialect; -import org.hibernate.dialect.DerbyDialect; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.HSQLDialect; -import org.hibernate.dialect.MySQL5Dialect; -import org.hibernate.dialect.MySQLDialect; -import org.hibernate.dialect.MySQLInnoDBDialect; -import org.hibernate.dialect.Oracle10gDialect; -import org.hibernate.dialect.Oracle9Dialect; -import org.hibernate.dialect.Oracle9iDialect; -import org.hibernate.dialect.OracleDialect; -import org.hibernate.dialect.PostgreSQLDialect; -import org.hibernate.engine.ActionQueue; -import org.hibernate.tool.hbm2ddl.DatabaseMetadata; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; import org.springframework.core.io.Resource; @@ -124,8 +103,6 @@ import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; import org.springframework.extensions.surf.util.AbstractLifecycleBean; import org.springframework.extensions.surf.util.I18NUtil; -import org.springframework.orm.hibernate3.LocalSessionFactoryBean; - /** * Bootstraps the schema and schema update. The schema is considered missing if the applied patch table @@ -151,11 +128,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean private static final String MSG_EXECUTING_COPIED_SCRIPT = "schema.update.msg.executing_copied_script"; private static final String MSG_EXECUTING_STATEMENT = "schema.update.msg.executing_statement"; private static final String MSG_OPTIONAL_STATEMENT_FAILED = "schema.update.msg.optional_statement_failed"; - private static final String WARN_DIALECT_UNSUPPORTED = "schema.update.warn.dialect_unsupported"; - private static final String WARN_DIALECT_HSQL = "schema.update.warn.dialect_hsql"; - private static final String WARN_DIALECT_DERBY = "schema.update.warn.dialect_derby"; private static final String ERR_FORCED_STOP = "schema.update.err.forced_stop"; - private static final String ERR_DIALECT_SHOULD_USE = "schema.update.err.dialect_should_use"; private static final String ERR_MULTIPLE_SCHEMAS = "schema.update.err.found_multiple"; private static final String ERR_PREVIOUS_FAILED_BOOTSTRAP = "schema.update.err.previous_failed"; private static final String ERR_STATEMENT_FAILED = "schema.update.err.statement_failed"; @@ -191,7 +164,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean */ public static final void setMaxStringLength(int length, Dialect dialect) { - int max = (dialect instanceof AlfrescoMySQLClusterNDBDialect ? DEFAULT_MAX_STRING_LENGTH_NDB : DEFAULT_MAX_STRING_LENGTH); + int max = (dialect instanceof MySQLClusterNDBDialect ? DEFAULT_MAX_STRING_LENGTH_NDB : DEFAULT_MAX_STRING_LENGTH); if (length < max) { @@ -268,7 +241,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean private DescriptorService descriptorService; private DataSource dataSource; private AppliedPatchDAO appliedPatchDAO; - private LocalSessionFactoryBean localSessionFactory; private String schemaOuputFilename; private boolean updateSchema; private boolean stopAfterSchemaBootstrap; @@ -308,16 +280,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean this.appliedPatchDAO = appliedPatchDAO; } - public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory) - { - this.localSessionFactory = localSessionFactory; - } - - public LocalSessionFactoryBean getLocalSessionFactory() - { - return localSessionFactory; - } - /** * Set this to output the full database creation script * @@ -415,23 +377,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean } } - /** - * Get the limit for the hibernate executions queue - */ - public int getHibernateMaxExecutions() - { - return ActionQueue.getMAX_EXECUTIONS_SIZE(); - } - - /** - * Set the limit for the hibernate executions queue - * Less than zero always uses event amalgamation - */ - public void setHibernateMaxExecutions(int hibernateMaxExecutions) - { - ActionQueue.setMAX_EXECUTIONS_SIZE(hibernateMaxExecutions); - } - /** * Set db.schema.name to be used */ @@ -453,11 +398,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean { this.globalProperties = globalProperties; } - - private SessionFactory getSessionFactory() - { - return (SessionFactory) localSessionFactory.getObject(); - } /** * Register a new script for execution when creating a clean schema. The order of registration @@ -580,12 +520,11 @@ public class SchemaBootstrap extends AbstractLifecycleBean * Count applied patches. This fails if multiple applied patch tables are found, * which normally indicates that the schema view needs to be limited. * - * @param cfg The Hibernate config * @param connection a valid database connection * @return Returns the number of applied patches * @throws NoSchemaException if the table of applied patches can't be found */ - private int countAppliedPatches(Configuration cfg, Connection connection) throws Exception + private int countAppliedPatches(Connection connection) throws Exception { String defaultSchema = dbSchemaName != null ? dbSchemaName : databaseMetaDataHelper.getSchema(connection); @@ -593,7 +532,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean { defaultSchema = null; } - String defaultCatalog = cfg.getProperty("hibernate.default_catalog"); + String defaultCatalog = connection.getCatalog(); if (defaultCatalog != null && defaultCatalog.length() == 0) { defaultCatalog = null; @@ -882,19 +821,19 @@ public class SchemaBootstrap extends AbstractLifecycleBean /** * Builds the schema from scratch or applies the necessary patches to the schema. */ - private boolean updateSchema(Configuration cfg, Session session, Connection connection) throws Exception + private boolean updateSchema(Connection connection) throws Exception { boolean create = false; try { - countAppliedPatches(cfg, connection); + countAppliedPatches(connection); } catch (NoSchemaException e) { create = true; } // Get the dialect - final Dialect dialect = Dialect.getDialect(cfg.getProperties()); + final Dialect dialect = this.dialect; String dialectStr = dialect.getClass().getSimpleName(); if (create) @@ -904,39 +843,12 @@ public class SchemaBootstrap extends AbstractLifecycleBean // execute pre-create scripts (not patches) for (String scriptUrl : this.preCreateScriptUrls) { - executeScriptUrl(cfg, connection, scriptUrl); - } - // Build and execute changes generated by Hibernate - File tempFile = null; - Writer writer = null; - try - { - DatabaseMetadata metadata = new DatabaseMetadata(connection, dialect); - String[] sqls = cfg.generateSchemaUpdateScript(dialect, metadata); - if (sqls.length > 0) - { - tempFile = TempFileProvider.createTempFile("AlfrescoSchema-" + dialectStr + "-Update-", ".sql"); - writer = new BufferedWriter(new FileWriter(tempFile)); - for (String sql : sqls) - { - writer.append(sql); - writer.append(";\n"); - } - try {writer.close();} catch (Throwable e) {} - executeScriptFile(cfg, connection, tempFile, null); - } - } - finally - { - if (writer != null) - { - try {writer.close();} catch (Throwable e) {} - } + executeScriptUrl(connection, scriptUrl); } // execute post-create scripts (not patches) for (String scriptUrl : this.postCreateScriptUrls) { - executeScriptUrl(cfg, connection, scriptUrl); + executeScriptUrl(connection, scriptUrl); } if (logger.isInfoEnabled()) @@ -947,41 +859,10 @@ public class SchemaBootstrap extends AbstractLifecycleBean else { // Execute any pre-auto-update scripts - checkSchemaPatchScripts(cfg, connection, preUpdateScriptPatches, true); - - // Build and execute changes generated by Hibernate - File tempFile = null; - Writer writer = null; - try - { - DatabaseMetadata metadata = new DatabaseMetadata(connection, dialect); - String[] sqls = cfg.generateSchemaUpdateScript(dialect, metadata); - if (sqls.length > 0) - { - tempFile = TempFileProvider.createTempFile("AlfrescoSchema-" + dialectStr + "-Update-", ".sql"); - writer = new BufferedWriter(new FileWriter(tempFile)); - for (String sql : sqls) - { - writer.append(sql); - writer.append(";\n"); - } - } - } - finally - { - if (writer != null) - { - try {writer.close();} catch (Throwable e) {} - } - } - // execute if there were changes raised by Hibernate - if (tempFile != null) - { - executeScriptFile(cfg, connection, tempFile, null); - } + checkSchemaPatchScripts(connection, preUpdateScriptPatches, true); // Execute any post-auto-update scripts - checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, true); + checkSchemaPatchScripts(connection, postUpdateScriptPatches, true); } // Initialise Activiti DB, using an unclosable connection @@ -1016,10 +897,10 @@ public class SchemaBootstrap extends AbstractLifecycleBean else { // Execute any auto-update scripts for Activiti tables - checkSchemaPatchScripts(cfg, connection, updateActivitiScriptPatches, true); + checkSchemaPatchScripts(connection, updateActivitiScriptPatches, true); // verify that all Activiti patches have been applied correctly - checkSchemaPatchScripts(cfg, connection, updateActivitiScriptPatches, false); + checkSchemaPatchScripts(connection, updateActivitiScriptPatches, false); } return create; @@ -1063,13 +944,12 @@ public class SchemaBootstrap extends AbstractLifecycleBean * Check that the necessary scripts have been executed against the database */ private void checkSchemaPatchScripts( - Configuration cfg, Connection connection, List scriptPatches, boolean apply) throws Exception { // first check if there have been any applied patches - int appliedPatchCount = countAppliedPatches(cfg, connection); + int appliedPatchCount = countAppliedPatches(connection); if (appliedPatchCount == 0) { // This is a new schema, so upgrade scripts are irrelevant @@ -1116,13 +996,13 @@ public class SchemaBootstrap extends AbstractLifecycleBean throw AlfrescoRuntimeException.create(ERR_SCRIPT_NOT_RUN, scriptUrl); } // it wasn't run and it can be run now - executeScriptUrl(cfg, connection, scriptUrl); + executeScriptUrl(connection, scriptUrl); } } - private void executeScriptUrl(Configuration cfg, Connection connection, String scriptUrl) throws Exception + private void executeScriptUrl(Connection connection, String scriptUrl) throws Exception { - Dialect dialect = Dialect.getDialect(cfg.getProperties()); + Dialect dialect = this.dialect; String dialectStr = dialect.getClass().getSimpleName(); InputStream scriptInputStream = getScriptInputStream(dialect.getClass(), scriptUrl); // check that it exists @@ -1145,7 +1025,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean // now execute it String dialectScriptUrl = scriptUrl.replaceAll(PLACEHOLDER_DIALECT, dialect.getClass().getName()); // Replace the script placeholders - executeScriptFile(cfg, connection, tempFile, dialectScriptUrl); + executeScriptFile(connection, tempFile, dialectScriptUrl); } /** @@ -1219,19 +1099,17 @@ public class SchemaBootstrap extends AbstractLifecycleBean } /** - * @param cfg the Hibernate configuration * @param connection the DB connection to use * @param scriptFile the file containing the statements * @param scriptUrl the URL of the script to report. If this is null, the script * is assumed to have been auto-generated. */ private void executeScriptFile( - Configuration cfg, Connection connection, File scriptFile, String scriptUrl) throws Exception { - final Dialect dialect = Dialect.getDialect(cfg.getProperties()); + final Dialect dialect = this.dialect; StringBuilder executedStatements = executedStatementsThreadLocal.get(); if (executedStatements == null) @@ -1315,7 +1193,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean } String includedScriptUrl = sql.substring(10, sql.length()); // Execute the script in line - executeScriptUrl(cfg, connection, includedScriptUrl); + executeScriptUrl(connection, includedScriptUrl); } // Check for variable assignment else if (sql.startsWith("--ASSIGN:")) @@ -1488,11 +1366,11 @@ public class SchemaBootstrap extends AbstractLifecycleBean sql = sql.replaceAll("(?i)TYPE=InnoDB", "ENGINE=InnoDB"); } - if (this.dialect != null && this.dialect instanceof AlfrescoMySQLClusterNDBDialect) + if (this.dialect != null && this.dialect instanceof MySQLClusterNDBDialect) { // note: enable bootstrap on MySQL Cluster NDB /* - * WARNING: Experimental/unsupported - see AlfrescoMySQLClusterNDBDialect ! + * WARNING: Experimental/unsupported - see MySQLClusterNDBDialect ! */ sql = sql.replaceAll("(?i)TYPE=InnoDB", "ENGINE=NDB"); // belts-and-braces sql = sql.replaceAll("(?i)ENGINE=InnoDB", "ENGINE=NDB"); @@ -1604,45 +1482,39 @@ public class SchemaBootstrap extends AbstractLifecycleBean { Class dialectClazz = dialect.getClass(); LogUtil.info(logger, MSG_DIALECT_USED, dialectClazz.getName()); - if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class)) - { - LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), MySQLInnoDBDialect.class.getName()); - throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName()); - } - else if (dialectClazz.equals(HSQLDialect.class)) - { - LogUtil.info(logger, WARN_DIALECT_HSQL); - } - else if (dialectClazz.equals(DerbyDialect.class)) - { - LogUtil.info(logger, WARN_DIALECT_DERBY); - } - else if (dialectClazz.equals(Oracle9iDialect.class) || dialectClazz.equals(Oracle10gDialect.class)) - { - LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), AlfrescoOracle9Dialect.class.getName()); - throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName()); - } - else if (dialectClazz.equals(OracleDialect.class) || dialectClazz.equals(Oracle9Dialect.class)) - { - LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), AlfrescoOracle9Dialect.class.getName()); - throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName()); - } +// if (dialectClazz.equals(MySQLDialect.class) || dialectClazz.equals(MySQL5Dialect.class)) +// { +// LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), MySQLInnoDBDialect.class.getName()); +// throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName()); +// } +// else if (dialectClazz.equals(HSQLDialect.class)) +// { +// LogUtil.info(logger, WARN_DIALECT_HSQL); +// } +// else if (dialectClazz.equals(DerbyDialect.class)) +// { +// LogUtil.info(logger, WARN_DIALECT_DERBY); +// } +// else if (dialectClazz.equals(Oracle9iDialect.class) || dialectClazz.equals(Oracle10gDialect.class)) +// { +// LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), Oracle9Dialect.class.getName()); +// throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName()); +// } +// else if (dialectClazz.equals(OracleDialect.class) || dialectClazz.equals(Oracle9Dialect.class)) +// { +// LogUtil.error(logger, ERR_DIALECT_SHOULD_USE, dialectClazz.getName(), Oracle9Dialect.class.getName()); +// throw AlfrescoRuntimeException.create(WARN_DIALECT_UNSUPPORTED, dialectClazz.getName()); +// } int maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH; int serializableType = SerializableTypeHandler.getSerializableType(); // Adjust the maximum allowable String length according to the dialect - if (dialect instanceof AlfrescoSQLServerDialect) + if (dialect instanceof SQLServerDialect) { // string_value nvarchar(1024) null, // serializable_value image null, maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH; } - else if (dialect instanceof AlfrescoSybaseAnywhereDialect) - { - // string_value text null, - // serializable_value varbinary(8192) null, - maxStringLength = Integer.MAX_VALUE; - } else if (dialect instanceof DB2Dialect) { // string_value varchar(1024), @@ -1650,13 +1522,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH; serializableType = Types.BLOB; } - else if (dialect instanceof HSQLDialect) - { - // string_value varchar(1024), - // serializable_value varbinary(8192), - maxStringLength = SchemaBootstrap.DEFAULT_MAX_STRING_LENGTH; - } - else if (dialect instanceof AlfrescoMySQLClusterNDBDialect) + else if (dialect instanceof MySQLClusterNDBDialect) { // string_value varchar(400), // serializable_value blob, @@ -1668,7 +1534,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean // serializable_value blob, maxStringLength = Integer.MAX_VALUE; } - else if (dialect instanceof AlfrescoOracle9Dialect) + else if (dialect instanceof Oracle9Dialect) { // string_value varchar2(1024 char), // serializable_value blob, @@ -1701,7 +1567,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean } // do everything in a transaction - Session session = getSessionFactory().openSession(); Connection connection = null; try { @@ -1709,17 +1574,10 @@ public class SchemaBootstrap extends AbstractLifecycleBean connection = dataSource.getConnection(); connection.setAutoCommit(true); LogUtil.info(logger, MSG_DATABASE_USED, connection); - - Configuration cfg = localSessionFactory.getConfiguration(); - + // Check and dump the dialect being used checkDialect(this.dialect); - // Ensure that our static connection provider is used - String defaultConnectionProviderFactoryClass = cfg.getProperty(Environment.CONNECTION_PROVIDER); - cfg.setProperty(Environment.CONNECTION_PROVIDER, SchemaBootstrapConnectionProvider.class.getName()); - SchemaBootstrapConnectionProvider.setBootstrapConnection(connection); - // Update the schema, if required. if (updateSchema) { @@ -1734,7 +1592,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean { try { - createdSchema = updateSchema(cfg, session, connection); + createdSchema = updateSchema(connection); updatedSchema = true; break; } @@ -1780,8 +1638,8 @@ public class SchemaBootstrap extends AbstractLifecycleBean if (! createdSchema) { // verify that all patches have been applied correctly - checkSchemaPatchScripts(cfg, connection, preUpdateScriptPatches, false); // check scripts - checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, false); // check scripts + checkSchemaPatchScripts(connection, preUpdateScriptPatches, false); // check scripts + checkSchemaPatchScripts(connection, postUpdateScriptPatches, false); // check scripts } if (executedStatements != null) @@ -1814,9 +1672,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean throw new BootstrapStopException(); } - // Reset the configuration - cfg.setProperty(Environment.CONNECTION_PROVIDER, defaultConnectionProviderFactoryClass); - if (event != null) { // all done successfully @@ -1853,20 +1708,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean { logger.warn("Error closing DB connection: " + e.getMessage()); } - try - { - if (session != null) - { - session.close(); - } - } - catch (Throwable e) - { - logger.warn("Error closing Hibernate session: " + e.getMessage()); - } - // Remove the connection reference from the threadlocal boostrap - SchemaBootstrapConnectionProvider.setBootstrapConnection(null); - } } @@ -2159,91 +2000,10 @@ public class SchemaBootstrap extends AbstractLifecycleBean return files; } - + @Override protected void onShutdown(ApplicationEvent event) { - // Shut down DB, if required - Class dialectClazz = this.dialect.getClass(); - if (dialectClazz.equals(DerbyDialect.class)) - { - try - { - DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } - // Derby shutdown always triggers an exception, even when clean - catch (Throwable e) - { - } - } - } - - /** - * This is a workaround for the odd Spring-Hibernate interaction during configuration. - * The Hibernate code assumes that schema scripts will be generated during context - * initialization. We want to do it afterwards and have a little more control. Hence this class. - *

- * The connection that is used will not be closed or manipulated in any way. This class - * merely serves to give the connection to Hibernate. - * - * @author Derek Hulley - */ - public static class SchemaBootstrapConnectionProvider extends UserSuppliedConnectionProvider - { - private static ThreadLocal threadLocalConnection = new ThreadLocal(); - - public SchemaBootstrapConnectionProvider() - { - } - - /** - * Set the connection for Hibernate to use for schema generation. - */ - public static void setBootstrapConnection(Connection connection) - { - threadLocalConnection.set(connection); - } - - /** - * Unsets the connection. - */ - @Override - public void close() - { - // Leave the connection well alone, just remove it - threadLocalConnection.set(null); - } - - /** - * Does nothing. The connection was given by a 3rd party and they can close it. - */ - @Override - public void closeConnection(Connection conn) - { - } - - /** - * Does nothing. - */ - @Override - public void configure(Properties props) throws HibernateException - { - } - - /** - * @see #setBootstrapConnection(Connection) - */ - @Override - public Connection getConnection() - { - return threadLocalConnection.get(); - } - - @Override - public boolean supportsAggressiveRelease() - { - return false; - } } /** diff --git a/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java b/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java index cd2b5cf4c7..3c9af0f0da 100644 --- a/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java +++ b/src/main/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImpl.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.domain.schema.script; import java.io.BufferedReader; @@ -42,20 +42,18 @@ import javax.sql.DataSource; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.content.filestore.FileContentWriter; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoMySQLClusterNDBDialect; +import org.alfresco.repo.domain.dialect.MySQLClusterNDBDialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; +import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.util.LogUtil; import org.alfresco.util.TempFileProvider; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.cfg.Configuration; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.MySQLInnoDBDialect; -import org.hibernate.dialect.PostgreSQLDialect; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.orm.hibernate3.LocalSessionFactoryBean; public class ScriptExecutorImpl implements ScriptExecutor @@ -83,7 +81,6 @@ public class ScriptExecutorImpl implements ScriptExecutor private Dialect dialect; private ResourcePatternResolver rpr = new PathMatchingResourcePatternResolver(this.getClass().getClassLoader()); private static Log logger = LogFactory.getLog(ScriptExecutorImpl.class); - private LocalSessionFactoryBean localSessionFactory; private Properties globalProperties; private ThreadLocal executedStatementsThreadLocal = new ThreadLocal(); private DataSource dataSource; @@ -133,17 +130,6 @@ public class ScriptExecutorImpl implements ScriptExecutor { globalProperties = new Properties(); } - - - public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory) - { - this.localSessionFactory = localSessionFactory; - } - - public LocalSessionFactoryBean getLocalSessionFactory() - { - return localSessionFactory; - } public void setDataSource(DataSource dataSource) { @@ -165,12 +151,11 @@ public class ScriptExecutorImpl implements ScriptExecutor @Override public void executeScriptUrl(String scriptUrl) throws Exception { - Configuration cfg = localSessionFactory.getConfiguration(); Connection connection = dataSource.getConnection(); connection.setAutoCommit(true); try { - executeScriptUrl(cfg, connection, scriptUrl); + executeScriptUrl(connection, scriptUrl); } finally { @@ -178,9 +163,9 @@ public class ScriptExecutorImpl implements ScriptExecutor } } - private void executeScriptUrl(Configuration cfg, Connection connection, String scriptUrl) throws Exception + private void executeScriptUrl(Connection connection, String scriptUrl) throws Exception { - Dialect dialect = Dialect.getDialect(cfg.getProperties()); + Dialect dialect = this.dialect; String dialectStr = dialect.getClass().getSimpleName(); InputStream scriptInputStream = getScriptInputStream(dialect.getClass(), scriptUrl); // check that it exists @@ -203,7 +188,7 @@ public class ScriptExecutorImpl implements ScriptExecutor // now execute it String dialectScriptUrl = scriptUrl.replaceAll(PLACEHOLDER_DIALECT, dialect.getClass().getName()); // Replace the script placeholders - executeScriptFile(cfg, connection, tempFile, dialectScriptUrl); + executeScriptFile(connection, tempFile, dialectScriptUrl); } /** @@ -281,19 +266,17 @@ public class ScriptExecutorImpl implements ScriptExecutor } /** - * @param cfg the Hibernate configuration * @param connection the DB connection to use * @param scriptFile the file containing the statements * @param scriptUrl the URL of the script to report. If this is null, the script * is assumed to have been auto-generated. */ private void executeScriptFile( - Configuration cfg, Connection connection, File scriptFile, String scriptUrl) throws Exception { - final Dialect dialect = Dialect.getDialect(cfg.getProperties()); + final Dialect dialect = this.dialect; StringBuilder executedStatements = executedStatementsThreadLocal.get(); if (executedStatements == null) @@ -371,7 +354,7 @@ public class ScriptExecutorImpl implements ScriptExecutor } String includedScriptUrl = sql.substring(10, sql.length()); // Execute the script in line - executeScriptUrl(cfg, connection, includedScriptUrl); + executeScriptUrl(connection, includedScriptUrl); } // Check for variable assignment else if (sql.startsWith("--ASSIGN:")) @@ -546,11 +529,11 @@ public class ScriptExecutorImpl implements ScriptExecutor sql = sql.replaceAll("(?i)TYPE=InnoDB", "ENGINE=InnoDB"); } - if (this.dialect != null && this.dialect instanceof AlfrescoMySQLClusterNDBDialect) + if (this.dialect != null && this.dialect instanceof MySQLClusterNDBDialect) { // note: enable bootstrap on MySQL Cluster NDB /* - * WARNING: Experimental/unsupported - see AlfrescoMySQLClusterNDBDialect ! + * WARNING: Experimental/unsupported - see MySQLClusterNDBDialect ! */ sql = sql.replaceAll("(?i)TYPE=InnoDB", "ENGINE=NDB"); // belts-and-braces sql = sql.replaceAll("(?i)ENGINE=InnoDB", "ENGINE=NDB"); diff --git a/src/main/java/org/alfresco/repo/management/DynamicMBeanExporter.java b/src/main/java/org/alfresco/repo/management/DynamicMBeanExporter.java index 8873016bed..bbe2e49cd1 100644 --- a/src/main/java/org/alfresco/repo/management/DynamicMBeanExporter.java +++ b/src/main/java/org/alfresco/repo/management/DynamicMBeanExporter.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.management; import javax.management.JMException; @@ -30,7 +30,7 @@ import javax.management.MBeanServer; import javax.management.ObjectName; import org.springframework.jmx.export.MBeanExporter; -import org.springframework.jmx.support.MBeanRegistrationSupport; +import org.springframework.jmx.support.RegistrationPolicy; /** * An {@link MBeanExporter} that allows individual MBeans to be registered and unregistered over time. @@ -51,9 +51,9 @@ public class DynamicMBeanExporter extends MBeanExporter implements DynamicMBeanE setServer(server); } - // Make replace existing the default registration behavior - setRegistrationBehavior(MBeanRegistrationSupport.REGISTRATION_REPLACE_EXISTING); - setAutodetectMode(MBeanExporter.AUTODETECT_NONE); + // Make replace existing the default registration behavior + setRegistrationPolicy(RegistrationPolicy.IGNORE_EXISTING); + setAutodetectMode(MBeanExporter.AUTODETECT_NONE); } @Override diff --git a/src/main/java/org/alfresco/repo/management/SafeApplicationEventMulticaster.java b/src/main/java/org/alfresco/repo/management/SafeApplicationEventMulticaster.java index a324392457..baae82464e 100644 --- a/src/main/java/org/alfresco/repo/management/SafeApplicationEventMulticaster.java +++ b/src/main/java/org/alfresco/repo/management/SafeApplicationEventMulticaster.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.management; import java.util.Collection; @@ -49,6 +49,7 @@ import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.GenericApplicationListenerAdapter; import org.springframework.context.event.SmartApplicationListener; import org.springframework.core.OrderComparator; +import org.springframework.core.ResolvableType; /** * Abstract implementation of the {@link ApplicationEventMulticaster} interface, @@ -199,6 +200,12 @@ public class SafeApplicationEventMulticaster implements ApplicationEventMulticas } } + @Override + public void multicastEvent(ApplicationEvent event, ResolvableType eventType) + { + multicastEvent(event); + } + @SuppressWarnings("unchecked") protected void multicastEventInternal(final ApplicationEvent event) { for (final ApplicationListener listener : getApplicationListeners(event)) { diff --git a/src/main/java/org/alfresco/repo/solr/SOLRAdminClient.java b/src/main/java/org/alfresco/repo/solr/SOLRAdminClient.java index 88e5b77cb1..95ce12a82e 100644 --- a/src/main/java/org/alfresco/repo/solr/SOLRAdminClient.java +++ b/src/main/java/org/alfresco/repo/solr/SOLRAdminClient.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.solr; import java.net.MalformedURLException; @@ -33,7 +33,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; - import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.httpclient.HttpClientFactory; import org.alfresco.util.ParameterCheck; @@ -47,12 +46,15 @@ import org.apache.solr.client.solrj.impl.XMLResponseParser; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.NamedList; -import org.quartz.CronTrigger; +import org.quartz.CronScheduleBuilder; +import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobDetail; +import org.quartz.JobKey; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.Trigger; +import org.quartz.TriggerBuilder; import org.springframework.beans.factory.DisposableBean; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisherAware; @@ -333,19 +335,23 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware, Disposab // It is not expected that this will occur during production, but it is possible during automated testing // where application contexts could be rebuilt between test cases, leading to multiple creations of // equivalent Quartz jobs. Quartz disallows the scheduling of multiple jobs with the same name and group. - JobDetail existingJob = scheduler.getJobDetail(jobName, jobGroup); + JobDetail existingJob = scheduler.getJobDetail(new JobKey(jobName, jobGroup)); if (existingJob != null) { - scheduler.deleteJob(jobName, jobGroup); + scheduler.deleteJob(existingJob.getKey()); } - - JobDetail job = new JobDetail(jobName, jobGroup, SOLRWatcherJob.class); - JobDataMap jobDataMap = new JobDataMap(); - jobDataMap.put("SOLR_TRACKER", this); - job.setJobDataMap(jobDataMap); - - trigger = new CronTrigger("SolrWatcherTrigger", jobGroup, solrPingCronExpression); - scheduler.scheduleJob(job, trigger); + JobDataMap jobDataMap = new JobDataMap(); + jobDataMap.put("SOLR_TRACKER", this); + final JobDetail jobDetail = JobBuilder.newJob() + .withIdentity(jobName, jobGroup) + .usingJobData(jobDataMap) + .ofType(SOLRWatcherJob.class) + .build(); + trigger = TriggerBuilder.newTrigger() + .withIdentity("rmt") + .withSchedule(CronScheduleBuilder.cronSchedule(solrPingCronExpression)) + .build(); + scheduler.scheduleJob(jobDetail, trigger); } catch(Exception e) { @@ -355,12 +361,12 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware, Disposab protected void startTimer() throws SchedulerException { - scheduler.resumeTrigger(trigger.getName(), trigger.getGroup()); + scheduler.resumeTrigger(trigger.getKey()); } protected void stopTimer() throws SchedulerException { - scheduler.pauseTrigger(trigger.getName(), trigger.getGroup()); + scheduler.pauseTrigger(trigger.getKey()); } void registerCores(List cores) diff --git a/src/main/java/org/alfresco/repo/transaction/AlfrescoTransactionSupport.java b/src/main/java/org/alfresco/repo/transaction/AlfrescoTransactionSupport.java index 965c94d10a..3014788151 100644 --- a/src/main/java/org/alfresco/repo/transaction/AlfrescoTransactionSupport.java +++ b/src/main/java/org/alfresco/repo/transaction/AlfrescoTransactionSupport.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.transaction; import java.util.Set; @@ -34,7 +34,6 @@ import org.alfresco.util.transaction.TransactionListener; import org.alfresco.util.transaction.TransactionSupportUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.orm.hibernate3.SessionFactoryUtils; import org.springframework.transaction.support.TransactionSynchronizationManager; /** @@ -67,10 +66,8 @@ public abstract class AlfrescoTransactionSupport extends TransactionSupportUtil /** * The order of synchronization set to be 100 less than the Hibernate synchronization order */ - public static final int SESSION_SYNCHRONIZATION_ORDER = - SessionFactoryUtils.SESSION_SYNCHRONIZATION_ORDER - 100; + public static final int SESSION_SYNCHRONIZATION_ORDER = 800; - private static Log logger = LogFactory.getLog(AlfrescoTransactionSupport.class); /** @@ -101,11 +98,6 @@ public abstract class AlfrescoTransactionSupport extends TransactionSupportUtil return TxnReadState.TXN_NONE; } // Find the read-write state of the txn - if (getResource(RESOURCE_KEY_TXN_COMPLETING) != null) - { - // Transaction is completing. For all intents and purposes, we are not in a transaction. - return TxnReadState.TXN_NONE; - } else if (TransactionSynchronizationManager.isCurrentTransactionReadOnly()) { return TxnReadState.TXN_READ_ONLY; @@ -268,13 +260,13 @@ public abstract class AlfrescoTransactionSupport extends TransactionSupportUtil /** * Method that registers a Listener against * the transaction. - *

will be better for the caller - * to only bind once per transaction, if possible. - * - * @param listener the transaction listener - * tasks on - * - * @since 5.0 + *

will be better for the caller + * to only bind once per transaction, if possible. + * + * @param listener the transaction listener + * tasks on + * + * @since 5.0 */ public static void bindListener(TransactionListener listener) { diff --git a/src/main/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java b/src/main/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java index 96c59a6020..5e77b943b5 100644 --- a/src/main/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java +++ b/src/main/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.transaction; import java.lang.reflect.Method; @@ -52,13 +52,6 @@ import org.alfresco.util.LockHelper.LockTryException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ibatis.exceptions.TooManyResultsException; -import org.hibernate.ObjectNotFoundException; -import org.hibernate.StaleObjectStateException; -import org.hibernate.StaleStateException; -import org.hibernate.cache.CacheException; -import org.hibernate.exception.ConstraintViolationException; -import org.hibernate.exception.LockAcquisitionException; -import org.hibernate.exception.SQLGrammarException; import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.ProxyFactory; import org.springframework.dao.ConcurrencyFailureException; @@ -105,20 +98,13 @@ public class RetryingTransactionHelper Class[] coreClasses = new Class[] { ConcurrencyFailureException.class, DeadlockLoserDataAccessException.class, - StaleObjectStateException.class, JdbcUpdateAffectedIncorrectNumberOfRowsException.class, // Similar to StaleObjectState - LockAcquisitionException.class, - ConstraintViolationException.class, UncategorizedSQLException.class, SQLException.class, BatchUpdateException.class, DataIntegrityViolationException.class, LicenseIntegrityException.class, - StaleStateException.class, TooManyResultsException.class, // Expected one result but found multiple (bad key alert) - ObjectNotFoundException.class, - CacheException.class, // Usually a cache replication issue - SQLGrammarException.class, // Actually specific to MS SQL Server 2005 - we check for this LockTryException.class }; @@ -642,11 +628,6 @@ public class RetryingTransactionHelper // Someone decided that the txn should NOT retry return null; } - else if (retryCause instanceof SQLGrammarException - && ((SQLGrammarException) retryCause).getErrorCode() != 3960) - { - return null; - } else if (retryCause instanceof UncategorizedSQLException) { // The exception will have been caused by something else, so check that instead diff --git a/src/main/java/org/alfresco/repo/transaction/RetryingTransactionInterceptor.java b/src/main/java/org/alfresco/repo/transaction/RetryingTransactionInterceptor.java index 08663a5160..fafda6fabc 100755 --- a/src/main/java/org/alfresco/repo/transaction/RetryingTransactionInterceptor.java +++ b/src/main/java/org/alfresco/repo/transaction/RetryingTransactionInterceptor.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.transaction; import java.lang.reflect.Method; @@ -64,7 +64,7 @@ public class RetryingTransactionInterceptor extends TransactionAspectSupport imp method, invocation.getThis().getClass()); final PlatformTransactionManager tm = determineTransactionManager(txnAttr); @SuppressWarnings("deprecation") - final String joinpointIdentification = methodIdentification(invocation.getMethod()); + final String joinpointIdentification = methodIdentification(invocation.getMethod(), invocation.getThis().getClass()); final int propagationBehaviour = txnAttr.getPropagationBehavior(); try { diff --git a/src/main/java/org/alfresco/repo/usage/RepoUsageMonitor.java b/src/main/java/org/alfresco/repo/usage/RepoUsageMonitor.java index 6f9531db00..44380364ae 100644 --- a/src/main/java/org/alfresco/repo/usage/RepoUsageMonitor.java +++ b/src/main/java/org/alfresco/repo/usage/RepoUsageMonitor.java @@ -45,14 +45,16 @@ import org.alfresco.util.PropertyCheck; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.quartz.Job; +import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.quartz.Scheduler; import org.quartz.SchedulerException; +import org.quartz.SimpleScheduleBuilder; import org.quartz.Trigger; -import org.quartz.TriggerUtils; +import org.quartz.TriggerBuilder; /** * This component monitors the repository usages, issuing warnings and errors @@ -124,17 +126,24 @@ public class RepoUsageMonitor implements RepoUsageComponent.RestrictionObserver PropertyCheck.mandatory(this, "jobLockService", jobLockService); // Trigger the scheduled updates - final JobDetail jobDetail = new JobDetail("rmj", Scheduler.DEFAULT_GROUP, RepoUsageMonitorJob.class); - jobDetail.getJobDataMap().put("RepoUsageMonitor", this); - final Trigger trigger = TriggerUtils.makeHourlyTrigger(12); // every 12 hours - trigger.setStartTime(new Date(System.currentTimeMillis() + 60L * 60L * 1000L)); // one hour from now - trigger.setName("rmt"); - trigger.setGroup(Scheduler.DEFAULT_GROUP); - + JobDataMap jobDataMap = new JobDataMap(); + jobDataMap.put("RepoUsageMonitor", this); + final JobDetail jobDetail = JobBuilder.newJob() + .withIdentity("rmj") + .usingJobData(jobDataMap) + .ofType(RepoUsageMonitorJob.class) + .build(); + + final Trigger trigger = TriggerBuilder.newTrigger() + .withIdentity("rmt") + .withSchedule(SimpleScheduleBuilder.repeatHourlyForever().withIntervalInHours(12)) + .startAt(new Date(System.currentTimeMillis() + 60L * 60L * 1000L)) + .build(); + repoUsageComponent.observeRestrictions(this); // Unschedule in case it was scheduled in an earlier retry of the transaction - scheduler.unscheduleJob("rmt", Scheduler.DEFAULT_GROUP); + scheduler.unscheduleJob(trigger.getKey()); scheduler.scheduleJob(jobDetail, trigger); } diff --git a/src/main/java/org/alfresco/schedule/AlfrescoSchedulerAccessorBean.java b/src/main/java/org/alfresco/schedule/AlfrescoSchedulerAccessorBean.java new file mode 100644 index 0000000000..77a0afb2f9 --- /dev/null +++ b/src/main/java/org/alfresco/schedule/AlfrescoSchedulerAccessorBean.java @@ -0,0 +1,83 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.schedule; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import org.quartz.SchedulerException; +import org.quartz.Trigger; +import org.quartz.TriggerKey; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.lang.Nullable; +import org.springframework.scheduling.quartz.SchedulerAccessorBean; + +/** + * The class is designed to add enabled check to switch on/off the triggers scheduling. + * The default is true. + * + * @since 6.0 + * + * @author amukha + */ +public class AlfrescoSchedulerAccessorBean extends SchedulerAccessorBean implements DisposableBean +{ + @Nullable + private List triggerKeys; + private boolean enabled = true; + + public boolean isEnabled() + { + return enabled; + } + + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + @Override + public void setTriggers(Trigger... triggers) + { + super.setTriggers(triggers); + this.triggerKeys = Arrays.stream(triggers).map(Trigger::getKey).collect(Collectors.toList()); + } + + @Override + public void afterPropertiesSet() throws SchedulerException + { + if (isEnabled()) + { + super.afterPropertiesSet(); + } + } + + @Override + public void destroy() throws Exception + { + getScheduler().unscheduleJobs(triggerKeys); + } +} diff --git a/src/main/java/org/alfresco/util/DatabaseMetaDataHelper.java b/src/main/java/org/alfresco/util/DatabaseMetaDataHelper.java index e079008398..f4629046f3 100644 --- a/src/main/java/org/alfresco/util/DatabaseMetaDataHelper.java +++ b/src/main/java/org/alfresco/util/DatabaseMetaDataHelper.java @@ -28,11 +28,8 @@ package org.alfresco.util; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.cfg.Configuration; -import org.springframework.orm.hibernate3.LocalSessionFactoryBean; /** * Helper class to collect all of our DatabaseMetaData interpretations in one place. @@ -40,98 +37,63 @@ import org.springframework.orm.hibernate3.LocalSessionFactoryBean; * @author sfrensley * */ -public class DatabaseMetaDataHelper { +public class DatabaseMetaDataHelper +{ private static Log logger = LogFactory.getLog(DatabaseMetaDataHelper.class); - private Configuration cfg; - - public void setLocalSessionFactory(LocalSessionFactoryBean localSessionFactory) - { - this.cfg = localSessionFactory.getConfiguration(); - } - /** - * Trys to determine the schema name from the DatabaseMetaData obtained from the Connection. + * Tries to determine the schema name from the DatabaseMetaData obtained from the Connection. * @param connection A database connection * @return String */ - private String getSchemaFromConnection(Connection connection) - { - - if (connection == null) { - logger.error("Unable to determine schema due to null connection."); - return null; - } - - ResultSet schemas = null; - - try - { - final DatabaseMetaData dbmd = connection.getMetaData(); - - // Assume that if there are schemas, we want the one named after the connection user or the one called "dbo" (MS - // SQL hack) - String schema = null; - schemas = dbmd.getSchemas(); - while (schemas.next()) - { - final String thisSchema = schemas.getString("TABLE_SCHEM"); - if (thisSchema.equals(dbmd.getUserName()) || thisSchema.equalsIgnoreCase("dbo")) - { - schema = thisSchema; - break; - } - } - return schema; - } - catch (Exception e) - { - logger.error("Unable to determine current schema.",e); - } - finally - { - if (schemas != null) - { - try - { - schemas.close(); - } - catch (Exception e) - { - //noop - } - } - } - return null; - } - public String getSchema(Connection connection) { - String schema = null; - - if (this.cfg != null) + if (connection == null) { - String tmpSchema = this.cfg.getProperty("hibernate.default_schema"); - if (tmpSchema != null && tmpSchema.trim().length() > 0) + logger.error("Unable to determine schema due to null connection."); + return null; + } + + ResultSet schemas = null; + + try + { + final DatabaseMetaData dbmd = connection.getMetaData(); + + // Assume that if there are schemas, we want the one named after the connection user or the one called "dbo" (MS + // SQL hack) + String schema = null; + schemas = dbmd.getSchemas(); + while (schemas.next()) { - schema = tmpSchema; + final String thisSchema = schemas.getString("TABLE_SCHEM"); + if (thisSchema.equals(dbmd.getUserName()) || thisSchema.equalsIgnoreCase("dbo")) + { + schema = thisSchema; + break; + } + } + return schema; + } + catch (Exception e) + { + logger.error("Unable to determine current schema.",e); + } + finally + { + if (schemas != null) + { + try + { + schemas.close(); + } + catch (Exception e) + { + //noop + } } } - - // if hibernate.default_schema was specified as a system property, then override previous value - String tmpSchema = System.getProperty("hibernate.default_schema"); - if (tmpSchema != null && tmpSchema.length() > 0) - { - schema = tmpSchema; - } - - if (schema == null) - { - schema = getSchemaFromConnection(connection); - } - - return schema; + return null; } - } diff --git a/src/main/java/org/alfresco/util/resource/HierarchicalResourceLoader.java b/src/main/java/org/alfresco/util/resource/HierarchicalResourceLoader.java new file mode 100644 index 0000000000..27d3b5d5da --- /dev/null +++ b/src/main/java/org/alfresco/util/resource/HierarchicalResourceLoader.java @@ -0,0 +1,210 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.util.resource; + +import org.alfresco.util.PropertyCheck; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; + +/** + * Locate resources by using a class hierarchy to drive the search. The well-known + * placeholder {@link #DEFAULT_DIALECT_PLACEHOLDER} is replaced with successive class + * names starting from the {@link #setDialectClass(String) dialect class} and + * progressing up the hierarchy until the {@link #setDialectBaseClass(String) base class} + * is reached. A full resource search using Spring's {@link DefaultResourceLoader} is + * done at each point until the resource is found or the base of the class hierarchy is + * reached. + *

+ * For example assume classpath resources:
+ *

+ *    RESOURCE 1: config/ibatis/org.hibernate.dialect.Dialect/SqlMap-DOG.xml
+ *    RESOURCE 2: config/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/SqlMap-DOG.xml
+ *    RESOURCE 3: config/ibatis/org.hibernate.dialect.Dialect/SqlMap-CAT.xml
+ *    RESOURCE 4: config/ibatis/org.hibernate.dialect.MySQLDialect/SqlMap-CAT.xml
+ * 
+ * and
+ *
+ *    dialectBaseClass = org.hibernate.dialect.Dialect
+ * 
+ * For dialect org.hibernate.dialect.MySQLInnoDBDialect the following will be returned:
+ *
+ *    config/ibatis/#resource.dialect#/SqlMap-DOG.xml == RESOURCE 2
+ *    config/ibatis/#resource.dialect#/SqlMap-CAT.xml == RESOURCE 4
+ * 
+ * For dialectorg.hibernate.dialect.MySQLDBDialect the following will be returned:
+ *
+ *    config/ibatis/#resource.dialect#/SqlMap-DOG.xml == RESOURCE 1
+ *    config/ibatis/#resource.dialect#/SqlMap-CAT.xml == RESOURCE 4
+ * 
+ * For dialectorg.hibernate.dialect.Dialect the following will be returned:
+ *
+ *    config/ibatis/#resource.dialect#/SqlMap-DOG.xml == RESOURCE 1
+ *    config/ibatis/#resource.dialect#/SqlMap-CAT.xml == RESOURCE 3
+ * 
+ * + * @author Derek Hulley + * @since 3.2 (Mobile) + */ +public class HierarchicalResourceLoader extends DefaultResourceLoader implements InitializingBean +{ + public static final String DEFAULT_DIALECT_PLACEHOLDER = "#resource.dialect#"; + public static final String DEFAULT_DIALECT_REGEX = "\\#resource\\.dialect\\#"; + + private String dialectBaseClass; + private String dialectClass; + + /** + * Create a new HierarchicalResourceLoader. + */ + public HierarchicalResourceLoader() + { + super(); + } + + /** + * Set the class to be used during hierarchical dialect replacement. Searches for the + * configuration location will not go further up the hierarchy than this class. + * + * @param className the name of the class or interface + */ + public void setDialectBaseClass(String className) + { + this.dialectBaseClass = className; + } + + public void setDialectClass(String className) + { + this.dialectClass = className; + } + + public void afterPropertiesSet() throws Exception + { + PropertyCheck.mandatory(this, "dialectBaseClass", dialectBaseClass); + PropertyCheck.mandatory(this, "dialectClass", dialectClass); + } + + /** + * Get a resource using the defined class hierarchy as a search path. + * + * @param location the location including a {@link #DEFAULT_DIALECT_PLACEHOLDER placeholder} + * @return a resource found by successive searches using class name replacement, or + * null if not found. + */ + @SuppressWarnings("unchecked") + @Override + public Resource getResource(String location) + { + if (dialectClass == null || dialectBaseClass == null) + { + return super.getResource(location); + } + + // If a property value has not been substituted, extract the property name and load from system + String dialectBaseClassStr = dialectBaseClass; + if (!PropertyCheck.isValidPropertyString(dialectBaseClass)) + { + String prop = PropertyCheck.getPropertyName(dialectBaseClass); + dialectBaseClassStr = System.getProperty(prop, dialectBaseClass); + } + String dialectClassStr = dialectClass; + if (!PropertyCheck.isValidPropertyString(dialectClass)) + { + String prop = PropertyCheck.getPropertyName(dialectClass); + dialectClassStr = System.getProperty(prop, dialectClass); + } + + Class dialectBaseClazz; + try + { + dialectBaseClazz = Class.forName(dialectBaseClassStr); + } + catch (ClassNotFoundException e) + { + throw new RuntimeException("Dialect base class not found: " + dialectBaseClassStr); + } + Class dialectClazz; + try + { + dialectClazz = Class.forName(dialectClassStr); + } + catch (ClassNotFoundException e) + { + throw new RuntimeException("Dialect class not found: " + dialectClassStr); + } + // Ensure that we are dealing with classes and not interfaces + if (!Object.class.isAssignableFrom(dialectBaseClazz)) + { + throw new RuntimeException( + "Dialect base class must be derived from java.lang.Object: " + + dialectBaseClazz.getName()); + } + if (!Object.class.isAssignableFrom(dialectClazz)) + { + throw new RuntimeException( + "Dialect class must be derived from java.lang.Object: " + + dialectClazz.getName()); + } + // We expect these to be in the same hierarchy + if (!dialectBaseClazz.isAssignableFrom(dialectClazz)) + { + throw new RuntimeException( + "Non-existent HierarchicalResourceLoader hierarchy: " + + dialectBaseClazz.getName() + " is not a superclass of " + dialectClazz); + } + + Class clazz = dialectClazz; + Resource resource = null; + while (resource == null) + { + // Do replacement + String newLocation = location.replaceAll(DEFAULT_DIALECT_REGEX, clazz.getName()); + resource = super.getResource(newLocation); + if (resource != null && resource.exists()) + { + // Found + break; + } + // Not found + resource = null; + // Are we at the base class? + if (clazz.equals(dialectBaseClazz)) + { + // We don't go any further + break; + } + // Move up the hierarchy + clazz = clazz.getSuperclass(); + if (clazz == null) + { + throw new RuntimeException( + "Non-existent HierarchicalResourceLoaderBean hierarchy: " + + dialectBaseClazz.getName() + " is not a superclass of " + dialectClazz); + } + } + return resource; + } +} diff --git a/src/main/java/org/alfresco/util/schemacomp/DiffContext.java b/src/main/java/org/alfresco/util/schemacomp/DiffContext.java index ab71a915bc..3df0d18128 100644 --- a/src/main/java/org/alfresco/util/schemacomp/DiffContext.java +++ b/src/main/java/org/alfresco/util/schemacomp/DiffContext.java @@ -1,32 +1,32 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.util.schemacomp.model.Schema; -import org.hibernate.dialect.Dialect; /** * A context made available to schema differencing and validation operations. It supplies information diff --git a/src/main/java/org/alfresco/util/schemacomp/ExportDb.java b/src/main/java/org/alfresco/util/schemacomp/ExportDb.java index 2e553c8187..2768af31cc 100644 --- a/src/main/java/org/alfresco/util/schemacomp/ExportDb.java +++ b/src/main/java/org/alfresco/util/schemacomp/ExportDb.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp; import java.lang.reflect.Field; @@ -35,6 +35,8 @@ import java.util.TreeMap; import javax.sql.DataSource; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.TypeNames; import org.alfresco.service.descriptor.Descriptor; import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.util.DatabaseMetaDataHelper; @@ -48,8 +50,6 @@ import org.alfresco.util.schemacomp.model.Sequence; import org.alfresco.util.schemacomp.model.Table; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.TypeNames; import org.springframework.context.ApplicationContext; @@ -172,8 +172,6 @@ public class ExportDb } } } - - public void execute() { diff --git a/src/main/java/org/alfresco/util/schemacomp/SchemaComparator.java b/src/main/java/org/alfresco/util/schemacomp/SchemaComparator.java index 1f0e1c5638..31e4992ad1 100644 --- a/src/main/java/org/alfresco/util/schemacomp/SchemaComparator.java +++ b/src/main/java/org/alfresco/util/schemacomp/SchemaComparator.java @@ -1,33 +1,33 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.util.schemacomp.model.Schema; import org.apache.xml.serialize.LineSeparator; -import org.hibernate.dialect.Dialect; /** * Compares two abstract database schemas, a reference schema and a target schema (the schema to check for validity). diff --git a/src/main/java/org/alfresco/util/schemacomp/validator/NameValidator.java b/src/main/java/org/alfresco/util/schemacomp/validator/NameValidator.java index 0d4f7bd68d..b9ec84a448 100644 --- a/src/main/java/org/alfresco/util/schemacomp/validator/NameValidator.java +++ b/src/main/java/org/alfresco/util/schemacomp/validator/NameValidator.java @@ -1,34 +1,35 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.validator; import java.util.Set; import java.util.TreeSet; import java.util.regex.Pattern; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.util.ParameterCheck; import org.alfresco.util.schemacomp.DbProperty; import org.alfresco.util.schemacomp.DiffContext; @@ -36,7 +37,6 @@ import org.alfresco.util.schemacomp.ValidationResult; import org.alfresco.util.schemacomp.model.DbObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.dialect.Dialect; import org.springframework.extensions.surf.util.I18NUtil; /** diff --git a/src/main/resources/alfresco/action-services-context.xml b/src/main/resources/alfresco/action-services-context.xml index fef552606a..e7ce0542c7 100644 --- a/src/main/resources/alfresco/action-services-context.xml +++ b/src/main/resources/alfresco/action-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -322,42 +323,42 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/alfresco/activiti-context.xml b/src/main/resources/alfresco/activiti-context.xml index 4540680fdb..2572fa3bf1 100644 --- a/src/main/resources/alfresco/activiti-context.xml +++ b/src/main/resources/alfresco/activiti-context.xml @@ -5,9 +5,9 @@ xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> - + - - - + + @@ -12,7 +14,6 @@ - diff --git a/src/main/resources/alfresco/application-context-highlevel.xml b/src/main/resources/alfresco/application-context-highlevel.xml index 7eba2d1e2b..009a103452 100644 --- a/src/main/resources/alfresco/application-context-highlevel.xml +++ b/src/main/resources/alfresco/application-context-highlevel.xml @@ -1,8 +1,10 @@ - + - - + diff --git a/src/main/resources/alfresco/application-context.xml b/src/main/resources/alfresco/application-context.xml index eb8dac8566..414bcf0bfc 100644 --- a/src/main/resources/alfresco/application-context.xml +++ b/src/main/resources/alfresco/application-context.xml @@ -1,9 +1,10 @@ - - - - + + - - - org.alfresco.repo.attributes.PropTablesCleanupJob + + + + + + + + + + + + + + - - - + @@ -29,19 +37,4 @@ - - - - - - - - - - ${attributes.propcleaner.cronExpression} - - - ${system.cronJob.startDelayMinutes} - - \ No newline at end of file diff --git a/src/main/resources/alfresco/audit-services-context.xml b/src/main/resources/alfresco/audit-services-context.xml index f542f0b4af..229703437a 100644 --- a/src/main/resources/alfresco/audit-services-context.xml +++ b/src/main/resources/alfresco/audit-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/authentication-services-context.xml b/src/main/resources/alfresco/authentication-services-context.xml index 86bee7cb8b..b27b303117 100644 --- a/src/main/resources/alfresco/authentication-services-context.xml +++ b/src/main/resources/alfresco/authentication-services-context.xml @@ -1,6 +1,4 @@ - - @@ -21,8 +19,10 @@ - - + diff --git a/src/main/resources/alfresco/authority-services-context.xml b/src/main/resources/alfresco/authority-services-context.xml index 1c575d1766..59994545bb 100644 --- a/src/main/resources/alfresco/authority-services-context.xml +++ b/src/main/resources/alfresco/authority-services-context.xml @@ -1,6 +1,4 @@ - - @@ -10,7 +8,10 @@ - + diff --git a/src/main/resources/alfresco/blog-context.xml b/src/main/resources/alfresco/blog-context.xml index ccbea96f92..ab9004f09a 100644 --- a/src/main/resources/alfresco/blog-context.xml +++ b/src/main/resources/alfresco/blog-context.xml @@ -1,7 +1,9 @@ - + - @@ -12,7 +14,7 @@ - + @@ -120,10 +122,10 @@ - + - + diff --git a/src/main/resources/alfresco/bootstrap-context.xml b/src/main/resources/alfresco/bootstrap-context.xml index 4589c521a1..af3cea14c2 100644 --- a/src/main/resources/alfresco/bootstrap-context.xml +++ b/src/main/resources/alfresco/bootstrap-context.xml @@ -1,7 +1,4 @@ - - - - + - @@ -66,9 +63,6 @@ - - - @@ -78,9 +72,6 @@ ${system.maximumStringLength} - - ${system.hibernateMaxExecutions} - ${db.schema.name} @@ -107,12 +98,6 @@ - - - - - - @@ -131,23 +116,23 @@ - - - - - - + + + + + + - - + + - - + + @@ -746,7 +731,7 @@ - + diff --git a/src/main/resources/alfresco/bulk-import-context.xml b/src/main/resources/alfresco/bulk-import-context.xml index 2bfad037d5..1553c6bd73 100644 --- a/src/main/resources/alfresco/bulk-import-context.xml +++ b/src/main/resources/alfresco/bulk-import-context.xml @@ -5,9 +5,9 @@ xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util - http://www.springframework.org/schema/util/spring-util-3.0.xsd"> + http://www.springframework.org/schema/util/spring-util.xsd"> diff --git a/src/main/resources/alfresco/cache-context.xml b/src/main/resources/alfresco/cache-context.xml index b7de524e9f..e6145a464f 100644 --- a/src/main/resources/alfresco/cache-context.xml +++ b/src/main/resources/alfresco/cache-context.xml @@ -1,11 +1,12 @@ - - - + diff --git a/src/main/resources/alfresco/comment-services-context.xml b/src/main/resources/alfresco/comment-services-context.xml index b23d7f3fad..f8c53a5d2c 100644 --- a/src/main/resources/alfresco/comment-services-context.xml +++ b/src/main/resources/alfresco/comment-services-context.xml @@ -1,7 +1,9 @@ - + - @@ -31,10 +33,10 @@ - + - + diff --git a/src/main/resources/alfresco/content-services-context.xml b/src/main/resources/alfresco/content-services-context.xml index 695c22b9bf..4cb12a67e7 100644 --- a/src/main/resources/alfresco/content-services-context.xml +++ b/src/main/resources/alfresco/content-services-context.xml @@ -1,7 +1,8 @@ - - - + - - - + diff --git a/src/main/resources/alfresco/core-services-context.xml b/src/main/resources/alfresco/core-services-context.xml index add0fea2da..efe69da7b7 100644 --- a/src/main/resources/alfresco/core-services-context.xml +++ b/src/main/resources/alfresco/core-services-context.xml @@ -1,8 +1,10 @@ - - + + - - + @@ -124,11 +126,11 @@ - + - + @@ -232,6 +234,15 @@ + + + + + + + + + ${db.url} @@ -245,9 +256,6 @@ - - - @@ -649,7 +657,7 @@ - + diff --git a/src/main/resources/alfresco/custom-model-management-services-context.xml b/src/main/resources/alfresco/custom-model-management-services-context.xml index 4c1ee1ecd0..53b3ad217e 100644 --- a/src/main/resources/alfresco/custom-model-management-services-context.xml +++ b/src/main/resources/alfresco/custom-model-management-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/dao/dao-context.xml b/src/main/resources/alfresco/dao/dao-context.xml index e48997b2d8..5e2a523369 100644 --- a/src/main/resources/alfresco/dao/dao-context.xml +++ b/src/main/resources/alfresco/dao/dao-context.xml @@ -1,7 +1,8 @@ - - - + @@ -11,7 +12,7 @@ org.alfresco.repo.domain.control.ControlDAO - org.hibernate.dialect.Dialect + org.alfresco.repo.domain.dialect.Dialect @@ -20,13 +21,13 @@ - - + parent="controlDAO.org.alfresco.repo.domain.dialect.Dialect"> @@ -58,7 +59,7 @@ org.alfresco.repo.domain.patch.PatchDAO - org.hibernate.dialect.Dialect + org.alfresco.repo.domain.dialect.Dialect @@ -73,9 +74,9 @@ - - - + + + @@ -109,7 +110,7 @@ org.alfresco.repo.domain.node.NodeDAO - org.hibernate.dialect.Dialect + org.alfresco.repo.domain.dialect.Dialect @@ -141,12 +142,12 @@ - - - + + + - - + + @@ -185,9 +186,9 @@ - - - + + + diff --git a/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.hibernate.dialect.AlfrescoMariaDBDialect/Schema-Reference-ACT.xml b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MariaDBDialect/Schema-Reference-ACT.xml similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.hibernate.dialect.AlfrescoMariaDBDialect/Schema-Reference-ACT.xml rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MariaDBDialect/Schema-Reference-ACT.xml diff --git a/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.hibernate.dialect.AlfrescoMariaDBDialect/Schema-Reference-ALF.xml b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MariaDBDialect/Schema-Reference-ALF.xml similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.hibernate.dialect.AlfrescoMariaDBDialect/Schema-Reference-ALF.xml rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MariaDBDialect/Schema-Reference-ALF.xml diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-ActivityTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-ActivityTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-ActivityTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-ActivityTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuditTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuditTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuditTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuditTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuthorizationTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuthorizationTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuthorizationTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-AuthorizationTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-LockTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-LockTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-LockTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-LockTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-PropertyValueTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-PropertyValueTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-PropertyValueTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-PropertyValueTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-RepoTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-RepoTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-RepoTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-RepoTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-SubscriptionTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-SubscriptionTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-SubscriptionTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-SubscriptionTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-TenantTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-TenantTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-TenantTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-TenantTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-UsageTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-UsageTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoCreate-UsageTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/AlfrescoCreate-UsageTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/Schema-Reference-ACT.xml diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ALF.xml b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/Schema-Reference-ALF.xml similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.MySQLInnoDBDialect/Schema-Reference-ALF.xml rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/Schema-Reference-ALF.xml diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-ActivityTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-ActivityTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-ActivityTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-ActivityTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AuditTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-AuditTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AuditTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-AuditTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AuthorizationTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-AuthorizationTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-AuthorizationTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-AuthorizationTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-ContentTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-ContentTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-ContentTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-ContentTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-ContentUrlEncryptionTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-LockTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-LockTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-LockTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-LockTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-PropertyValueTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-PropertyValueTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-PropertyValueTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-PropertyValueTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-RepoTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-RepoTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-RepoTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-RepoTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-SubscriptionTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-SubscriptionTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-SubscriptionTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-SubscriptionTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-TenantTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-TenantTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-TenantTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-TenantTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-UsageTables.sql b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-UsageTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/AlfrescoCreate-UsageTables.sql rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/AlfrescoCreate-UsageTables.sql diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/Schema-Reference-ACT.xml diff --git a/src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ALF.xml b/src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/Schema-Reference-ALF.xml similarity index 100% rename from src/main/resources/alfresco/dbscripts/create/org.hibernate.dialect.PostgreSQLDialect/Schema-Reference-ALF.xml rename to src/main/resources/alfresco/dbscripts/create/org.alfresco.repo.domain.dialect.PostgreSQLDialect/Schema-Reference-ALF.xml diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.Dialect/AclChangeSet-Tracking2.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.Dialect/AclChangeSet-Tracking2.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.Dialect/AclChangeSet-Tracking2.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.Dialect/AclChangeSet-Tracking2.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.Dialect/ActivitiTaskIdIndexes.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.Dialect/ActivitiTaskIdIndexes.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.Dialect/ActivitiTaskIdIndexes.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.Dialect/ActivitiTaskIdIndexes.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.Dialect/Solr-Tracking.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.Dialect/Solr-Tracking.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.Dialect/Solr-Tracking.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.Dialect/Solr-Tracking.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.MySQLInnoDBDialect/Solr-Tracking.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/Solr-Tracking.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.0/org.hibernate.dialect.MySQLInnoDBDialect/Solr-Tracking.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/Solr-Tracking.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/drop-activiti-feed-format.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/drop-activiti-feed-format.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/drop-activiti-feed-format.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/drop-activiti-feed-format.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/dropAlfQnameFKIndexes.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/dropAlfQnameFKIndexes.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/dropAlfQnameFKIndexes.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/dropAlfQnameFKIndexes.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/fix-Repo-seqs-order.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/fix-Repo-seqs-order.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/fix-Repo-seqs-order.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/fix-Repo-seqs-order.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/increase-column-size-activiti.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/increase-column-size-activiti.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/increase-column-size-activiti.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/increase-column-size-activiti.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/remove-column-activiti.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/remove-column-activiti.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/remove-column-activiti.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/remove-column-activiti.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/rename-constraint-activiti.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/rename-constraint-activiti.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/rename-constraint-activiti.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/rename-constraint-activiti.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/update-activiti-nullable-columns.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/update-activiti-nullable-columns.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/update-activiti-nullable-columns.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.Dialect/update-activiti-nullable-columns.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/ChildAssoc-OrderBy.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/ChildAssoc-OrderBy.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/ChildAssoc-OrderBy.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/ChildAssoc-OrderBy.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/NodeDeleted.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/NodeDeleted.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/NodeDeleted.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/NodeDeleted.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/createIdxAlfNodeTQN.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/createIdxAlfNodeTQN.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/createIdxAlfNodeTQN.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/createIdxAlfNodeTQN.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/dropAlfQnameFKIndexes.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/dropAlfQnameFKIndexes.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/dropAlfQnameFKIndexes.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/dropAlfQnameFKIndexes.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/increase-column-size-activiti.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/increase-column-size-activiti.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.MySQLInnoDBDialect/increase-column-size-activiti.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/increase-column-size-activiti.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/ChildAssoc-OrderBy.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/ChildAssoc-OrderBy.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/ChildAssoc-OrderBy.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/ChildAssoc-OrderBy.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/NodeDeleted.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/NodeDeleted.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/NodeDeleted.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/NodeDeleted.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/createIdxAlfNodeTQN.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/createIdxAlfNodeTQN.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/createIdxAlfNodeTQN.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/createIdxAlfNodeTQN.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/increase-column-size-activiti.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/increase-column-size-activiti.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.PostgreSQLDialect/increase-column-size-activiti.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/increase-column-size-activiti.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/add-activti-index-historic-activity.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/add-activti-index-historic-activity.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/add-activti-index-historic-activity.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/add-activti-index-historic-activity.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/metadata-query-indexes.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/metadata-query-indexes.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/metadata-query-indexes.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/metadata-query-indexes.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/remove-index-acl_id.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/remove-index-acl_id.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/remove-index-acl_id.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/remove-index-acl_id.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/remove-old-index-act.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/remove-old-index-act.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/remove-old-index-act.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/remove-old-index-act.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/restructure-idx_alf_nprop_s-MSSQL.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/restructure-idx_alf_nprop_s-MSSQL.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.Dialect/restructure-idx_alf_nprop_s-MSSQL.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.Dialect/restructure-idx_alf_nprop_s-MSSQL.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-10.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-10.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-10.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-10.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-11.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-11.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-11.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-11.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-13.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-13.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-13.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-13.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/metadata-query-indexes.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/metadata-query-indexes.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/metadata-query-indexes.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/metadata-query-indexes.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/migrate-activiti-workflows.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/migrate-activiti-workflows.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/migrate-activiti-workflows.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/migrate-activiti-workflows.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/migrate-locale-multilingual.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/migrate-locale-multilingual.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/migrate-locale-multilingual.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/migrate-locale-multilingual.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-old-index-act.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/remove-old-index-act.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-old-index-act.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/remove-old-index-act.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-10.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-10.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-10.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-10.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-11.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-11.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-11.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-11.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-13.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-13.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-13.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-13.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/migrate-activiti-workflows.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/migrate-activiti-workflows.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/migrate-activiti-workflows.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/migrate-activiti-workflows.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/migrate-locale-multilingual.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/migrate-locale-multilingual.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/migrate-locale-multilingual.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/migrate-locale-multilingual.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/remove-old-index-act.sql b/src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/remove-old-index-act.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/4.2/org.hibernate.dialect.PostgreSQLDialect/remove-old-index-act.sql rename to src/main/resources/alfresco/dbscripts/upgrade/4.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/remove-old-index-act.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/activiti-correct-tenant-id-MSSQL.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/activiti-correct-tenant-id-MSSQL.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/activiti-correct-tenant-id-MSSQL.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/activiti-correct-tenant-id-MSSQL.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/activiti-del-unused-after-5-16-2.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/activiti-del-unused-after-5-16-2.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/activiti-del-unused-after-5-16-2.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/activiti-del-unused-after-5-16-2.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/activiti-upgrade-5-16-4.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/activiti-upgrade-5-16-4.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/activiti-upgrade-5-16-4.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/activiti-upgrade-5-16-4.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/update-activiti-default-timestamp-column.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/update-activiti-default-timestamp-column.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.Dialect/update-activiti-default-timestamp-column.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.Dialect/update-activiti-default-timestamp-column.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-16-2.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-16-2.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-16-2.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-16-2.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.MySQLInnoDBDialect/update-activiti-default-timestamp-column.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/update-activiti-default-timestamp-column.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.MySQLInnoDBDialect/update-activiti-default-timestamp-column.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/update-activiti-default-timestamp-column.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-16-2.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-16-2.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.0/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-16-2.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.0/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-16-2.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.Dialect/activiti-upgrade-5.19.0.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.Dialect/activiti-upgrade-5.19.0.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.Dialect/activiti-upgrade-5.19.0.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.Dialect/activiti-upgrade-5.19.0.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.Dialect/metadata-query-indexes-2.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.Dialect/metadata-query-indexes-2.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.Dialect/metadata-query-indexes-2.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.Dialect/metadata-query-indexes-2.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-19-0.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-19-0.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.MySQLInnoDBDialect/activiti-upgrade-5-19-0.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activiti-upgrade-5-19-0.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.MySQLInnoDBDialect/metadata-query-indexes-2.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/metadata-query-indexes-2.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.MySQLInnoDBDialect/metadata-query-indexes-2.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/metadata-query-indexes-2.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-19-0.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-19-0.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.1/org.hibernate.dialect.PostgreSQLDialect/activiti-upgrade-5-19-0.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.1/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activiti-upgrade-5-19-0.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-jbpm-tables-from-db.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/remove-jbpm-tables-from-db.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.2/org.hibernate.dialect.MySQLInnoDBDialect/remove-jbpm-tables-from-db.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.2/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/remove-jbpm-tables-from-db.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/5.2/org.hibernate.dialect.PostgreSQLDialect/remove-jbpm-tables-from-db.sql b/src/main/resources/alfresco/dbscripts/upgrade/5.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/remove-jbpm-tables-from-db.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/5.2/org.hibernate.dialect.PostgreSQLDialect/remove-jbpm-tables-from-db.sql rename to src/main/resources/alfresco/dbscripts/upgrade/5.2/org.alfresco.repo.domain.dialect.PostgreSQLDialect/remove-jbpm-tables-from-db.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/6.0/org.hibernate.dialect.Dialect/change-set-indexes.sql b/src/main/resources/alfresco/dbscripts/upgrade/6.0/org.alfresco.repo.domain.dialect.Dialect/change-set-indexes.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/6.0/org.hibernate.dialect.Dialect/change-set-indexes.sql rename to src/main/resources/alfresco/dbscripts/upgrade/6.0/org.alfresco.repo.domain.dialect.Dialect/change-set-indexes.sql diff --git a/src/main/resources/alfresco/dbscripts/upgrade/6.0/org.hibernate.dialect.MySQLInnoDBDialect/change-set-indexes.sql b/src/main/resources/alfresco/dbscripts/upgrade/6.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/change-set-indexes.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/upgrade/6.0/org.hibernate.dialect.MySQLInnoDBDialect/change-set-indexes.sql rename to src/main/resources/alfresco/dbscripts/upgrade/6.0/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/change-set-indexes.sql diff --git a/src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.MySQLInnoDBDialect/CleanAlfPropTables.sql b/src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/CleanAlfPropTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.MySQLInnoDBDialect/CleanAlfPropTables.sql rename to src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/CleanAlfPropTables.sql diff --git a/src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.MySQLInnoDBDialect/CleanAlfPropTablesPostExec.sql b/src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/CleanAlfPropTablesPostExec.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.MySQLInnoDBDialect/CleanAlfPropTablesPostExec.sql rename to src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/CleanAlfPropTablesPostExec.sql diff --git a/src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.PostgreSQLDialect/CleanAlfPropTables.sql b/src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.PostgreSQLDialect/CleanAlfPropTables.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.PostgreSQLDialect/CleanAlfPropTables.sql rename to src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.PostgreSQLDialect/CleanAlfPropTables.sql diff --git a/src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.PostgreSQLDialect/CleanAlfPropTablesPostExec.sql b/src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.PostgreSQLDialect/CleanAlfPropTablesPostExec.sql similarity index 100% rename from src/main/resources/alfresco/dbscripts/utility/org.hibernate.dialect.PostgreSQLDialect/CleanAlfPropTablesPostExec.sql rename to src/main/resources/alfresco/dbscripts/utility/org.alfresco.repo.domain.dialect.PostgreSQLDialect/CleanAlfPropTablesPostExec.sql diff --git a/src/main/resources/alfresco/deprecated-context.xml b/src/main/resources/alfresco/deprecated-context.xml index 200cd8df9f..85b07c7c79 100644 --- a/src/main/resources/alfresco/deprecated-context.xml +++ b/src/main/resources/alfresco/deprecated-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/deprecated-model-bootstrap-context.xml b/src/main/resources/alfresco/deprecated-model-bootstrap-context.xml index e89fff0476..85c040e91d 100644 --- a/src/main/resources/alfresco/deprecated-model-bootstrap-context.xml +++ b/src/main/resources/alfresco/deprecated-model-bootstrap-context.xml @@ -1,9 +1,11 @@ - - + diff --git a/src/main/resources/alfresco/discussions-services-context.xml b/src/main/resources/alfresco/discussions-services-context.xml index ce6c370faf..c258b15eb9 100644 --- a/src/main/resources/alfresco/discussions-services-context.xml +++ b/src/main/resources/alfresco/discussions-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/distributionpolicies-context.xml b/src/main/resources/alfresco/distributionpolicies-context.xml index c55ed2cd1d..ce1a67d673 100644 --- a/src/main/resources/alfresco/distributionpolicies-context.xml +++ b/src/main/resources/alfresco/distributionpolicies-context.xml @@ -1,18 +1,20 @@ - - + - - - - - alfresco/model/distributionPoliciesModel.xml - - - - - alfresco/messages/distributionpolicies-model - - - + + + + + alfresco/model/distributionPoliciesModel.xml + + + + + alfresco/messages/distributionpolicies-model + + + diff --git a/src/main/resources/alfresco/domain/hibernate-cfg.properties b/src/main/resources/alfresco/domain/hibernate-cfg.properties deleted file mode 100644 index 205e518c22..0000000000 --- a/src/main/resources/alfresco/domain/hibernate-cfg.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# Hibernate configuration -# - -# The Hibernate Dialect: -# As of V3.1, the dialect is automatically detected. -# It is still possible to set the dialect explicitly, for example: -# hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect - -hibernate.jdbc.use_streams_for_binary=true -hibernate.show_sql=false -hibernate.cache.use_query_cache=false -hibernate.max_fetch_depth=10 -hibernate.cache.provider_class=org.alfresco.repo.cache.DefaultCacheProvider -hibernate.cache.use_second_level_cache=true -hibernate.default_batch_fetch_size=1 -hibernate.jdbc.batch_size=32 -hibernate.connection.release_mode=auto -hibernate.connection.isolation=2 - -#hibernate.query.substitutions= -#hibernate.jdbc.use_get_generated_keys=false - -# Oracle Schema Distinction: -# See https://issues.alfresco.com/jira/browse/ETHREEOH-680 -# Metadata queries to Oracle have to be limited by schema name -# when multiple instances of Alfresco are installed on an Oracle server. -#hibernate.default_schema= diff --git a/src/main/resources/alfresco/download-services-context.xml b/src/main/resources/alfresco/download-services-context.xml index 7e94fef9b3..d427c9be49 100644 --- a/src/main/resources/alfresco/download-services-context.xml +++ b/src/main/resources/alfresco/download-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -114,33 +115,28 @@ - - - - org.alfresco.repo.download.DownloadsCleanupJob - - - - - - - - - - - - - - - - - - - - ${download.cleaner.startDelayMins} - - - ${download.cleaner.repeatIntervalMins} + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/alfresco/favourites-service-context.xml b/src/main/resources/alfresco/favourites-service-context.xml index b5436cfa7c..e9f4f5ccf4 100644 --- a/src/main/resources/alfresco/favourites-service-context.xml +++ b/src/main/resources/alfresco/favourites-service-context.xml @@ -1,7 +1,9 @@ - + - @@ -12,10 +14,10 @@ - + - + diff --git a/src/main/resources/alfresco/form-services-context.xml b/src/main/resources/alfresco/form-services-context.xml index fe9f85e74e..45080f4667 100644 --- a/src/main/resources/alfresco/form-services-context.xml +++ b/src/main/resources/alfresco/form-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -21,10 +22,10 @@ - + - + diff --git a/src/main/resources/alfresco/hibernate-context.xml b/src/main/resources/alfresco/hibernate-context.xml deleted file mode 100644 index 532b9e57d6..0000000000 --- a/src/main/resources/alfresco/hibernate-context.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - classpath:alfresco/domain/hibernate-cfg.properties - classpath*:alfresco/enterprise/cache/hibernate-cfg.properties - - - - - - - - true - - - - - - - - classpath:alfresco/domain/cache-strategies.properties - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - SYNCHRONIZATION_ALWAYS - - - - - - - - - \ No newline at end of file diff --git a/src/main/resources/alfresco/ibatis/ibatis-context.xml b/src/main/resources/alfresco/ibatis/ibatis-context.xml index f750471e18..d58d58088e 100644 --- a/src/main/resources/alfresco/ibatis/ibatis-context.xml +++ b/src/main/resources/alfresco/ibatis/ibatis-context.xml @@ -1,15 +1,16 @@ - - - + - org.hibernate.dialect.Dialect + org.alfresco.repo.domain.dialect.Dialect diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/activities-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/activities-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/activities-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/activities-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/activities-select-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/activities-select-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/activities-select-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/activities-select-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/alfresco-util-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/alfresco-util-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/alfresco-util-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/alfresco-util-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/appliedpatch-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/appliedpatch-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/appliedpatch-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/appliedpatch-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/audit-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/audit-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-select-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/audit-select-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/audit-select-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/audit-select-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/content-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/content-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/content-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/content-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/content-select-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/content-select-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/content-select-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/content-select-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/locale-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/locale-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/locale-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/locale-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/locks-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/locks-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/locks-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/locks-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/metadata-query-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/metadata-query-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/metadata-query-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/metadata-query-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/metadata-query-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-delete-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-delete-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-delete-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-delete-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-select-children-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-select-children-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-select-children-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-select-children-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-update-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-update-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/node-update-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/node-update-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/patch-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/patch-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/patch-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/patch-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/permissions-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/permissions-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/permissions-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/permissions-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/propval-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/propval-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/propval-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/propval-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/qname-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/qname-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/qname-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/qname-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-archived-nodes-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-archived-nodes-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-archived-nodes-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-archived-nodes-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-auditable-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-auditable-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-auditable-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-auditable-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-authorities-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-authorities-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-authorities-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-authorities-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-blogs-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-blogs-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-blogs-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-blogs-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-calendar-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-calendar-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-calendar-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-calendar-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-copy-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-copy-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-copy-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-copy-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-discussion-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-discussion-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-discussion-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-discussion-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-doclink-nodes-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-doclink-nodes-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-doclink-nodes-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-doclink-nodes-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-downloads-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-downloads-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-downloads-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-downloads-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-people-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-people-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-people-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-people-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-usages-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-usages-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-usages-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-usages-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/solr-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/solr-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/solr-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/solr-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/subscriptions-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/subscriptions-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/subscriptions-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/subscriptions-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/tenants-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/tenants-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/tenants-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/tenants-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/usage-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/usage-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/usage-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/usage-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/activities-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activities-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/activities-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activities-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/activities-select-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activities-select-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/activities-select-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/activities-select-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/audit-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-select-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/audit-select-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/audit-select-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/audit-select-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/content-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-select-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/content-select-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/content-select-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/content-select-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/locale-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/locks-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/metadata-query-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/metadata-query-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/metadata-query-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/metadata-query-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-delete-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-delete-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-delete-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-delete-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-select-children-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-update-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-update-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/node-update-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/node-update-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/permissions-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/propval-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/qname-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/query-authorities-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-people-common-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/query-people-common-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/query-people-common-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/query-people-common-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/usage-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/activities-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/alfresco-util-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/alfresco-util-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/alfresco-util-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/alfresco-util-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/audit-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-select-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/audit-select-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/audit-select-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/audit-select-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/content-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/content-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/content-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/content-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/locale-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/locks-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/node-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/node-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/node-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/node-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/permissions-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/propval-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/qname-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml b/src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml similarity index 100% rename from src/main/resources/alfresco/ibatis/org.hibernate.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml rename to src/main/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.PostgreSQLDialect/usage-insert-SqlMap.xml diff --git a/src/main/resources/alfresco/import-export-context.xml b/src/main/resources/alfresco/import-export-context.xml index 74a300a141..d986471533 100644 --- a/src/main/resources/alfresco/import-export-context.xml +++ b/src/main/resources/alfresco/import-export-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/invitation-service-context.xml b/src/main/resources/alfresco/invitation-service-context.xml index 50d17da73b..5609f946b7 100644 --- a/src/main/resources/alfresco/invitation-service-context.xml +++ b/src/main/resources/alfresco/invitation-service-context.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd"> + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> @@ -61,10 +61,10 @@ - + - + diff --git a/src/main/resources/alfresco/links-services-context.xml b/src/main/resources/alfresco/links-services-context.xml index 78fbae2dfd..96869c2242 100644 --- a/src/main/resources/alfresco/links-services-context.xml +++ b/src/main/resources/alfresco/links-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/logging-context.xml b/src/main/resources/alfresco/logging-context.xml index a16477a05f..b84bf535a8 100644 --- a/src/main/resources/alfresco/logging-context.xml +++ b/src/main/resources/alfresco/logging-context.xml @@ -1,8 +1,9 @@ - - - + diff --git a/src/main/resources/alfresco/messages/schema-update.properties b/src/main/resources/alfresco/messages/schema-update.properties index 89824c3aae..9ce80226bf 100644 --- a/src/main/resources/alfresco/messages/schema-update.properties +++ b/src/main/resources/alfresco/messages/schema-update.properties @@ -12,12 +12,8 @@ schema.update.msg.executing_generated_script=Executing database script {0} (Gene schema.update.msg.executing_copied_script=Executing database script {0} (Copied from {1}). schema.update.msg.executing_statement= Executing statement: {0} schema.update.msg.optional_statement_failed=Optional statement execution failed:\n SQL: {0}\n Error: {1}\n File: {2}\n Line: {3} -schema.update.warn.dialect_unsupported=Alfresco should not be used with database dialect {0}. -schema.update.warn.dialect_hsql=Alfresco is using the HSQL default database. Please only use this while evaluating Alfresco, it is NOT recommended for production or deployment! -schema.update.warn.dialect_derby=Alfresco is using the Apache Derby default database. Please only use this while evaluating Alfresco, it is NOT recommended for production or deployment! schema.update.warn.dialect_substituting=The dialect ''{0}'' is being changed to ''{1}''. schema.update.err.forced_stop=The property 'stopAfterSchemaBootstrap' has been set. The bootstrap process is being terminated. -schema.update.err.dialect_should_use=The dialect ''{0}'' is unsupported. Please use ''{1}'' instead. schema.update.err.found_multiple=\nMore than one Alfresco schema was found when querying the database metadata.\n Limit the database user's permissions or set the 'hibernate.default_schema' property in 'custom-hibernate-dialect.properties'. schema.update.err.previous_failed=A previous schema upgrade failed or was not completed. Revert to the original database before attempting the upgrade again. schema.update.err.statement_failed=Statement execution failed:\n SQL: {0}\n Error: {1}\n File: {2}\n Line: {3} diff --git a/src/main/resources/alfresco/minimal-context.xml b/src/main/resources/alfresco/minimal-context.xml index 0736acd42c..2345194422 100644 --- a/src/main/resources/alfresco/minimal-context.xml +++ b/src/main/resources/alfresco/minimal-context.xml @@ -1,10 +1,11 @@ - - - + diff --git a/src/main/resources/alfresco/module-context.xml b/src/main/resources/alfresco/module-context.xml index 2628a0a34e..87999b274e 100644 --- a/src/main/resources/alfresco/module-context.xml +++ b/src/main/resources/alfresco/module-context.xml @@ -1,10 +1,11 @@ - - - + diff --git a/src/main/resources/alfresco/mt/mt-admin-context.xml b/src/main/resources/alfresco/mt/mt-admin-context.xml index b066fb04f2..85e732a454 100644 --- a/src/main/resources/alfresco/mt/mt-admin-context.xml +++ b/src/main/resources/alfresco/mt/mt-admin-context.xml @@ -1,18 +1,19 @@ - - - + - - - - - - + + + + + + diff --git a/src/main/resources/alfresco/mt/mt-base-context.xml b/src/main/resources/alfresco/mt/mt-base-context.xml index 0c9103c128..c07a6f0ab3 100644 --- a/src/main/resources/alfresco/mt/mt-base-context.xml +++ b/src/main/resources/alfresco/mt/mt-base-context.xml @@ -1,18 +1,19 @@ - - - + - - - - - - + + + + + + diff --git a/src/main/resources/alfresco/network-authentication-context.xml b/src/main/resources/alfresco/network-authentication-context.xml index 75560a5206..f04fcb1db2 100644 --- a/src/main/resources/alfresco/network-authentication-context.xml +++ b/src/main/resources/alfresco/network-authentication-context.xml @@ -1,7 +1,9 @@ - - - + + diff --git a/src/main/resources/alfresco/node-locator-context.xml b/src/main/resources/alfresco/node-locator-context.xml index 31258d6042..bfcf65c6f4 100644 --- a/src/main/resources/alfresco/node-locator-context.xml +++ b/src/main/resources/alfresco/node-locator-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/node-services-context.xml b/src/main/resources/alfresco/node-services-context.xml index 498db53a55..b5687c2401 100644 --- a/src/main/resources/alfresco/node-services-context.xml +++ b/src/main/resources/alfresco/node-services-context.xml @@ -1,8 +1,9 @@ - - - + diff --git a/src/main/resources/alfresco/notification-services-context.xml b/src/main/resources/alfresco/notification-services-context.xml index e7af54d45f..35e8db1ad5 100644 --- a/src/main/resources/alfresco/notification-services-context.xml +++ b/src/main/resources/alfresco/notification-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -13,7 +14,7 @@ - + diff --git a/src/main/resources/alfresco/opencmis-context.xml b/src/main/resources/alfresco/opencmis-context.xml index e2cf05c7c2..a517072adb 100644 --- a/src/main/resources/alfresco/opencmis-context.xml +++ b/src/main/resources/alfresco/opencmis-context.xml @@ -1,7 +1,9 @@ - + - diff --git a/src/main/resources/alfresco/opencmis-qnamefilter-context.xml b/src/main/resources/alfresco/opencmis-qnamefilter-context.xml index d3f519b81f..246818cbaa 100644 --- a/src/main/resources/alfresco/opencmis-qnamefilter-context.xml +++ b/src/main/resources/alfresco/opencmis-qnamefilter-context.xml @@ -1,7 +1,9 @@ - + - diff --git a/src/main/resources/alfresco/ownable-services-context.xml b/src/main/resources/alfresco/ownable-services-context.xml index ba81a91c10..1228c5c516 100644 --- a/src/main/resources/alfresco/ownable-services-context.xml +++ b/src/main/resources/alfresco/ownable-services-context.xml @@ -1,7 +1,9 @@ - + - diff --git a/src/main/resources/alfresco/patch/patch-services-context.xml b/src/main/resources/alfresco/patch/patch-services-context.xml index ade6f49c71..c9a4675f0d 100644 --- a/src/main/resources/alfresco/patch/patch-services-context.xml +++ b/src/main/resources/alfresco/patch/patch-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -10,7 +11,7 @@ - + diff --git a/src/main/resources/alfresco/period-type-context.xml b/src/main/resources/alfresco/period-type-context.xml index 5d51e9ad11..da6e1aacda 100644 --- a/src/main/resources/alfresco/period-type-context.xml +++ b/src/main/resources/alfresco/period-type-context.xml @@ -1,12 +1,13 @@ - - - + diff --git a/src/main/resources/alfresco/policy-context.xml b/src/main/resources/alfresco/policy-context.xml index dd1e674975..137c26f12a 100644 --- a/src/main/resources/alfresco/policy-context.xml +++ b/src/main/resources/alfresco/policy-context.xml @@ -1,7 +1,9 @@ - + - diff --git a/src/main/resources/alfresco/preference-service-context.xml b/src/main/resources/alfresco/preference-service-context.xml index 1536c026c1..ffb8523394 100644 --- a/src/main/resources/alfresco/preference-service-context.xml +++ b/src/main/resources/alfresco/preference-service-context.xml @@ -1,7 +1,8 @@ - - - + @@ -13,10 +14,10 @@ - + - + diff --git a/src/main/resources/alfresco/public-services-context.xml b/src/main/resources/alfresco/public-services-context.xml index bc70ac2aa8..4ae14cfdaf 100644 --- a/src/main/resources/alfresco/public-services-context.xml +++ b/src/main/resources/alfresco/public-services-context.xml @@ -1,7 +1,9 @@ - + - @@ -23,7 +25,7 @@ - + @@ -71,9 +73,9 @@ - - - + + + @@ -133,9 +135,9 @@ - - - + + + @@ -175,9 +177,9 @@ - - - + + + @@ -192,9 +194,9 @@ - - - + + + @@ -222,9 +224,9 @@ - - - + + + @@ -252,9 +254,9 @@ - - - + + + @@ -282,9 +284,9 @@ - - - + + + @@ -329,9 +331,9 @@ - - - + + + @@ -360,9 +362,9 @@ - - - + + + @@ -390,9 +392,9 @@ - - - + + + @@ -420,9 +422,9 @@ - - - + + + @@ -450,8 +452,8 @@ - - + + @@ -478,9 +480,9 @@ - - - + + + @@ -508,9 +510,9 @@ - - - + + + @@ -538,9 +540,9 @@ - - - + + + @@ -568,9 +570,9 @@ - - - + + + @@ -598,9 +600,9 @@ - - - + + + @@ -628,9 +630,9 @@ - - - + + + @@ -659,9 +661,9 @@ - - - + + + @@ -697,9 +699,9 @@ - - - + + + @@ -727,9 +729,9 @@ - - - + + + @@ -756,10 +758,10 @@ - + - - + + @@ -854,9 +856,9 @@ - - - + + + @@ -884,9 +886,9 @@ - - - + + + @@ -915,8 +917,8 @@ - - + + @@ -947,7 +949,7 @@ - + @@ -975,7 +977,7 @@ - + @@ -1004,7 +1006,7 @@ - + @@ -1032,7 +1034,7 @@ - + @@ -1060,15 +1062,16 @@ - - - + + + - + + @@ -1089,10 +1092,10 @@ - + - + @@ -1121,9 +1124,9 @@ - - - + + + @@ -1152,8 +1155,8 @@ - - + + @@ -1178,8 +1181,8 @@ - - + + diff --git a/src/main/resources/alfresco/public-services-security-context.xml b/src/main/resources/alfresco/public-services-security-context.xml index 733ce49e9d..2165c7ca78 100644 --- a/src/main/resources/alfresco/public-services-security-context.xml +++ b/src/main/resources/alfresco/public-services-security-context.xml @@ -1,5 +1,4 @@ - @@ -10,7 +9,10 @@ - + @@ -160,8 +162,7 @@ - + ROLE_ @@ -171,8 +172,7 @@ - + GROUP_ @@ -188,8 +188,7 @@ - + @@ -222,9 +221,9 @@ false - - - + + + @@ -233,8 +232,7 @@ - + @@ -271,7 +269,7 @@ - + @@ -377,8 +375,8 @@ - - + + org.alfresco.service.cmr.repository.NodeService.getStores=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties @@ -438,8 +436,8 @@ - - + + org.alfresco.service.cmr.model.FileFolderService.list=ACL_NODE.0.sys:base.ReadChildren,AFTER_ACL_NODE.sys:base.ReadProperties @@ -486,8 +484,8 @@ - - + + org.alfresco.service.cmr.repository.ContentService.getStoreTotalSpace=ACL_ALLOW @@ -523,8 +521,8 @@ - - + + org.alfresco.service.cmr.search.SearchService.query=ACL_ALLOW,AFTER_ACL_NODE.sys:base.Read @@ -539,8 +537,8 @@ - - + + org.alfresco.service.cmr.search.StatsService.query=ACL_ALLOW,AFTER_ACL_NODE.sys:base.Read @@ -559,8 +557,8 @@ - - + + org.alfresco.service.cmr.search.CategoryService.getChildren=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties @@ -589,8 +587,8 @@ - - + + org.alfresco.service.cmr.repository.CopyService.copy=ACL_ALLOW @@ -617,8 +615,8 @@ - - + + org.alfresco.service.cmr.lock.LockService.lock=ACL_NODE.0.cm:lockable.Lock @@ -653,8 +651,8 @@ - - + + org.alfresco.service.cmr.ml.MultilingualContentService.getTranslationContainer=ACL_ALLOW @@ -681,8 +679,8 @@ - - + + org.alfresco.service.cmr.ml.EditionService.createEdition=ACL_NODE.0.sys:base.Read @@ -705,8 +703,8 @@ - - + + org.alfresco.service.cmr.coci.CheckOutCheckInService.checkout=ACL_NODE.0.cm:lockable.CheckOut @@ -757,8 +755,8 @@ - - + + org.alfresco.service.cmr.security.PermissionService.getOwnerAuthority=ACL_ALLOW @@ -790,8 +788,8 @@ - - + + org.alfresco.service.cmr.security.AuthorityService.hasAdminAuthority=ACL_ALLOW @@ -847,8 +845,8 @@ - - + + org.alfresco.service.cmr.security.MutableAuthenticationService.isAuthenticationMutable=ACL_ALLOW @@ -884,8 +882,8 @@ - - + + org.alfresco.service.cmr.security.OwnableService.getOwner=ACL_NODE.0.sys:base.ReadProperties @@ -902,8 +900,8 @@ - - + + org.alfresco.service.cmr.security.PersonService.getPerson=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties @@ -971,8 +969,8 @@ - - + + org.alfresco.service.cmr.audit.AuditService.*=ACL_METHOD.ROLE_ADMINISTRATOR @@ -1006,8 +1004,8 @@ - - + + org.alfresco.service.cmr.site.SiteService.cleanSitePermissions=ACL_NODE.0.sys:base.ReadProperties @@ -1065,8 +1063,8 @@ - - + + org.alfresco.service.cmr.calendar.CalendarService.listCalendarEntries=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties @@ -1092,8 +1090,8 @@ - - + + org.alfresco.service.cmr.download.DownloadService.deleteDownloads=ACL_ALLOW @@ -1118,8 +1116,8 @@ - - + + org.alfresco.service.cmr.links.LinksService.listLinks=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties @@ -1144,8 +1142,8 @@ - - + + org.alfresco.service.cmr.discussion.DiscussionService.listPosts=ACL_ALLOW,AFTER_ACL_NODE.sys:base.ReadProperties @@ -1177,8 +1175,8 @@ - - + + org.alfresco.service.cmr.admin.RepoAdminService.getRestrictions=ACL_ALLOW @@ -1200,10 +1198,10 @@ - + - + org.alfresco.service.cmr.security.PublicServiceAccessService.hasAccess=ACL_ALLOW @@ -1236,10 +1234,10 @@ - + - + diff --git a/src/main/resources/alfresco/quickshare-services-context.xml b/src/main/resources/alfresco/quickshare-services-context.xml index 0c568b5ffb..f0493575d2 100644 --- a/src/main/resources/alfresco/quickshare-services-context.xml +++ b/src/main/resources/alfresco/quickshare-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/rating-services-context.xml b/src/main/resources/alfresco/rating-services-context.xml index c03cb25c0a..b28c1c8650 100644 --- a/src/main/resources/alfresco/rating-services-context.xml +++ b/src/main/resources/alfresco/rating-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -13,10 +14,10 @@ - + - + @@ -41,7 +42,7 @@ - + diff --git a/src/main/resources/alfresco/remote-credentials-services-context.xml b/src/main/resources/alfresco/remote-credentials-services-context.xml index 4efbdd42b1..6e2891fbd9 100644 --- a/src/main/resources/alfresco/remote-credentials-services-context.xml +++ b/src/main/resources/alfresco/remote-credentials-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/remote-ticket-services-context.xml b/src/main/resources/alfresco/remote-ticket-services-context.xml index 2277cc5757..33af09bc73 100644 --- a/src/main/resources/alfresco/remote-ticket-services-context.xml +++ b/src/main/resources/alfresco/remote-ticket-services-context.xml @@ -5,8 +5,8 @@ xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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-3.0.xsd - http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd + http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> diff --git a/src/main/resources/alfresco/rendition-services-context.xml b/src/main/resources/alfresco/rendition-services-context.xml index ba0c7d2e3f..e0bc87f687 100644 --- a/src/main/resources/alfresco/rendition-services-context.xml +++ b/src/main/resources/alfresco/rendition-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -14,10 +15,10 @@ - + - + diff --git a/src/main/resources/alfresco/replication-services-context.xml b/src/main/resources/alfresco/replication-services-context.xml index 43bccb93fd..6342e5ff53 100644 --- a/src/main/resources/alfresco/replication-services-context.xml +++ b/src/main/resources/alfresco/replication-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -32,10 +33,10 @@ - + - + diff --git a/src/main/resources/alfresco/repo-admin-context.xml b/src/main/resources/alfresco/repo-admin-context.xml index 2fe39090f5..dc78e5dfa8 100644 --- a/src/main/resources/alfresco/repo-admin-context.xml +++ b/src/main/resources/alfresco/repo-admin-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/repo-clients-apps-context.xml b/src/main/resources/alfresco/repo-clients-apps-context.xml index 79383c4e40..596834a42a 100644 --- a/src/main/resources/alfresco/repo-clients-apps-context.xml +++ b/src/main/resources/alfresco/repo-clients-apps-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/repository.properties b/src/main/resources/alfresco/repository.properties index fecaa7d188..0fccd0ec44 100644 --- a/src/main/resources/alfresco/repository.properties +++ b/src/main/resources/alfresco/repository.properties @@ -964,8 +964,8 @@ ticket.cleanup.cronExpression=0 0 * * * ? # # Download Service Cleanup # -download.cleaner.startDelayMins=60 -download.cleaner.repeatIntervalMins=60 +download.cleaner.startDelayMilliseconds=3600000 +download.cleaner.repeatIntervalSeconds=3600 download.cleaner.maxAgeMins=60 # @@ -1062,7 +1062,7 @@ system.remove-jbpm-tables-from-db.ignored=true people.search.honor.hint.useCQ=true # Delays cron jobs after bootstrap to allow server to fully come up before jobs start -system.cronJob.startDelayMinutes=1 +system.cronJob.startDelayMilliseconds=60000 # # Check that the declared mimetype (of the Node) is the same as the derived diff --git a/src/main/resources/alfresco/reset-password-context.xml b/src/main/resources/alfresco/reset-password-context.xml index 3c3375de72..f979d6e811 100644 --- a/src/main/resources/alfresco/reset-password-context.xml +++ b/src/main/resources/alfresco/reset-password-context.xml @@ -1,8 +1,10 @@ - + - diff --git a/src/main/resources/alfresco/rule-services-context.xml b/src/main/resources/alfresco/rule-services-context.xml index 530218037c..9bd4ace992 100644 --- a/src/main/resources/alfresco/rule-services-context.xml +++ b/src/main/resources/alfresco/rule-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/scheduled-jobs-context.xml b/src/main/resources/alfresco/scheduled-jobs-context.xml index de72dbbbb3..057dfd05de 100644 --- a/src/main/resources/alfresco/scheduled-jobs-context.xml +++ b/src/main/resources/alfresco/scheduled-jobs-context.xml @@ -1,355 +1,226 @@ - + - - - - - - - - - org.alfresco.util.TempFileProvider$TempFileCleanerJob - - - - - 1 - - - - - - - - - - - 0 30 * * * ? - - - ${system.cronJob.startDelayMinutes} - - - - - - - - org.alfresco.util.TempFileProvider$TempFileCleanerJob - - - - - 1 - - - ${webscripts.tempDirectoryName} - - - - - - - - - - - 0 0 * * * ? - - - ${system.cronJob.startDelayMinutes} - - - - - - org.alfresco.repo.content.cleanup.ContentStoreCleanupJob - - - - - - - - - - - - - - - - - - ${system.content.orphanCleanup.cronExpression} - - - ${system.cronJob.startDelayMinutes} - - - - - - org.alfresco.repo.admin.patch.impl.SharedFolderPatch$SharedFolderPatchJob - - - - - - - - - - - - - - - - - - ${system.patch.sharedFolder.cronExpression} - - - ${system.cronJob.startDelayMinutes} - - - - - - - - - - - - - - - - - - - - - org.alfresco.repo.node.cleanup.NodeCleanupJob - - - - - - - - - - - - - - - - - - 0 0 21 * * ? - - - ${system.cronJob.startDelayMinutes} - - - - - - - - - org.alfresco.repo.usage.UserUsageCollapseJob - - - - - - - - - - - - - - ${system.cronJob.startDelayMinutes} - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - org.alfresco.repo.tagging.UpdateTagScopesQuartzJob - - - - - - - - - - - - - - - - + + + - - - - - - - 2 - - - 60 + + + + + + + + + + - - - - - org.alfresco.repo.security.authentication.TicketCleanupJob - - - - - - - - - - - + + + - - - - - - - ${ticket.cleanup.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + - - - - - org.alfresco.repo.admin.patch.AsynchronousPatch$AsynchronousPatchJob - - - - - - - - - - + + + - - - - - - - ${system.patch.surfConfigFolder.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - org.alfresco.repo.admin.patch.AsynchronousPatch$AsynchronousPatchJob - - - - - - - - - - + + + - - - - - - - ${system.patch.addUnmovableAspect.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + - - - - - org.alfresco.repo.domain.permissions.FixedAclUpdaterJob - - - - - - - + + + + + + + + + + + + - - - - - - - ${system.cronJob.startDelayMinutes} - - - + diff --git a/src/main/resources/alfresco/scheduler-core-context.xml b/src/main/resources/alfresco/scheduler-core-context.xml index be591d6038..b20f2305de 100644 --- a/src/main/resources/alfresco/scheduler-core-context.xml +++ b/src/main/resources/alfresco/scheduler-core-context.xml @@ -1,7 +1,9 @@ - + - @@ -20,9 +22,10 @@ - - - + + + + true diff --git a/src/main/resources/alfresco/script-services-context.xml b/src/main/resources/alfresco/script-services-context.xml index b736cb43ad..2a2b930696 100644 --- a/src/main/resources/alfresco/script-services-context.xml +++ b/src/main/resources/alfresco/script-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/site-services-context.xml b/src/main/resources/alfresco/site-services-context.xml index a46d03834a..70ed62eb4a 100644 --- a/src/main/resources/alfresco/site-services-context.xml +++ b/src/main/resources/alfresco/site-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/slingshot-context.xml b/src/main/resources/alfresco/slingshot-context.xml index 506460ddea..b1fb398a93 100644 --- a/src/main/resources/alfresco/slingshot-context.xml +++ b/src/main/resources/alfresco/slingshot-context.xml @@ -2,7 +2,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> diff --git a/src/main/resources/alfresco/smartfolder-context.xml b/src/main/resources/alfresco/smartfolder-context.xml index ae13ba6386..122216982d 100644 --- a/src/main/resources/alfresco/smartfolder-context.xml +++ b/src/main/resources/alfresco/smartfolder-context.xml @@ -1,6 +1,9 @@ - - + + diff --git a/src/main/resources/alfresco/social-publishing-context.xml b/src/main/resources/alfresco/social-publishing-context.xml index 25c756fcea..047ef6ece5 100644 --- a/src/main/resources/alfresco/social-publishing-context.xml +++ b/src/main/resources/alfresco/social-publishing-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/solr-facets-context.xml b/src/main/resources/alfresco/solr-facets-context.xml index a1304381d5..20a3e227fe 100644 --- a/src/main/resources/alfresco/solr-facets-context.xml +++ b/src/main/resources/alfresco/solr-facets-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/spring/encrypted-properties-context.xml b/src/main/resources/alfresco/spring/encrypted-properties-context.xml index 96826b9c41..9c20afed8e 100644 --- a/src/main/resources/alfresco/spring/encrypted-properties-context.xml +++ b/src/main/resources/alfresco/spring/encrypted-properties-context.xml @@ -5,11 +5,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"> - + - - empty - - + empty + \ No newline at end of file diff --git a/src/main/resources/alfresco/st-context.xml b/src/main/resources/alfresco/st-context.xml index af6d58b828..af0f0082e2 100644 --- a/src/main/resources/alfresco/st-context.xml +++ b/src/main/resources/alfresco/st-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs-context.xml b/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs-context.xml index 36fc9e0c79..13ef572193 100644 --- a/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs-context.xml +++ b/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs-context.xml @@ -1,133 +1,132 @@ - - - + - - - org.alfresco.repo.activities.feed.cleanup.FeedCleanupJob - - - - - - - + + + + + + + + + + + - - - - - - - ${activities.feed.cleaner.startDelayMins} + + + + + + - - - org.alfresco.repo.activities.feed.FeedGeneratorJob - - - - - - - + + + + + + + + + + + - - - - - - - ${activities.feed.generator.startDelayMins} + + + + + + - - - org.alfresco.repo.activities.post.lookup.PostLookupJob + + + + + + + + + + + + + + + - - - + - - - - - - - ${activities.post.lookup.startDelayMins} - - - - - org.alfresco.repo.activities.post.cleanup.PostCleanupJob - - - - - - - + + + + + + + + + + + - - - - - - - ${activities.post.cleaner.startDelayMins} + + + + + + - - - org.alfresco.repo.activities.feed.FeedNotifierJob + + + + + + + + + + + + + + + - - - - - - + + - - - - - - - - ${activities.feed.notifier.startDelayMins} - - - diff --git a/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties b/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties index 6081aabf53..6830a3b110 100644 --- a/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties +++ b/src/main/resources/alfresco/subsystems/ActivitiesFeed/default/activities-jobs.properties @@ -8,7 +8,7 @@ activities.feed.max.ageMins=44640 # please note: # - refer to "email/OutboundSMTP" subsystem for SMTP properties (mail.*) # - refer to "sysAdmin" subsystem for Share url/ctx properties (share.*) -activities.feed.notifier.startDelayMins=${system.cronJob.startDelayMinutes} +activities.feed.notifier.startDelayMilliseconds=${system.cronJob.startDelayMilliseconds} # Feed notification period (every 24 hours at 00:00) activities.feed.notifier.cronExpression=0 0 0 * * ? activities.feed.notifier.enabled=true @@ -17,7 +17,7 @@ activities.feed.notifier.emailTemplatePath=/app:company_home/app:dictionary/app: activities.feed.notifier.emailTemplateLocationType=xpath # activities feed generator -activities.feed.generator.startDelayMins=${system.cronJob.startDelayMinutes} +activities.feed.generator.startDelayMilliseconds=${system.cronJob.startDelayMilliseconds} activities.feed.generator.cronExpression=0/30 * * * * ? activities.feed.generator.maxItemsPerCycle=100 activities.feed.generator.enabled=true @@ -25,18 +25,18 @@ activities.feed.generator.batchSize=1000 activities.feed.generator.numThreads=4 # activities feed cleaner -activities.feed.cleaner.startDelayMins=${system.cronJob.startDelayMinutes} +activities.feed.cleaner.startDelayMilliseconds=${system.cronJob.startDelayMilliseconds} # repeat every 10 mins activities.feed.cleaner.cronExpression=0 0/10 * * * ? activities.feed.cleaner.enabled=true # activities post cleaner -activities.post.cleaner.startDelayMins=${system.cronJob.startDelayMinutes} +activities.post.cleaner.startDelayMilliseconds=${system.cronJob.startDelayMilliseconds} activities.post.cleaner.cronExpression=0 0/10 * * * ? activities.post.cleaner.enabled=true # activities post lookup -activities.post.lookup.startDelayMins=${system.cronJob.startDelayMinutes} +activities.post.lookup.startDelayMilliseconds=${system.cronJob.startDelayMilliseconds} activities.post.lookup.cronExpression=0/15 * * * * ? activities.post.lookup.maxItemsPerCycle=500 activities.post.lookup.enabled=true \ No newline at end of file diff --git a/src/main/resources/alfresco/subsystems/Search/common-search-context.xml b/src/main/resources/alfresco/subsystems/Search/common-search-context.xml index b433b88c7c..c6f317b5bb 100644 --- a/src/main/resources/alfresco/subsystems/Search/common-search-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/common-search-context.xml @@ -1,8 +1,9 @@ - - - + @@ -30,7 +31,7 @@ - + ${search.solrTrackingSupport.ignorePathsForSpecificTypes} @@ -43,7 +44,7 @@ - + ${search.solrTrackingSupport.ignorePathsForSpecificAspects} diff --git a/src/main/resources/alfresco/subsystems/Search/solr/common-search-scheduler-context.xml b/src/main/resources/alfresco/subsystems/Search/solr/common-search-scheduler-context.xml index bba245dfd8..0443537a1e 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr/common-search-scheduler-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr/common-search-scheduler-context.xml @@ -20,9 +20,10 @@ - - - + + + + true diff --git a/src/main/resources/alfresco/subsystems/Search/solr/solr-backup-context.xml b/src/main/resources/alfresco/subsystems/Search/solr/solr-backup-context.xml index 2c4259b85a..36d034b1ab 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr/solr-backup-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr/solr-backup-context.xml @@ -1,38 +1,36 @@ - + + + + + + + + + + + - - - - - org.alfresco.repo.search.impl.solr.SolrBackupJob - - - - - - - - - - - + + + + - - - - - - - - ${solr.backup.alfresco.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + - + @@ -55,33 +53,19 @@ - - - - org.alfresco.repo.search.impl.solr.SolrBackupJob - - - - - - - - - - - + + + + - - - - - - - - ${solr.backup.archive.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + diff --git a/src/main/resources/alfresco/subsystems/Search/solr4/common-search-scheduler-context.xml b/src/main/resources/alfresco/subsystems/Search/solr4/common-search-scheduler-context.xml index 3de15938a3..8b5e3d86e7 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr4/common-search-scheduler-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr4/common-search-scheduler-context.xml @@ -20,9 +20,10 @@ - - - + + + + true diff --git a/src/main/resources/alfresco/subsystems/Search/solr4/solr-backup-context.xml b/src/main/resources/alfresco/subsystems/Search/solr4/solr-backup-context.xml index 652cfe0077..0ff8fa1b0d 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr4/solr-backup-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr4/solr-backup-context.xml @@ -1,35 +1,33 @@ - + - - - - - - org.alfresco.repo.search.impl.solr.SolrBackupJob - - - - - - - + + + + + + + - - + + + + + + - - - - - - - - ${solr.backup.alfresco.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + @@ -58,36 +56,22 @@ - - - - org.alfresco.repo.search.impl.solr.SolrBackupJob - - - - - - - - - - - + + + + - - - - - - - - ${solr.backup.archive.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + - + diff --git a/src/main/resources/alfresco/subsystems/Search/solr4/solr-search-context.xml b/src/main/resources/alfresco/subsystems/Search/solr4/solr-search-context.xml index 64cea67b03..5f4a10e34b 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr4/solr-search-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr4/solr-search-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/subsystems/Search/solr6/common-search-scheduler-context.xml b/src/main/resources/alfresco/subsystems/Search/solr6/common-search-scheduler-context.xml index 3de15938a3..8b5e3d86e7 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr6/common-search-scheduler-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr6/common-search-scheduler-context.xml @@ -20,9 +20,10 @@ - - - + + + + true diff --git a/src/main/resources/alfresco/subsystems/Search/solr6/solr-backup-context.xml b/src/main/resources/alfresco/subsystems/Search/solr6/solr-backup-context.xml index 652cfe0077..e904a393b7 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr6/solr-backup-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr6/solr-backup-context.xml @@ -1,35 +1,33 @@ - + - - - - - - org.alfresco.repo.search.impl.solr.SolrBackupJob - - - - - - - + + + + + + + - - + + + + + + - - - - - - - - ${solr.backup.alfresco.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + @@ -58,33 +56,19 @@ - - - - org.alfresco.repo.search.impl.solr.SolrBackupJob - - - - - - - - - - - + + + + - - - - - - - - ${solr.backup.archive.cronExpression} - - - ${system.cronJob.startDelayMinutes} + + + + + + + + diff --git a/src/main/resources/alfresco/subsystems/Search/solr6/solr-search-context.xml b/src/main/resources/alfresco/subsystems/Search/solr6/solr-search-context.xml index cb06e6dd40..d06961782c 100644 --- a/src/main/resources/alfresco/subsystems/Search/solr6/solr-search-context.xml +++ b/src/main/resources/alfresco/subsystems/Search/solr6/solr-search-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml b/src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml index f76aaa578d..c962e2de37 100644 --- a/src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml +++ b/src/main/resources/alfresco/subsystems/Synchronization/default/default-synchronization-context.xml @@ -1,38 +1,34 @@ - + - - - - - - org.alfresco.repo.security.sync.UserRegistrySynchronizerJob - - - - - - - - ${synchronization.synchronizeChangesOnly} - - - - - - - ${synchronization.import.cron} - - - - - - ${system.cronJob.startDelayMinutes} + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/alfresco/subsystems/fileServers/default/file-servers-context.xml b/src/main/resources/alfresco/subsystems/fileServers/default/file-servers-context.xml index 300ebcfbcc..2b7edbc6ac 100644 --- a/src/main/resources/alfresco/subsystems/fileServers/default/file-servers-context.xml +++ b/src/main/resources/alfresco/subsystems/fileServers/default/file-servers-context.xml @@ -1,7 +1,8 @@ - - + - + @@ -39,7 +40,7 @@ - + diff --git a/src/main/resources/alfresco/subsystems/fileServers/default/network-protocol-context.xml b/src/main/resources/alfresco/subsystems/fileServers/default/network-protocol-context.xml index c6e12825f6..1c613979f8 100644 --- a/src/main/resources/alfresco/subsystems/fileServers/default/network-protocol-context.xml +++ b/src/main/resources/alfresco/subsystems/fileServers/default/network-protocol-context.xml @@ -1,7 +1,9 @@ - - - + + @@ -77,34 +79,28 @@ ${filesystem.lockKeeperEnabled} ${filesystem.lockKeeperTimeout} - - - - - - org.alfresco.filesys.repo.LockKeeperRefreshJob - - - - - - - - - - - - - - - ${filesystem.lockKeeperRefreshCronExpression} - - - ${system.cronJob.startDelayMinutes} - + + + + + + + + + + + + + + + + + + + + + - - diff --git a/src/main/resources/alfresco/subsystems/imap/default/imap-server-context.xml b/src/main/resources/alfresco/subsystems/imap/default/imap-server-context.xml index c297afdf03..3d22384b06 100644 --- a/src/main/resources/alfresco/subsystems/imap/default/imap-server-context.xml +++ b/src/main/resources/alfresco/subsystems/imap/default/imap-server-context.xml @@ -1,7 +1,8 @@ - - - + @@ -32,7 +33,7 @@ - + @@ -207,7 +208,7 @@ - + diff --git a/src/main/resources/alfresco/tagging-services-context.xml b/src/main/resources/alfresco/tagging-services-context.xml index f639dcac83..0464b85a5f 100644 --- a/src/main/resources/alfresco/tagging-services-context.xml +++ b/src/main/resources/alfresco/tagging-services-context.xml @@ -1,7 +1,8 @@ - - - + @@ -12,10 +13,10 @@ - + - + diff --git a/src/main/resources/alfresco/template-services-context.xml b/src/main/resources/alfresco/template-services-context.xml index f7f7ef4610..5ddb23246c 100644 --- a/src/main/resources/alfresco/template-services-context.xml +++ b/src/main/resources/alfresco/template-services-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/thumbnail-service-context.xml b/src/main/resources/alfresco/thumbnail-service-context.xml index c92b93aa8d..2d3eae01aa 100644 --- a/src/main/resources/alfresco/thumbnail-service-context.xml +++ b/src/main/resources/alfresco/thumbnail-service-context.xml @@ -3,8 +3,8 @@ + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> @@ -16,10 +16,10 @@ - + - + diff --git a/src/main/resources/alfresco/transfer-service-context.xml b/src/main/resources/alfresco/transfer-service-context.xml index 0ec5ebcb27..dbc9a451ef 100644 --- a/src/main/resources/alfresco/transfer-service-context.xml +++ b/src/main/resources/alfresco/transfer-service-context.xml @@ -1,6 +1,9 @@ - - + + @@ -212,10 +215,10 @@ - + - + @@ -229,10 +232,10 @@ - + - + @@ -263,10 +266,10 @@ - + - + diff --git a/src/main/resources/alfresco/usage-services-context.xml b/src/main/resources/alfresco/usage-services-context.xml index 0f4f1940b5..7a578b3775 100644 --- a/src/main/resources/alfresco/usage-services-context.xml +++ b/src/main/resources/alfresco/usage-services-context.xml @@ -1,8 +1,10 @@ - - + diff --git a/src/main/resources/alfresco/webdav-context.xml b/src/main/resources/alfresco/webdav-context.xml index a418000cc3..4313b6da84 100644 --- a/src/main/resources/alfresco/webdav-context.xml +++ b/src/main/resources/alfresco/webdav-context.xml @@ -1,7 +1,8 @@ - - - + diff --git a/src/main/resources/alfresco/workflow-context.xml b/src/main/resources/alfresco/workflow-context.xml index d7bc534be1..17e9e44fa0 100644 --- a/src/main/resources/alfresco/workflow-context.xml +++ b/src/main/resources/alfresco/workflow-context.xml @@ -1,7 +1,8 @@ - - - + @@ -132,7 +133,7 @@ - + diff --git a/src/test/java/org/alfresco/AllUnitTestsSuite.java b/src/test/java/org/alfresco/AllUnitTestsSuite.java index 8d1e60fbe0..34e767d470 100644 --- a/src/test/java/org/alfresco/AllUnitTestsSuite.java +++ b/src/test/java/org/alfresco/AllUnitTestsSuite.java @@ -193,7 +193,12 @@ import org.junit.runners.Suite; org.alfresco.heartbeat.ConfigurationDataCollectorTest.class, org.alfresco.heartbeat.InfoDataCollectorTest.class, org.alfresco.heartbeat.ModelUsageDataCollectorTest.class, - org.alfresco.heartbeat.SystemUsageDataCollectorTest.class + org.alfresco.heartbeat.SystemUsageDataCollectorTest.class, + + org.alfresco.repo.domain.DialectFactoryBeanTest.class, + org.alfresco.util.BeanExtenderUnitTest.class, + org.alfresco.util.bean.HierarchicalBeanLoaderTest.class, + org.alfresco.util.resource.HierarchicalResourceLoaderTest.class }) public class AllUnitTestsSuite { diff --git a/src/test/java/org/alfresco/AppContext04TestSuite.java b/src/test/java/org/alfresco/AppContext04TestSuite.java index 93a51c28fe..7fc84cd396 100644 --- a/src/test/java/org/alfresco/AppContext04TestSuite.java +++ b/src/test/java/org/alfresco/AppContext04TestSuite.java @@ -88,7 +88,6 @@ import org.junit.runners.Suite; org.alfresco.util.schemacomp.SchemaReferenceFileTest.class, org.alfresco.repo.module.ModuleComponentHelperTest.class, org.alfresco.repo.node.getchildren.GetChildrenCannedQueryTest.class, - org.alfresco.util.CronTriggerBeanSystemTest.class, org.alfresco.filesys.auth.cifs.CifsAuthenticatorPassthruTest.class, // the following test fails locally - on windows diff --git a/src/test/java/org/alfresco/AppContextExtraTestSuite.java b/src/test/java/org/alfresco/AppContextExtraTestSuite.java index c2f35f3175..740435576a 100644 --- a/src/test/java/org/alfresco/AppContextExtraTestSuite.java +++ b/src/test/java/org/alfresco/AppContextExtraTestSuite.java @@ -114,6 +114,9 @@ import org.junit.runners.Suite; org.alfresco.repo.site.SiteServiceImplMoreTest.class, org.alfresco.util.test.junitrules.TemporarySitesTest.class, + // [classpath:alfresco/application-context.xml, classpath:subsystem-test-context.xml] + org.alfresco.repo.management.subsystems.test.SubsystemsTest.class, + // ====================================================================== // any other order may lead to failing tests // ====================================================================== diff --git a/src/test/java/org/alfresco/MiscContextTestSuite.java b/src/test/java/org/alfresco/MiscContextTestSuite.java index 306c42753b..121f001584 100644 --- a/src/test/java/org/alfresco/MiscContextTestSuite.java +++ b/src/test/java/org/alfresco/MiscContextTestSuite.java @@ -121,9 +121,6 @@ import org.springframework.context.ApplicationContext; // [module/module-component-test-beans.xml] org.alfresco.repo.module.ComponentsTest.class, - // [alfresco/scheduler-core-context.xml, org/alfresco/util/test-scheduled-jobs-context.xml] - org.alfresco.util.CronTriggerBeanTest.class, - // ---------------------------------------------------------------------- // Transformer/Rendition contexts // @@ -140,6 +137,8 @@ import org.springframework.context.ApplicationContext; // this does NOT passes locally org.alfresco.repo.rendition.RenditionServicePermissionsTest.class, + // [ibatis/hierarchy-test/hierarchy-test-context.xml] + org.alfresco.ibatis.HierarchicalSqlSessionFactoryBeanTest.class }) public class MiscContextTestSuite { diff --git a/src/test/java/org/alfresco/heartbeat/HBDataCollectorServiceImplTest.java b/src/test/java/org/alfresco/heartbeat/HBDataCollectorServiceImplTest.java index e41e7a07c2..66816659fe 100644 --- a/src/test/java/org/alfresco/heartbeat/HBDataCollectorServiceImplTest.java +++ b/src/test/java/org/alfresco/heartbeat/HBDataCollectorServiceImplTest.java @@ -32,7 +32,9 @@ import org.alfresco.service.license.LicenseDescriptor; import org.junit.Before; import org.junit.Test; import org.quartz.CronTrigger; +import org.quartz.JobKey; import org.quartz.Scheduler; +import org.quartz.TriggerKey; import org.springframework.scheduling.quartz.SchedulerFactoryBean; import org.junit.rules.ExpectedException; @@ -279,9 +281,9 @@ public class HBDataCollectorServiceImplTest collectorService.registerCollector(c2); collectorService.registerCollector(c3); - String testCron1 = ((CronTrigger) scheduler.getTrigger(triggerName1, Scheduler.DEFAULT_GROUP)).getCronExpression(); - String testCron2 = ((CronTrigger) scheduler.getTrigger(triggerName2, Scheduler.DEFAULT_GROUP)).getCronExpression(); - String testCron3 = ((CronTrigger) scheduler.getTrigger(triggerName3, Scheduler.DEFAULT_GROUP)).getCronExpression(); + String testCron1 = ((CronTrigger) scheduler.getTrigger(new TriggerKey(triggerName1, Scheduler.DEFAULT_GROUP))).getCronExpression(); + String testCron2 = ((CronTrigger) scheduler.getTrigger(new TriggerKey(triggerName2, Scheduler.DEFAULT_GROUP))).getCronExpression(); + String testCron3 = ((CronTrigger) scheduler.getTrigger(new TriggerKey(triggerName3, Scheduler.DEFAULT_GROUP))).getCronExpression(); assertEquals("Cron expression doesn't match", cron1, testCron1); assertEquals("Cron expression doesn't match", cron2, testCron2); @@ -331,10 +333,8 @@ public class HBDataCollectorServiceImplTest { String jobName = "heartbeat-" + collectorId; String triggerName = jobName + "-Trigger"; - - String[] jobs = scheduler.getJobNames(Scheduler.DEFAULT_GROUP); - String[] triggers = scheduler.getTriggerNames(Scheduler.DEFAULT_GROUP); - return Arrays.asList(jobs).contains(jobName) && Arrays.asList(triggers).contains(triggerName); + return scheduler.checkExists(new JobKey(jobName, Scheduler.DEFAULT_GROUP)) + && scheduler.checkExists(new TriggerKey(triggerName, Scheduler.DEFAULT_GROUP)); } private class SimpleHBDataCollector extends HBBaseDataCollector diff --git a/src/test/java/org/alfresco/heartbeat/HeartBeatJobTest.java b/src/test/java/org/alfresco/heartbeat/HeartBeatJobTest.java index 81b5df8d3b..c619a450d5 100644 --- a/src/test/java/org/alfresco/heartbeat/HeartBeatJobTest.java +++ b/src/test/java/org/alfresco/heartbeat/HeartBeatJobTest.java @@ -28,12 +28,12 @@ package org.alfresco.heartbeat; import org.alfresco.heartbeat.datasender.HBData; import org.alfresco.heartbeat.datasender.HBDataSenderService; import org.alfresco.repo.lock.JobLockService; -import org.alfresco.repo.lock.JobLockServiceImpl; import org.alfresco.repo.lock.LockAcquisitionException; import org.alfresco.service.namespace.QName; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; @@ -89,16 +89,18 @@ public class HeartBeatJobTest { // mock the job context JobExecutionContext mockJobExecutionContext = mock(JobExecutionContext.class); - JobDetail jobDetail = new JobDetail(); - when(mockJobExecutionContext.getJobDetail()).thenReturn(jobDetail); - // create the hb collector SimpleHBDataCollector simpleCollector = spy(new SimpleHBDataCollector("simpleCollector")); JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put("collector", simpleCollector); jobDataMap.put("hbDataSenderService", mockDataSenderService); jobDataMap.put("jobLockService", mockJobLockService); - jobDetail.setJobDataMap(jobDataMap); + JobDetail jobDetail = JobBuilder.newJob() + .setJobData(jobDataMap) + .ofType(HeartBeatJob.class) + .build(); + when(mockJobExecutionContext.getJobDetail()).thenReturn(jobDetail); + // collector job is not locked from an other collector String lockToken = "locked"; @@ -162,14 +164,15 @@ public class HeartBeatJobTest // mock the job context JobExecutionContext mockJobExecutionContext = mock(JobExecutionContext.class); - JobDetail jobDetail = new JobDetail(); - when(mockJobExecutionContext.getJobDetail()).thenReturn(jobDetail); - JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put("collector", simpleCollector); jobDataMap.put("hbDataSenderService", mockDataSenderService); jobDataMap.put("jobLockService", mockJobLockService); - jobDetail.setJobDataMap(jobDataMap); + JobDetail jobDetail = JobBuilder.newJob() + .setJobData(jobDataMap) + .ofType(HeartBeatJob.class) + .build(); + when(mockJobExecutionContext.getJobDetail()).thenReturn(jobDetail); // Simulate job lock service String lockToken = "token"; diff --git a/src/test/java/org/alfresco/ibatis/HierarchicalSqlSessionFactoryBeanTest.java b/src/test/java/org/alfresco/ibatis/HierarchicalSqlSessionFactoryBeanTest.java new file mode 100644 index 0000000000..585e291d88 --- /dev/null +++ b/src/test/java/org/alfresco/ibatis/HierarchicalSqlSessionFactoryBeanTest.java @@ -0,0 +1,232 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.ibatis; + +import java.util.AbstractCollection; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.TreeSet; +import junit.framework.TestCase; +import org.alfresco.util.resource.HierarchicalResourceLoader; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.ibatis.mapping.MappedStatement; +import org.apache.ibatis.session.Configuration; +import org.apache.ibatis.session.SqlSessionFactory; +import org.springframework.context.support.ClassPathXmlApplicationContext; + + +/** + * @see HierarchicalSqlSessionFactoryBean + * @see HierarchicalXMLConfigBuilder + * @see HierarchicalResourceLoader + * + * @author Derek Hulley, janv + * @since 4.0 + */ +public class HierarchicalSqlSessionFactoryBeanTest extends TestCase +{ + private static final String QUERY_OBJECT = Object.class.getName(); + private static final String QUERY_ABSTRACTCOLLECTION = "org.alfresco.ibatis.abstractcollection."+AbstractCollection.class.getName().replace(".", "_"); + private static final String QUERY_ABSTRACTLIST = "org.alfresco.ibatis.abstractlist."+AbstractList.class.getName().replace(".", "_"); + private static final String QUERY_TREESET = "org.alfresco.ibatis.treeset."+TreeSet.class.getName().replace(".", "_"); + + private static Log logger = LogFactory.getLog(HierarchicalSqlSessionFactoryBeanTest.class); + + private ClassPathXmlApplicationContext ctx; + private TestDAO testDao; + + @Override + public void setUp() throws Exception + { + testDao = new TestDAO(); + testDao.setId(5L); + testDao.setPropOne("prop-one"); + testDao.setPropTwo("prop-two"); + } + + @Override + public void tearDown() throws Exception + { + try + { + if (ctx != null) + { + ctx.close(); + } + } + catch (Throwable e) + { + logger.error("Failed to neatly close application context", e); + } + } + + /** + * Pushes the dialect class into the system properties, closes an current context and + * recreates it; the MyBatis Configuration is then returned. + */ + @SuppressWarnings("unchecked") + private Configuration getConfiguration(Class dialectClass) throws Exception + { + System.setProperty("hierarchy-test.dialect", dialectClass.getName()); + if (ctx != null) + { + try + { + ctx.close(); + ctx = null; + } + catch (Throwable e) + { + logger.error("Failed to neatly close application context", e); + } + } + ctx = new ClassPathXmlApplicationContext("ibatis/hierarchy-test/hierarchy-test-context.xml"); + return ((SqlSessionFactory)ctx.getBean("mybatisConfig")).getConfiguration(); + } + + /** + * Check context startup and shutdown + */ + public void testContextStartup() throws Exception + { + getConfiguration(TreeSet.class); + getConfiguration(HashSet.class); + getConfiguration(ArrayList.class); + getConfiguration(AbstractCollection.class); + try + { + getConfiguration(Collection.class); + fail("Failed to detect incompatible class hierarchy"); + } + catch (Throwable e) + { + // Expected + } + } + + public void testHierarchyTreeSet() throws Exception + { + Configuration mybatisConfig = getConfiguration(TreeSet.class); + MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_TREESET); + assertNotNull("Query missing for " + QUERY_TREESET + " using " + TreeSet.class, stmt); + try + { + mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION); + fail("Query not missing for " + QUERY_ABSTRACTCOLLECTION + " using " + TreeSet.class); + } + catch (IllegalArgumentException e) + { + // Expected + } + } + + public void testHierarchyHashSet() throws Exception + { + Configuration mybatisConfig = getConfiguration(HashSet.class); + MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION); + assertNotNull("Query missing for " + QUERY_ABSTRACTCOLLECTION + " using " + HashSet.class, stmt); + try + { + mybatisConfig.getMappedStatement(QUERY_OBJECT); + fail("Query not missing for " + QUERY_OBJECT + " using " + HashSet.class); + } + catch (IllegalArgumentException e) + { + // Expected + } + } + + public void testHierarchyArrayList() throws Exception + { + Configuration mybatisConfig = getConfiguration(ArrayList.class); + MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_ABSTRACTLIST); + assertNotNull("Query missing for " + QUERY_ABSTRACTLIST + " using " + ArrayList.class, stmt); + try + { + mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION); + fail("Query not missing for " + QUERY_ABSTRACTCOLLECTION + " using " + ArrayList.class); + } + catch (IllegalArgumentException e) + { + // Expected + } + } + + public void testHierarchyAbstractCollection() throws Exception + { + Configuration mybatisConfig = getConfiguration(AbstractCollection.class); + MappedStatement stmt = mybatisConfig.getMappedStatement(QUERY_ABSTRACTCOLLECTION); + assertNotNull("Query missing for " + QUERY_ABSTRACTCOLLECTION + " using " + AbstractCollection.class, stmt); + try + { + mybatisConfig.getMappedStatement(QUERY_OBJECT); + fail("Query not missing for " + QUERY_OBJECT + " using " + AbstractCollection.class); + } + catch (IllegalArgumentException e) + { + // Expected + } + } + + /** + * Helper class that iBatis will use in the test mappings + * @author Derek Hulley + */ + public static class TestDAO + { + private Long id; + private String propOne; + private String propTwo; + + public Long getId() + { + return id; + } + public void setId(Long id) + { + this.id = id; + } + public String getPropOne() + { + return propOne; + } + public void setPropOne(String propOne) + { + this.propOne = propOne; + } + public String getPropTwo() + { + return propTwo; + } + public void setPropTwo(String propTwo) + { + this.propTwo = propTwo; + } + } +} diff --git a/src/test/java/org/alfresco/repo/action/ActionServiceImplTest.java b/src/test/java/org/alfresco/repo/action/ActionServiceImplTest.java index 03c4ba7f79..5119b97003 100644 --- a/src/test/java/org/alfresco/repo/action/ActionServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/action/ActionServiceImplTest.java @@ -78,8 +78,14 @@ import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * Action service test @@ -87,6 +93,9 @@ import org.springframework.context.ConfigurableApplicationContext; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional +@ContextConfiguration({"classpath:alfresco/application-context.xml", + "classpath:org/alfresco/repo/action/test-action-services-context.xml"}) public class ActionServiceImplTest extends BaseAlfrescoSpringTest { private static final String BAD_NAME = "badName"; @@ -95,23 +104,10 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest private NodeRef folder; private RetryingTransactionHelper transactionHelper; - @Override - protected String[] getConfigLocations() + @Before + public void before() throws Exception { - String[] existingConfigLocations = ApplicationContextHelper.CONFIG_LOCATIONS; - - List locations = Arrays.asList(existingConfigLocations); - List mutableLocationsList = new ArrayList(locations); - mutableLocationsList.add("classpath:org/alfresco/repo/action/test-action-services-context.xml"); - - String[] result = mutableLocationsList.toArray(new String[mutableLocationsList.size()]); - return result; - } - - @Override - protected void onSetUpInTransaction() throws Exception - { - super.onSetUpInTransaction(); + super.before(); this.transactionHelper = (RetryingTransactionHelper)this.applicationContext.getBean("retryingTransactionHelper"); @@ -138,6 +134,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test getActionDefinition */ + @Test public void testGetActionDefinition() { ActionDefinition action = actionService.getActionDefinition(AddFeaturesActionExecuter.NAME); @@ -151,6 +148,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test getActionDefintions */ + @Test public void testGetActionDefinitions() { List defintions = this.actionService.getActionDefinitions(); @@ -172,6 +170,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test getActionConditionDefinition */ + @Test public void testGetActionConditionDefinition() { ActionConditionDefinition condition = this.actionService.getActionConditionDefinition(NoConditionEvaluator.NAME); @@ -186,6 +185,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest * Test getActionConditionDefinitions * */ + @Test public void testGetActionConditionDefinitions() { List defintions = this.actionService.getActionConditionDefinitions(); @@ -201,6 +201,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test create action condition */ + @Test public void testCreateActionCondition() { ActionCondition condition = this.actionService.createActionCondition(NoConditionEvaluator.NAME); @@ -217,7 +218,8 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test createCompositeAction */ - public void testCreateCompositeActionCondition() + @Test + public void testCreateCompositeActionCondition() { CompositeActionCondition action = this.actionService.createCompositeActionCondition(); assertNotNull(action); @@ -227,6 +229,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test createAction */ + @Test public void testCreateAction() { Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME); @@ -242,6 +245,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test createCompositeAction */ + @Test public void testCreateCompositeAction() { CompositeAction action = this.actionService.createCompositeAction(); @@ -252,6 +256,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Evaluate action */ + @Test public void testEvaluateAction() { Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME); @@ -277,6 +282,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test evaluate action condition */ + @Test public void testEvaluateActionCondition() { ActionCondition condition = this.actionService.createActionCondition(ComparePropertyValueEvaluator.NAME); @@ -294,7 +300,8 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test evaluate action condition */ - public void testEvaluateCompositeActionConditionWith1SubCondition() + @Test + public void testEvaluateCompositeActionConditionWith1SubCondition() { CompositeActionCondition compositeCondition = this.actionService.createCompositeActionCondition(); @@ -314,7 +321,8 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test evaluate action condition */ - public void testEvaluateCompositeActionConditionWith2SubConditions() + @Test + public void testEvaluateCompositeActionConditionWith2SubConditions() { CompositeActionCondition compositeCondition = this.actionService.createCompositeActionCondition(); @@ -356,6 +364,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test execute action */ + @Test public void testExecuteAction() { assertFalse(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE)); @@ -413,6 +422,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest assertTrue(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE)); } + @Test public void testGetAndGetAllWithNoActions() { assertNull(this.actionService.getAction(this.nodeRef, AddFeaturesActionExecuter.NAME)); @@ -421,6 +431,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest assertEquals(0, actions.size()); } + @Test public void testExecuteActionWithNoParameterDef() { Action action = this.actionService.createAction("empty-action"); @@ -432,6 +443,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest * Test saving an action with no conditions. Includes testing storage and retrieval * of compensating actions. */ + @Test public void testSaveActionNoCondition() { // Create the action @@ -513,6 +525,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest //System.out.println(NodeStoreInspector.dumpNodeStore(this.nodeService, this.testStoreRef)); } + @Test public void testOwningNodeRef() { // Create the action @@ -540,6 +553,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test saving an action with conditions */ + @Test public void testSaveActionWithConditions() { // Create the action @@ -632,6 +646,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test saving a composite action */ + @Test public void testSaveCompositeAction() { Action action1 = this.actionService.createAction(AddFeaturesActionExecuter.NAME); @@ -696,6 +711,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test remove action */ + @Test public void testRemove() { assertEquals(0, this.actionService.getActions(this.nodeRef).size()); @@ -713,6 +729,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest assertEquals(0, this.actionService.getActions(this.nodeRef).size()); } + @Test public void testConditionOrder() { Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME); @@ -750,6 +767,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest assertEquals(condition4, savedAction2.getActionCondition(2)); } + @Test public void testActionOrder() { CompositeAction action = this.actionService.createCompositeAction(); @@ -790,6 +808,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test the action result parameter */ + @Test public void testActionResult() { // Create the script node reference @@ -828,8 +847,8 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest */ public void offtestAsyncLongRunningActionsFilter() { - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); final SleepActionExecuter sleepAction = (SleepActionExecuter)applicationContext.getBean("sleep-action"); assertNotNull(sleepAction); @@ -904,6 +923,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test asynchronous execute action */ + @Test public void testAsyncExecuteAction() { assertFalse(this.nodeService.hasAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE)); @@ -913,9 +933,9 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest action.setExecuteAsynchronously(true); this.actionService.executeAction(action, this.nodeRef); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); final NodeService finalNodeService = this.nodeService; final NodeRef finalNodeRef = this.nodeRef; @@ -939,6 +959,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test async composite action execution */ + @Test public void testAsyncCompositeActionExecute() { // Create the composite action @@ -955,9 +976,9 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest // Execute the composite action this.actionService.executeAction(compAction, this.nodeRef); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); final NodeService finalNodeService = this.nodeService; final NodeRef finalNodeRef = this.nodeRef; @@ -988,10 +1009,10 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest for (int i = 0; i < 1000; i++) { this.actionService.executeAction(action, this.nodeRef); - } - - setComplete(); - endTransaction(); + } + + TestTransaction.flagForCommit(); + TestTransaction.end(); // TODO how do we assess whether the large number of actions stacked cause a problem ?? } @@ -1071,6 +1092,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test sync failure behaviour */ + @Test public void testSyncFailureBehaviour() { // Create an action that is going to fail @@ -1116,6 +1138,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Test the compensating action */ + @Test public void testCompensatingAction() { // Create actions that are going to fail @@ -1142,9 +1165,9 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest this.actionService.executeAction(fatalAction, this.nodeRef); this.actionService.executeAction(nonfatalAction, this.nodeRef); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); postAsyncActionTest( this.transactionService, @@ -1200,6 +1223,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * http://issues.alfresco.com/jira/browse/ALF-5027 */ + @Test public void testALF5027() throws Exception { String userName = "bob" + GUID.generate(); @@ -1239,6 +1263,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest * execution related details such as started at, * ended at, status and exception */ + @Test public void testExecutionTrackingDetails() { Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME); String actionId = action.getId(); @@ -1394,7 +1419,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest /** * Loads this executor into the ApplicationContext, if it isn't already there */ - public static void registerIfNeeded(ConfigurableApplicationContext ctx) + public static void registerIfNeeded(ApplicationContext ctx) { if (!ctx.containsBean(SleepActionExecuter.NAME)) { @@ -1403,7 +1428,7 @@ public class ActionServiceImplTest extends BaseAlfrescoSpringTest executor.setTrackStatus(true); executor.actionTrackingService = (ActionTrackingService) ctx.getBean("actionTrackingService"); // Register - ctx.getBeanFactory().registerSingleton(SleepActionExecuter.NAME, executor); + ((ConfigurableApplicationContext) ctx).getBeanFactory().registerSingleton(SleepActionExecuter.NAME, executor); } } diff --git a/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java b/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java index f57f44c811..4d9224c84f 100644 --- a/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java +++ b/src/test/java/org/alfresco/repo/action/constraint/ActionParameterConstraintTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.constraint; import java.util.List; @@ -32,6 +32,7 @@ import org.alfresco.repo.action.evaluator.compare.ComparePropertyValueOperation; import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ParameterConstraint; import org.alfresco.util.BaseSpringTest; +import org.junit.Before; /** * Action parameter constraint unit test @@ -44,12 +45,8 @@ public class ActionParameterConstraintTest extends BaseSpringTest private ActionService actionService; - /** - * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpInTransaction() - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { actionService = (ActionService)applicationContext.getBean("ActionService"); } diff --git a/src/test/java/org/alfresco/repo/action/evaluator/CompareMimeTypeEvaluatorTest.java b/src/test/java/org/alfresco/repo/action/evaluator/CompareMimeTypeEvaluatorTest.java index d4b6d49602..1d10174e86 100644 --- a/src/test/java/org/alfresco/repo/action/evaluator/CompareMimeTypeEvaluatorTest.java +++ b/src/test/java/org/alfresco/repo/action/evaluator/CompareMimeTypeEvaluatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.evaluator; import org.alfresco.model.ContentModel; @@ -36,12 +36,16 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; +import org.springframework.transaction.annotation.Transactional; /** * Compare property value evaluator test * * @author Roy Wetherall */ +@Transactional public class CompareMimeTypeEvaluatorTest extends BaseSpringTest { private NodeService nodeService; @@ -51,11 +55,8 @@ public class CompareMimeTypeEvaluatorTest extends BaseSpringTest private NodeRef nodeRef; private CompareMimeTypeEvaluator evaluator; - /** - * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpInTransaction() - */ - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); @@ -76,7 +77,8 @@ public class CompareMimeTypeEvaluatorTest extends BaseSpringTest this.evaluator = (CompareMimeTypeEvaluator)this.applicationContext.getBean(CompareMimeTypeEvaluator.NAME); } - + + @Test public void testContentPropertyComparisons() { ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME); diff --git a/src/test/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java b/src/test/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java index 4d3b69c0b1..9dc65eef11 100644 --- a/src/test/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java +++ b/src/test/java/org/alfresco/repo/action/evaluator/ComparePropertyValueEvaluatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.evaluator; import java.io.Serializable; @@ -54,12 +54,17 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; /** * Compare property value evaluator test * * @author Roy Wetherall */ +@Transactional public class ComparePropertyValueEvaluatorTest extends BaseSpringTest { private static final String TEST_TYPE_NAMESPACE = "testNamespace"; @@ -77,7 +82,8 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest private Date dateValue; private Date afterDateValue; private NodeRef nodeValue; - + + @Autowired private DictionaryDAO dictionaryDAO; private NodeService nodeService; private ContentService contentService; @@ -87,22 +93,8 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest private NodeRef nodeRef; private ComparePropertyValueEvaluator evaluator; - /** - * Sets the meta model DAO - * - * @param dictionaryDAO the meta model DAO - */ - public void setDictionaryDAO(DictionaryDAO dictionaryDAO) - { - this.dictionaryDAO = dictionaryDAO; - } - - /** - * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpInTransaction() - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { // Need to create model to contain our custom type createTestModel(); @@ -142,7 +134,8 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest this.evaluator = (ComparePropertyValueEvaluator)this.applicationContext.getBean(ComparePropertyValueEvaluator.NAME); } - + + @Test public void testCheckParamDefintionWithConstraint() { ActionConditionDefinition def = evaluator.getActionConditionDefintion(); @@ -160,6 +153,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest /** * Test numeric comparisions */ + @Test public void testNumericComparison() { ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME); @@ -242,6 +236,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest /** * Test date comparison */ + @Test public void testDateComparison() { ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME); @@ -324,6 +319,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest /** * Test text comparison */ + @Test public void testTextComparison() { ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME); @@ -404,6 +400,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest /** * Test some combinations of test file names that had been failing */ + @Test public void testTempFileNames() { ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME); @@ -418,6 +415,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest /** * Test comparison of properties that do not have a registered comparitor */ + @Test public void testOtherComparison() { NodeRef badNodeRef = new NodeRef(this.testStoreRef, "badId"); @@ -465,6 +463,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest } + @Test public void testContentPropertyComparisons() { ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME); @@ -503,6 +502,7 @@ public class ComparePropertyValueEvaluatorTest extends BaseSpringTest } + @Test public void testMultiValuedPropertyComparisons() { ActionConditionImpl condition = new ActionConditionImpl(GUID.generate(), ComparePropertyValueEvaluator.NAME); diff --git a/src/test/java/org/alfresco/repo/action/evaluator/HasAspectEvaluatorTest.java b/src/test/java/org/alfresco/repo/action/evaluator/HasAspectEvaluatorTest.java index 7c4e482d8a..6bfcb2b1a3 100644 --- a/src/test/java/org/alfresco/repo/action/evaluator/HasAspectEvaluatorTest.java +++ b/src/test/java/org/alfresco/repo/action/evaluator/HasAspectEvaluatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.evaluator; import org.alfresco.model.ContentModel; @@ -34,12 +34,16 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; +import org.springframework.transaction.annotation.Transactional; /** * Is sub class evaluator test * * @author Roy Wetherall */ +@Transactional public class HasAspectEvaluatorTest extends BaseSpringTest { private NodeService nodeService; @@ -50,9 +54,8 @@ public class HasAspectEvaluatorTest extends BaseSpringTest private final static String ID = GUID.generate(); - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); @@ -72,6 +75,7 @@ public class HasAspectEvaluatorTest extends BaseSpringTest this.evaluator = (HasAspectEvaluator)this.applicationContext.getBean(HasAspectEvaluator.NAME); } + @Test public void testMandatoryParamsMissing() { ActionCondition condition = new ActionConditionImpl(ID, HasAspectEvaluator.NAME, null); @@ -87,6 +91,7 @@ public class HasAspectEvaluatorTest extends BaseSpringTest } } + @Test public void testPass() { this.nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE, null); @@ -95,6 +100,7 @@ public class HasAspectEvaluatorTest extends BaseSpringTest assertTrue(this.evaluator.evaluate(condition, this.nodeRef)); } + @Test public void testFail() { ActionCondition condition = new ActionConditionImpl(ID, HasAspectEvaluator.NAME, null); diff --git a/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java b/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java index 6929f6f921..a4cf32644d 100644 --- a/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java +++ b/src/test/java/org/alfresco/repo/action/evaluator/HasChildEvaluatorTest.java @@ -34,6 +34,8 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.springframework.transaction.annotation.Transactional; /** * Test class for {@link HasChildEvaluator}. @@ -41,6 +43,7 @@ import org.alfresco.util.GUID; * @author Neil McErlean * @since 3.4 */ +@Transactional public class HasChildEvaluatorTest extends BaseSpringTest { private NodeService nodeService; @@ -53,9 +56,8 @@ public class HasChildEvaluatorTest extends BaseSpringTest private final static String ID = GUID.generate(); - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); diff --git a/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java b/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java index a12d6317ca..0ae69cd9c0 100644 --- a/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java +++ b/src/test/java/org/alfresco/repo/action/evaluator/HasTagEvaluatorTest.java @@ -1,47 +1,50 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.evaluator; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.action.ActionConditionImpl; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.service.cmr.action.ActionCondition; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.tagging.TaggingService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.BaseSpringTest; -import org.alfresco.util.GUID; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.action.ActionConditionImpl; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.service.cmr.action.ActionCondition; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.tagging.TaggingService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.BaseSpringTest; +import org.alfresco.util.GUID; +import org.junit.Before; +import org.springframework.transaction.annotation.Transactional; /** * Has tag evaluator unit test * * @author Roy Wetherall */ +@Transactional public class HasTagEvaluatorTest extends BaseSpringTest { private NodeService nodeService; @@ -53,9 +56,8 @@ public class HasTagEvaluatorTest extends BaseSpringTest private final static String ID = GUID.generate(); - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)applicationContext.getBean("nodeService"); this.taggingService = (TaggingService)applicationContext.getBean("taggingService"); diff --git a/src/test/java/org/alfresco/repo/action/evaluator/IsSubTypeEvaluatorTest.java b/src/test/java/org/alfresco/repo/action/evaluator/IsSubTypeEvaluatorTest.java index 8384c70a0a..b65384e9cf 100644 --- a/src/test/java/org/alfresco/repo/action/evaluator/IsSubTypeEvaluatorTest.java +++ b/src/test/java/org/alfresco/repo/action/evaluator/IsSubTypeEvaluatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.evaluator; import org.alfresco.model.ContentModel; @@ -34,12 +34,16 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; +import org.springframework.transaction.annotation.Transactional; /** * Is sub class evaluator test * * @author Roy Wetherall */ +@Transactional public class IsSubTypeEvaluatorTest extends BaseSpringTest { private NodeService nodeService; @@ -50,8 +54,8 @@ public class IsSubTypeEvaluatorTest extends BaseSpringTest private final static String ID = GUID.generate(); - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); @@ -71,6 +75,7 @@ public class IsSubTypeEvaluatorTest extends BaseSpringTest this.evaluator = (IsSubTypeEvaluator)this.applicationContext.getBean(IsSubTypeEvaluator.NAME); } + @Test public void testMandatoryParamsMissing() { ActionCondition condition = new ActionConditionImpl(ID, IsSubTypeEvaluator.NAME, null); @@ -86,6 +91,7 @@ public class IsSubTypeEvaluatorTest extends BaseSpringTest } } + @Test public void testPass() { ActionCondition condition = new ActionConditionImpl(ID, IsSubTypeEvaluator.NAME, null); @@ -95,6 +101,7 @@ public class IsSubTypeEvaluatorTest extends BaseSpringTest assertTrue(this.evaluator.evaluate(condition, this.nodeRef)); } + @Test public void testFail() { ActionCondition condition = new ActionConditionImpl(ID, IsSubTypeEvaluator.NAME, null); diff --git a/src/test/java/org/alfresco/repo/action/executer/AddFeaturesActionExecuterTest.java b/src/test/java/org/alfresco/repo/action/executer/AddFeaturesActionExecuterTest.java index 72df6d201e..d6d17005b6 100644 --- a/src/test/java/org/alfresco/repo/action/executer/AddFeaturesActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/AddFeaturesActionExecuterTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; import java.util.List; @@ -39,13 +39,17 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.transaction.annotation.Transactional; /** * Add features action execution test * * @author Roy Wetherall */ +@Transactional public class AddFeaturesActionExecuterTest extends BaseSpringTest { /** @@ -81,8 +85,8 @@ public class AddFeaturesActionExecuterTest extends BaseSpringTest /** * Called at the begining of all tests */ - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); @@ -109,6 +113,7 @@ public class AddFeaturesActionExecuterTest extends BaseSpringTest /** * Test execution */ + @Test public void testExecution() { // Check that the node does not have the classifiable aspect @@ -126,6 +131,7 @@ public class AddFeaturesActionExecuterTest extends BaseSpringTest /** * MNT-15802 */ + @Test public void testCheckLocalizedParamDefintionWithConstraint() { // test for other than default locale diff --git a/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java b/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java index 91f37b8e3c..c0dbb13824 100644 --- a/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/CheckOutActionExecuterTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; import org.alfresco.model.ContentModel; @@ -36,12 +36,15 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Tests checkout using action executer */ @Category(BaseSpringTestsCategory.class) +@Transactional public class CheckOutActionExecuterTest extends BaseSpringTest { private NodeService nodeService; @@ -62,8 +65,8 @@ public class CheckOutActionExecuterTest extends BaseSpringTest */ private final static String ID = GUID.generate(); - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); diff --git a/src/test/java/org/alfresco/repo/action/executer/ContentMetadataEmbedderTest.java b/src/test/java/org/alfresco/repo/action/executer/ContentMetadataEmbedderTest.java index 477c528d94..c4df229da6 100644 --- a/src/test/java/org/alfresco/repo/action/executer/ContentMetadataEmbedderTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/ContentMetadataEmbedderTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; import java.io.IOException; @@ -60,12 +60,16 @@ import org.apache.tika.metadata.Metadata; import org.apache.tika.mime.MediaType; import org.apache.tika.parser.ParseContext; import org.apache.tika.parser.Parser; +import org.junit.Before; +import org.junit.Test; +import org.springframework.transaction.annotation.Transactional; /** * Test of the ActionExecuter for embedding metadata * * @author Ray Gauss II */ +@Transactional public class ContentMetadataEmbedderTest extends BaseSpringTest { @@ -82,8 +86,8 @@ public class ContentMetadataEmbedderTest extends BaseSpringTest private final static String ID = GUID.generate(); - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); this.contentService = (ContentService) this.applicationContext.getBean("contentService"); @@ -122,6 +126,7 @@ public class ContentMetadataEmbedderTest extends BaseSpringTest /** * Test that a failing embedder does not destroy the original content */ + @Test public void testFailingEmbedder() { MetadataExtracterRegistry registry = (MetadataExtracterRegistry) applicationContext.getBean("metadataExtracterRegistry"); diff --git a/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java b/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java index d06be5de93..d7ccf2a97d 100644 --- a/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/ContentMetadataExtracterTest.java @@ -1,29 +1,29 @@ /* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* * Copyright (C) 2005 Jesper Steen M�ller * * This file is part of Alfresco @@ -67,7 +67,10 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Test of the ActionExecuter for extracting metadata. Note: This test makes @@ -76,6 +79,7 @@ import org.junit.experimental.categories.Category; * @author Jesper Steen Møller */ @Category(BaseSpringTestsCategory.class) +@Transactional public class ContentMetadataExtracterTest extends BaseSpringTest { protected static final String QUICK_TITLE = "The quick brown fox jumps over the lazy dog"; @@ -92,8 +96,8 @@ public class ContentMetadataExtracterTest extends BaseSpringTest private final static String ID = GUID.generate(); - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); this.contentService = (ContentService) this.applicationContext.getBean("contentService"); @@ -125,6 +129,7 @@ public class ContentMetadataExtracterTest extends BaseSpringTest /** * Test execution of the extraction itself */ + @Test public void testFromBlanks() { // Test that the action writes properties when they don't exist or are @@ -181,6 +186,7 @@ public class ContentMetadataExtracterTest extends BaseSpringTest } } + @Test public void testUnknownProperties() { MetadataExtracterRegistry registry = (MetadataExtracterRegistry) applicationContext.getBean("metadataExtracterRegistry"); @@ -238,6 +244,7 @@ public class ContentMetadataExtracterTest extends BaseSpringTest * when running with {@link ContentMetadataExtracter#setCarryAspectProperties(boolean)} * set to false. */ + @Test public void testNullExtractedValues_ALF1823() { MetadataExtracterRegistry registry = (MetadataExtracterRegistry) applicationContext.getBean("metadataExtracterRegistry"); @@ -285,6 +292,7 @@ public class ContentMetadataExtracterTest extends BaseSpringTest /** * Test execution of the pragmatic approach */ + @Test public void testFromPartial() { // Test that the action does not overwrite properties that are already diff --git a/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java b/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java index 7eeff9014c..6471762a73 100644 --- a/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/ExecuteAllRulesActionExecuterTest.java @@ -51,12 +51,15 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; import org.junit.experimental.categories.Category; import java.io.Serializable; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; import static org.alfresco.repo.rule.RuleModel.ASPECT_IGNORE_INHERITED_RULES; @@ -66,6 +69,7 @@ import static org.alfresco.repo.rule.RuleModel.ASPECT_IGNORE_INHERITED_RULES; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest { /** The node service */ @@ -101,8 +105,8 @@ public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest /** * Called at the beginning of all tests */ - @Override - protected void onSetUpInTransaction() throws Exception + @Before + protected void before() throws Exception { this.checkOutCheckInService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService"); this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); @@ -157,8 +161,8 @@ public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest // Execute rule on document upload ActionImpl action = new ActionImpl(null, ID, ExecuteAllRulesActionExecuter.NAME, null); this.executer.execute(action, folder); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); assertTrue(this.nodeService.hasAspect(doc, ContentModel.ASPECT_CLASSIFIABLE)); transactionHelper.doInTransaction(new RetryingTransactionCallback() @@ -256,8 +260,8 @@ public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest ActionImpl action = new ActionImpl(null, ID, ExecuteAllRulesActionExecuter.NAME, null); this.executer.execute(action, folder); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionHelper.doInTransaction(new RetryingTransactionCallback() { @@ -390,8 +394,8 @@ public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest linkAction.setExecuteAsynchronously(false); actionService.executeAction(linkAction, folderA); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionHelper.doInTransaction(() -> { assertFalse(nodeService.hasAspect(folderA, ContentModel.ASPECT_CLASSIFIABLE)); @@ -462,8 +466,8 @@ public class ExecuteAllRulesActionExecuterTest extends BaseSpringTest NodeRef fileB = createFile(folderB, "fileB.txt").getNodeRef(); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // On RootFolder create a rule transactionHelper.doInTransaction(() -> { diff --git a/src/test/java/org/alfresco/repo/action/executer/RemoveFeaturesActionExecuterTest.java b/src/test/java/org/alfresco/repo/action/executer/RemoveFeaturesActionExecuterTest.java index 5b94c392e7..ac88fb6f26 100644 --- a/src/test/java/org/alfresco/repo/action/executer/RemoveFeaturesActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/RemoveFeaturesActionExecuterTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; import org.alfresco.model.ContentModel; @@ -35,7 +35,10 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Remove features action execution test @@ -43,6 +46,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class RemoveFeaturesActionExecuterTest extends BaseSpringTest { /** @@ -78,8 +82,8 @@ public class RemoveFeaturesActionExecuterTest extends BaseSpringTest /** * Called at the begining of all tests */ - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); @@ -107,6 +111,7 @@ public class RemoveFeaturesActionExecuterTest extends BaseSpringTest /** * Test execution */ + @Test public void testExecution() { // Check that the node has the classifiable aspect diff --git a/src/test/java/org/alfresco/repo/action/executer/SetPropertyValueActionExecuterTest.java b/src/test/java/org/alfresco/repo/action/executer/SetPropertyValueActionExecuterTest.java index 2748787876..0f40b0d4a5 100644 --- a/src/test/java/org/alfresco/repo/action/executer/SetPropertyValueActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/SetPropertyValueActionExecuterTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; import org.alfresco.model.ContentModel; @@ -35,7 +35,10 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Is sub class evaluator test @@ -43,6 +46,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class SetPropertyValueActionExecuterTest extends BaseSpringTest { private NodeService nodeService; @@ -55,8 +59,8 @@ public class SetPropertyValueActionExecuterTest extends BaseSpringTest private final static String TEST_VALUE = "TestValue"; - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); @@ -83,6 +87,7 @@ public class SetPropertyValueActionExecuterTest extends BaseSpringTest /** * Test execution */ + @Test public void testExecution() { // Execute the action diff --git a/src/test/java/org/alfresco/repo/action/executer/SpecialiseTypeActionExecuterTest.java b/src/test/java/org/alfresco/repo/action/executer/SpecialiseTypeActionExecuterTest.java index 7071c18c79..0782c17297 100644 --- a/src/test/java/org/alfresco/repo/action/executer/SpecialiseTypeActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/SpecialiseTypeActionExecuterTest.java @@ -1,38 +1,41 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.action.ActionImpl; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.util.BaseAlfrescoSpringTest; -import org.alfresco.util.GUID; -import org.junit.experimental.categories.Category; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.action.ActionImpl; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.test_category.BaseSpringTestsCategory; +import org.alfresco.util.BaseAlfrescoSpringTest; +import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Specialise type action execution test @@ -40,6 +43,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class SpecialiseTypeActionExecuterTest extends BaseAlfrescoSpringTest { /** @@ -60,10 +64,10 @@ public class SpecialiseTypeActionExecuterTest extends BaseAlfrescoSpringTest /** * Called at the begining of all tests */ - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Create the node used for tests this.nodeRef = this.nodeService.createNode( @@ -79,6 +83,7 @@ public class SpecialiseTypeActionExecuterTest extends BaseAlfrescoSpringTest /** * Test execution */ + @Test public void testExecution() { // Check the type of the node diff --git a/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java b/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java index 7d9564048f..acf3dfe45e 100644 --- a/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/action/executer/TransitionSimpleWorkflowActionExecuterTest.java @@ -1,44 +1,45 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.action.executer; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.model.ApplicationModel; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.action.ActionImpl; -import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.namespace.QName; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.util.BaseAlfrescoSpringTest; -import org.alfresco.util.GUID; -import org.junit.experimental.categories.Category; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.model.ApplicationModel; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.action.ActionImpl; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; +import org.alfresco.test_category.BaseSpringTestsCategory; +import org.alfresco.util.BaseAlfrescoSpringTest; +import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.experimental.categories.Category; /** * Transition simple workflow action executer unit test @@ -72,10 +73,10 @@ public class TransitionSimpleWorkflowActionExecuterTest extends BaseAlfrescoSpri * Called at the begining of all tests */ @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); fileFolderService = (FileFolderService)this.applicationContext.getBean("fileFolderService"); diff --git a/src/test/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinitionTest.java b/src/test/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinitionTest.java index a75f4d0711..25361ca017 100644 --- a/src/test/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinitionTest.java +++ b/src/test/java/org/alfresco/repo/action/scheduled/CronScheduledQueryBasedTemplateActionDefinitionTest.java @@ -300,7 +300,7 @@ public class CronScheduledQueryBasedTemplateActionDefinitionTest extends TestCas @Override public void tearDown() throws Exception { - scheduler.getScheduler().unscheduleJob(scheduler.getTriggerName(), scheduler.getJobGroup()); + scheduler.getScheduler().unscheduleJob(scheduler.getTrigger().getKey()); if (Status.STATUS_ROLLEDBACK != transaction.getStatus()) { diff --git a/src/test/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceTest.java b/src/test/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceTest.java index 9d5928da73..406c66d80c 100644 --- a/src/test/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceTest.java +++ b/src/test/java/org/alfresco/repo/action/scheduled/ScheduledPersistedActionServiceTest.java @@ -52,15 +52,19 @@ import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.util.ApplicationContextHelper; import org.junit.experimental.categories.Category; -import org.quartz.DateIntervalTrigger; +import org.quartz.CalendarIntervalTrigger; +import org.quartz.DateBuilder; import org.quartz.Job; +import org.quartz.JobBuilder; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.quartz.Scheduler; +import org.quartz.SimpleScheduleBuilder; import org.quartz.SimpleTrigger; import org.quartz.Trigger; -import org.quartz.DateIntervalTrigger.IntervalUnit; +import org.quartz.TriggerBuilder; +import org.quartz.impl.matchers.GroupMatcher; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -295,9 +299,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase assertNotNull(t); assertEquals((double) System.currentTimeMillis(), (double) t.getStartTime().getTime(), 10); // Within 10ms assertEquals(null, t.getEndTime()); - assertEquals(DateIntervalTrigger.class, t.getClass()); - assertEquals(2, ((DateIntervalTrigger) t).getRepeatInterval()); - assertEquals(IntervalUnit.SECOND, ((DateIntervalTrigger) t).getRepeatIntervalUnit()); + assertEquals(Trigger.class, t.getClass()); + assertEquals(2, ((CalendarIntervalTrigger) t).getRepeatInterval()); + assertEquals(DateBuilder.IntervalUnit.SECOND, ((CalendarIntervalTrigger) t).getRepeatIntervalUnit()); // Start+interval schedule.setScheduleStart(new Date(12345)); @@ -309,9 +313,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase assertNotNull(t); assertEquals(12345, t.getStartTime().getTime()); assertEquals(null, t.getEndTime()); - assertEquals(DateIntervalTrigger.class, t.getClass()); - assertEquals(3, ((DateIntervalTrigger) t).getRepeatInterval()); - assertEquals(IntervalUnit.MONTH, ((DateIntervalTrigger) t).getRepeatIntervalUnit()); + assertEquals(CalendarIntervalTrigger.class, t.getClass()); + assertEquals(3, ((CalendarIntervalTrigger) t).getRepeatInterval()); + assertEquals(DateBuilder.IntervalUnit.MONTH, ((CalendarIntervalTrigger) t).getRepeatIntervalUnit()); // Start+interval+end-in-the-past schedule.setScheduleStart(new Date(12345)); @@ -333,9 +337,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase assertNotNull(t); assertEquals(12345, t.getStartTime().getTime()); assertEquals(future, t.getEndTime().getTime()); - assertEquals(DateIntervalTrigger.class, t.getClass()); - assertEquals(12, ((DateIntervalTrigger) t).getRepeatInterval()); - assertEquals(IntervalUnit.WEEK, ((DateIntervalTrigger) t).getRepeatIntervalUnit()); + assertEquals(CalendarIntervalTrigger.class, t.getClass()); + assertEquals(12, ((CalendarIntervalTrigger) t).getRepeatInterval()); + assertEquals(DateBuilder.IntervalUnit.WEEK, ((CalendarIntervalTrigger) t).getRepeatIntervalUnit()); // interval+end schedule.setScheduleStart(null); @@ -347,9 +351,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase assertNotNull(t); assertEquals((double) System.currentTimeMillis(), (double) t.getStartTime().getTime(), 2); // Within 2ms assertEquals(future, t.getEndTime().getTime()); - assertEquals(DateIntervalTrigger.class, t.getClass()); - assertEquals(6, ((DateIntervalTrigger) t).getRepeatInterval()); - assertEquals(IntervalUnit.HOUR, ((DateIntervalTrigger) t).getRepeatIntervalUnit()); + assertEquals(CalendarIntervalTrigger.class, t.getClass()); + assertEquals(6, ((CalendarIntervalTrigger) t).getRepeatInterval()); + assertEquals(DateBuilder.IntervalUnit.HOUR, ((CalendarIntervalTrigger) t).getRepeatIntervalUnit()); // Start+end-in-the-past // (Ignored as the end has passed) @@ -768,12 +772,16 @@ public class ScheduledPersistedActionServiceTest extends TestCase public void testStartup() throws Exception { // Startup with none there, nothing happens - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); assertEquals(0, service.listSchedules().size()); bootstrap.onBootstrap(null); - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); assertEquals(0, service.listSchedules().size()); // Manually add a scheduled action @@ -786,13 +794,17 @@ public class ScheduledPersistedActionServiceTest extends TestCase ((ScheduledPersistedActionServiceImpl) ctx.getBean("scheduledPersistedActionService")) .removeFromScheduler((ScheduledPersistedActionImpl) schedule); - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); assertEquals(1, service.listSchedules().size()); // Now do the bootstrap, and see it get registered bootstrap.onBootstrap(null); - assertEquals(1, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(1, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); assertEquals(1, service.listSchedules().size()); } @@ -884,10 +896,15 @@ public class ScheduledPersistedActionServiceTest extends TestCase // The job should run almost immediately Job job = new TestJob(); - JobDetail details = new JobDetail("ThisIsATest", null, job.getClass()); - Trigger now = new SimpleTrigger("TestTrigger", new Date(1)); - now.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW); - + JobDetail details = JobBuilder.newJob() + .withIdentity("ThisIsATest") + .ofType(job.getClass()) + .build(); + Trigger now = TriggerBuilder.newTrigger() + .withIdentity("TestTrigger") + .startAt(new Date(1)) + .withSchedule(SimpleScheduleBuilder.simpleSchedule().withMisfireHandlingInstructionFireNow()) + .build(); Scheduler scheduler = (Scheduler) ctx.getBean("schedulerFactory"); scheduler.scheduleJob(details, now); @@ -918,7 +935,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase // Until the schedule is persisted, nothing will happen @SuppressWarnings("unused") ScheduledPersistedAction schedule = service.createSchedule(testAction); - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -941,7 +960,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase }, false, true); // Check it went in - assertEquals(1, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(1, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); // Let it run Thread.sleep(2000); @@ -950,7 +971,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase assertEquals(1, sleepActionExec.getTimesExecuted()); // Should have removed itself now the schedule is over - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -964,7 +987,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase // Zap it service.deleteSchedule(schedule); - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); return null; } @@ -1019,7 +1044,9 @@ public class ScheduledPersistedActionServiceTest extends TestCase // Zap it service.deleteSchedule(schedule); - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); return null; } @@ -1060,9 +1087,13 @@ public class ScheduledPersistedActionServiceTest extends TestCase // Zap it - should still be live ScheduledPersistedAction schedule = service.getSchedule(testAction); - assertEquals(1, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(1, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); service.deleteSchedule(schedule); - assertEquals(0, scheduler.getJobNames(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP).length); + assertEquals(0, scheduler + .getJobKeys(GroupMatcher.groupEquals(ScheduledPersistedActionServiceImpl.SCHEDULER_GROUP)) + .size()); // Check it ran an appropriate number of times assertEquals("Didn't run enough - " + sleepActionExec.getTimesExecuted(), true, diff --git a/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierJobTest.java b/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierJobTest.java index ac878a1f9d..d1fb40d72f 100644 --- a/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierJobTest.java +++ b/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierJobTest.java @@ -56,6 +56,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.quartz.JobBuilder; import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; @@ -157,13 +158,16 @@ public class FeedNotifierJobTest userNotifier.setExcludedEmailSuffixes(emailUserNotifier.getExcludedEmailSuffixes()); userNotifier.setEmailHelper(emailHelper); feedNotifier.setUserNotifier(userNotifier); - - jobDetail = new JobDetail("feedNotifier", FeedNotifierJob.class); - JobDataMap jobDataMap = jobDetail.getJobDataMap(); + + JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put("tenantAdminService", tenantAdminService); jobDataMap.put("feedNotifier", feedNotifier); + jobDetail = JobBuilder.newJob() + .withIdentity("feedNotifier") + .ofType(FeedNotifierJob.class) + .setJobData(jobDataMap) + .build(); feedNotifierJob = new FeedNotifierJob(); - when(jobCtx.getJobDetail()).thenReturn(jobDetail); } diff --git a/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java b/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java index 0d2efa941e..33c79e3a08 100644 --- a/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java +++ b/src/test/java/org/alfresco/repo/activities/feed/FeedNotifierTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.activities.feed; import static junit.framework.Assert.fail; @@ -58,10 +58,10 @@ import org.json.JSONObject; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.quartz.JobDetail; import org.quartz.Scheduler; import org.springframework.beans.factory.ObjectFactory; import org.springframework.context.ApplicationContext; -import org.springframework.scheduling.quartz.JobDetailBean; import java.util.Collections; import java.util.List; @@ -121,18 +121,18 @@ public class FeedNotifierTest Scheduler scheduler = (Scheduler) ctx.getBean("schedulerFactory"); - JobDetailBean feedGeneratorJobDetail = (JobDetailBean) activitiesFeedCtx.getBean("feedGeneratorJobDetail"); - JobDetailBean postLookupJobDetail = (JobDetailBean) activitiesFeedCtx.getBean("postLookupJobDetail"); - JobDetailBean feedCleanerJobDetail = (JobDetailBean) activitiesFeedCtx.getBean("feedCleanerJobDetail"); - JobDetailBean postCleanerJobDetail = (JobDetailBean) activitiesFeedCtx.getBean("postCleanerJobDetail"); - JobDetailBean feedNotifierJobDetail = (JobDetailBean) activitiesFeedCtx.getBean("feedNotifierJobDetail"); + JobDetail feedGeneratorJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedGeneratorJobDetail"); + JobDetail postLookupJobDetail = (JobDetail) activitiesFeedCtx.getBean("postLookupJobDetail"); + JobDetail feedCleanerJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedCleanerJobDetail"); + JobDetail postCleanerJobDetail = (JobDetail) activitiesFeedCtx.getBean("postCleanerJobDetail"); + JobDetail feedNotifierJobDetail = (JobDetail) activitiesFeedCtx.getBean("feedNotifierJobDetail"); // Pause activities jobs so that we aren't competing with their scheduled versions - scheduler.pauseJob(feedGeneratorJobDetail.getName(), feedGeneratorJobDetail.getGroup()); - scheduler.pauseJob(postLookupJobDetail.getName(), postLookupJobDetail.getGroup()); - scheduler.pauseJob(feedCleanerJobDetail.getName(), feedCleanerJobDetail.getGroup()); - scheduler.pauseJob(postCleanerJobDetail.getName(), postCleanerJobDetail.getGroup()); - scheduler.pauseJob(feedNotifierJobDetail.getName(), feedNotifierJobDetail.getGroup()); + scheduler.pauseJob(feedGeneratorJobDetail.getKey()); + scheduler.pauseJob(postLookupJobDetail.getKey()); + scheduler.pauseJob(feedCleanerJobDetail.getKey()); + scheduler.pauseJob(postCleanerJobDetail.getKey()); + scheduler.pauseJob(feedNotifierJobDetail.getKey()); this.personService = (PersonService) ctx.getBean("personService"); this.nodeService = (NodeService) ctx.getBean("nodeService"); diff --git a/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobIntegrationTest.java b/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobIntegrationTest.java index fd6616caf6..08786c2020 100644 --- a/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobIntegrationTest.java +++ b/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobIntegrationTest.java @@ -1,37 +1,35 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.attributes; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.alfresco.util.ApplicationContextHelper; -import org.alfresco.util.CronTriggerBean; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.quartz.JobDetail; import org.springframework.context.ApplicationContext; @@ -44,19 +42,18 @@ import org.springframework.context.ApplicationContext; public class PropTablesCleanupJobIntegrationTest { private ApplicationContext ctx; - private CronTriggerBean jobTrigger; + private JobDetail jobDetail; @Before public void setUp() throws Exception - { + { ctx = ApplicationContextHelper.getApplicationContext(); - jobTrigger = ctx.getBean("propTablesCleanupTrigger", CronTriggerBean.class); + jobDetail = ctx.getBean("propTablesCleanupJobDetail", JobDetail.class); } @Test public void checkJobDetails() { - JobDetail jobDetail = jobTrigger.getJobDetail(); assertEquals(PropTablesCleanupJob.class, jobDetail.getJobClass()); assertTrue("JobDetail did not contain PropTablesCleaner reference", jobDetail.getJobDataMap().get("propTablesCleaner") instanceof PropTablesCleaner); diff --git a/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobTest.java b/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobTest.java index 8d58e3ccb0..b84c8f484a 100644 --- a/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobTest.java +++ b/src/test/java/org/alfresco/repo/attributes/PropTablesCleanupJobTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.attributes; import static org.mockito.Mockito.verify; @@ -34,6 +34,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.quartz.JobBuilder; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @@ -55,10 +56,11 @@ public class PropTablesCleanupJobTest @Before public void setUp() throws Exception { - jobDetail = new JobDetail("propTablesCleanupJob", PropTablesCleanupJob.class); + jobDetail = JobBuilder.newJob() + .withIdentity("propTablesCleanupJob") + .ofType(PropTablesCleanupJob.class).build(); jobDetail.getJobDataMap().put("propTablesCleaner", propTablesCleaner); cleanupJob = new PropTablesCleanupJob(); - when(jobCtx.getJobDetail()).thenReturn(jobDetail); } diff --git a/src/test/java/org/alfresco/repo/blog/BlogIntegrationServiceSystemTest.java b/src/test/java/org/alfresco/repo/blog/BlogIntegrationServiceSystemTest.java index 4c6881f30a..df8c36782c 100644 --- a/src/test/java/org/alfresco/repo/blog/BlogIntegrationServiceSystemTest.java +++ b/src/test/java/org/alfresco/repo/blog/BlogIntegrationServiceSystemTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.blog; import java.io.Serializable; @@ -46,12 +46,15 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; +import org.junit.Before; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class BlogIntegrationServiceSystemTest extends BaseAlfrescoSpringTest implements BlogIntegrationModel { /** @@ -100,11 +103,10 @@ public class BlogIntegrationServiceSystemTest extends BaseAlfrescoSpringTest imp private NodeRef nodeRef; private NodeRef blogDetailsNodeRef; - @Override - protected void onSetUpInTransaction() - throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get references to the relevant services this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); diff --git a/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java b/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java index e7958c356f..a3eedf5221 100644 --- a/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/coci/CheckOutCheckInServiceImplTest.java @@ -74,15 +74,26 @@ import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; import org.alfresco.util.PropertyMap; import org.alfresco.util.TestWithUserUtils; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Version operations service implementation unit tests * * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class CheckOutCheckInServiceImplTest extends BaseSpringTest { /** @@ -131,9 +142,8 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * On setup in transaction implementation */ - @Override - protected void onSetUpInTransaction() - throws Exception + @Before + public void before() { // Set the services this.cociService = (CheckOutCheckInService)this.applicationContext.getBean("checkOutCheckInService"); @@ -239,6 +249,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * Test checkout */ + @Test public void testCheckOut() { checkout(); @@ -296,6 +307,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * Test checkIn */ + @Test public void testCheckIn() { NodeRef workingCopy = checkout(); @@ -357,6 +369,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest this.cociService.checkin(workingCopy2, new HashMap(), null, true); } + @Test public void testCheckInVersionedNode_MNT_8789() { String versionDescription = "This is a test version"; @@ -425,6 +438,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * MNT-9202 */ + @Test public void testDeleteSourceOfLockedCopy() { // Create a FolderA @@ -496,6 +510,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest assertEquals("cm:modified should not change on the copied node when deleting the original", wcModBefore, wcModAfter); } + @Test public void testCheckOutCheckInWithDifferentLocales() { // Check-out nodeRef using the locale fr_FR @@ -521,6 +536,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest assertEquals("Working copy label was not removed.", "myDocument.doc", name); } + @Test public void testCheckOutCheckInWithAlteredWorkingCopyName() { // Check-out nodeRef using the locale fr_FR @@ -549,6 +565,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest assertEquals("File not renamed correctly.", "newName.doc", name); } + @Test public void testCheckInWithNameChange() { // Check out the file @@ -564,6 +581,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest cociService.checkin(fileWorkingCopyNodeRef, null); } + @Test public void testCheckOutCheckInWithTranslatableAspect() { // Create a node to be used as the translation @@ -593,6 +611,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * Test when the aspect is not set when check-in is performed */ + @Test public void testVersionAspectNotSetOnCheckIn() { // Create a bag of props @@ -619,6 +638,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * Test cancel checkOut */ + @Test public void testCancelCheckOut() { NodeRef workingCopy = checkout(); @@ -644,6 +664,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * Test the deleting a wokring copy node removed the lock on the original node */ + @Test public void testAutoCancelCheckOut() { Date modifiedDateBeforeCheckOut = (Date) this.nodeService.getProperty(this.nodeRef, ContentModel.PROP_MODIFIED); @@ -678,6 +699,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest * @see CheckOutCheckInService#getWorkingCopy(NodeRef) * @see CheckOutCheckInService#getCheckedOut(NodeRef) */ + @Test public void testBidirectionalReferences() { final NodeRef origNodeRef = nodeService.createNode( @@ -699,9 +721,9 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest assertEquals("Expect a 1:1 relationship", 1, sourceAssocs.size()); // Need to commit the transaction in order to get the indexer to run - setComplete(); - endTransaction(); - + TestTransaction.flagForCommit(); + TestTransaction.end(); + final NodeRef finalNodeRef = origNodeRef; NodeRef wk3 = this.transactionService.getRetryingTransactionHelper().doInTransaction( @@ -725,6 +747,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * Test the getWorkingCopy method */ + @Test public void testETWOTWO_733() { NodeRef origNodeRef = nodeService.createNode( @@ -748,8 +771,8 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest final NodeRef workingCopy = cociService.checkout(origNodeRef); // Need to commit the transaction in order to get the indexer to run - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); final NodeRef finalNodeRef = origNodeRef; @@ -769,6 +792,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest assertNull(wk3); } + @Test public void testAR1056() { // Check out the node @@ -795,6 +819,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest } } + @Test public void testMultipleCheckoutsCheckInsWithPropChange() { // Note: this test assumes cm:autoVersionProps=true by default (refer to cm:versionableAspect in contentModel.xml) @@ -810,9 +835,9 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest // Add the version aspect to the created node nodeService.addAspect(testNodeRef, ContentModel.ASPECT_VERSIONABLE, null); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); // Checkout final NodeRef workingCopy1 = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() @@ -887,6 +912,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest }); } + @Test public void testAlfrescoCheckoutDoesNotModifyNode() { String adminUser = AuthenticationUtil.getAdminUserName(); @@ -927,6 +953,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest assertEquals("The modifier should NOT change to Admin after checkin!", initModifier, modifier); } + @Test public void testCheckOutPermissions_ALF7680_ALF535() { /* @@ -1027,6 +1054,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest } } + @Test public void testCheckInLockableAspectDoesntCopies_ALF16194() { // Check-out nodeRef @@ -1048,6 +1076,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest } } + @Test public void testCanCheckInWhenOriginalHasUndeletableAspect() { nodeService.addAspect(nodeRef, ContentModel.ASPECT_UNDELETABLE, null); @@ -1121,6 +1150,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest * Creating a document and working copy. Then try to move working copy to another place. Test is passed, if a working copy was moved to another place with original * document. Only the lock owner can move documents. */ + @Test public void testMoveOriginalWithWorkingCopy() { // Create a FolderA @@ -1236,6 +1266,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * MNT-2641 (however, see also REPO-1108) */ + @Test public void testDeleteUpdateOriginalOfCheckedOutDocument() { // Create a FolderA @@ -1334,6 +1365,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest * MNT-2641 * The working copy delete is equivalent to "cancelCheckout". This should fail for everyone except the lock owner. */ + @Test public void testDeleteOfWorkingCopy() { // Create a FolderA @@ -1357,6 +1389,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * MNT-2641: The {@link ContentModel#ASPECT_WORKING_COPY} aspect cannot be removed from a working copy */ + @Test public void testDeleteWorkingCopyAspect() { // Create a FolderA @@ -1373,9 +1406,9 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest nodeService.hasAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY)); assertTrue("cm:copiedFrom aspect not found on working copy.", nodeService.hasAspect(workingCopy, ContentModel.ASPECT_COPIEDFROM)); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); // try to delete cm:copiedfrom aspect from working copy - must be allowed nodeService.removeAspect(workingCopy, ContentModel.ASPECT_COPIEDFROM); @@ -1394,6 +1427,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest /** * MNT-2641 The cm:workingcopylink association cannot be removed */ + @Test public void testDeleteWorkingCopyLinkAssociation() { // Create a FolderA @@ -1409,9 +1443,9 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest // Check that the cm:original association is present assertEquals("Did not find cm:workingcopylink", 1, nodeService.getSourceAssocs(workingCopy, ContentModel.ASSOC_WORKING_COPY_LINK).size()); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); // try to delete cm:workingcopylink association - must be denied try @@ -1472,6 +1506,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest *
* Creating node - CheckOut - Add write lock to working copy - Unlock working copy - CancelCheckOut */ + @Test public void testCancelCheckoutUnlockedWCopy() { ServiceRegistry serviceRegistry = (ServiceRegistry)this.applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); @@ -1488,6 +1523,7 @@ public class CheckOutCheckInServiceImplTest extends BaseSpringTest } // REPO-1108 / ALF-21645 (see also MNT-15855) + @Test public void testDeleteAndRestore() { authenticationComponent.setSystemUserAsCurrentUser(); diff --git a/src/test/java/org/alfresco/repo/configuration/ConfigurableServiceImplTest.java b/src/test/java/org/alfresco/repo/configuration/ConfigurableServiceImplTest.java index 1ddef54157..59c5d3860c 100644 --- a/src/test/java/org/alfresco/repo/configuration/ConfigurableServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/configuration/ConfigurableServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.configuration; import java.util.List; @@ -37,7 +37,10 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Configurable service implementation test @@ -46,6 +49,7 @@ import org.junit.experimental.categories.Category; */ @SuppressWarnings("unused") @Category(BaseSpringTestsCategory.class) +@Transactional public class ConfigurableServiceImplTest extends BaseSpringTest { public NodeService nodeService; @@ -54,12 +58,9 @@ public class ConfigurableServiceImplTest extends BaseSpringTest private StoreRef testStoreRef; private NodeRef rootNodeRef; private NodeRef nodeRef; - - /** - * onSetUpInTransaction - */ - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); this.serviceRegistry = (ServiceRegistry)this.applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); @@ -79,6 +80,7 @@ public class ConfigurableServiceImplTest extends BaseSpringTest /** * Test isConfigurable */ + @Test public void testIsConfigurable() { assertFalse(this.configurableService.isConfigurable(this.nodeRef)); @@ -89,6 +91,7 @@ public class ConfigurableServiceImplTest extends BaseSpringTest /** * Test make configurable */ + @Test public void testMakeConfigurable() { this.configurableService.makeConfigurable(this.nodeRef); @@ -104,6 +107,7 @@ public class ConfigurableServiceImplTest extends BaseSpringTest /** * Test getConfigurationFolder */ + @Test public void testGetConfigurationFolder() { assertNull(this.configurableService.getConfigurationFolder(this.nodeRef)); diff --git a/src/test/java/org/alfresco/repo/descriptor/DescriptorServiceTest.java b/src/test/java/org/alfresco/repo/descriptor/DescriptorServiceTest.java index 04cdc2a4df..3114d9b63b 100644 --- a/src/test/java/org/alfresco/repo/descriptor/DescriptorServiceTest.java +++ b/src/test/java/org/alfresco/repo/descriptor/DescriptorServiceTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.descriptor; import org.alfresco.repo.importer.ImporterBootstrap; @@ -36,19 +36,23 @@ import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; @Category(BaseSpringTestsCategory.class) +@Transactional public class DescriptorServiceTest extends BaseSpringTest { private NodeService nodeService; private ImporterBootstrap systemBootstrap; private StoreRef storeRef; private AuthenticationComponent authenticationComponent; - - - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()); systemBootstrap = (ImporterBootstrap)applicationContext.getBean("systemBootstrap"); @@ -62,17 +66,17 @@ public class DescriptorServiceTest extends BaseSpringTest this.authenticationComponent.setSystemUserAsCurrentUser(); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() { authenticationComponent.clearCurrentSecurityContext(); - super.onTearDownInTransaction(); } /** * Test server decriptor */ + @Test public void testServerDescriptor() { ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); @@ -102,6 +106,7 @@ public class DescriptorServiceTest extends BaseSpringTest /** * Test current repository descriptor */ + @Test public void testCurrentRepositoryDescriptor() { ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); @@ -129,6 +134,7 @@ public class DescriptorServiceTest extends BaseSpringTest assertTrue("Repository schema version must be greater than -1", schemaVersion > -1); } + @Test public void testCompareDescriptors() { ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); @@ -164,6 +170,7 @@ public class DescriptorServiceTest extends BaseSpringTest /** * Test installed repository descriptor */ + @Test public void testInstalledRepositoryDescriptor() { ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); @@ -224,11 +231,9 @@ public class DescriptorServiceTest extends BaseSpringTest return builder.toString(); } + @Test public void testReadOnlyLicenseLoad_ALF10110() throws Exception { - setComplete(); - endTransaction(); - QName vetoName = QName.createQName("{test}veto"); TransactionServiceImpl txnService = (TransactionServiceImpl) applicationContext.getBean("TransactionService"); ServiceRegistry registry = (ServiceRegistry)applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); diff --git a/src/test/java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java b/src/test/java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java index 9ad0dc1309..89ea8ac0f5 100644 --- a/src/test/java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java +++ b/src/test/java/org/alfresco/repo/dictionary/DictionaryModelTypeTest.java @@ -46,6 +46,7 @@ import org.alfresco.repo.i18n.MessageService; import org.alfresco.repo.policy.PolicyComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.tenant.TenantAdminService; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.coci.CheckOutCheckInService; @@ -67,7 +68,14 @@ import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.PropertyMap; import org.alfresco.util.testing.category.LuceneTests; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.ExpectedException; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ResourceUtils; /** @@ -76,6 +84,7 @@ import org.springframework.util.ResourceUtils; * @author Roy Wetherall, janv */ @Category({BaseSpringTestsCategory.class, LuceneTests.class}) +@Transactional public class DictionaryModelTypeTest extends BaseSpringTest { /** QNames of the test models */ @@ -374,11 +383,10 @@ public class DictionaryModelTypeTest extends BaseSpringTest private TransactionService transactionService; private AuthenticationComponent authenticationComponent; - private UserTransaction txn; - - @Override - protected void onSetUp() throws Exception + @Before + public void before() throws Exception { + TestTransaction.flagForCommit(); this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); this.contentService = (ContentService) this.applicationContext.getBean("contentService"); this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService"); @@ -390,11 +398,6 @@ public class DictionaryModelTypeTest extends BaseSpringTest .getBean("authenticationComponent"); authenticationComponent.setSystemUserAsCurrentUser(); - txn = transactionService.getUserTransaction(); - - // Create the store in a separate transaction to run successfully on MS SQL Server - txn.begin(); - // Create the store and get the root node this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = this.nodeService.getRootNode(this.storeRef); @@ -410,10 +413,10 @@ public class DictionaryModelTypeTest extends BaseSpringTest TenantAdminService tenantAdminService = (TenantAdminService)this.applicationContext.getBean("tenantAdminService"); MessageService messageService = (MessageService)this.applicationContext.getBean("messageService"); - txn.commit(); + TestTransaction.end(); + TestTransaction.start(); + TestTransaction.flagForCommit(); - txn = transactionService.getUserTransaction(); - txn.begin(); DictionaryRepositoryBootstrap bootstrap = new DictionaryRepositoryBootstrap(); bootstrap.setContentService(this.contentService); bootstrap.setDictionaryDAO(this.dictionaryDAO); @@ -438,11 +441,12 @@ public class DictionaryModelTypeTest extends BaseSpringTest // register with dictionary service bootstrap.register(); - txn.commit(); + TestTransaction.end(); + TestTransaction.start(); } - @Override - protected void onTearDown() throws Exception + @After + public void after() throws Exception { authenticationService.clearCurrentSecurityContext(); } @@ -450,6 +454,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest /** * Test the creation of dictionary model nodes */ + @Test public void testCreateAndUpdateDictionaryModelNodeContent() throws Exception { try @@ -462,34 +467,31 @@ public class DictionaryModelTypeTest extends BaseSpringTest { // We expect this exception } - + // Check that the namespace is not yet in the namespace service String uri = this.namespaceService.getNamespaceURI("test1"); assertNull(uri); // Create a model node - PropertyMap properties = new PropertyMap(1); - properties.put(ContentModel.PROP_MODEL_ACTIVE, true); + final NodeRef modelNode = transactionService.getRetryingTransactionHelper().doInTransaction(() -> + { + PropertyMap properties = new PropertyMap(1); + properties.put(ContentModel.PROP_MODEL_ACTIVE, true); + NodeRef model = this.nodeService.createNode( + this.rootNodeRef, + ContentModel.ASSOC_CHILDREN, + QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"), + ContentModel.TYPE_DICTIONARY_MODEL, + properties).getChildRef(); + assertNotNull(model); - txn = transactionService.getUserTransaction(); - txn.begin(); - - final NodeRef modelNode = this.nodeService.createNode( - this.rootNodeRef, - ContentModel.ASSOC_CHILDREN, - QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"), - ContentModel.TYPE_DICTIONARY_MODEL, - properties).getChildRef(); - assertNotNull(modelNode); - - // Add the model content to the model node - ContentWriter contentWriter = this.contentService.getWriter(modelNode, ContentModel.PROP_CONTENT, true); - contentWriter.setEncoding("UTF-8"); - contentWriter.setMimetype(MimetypeMap.MIMETYPE_XML); - contentWriter.putContent(MODEL_ONE_XML); - - // End the transaction to force update - txn.commit(); + // Add the model content to the model node + ContentWriter contentWriter = this.contentService.getWriter(model, ContentModel.PROP_CONTENT, true); + contentWriter.setEncoding("UTF-8"); + contentWriter.setMimetype(MimetypeMap.MIMETYPE_XML); + contentWriter.putContent(MODEL_ONE_XML); + return model; + }, false, true); final NodeRef workingCopy = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -523,7 +525,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest return workingCopy; } - }); + }, false, true); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -536,7 +538,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest DictionaryModelTypeTest.this.cociService.checkin(workingCopy, null); return null; } - }); + }, false, true); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -546,7 +548,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest assertEquals("1.1", DictionaryModelTypeTest.this.nodeService.getProperty(modelNode, ContentModel.PROP_MODEL_VERSION)); return null; } - }); + }, false, true); // create node using new type final NodeRef node1 = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() @@ -562,7 +564,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest assertNotNull(node); return node; } - }); + }, false, true); try { @@ -573,7 +575,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest DictionaryModelTypeTest.this.nodeService.deleteNode(modelNode); return null; } - }); + }, false, true); fail("Unexpected - should not be able to delete model"); } @@ -590,7 +592,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest nodeService.deleteNode(node1); return null; } - }); + }, false, true); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -599,9 +601,10 @@ public class DictionaryModelTypeTest extends BaseSpringTest DictionaryModelTypeTest.this.nodeService.deleteNode(modelNode); return null; } - }); + }, false, true); } + @Test public void testUpdateDictionaryModelPropertyDelete() throws Exception { try @@ -619,9 +622,6 @@ public class DictionaryModelTypeTest extends BaseSpringTest String uri = this.namespaceService.getNamespaceURI("test1"); assertNull(uri); - txn = transactionService.getUserTransaction(); - txn.begin(); - // Create a model node PropertyMap properties = new PropertyMap(1); properties.put(ContentModel.PROP_MODEL_ACTIVE, true); @@ -640,7 +640,8 @@ public class DictionaryModelTypeTest extends BaseSpringTest contentWriter.putContent(MODEL_ONE_MODIFIED_XML); // End the transaction to force update - txn.commit(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // create node using new type final NodeRef node1 = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() @@ -664,7 +665,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest assertNotNull(node); return node; } - }); + }, false, true); final NodeRef workingCopy = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -677,7 +678,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest return workingCopy; } - }); + }, false, true); try { @@ -709,7 +710,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest nodeService.deleteNode(node1); return null; } - }); + }, false, true); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -722,7 +723,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest DictionaryModelTypeTest.this.cociService.checkin(workingCopy, null); return null; } - }); + }, false, true); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -732,7 +733,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest assertEquals("1.2", DictionaryModelTypeTest.this.nodeService.getProperty(modelNode, ContentModel.PROP_MODEL_VERSION)); return null; } - }); + }, false, true); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -741,9 +742,10 @@ public class DictionaryModelTypeTest extends BaseSpringTest DictionaryModelTypeTest.this.nodeService.deleteNode(modelNode); return null; } - }); + }, false, true); } + @Test public void testUpdateDictionaryModelConstraintDelete() throws Exception { try @@ -761,9 +763,6 @@ public class DictionaryModelTypeTest extends BaseSpringTest String uri = this.namespaceService.getNamespaceURI("test2"); assertNull(uri); - txn = transactionService.getUserTransaction(); - txn.begin(); - // Create a model node PropertyMap properties = new PropertyMap(1); properties.put(ContentModel.PROP_MODEL_ACTIVE, true); @@ -782,7 +781,8 @@ public class DictionaryModelTypeTest extends BaseSpringTest contentWriter.putContent(MODEL_TWO_XML); // End the transaction to force update - txn.commit(); + TestTransaction.flagForCommit(); + TestTransaction.end(); final NodeRef workingCopy = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -868,6 +868,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest }); } + @Test public void testIsActiveFlagAndDelete() throws Exception { try @@ -881,8 +882,6 @@ public class DictionaryModelTypeTest extends BaseSpringTest // We expect this exception } - txn = transactionService.getUserTransaction(); - txn.begin(); // Create a model node PropertyMap properties = new PropertyMap(1); final NodeRef modelNode = this.nodeService.createNode( @@ -900,7 +899,8 @@ public class DictionaryModelTypeTest extends BaseSpringTest contentWriter.putContent(MODEL_ONE_XML); // End the transaction to force update - txn.commit(); + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1000,6 +1000,7 @@ public class DictionaryModelTypeTest extends BaseSpringTest * Test for MNT-11653 */ @SuppressWarnings("deprecation") + @Test public void testOverrideMandatoryProperty() throws Exception { try @@ -1021,9 +1022,6 @@ public class DictionaryModelTypeTest extends BaseSpringTest PropertyMap properties = new PropertyMap(1); properties.put(ContentModel.PROP_MODEL_ACTIVE, true); - txn = transactionService.getUserTransaction(); - txn.begin(); - final NodeRef modelNode = this.nodeService.createNode( this.rootNodeRef, ContentModel.ASSOC_CHILDREN, @@ -1040,7 +1038,8 @@ public class DictionaryModelTypeTest extends BaseSpringTest // End the transaction to force update - txn.commit(); + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1098,17 +1097,17 @@ public class DictionaryModelTypeTest extends BaseSpringTest } /* MNT-15345 test */ + @Test public void testImportingSameNamespaceFails() throws Exception { // Create model - txn = transactionService.getUserTransaction(); - txn.begin(); + final NodeRef modelNode = createActiveModel("dictionary/testModel.xml"); - txn.commit(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // add second model to introduce self referencing dependency - txn = transactionService.getUserTransaction(); - txn.begin(); + TestTransaction.start(); PropertyMap properties = new PropertyMap(1); properties.put(ContentModel.PROP_MODEL_ACTIVE, true); final NodeRef modelNode2 = this.nodeService.createNode( @@ -1116,8 +1115,9 @@ public class DictionaryModelTypeTest extends BaseSpringTest ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"), ContentModel.TYPE_DICTIONARY_MODEL, - properties).getChildRef(); - txn.commit(); + properties).getChildRef(); + TestTransaction.flagForCommit(); + TestTransaction.end(); try { @@ -1149,11 +1149,10 @@ public class DictionaryModelTypeTest extends BaseSpringTest } /* MNT-15345 test */ + @Test(expected=AlfrescoRuntimeException.class) public void testImportingSameNamespaceFailsWithinSingleModel() throws Exception { // Create model - txn = transactionService.getUserTransaction(); - txn.begin(); PropertyMap properties = new PropertyMap(1); properties.put(ContentModel.PROP_MODEL_ACTIVE, true); final NodeRef modelNode = this.nodeService.createNode( @@ -1162,13 +1161,16 @@ public class DictionaryModelTypeTest extends BaseSpringTest QName.createQName(NamespaceService.ALFRESCO_URI, "dictionaryModels"), ContentModel.TYPE_DICTIONARY_MODEL, properties).getChildRef(); - assertNotNull(modelNode); - txn.commit(); + assertNotNull(modelNode); + TestTransaction.flagForCommit(); + TestTransaction.end(); // update model to introduce self referencing dependency try { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { + RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper(); + txnHelper.setMaxRetries(1); + txnHelper.doInTransaction(new RetryingTransactionCallback() { public Void execute() throws Exception { ContentWriter contentWriter = contentService.getWriter(modelNode, ContentModel.PROP_CONTENT, true); @@ -1177,11 +1179,12 @@ public class DictionaryModelTypeTest extends BaseSpringTest contentWriter.putContent(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary/modelWithCurrentNamespaceImported.xml")); return null; } - }); + }, false, true); fail("Validation should fail as a circular dependency was introduced"); } catch(AlfrescoRuntimeException e) { assertTrue(e.getCause().getMessage().contains("URI http://www.alfresco.org/model/dictionary/1.0 cannot be imported as it is already contained in the model's namespaces")); + throw e; } //delete model @@ -1194,28 +1197,30 @@ public class DictionaryModelTypeTest extends BaseSpringTest DictionaryModelTypeTest.this.nodeService.deleteNode(modelNode); return null; } - }); + }, false, true); } } + @Test public void testCircularDependencyDetected() throws Exception { // Create modelA - txn = transactionService.getUserTransaction(); - txn.begin(); final NodeRef modelANode = createActiveModel("dictionary/modelA.xml"); - txn.commit(); + TestTransaction.flagForCommit(); + TestTransaction.end(); //Create modelB - txn = transactionService.getUserTransaction(); - txn.begin(); + TestTransaction.start(); final NodeRef modelBNode = createActiveModel("dictionary/modelB.xml"); - txn.commit(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // update model A to introduce circular dependency try { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { + RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper(); + txnHelper.setMaxRetries(3); + txnHelper.doInTransaction(new RetryingTransactionCallback() { public Void execute() throws Exception { ContentWriter contentWriter = DictionaryModelTypeTest.this.contentService.getWriter(modelANode, ContentModel.PROP_CONTENT, true); contentWriter.putContent(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary/modelAupdated.xml")); @@ -1231,7 +1236,9 @@ public class DictionaryModelTypeTest extends BaseSpringTest // update model A to introduce circular dependency - also add a second namespace try { - transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { + RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper(); + txnHelper.setMaxRetries(3); + txnHelper.doInTransaction(new RetryingTransactionCallback() { public Void execute() throws Exception { ContentWriter contentWriter = DictionaryModelTypeTest.this.contentService.getWriter(modelANode, ContentModel.PROP_CONTENT, true); contentWriter.putContent(Thread.currentThread().getContextClassLoader().getResourceAsStream("dictionary/modelAupdatedWithSecondNamespace.xml")); diff --git a/src/test/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java b/src/test/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java index ac1e6d2641..1fa78443b2 100644 --- a/src/test/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java +++ b/src/test/java/org/alfresco/repo/dictionary/DictionaryRepositoryBootstrapTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.dictionary; import java.text.MessageFormat; @@ -49,11 +49,16 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import javax.transaction.UserTransaction; +import org.springframework.transaction.annotation.Transactional; @Category(BaseSpringTestsCategory.class) +@Transactional public class DictionaryRepositoryBootstrapTest extends BaseSpringTest { public static final String TEMPLATE_MODEL_XML = @@ -120,8 +125,8 @@ public class DictionaryRepositoryBootstrapTest extends BaseSpringTest private StoreRef storeRef; private NodeRef rootNodeRef; - @Override - protected void onSetUp() throws Exception + @Before + public void before() throws Exception { // Get the behaviour filter this.behaviourFilter = (BehaviourFilter)this.applicationContext.getBean("policyBehaviourFilter"); @@ -179,8 +184,8 @@ public class DictionaryRepositoryBootstrapTest extends BaseSpringTest txn.commit(); } - @Override - protected void onTearDown() throws Exception + @After + public void after() throws Exception { authenticationService.clearCurrentSecurityContext(); } @@ -188,6 +193,7 @@ public class DictionaryRepositoryBootstrapTest extends BaseSpringTest /** * Test bootstrap */ + @Test public void testBootstrap() throws Exception { txn = transactionService.getUserTransaction(); diff --git a/src/test/java/org/alfresco/repo/domain/DialectFactoryBeanTest.java b/src/test/java/org/alfresco/repo/domain/DialectFactoryBeanTest.java new file mode 100644 index 0000000000..c88dd4c73c --- /dev/null +++ b/src/test/java/org/alfresco/repo/domain/DialectFactoryBeanTest.java @@ -0,0 +1,73 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.domain; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import org.alfresco.repo.domain.dialect.DialectFactoryBean; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + + +/** + * @author Erik Knizat + */ +public class DialectFactoryBeanTest +{ + private static final String MARIADB_DIALECT_NAME = "org.alfresco.repo.domain.dialect.MariaDBDialect"; + private static final String MARIA_DB_DRIVER_NAME = "MariaDB connector/J"; + + @Test + public void testMariaDBDialectGetsAdded() + { +// DialectFactoryBean dfb = new DialectFactoryBean(); +// Map driverDialectMap = new HashMap<>(); +// driverDialectMap.put(MARIA_DB_DRIVER_NAME, MARIADB_DIALECT_NAME); +// dfb.setDriverDialectMap(driverDialectMap); +// Properties props = new Properties(); +// dfb.overrideDialectPropertyForDriver(props, MARIA_DB_DRIVER_NAME); +// +// assertNotNull("The dialect property was not set for the driver.", props.getProperty((Environment.DIALECT))); +// assertEquals("Dialect name did not match.", MARIADB_DIALECT_NAME, props.getProperty((Environment.DIALECT))); + } + + @Test + public void testDialectNotAddedIfNotSpecifiedForDriver() + { +// DialectFactoryBean dfb = new DialectFactoryBean(); +// Map driverDialectMap = new HashMap<>(); +// dfb.setDriverDialectMap(driverDialectMap); // Add empty dialect driver map +// Properties props = new Properties(); +// dfb.overrideDialectPropertyForDriver(props, MARIA_DB_DRIVER_NAME); +// +// assertNull("Dialect name property was set for unspecified driver name.", props.getProperty((Environment.DIALECT))); + } + +} diff --git a/src/test/java/org/alfresco/repo/domain/audit/AuditDAOTest.java b/src/test/java/org/alfresco/repo/domain/audit/AuditDAOTest.java index 22ade9935a..ae1d8a0ac3 100644 --- a/src/test/java/org/alfresco/repo/domain/audit/AuditDAOTest.java +++ b/src/test/java/org/alfresco/repo/domain/audit/AuditDAOTest.java @@ -43,7 +43,8 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.content.transform.AbstractContentTransformerTest; import org.alfresco.repo.domain.audit.AuditDAO.AuditApplicationInfo; import org.alfresco.repo.domain.contentdata.ContentDataDAO; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoMySQLClusterNDBDialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLClusterNDBDialect; import org.alfresco.repo.domain.propval.PropValGenerator; import org.alfresco.repo.domain.propval.PropertyValueDAO; import org.alfresco.repo.transaction.RetryingTransactionHelper; @@ -59,7 +60,6 @@ import org.alfresco.util.GUID; import org.alfresco.util.Pair; import org.alfresco.util.testing.category.DBTests; import org.apache.commons.lang.mutable.MutableInt; -import org.hibernate.dialect.Dialect; import org.junit.experimental.categories.Category; import org.springframework.context.ConfigurableApplicationContext; @@ -717,7 +717,7 @@ public class AuditDAOTest extends TestCase public void testScriptCanDeleteOrphanedProps() throws Exception { Dialect dialect = (Dialect) ctx.getBean("dialect"); - if (dialect instanceof AlfrescoMySQLClusterNDBDialect) + if (dialect instanceof MySQLClusterNDBDialect) { throw new Exception("TODO review this test case with NDB - note: throw exeception here else causes later tests to fail (when running via AllDBTestTestSuite)"); } diff --git a/src/test/java/org/alfresco/repo/domain/hibernate/BorrowedConnectionProxyTest.java b/src/test/java/org/alfresco/repo/domain/hibernate/BorrowedConnectionProxyTest.java deleted file mode 100644 index da17ad8f98..0000000000 --- a/src/test/java/org/alfresco/repo/domain/hibernate/BorrowedConnectionProxyTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.repo.domain.hibernate; - -import java.sql.Connection; - -import javax.sql.DataSource; -import javax.transaction.UserTransaction; - -import junit.framework.TestCase; - -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.ApplicationContextHelper; -import org.hibernate.HibernateException; -import org.hibernate.jdbc.BorrowedConnectionProxy; -import org.junit.experimental.categories.Category; -import org.springframework.context.ApplicationContext; -import org.springframework.jdbc.datasource.ConnectionHolder; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -/** - * Tests the {@link BorrowedConnectionProxy}'s ability to detect post-close reuse. - * - * @author Derek Hulley - */ -@Category(OwnJVMTestsCategory.class) -public class BorrowedConnectionProxyTest extends TestCase -{ - private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext(); - - private TransactionService transactionService; - private DataSource dataSource; - - public void setUp() throws Exception - { - transactionService = (TransactionService) ctx.getBean("transactionComponent"); - dataSource = (DataSource) ctx.getBean("dataSource"); - } - - public void testSimpleCommit() throws Throwable - { - UserTransaction txn = transactionService.getUserTransaction(); - try - { - txn.begin(); - txn.commit(); - } - catch (Throwable e) - { - try { txn.rollback(); } catch (Throwable ee) {} - throw e; - } - } - - public void testLoggingAutoActivate() throws Throwable - { - assertFalse("Auto-logging of misuse of the wrapper should be off", BorrowedConnectionProxy.isCallStackTraced()); - - UserTransaction txn = transactionService.getUserTransaction(); - Connection connection; - try - { - txn.begin(); - // Dig the proxy out of ... somewhere - ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource); - connection = conHolder.getConnection(); - txn.commit(); - } - catch (Throwable e) - { - try { txn.rollback(); } catch (Throwable ee) {} - throw e; - } - // Now mess with the connection, which is protected by the Hibernate wrapper - try - { - connection.commit(); - fail("Use case should have generated a HibernateException"); - } - catch (HibernateException e) - { - // Expected - } - assertTrue("Auto-logging of misuse of the wrapper should now be on", BorrowedConnectionProxy.isCallStackTraced()); - - // Now start a new transaction and we should see logging - txn = transactionService.getUserTransaction(); - try - { - txn.begin(); - // Dig the proxy out of ... somewhere - ConnectionHolder conHolder = (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource); - connection = conHolder.getConnection(); - txn.commit(); - } - catch (Throwable e) - { - try { txn.rollback(); } catch (Throwable ee) {} - throw e; - } - // Now mess with the connection, which is protected by the Hibernate wrapper - try - { - connection.commit(); - fail("Use case should have generated a HibernateException"); - } - catch (HibernateException e) - { - // Expected - } - // Check for error logs - } -} diff --git a/src/test/java/org/alfresco/repo/domain/propval/PropertyTypeConverterTest.java b/src/test/java/org/alfresco/repo/domain/propval/PropertyTypeConverterTest.java index d32b5ddbc7..e2906ec22b 100644 --- a/src/test/java/org/alfresco/repo/domain/propval/PropertyTypeConverterTest.java +++ b/src/test/java/org/alfresco/repo/domain/propval/PropertyTypeConverterTest.java @@ -25,10 +25,10 @@ */ package org.alfresco.repo.domain.propval; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; import org.alfresco.repo.domain.schema.SchemaBootstrap; import org.alfresco.test_category.OwnJVMTestsCategory; import org.apache.commons.lang.RandomStringUtils; -import org.hibernate.dialect.MySQLInnoDBDialect; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImplIntegrationTest.java b/src/test/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImplIntegrationTest.java index c769ca7905..c5bedf8e20 100644 --- a/src/test/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImplIntegrationTest.java +++ b/src/test/java/org/alfresco/repo/domain/schema/script/ScriptExecutorImplIntegrationTest.java @@ -33,13 +33,13 @@ import java.util.List; import javax.sql.DataSource; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; +import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.testing.category.LuceneTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.MySQLInnoDBDialect; -import org.hibernate.dialect.PostgreSQLDialect; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; diff --git a/src/test/java/org/alfresco/repo/exporter/ExporterComponentTest.java b/src/test/java/org/alfresco/repo/exporter/ExporterComponentTest.java index a4278b3945..d3d37a8ee3 100644 --- a/src/test/java/org/alfresco/repo/exporter/ExporterComponentTest.java +++ b/src/test/java/org/alfresco/repo/exporter/ExporterComponentTest.java @@ -77,10 +77,15 @@ import org.alfresco.util.TempFileProvider; import org.alfresco.util.debug.NodeStoreInspector; import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.RedundantTests; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.transaction.annotation.Transactional; @Category({OwnJVMTestsCategory.class, LuceneTests.class}) +@Transactional public class ExporterComponentTest extends BaseSpringTest { @@ -97,8 +102,8 @@ public class ExporterComponentTest extends BaseSpringTest private Locale contentLocaleToRestore; private Locale localeToRestore; - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()); exporterService = (ExporterService)applicationContext.getBean("exporterComponent"); @@ -112,31 +117,19 @@ public class ExporterComponentTest extends BaseSpringTest this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); this.authenticationComponent.setSystemUserAsCurrentUser(); this.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); - } - - @Override - protected void onTearDownInTransaction() throws Exception - { - authenticationComponent.clearCurrentSecurityContext(); - super.onTearDownInTransaction(); - } - - @Override - protected void onSetUp() throws Exception - { - super.onSetUp(); contentLocaleToRestore = I18NUtil.getContentLocale(); localeToRestore = I18NUtil.getLocale(); } - @Override - protected void onTearDown() throws Exception + @After + public void after() { - super.onTearDown(); I18NUtil.setContentLocale(contentLocaleToRestore); I18NUtil.setLocale(localeToRestore); + authenticationComponent.clearCurrentSecurityContext(); } + @Test public void testExport() throws Exception { @@ -177,6 +170,7 @@ public class ExporterComponentTest extends BaseSpringTest */ @SuppressWarnings("unchecked") @Category(RedundantTests.class) + @Test public void testRoundTripKeepsCategoriesWhenWithinSameStore() throws Exception { // Use a store ref that has the bootstrapped categories @@ -207,6 +201,7 @@ public class ExporterComponentTest extends BaseSpringTest */ @SuppressWarnings("unchecked") @Category(RedundantTests.class) + @Test public void testRoundTripLosesCategoriesImportingToDifferentStore() throws Exception { // Use a store ref that has the bootstrapped categories @@ -230,6 +225,7 @@ public class ExporterComponentTest extends BaseSpringTest assertEquals("No categories should have been imported for the content", 0, importedFileCategories.size()); } + @Test public void testMLText() throws Exception { NodeRef rootNode = nodeService.getRootNode(storeRef); @@ -278,6 +274,7 @@ public class ExporterComponentTest extends BaseSpringTest } } + @Test public void testMNT12504() throws Exception { String testUser = "testUserMnt12504"; diff --git a/src/test/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java b/src/test/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java index 103f9a4f66..f66ce9a8f9 100644 --- a/src/test/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java +++ b/src/test/java/org/alfresco/repo/exporter/RepositoryExporterComponentTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.exporter; import org.alfresco.model.ContentModel; @@ -37,8 +37,15 @@ import org.alfresco.service.cmr.view.RepositoryExporterService; import org.alfresco.service.cmr.view.RepositoryExporterService.FileExportHandle; import org.alfresco.service.cmr.view.RepositoryExporterService.RepositoryExportHandle; import org.alfresco.util.BaseSpringTest; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.test.annotation.Commit; +import org.springframework.transaction.annotation.Transactional; +@Transactional public class RepositoryExporterComponentTest extends BaseSpringTest { private RepositoryExporterService repositoryService; @@ -46,9 +53,8 @@ public class RepositoryExporterComponentTest extends BaseSpringTest private NodeService nodeService; private FileFolderService fileFolderService; - - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()); this.fileFolderService = (FileFolderService)applicationContext.getBean(ServiceRegistry.FILE_FOLDER_SERVICE.getLocalName()); @@ -57,14 +63,14 @@ public class RepositoryExporterComponentTest extends BaseSpringTest this.authenticationComponent.setSystemUserAsCurrentUser(); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { authenticationComponent.clearCurrentSecurityContext(); - super.onTearDownInTransaction(); } + @Test public void testDummy() { } @@ -80,9 +86,11 @@ public class RepositoryExporterComponentTest extends BaseSpringTest assertTrue(tempFile.exportFile.exists()); } } - - public void xtestRepositoryExport() - throws Exception + + @Ignore + @Commit + @Test + public void testRepositoryExport() { // Create a temp store to hold exports StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); @@ -97,8 +105,6 @@ public class RepositoryExporterComponentTest extends BaseSpringTest { assertTrue(nodeService.exists(handle.exportFile)); } - - setComplete(); } } diff --git a/src/test/java/org/alfresco/repo/forms/FormServiceImplTest.java b/src/test/java/org/alfresco/repo/forms/FormServiceImplTest.java index 0f8ad0e2e1..a391530a0a 100644 --- a/src/test/java/org/alfresco/repo/forms/FormServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/forms/FormServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.forms; import java.io.Serializable; @@ -73,7 +73,10 @@ import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; /** @@ -83,6 +86,7 @@ import org.springframework.util.StringUtils; * @author Nick Smith */ @Category(BaseSpringTestsCategory.class) +@Transactional public class FormServiceImplTest extends BaseAlfrescoSpringTest { private FormService formService; @@ -136,15 +140,11 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest private static final String TYPE_FORM_ITEM_KIND = "type"; private static final String WORKFLOW_FORM_ITEM_KIND = "workflow"; private static final String TASK_FORM_ITEM_KIND = "task"; - - /** - * Called during the transaction setup - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the required services this.formService = (FormService)this.applicationContext.getBean("FormService"); @@ -244,6 +244,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } @SuppressWarnings("unchecked") + @Test public void testGetAllDocForm() throws Exception { Form form = this.formService.getForm(new Item(NODE_FORM_ITEM_KIND, this.document.toString())); @@ -401,6 +402,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } @SuppressWarnings("unchecked") + @Test public void testGetSelectedFieldsDocForm() throws Exception { // define a list of fields to retrieve from the node @@ -521,6 +523,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertEquals(this.associatedDoc.toString(), targets.get(0)); } + @Test public void testMissingFieldsDocForm() throws Exception { // define a list of fields to retrieve from the node @@ -574,6 +577,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertEquals(VALUE_TITLE, data.getFieldData(titleField.getDataKeyName()).getValue()); } + @Test public void testForcedFieldsDocForm() throws Exception { // define a list of fields to retrieve from the node @@ -642,6 +646,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } @SuppressWarnings("unchecked") + @Test public void testGetAllFolderForm() throws Exception { Form form = this.formService.getForm(new Item(NODE_FORM_ITEM_KIND, this.folder.toString())); @@ -723,6 +728,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } @SuppressWarnings("unchecked") + @Test public void testSaveNodeForm() throws Exception { // create FormData object containing the values to update @@ -820,6 +826,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest */ } + @Test public void testGetAllCreateForm() throws Exception { // get a form for the cm:content type @@ -868,6 +875,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertNotNull("Expecting to find the cm:modifier field", modifierField); } + @Test public void testGetSelectedFieldsCreateForm() throws Exception { // define a list of fields to retrieve from the node @@ -921,6 +929,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } + @Test public void testSaveTypeForm() throws Exception { // create FormData object containing the values to update @@ -973,6 +982,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertNotNull("Expected new node to be created using itemId " + ContentModel.TYPE_CONTENT.toString(), newNode); } + @Test public void testContentForms() throws Exception { // create FormData object @@ -1315,6 +1325,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } + @Test public void testGetFormForActivitiTask() throws Exception { checkGetFormForTask("activiti$activitiReview"); @@ -1349,6 +1360,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testSaveActivitiTask() throws Exception { checkSaveTask("activiti$activitiReview"); @@ -1374,6 +1386,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } + @Test public void testTransitionActivitiTask() throws Exception { checkTransitionTask("activiti$activitiReview", ActivitiConstants.DEFAULT_TRANSITION_NAME, "Approve"); @@ -1446,6 +1459,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest return fields; } + @Test public void testActivitiWorkflowForm() throws Exception { checkWorkflowForms("activiti$activitiAdhoc", "Next|Task Done"); @@ -1572,6 +1586,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testNoForm() throws Exception { // test that a form can not be retrieved for a non-existent item @@ -1640,7 +1655,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest data.addFieldData("assoc_bpm_assignee_added", this.personManager.get(USER_ONE).toString()); data.addFieldData("assoc_packageItems_added", this.document.toString()); - this.formService.saveForm(new Item(WORKFLOW_FORM_ITEM_KIND, "activiti$activiti_Adhoc"), data); // correct name would be "activiti$activitiAdhoc" + this.formService.saveForm(new Item(WORKFLOW_FORM_ITEM_KIND, "activiti$activiti_Adhoc"), data); // correct name would be "activiti$activitiAdhoc" fail("Expecting saveForm for a 'workflow' item kind containing an underscore to fail"); } catch (Exception e) @@ -1649,6 +1664,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testFormData() throws Exception { FormData formData = new FormData(); @@ -1687,6 +1703,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertEquals("Expecting 'overwritten' value to be 'three'", "three", value); } + @Test public void testFormContext() throws Exception { Map context = new HashMap(2); @@ -1697,6 +1714,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertNotNull(form); } + @Test public void testNonContentNode() throws Exception { // create a node (not cm:content) @@ -1736,6 +1754,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest } @SuppressWarnings("unchecked") + @Test public void testMNT_10969() throws Exception { // create a node (cm:content) @@ -1774,6 +1793,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertEquals(Arrays.asList("", "titi", "toto", ""), savedValue); } + @Test public void testJavascriptAPI() throws Exception { Map model = new HashMap(); diff --git a/src/test/java/org/alfresco/repo/forms/processor/action/ActionFormProcessorTest.java b/src/test/java/org/alfresco/repo/forms/processor/action/ActionFormProcessorTest.java index 9c1115eb09..c7b8dc9ed3 100644 --- a/src/test/java/org/alfresco/repo/forms/processor/action/ActionFormProcessorTest.java +++ b/src/test/java/org/alfresco/repo/forms/processor/action/ActionFormProcessorTest.java @@ -67,9 +67,14 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.ApplicationContextHelper; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.alfresco.util.BaseAlfrescoSpringTest; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; /** * Test class for the {@link ActionFormProcessor}. @@ -78,6 +83,9 @@ import org.springframework.extensions.surf.util.I18NUtil; * @since 4.0 */ @Category(BaseSpringTestsCategory.class) +@Transactional +@ContextConfiguration({ "classpath:alfresco/application-context.xml", + "classpath:org/alfresco/repo/forms/MNT-7383-context.xml"}) public class ActionFormProcessorTest extends BaseAlfrescoSpringTest { private RetryingTransactionHelper transactionHelper; @@ -89,24 +97,11 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest private List testNodesToBeTidiedUp; - @Override - protected String[] getConfigLocations() - { - String[] existingConfigLocations = ApplicationContextHelper.CONFIG_LOCATIONS; - - List locations = Arrays.asList(existingConfigLocations); - List mutableLocationsList = new ArrayList(locations); - mutableLocationsList.add("classpath:org/alfresco/repo/forms/MNT-7383-context.xml"); - - String[] result = mutableLocationsList.toArray(new String[mutableLocationsList.size()]); - return result; - } - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.formService = (FormService)this.applicationContext.getBean("FormService"); this.namespaceService = (NamespaceService)this.applicationContext.getBean("NamespaceService"); @@ -129,9 +124,10 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { + super.after(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); for (NodeRef node : testNodesToBeTidiedUp) @@ -139,7 +135,6 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest if (nodeService.exists(node)) nodeService.deleteNode(node); } authenticationService.clearCurrentSecurityContext(); - super.onTearDownInTransaction(); } /** @@ -158,6 +153,7 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest return node; } + @Test public void testRequestFormForNonExistentAction() throws Exception { try @@ -172,6 +168,7 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest } + @Test public void testGenerateDefaultFormForParameterlessAction() throws Exception { this.transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -202,6 +199,7 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest }); } + @Test public void testGenerateDefaultFormForActionWithNodeRefParam() throws Exception { this.transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -255,6 +253,7 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest /** * REPO-2253 Community: ALF-21854 Action parameter lookup for "de_DE" falls back to "root" locale instead of "de" */ + @Test public void testGenerateFormWithSpecificLocale() { final Locale originalLocale = I18NUtil.getLocale(); @@ -279,6 +278,7 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest } } + @Test public void testGenerateFormWithSelectedFields() throws Exception { this.transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -318,6 +318,7 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest }); } + @Test public void testPersistForm_executeTransformAction() throws Exception { this.transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -353,6 +354,7 @@ public class ActionFormProcessorTest extends BaseAlfrescoSpringTest }); } + @Test public void testMNT7383() throws Exception { this.transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() diff --git a/src/test/java/org/alfresco/repo/importer/ImporterComponentTest.java b/src/test/java/org/alfresco/repo/importer/ImporterComponentTest.java index 835e34613e..e4f15ac3ba 100644 --- a/src/test/java/org/alfresco/repo/importer/ImporterComponentTest.java +++ b/src/test/java/org/alfresco/repo/importer/ImporterComponentTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.importer; import java.io.InputStream; @@ -55,10 +55,15 @@ import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.debug.NodeStoreInspector; import org.joda.time.DateTimeZone; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.extensions.surf.util.ISO8601DateFormat; +import org.springframework.transaction.annotation.Transactional; @Category(BaseSpringTestsCategory.class) +@Transactional public class ImporterComponentTest extends BaseSpringTest { private ImporterService importerService; @@ -68,9 +73,9 @@ public class ImporterComponentTest extends BaseSpringTest private StoreRef storeRef; private AuthenticationComponent authenticationComponent; - - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()); importerService = (ImporterService)applicationContext.getBean(ServiceRegistry.IMPORTER_SERVICE.getLocalName()); @@ -92,14 +97,14 @@ public class ImporterComponentTest extends BaseSpringTest DateTimeZone.setDefault(DateTimeZone.forTimeZone(tz)); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() { authenticationComponent.clearCurrentSecurityContext(); - super.onTearDownInTransaction(); } + @Test public void testImport() throws Exception { InputStream test = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml"); @@ -109,6 +114,7 @@ public class ImporterComponentTest extends BaseSpringTest System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef)); } + @Test public void testImportWithAuditableProperties() throws Exception { InputStream test = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml"); @@ -159,6 +165,7 @@ public class ImporterComponentTest extends BaseSpringTest assertEquals("cm:modifier not preserved during import", AuthenticationUtil.getSystemUserName(), modifier); } + @Test public void testImportWithVersioning() throws Exception { InputStream test = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml"); @@ -204,6 +211,7 @@ public class ImporterComponentTest extends BaseSpringTest assertEquals(1, vh.getAllVersions().size()); } + @Test public void testImportWithUuidBinding() throws Exception { Location location = new Location(storeRef); @@ -252,6 +260,7 @@ public class ImporterComponentTest extends BaseSpringTest System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef)); } + @Test public void testBootstrap() { StoreRef bootstrapStoreRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); @@ -261,6 +270,7 @@ public class ImporterComponentTest extends BaseSpringTest System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, bootstrapStoreRef)); } + @Test public void testImportFoldersUuidBindingNullUuidNullLocationPath() throws Exception { Location location = new Location(storeRef); diff --git a/src/test/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java b/src/test/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java index c5d92832be..de2756109d 100644 --- a/src/test/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/invitation/AbstractInvitationServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.invitation; @@ -47,12 +47,12 @@ import org.alfresco.repo.site.SiteModel; import org.alfresco.repo.workflow.WorkflowAdminServiceImpl; import org.alfresco.service.cmr.invitation.Invitation; import org.alfresco.service.cmr.invitation.Invitation.ResourceType; -import org.alfresco.service.cmr.invitation.InvitationExceptionUserError; +import org.alfresco.service.cmr.invitation.InvitationExceptionUserError; import org.alfresco.service.cmr.invitation.InvitationSearchCriteria; import org.alfresco.service.cmr.invitation.InvitationService; import org.alfresco.service.cmr.invitation.ModeratedInvitation; import org.alfresco.service.cmr.invitation.NominatedInvitation; -import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.TemplateService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.site.SiteInfo; @@ -63,20 +63,25 @@ import org.alfresco.util.PropertyMap; import org.alfresco.util.email.ExtendedMailActionExecutor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Before; +import org.springframework.test.annotation.Commit; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ReflectionUtils; /** * Unit tests of Invitation Service */ +@Transactional public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpringTest { - private static final String TEST_REJECT_URL = "testRejectUrl"; - - private static final String TEST_ACCEPT_URL = "testAcceptUrl"; - - private static final String TEST_SERVER_PATH = "testServerPath"; - + private static final String TEST_REJECT_URL = "testRejectUrl"; + + private static final String TEST_ACCEPT_URL = "testAcceptUrl"; + + private static final String TEST_SERVER_PATH = "testServerPath"; + private static final Log logger = LogFactory.getLog(AbstractInvitationServiceImplTest.class); private SiteService siteService; @@ -110,14 +115,11 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri private Collection enabledEngines; private Collection visibleEngines; - /** - * Called during the transaction setup - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.invitationService = (InvitationService) this.applicationContext.getBean("InvitationService"); this.siteService = (SiteService) this.applicationContext.getBean("SiteService"); this.personService = (PersonService) this.applicationContext.getBean("PersonService"); @@ -175,8 +177,8 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { // Make sure both workflow engines are enabled.and visible @@ -193,7 +195,7 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri // deletePersonByUserName(USER_TWO); // deletePersonByUserName(USER_EVE); // deletePersonByUserName(USER_MANAGER); - super.onTearDownInTransaction(); + super.after(); } /* @@ -233,14 +235,14 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri this.authenticationComponent.setCurrentUser(USER_MANAGER); // Invite our existing user - try - { - invitationService.inviteNominated(inviteeUserName, resourceType, resourceName, inviteeRole, acceptUrl, rejectUrl); - fail("An exception of type " + InvitationExceptionUserError.class.getName() + " should be thrown"); - } - catch (Exception ex) - { - assertTrue("Incorrect exception was thrown", ex instanceof InvitationExceptionUserError); + try + { + invitationService.inviteNominated(inviteeUserName, resourceType, resourceName, inviteeRole, acceptUrl, rejectUrl); + fail("An exception of type " + InvitationExceptionUserError.class.getName() + " should be thrown"); + } + catch (Exception ex) + { + assertTrue("Incorrect exception was thrown", ex instanceof InvitationExceptionUserError); } @@ -1276,62 +1278,63 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri results = invitationService.searchInvitation(query, MAX_SEARCH); assertEquals(MAX_SEARCH, results.size()); } - - /** - * MNT-17341 : External users with Manager role cannot invite other external users to the site because site invitation accept fails - */ - public void testExternalUserManagerInvitingAnotherExternalUser() throws Exception{ - String inviteeFirstName = PERSON_FIRSTNAME; - String inviteeLastName = PERSON_LASTNAME; - String inviteeEmail = "123@alfrescotesting.com"; - - String inviteeFirstName2 = "user2name"; - String inviteeLastName2 = "user2lastname"; - String inviteeEmail2 = "1234@alfrescotesting.com"; + + /** + * MNT-17341 : External users with Manager role cannot invite other external users to the site because site invitation accept fails + */ + public void testExternalUserManagerInvitingAnotherExternalUser() throws Exception{ + String inviteeFirstName = PERSON_FIRSTNAME; + String inviteeLastName = PERSON_LASTNAME; + String inviteeEmail = "123@alfrescotesting.com"; + + String inviteeFirstName2 = "user2name"; + String inviteeLastName2 = "user2lastname"; + String inviteeEmail2 = "1234@alfrescotesting.com"; - this.authenticationComponent.setCurrentUser(USER_MANAGER); - - // internal user invites an external user as a site manager - NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, - Invitation.ResourceType.WEB_SITE, SITE_SHORT_NAME_INVITE, SiteModel.SITE_MANAGER, TEST_SERVER_PATH, TEST_ACCEPT_URL, TEST_REJECT_URL); - - AuthenticationUtil.setFullyAuthenticatedUser(nominatedInvitation.getInviteeUserName()); - - invitationService.accept(nominatedInvitation.getInviteId(), nominatedInvitation.getTicket()); - - // external user1 now a site manager, invites another external user as a site collaborator - NominatedInvitation nominatedInvitation2 = invitationService.inviteNominated(inviteeFirstName2, inviteeLastName2, inviteeEmail2, - Invitation.ResourceType.WEB_SITE, SITE_SHORT_NAME_INVITE, SiteModel.SITE_COLLABORATOR, TEST_SERVER_PATH, TEST_ACCEPT_URL, TEST_REJECT_URL); - - assertNotNull("nominated invitation is null", nominatedInvitation2); - assertEquals("first name wrong", inviteeFirstName2, nominatedInvitation2.getInviteeFirstName()); - assertEquals("last name wrong", inviteeLastName2, nominatedInvitation2.getInviteeLastName()); - assertEquals("email name wrong", inviteeEmail2, nominatedInvitation2.getInviteeEmail()); - - AuthenticationUtil.setFullyAuthenticatedUser(nominatedInvitation2.getInviteeUserName()); - - NodeRef person = personService.getPersonOrNull(nominatedInvitation2.getInviteeUserName()); - assertTrue("user has not been created", person != null); - assertTrue("user should have the ASPECT_ANULLABLE aspect since the invitation hasn't been accepted yet", nodeService.hasAspect(person, ContentModel.ASPECT_ANULLABLE)); - - // authenticated as external user 2 accept the invitation - Invitation acceptedNominatedInvitation2 = invitationService.accept(nominatedInvitation2.getInviteId(), nominatedInvitation2.getTicket()); - - assertNotNull("accepted nominated invitation is null", acceptedNominatedInvitation2); - assertEquals("role is wrong", SiteModel.SITE_COLLABORATOR, acceptedNominatedInvitation2.getRoleName()); - assertEquals("user name wrong", inviteeFirstName2 + "_" + inviteeLastName2, acceptedNominatedInvitation2.getInviteeUserName()); - - person = personService.getPersonOrNull(acceptedNominatedInvitation2.getInviteeUserName()); - assertTrue("user has not been created", person != null); - assertTrue("user should not have the ASPECT_ANULLABLE aspect anymore", !nodeService.hasAspect(person, ContentModel.ASPECT_ANULLABLE)); - - Invitation invitation = invitationService.getInvitation(acceptedNominatedInvitation2.getInviteId()); - assertEquals("invited user name is wrong", invitation.getInviteeUserName(), acceptedNominatedInvitation2.getInviteeUserName()); - assertEquals("invite id is wrong", invitation.getInviteId(), acceptedNominatedInvitation2.getInviteId()); - assertEquals("invite resource name is wrong", invitation.getResourceName(), acceptedNominatedInvitation2.getResourceName()); - + this.authenticationComponent.setCurrentUser(USER_MANAGER); + + // internal user invites an external user as a site manager + NominatedInvitation nominatedInvitation = invitationService.inviteNominated(inviteeFirstName, inviteeLastName, inviteeEmail, + Invitation.ResourceType.WEB_SITE, SITE_SHORT_NAME_INVITE, SiteModel.SITE_MANAGER, TEST_SERVER_PATH, TEST_ACCEPT_URL, TEST_REJECT_URL); + + AuthenticationUtil.setFullyAuthenticatedUser(nominatedInvitation.getInviteeUserName()); + + invitationService.accept(nominatedInvitation.getInviteId(), nominatedInvitation.getTicket()); + + // external user1 now a site manager, invites another external user as a site collaborator + NominatedInvitation nominatedInvitation2 = invitationService.inviteNominated(inviteeFirstName2, inviteeLastName2, inviteeEmail2, + Invitation.ResourceType.WEB_SITE, SITE_SHORT_NAME_INVITE, SiteModel.SITE_COLLABORATOR, TEST_SERVER_PATH, TEST_ACCEPT_URL, TEST_REJECT_URL); + + assertNotNull("nominated invitation is null", nominatedInvitation2); + assertEquals("first name wrong", inviteeFirstName2, nominatedInvitation2.getInviteeFirstName()); + assertEquals("last name wrong", inviteeLastName2, nominatedInvitation2.getInviteeLastName()); + assertEquals("email name wrong", inviteeEmail2, nominatedInvitation2.getInviteeEmail()); + + AuthenticationUtil.setFullyAuthenticatedUser(nominatedInvitation2.getInviteeUserName()); + + NodeRef person = personService.getPersonOrNull(nominatedInvitation2.getInviteeUserName()); + assertTrue("user has not been created", person != null); + assertTrue("user should have the ASPECT_ANULLABLE aspect since the invitation hasn't been accepted yet", nodeService.hasAspect(person, ContentModel.ASPECT_ANULLABLE)); + + // authenticated as external user 2 accept the invitation + Invitation acceptedNominatedInvitation2 = invitationService.accept(nominatedInvitation2.getInviteId(), nominatedInvitation2.getTicket()); + + assertNotNull("accepted nominated invitation is null", acceptedNominatedInvitation2); + assertEquals("role is wrong", SiteModel.SITE_COLLABORATOR, acceptedNominatedInvitation2.getRoleName()); + assertEquals("user name wrong", inviteeFirstName2 + "_" + inviteeLastName2, acceptedNominatedInvitation2.getInviteeUserName()); + + person = personService.getPersonOrNull(acceptedNominatedInvitation2.getInviteeUserName()); + assertTrue("user has not been created", person != null); + assertTrue("user should not have the ASPECT_ANULLABLE aspect anymore", !nodeService.hasAspect(person, ContentModel.ASPECT_ANULLABLE)); + + Invitation invitation = invitationService.getInvitation(acceptedNominatedInvitation2.getInviteId()); + assertEquals("invited user name is wrong", invitation.getInviteeUserName(), acceptedNominatedInvitation2.getInviteeUserName()); + assertEquals("invite id is wrong", invitation.getInviteId(), acceptedNominatedInvitation2.getInviteId()); + assertEquals("invite resource name is wrong", invitation.getResourceName(), acceptedNominatedInvitation2.getResourceName()); + } + @Commit public void disabled_test100Invites() throws Exception { Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; @@ -1362,9 +1365,6 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri assertEquals(1, results.size()); assertEquals(invite.getInviteId(), results.get(0).getInviteId()); - this.setComplete(); - this.endTransaction(); - } public void testGetInvitation() diff --git a/src/test/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java b/src/test/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java index d7361efa53..df6ae882cd 100644 --- a/src/test/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java +++ b/src/test/java/org/alfresco/repo/invitation/ActivitiInvitationServiceImplTests.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.invitation; @@ -37,8 +37,11 @@ import org.alfresco.service.cmr.workflow.WorkflowPath; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.cmr.workflow.WorkflowTaskState; -import org.alfresco.test_category.BaseSpringTestsCategory; -import org.junit.experimental.categories.Category; +import org.alfresco.test_category.BaseSpringTestsCategory; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * @author Nick Smith @@ -46,13 +49,15 @@ import org.junit.experimental.categories.Category; * */ @Category(BaseSpringTestsCategory.class) +@Transactional public class ActivitiInvitationServiceImplTests extends AbstractInvitationServiceImplTest { private WorkflowService workflowService; - /** - * Nominated invites workflows finish without waiting for user accept + /** + * Nominated invites workflows finish without waiting for user accept */ + @Test public void testWorkflowTaskContainsProps() { Invitation.ResourceType resourceType = Invitation.ResourceType.WEB_SITE; @@ -64,24 +69,21 @@ public class ActivitiInvitationServiceImplTests extends AbstractInvitationServic NominatedInvitation nomInvite = invitationService.inviteNominated(USER_ONE, resourceType, resourceName, inviteeRole, serverPath, acceptUrl, rejectUrl); - List paths = workflowService.getWorkflowPaths(nomInvite.getInviteId()); + List paths = workflowService.getWorkflowPaths(nomInvite.getInviteId()); assertEquals(0, paths.size()); } - /** - * {@inheritDoc} - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.workflowService = (WorkflowService) applicationContext.getBean("WorkflowService"); // Enable Activiti workflowAdminService.setEnabledEngines(Arrays.asList(ActivitiConstants.ENGINE_ID)); } + @Test public void testAddExistingUser() throws Exception { this.invitationServiceImpl.setNominatedInvitationWorkflowId( diff --git a/src/test/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java b/src/test/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java index acf481a043..668a675c21 100644 --- a/src/test/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java +++ b/src/test/java/org/alfresco/repo/jscript/ScriptBehaviourTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.jscript; import java.io.Serializable; @@ -45,7 +45,11 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; /** * @@ -53,6 +57,8 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional +@ContextConfiguration({ "classpath:org/alfresco/repo/jscript/test-context.xml" }) public class ScriptBehaviourTest extends BaseSpringTest { private ServiceRegistry serviceRegistry; @@ -62,18 +68,9 @@ public class ScriptBehaviourTest extends BaseSpringTest private StoreRef storeRef; private NodeRef folderNodeRef; - protected String[] getConfigLocations() + @Before + public void before() throws Exception { - return new String[] { "classpath:org/alfresco/repo/jscript/test-context.xml" }; - } - - /** - * On setup in transaction implementation - */ - @Override - protected void onSetUpInTransaction() - throws Exception - { // Get the required services this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); this.policyComponent = (PolicyComponent)this.applicationContext.getBean("policyComponent"); @@ -98,7 +95,8 @@ public class ScriptBehaviourTest extends BaseSpringTest this.folderNodeRef = childAssocRef.getChildRef(); } - public void test1EnableDisableBehaviour() + @Test + public void test1EnableDisableBehaviour() { // Register the onCreateNode behaviour script ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/jscript/test_onCreateNode_cmContent.js"); @@ -135,7 +133,8 @@ public class ScriptBehaviourTest extends BaseSpringTest assertTrue(this.nodeService.hasAspect(childAssoc2.getChildRef(), ContentModel.ASPECT_TITLED)); } - public void test2ClasspathLocationBehaviour() + @Test + public void test2ClasspathLocationBehaviour() { // Register the onCreateNode behaviour script ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/jscript/test_onCreateNode_cmContent.js"); @@ -160,7 +159,8 @@ public class ScriptBehaviourTest extends BaseSpringTest assertTrue(this.nodeService.hasAspect(childAssoc.getChildRef(), ContentModel.ASPECT_TITLED)); } - public void test3SpringConfiguredBehaviour() + @Test + public void test3SpringConfiguredBehaviour() { this.nodeService.addAspect(this.folderNodeRef, ContentModel.ASPECT_COUNTABLE, null); assertTrue(this.nodeService.hasAspect(this.folderNodeRef, ContentModel.ASPECT_TITLED)); diff --git a/src/test/java/org/alfresco/repo/lock/LockBehaviourImplTest.java b/src/test/java/org/alfresco/repo/lock/LockBehaviourImplTest.java index 7dca605628..015d04ce2f 100644 --- a/src/test/java/org/alfresco/repo/lock/LockBehaviourImplTest.java +++ b/src/test/java/org/alfresco/repo/lock/LockBehaviourImplTest.java @@ -48,7 +48,10 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.TestWithUserUtils; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * LockBehaviourImpl Unit Test. @@ -56,6 +59,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(OwnJVMTestsCategory.class) +@Transactional public class LockBehaviourImplTest extends BaseSpringTest { /** @@ -111,9 +115,9 @@ public class LockBehaviourImplTest extends BaseSpringTest private static final String BAD_USER_WITH_ALL_PERMS_NAME = "badUserOwns"; NodeRef rootNodeRef; - - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { this.nodeService = (NodeService)applicationContext.getBean("dbNodeService"); this.lockService = (LockService)applicationContext.getBean("lockService"); @@ -186,6 +190,7 @@ public class LockBehaviourImplTest extends BaseSpringTest /** * Test checkForLock (no user specified) */ + @Test public void testCheckForLockNoUser() { TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService); @@ -268,6 +273,7 @@ public class LockBehaviourImplTest extends BaseSpringTest assertTrue(lockService.isLockedAndReadOnly(nodeRef)); } + @Test public void testCheckForLockWhenExpired() { TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService); @@ -298,6 +304,7 @@ public class LockBehaviourImplTest extends BaseSpringTest /** * Test version service lock checking */ + @Test public void testVersionServiceLockBehaviour01() { TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService); @@ -342,6 +349,7 @@ public class LockBehaviourImplTest extends BaseSpringTest /** * Test version service lock checking */ + @Test public void testVersionServiceLockBehaviour02() { // Add the version aspect to the node @@ -426,6 +434,7 @@ public class LockBehaviourImplTest extends BaseSpringTest /** * ALF-5680: It is possible to cut/paste a locked file */ + @Test public void testCannotMoveNodeWhenLocked() { TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService); @@ -469,6 +478,7 @@ public class LockBehaviourImplTest extends BaseSpringTest /** * MNT-9475: Moving locked content breaks edit online */ + @Test public void testCanMoveCopyDeleteWithLockOwner() { TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService); diff --git a/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java b/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java index c32cf44edd..192281b0f8 100644 --- a/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/lock/LockServiceImplTest.java @@ -62,17 +62,20 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.TestWithUserUtils; -import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.RedundantTests; +import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * Simple lock service test * * @author Roy Wetherall */ -@Category({BaseSpringTestsCategory.class, LuceneTests.class}) +@Category({BaseSpringTestsCategory.class}) +@Transactional public class LockServiceImplTest extends BaseSpringTest { /** @@ -101,10 +104,8 @@ public class LockServiceImplTest extends BaseSpringTest NodeRef rootNodeRef; private StoreRef storeRef; - /** - * Called during the transaction setup - */ - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)applicationContext.getBean("dbNodeService"); this.lockService = (LockService)applicationContext.getBean("lockService"); @@ -594,7 +595,7 @@ public class LockServiceImplTest extends BaseSpringTest lockService.lock(rootNodeRef, LockType.NODE_LOCK, 3600, Lifetime.EPHEMERAL); // Rollback - endTransaction(); + TestTransaction.end(); // This lock should not be present. assertEquals(LockStatus.NO_LOCK, lockService.getLockStatus(noAspectNode)); diff --git a/src/test/java/org/alfresco/repo/management/subsystems/test/SubsystemsTest.java b/src/test/java/org/alfresco/repo/management/subsystems/test/SubsystemsTest.java new file mode 100644 index 0000000000..17d3b7100d --- /dev/null +++ b/src/test/java/org/alfresco/repo/management/subsystems/test/SubsystemsTest.java @@ -0,0 +1,216 @@ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.management.subsystems.test; + +import java.util.HashMap; +import java.util.Map; +import org.alfresco.repo.management.subsystems.ApplicationContextFactory; +import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; +import org.alfresco.repo.management.subsystems.InvalidPropertyValueException; +import org.alfresco.repo.management.subsystems.SubsystemEarlyPropertyChecker; +import org.alfresco.repo.management.subsystems.test.TestBean; +import org.alfresco.repo.management.subsystems.test.TestService; +import org.alfresco.test_category.OwnJVMTestsCategory; +import org.alfresco.util.BaseSpringTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.context.ContextConfiguration; + +/** + * Ensures the following features of subsystems are working: + *
    + *
  • Subsystem default properties + *
  • Global property overrides (via alfresco-global.properties) + *
  • Subsystem instance specific property overrides (via extension classpath) + *
  • Subsystem instance specific Spring overrides (via extension classpath) + *
  • Composite property defaults + *
  • Composite property instance overrides + *
+ * + * @see ChildApplicationContextFactory + * @author dward + */ +@Category(OwnJVMTestsCategory.class) +@ContextConfiguration({"classpath:alfresco/application-context.xml", "classpath:subsystem-test-context.xml"}) +public class SubsystemsTest extends BaseSpringTest +{ + volatile boolean shouldBlockPort; + + /** + * Test subsystems. + * + * @throws Exception + * the exception + */ + @Test + public void testSubsystems() throws Exception + { + ApplicationContextFactory subsystem = (ApplicationContextFactory) applicationContext.getBean( + "testsubsystem"); + ConfigurableApplicationContext childContext = (ConfigurableApplicationContext) subsystem + .getApplicationContext(); + assertTrue("Subsystem not started", childContext.isActive()); + TestService testService = (TestService) childContext.getBean("testService"); + // Make sure subsystem defaults work + assertEquals("Subsystem Default1", testService.getSimpleProp1()); + // Make sure global property overrides work + assertEquals(true, testService.getSimpleProp2().booleanValue()); + // Make sure extension classpath property overrides work + assertEquals("Instance Override3", testService.getSimpleProp3()); + // Make sure extension classpath Spring overrides work + assertEquals("An extra bean I changed", childContext.getBean("anotherBean")); + // Make sure composite properties and their defaults work + TestBean[] testBeans = testService.getTestBeans(); + assertNotNull("Composite property not set", testBeans); + assertEquals(3, testBeans.length); + assertEquals("inst1", testBeans[0].getId()); + assertEquals(false, testBeans[0].isBoolProperty()); + assertEquals(123456789123456789L, testBeans[0].getLongProperty()); + assertEquals("Global Default", testBeans[0].getAnotherStringProperty()); + assertEquals("inst2", testBeans[1].getId()); + assertEquals(true, testBeans[1].isBoolProperty()); + assertEquals(123456789123456789L, testBeans[1].getLongProperty()); + assertEquals("Global Default", testBeans[1].getAnotherStringProperty()); + assertEquals("inst3", testBeans[2].getId()); + assertEquals(false, testBeans[2].isBoolProperty()); + assertEquals(123456789123456789L, testBeans[2].getLongProperty()); + assertEquals("Global Instance Default", testBeans[2].getAnotherStringProperty()); + } + + @Test + public void testAbstractPropertyBackedBean_performEarlyPropertyChecks_PortEarlyPropertyChecker() + { + int testPortNumber = (Integer) applicationContext.getBean("testPortNumber"); + String testHost = (String) applicationContext.getBean("testHost"); + + ChildApplicationContextFactory testBean = (ChildApplicationContextFactory) applicationContext.getBean("testsubsystem"); + + Map testProperties = new HashMap(); + + // Check for empty port value error: + testProperties.put("test1.port", ""); + + // Check for "unable to parse" error: + testProperties.put("test2.port", "123xy"); + + // Check for "out-of-bounds" (less than) error: + testProperties.put("test3.port", "0"); + + // Check for "out of bounds" (greater than) error: + testProperties.put("test4.port", "65536"); + + // Check for "port in use" error: + testProperties.put("test5.port", "" + testPortNumber); + + String errorMessage = testBean.performEarlyPropertyChecks(testProperties); + + assertTrue(errorMessage.contains("The value for TestSubsystem port property cannot be empty.")); + assertTrue(errorMessage.contains("Unable to parse value for TestSubsystem port property: 123xy.")); + assertTrue(errorMessage.contains("The port chosen for TestSubsystem is outside the required range (1, 65535): 0.")); + assertTrue(errorMessage.contains("The port chosen for TestSubsystem is outside the required range (1, 65535): 65536.")); + + assertTrue(errorMessage.contains( + "The port chosen for TestSubsystem is already in use or you don't have permission to use it: " + testPortNumber + ".")); + + testProperties.clear(); + + testProperties.put("test_with_host.port", "" + testPortNumber); + // Check for unknown host: + testProperties.put("test.subsystem.host", testHost); + + errorMessage = testBean.performEarlyPropertyChecks(testProperties); + + assertTrue(errorMessage.contains( + "The hostname chosen for TestSubsystem is unknown or misspelled: " + testProperties.get("test.subsystem.host") + ".")); + + } + + @Test + public void testAbstractPropertyBackedBean_performEarlyPropertyChecks_CustomEarlyPropertyChecker() + { + ChildApplicationContextFactory testBean = new ChildApplicationContextFactory(); + + SubsystemEarlyPropertyChecker testEarlyPropertyChecker = new SubsystemEarlyPropertyChecker() + { + @Override + public void checkPropertyValue(String propertyName, String propertyValue, String pairedPropertyValue) throws InvalidPropertyValueException + { + if (propertyValue == null || propertyValue.isEmpty()) + { + throw new InvalidPropertyValueException("Property value cannot be empty."); + } + + if (pairedPropertyValue == null) + { + if (propertyValue.equals("Bad value")) + { + throw new InvalidPropertyValueException("Property value cannot be a 'Bad value'."); + } + } + else if ((propertyValue + pairedPropertyValue).contains("bad value")) + { + throw new InvalidPropertyValueException("No 'bad value's allowed!"); + } + } + + @Override + public String getPairedPropertyName() + { + return "testPairedPropertyName"; + } + }; + + Map earlyPropertyCheckersMap = new HashMap(); + earlyPropertyCheckersMap.put("test1.property", testEarlyPropertyChecker); + earlyPropertyCheckersMap.put("test2.property", testEarlyPropertyChecker); + + testBean.setEarlyPropertyCheckers(earlyPropertyCheckersMap); + + Map testProperties = new HashMap(); + + // Test empty value error: + testProperties.put("test1.property", ""); + + // Test "Bad value" error: + testProperties.put("test2.property", "Bad value"); + + String errorMessage = testBean.performEarlyPropertyChecks(testProperties); + + assertTrue(errorMessage.contains("Property value cannot be empty.")); + assertTrue(errorMessage.contains("Property value cannot be a 'Bad value'.")); + + earlyPropertyCheckersMap.clear(); + earlyPropertyCheckersMap.put("test3.property", testEarlyPropertyChecker); + + testProperties.clear(); + testProperties.put("testPairedPropertyName", "Test paired property bad value"); + testProperties.put("test3.property", "Test property value"); + + errorMessage = testBean.performEarlyPropertyChecks(testProperties); + assertTrue(errorMessage.contains("No 'bad value's allowed!")); + } +} diff --git a/src/test/java/org/alfresco/repo/management/subsystems/test/TestPortEarlyPropertyChecker.java b/src/test/java/org/alfresco/repo/management/subsystems/test/TestPortEarlyPropertyChecker.java new file mode 100644 index 0000000000..66c0a47626 --- /dev/null +++ b/src/test/java/org/alfresco/repo/management/subsystems/test/TestPortEarlyPropertyChecker.java @@ -0,0 +1,72 @@ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.management.subsystems.test; + +import java.io.IOException; +import org.alfresco.repo.management.subsystems.PortEarlyPropertyChecker; + +public class TestPortEarlyPropertyChecker extends PortEarlyPropertyChecker +{ + private int blockedPort = -1; + private String wrongHost = ""; + + public TestPortEarlyPropertyChecker(String subsystemName, boolean hasMultiplePorts, + boolean shouldCheckForBlockedPort) + { + super(subsystemName, hasMultiplePorts, shouldCheckForBlockedPort); + } + + public TestPortEarlyPropertyChecker(String subsystemName, String requiredPairedPropertyName, + boolean hasMultiplePorts, boolean shouldCheckForBlockedPort) + { + super(subsystemName, requiredPairedPropertyName, hasMultiplePorts, + shouldCheckForBlockedPort); + } + + public void setBlockedPort(int blockedPort) + { + this.blockedPort = blockedPort; + } + + public void setWrongHost(String wrongHost) + { + this.wrongHost = wrongHost; + } + + @Override + public void checkPort(int portNumber, String host) throws IOException + { + if (portNumber == blockedPort) + { + throw new java.net.BindException(); + } + + if (wrongHost.equals(host)) + { + throw new java.net.UnknownHostException(); + } + } +} diff --git a/src/test/java/org/alfresco/repo/model/filefolder/FileFolderLoaderTest.java b/src/test/java/org/alfresco/repo/model/filefolder/FileFolderLoaderTest.java index 9858ab3612..db9a1a6236 100644 --- a/src/test/java/org/alfresco/repo/model/filefolder/FileFolderLoaderTest.java +++ b/src/test/java/org/alfresco/repo/model/filefolder/FileFolderLoaderTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.model.filefolder; import java.util.List; @@ -136,9 +136,13 @@ public class FileFolderLoaderTest extends TestCase @Override public Void doWork() throws Exception { - fileFolderService.delete(hiddenFolderNodeRef); - fileFolderService.delete(readOnlyFolderNodeRef); - fileFolderService.delete(writeFolderNodeRef); + transactionService.getRetryingTransactionHelper().doInTransaction((RetryingTransactionCallback) () -> + { + fileFolderService.delete(hiddenFolderNodeRef); + fileFolderService.delete(readOnlyFolderNodeRef); + fileFolderService.delete(writeFolderNodeRef); + return null; + }); // Done return null; } diff --git a/src/test/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java b/src/test/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java index 2d9fbbf5b6..029efd44d8 100644 --- a/src/test/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.model.filefolder; import java.io.InputStream; @@ -53,7 +53,8 @@ import org.alfresco.repo.dictionary.DictionaryBootstrap; import org.alfresco.repo.dictionary.DictionaryDAO; import org.alfresco.repo.dictionary.M2Model; import org.alfresco.repo.dictionary.M2Type; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoMySQLClusterNDBDialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLClusterNDBDialect; import org.alfresco.repo.model.filefolder.FileFolderServiceImpl.InvalidTypeException; import org.alfresco.repo.node.integrity.IntegrityChecker; import org.alfresco.repo.security.authentication.AuthenticationUtil; @@ -88,7 +89,6 @@ import org.alfresco.util.FileFilterMode; import org.alfresco.util.FileFilterMode.Client; import org.alfresco.util.GUID; import org.alfresco.util.Pair; -import org.hibernate.dialect.Dialect; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; import org.springframework.extensions.surf.util.I18NUtil; @@ -1759,7 +1759,7 @@ public class FileFolderServiceImplTest extends TestCase int COUNT = 3000; Dialect dialect = (Dialect) ctx.getBean("dialect"); - if (dialect instanceof AlfrescoMySQLClusterNDBDialect) + if (dialect instanceof MySQLClusterNDBDialect) { // note: to increase the file count on NDB, may need to further bump-up NDB cluster config // eg. DataMemory, IndexMemory, MaxNoOfConcurrentOperations, ... diff --git a/src/test/java/org/alfresco/repo/node/BaseNodeServiceTest.java b/src/test/java/org/alfresco/repo/node/BaseNodeServiceTest.java index 1e7186c493..e2f79c4e6a 100644 --- a/src/test/java/org/alfresco/repo/node/BaseNodeServiceTest.java +++ b/src/test/java/org/alfresco/repo/node/BaseNodeServiceTest.java @@ -39,10 +39,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; - import javax.crypto.SealedObject; -import javax.transaction.UserTransaction; - import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.dictionary.DictionaryComponent; @@ -84,17 +81,21 @@ import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; -import org.hibernate.dialect.DB2Dialect; -import org.hibernate.dialect.Dialect; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.test.annotation.Commit; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * Provides a base set of tests of the various {@link org.alfresco.service.cmr.repository.NodeService} * implementations. *

- * To test a specific incarnation of the service, the methods {@link #getStoreService()} and - * {@link #getNodeService()} must be implemented. + * To test a specific incarnation of the service, the method + * {@link #getNodeService()} must be implemented. * * @see #nodeService * @see #rootNodeRef @@ -103,6 +104,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * @author Derek Hulley */ @SuppressWarnings("unused") /* its just a test */ +@Transactional public abstract class BaseNodeServiceTest extends BaseSpringTest { public static final String NAMESPACE = "http://www.alfresco.org/test/BaseNodeServiceTest"; @@ -113,7 +115,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest public static final QName TYPE_QNAME_TEST_CONTENT = QName.createQName(NAMESPACE, "content"); public static final QName TYPE_QNAME_TEST_MANY_PROPERTIES = QName.createQName(NAMESPACE, "many-properties"); - public static final QName TYPE_QNAME_TEST_MANY_PROPERTIES_ENCRYPTED = QName.createQName(NAMESPACE, "many-properties-encrypted"); + public static final QName TYPE_QNAME_TEST_MAFullNodeServiceTestNY_PROPERTIES_ENCRYPTED = QName.createQName(NAMESPACE, "many-properties-encrypted"); public static final QName TYPE_QNAME_TEST_MANY_ML_PROPERTIES = QName.createQName(NAMESPACE, "many-ml-properties"); public static final QName TYPE_QNAME_EXTENDED_CONTENT = QName.createQName(NAMESPACE, "extendedcontent"); public static final QName ASPECT_QNAME_TEST_TITLED = QName.createQName(NAMESPACE, "titled"); @@ -180,17 +182,13 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest protected AuthenticationComponent authenticationComponent; protected NodeService nodeService; protected MetadataEncryptor metadataEncryptor; - protected Dialect dialect; /** populated during setup */ protected NodeRef rootNodeRef; private NodeRef cat; - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() { - super.onSetUpInTransaction(); - - dialect = (Dialect) applicationContext.getBean("dialect"); metadataEncryptor = (MetadataEncryptor) applicationContext.getBean("metadataEncryptor"); transactionService = (TransactionService) applicationContext.getBean("transactionComponent"); @@ -236,8 +234,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest IntegrityChecker.setWarnInTransaction(); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() { try { @@ -247,11 +245,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest { // do nothing } - super.onTearDownInTransaction(); } - - /** * Loads the test model required for building the node graphs */ @@ -289,7 +284,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * used for this test. It must have transaction demarcation. */ protected abstract NodeService getNodeService(); - + + @Test public void testSetUp() throws Exception { assertNotNull("StoreService not set", nodeService); @@ -445,10 +441,6 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assoc = nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME_TEST_CHILDREN, qname); ret.put(qname, assoc); -// // flush and clear -// getSession().flush(); -// getSession().clear(); - // done return ret; } @@ -460,12 +452,13 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest { StoreRef storeRef = nodeService.createStore( StoreRef.PROTOCOL_WORKSPACE, - getName() + "_" + System.nanoTime()); + getClass().getName() + "_" + System.nanoTime()); assertNotNull("No reference returned", storeRef); // done return storeRef; } - + + @Test public void testCreateStore() throws Exception { StoreRef storeRef = createStore(); @@ -482,7 +475,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest QName rootType = nodeService.getType(storeRootNode); assertEquals("Store root node of incorrect type", ContentModel.TYPE_STOREROOT, rootType); } - + + @Test public void testGetStores() throws Exception { StoreRef storeRef = createStore(); @@ -493,7 +487,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // check that the store ref is present assertTrue("New store not present is list of stores", storeRefs.contains(storeRef)); } - + + @Commit + @Test public void testDeleteStore() throws Exception { StoreRef storeRef = createStore(); @@ -548,10 +544,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertEquals("Incorrect node for onDelete callback", nodeRef, onDeleteNodeRefs.get(0)); // Commit to ensure all is well - setComplete(); - endTransaction(); } - + + @Test public void testExists() throws Exception { StoreRef storeRef = createStore(); @@ -562,7 +557,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest exists = nodeService.exists(bogusRef); assertEquals("Exists failed", false, exists); } - + + @Test public void testGetRootNode() throws Exception { StoreRef storeRef = createStore(); @@ -573,7 +569,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest NodeRef rootNodeRefCheck = nodeService.getRootNode(storeRef); assertEquals("Root nodes returned different refs", rootNodeRef, rootNodeRefCheck); } - + + @Test public void testCreateNode() throws Exception { ChildAssociationRef assocRef = nodeService.createNode(rootNodeRef, @@ -587,6 +584,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertEquals("Child node type incorrect", ContentModel.TYPE_CONTAINER, checkType); } + @Test public void testCreateWithTooLongPathLocalname() throws Exception { try @@ -608,6 +606,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Tests node creation with a pre-determined {@link ContentModel#PROP_NODE_UUID uuid}. */ + @Test public void testCreateNodeWithId() throws Exception { String uuid = GUID.generate(); @@ -626,6 +625,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertEquals("Failed to create node with a chosen ID", expectedNodeRef, checkNodeRef); } + @Test public void testGetType() throws Exception { ChildAssociationRef assocRef = nodeService.createNode( @@ -638,7 +638,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest QName type = nodeService.getType(nodeRef); assertEquals("Type mismatch", ContentModel.TYPE_CONTAINER, type); } - + + @Test public void testSetType() throws Exception { NodeRef nodeRef = nodeService.createNode( @@ -715,6 +716,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * Checks that aspects can be added, removed and queried. Failure to detect * inadequate properties is also checked. */ + @Test public void testAspects() throws Exception { // create a regular base node @@ -760,7 +762,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest propertiesBefore.size(), propertiesAfter.size()); } - + + @Test public void testAspectsAddedAutomatically() throws Exception { // Add the test:titled properties @@ -831,7 +834,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertFalse("Unexpected aspect added by peer association during 'createAssociation'", nodeService.hasAspect(nodeRef, BaseNodeServiceTest.ASSOC_ASPECT_NORMAL_ASSOC)); } - + + @Test public void testAspectRemoval() throws Exception { // Create a node to add the aspect to @@ -894,7 +898,10 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Test ALFCOM-2299 + *

Needs to be committed for good measure

*/ + @Commit + @Test public void testAspectRemovalCascadeDelete() throws Exception { // Create a node to add the aspect to @@ -916,16 +923,13 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // Now remove the aspect from the source node and check that the target node was cascade-deleted nodeService.removeAspect(sourceNodeRef, ASPECT_WITH_ASSOCIATIONS); assertFalse("Child node must have been cascade-deleted", nodeService.exists(targetNodeRef)); - - // Commit for good measure - setComplete(); - endTransaction(); } private static final QName ASPECT_QNAME_TEST_RENDERED = QName.createQName(NAMESPACE, "rendered"); private static final QName ASSOC_TYPE_QNAME_TEST_RENDITION = QName.createQName(NAMESPACE, "rendition-page"); private static final QName TYPE_QNAME_TEST_RENDITION_PAGE = QName.createQName(NAMESPACE, "rendition-page"); private static final QName PROP_QNAME_TEST_RENDITION_PAGE_CONTENT = QName.createQName(NAMESPACE, "rendition-page-content"); + @Test public void testAspectWithChildAssociationsCreationAndRetrieval() throws Exception { // Create a folder. This is like the user's home folder, say. @@ -1010,7 +1014,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest QName renditionQName = QName.createQName(NAMESPACE, pageLocalName); return renditionQName; } - + + @Test public void testCreateNodeNoProperties() throws Exception { // flush to ensure that the pure JDBC query will work @@ -1021,20 +1026,14 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest NodeRef nodeRef = assocRef.getChildRef(); assertTrue(nodeService.exists(nodeRef)); } - + + @Test public void testLargeStrings() throws Exception { StringBuilder sb = new StringBuilder(2056); for (int i = 0; i < 1024; i++) { - if (dialect instanceof DB2Dialect) - { - sb.append("A"); // pending ALF-4300 - } - else - { - sb.append("\u1234"); - } + sb.append("\u1234"); } String longString = sb.toString(); int len = longString.length(); @@ -1060,6 +1059,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * @see #ASPECT_QNAME_TEST_TITLED */ + @Test public void testCreateNodeWithProperties() throws Exception { Map properties = new HashMap(5); @@ -1079,7 +1079,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertTrue("Titled aspect not present", nodeService.hasAspect(nodeRef, ASPECT_QNAME_TEST_TITLED)); } - + + @Test public void testCascadeDelete() throws Exception { // build the node and commit the node graph @@ -1105,11 +1106,10 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertFalse("n8 not cascade deleted in-transaction", nodeService.exists(n8Ref)); // commit to check - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); - startNewTransaction(); - + TestTransaction.start(); assertFalse("n6 not directly deleted", nodeService.exists(n6Ref)); assertFalse("n8 not cascade deleted", nodeService.exists(n8Ref)); assertEquals("n6 primary parent association not removed from n3", 0, countChildrenOfNode(n3Ref)); @@ -1201,7 +1201,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } } - + + @Commit + @Test public void testDelete() throws Exception { final List beforeDeleteNodeRefs = new ArrayList(5); @@ -1250,10 +1252,6 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertTrue("n3Ref delete policy not called", deletedNodeRefs.contains(n3Ref)); assertTrue("n6Ref delete policy not called", deletedNodeRefs.contains(n6Ref)); assertTrue("n8Ref delete policy not called", deletedNodeRefs.contains(n8Ref)); - - // commit to check - setComplete(); - endTransaction(); } /** @@ -1261,8 +1259,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * creating siblings of the soon to be deleted children. * * In particular, it verifies that we don't get stuck in an infinite loop. - * @throws Exception */ + @Test public void testDeleteWithBadlyBehavedOnDeletePolicies() throws Exception { final List beforeDeleteNodeRefs = new ArrayList(5); @@ -1300,9 +1298,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest fail("test has not detected orphan children"); // commit to check - setComplete(); - endTransaction(); - + TestTransaction.start(); } catch (Exception e) { @@ -1321,8 +1317,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * creating children of the soon to be deleted children. * * In particular, it verifies that we don't get stuck in an infinite loop. - * @throws Exception */ + @Test public void testDeleteWithBadlyBehavedBeforeDeletePolicies() throws Exception { final List beforeDeleteNodeRefs = new ArrayList(5); @@ -1373,12 +1369,13 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } } - private int countChildrenOfNode(NodeRef nodeRef) + protected int countChildrenOfNode(NodeRef nodeRef) { List children = nodeService.getChildAssocs(nodeRef); return children.size(); } - + + @Test public void testAddBogusChild() throws Exception { // create a bogus reference @@ -1393,7 +1390,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // expected } } - + + @Test public void testAddChild() throws Exception { NodeRef childNodeRef1 = nodeService.createNode( @@ -1436,6 +1434,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } } + @Test public void testRemoveSpecificChild() throws Exception { ChildAssociationRef pathPrimaryRef = nodeService.createNode( @@ -1484,6 +1483,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } } + @Test public void testRemoveChildPolicyFires() throws Exception { ChildAssociationRef pathPrimaryRef = nodeService.createNode( @@ -1522,7 +1522,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertTrue("Association was removed", removed); assertEquals("The BeforeDeleteChildAssociationPolicy must fire on removeChildAssociation", pathCRef, beforeDeletePolicy.childRef); } - + + @Test public void testRemoveChildByRef() throws Exception { NodeRef parentRef = nodeService.createNode( @@ -1556,7 +1557,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest TEST_ONE, TEST_TWO } - + + @Test public void testProperties() throws Exception { // create a node to play with @@ -1585,10 +1587,6 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // set an enum property nodeService.setProperty(nodeRef, qnameProperty4, TestEnum.TEST_ONE); - // force a flush - getSession().flush(); - getSession().clear(); - // now get them back Map checkMap = nodeService.getProperties(nodeRef); assertNotNull("Properties were not set/retrieved", checkMap); @@ -1631,7 +1629,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest fail("Null property values are allowed in the map"); } } - + + @Test public void testAddProperties() throws Exception { Map properties = nodeService.getProperties(rootNodeRef); @@ -1651,7 +1650,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertEquals("Title", checkProperties.get(PROP_QNAME_TEST_TITLE)); assertEquals("Description", checkProperties.get(PROP_QNAME_TEST_DESCRIPTION)); } - + + @Test public void testDefaultPropertyOverride_AddAspect() throws Exception { Serializable nullValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2); @@ -1664,7 +1664,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest Serializable checkValue = nodeService.getProperty(rootNodeRef, PROP_QNAME_PROP2); assertEquals("Property should not be defaulted", valueOverride, checkValue); } - + + @Test public void testDefaultPropertyOverride_CreateNode() throws Exception { NodeRef nodeRef = nodeService.createNode( @@ -1688,7 +1689,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1); assertEquals("Property should not be defaulted", valueOverride, checkValue); } - + + @Test public void testDefaultPropertyOverride_SpecializeWithoutProperty() throws Exception { NodeRef nodeRef = nodeService.createNode( @@ -1706,7 +1708,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1); assertEquals("Property should be defaulted", DEFAULT_VALUE, checkValue); } - + + @Test public void testDefaultPropertyOverride_SpecializeWithProperty() throws Exception { String valueOverride = "VALUE_OVERRIDE"; @@ -1727,7 +1730,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest checkValue = nodeService.getProperty(nodeRef, PROP_QNAME_PROP1); assertEquals("Property should *still* not be defaulted", valueOverride, checkValue); } - + + @Test public void testRemoveProperty() throws Exception { Map properties = nodeService.getProperties(rootNodeRef); @@ -1770,11 +1774,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * Makes a read-only transaction and then looks for a property using a non-existent QName. * The QName persistence must not lazily create QNameEntity instances for queries. */ + @Test public void testGetUnknownProperty() throws Exception { // commit to keep the root node - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); RetryingTransactionCallback createCallback = new RetryingTransactionCallback() { @@ -1806,6 +1811,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Ensures that the type you get out of a d:any property is the type that you put in. */ + @Test public void testSerializableProperties() throws Exception { ContentData contentData = new ContentData(null, null, 0L, null); @@ -1822,7 +1828,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest ContentModel.TYPE_CONTAINER, properties).getChildRef(); // persist - flushAndClear(); +// flushAndClear(); // get the properties back Map checkProperties = nodeService.getProperties(nodeRef); @@ -1831,7 +1837,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertTrue("Serialization/deserialization of ContentData failed", checkPropertyContentData instanceof ContentData); assertTrue("Serialization/deserialization failed", checkPropertyQname instanceof QName); } - + + @Test public void testEncryptionAndDecryptionOfProperties() { QName valueToEncrypt = PROP_QNAME_CONTENT_VALUE; @@ -1877,6 +1884,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Check that d:encrypted properties work correctly. */ + @Test public void testEncryptedProperties() throws Exception { QName property = PROP_QNAME_CONTENT_VALUE; @@ -1897,11 +1905,10 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest ContentModel.TYPE_CONTAINER, properties).getChildRef(); // persist - setComplete(); - endTransaction(); - - startNewTransaction(); - + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); + // get the properties back Map checkProperties = nodeService.getProperties(nodeRef); checkProperty = checkProperties.get(PROP_QNAME_ENCRYPTED_VALUE); @@ -1948,11 +1955,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // Expected } } - + + @Test @SuppressWarnings("unchecked") public void testMultiProp() throws Exception { - QName undeclaredPropQName = QName.createQName(NAMESPACE, getName()); + QName undeclaredPropQName = QName.createQName(NAMESPACE, getClass().getName()); // create node NodeRef nodeRef = nodeService.createNode( rootNodeRef, @@ -1975,13 +1983,11 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest nodeService.setProperty(nodeRef, undeclaredPropQName, values); // commit as we will be breaking the transaction in the next test - setComplete(); - endTransaction(); - - UserTransaction txn = transactionService.getUserTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); try { - txn.begin(); // this should fail as we are passing multiple values into a non-any that is multiple=false nodeService.setProperty(nodeRef, PROP_QNAME_STRING_PROP_SINGLE, values); } @@ -1991,13 +1997,13 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } finally { - try { txn.rollback(); } catch (Throwable e) {} + TestTransaction.flagForRollback(); + TestTransaction.end(); } - - txn = transactionService.getUserTransaction(); + + TestTransaction.start(); try { - txn.begin(); // Check that multi-valued d:mltext can be collections of MLText values.clear(); values.add(new MLText("ABC")); @@ -2047,7 +2053,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } finally { - try { txn.rollback(); } catch (Throwable e) {} + TestTransaction.flagForRollback(); + TestTransaction.end(); } } @@ -2093,8 +2100,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Check that properties go in and come out in the correct format. - * @see #getCheckPropertyValues(Map) */ + @Test @SuppressWarnings("unchecked") public void testPropertyTypes() throws Exception { @@ -2162,13 +2169,16 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest nodeService.setProperty(nodeRef, PROP_QNAME_FLOAT_VALUE, Float.POSITIVE_INFINITY); assertEquals("Float.POSITIVE_INFINITY failed", Float.POSITIVE_INFINITY, nodeService.getProperty(nodeRef, PROP_QNAME_FLOAT_VALUE)); } - + + @Test public void testPropertySpecialNumbers() throws Exception { Map properties = new HashMap(17); properties.put(PROP_QNAME_DOUBLE_VALUE, Double.NaN); } - + + @Commit + @Test public void testPropertyLocaleBehaviour() throws Exception { Map properties = new HashMap(17); @@ -2245,14 +2255,12 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // Check the properties again checkProperties = nodeService.getProperties(nodeRef); checkProperties(checkProperties, expectedProperties); - - setComplete(); - endTransaction(); } /** * Checks that empty collections can be persisted */ + @Test @SuppressWarnings("unchecked") public void testEmptyCollections() throws Exception { @@ -2284,6 +2292,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Checks that large collections can be persisted */ + @Test @SuppressWarnings("unchecked") public void testBigCollections() throws Exception { @@ -2345,7 +2354,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertNull("Null property should stay null", checkNullCollection); } } - + + @Test @SuppressWarnings("unchecked") public void testMultiValueMLTextProperties() throws Exception { @@ -2374,6 +2384,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Ensures that d:any types are handled correctly when adding values */ + @Test public void testMultivaluedSerializable() throws Exception { ArrayList listProp = new ArrayList(); @@ -2409,6 +2420,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * Checks that the {@link ContentModel#ASPECT_REFERENCEABLE referencable} properties * are present */ + @Test public void testGetReferencableProperties() throws Exception { // check individual property retrieval @@ -2433,7 +2445,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertTrue("Node UUID property not present in map", properties.containsKey(ContentModel.PROP_NODE_UUID)); assertTrue("Node DB ID property not present in map", properties.containsKey(ContentModel.PROP_NODE_DBID)); } - + + @Test public void testReferencePropertySet() throws Exception { Serializable nodeDbId = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID); @@ -2442,7 +2455,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest Serializable nodeDbIdCheck = nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID); assertEquals("Cannot set Node DB ID", nodeDbId, nodeDbIdCheck); } - + + @Test public void testResidual() throws Exception { // Add the residual aspect @@ -2462,11 +2476,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // Map propsCheck = nodeService.getProperties(rootNodeRef); // assertEquals("Residual properties not present and equal. ", props, propsCheck); // assertTrue("Expect residual aspect to be present.", nodeService.hasAspect(rootNodeRef, ASPECT_RESIDUAL)); -// -// setComplete(); -// endTransaction(); } - + + @Test public void testGetParentAssocs() throws Exception { Map assocRefs = buildNodeGraph(); @@ -2502,7 +2514,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest ASSOC_TYPE_QNAME_TEST_CHILDREN, RegexQNamePattern.MATCH_ALL); } - + + @Test public void testGetChildAssocs() throws Exception { Map assocRefs = buildNodeGraph(); @@ -2552,7 +2565,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest 1, false); assertEquals("Incorrect number of children", 1, childAssocRefsByTypeQName.size()); } - + + @Commit + @Test public void testDuplicateChildAssocCleanup() throws Exception { Map assocRefs = buildNodeGraph(); @@ -2575,11 +2590,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertEquals("Expected duplicates", 2, dupAssocs.size()); // Now delete the specific association nodeService.removeChildAssociation(dup1); - - setComplete(); - endTransaction(); } - + + @Test public void testGetChildAssocsByChildType() throws Exception { /* @@ -2630,6 +2643,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } } + @Test public void testMoveNode() throws Exception { Map assocRefs = buildNodeGraph(); @@ -2726,7 +2740,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // done return assocRef; } - + + @Test public void testDuplicateAssociationDetection() throws Exception { AssociationRef assocRef = createAssociation(); @@ -2744,7 +2759,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // expected } } - + + @Test public void testCreateAndRemoveAssociation() throws Exception { AssociationRef assocRef = createAssociation(); @@ -2780,7 +2796,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assoc.getTypeQName()); } } - + + @Test public void testGetTargetAssocs() throws Exception { AssociationRef assocRef = createAssociation(); @@ -2798,7 +2815,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertNotNull("Association does not have ID", targetAssoc.getId()); } } - + + @Commit + @Test public void testTargetAssoc_Ordering() throws Exception { AssociationRef assocRef = createAssociation(); @@ -2859,9 +2878,6 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest // Remove one of the targets targetNodeRefs.remove(0); } - - setComplete(); - endTransaction(); } /** @@ -2870,6 +2886,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * * @throws Exception */ + @Test public void testGetTargetAssocsByPropertyValue() throws Exception { // Create test data. @@ -2936,6 +2953,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest } } + @Test public void testGetSourceAssocs() throws Exception { AssociationRef assocRef = createAssociation(); @@ -2957,6 +2975,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * @see #buildNodeGraph() */ + @Test public void testGetPath() throws Exception { Map assocRefs = buildNodeGraph(); @@ -2972,6 +2991,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * @see #buildNodeGraph() */ + @Test public void testGetPaths() throws Exception { Map assocRefs = buildNodeGraph(); @@ -3029,7 +3049,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest throw e; } } - + + @Test public void testPrimaryPathCascadeDelete() throws Exception { Map assocRefs = buildNodeGraph(); @@ -3049,6 +3070,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * * @throws Exception */ + @Test public void testDefaultValues() throws Exception { NodeRef nodeRef = nodeService.createNode( @@ -3076,7 +3098,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertEquals(NOT_DEFAULT_VALUE, this.nodeService.getProperty(nodeRef2, PROP_QNAME_PROP2)); } - + + @Test public void testMandatoryAspects() { NodeRef nodeRef = nodeService.createNode( @@ -3153,6 +3176,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Check that the duplicate child name is detected and thrown correctly */ + @Test public void testDuplicateCatch() throws Exception { NodeRef parentRef = nodeService.createNode( @@ -3208,9 +3232,10 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * Create some nodes that have the same cm:name but use associations that don't * enforce uniqueness. */ + @Test public void testNonDuplicateAssocsWithSuppliedName() throws Throwable { - Map properties = Collections.singletonMap(ContentModel.PROP_NAME, (Serializable) getName()); + Map properties = Collections.singletonMap(ContentModel.PROP_NAME, (Serializable) getClass().getName()); NodeRef parentRef = nodeService.createNode( rootNodeRef, ASSOC_TYPE_QNAME_TEST_CHILDREN, @@ -3235,6 +3260,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest *

* ALF-5001: cm:name uniqueness check can fail if the property is not set */ + @Test public void testDuplicateAssocsWithoutSuppliedName() throws Throwable { Map properties = Collections.emptyMap(); @@ -3269,6 +3295,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest * Checks that the unique constraint doesn't break delete and create within the same * transaction. */ + @Test public void testDeleteAndAddSameName() throws Exception { NodeRef parentRef = nodeService.createNode( @@ -3297,7 +3324,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest props); // there should not be any failure when doing this in the same transaction } - + + @Test public void testGetByName() throws Exception { NodeRef parentRef = nodeService.createNode( @@ -3352,7 +3380,9 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertTrue("Expected result not included", childAssocRefs.contains(pathDefRef)); assertTrue("Expected result not included", childAssocRefs.contains(pathKlmRef)); } - + + @Commit + @Test public void testLocalizedAspect() throws Exception { nodeService.addAspect( @@ -3360,12 +3390,11 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest ContentModel.ASPECT_LOCALIZED, Collections.singletonMap(ContentModel.PROP_LOCALE, Locale.CANADA_FRENCH)); // commit to check - setComplete(); - endTransaction(); } static boolean behaviourExecuted = false; + @Test public void testAR1303() throws Exception { PolicyComponent policyComponent = (PolicyComponent) this.applicationContext.getBean("policyComponent"); @@ -3415,6 +3444,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Checks that unconvertable property values cannot be persisted. */ + @Test public void testAR782() throws Exception { Map properties = nodeService.getProperties(rootNodeRef); @@ -3446,6 +3476,7 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest /** * Check that Serializable properties do not remain connected to the L1 session */ + @Test public void testAR1414() throws Exception { AR1414Blob blob = new AR1414Blob(); @@ -3459,7 +3490,8 @@ public abstract class BaseNodeServiceTest extends BaseSpringTest assertNotNull(checkBlob); assertEquals("Blob was modified while persisted", 0, checkBlob.i); } - + + @Test public void testGetNodeRefById() { Long nodeId = (Long) nodeService.getProperty(rootNodeRef, ContentModel.PROP_NODE_DBID); diff --git a/src/test/java/org/alfresco/repo/node/FullNodeServiceTest.java b/src/test/java/org/alfresco/repo/node/FullNodeServiceTest.java index 953af200b8..654eb80a17 100644 --- a/src/test/java/org/alfresco/repo/node/FullNodeServiceTest.java +++ b/src/test/java/org/alfresco/repo/node/FullNodeServiceTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.node; import java.io.Serializable; @@ -34,9 +34,6 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; - -import javax.transaction.UserTransaction; - import org.alfresco.service.cmr.dictionary.DictionaryException; import org.alfresco.service.cmr.repository.MLText; import org.alfresco.service.cmr.repository.NodeRef; @@ -44,8 +41,13 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.namespace.QName; import org.alfresco.test_category.OwnJVMTestsCategory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * Tests the fully-intercepted version of the NodeService @@ -54,38 +56,24 @@ import org.springframework.extensions.surf.util.I18NUtil; * * @author Derek Hulley */ +@Transactional @Category(OwnJVMTestsCategory.class) public class FullNodeServiceTest extends BaseNodeServiceTest -{ - private Locale contentLocaleToRestore; - private Locale localeToRestore; +{ + private static Locale contentLocaleToRestore; + private static Locale localeToRestore; protected NodeService getNodeService() { return (NodeService) applicationContext.getBean("NodeService"); } - - - @Override - protected void onSetUp() throws Exception - { - super.onSetUp(); - contentLocaleToRestore = I18NUtil.getContentLocale(); - localeToRestore = I18NUtil.getLocale(); - } - - @Override - protected void onTearDown() throws Exception - { - super.onTearDown(); - I18NUtil.setContentLocale(contentLocaleToRestore); - I18NUtil.setLocale(localeToRestore); - } - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() { - super.onSetUpInTransaction(); + super.before(); + contentLocaleToRestore = I18NUtil.getContentLocale(); + localeToRestore = I18NUtil.getLocale(); Locale.setDefault(Locale.ENGLISH); MLPropertyInterceptor.setMLAware(false); } @@ -93,13 +81,15 @@ public class FullNodeServiceTest extends BaseNodeServiceTest /* (non-Javadoc) * @see org.alfresco.repo.node.BaseNodeServiceTest#onTearDownInTransaction() */ - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() { - super.onTearDownInTransaction(); - I18NUtil.setContentLocale(null); + super.after(); + I18NUtil.setContentLocale(contentLocaleToRestore); + I18NUtil.setLocale(localeToRestore); } + @Test public void testMLTextValues() throws Exception { // Set the server default locale @@ -140,6 +130,7 @@ public class FullNodeServiceTest extends BaseNodeServiceTest * with a locale of en_US will result in the addition of the en_US text rather than a true update (they're both * English, and using two slightly differently configured browsers in this way leads to confusion). */ + @Test public void testMLTextUpdatedForCorrectLanguage() throws Exception { Locale.setDefault(Locale.UK); @@ -196,13 +187,14 @@ public class FullNodeServiceTest extends BaseNodeServiceTest ((MLText) textValue).getClosestValue(Locale.UK)); assertEquals("fr_FR String", ((MLText) textValue).getValue(Locale.FRANCE)); } - + + @Test @SuppressWarnings("unchecked") public void testMLTextCollectionUpdatedForCorrectLanguage() { - Locale.setDefault(Locale.UK); - I18NUtil.setContentLocale(Locale.UK); - I18NUtil.setLocale(Locale.UK); + Locale.setDefault(Locale.UK); + I18NUtil.setContentLocale(Locale.UK); + I18NUtil.setLocale(Locale.UK); MLPropertyInterceptor.setMLAware(true); @@ -267,7 +259,8 @@ public class FullNodeServiceTest extends BaseNodeServiceTest assertEquals("entirely new text value should be added", 1, mlText.size()); assertEquals("text 4 added using en_US", mlText.getValue(Locale.ENGLISH)); } - + + @Test public void testLongMLTextValues() throws Exception { StringBuilder sb = new StringBuilder(); @@ -296,7 +289,8 @@ public class FullNodeServiceTest extends BaseNodeServiceTest BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE, mlTextProperty); } - + + @Test public void testNullMLText() throws Exception { // Set an ML value to null @@ -333,6 +327,7 @@ public class FullNodeServiceTest extends BaseNodeServiceTest } } + @Test public void testMLValuesOnCreate() throws Exception { Map properties = new HashMap(); @@ -345,7 +340,7 @@ public class FullNodeServiceTest extends BaseNodeServiceTest NodeRef nodeRef = nodeService.createNode( rootNodeRef, BaseNodeServiceTest.ASSOC_TYPE_QNAME_TEST_CHILDREN, - QName.createQName(BaseNodeServiceTest.NAMESPACE, getName()), + QName.createQName(BaseNodeServiceTest.NAMESPACE, getClass().getName()), BaseNodeServiceTest.TYPE_QNAME_TEST_MANY_PROPERTIES, properties).getChildRef(); // Now switch to English @@ -368,6 +363,7 @@ public class FullNodeServiceTest extends BaseNodeServiceTest nodeService.getProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE)); } + @Test public void testMLValuesOnAddAspect() throws Exception { Map properties = new HashMap(); @@ -402,6 +398,7 @@ public class FullNodeServiceTest extends BaseNodeServiceTest nodeService.getProperty(nodeRef, BaseNodeServiceTest.PROP_QNAME_ML_TEXT_VALUE)); } + @Test public void testMLValuesOnAddProperties() throws Exception { Map properties = new HashMap(); @@ -444,11 +441,12 @@ public class FullNodeServiceTest extends BaseNodeServiceTest String strValue = mlTextValue.getDefaultValue(); checkProperties.put(PROP_QNAME_ML_TEXT_VALUE, strValue); } - + + @Test @SuppressWarnings("unchecked") public void testMultiProp() throws Exception { - QName undeclaredPropQName = QName.createQName(NAMESPACE, getName()); + QName undeclaredPropQName = QName.createQName(NAMESPACE, getClass().getName()); // create node NodeRef nodeRef = nodeService.createNode( rootNodeRef, @@ -471,13 +469,12 @@ public class FullNodeServiceTest extends BaseNodeServiceTest nodeService.setProperty(nodeRef, undeclaredPropQName, values); // commit as we will be breaking the transaction in the next test - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); - UserTransaction txn = transactionService.getUserTransaction(); try { - txn.begin(); // this should fail as we are passing multiple values into a non-any that is multiple=false nodeService.setProperty(nodeRef, PROP_QNAME_STRING_PROP_SINGLE, values); } @@ -487,13 +484,13 @@ public class FullNodeServiceTest extends BaseNodeServiceTest } finally { - try { txn.rollback(); } catch (Throwable e) {} + TestTransaction.flagForRollback(); + TestTransaction.end(); } - - txn = transactionService.getUserTransaction(); + + TestTransaction.start(); try { - txn.begin(); // Check that multi-valued d:mltext can be collections of MLText values.clear(); values.add(new MLText("ABC")); @@ -539,10 +536,12 @@ public class FullNodeServiceTest extends BaseNodeServiceTest } finally { - try { txn.rollback(); } catch (Throwable e) {} + TestTransaction.flagForRollback(); + TestTransaction.end(); } } - + + @Test @SuppressWarnings("unchecked") public void testMultiValueMLTextProperties() throws Exception { diff --git a/src/test/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptorTest.java b/src/test/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptorTest.java index c58bd0b2f7..9810e6e5e1 100644 --- a/src/test/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptorTest.java +++ b/src/test/java/org/alfresco/repo/node/NodeRefPropertyMethodInterceptorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.node; import java.io.InputStream; @@ -40,11 +40,15 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; @Category(BaseSpringTestsCategory.class) +@Transactional public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest { @@ -91,10 +95,9 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest super(); } - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); mlAwareNodeService = (NodeService) applicationContext.getBean("mlAwareNodeService"); nodeService = (NodeService) applicationContext.getBean("nodeService"); dictionaryDAO = (DictionaryDAO) applicationContext.getBean("dictionaryDAO"); @@ -114,8 +117,8 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { try { @@ -125,9 +128,9 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest { // do nothing } - super.onTearDownInTransaction(); } + @Test public void testOnRead() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -416,6 +419,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest } + @Test public void testAddAspectNull() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -449,6 +453,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testAddAspectNullValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -491,6 +496,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testAddAspectInvalidValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -536,6 +542,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testAddAspectValidNode() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -578,6 +585,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNotNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testAddAspectValidCategory() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -620,6 +628,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNotNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testAddAspectEmptyList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -661,6 +670,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(0, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testAddAspectInvalidList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -705,6 +715,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(0, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testAddAspectNodeRefList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -747,6 +758,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testAddAspectCatList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -789,6 +801,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testAddAspectMixedList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -833,6 +846,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(2, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testCreateNodeNull() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -858,6 +872,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testCreateNodeNullValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -889,6 +904,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testCreateNodeInvalidValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -920,6 +936,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNotNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testCreateNodeNodeRefValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -951,6 +968,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNotNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testCreateNodeCatValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -982,6 +1000,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNotNull(nodeService.getProperties(n1).get(aspectNoderefsProp)); } + @Test public void testCreateEmptyListValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1013,6 +1032,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(0, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testCreateInvalidListValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1045,6 +1065,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(0, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testCreateNodeRefListValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1077,6 +1098,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testCreateCatListValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1109,6 +1131,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testCreateMixedListValues() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1143,6 +1166,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(2, ((Collection) nodeService.getProperties(n1).get(aspectNoderefsProp)).size()); } + @Test public void testSetPropertyNull() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1190,6 +1214,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(typeNoderefsProp)); } + @Test public void testSetPropertyInvalid() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1237,6 +1262,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(typeNoderefsProp)); } + @Test public void testSetPropertyNodeRef() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1288,6 +1314,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertyCat() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1344,6 +1371,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest } + @Test public void testSetPropertyEmptyList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1383,6 +1411,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(0, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertyNodeRefList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1423,6 +1452,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertyCatList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1464,6 +1494,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(2, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertyMixedList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1506,6 +1537,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(2, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertiesNull() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1556,6 +1588,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(typeNoderefsProp)); } + @Test public void testSetPropertiesInvalid() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1606,6 +1639,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertNull(nodeService.getProperties(n1).get(typeNoderefsProp)); } + @Test public void testSetPropertiesNodeRef() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1660,6 +1694,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertiesCat() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1719,6 +1754,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest } + @Test public void testSetPropertiesEmptyList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1761,6 +1797,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(0, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertiesNodeRefList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1804,6 +1841,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertiesCatList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); @@ -1847,6 +1885,7 @@ public class NodeRefPropertyMethodInterceptorTest extends BaseSpringTest assertEquals(1, ((Collection) nodeService.getProperties(n1).get(typeNoderefsProp)).size()); } + @Test public void testSetPropertiesMixedList() { NodeRef invalidNodeRef = new NodeRef(rootNodeRef.getStoreRef(), "InvalidNode"); diff --git a/src/test/java/org/alfresco/repo/node/NodeServiceTest.java b/src/test/java/org/alfresco/repo/node/NodeServiceTest.java index 591f8b11b6..71c02371b3 100644 --- a/src/test/java/org/alfresco/repo/node/NodeServiceTest.java +++ b/src/test/java/org/alfresco/repo/node/NodeServiceTest.java @@ -51,6 +51,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.cache.TransactionalCache; import org.alfresco.repo.cache.TransactionalCache.ValueHolder; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.repo.domain.node.Node; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.node.NodeEntity; @@ -97,7 +98,6 @@ import org.alfresco.util.PropertyMap; import org.alfresco.util.test.junitrules.ApplicationContextInit; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.dialect.Dialect; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; diff --git a/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplPropagationTest.java b/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplPropagationTest.java index 2fa12a9dff..7835a5ba36 100644 --- a/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplPropagationTest.java +++ b/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplPropagationTest.java @@ -35,6 +35,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.repo.dictionary.DictionaryComponent; import org.alfresco.repo.dictionary.DictionaryDAO; import org.alfresco.repo.dictionary.M2Model; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.node.BaseNodeServiceTest; import org.alfresco.repo.security.authentication.AuthenticationComponent; @@ -48,9 +49,14 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.testing.category.DBTests; -import org.hibernate.dialect.Dialect; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; +import org.springframework.test.annotation.Commit; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * @see org.alfresco.repo.node.db.DbNodeServiceImpl#propagateTimeStamps(ChildAssociationRef) @@ -58,6 +64,7 @@ import org.springframework.context.ApplicationContext; * @author sergey.shcherbovich */ @Category(DBTests.class) +@Transactional public class DbNodeServiceImplPropagationTest extends BaseSpringTest { private TransactionService txnService; @@ -69,10 +76,9 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest private UserTransaction txn = null; private Dialect dialect; - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); txnService = (TransactionService) applicationContext.getBean("transactionComponent"); nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO"); dialect = (Dialect) applicationContext.getBean("dialect"); @@ -99,11 +105,11 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest dictionary.setDictionaryDAO(dictionaryDao); dictionaryService = loadModel(applicationContext); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { try { @@ -113,7 +119,6 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest { // do nothing } - super.onTearDownInTransaction(); } /** @@ -145,6 +150,8 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest * are added or removed. */ @SuppressWarnings("deprecation") + @Commit + @Test public void testAuditablePropagation() throws Exception { String fullyAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser(); @@ -176,16 +183,15 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest QName typeBefore = nodeService.getType(n2Ref); // Get onto our own transactions - setComplete(); - endTransaction(); - txn = restartAuditableTxn(txn); + TestTransaction.flagForCommit(); + restartAuditableTxn(); // Create a non-auditable child, parent won't update NodeRef naC = nodeService.createNode(n2Ref, ASSOC_NOT_AUDITABLE, QName.createQName("not-auditable"), TYPE_NOT_AUDITABLE).getChildRef(); logger.debug("Created non-auditable child " + naC); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); // Parent hasn't been updated assertNull(nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIED)); @@ -196,7 +202,7 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest QName.createQName("is-auditable"), TYPE_AUDITABLE).getChildRef(); nodeService.addAspect(adC, ContentModel.ASPECT_AUDITABLE, null); logger.debug("Created auditable child " + naC + " of non-auditable parent " + n2Ref); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); // Parent hasn't been updated, but auditable child has assertNull(nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIED)); @@ -207,11 +213,11 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest // Make the parent auditable, and give it a special modified by nodeService.addAspect(n2Ref, ContentModel.ASPECT_AUDITABLE, null); nodeService.setType(n2Ref, ContentModel.TYPE_FOLDER); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); Date modified = new Date(); nodeDAO.setModifiedProperties(n2Id, modified, "TestModifier"); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); assertEquals(modified.getTime(), ((Date)nodeDAO.getNodeProperty(n2Id, ContentModel.PROP_MODIFIED)).getTime()); assertEquals("TestModifier", nodeDAO.getNodeProperty(n2Id, ContentModel.PROP_MODIFIER)); @@ -220,7 +226,7 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest logger.debug("Deleting non-auditable child " + naC + " of auditable parent " + n2Ref); nodeService.addAspect(naC, ContentModel.ASPECT_TEMPORARY, null); nodeService.deleteNode(naC); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); assertEquals(modified.getTime(), ((Date)nodeDAO.getNodeProperty(n2Id, ContentModel.PROP_MODIFIED)).getTime()); assertEquals("TestModifier", nodeDAO.getNodeProperty(n2Id, ContentModel.PROP_MODIFIER)); @@ -230,7 +236,7 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest QName.createQName("is-auditable"), TYPE_AUDITABLE).getChildRef(); final long adCId = nodeDAO.getNodePair(adC).getFirst(); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); modifiedAt = (Date)nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIED); assertNotNull(modifiedAt); assertEquals((double)new Date().getTime(), (double)modifiedAt.getTime(), 10000d); @@ -239,14 +245,14 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest // Set well-known modified details on both nodes nodeDAO.setModifiedProperties(n2Id, new Date(Integer.MIN_VALUE), "TestModifierPrnt"); nodeDAO.setModifiedProperties(adCId, new Date(Integer.MIN_VALUE), "TestModifierChld"); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); // Now delete the auditable child // The parent's modified date will change, but not the modified by, as the child // has been deleted so the child's modified-by can't be read logger.debug("Deleting auditable child " + adC + " of auditable parent " + n2Ref); nodeService.deleteNode(adC); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); // Parent's date was updated, but not the modifier, since child was deleted // which means the child's modifier wasn't available to read @@ -258,7 +264,7 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest // Set well-known modified detail on our parent again modified = new Date(); nodeDAO.setModifiedProperties(n2Id, modified, "ModOn2"); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); assertEquals("ModOn2", nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIER)); // Add two auditable children, both with special modifiers @@ -277,7 +283,7 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest // Ensure the parent is "old", so that the propagation can take place nodeDAO.setModifiedProperties(n2Id, new Date(Integer.MIN_VALUE), "ModOn2"); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); // Check that only the first reached the parent assertNotNull(nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIED)); @@ -297,7 +303,7 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest NodeRef ac3 = nodeService.createNode(n2Ref, ASSOC_AUDITABLE, QName.createQName("is-auditable-3"), TYPE_AUDITABLE).getChildRef(); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); assertEquals("TestModifierPrnt", nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIER)); assertEquals(fullyAuthenticatedUser, nodeService.getProperty(ac3, ContentModel.PROP_MODIFIER)); @@ -310,7 +316,7 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest // Parent-Child association needs to be a suitable kind to trigger nodeService.setType(n2Ref, typeBefore); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); try { @@ -323,14 +329,14 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest modified = new Date(); nodeDAO.setModifiedProperties(n2Id, modified, "TestModifier"); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); assertEquals("TestModifier", nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIER)); NodeRef ac4 = nodeService.createNode(n2Ref, ASSOC_NOT_AUDITABLE, QName.createQName("is-auditable-4"), TYPE_AUDITABLE).getChildRef(); - txn = restartAuditableTxn(txn); + restartAuditableTxn(); assertEquals("TestModifier", nodeService.getProperty(n2Ref, ContentModel.PROP_MODIFIER)); assertEquals(fullyAuthenticatedUser, nodeService.getProperty(ac4, ContentModel.PROP_MODIFIER)); @@ -339,21 +345,11 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest assertEquals(modified.getTime(), modifiedAt.getTime()); modifiedAt = (Date)nodeService.getProperty(ac4, ContentModel.PROP_MODIFIED); assertEquals((double)new Date().getTime(), (double)modifiedAt.getTime(), 3000d); - - setComplete(); - endTransaction(); - - startNewTransaction(); - txn.commit(); - } - private UserTransaction restartAuditableTxn(UserTransaction txn) throws Exception + private void restartAuditableTxn() throws Exception { - if (txn != null) - txn.commit(); - txn = txnService.getUserTransaction(); - txn.begin(); + TestTransaction.end(); // Wait long enough that AuditablePropertiesEntity.setAuditModified // will recognize subsequent changes as needing new audit entries @@ -364,8 +360,6 @@ public class DbNodeServiceImplPropagationTest extends BaseSpringTest catch(InterruptedException e) { } - - return txn; + TestTransaction.start(); } - } diff --git a/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java b/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java index 600006ff18..1000ca1318 100644 --- a/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/node/db/DbNodeServiceImplTest.java @@ -37,7 +37,9 @@ import java.util.Set; import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoMySQLClusterNDBDialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLClusterNDBDialect; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.node.NodeDAO.ChildAssocRefQueryCallback; import org.alfresco.repo.domain.node.Transaction; @@ -63,12 +65,13 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.Pair; import org.alfresco.util.testing.category.DBTests; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.MySQLInnoDBDialect; +import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * @see org.alfresco.repo.node.db.DbNodeServiceImpl @@ -76,6 +79,7 @@ import org.springframework.extensions.surf.util.I18NUtil; * @author Derek Hulley */ @SuppressWarnings("unused") +@Transactional @Category({OwnJVMTestsCategory.class, DBTests.class}) public class DbNodeServiceImplTest extends BaseNodeServiceTest { @@ -91,10 +95,10 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest return (NodeService) applicationContext.getBean("dbNodeService"); } - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() { - super.onSetUpInTransaction(); + super.before(); txnService = (TransactionService) applicationContext.getBean("transactionComponent"); nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO"); dictionaryService = (DictionaryService) applicationContext.getBean("dictionaryService"); @@ -105,9 +109,9 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest */ public void testCallWithoutTxn() { - setComplete(); - endTransaction(); - + TestTransaction.flagForCommit(); + TestTransaction.end(); + nodeService.getAllRootNodes(rootNodeRef.getStoreRef()); } @@ -117,9 +121,9 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest @SuppressWarnings("deprecation") public void testNodeCleanupRegistry() throws Exception { + TestTransaction.flagForCommit(); + TestTransaction.end(); // REPO-2963: this test takes a long time in order to pass on a clean DB. - setComplete(); - endTransaction(); NodeCleanupRegistry cleanupRegistry = (NodeCleanupRegistry) applicationContext.getBean("nodeCleanupRegistry"); cleanupRegistry.doClean(); } @@ -144,8 +148,8 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest assertEquals("Should not have found a written txn", 0L, currentTxnCommitTime); // Now commit - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // Now check again. The transaction time must be greater than the last time that // the listener wrote through. @@ -215,8 +219,8 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest { Map assocRefs = buildNodeGraph(); // commit results - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); UserTransaction userTransaction = txnService.getUserTransaction(); @@ -267,8 +271,8 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest final Map properties = nodeService.getProperties(n6Ref); // commit results - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // change property - check status RetryingTransactionCallback changePropertiesWork = new RetryingTransactionCallback() @@ -567,8 +571,8 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest 1, nodeService.getTargetAssocs(sourceNodeRef, RegexQNamePattern.MATCH_ALL).size()); // Force a commit here - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // start another transaction to remove the aspect UserTransaction txn = txnService.getUserTransaction(); @@ -725,12 +729,12 @@ public class DbNodeServiceImplTest extends BaseNodeServiceTest @SuppressWarnings("deprecation") public void testMySQLInnoDBNodeStringLengthWorker() throws Exception { - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // Skip of the dialect if not MySQL (also skip for MySQL Cluster NDB) Dialect dialect = (Dialect) applicationContext.getBean("dialect"); - if ((dialect instanceof AlfrescoMySQLClusterNDBDialect) || (! (dialect instanceof MySQLInnoDBDialect))) + if ((dialect instanceof MySQLClusterNDBDialect) || (! (dialect instanceof MySQLInnoDBDialect))) { return; } diff --git a/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java b/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java index 3df4480bb8..e764e7f8f0 100644 --- a/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java +++ b/src/test/java/org/alfresco/repo/rendition/RenditionServiceIntegrationTest.java @@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit; import javax.imageio.ImageIO; -import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.model.RenditionModel; import org.alfresco.repo.action.RuntimeActionService; @@ -91,10 +90,16 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; +import org.alfresco.util.GUID; import org.alfresco.util.Pair; -import org.alfresco.util.testing.category.LuceneTests; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * @author Neil McErlean @@ -103,6 +108,7 @@ import org.springframework.context.ConfigurableApplicationContext; */ @SuppressWarnings("deprecation") @Category({OwnJVMTestsCategory.class}) +@Transactional public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest { private static final String WHITE = "ffffff"; @@ -127,10 +133,10 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest private ScriptService scriptService; private RetryingTransactionHelper transactionHelper; - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.namespaceService= (NamespaceService) this.applicationContext.getBean("namespaceService"); this.renditionService = (RenditionService) this.applicationContext.getBean("renditionService"); this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper"); @@ -148,10 +154,10 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest NodeRef companyHome = this.repositoryHelper.getCompanyHome(); // Create the test folder used for these tests - this.testTargetFolder = createNode(companyHome, "testFolder", ContentModel.TYPE_FOLDER); + this.testTargetFolder = createNode(companyHome, "testFolder-" + GUID.generate(), ContentModel.TYPE_FOLDER); // Create the node used as a content supplier for tests - this.nodeWithDocContent = createContentNode(companyHome, "testDocContent"); + this.nodeWithDocContent = createContentNode(companyHome, "testDocContent-" + GUID.generate()); // Put some known PDF content in it. File pdfQuickFile = AbstractContentTransformerTest.loadQuickTestFile("pdf"); @@ -172,7 +178,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest // Create a test image - this.nodeWithImageContent = createContentNode(companyHome, "testImageNode"); + this.nodeWithImageContent = createContentNode(companyHome, "testImageNode-" + GUID.generate()); // Stream some well-known image content into the node. URL url = RenditionServiceIntegrationTest.class.getClassLoader().getResource("images/gray21.512.png"); assertNotNull("url of test image was null", url); @@ -181,6 +187,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest // Create a test template node. this.nodeWithFreeMarkerContent = createFreeMarkerNode(companyHome); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); } private NodeRef createContentNode(NodeRef companyHome, String name) @@ -201,7 +210,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest private NodeRef createFreeMarkerNode(NodeRef companyHome) { - NodeRef fmNode = createContentNode(companyHome, "testFreeMarkerNode"); + NodeRef fmNode = createContentNode(companyHome, "testFreeMarkerNode-" + GUID.generate()); nodeService.setProperty(fmNode, ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null)); @@ -217,19 +226,15 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest return fmNode; } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { - nodeService.deleteNode(nodeWithImageContent); - nodeService.deleteNode(nodeWithDocContent); - nodeService.deleteNode(nodeWithFreeMarkerContent); - nodeService.deleteNode(testTargetFolder); + super.after(); } + @Test public void testRenderFreeMarkerTemplate() throws Exception { - this.setComplete(); - this.endTransaction(); final QName renditionName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, FreemarkerRenderingEngine.NAME); @@ -265,10 +270,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest }); } + @Test public void testHTMLRenderFreeMarkerTemplate() throws Exception { - this.setComplete(); - this.endTransaction(); final QName renditionName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "htmlRenderingDefinition"); @@ -321,10 +325,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest } + @Test public void testRenderFreeMarkerTemplateOneTransaction() throws Exception { - this.setComplete(); - this.endTransaction(); final QName renditionName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, FreemarkerRenderingEngine.NAME); @@ -350,11 +353,10 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest }); } + @Test public void testRenderFreemarkerTemplatePath() throws Exception { //TODO displayName paths. - this.setComplete(); - this.endTransaction(); final QName renditionName1 = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, FreemarkerRenderingEngine.NAME + "_UpdateOnAnyPropChange"); final QName renditionName2 = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, @@ -526,11 +528,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * type PDF) into a different format (of type plain_text) and place the * rendition under the source node. */ + @Test public void testRenderDocumentInAnotherFormatInSitu() throws Exception { - this.setComplete(); - this.endTransaction(); - this.renditionNode = transactionHelper .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -661,9 +661,6 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest protected void renderPdfDocumentLongRunningTest(AbstractNodeModifyingRunnable nodeModifyingRunnable, boolean joinNodeModifyingThread) throws Exception { - this.setComplete(); - this.endTransaction(); - // Register our dummy transformer ContentTransformerRegistry contentTransformerRegistry = (ContentTransformerRegistry) this.applicationContext.getBean("contentTransformerRegistry"); @@ -700,7 +697,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest nodeWithDocContent, RenditionModel.ASPECT_RENDITIONED)); return renditionAssoc.getChildRef(); } - }); + }, false, true); } catch (RenditionCancelledException e) { @@ -732,6 +729,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testRenderPdfDocumentLongRunningCheckout() throws Exception { try @@ -747,16 +745,23 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest AuthenticationUtil.setRunAsUserSystem(); CheckOutCheckInService checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("checkOutCheckInService"); - checkOutCheckInService.checkout(nodeWithDocContent); + NodeRef wc = checkOutCheckInService.checkout(nodeRef); + assertNotNull(wc); } }; renderPdfDocumentLongRunningTest(new CheckoutRunnable(nodeWithDocContent), true); } finally { - AuthenticationUtil.setRunAsUserSystem(); - CheckOutCheckInService checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("CheckOutCheckInService"); - checkOutCheckInService.cancelCheckout(checkOutCheckInService.getWorkingCopy(nodeWithDocContent)); + transactionHelper.doInTransaction(() -> + { + AuthenticationUtil.setRunAsUserSystem(); + CheckOutCheckInService checkOutCheckInService = (CheckOutCheckInService) applicationContext.getBean("CheckOutCheckInService"); + NodeRef wc = checkOutCheckInService.getWorkingCopy(nodeWithDocContent); + assertNotNull(wc); + checkOutCheckInService.cancelCheckout(wc); + return null; + }, false, true); } } @@ -765,6 +770,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testRenderPdfDocumentLongRunningLock() throws Exception { class LockRunnable extends AbstractNodeModifyingRunnable @@ -783,11 +789,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest renderPdfDocumentLongRunningTest(new LockRunnable(nodeWithDocContent)); } + @Test public void testCompositeReformatAndResizeRendition() throws Exception { - this.setComplete(); - this.endTransaction(); - final QName renditionName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "composite"); final int newX = 20; final int newY = 30; @@ -839,11 +843,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * type PDF) into a different format (of type plain_text) and place the * rendition under the specified folder. */ + @Test public void testRenderDocumentInAnotherFormatUnderSpecifiedFolder() throws Exception { - this.setComplete(); - this.endTransaction(); - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable @@ -897,11 +899,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * type PNG) as a cropped image of the same type. */ @SuppressWarnings("unused") + @Test public void testRenderCropImage() throws Exception { - this.setComplete(); - this.endTransaction(); - final int originalImageWidth = 512; final int originalImageHeight = 512; @@ -1021,11 +1021,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * This test method used the RenditionService to render a test image (of * type PNG) as a rescaled image of the same type. */ + @Test public void testRenderRescaledImage() throws Exception { - this.setComplete(); - this.endTransaction(); - final int originalImageWidth = 512; final int originalImageHeight = 512; @@ -1130,11 +1128,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testReformatImage() throws Exception { - setComplete(); - endTransaction(); - this.renditionNode = transactionHelper .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -1186,11 +1182,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * * @since 4.0.1 */ + @Test public void testSuitablyMarkedNodesDoNotGetRenditioned() throws Exception { - setComplete(); - endTransaction(); - this.renditionNode = transactionHelper .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -1223,6 +1217,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest }); } + @Test public void testSuccessfulAsynchronousRendition() throws Exception { // There are two relevant threads here: the JUnit test thread and the background @@ -1267,6 +1262,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * @throws Exception * @see {@link #testSuccessfulAsynchronousRendition()} */ + @Test public void testFailedAsynchronousRendition() throws Exception { // see comment in method above for explanation of the countdown latch. @@ -1313,9 +1309,6 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest private void performAsyncRendition(final NodeRef nodeToRender, final RenderCallback callback, CountDownLatch latch, final AsyncResultsHolder failureMessage) throws InterruptedException { - setComplete(); - endTransaction(); - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable @@ -1327,7 +1320,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest renditionService.render(nodeToRender, action, callback); return null; } - }); + }, false, true); // Now wait for the actionService thread to complete the rendering. // We'll arbitrarily timeout after 30 seconds, which should be plenty for the @@ -1381,11 +1374,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest } } + @Test public void testGetRenditionsForNode() throws Exception { - setComplete(); - endTransaction(); - this.renditionNode = transactionHelper .doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -1518,11 +1509,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * Checks that the saveRenderingAction Method creates the proper node in the * repository. */ + @Test public void testSaveRenderingAction() throws Exception { - this.setComplete(); - this.endTransaction(); - final List savedRenditionsToDelete = new ArrayList(); try { @@ -1599,9 +1588,6 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest */ public void off_test_CleanPersistedRenditionsAndCreateExportedACP() throws Exception { - this.setComplete(); - this.endTransaction(); - // Check that if no node exists already then a new node is created. transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -1758,11 +1744,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testLoadRenderingAction() throws Exception { - this.setComplete(); - this.endTransaction(); - final RenditionDefinition reformatAction = makeReformatAction(null, MimetypeMap.MIMETYPE_TEXT_PLAIN); final RenditionDefinition rescaleAction = makeRescaleImageAction(); @@ -1857,11 +1841,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest } } + @Test public void testSaveAndLoadCompositeRenditionDefinition() throws Exception { - this.setComplete(); - this.endTransaction(); - final QName renditionName = QName.createQName(NamespaceService.RENDITION_MODEL_1_0_URI, "composite"); final CompositeRenditionDefinition compositeDefinition = makeCompositeReformatAndResizeDefinition( renditionName, 20, 30); @@ -1955,6 +1937,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testBuiltinRenditionDefinitions() throws Exception { final RenditionDefinition mediumRenditionDef = loadAndValidateRenditionDefinition("medium"); @@ -1977,11 +1960,9 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * * @since 3.4.2 */ + @Test public void testRenderValidContentThenUpdateToInvalidContent() throws Exception { - setComplete(); - endTransaction(); - transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { public Void execute() throws Throwable @@ -2004,7 +1985,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest renditionService.render(nodeWithDocContent, doclib, dummyCallback); return null; } - }); + }, false, true); // Now wait for the actionService thread to complete the rendering. Thread.sleep(5000); @@ -2019,7 +2000,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest assertEquals("Wrong rendition count", 1, renditions.size()); return null; } - }); + }, false, true); // Now update the content to a corrupt PDF file that cannot be rendered. transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -2036,7 +2017,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest return null; } - }); + }, false, true); // Now wait for the actionService thread to complete the rendition removal. Thread.sleep(5000); @@ -2050,10 +2031,11 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest assertEquals("Wrong rendition count", 0, renditions.size()); return null; } - }); + }, false, true); } + @Test public void testALF3733() throws Exception { // ALF-3733 was caused by ${cwd} evaluating to the empty string and a path "//sourceNodeName" @@ -2112,6 +2094,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * end up with both source nodes thinking they have the same * rendition node, because it'd only be one of theirs! */ + @Test public void testPathBasedRenditionOverwrite() throws Exception { @@ -2122,6 +2105,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * renditions, both single and composite, to check that * the renditions always end up as they should do. */ + @Test public void testRenditionPlacements() throws Exception { QName plainQName = QName.createQName("Plain"); @@ -2515,6 +2499,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest return compositeDefinition; } + @Test public void testJavascriptAPI() throws Exception { Map model = new HashMap(); @@ -2528,6 +2513,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest /** * This test method takes an image with Exif Orientation information and checks if it is automatially rotated. */ + @Test public void testAutoRotateImage() throws Exception { NodeRef companyHome = repositoryHelper.getCompanyHome(); @@ -2620,7 +2606,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest * Loads this executor into the ApplicationContext, if it * isn't already there */ - public static void registerIfNeeded(ConfigurableApplicationContext ctx) + public static void registerIfNeeded(ApplicationContext ctx) { if(!ctx.containsBean(ENGINE_NAME)) { @@ -2646,7 +2632,7 @@ public class RenditionServiceIntegrationTest extends BaseAlfrescoSpringTest ); // Register - ctx.getBeanFactory().registerSingleton( + ((ConfigurableApplicationContext) ctx).getBeanFactory().registerSingleton( ENGINE_NAME, hw ); hw.init(); diff --git a/src/test/java/org/alfresco/repo/rendition/StandardRenditionLocationResolverTest.java b/src/test/java/org/alfresco/repo/rendition/StandardRenditionLocationResolverTest.java index ac2c477deb..51081f9fa4 100644 --- a/src/test/java/org/alfresco/repo/rendition/StandardRenditionLocationResolverTest.java +++ b/src/test/java/org/alfresco/repo/rendition/StandardRenditionLocationResolverTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rendition; @@ -43,13 +43,17 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * @author Brian Remmington * @author Nick Smith */ @Category(BaseSpringTestsCategory.class) +@Transactional public class StandardRenditionLocationResolverTest extends BaseAlfrescoSpringTest { private ServiceRegistry serviceRegistry; @@ -58,26 +62,23 @@ public class StandardRenditionLocationResolverTest extends BaseAlfrescoSpringTes private RenditionService renditionService; private Repository repositoryHelper; - /** - * Called during the transaction setup - */ - @Override - @SuppressWarnings("deprecation") - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the required services - this.serviceRegistry = (ServiceRegistry) this.getApplicationContext().getBean("ServiceRegistry"); + this.serviceRegistry = (ServiceRegistry) applicationContext.getBean("ServiceRegistry"); this.nodeService=serviceRegistry.getNodeService(); - this.renditionService = (RenditionService) this.getApplicationContext().getBean("RenditionService"); - this.repositoryHelper = (Repository) this.getApplicationContext().getBean("repositoryHelper"); + this.renditionService = (RenditionService) applicationContext.getBean("RenditionService"); + this.repositoryHelper = (Repository) applicationContext.getBean("repositoryHelper"); this.companyHome = this.applicationContext.getBean("repositoryHelper", Repository.class).getCompanyHome(); locationResolver = new StandardRenditionLocationResolverImpl(); locationResolver.setServiceRegistry(serviceRegistry); locationResolver.setRepositoryHelper(repositoryHelper); } + @Test public void testChildAssociationFinder() { QName renditionKind = QName.createQName(NamespaceService.APP_MODEL_1_0_URI, "test"); @@ -139,6 +140,7 @@ public class StandardRenditionLocationResolverTest extends BaseAlfrescoSpringTes assertEquals(destinationNode, location.getChildRef()); } + @Test public void testCreatesFoldersForTemplatedLocation() throws Exception { QName fooName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testFooFolder"); diff --git a/src/test/java/org/alfresco/repo/rendition/executer/HTMLRenderingEngineTest.java b/src/test/java/org/alfresco/repo/rendition/executer/HTMLRenderingEngineTest.java index 802eaefdc1..fa8bdc9433 100644 --- a/src/test/java/org/alfresco/repo/rendition/executer/HTMLRenderingEngineTest.java +++ b/src/test/java/org/alfresco/repo/rendition/executer/HTMLRenderingEngineTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rendition.executer; @@ -52,7 +52,11 @@ import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Unit tests for the HTML Rendering Engine @@ -60,6 +64,7 @@ import org.junit.experimental.categories.Category; * @author Nick Burch */ @Category(BaseSpringTestsCategory.class) +@Transactional public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest { private final static Log log = LogFactory.getLog(HTMLRenderingEngineTest.class); @@ -77,16 +82,10 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest private static final String MIMETYPE_DOC = "application/msword"; private static final String MIMETYPE_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; - /* - * (non-Javadoc) - * - * @see org.alfresco.util.BaseAlfrescoSpringTest#onSetUpInTransaction() - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.nodeService = (NodeService) this.applicationContext.getBean("NodeService"); this.contentService = (ContentService) this.applicationContext.getBean("ContentService"); this.renditionService = (RenditionService) this.applicationContext.getBean("RenditionService"); @@ -108,9 +107,10 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest def = renditionService.createRenditionDefinition(renditionName, HTMLRenderingEngine.NAME); } - @Override - protected void onTearDownInTransaction() throws Exception { - super.onTearDownInTransaction(); + @After + public void after() throws Exception + { + super.after(); tidyUpSourceDoc(); } @@ -194,6 +194,7 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest return node; } + @Test public void testBasics() throws Exception { def.setParameterValue( @@ -256,6 +257,7 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest /** * Test for a .doc and a .docx, neither of which have images */ + @Test public void testDocWithoutImages() throws Exception { def.setParameterValue( @@ -326,6 +328,7 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest * Test for a .doc and a .docx, both of which have * images in them */ + @Test public void testDocWithImages() throws Exception { def.setParameterValue( @@ -433,6 +436,7 @@ public class HTMLRenderingEngineTest extends BaseAlfrescoSpringTest * * TODO Re-enable when we've figured out why the rendition service sulkts */ + @Test public void testImagesSameFolder() throws Exception { def.setParameterValue( diff --git a/src/test/java/org/alfresco/repo/rendition/executer/XSLTFunctionsTest.java b/src/test/java/org/alfresco/repo/rendition/executer/XSLTFunctionsTest.java index 39afa61848..ccfbf6fb99 100644 --- a/src/test/java/org/alfresco/repo/rendition/executer/XSLTFunctionsTest.java +++ b/src/test/java/org/alfresco/repo/rendition/executer/XSLTFunctionsTest.java @@ -48,7 +48,10 @@ import org.alfresco.util.GUID; import org.alfresco.util.testing.category.LuceneTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; import org.w3c.dom.Document; import org.w3c.dom.NodeList; @@ -57,6 +60,7 @@ import org.w3c.dom.NodeList; * */ @Category({BaseSpringTestsCategory.class}) +@Transactional public class XSLTFunctionsTest extends BaseAlfrescoSpringTest { private final static Log log = LogFactory.getLog(XSLTFunctionsTest.class); @@ -65,14 +69,10 @@ public class XSLTFunctionsTest extends BaseAlfrescoSpringTest private FileFolderService fileFolderService; private Repository repositoryHelper; - /* (non-Javadoc) - * @see org.alfresco.util.BaseAlfrescoSpringTest#onSetUpInTransaction() - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.xsltFunctions = (XSLTFunctions) this.applicationContext.getBean("xsltFunctions"); this.nodeService = (NodeService) this.applicationContext.getBean("NodeService"); this.contentService = (ContentService) this.applicationContext.getBean("ContentService"); @@ -81,6 +81,7 @@ public class XSLTFunctionsTest extends BaseAlfrescoSpringTest this.companyHome = repositoryHelper.getCompanyHome(); } + @Test public void testSimplestParseXMLDocument() { FileInfo file = createXmlFile(companyHome); @@ -97,6 +98,7 @@ public class XSLTFunctionsTest extends BaseAlfrescoSpringTest } } + @Test public void testPathParseXMLDocument() { String path = "path/to/xml/files"; @@ -117,6 +119,7 @@ public class XSLTFunctionsTest extends BaseAlfrescoSpringTest } } + @Test public void testParseXMLDocuments() { String path = "path/to/xml/files"; diff --git a/src/test/java/org/alfresco/repo/rendition/executer/XSLTRenderingEngineTest.java b/src/test/java/org/alfresco/repo/rendition/executer/XSLTRenderingEngineTest.java index 3c19578e2a..8d489a6552 100644 --- a/src/test/java/org/alfresco/repo/rendition/executer/XSLTRenderingEngineTest.java +++ b/src/test/java/org/alfresco/repo/rendition/executer/XSLTRenderingEngineTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rendition.executer; @@ -51,13 +51,17 @@ import org.alfresco.util.GUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.custommonkey.xmlunit.Diff; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * @author Brian * */ @Category(BaseSpringTestsCategory.class) +@Transactional public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest { private final static Log log = LogFactory.getLog(XSLTRenderingEngineTest.class); @@ -67,16 +71,10 @@ public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest private TemplateService templateService; private RenditionService renditionService; - /* - * (non-Javadoc) - * - * @see org.alfresco.util.BaseAlfrescoSpringTest#onSetUpInTransaction() - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.nodeService = (NodeService) this.applicationContext.getBean("NodeService"); this.contentService = (ContentService) this.applicationContext.getBean("ContentService"); this.fileFolderService = (FileFolderService) this.applicationContext.getBean("FileFolderService"); @@ -87,6 +85,7 @@ public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest this.companyHome = this.applicationContext.getBean("repositoryHelper", Repository.class).getCompanyHome(); } + @Test public void testSimplestStringTemplate() throws Exception { try @@ -116,6 +115,7 @@ public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest } + @Test public void testSimplestTemplateWithTargetPath() throws Exception { try @@ -147,6 +147,7 @@ public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest } + @Test public void testParseXMLDocument() throws Exception { try @@ -176,6 +177,7 @@ public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest } } + @Test public void testParseXMLDocuments() throws Exception { try @@ -218,6 +220,7 @@ public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest } } + @Test public void testImportXMLDocument() throws Exception { try diff --git a/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java b/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java index 4ff4b72c31..d7a1769e86 100644 --- a/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java +++ b/src/test/java/org/alfresco/repo/rule/BaseRuleTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rule; import java.io.Serializable; @@ -50,6 +50,9 @@ import org.alfresco.service.cmr.rule.RuleType; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.BaseSpringTest; +import org.junit.After; +import org.junit.Before; +import org.springframework.transaction.annotation.Transactional; /** * Base class for rule service test. @@ -58,6 +61,7 @@ import org.alfresco.util.BaseSpringTest; * * @author Roy Wetherall */ +@Transactional public class BaseRuleTest extends BaseSpringTest { /** @@ -109,12 +113,9 @@ public class BaseRuleTest extends BaseSpringTest protected ActionService actionService; protected TransactionService transactionService; - /** - * onSetUpInTransaction implementation - */ - @Override - protected void onSetUpInTransaction() throws Exception - { + @Before + public void before() throws Exception + { // Get the services this.nodeService = (NodeService) this.applicationContext .getBean("nodeService"); @@ -147,11 +148,10 @@ public class BaseRuleTest extends BaseSpringTest ContentModel.TYPE_CONTAINER).getChildRef(); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() { authenticationComponent.clearCurrentSecurityContext(); - super.onTearDownInTransaction(); } protected void addRulesAspect() diff --git a/src/test/java/org/alfresco/repo/rule/RuleLinkTest.java b/src/test/java/org/alfresco/repo/rule/RuleLinkTest.java index 3da04b1c89..1e4f492cf2 100644 --- a/src/test/java/org/alfresco/repo/rule/RuleLinkTest.java +++ b/src/test/java/org/alfresco/repo/rule/RuleLinkTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rule; import java.io.Serializable; @@ -51,7 +51,10 @@ import org.alfresco.service.cmr.rule.RuleType; import org.alfresco.service.namespace.QName; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Parameter definition implementation unit test. @@ -59,6 +62,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class RuleLinkTest extends BaseSpringTest { protected static final String RULE_TYPE_NAME = RuleType.INBOUND; @@ -80,17 +84,16 @@ public class RuleLinkTest extends BaseSpringTest private NodeRef folderOne; private NodeRef folderTwo; private NodeRef folderThree; - - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception - { + + @Before + public void before() throws Exception + { // Get the services - nodeService = (NodeService)getApplicationContext().getBean("nodeService"); - ruleService = (RuleService)getApplicationContext().getBean("ruleService"); - actionService = (ActionService)getApplicationContext().getBean("actionService"); - authenticationComponent = (AuthenticationComponent)getApplicationContext().getBean("authenticationComponent"); - fileFolderService = (FileFolderService)getApplicationContext().getBean("fileFolderService"); + nodeService = (NodeService) applicationContext.getBean("nodeService"); + ruleService = (RuleService) applicationContext.getBean("ruleService"); + actionService = (ActionService) applicationContext.getBean("actionService"); + authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); + fileFolderService = (FileFolderService) applicationContext.getBean("fileFolderService"); //authenticationComponent.setSystemUserAsCurrentUser(); authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); @@ -114,6 +117,7 @@ public class RuleLinkTest extends BaseSpringTest folderThree = fileFolderService.create(folder, "folderThree", ContentModel.TYPE_FOLDER).getNodeRef(); } + @Test public void testLinkRule() { // Create a rule @@ -212,6 +216,7 @@ public class RuleLinkTest extends BaseSpringTest actionService.executeAction(unlinkAction, folder); } + @Test public void testRelink() { // Setup test data @@ -274,6 +279,7 @@ public class RuleLinkTest extends BaseSpringTest * @since 4.0.2 * @author Neil Mc Erlean. */ + @Test public void testDeleteFolderWithPrimaryRules() { // Setup test data @@ -311,6 +317,7 @@ public class RuleLinkTest extends BaseSpringTest * @since 4.1.1 * @author Neil Mc Erlean. */ + @Test public void testDeleteFolderWithSecondaryRules() { // Setup test data diff --git a/src/test/java/org/alfresco/repo/rule/RuleServiceImplTest.java b/src/test/java/org/alfresco/repo/rule/RuleServiceImplTest.java index d27104f8d9..c05b5b797e 100644 --- a/src/test/java/org/alfresco/repo/rule/RuleServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/rule/RuleServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rule; import java.io.File; @@ -67,10 +67,14 @@ import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.GUID; +import org.junit.Before; import org.junit.experimental.categories.Category; import org.junit.Test; import javax.transaction.UserTransaction; +import org.springframework.test.annotation.Commit; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** @@ -79,6 +83,7 @@ import javax.transaction.UserTransaction; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class RuleServiceImplTest extends BaseRuleTest { private String ASSOC_NAME_RULES_PREFIX = "rules"; @@ -89,11 +94,11 @@ public class RuleServiceImplTest extends BaseRuleTest SearchService searchService; NamespaceService namespaceService; FileFolderService fileFolderService; - - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.permissionService = (PermissionService)this.applicationContext.getBean("permissionService"); this.authenticationService = (MutableAuthenticationService)this.applicationContext.getBean("authenticationService"); this.searchService = (SearchService) applicationContext.getBean("SearchService"); @@ -104,6 +109,7 @@ public class RuleServiceImplTest extends BaseRuleTest /** * Test get rule type */ + @Test public void testGetRuleType() { List ruleTypes = this.ruleService.getRuleTypes(); @@ -120,6 +126,7 @@ public class RuleServiceImplTest extends BaseRuleTest * Test addRule * */ + @Test public void testAddRule() { Rule newRule = createTestRule(); @@ -151,6 +158,7 @@ public class RuleServiceImplTest extends BaseRuleTest assertTrue(savedRule2.isAppliedToChildren()); } + @Test public void testRemoveRule() { this.ruleService.removeAllRules(this.nodeRef); @@ -209,6 +217,7 @@ public class RuleServiceImplTest extends BaseRuleTest assertEquals(false, nodeService.hasAspect(nodeRef, RuleModel.ASPECT_RULES)); } + @Test public void testRemoveAllRules() { this.ruleService.removeAllRules(this.nodeRef); @@ -242,6 +251,7 @@ public class RuleServiceImplTest extends BaseRuleTest /** * Test get rules */ + @Test public void testGetRules() { // Check that there are no rules associationed with the node @@ -279,6 +289,7 @@ public class RuleServiceImplTest extends BaseRuleTest } /** Ensure the rules are retrieved in the correct order **/ + @Test public void testGetRulesOrder() { for (int index = 0; index < 10; index++) @@ -402,6 +413,7 @@ public class RuleServiceImplTest extends BaseRuleTest } } + @Test public void testIgnoreInheritedRules() { // Create the nodes and rules @@ -452,6 +464,7 @@ public class RuleServiceImplTest extends BaseRuleTest /** * Test disabling the rules */ + @Test public void testRulesDisabled() { testAddRule(); @@ -475,6 +488,7 @@ public class RuleServiceImplTest extends BaseRuleTest ContentModel.TYPE_CONTAINER).getChildRef(); } + @Test public void testRuleServicePermissionsConsumer() { this.authenticationService.createAuthentication("conUser", "password".toCharArray()); @@ -496,6 +510,7 @@ public class RuleServiceImplTest extends BaseRuleTest } + @Test public void testRuleServicePermissionsEditor() { this.authenticationService.createAuthentication("editorUser", "password".toCharArray()); @@ -516,6 +531,7 @@ public class RuleServiceImplTest extends BaseRuleTest } } + @Test public void testRuleServicePermissionsCoordinator() { this.authenticationService.createAuthentication("coordUser", "password".toCharArray()); @@ -532,6 +548,7 @@ public class RuleServiceImplTest extends BaseRuleTest * Tests the rule inheritance within the store, checking that the cache is reset correctly when * rules are added and removed. */ + @Test public void testRuleInheritance() { // Create the nodes and rules @@ -781,6 +798,7 @@ public class RuleServiceImplTest extends BaseRuleTest * * @throws Exception */ + @Test public void testCyclicGraphWithInheritedRules() throws Exception { @@ -830,6 +848,7 @@ public class RuleServiceImplTest extends BaseRuleTest /** * Ensures that rules are not duplicated when inherited */ + @Test public void testRuleDuplication() { NodeRef nodeRef1 = createNewNode(this.rootNodeRef); @@ -873,10 +892,13 @@ public class RuleServiceImplTest extends BaseRuleTest assertTrue(allRules4.contains(rule4)); } + @Test public void testCyclicRules() { } - + + @Commit + @Test public void testCyclicAsyncRules() throws Exception { NodeRef nodeRef = createNewNode(this.rootNodeRef); @@ -946,9 +968,6 @@ public class RuleServiceImplTest extends BaseRuleTest writer.setMimetype(MimetypeMap.MIMETYPE_IMAGE_JPEG); writer.putContent(file); - setComplete(); - endTransaction(); - //final NodeRef finalNodeRef = nodeRef; // Check to see what has happened @@ -972,9 +991,12 @@ public class RuleServiceImplTest extends BaseRuleTest // }); } + @Test public void testDeleteSpaceWithExecuteScriptRule() throws Exception { - endTransaction(); // So we don't hang indefinitely waiting for the outer transaction + TestTransaction.flagForCommit(); + TestTransaction.end(); + // So we don't hang indefinitely waiting for the outer transaction transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { public Object execute() @@ -1027,6 +1049,7 @@ public class RuleServiceImplTest extends BaseRuleTest }, false, true); } + @Test public void testPermissionsForPropagatedRules_ALF_8408() throws Exception { // Create parent and child folders @@ -1096,6 +1119,7 @@ public class RuleServiceImplTest extends BaseRuleTest * ALF-12726 * use FileFolderService to rename */ + @Test public void testOutboundRuleTriggeredAfterRename1() throws Exception { String newName = "newName" + GUID.generate(); @@ -1145,6 +1169,7 @@ public class RuleServiceImplTest extends BaseRuleTest * ALF-12726 * use NodeService to rename */ + @Test public void testOutboundRuleTriggeredAfterRename2() throws Exception { UserTransaction txn = transactionService.getUserTransaction(); @@ -1202,6 +1227,7 @@ public class RuleServiceImplTest extends BaseRuleTest /** * MNT-11670 */ + @Test public void testRuleExecutionWhenSecurityContextIsEmpty() throws Exception { // Create parent and child folders @@ -1251,6 +1277,7 @@ public class RuleServiceImplTest extends BaseRuleTest /** * Test for MNT-11695 */ + @Test public void testOutBoundRuleTriggerForPendingDelete() throws Exception { UserTransaction txn = transactionService.getUserTransaction(); @@ -1356,6 +1383,7 @@ public class RuleServiceImplTest extends BaseRuleTest * * @throws Exception */ + @Test public void testRuleTriggerWithTemporaryFiles() throws Exception { UserTransaction txn = transactionService.getUserTransaction(); @@ -1428,11 +1456,9 @@ public class RuleServiceImplTest extends BaseRuleTest /** * MNT-12819 * Create two rules: outbound (enabled) and inbound (disabled). Then try to remove them via removeAllRules method. - * @throws SystemException - * @throws NotSupportedException */ @Test - public void testRemoveAllRulesForInboundAndOutbound() throws Exception + public void testRemoveAllRulesForInboundAndOutbound() { String scriptName = "nothingToDo.js"; createNothingToDoScript(scriptName); diff --git a/src/test/java/org/alfresco/repo/rule/RuleTypeImplTest.java b/src/test/java/org/alfresco/repo/rule/RuleTypeImplTest.java index fdc3c8003a..67ddd9bc94 100644 --- a/src/test/java/org/alfresco/repo/rule/RuleTypeImplTest.java +++ b/src/test/java/org/alfresco/repo/rule/RuleTypeImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rule; import java.util.ArrayList; @@ -38,7 +38,10 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Parameter definition implementation unit test. @@ -46,6 +49,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class RuleTypeImplTest extends BaseSpringTest { private static final String NAME = "name"; @@ -55,17 +59,18 @@ public class RuleTypeImplTest extends BaseSpringTest private StoreRef testStoreRef; private NodeRef rootNodeRef; - - @Override - protected void onSetUpInTransaction() throws Exception - { - this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); + + @Before + public void before() throws Exception + { + this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); this.contentService = (ContentService)this.applicationContext.getBean("contentService"); this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef); } + @Test public void testConstructor() { create(); @@ -79,6 +84,7 @@ public class RuleTypeImplTest extends BaseSpringTest return temp; } + @Test public void testGetName() { RuleTypeImpl temp = create(); @@ -91,6 +97,7 @@ public class RuleTypeImplTest extends BaseSpringTest // TODO Test triggerRuleType + @Test public void testMockInboundRuleType() { List triggers = new ArrayList(2); diff --git a/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java b/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java index f7a9638a11..5412b6adc6 100644 --- a/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java +++ b/src/test/java/org/alfresco/repo/rule/ruletrigger/RuleTriggerTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.rule.ruletrigger; import org.alfresco.model.ContentModel; @@ -38,7 +38,12 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.rule.RuleType; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.util.BaseSpringTest; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * Rule trigger test @@ -46,6 +51,7 @@ import org.junit.experimental.categories.Category; * @author Roy Wetherall */ @Category(BaseSpringTestsCategory.class) +@Transactional public class RuleTriggerTest extends BaseSpringTest { private static final String ON_CREATE_NODE_TRIGGER = "on-create-node-trigger"; @@ -63,9 +69,9 @@ public class RuleTriggerTest extends BaseSpringTest private StoreRef testStoreRef; private NodeRef rootNodeRef; - - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); this.nodeService = serviceRegistry.getNodeService(); @@ -77,12 +83,13 @@ public class RuleTriggerTest extends BaseSpringTest this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef); } - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() { AuthenticationUtil.clearCurrentSecurityContext(); } + @Test public void testOnCreateNodeTrigger() { TestRuleType ruleType = createTestRuleType(ON_CREATE_NODE_TRIGGER); @@ -99,6 +106,7 @@ public class RuleTriggerTest extends BaseSpringTest assertTrue(ruleType.rulesTriggered); } + @Test public void testOnCreateIgnoredTypesTrigger() { TestRuleType ruleType = createTestRuleType(ON_CREATE_NODE_TRIGGER); @@ -115,6 +123,7 @@ public class RuleTriggerTest extends BaseSpringTest assertFalse(ruleType.rulesTriggered); } + @Test public void testOnUpdateNodeTrigger() { NodeRef nodeRef = this.nodeService.createNode( @@ -151,6 +160,7 @@ public class RuleTriggerTest extends BaseSpringTest // assertTrue(ruleType.rulesTriggered); // } + @Test public void testOnCreateChildAssociationTrigger() { NodeRef nodeRef = this.nodeService.createNode( @@ -178,6 +188,7 @@ public class RuleTriggerTest extends BaseSpringTest assertTrue(ruleType.rulesTriggered); } + @Test public void testOnDeleteChildAssociationTrigger() { NodeRef nodeRef = this.nodeService.createNode( @@ -206,6 +217,7 @@ public class RuleTriggerTest extends BaseSpringTest assertTrue(ruleType.rulesTriggered); } + @Test public void testOnCreateAssociationTrigger() { NodeRef nodeRef = this.nodeService.createNode( @@ -229,6 +241,7 @@ public class RuleTriggerTest extends BaseSpringTest assertTrue(ruleType.rulesTriggered); } + @Test public void testOnCreateOriginalAssociationTrigger() { NodeRef nodeRef = this.nodeService.createNode( @@ -252,6 +265,7 @@ public class RuleTriggerTest extends BaseSpringTest assertFalse(ruleType.rulesTriggered); } + @Test public void testOnDeleteAssociationTrigger() { NodeRef nodeRef = this.nodeService.createNode( @@ -276,6 +290,7 @@ public class RuleTriggerTest extends BaseSpringTest assertTrue(ruleType.rulesTriggered); } + @Test public void testOnContentCreateTrigger() { TestRuleType nodeCreate = createTestRuleType(ON_CREATE_NODE_TRIGGER); @@ -290,9 +305,9 @@ public class RuleTriggerTest extends BaseSpringTest assertTrue(nodeCreate.rulesTriggered); // Terminate the transaction - setComplete(); - endTransaction(); - startNewTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); TestRuleType contentCreate = createTestRuleType(ON_CONTENT_CREATE_TRIGGER); assertFalse(contentCreate.rulesTriggered); @@ -318,6 +333,7 @@ public class RuleTriggerTest extends BaseSpringTest assertFalse(contentCreate.rulesTriggered); } + @Test public void testOnContentUpdateTrigger() { TestRuleType nodeCreate = createTestRuleType(ON_CREATE_NODE_TRIGGER); @@ -361,8 +377,9 @@ public class RuleTriggerTest extends BaseSpringTest contentUpdate.rulesTriggered); // Terminate the transaction - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); contentCreate.rulesTriggered = false; // Try and trigger the type (again) @@ -380,6 +397,7 @@ public class RuleTriggerTest extends BaseSpringTest contentUpdate.rulesTriggered); } + @Test public void testOnMoveNodeTrigger() { NodeRef nodeRef1 = this.nodeService.createNode(this.rootNodeRef, diff --git a/src/test/java/org/alfresco/repo/search/SearcherComponentTest.java b/src/test/java/org/alfresco/repo/search/SearcherComponentTest.java index 1acb2e6fc8..129814cddf 100644 --- a/src/test/java/org/alfresco/repo/search/SearcherComponentTest.java +++ b/src/test/java/org/alfresco/repo/search/SearcherComponentTest.java @@ -36,6 +36,8 @@ import javax.transaction.UserTransaction; import junit.framework.TestCase; import org.alfresco.model.ContentModel; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.repo.node.BaseNodeServiceTest; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.service.ServiceRegistry; @@ -52,9 +54,6 @@ import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ISO9075; -import org.alfresco.util.testing.category.LuceneTests; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.PostgreSQLDialect; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; diff --git a/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java b/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java index e0b0827b75..41f37e9a27 100644 --- a/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java +++ b/src/test/java/org/alfresco/repo/security/authentication/AuthenticationTest.java @@ -1,37 +1,33 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.security.authentication; -import static org.junit.Assert.assertNotNull; - import java.io.Serializable; import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; @@ -57,6 +53,8 @@ import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; import org.alfresco.repo.admin.SysAdminParamsImpl; import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; import org.alfresco.repo.management.subsystems.ChildApplicationContextManager; import org.alfresco.repo.policy.BehaviourFilter; @@ -86,8 +84,6 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.PostgreSQLDialect; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; import org.springframework.extensions.webscripts.GUID; @@ -2154,63 +2150,63 @@ public class AuthenticationTest extends TestCase nspr.registerNamespace("namespace", "namespace"); nspr.registerNamespace(NamespaceService.DEFAULT_PREFIX, defaultURI); return nspr; - } - - public void testCreatingUserWithEmptyPassword() throws Exception - { - String previousAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser(); - String userName = GUID.generate(); - String rawPass = ""; - try - { - dao.createUser(userName, null, rawPass.toCharArray()); - NodeRef userNodeRed = getRepositoryAuthenticationDao().getUserOrNull(userName); - assertNotNull(userNodeRed); - - Map properties = nodeService.getProperties(userNodeRed); - assertEquals(properties.get(ContentModel.PROP_ENABLED), false); - - properties.remove(ContentModel.PROP_ENABLED); - properties.put(ContentModel.PROP_ENABLED, true); - nodeService.setProperties(userNodeRed, properties); - assertEquals(properties.get(ContentModel.PROP_ENABLED), true); - - try - { - authenticationService.authenticate(userName, rawPass.toCharArray()); - fail("Authentication should have been rejected"); - } - catch (IllegalArgumentException e) - { - assertEquals(e.getMessage(), "rawPassword is a mandatory parameter"); - } - - rawPass = "newPassword"; - dao.updateUser(userName, rawPass.toCharArray()); - try - { - authenticationService.authenticate(userName, rawPass.toCharArray()); - } - catch (AuthenticationException e) - { - fail("Authentication should have passed."); - } - assertEquals(authenticationService.getCurrentUserName(), userName); - } - finally - { - if (previousAuthenticatedUser != null) - { - AuthenticationUtil.setFullyAuthenticatedUser(previousAuthenticatedUser); - } - try - { - dao.deleteUser(userName); - } - catch (Exception e) - { - // Nothing to do here. - } - } + } + + public void testCreatingUserWithEmptyPassword() throws Exception + { + String previousAuthenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser(); + String userName = GUID.generate(); + String rawPass = ""; + try + { + dao.createUser(userName, null, rawPass.toCharArray()); + NodeRef userNodeRed = getRepositoryAuthenticationDao().getUserOrNull(userName); + assertNotNull(userNodeRed); + + Map properties = nodeService.getProperties(userNodeRed); + assertEquals(properties.get(ContentModel.PROP_ENABLED), false); + + properties.remove(ContentModel.PROP_ENABLED); + properties.put(ContentModel.PROP_ENABLED, true); + nodeService.setProperties(userNodeRed, properties); + assertEquals(properties.get(ContentModel.PROP_ENABLED), true); + + try + { + authenticationService.authenticate(userName, rawPass.toCharArray()); + fail("Authentication should have been rejected"); + } + catch (IllegalArgumentException e) + { + assertEquals(e.getMessage(), "rawPassword is a mandatory parameter"); + } + + rawPass = "newPassword"; + dao.updateUser(userName, rawPass.toCharArray()); + try + { + authenticationService.authenticate(userName, rawPass.toCharArray()); + } + catch (AuthenticationException e) + { + fail("Authentication should have passed."); + } + assertEquals(authenticationService.getCurrentUserName(), userName); + } + finally + { + if (previousAuthenticatedUser != null) + { + AuthenticationUtil.setFullyAuthenticatedUser(previousAuthenticatedUser); + } + try + { + dao.deleteUser(userName); + } + catch (Exception e) + { + // Nothing to do here. + } + } } } diff --git a/src/test/java/org/alfresco/repo/security/authentication/subsystems/SubsystemChainingFtpAuthenticatorTest.java b/src/test/java/org/alfresco/repo/security/authentication/subsystems/SubsystemChainingFtpAuthenticatorTest.java index b6007f65dd..592c1d99d8 100644 --- a/src/test/java/org/alfresco/repo/security/authentication/subsystems/SubsystemChainingFtpAuthenticatorTest.java +++ b/src/test/java/org/alfresco/repo/security/authentication/subsystems/SubsystemChainingFtpAuthenticatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.security.authentication.subsystems; @@ -32,9 +32,12 @@ import org.alfresco.jlan.server.auth.ClientInfo; import org.alfresco.repo.management.subsystems.ChildApplicationContextManager; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.BaseSpringTest; +import org.junit.Test; import org.mockito.Mock; import java.util.List; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; /** * Test class with test spring contexts for auth subsystems. @@ -42,6 +45,8 @@ import java.util.List; * @author alex.mukha * @since 4.2.1 */ +@Transactional +@ContextConfiguration({"classpath:test-ftp-auth-context.xml"}) public class SubsystemChainingFtpAuthenticatorTest extends BaseSpringTest { private static String SOURCE_BEAN_NAME = "testFtpAuthenticator"; @@ -51,15 +56,7 @@ public class SubsystemChainingFtpAuthenticatorTest extends BaseSpringTest private @Mock ClientInfo info; private @Mock FTPSrvSession session; - @Override - protected String[] getConfigLocations() - { - return new String[] - { - ApplicationContextHelper.CONFIG_LOCATIONS[0], "classpath:test-ftp-auth-context.xml" - }; - } - + @Test public void testNumberOfAuthenticatorsInChain() { // The contexts are configured for 3 subsystems: @@ -85,6 +82,7 @@ public class SubsystemChainingFtpAuthenticatorTest extends BaseSpringTest /** * As the context is configured to fail on first two subsystems, the third should be used */ + @Test public void testAuthenticatorChain() { // The contexts are configured for 3 subsystems: @@ -110,7 +108,7 @@ public class SubsystemChainingFtpAuthenticatorTest extends BaseSpringTest private void setContextForSubsystem(String beanName) { chainingAuthenticator = new SubsystemChainingFtpAuthenticator(); - ChildApplicationContextManager applicationContextManager = (ChildApplicationContextManager) getApplicationContext().getBean(beanName); + ChildApplicationContextManager applicationContextManager = (ChildApplicationContextManager) applicationContext.getBean(beanName); chainingAuthenticator.setApplicationContextManager(applicationContextManager); chainingAuthenticator.setSourceBeanName(SOURCE_BEAN_NAME); } diff --git a/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java b/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java index bbeb58ff3a..c0819c2b54 100644 --- a/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java +++ b/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractPermissionTest.java @@ -1,78 +1,77 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.security.permissions.impl; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import javax.transaction.UserTransaction; - -import junit.framework.TestCase; - -import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.model.ContentModel; -import org.alfresco.repo.domain.node.NodeDAO; -import org.alfresco.repo.domain.permissions.AclDAO; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.repo.security.authentication.MutableAuthenticationDao; -import org.alfresco.repo.security.authority.AuthorityDAO; -import org.alfresco.repo.security.permissions.PermissionReference; -import org.alfresco.repo.security.permissions.PermissionServiceSPI; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; -import org.alfresco.repo.transaction.RetryingTransactionHelper; -import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.dictionary.DictionaryService; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.cmr.security.AuthorityService; -import org.alfresco.service.cmr.security.MutableAuthenticationService; -import org.alfresco.service.cmr.security.PersonService; -import org.alfresco.service.cmr.security.PublicServiceAccessService; -import org.alfresco.service.cmr.site.SiteService; -import org.alfresco.service.namespace.NamespacePrefixResolver; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.service.transaction.TransactionService; -import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ApplicationContext; -import org.springframework.orm.hibernate3.LocalSessionFactoryBean; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import javax.transaction.UserTransaction; + +import junit.framework.TestCase; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.domain.node.NodeDAO; +import org.alfresco.repo.domain.permissions.AclDAO; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.security.authentication.MutableAuthenticationDao; +import org.alfresco.repo.security.authority.AuthorityDAO; +import org.alfresco.repo.security.permissions.PermissionReference; +import org.alfresco.repo.security.permissions.PermissionServiceSPI; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.dictionary.DictionaryService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.security.AuthorityService; +import org.alfresco.service.cmr.security.MutableAuthenticationService; +import org.alfresco.service.cmr.security.PersonService; +import org.alfresco.service.cmr.security.PublicServiceAccessService; +import org.alfresco.service.cmr.site.SiteService; +import org.alfresco.service.namespace.NamespacePrefixResolver; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.service.transaction.TransactionService; +import org.alfresco.util.ApplicationContextHelper; +import org.springframework.context.ApplicationContext; public class AbstractPermissionTest extends TestCase { - protected static final String USER2_LEMUR = "lemur"; - - protected static final String USER1_ANDY = "andy"; - - protected static final String USER3_PAUL ="paul"; - + protected static final String USER2_LEMUR = "lemur"; + + protected static final String USER1_ANDY = "andy"; + + protected static final String USER3_PAUL ="paul"; + protected static ApplicationContext applicationContext = ApplicationContextHelper.getApplicationContext(); protected static final String ROLE_AUTHENTICATED = "ROLE_AUTHENTICATED"; @@ -87,8 +86,6 @@ public class AbstractPermissionTest extends TestCase private MutableAuthenticationDao authenticationDAO; - protected LocalSessionFactoryBean sessionFactory; - protected StoreRef testStoreRef; protected NodeRef rootNodeRef; @@ -121,10 +118,10 @@ public class AbstractPermissionTest extends TestCase protected PermissionServiceImpl permissionServiceImpl; - protected PublicServiceAccessService publicServiceAccessService; - - protected PolicyComponent policyComponent; - + protected PublicServiceAccessService publicServiceAccessService; + + protected PolicyComponent policyComponent; + protected SiteService siteService; public AbstractPermissionTest() @@ -155,7 +152,7 @@ public class AbstractPermissionTest extends TestCase permissionModelDAO = (ModelDAO) applicationContext.getBean("permissionsModelDAO"); personService = (PersonService) applicationContext.getBean("personService"); authorityService = (AuthorityService) applicationContext.getBean("authorityService"); - authorityDAO = (AuthorityDAO) applicationContext.getBean("authorityDAO"); + authorityDAO = (AuthorityDAO) applicationContext.getBean("authorityDAO"); siteService = (SiteService) applicationContext.getBean("SiteService"); // Big 'S' authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName()); @@ -163,7 +160,7 @@ public class AbstractPermissionTest extends TestCase nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO"); aclDaoComponent = (AclDAO) applicationContext.getBean("aclDAO"); - publicServiceAccessService = (PublicServiceAccessService) applicationContext.getBean("publicServiceAccessService"); + publicServiceAccessService = (PublicServiceAccessService) applicationContext.getBean("publicServiceAccessService"); policyComponent = (PolicyComponent) applicationContext.getBean("policyComponent"); retryingTransactionHelper = (RetryingTransactionHelper) applicationContext.getBean("retryingTransactionHelper"); @@ -200,12 +197,12 @@ public class AbstractPermissionTest extends TestCase { authenticationService.deleteAuthentication(USER2_LEMUR); } - authenticationService.createAuthentication(USER2_LEMUR, USER2_LEMUR.toCharArray()); - - if(authenticationDAO.userExists(USER3_PAUL)) - { - authenticationService.deleteAuthentication(USER3_PAUL); - } + authenticationService.createAuthentication(USER2_LEMUR, USER2_LEMUR.toCharArray()); + + if(authenticationDAO.userExists(USER3_PAUL)) + { + authenticationService.deleteAuthentication(USER3_PAUL); + } authenticationService.createAuthentication(USER3_PAUL, USER3_PAUL.toCharArray()); if(authenticationDAO.userExists(AuthenticationUtil.getAdminUserName())) diff --git a/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java b/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java index 154bca1e7d..cbdd13453b 100644 --- a/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java +++ b/src/test/java/org/alfresco/repo/security/permissions/impl/AbstractReadPermissionTest.java @@ -36,7 +36,6 @@ import junit.framework.TestCase; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.domain.node.NodeDAO; import org.alfresco.repo.domain.permissions.AccessControlListDAO; import org.alfresco.repo.domain.permissions.AclDAO; @@ -54,7 +53,6 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti import org.alfresco.service.ServiceRegistry; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.model.FileFolderService; -import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; @@ -65,14 +63,12 @@ import org.alfresco.service.cmr.security.OwnableService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.NamespacePrefixResolver; -import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.testing.category.LuceneTests; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; -import org.springframework.orm.hibernate3.LocalSessionFactoryBean; @Category(LuceneTests.class) public class AbstractReadPermissionTest extends TestCase @@ -91,8 +87,6 @@ public class AbstractReadPermissionTest extends TestCase protected MutableAuthenticationDao authenticationDAO; - protected LocalSessionFactoryBean sessionFactory; - protected NodeRef rootNodeRef; protected NamespacePrefixResolver namespacePrefixResolver; diff --git a/src/test/java/org/alfresco/repo/security/person/TestPersonManager.java b/src/test/java/org/alfresco/repo/security/person/TestPersonManager.java index 8e8bfad86e..e86d7960cf 100644 --- a/src/test/java/org/alfresco/repo/security/person/TestPersonManager.java +++ b/src/test/java/org/alfresco/repo/security/person/TestPersonManager.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.security.person; @@ -78,7 +78,12 @@ public class TestPersonManager } else { - return personService.getPerson(userName); + NodeRef personRef = personService.getPerson(userName); + if (personRef != null) + { + people.put(userName, personRef); + } + return personRef; } } }, AuthenticationUtil.getSystemUserName()); diff --git a/src/test/java/org/alfresco/repo/site/CustomRoleTest.java b/src/test/java/org/alfresco/repo/site/CustomRoleTest.java index d3d94c7ddf..22f49b8017 100755 --- a/src/test/java/org/alfresco/repo/site/CustomRoleTest.java +++ b/src/test/java/org/alfresco/repo/site/CustomRoleTest.java @@ -40,12 +40,18 @@ import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.Pair; import org.alfresco.util.PropertyMap; +import org.junit.Before; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; /** * Test custom role for a Site. Based on MNT-12873 * * @author Alex Bykov */ +@Transactional +@ContextConfiguration({"classpath:alfresco/application-context.xml", + "classpath:org/alfresco/repo/site/site-custom-context.xml"}) public class CustomRoleTest extends BaseAlfrescoSpringTest { private static final String USER_ONE = "UserOne_CustomRoleTest"; @@ -54,10 +60,10 @@ public class CustomRoleTest extends BaseAlfrescoSpringTest private SiteService siteService; private PersonService personService; - @SuppressWarnings("deprecation") - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the required services this.authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent"); @@ -96,17 +102,4 @@ public class CustomRoleTest extends BaseAlfrescoSpringTest fail("Custom role breaks sites API. Take a look on MNT-12873\n" + ex.getMessage()); } } - - @Override - protected String[] getConfigLocations() - { - String[] existingConfigLocations = ApplicationContextHelper.CONFIG_LOCATIONS; - - List locations = Arrays.asList(existingConfigLocations); - List mutableLocationsList = new ArrayList(locations); - mutableLocationsList.add("classpath:org/alfresco/repo/site/site-custom-context.xml"); - - String[] result = mutableLocationsList.toArray(new String[mutableLocationsList.size()]); - return result; - } } diff --git a/src/test/java/org/alfresco/repo/site/SiteServiceImplTest.java b/src/test/java/org/alfresco/repo/site/SiteServiceImplTest.java index 691c1fa3c8..a5cf566406 100644 --- a/src/test/java/org/alfresco/repo/site/SiteServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/site/SiteServiceImplTest.java @@ -94,8 +94,13 @@ import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.RedundantTests; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.extensions.surf.util.I18NUtil; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; @@ -106,6 +111,9 @@ import static org.mockito.Mockito.when; * @author Roy Wetherall */ @Category({BaseSpringTestsCategory.class, LuceneTests.class}) +@Transactional +@ContextConfiguration({"classpath:alfresco/application-context.xml", + "classpath:org/alfresco/repo/site/site-custom-context.xml"}) public class SiteServiceImplTest extends BaseAlfrescoSpringTest { public static final StoreRef SITE_STORE = new StoreRef("workspace://SpacesStore"); @@ -158,16 +166,16 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * Called during the transaction setup */ @SuppressWarnings("deprecation") - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { + super.before(); RetryingTransactionCallback work = new RetryingTransactionCallback() { @Override public Object execute() throws Throwable { - // from super.onSetUpInTransaction(); - // Get a reference to the node service nodeService = (NodeService) applicationContext.getBean("nodeService"); contentService = (ContentService) applicationContext.getBean("contentService"); @@ -242,15 +250,14 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService = (TransactionService)this.applicationContext.getBean("transactionComponent"); - transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); + transactionService.getRetryingTransactionHelper().doInTransaction(work, false, true); } - @Override - protected void onTearDownInTransaction() throws Exception { - super.onTearDownInTransaction(); + @After + public void after() throws Exception + { + super.after(); // Reset the sysadmin params on the site service, in case of changes to it siteServiceImpl.setSysAdminParams(sysAdminParams); @@ -260,6 +267,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * This test method ensures that public sites can be created and that their site info is correct. * It also tests that a duplicate site cannot be created. */ + @Test public void testCreateSite() throws Exception { // Create a public site @@ -323,6 +331,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testHasSite() throws Exception { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -353,10 +362,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); - } /** @@ -364,6 +370,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testETHREEOH_2133() throws Exception { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -394,10 +401,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); - } /** @@ -408,6 +412,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * @since 3.4 */ @SuppressWarnings("deprecation") + @Test public void testConfigurableSitePublicGroup() throws Exception { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); @@ -500,6 +505,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest /** * This method tests that admin and system users can set site membership for a site of which they are not SiteManagers. */ + @Test public void testETHREEOH_15() throws Exception { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -550,9 +556,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } private void checkSiteInfo(SiteInfo siteInfo, @@ -583,6 +587,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * should offer consistent, accurate result sets. */ @Category(RedundantTests.class) + @Test public void testListSites() throws Exception { // We'll match against the first few letter of TEST_TITLE in various listSites() tests below. @@ -802,19 +807,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest } } - @Override - protected String[] getConfigLocations() - { - String[] existingConfigLocations = ApplicationContextHelper.CONFIG_LOCATIONS; - - List locations = Arrays.asList(existingConfigLocations); - List mutableLocationsList = new ArrayList(locations); - mutableLocationsList.add("classpath:org/alfresco/repo/site/site-custom-context.xml"); - - String[] result = mutableLocationsList.toArray(new String[mutableLocationsList.size()]); - return result; - } - + @Test public void testMNT_13710() throws Exception { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -855,14 +848,13 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } /** * Test listSite case sensitivity */ + @Test public void testListSitesCaseSensitivity() throws Exception { // RUN AS USER_ONE @@ -895,6 +887,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * This test method ensures that searches with wildcards work as they should */ @Category(RedundantTests.class) + @Test public void testfindSitesWithWildcardTitles() throws Exception { // How many sites are there already in the repo? @@ -927,6 +920,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * This test method ensures that searches with wildcards work as they should */ @Category(RedundantTests.class) + @Test public void testfindSitesForLiveSearchWithWildcardTitles() throws Exception { // How many sites are there already in the repo? @@ -1052,6 +1046,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest assertEquals("Matched wrong number of sites for top draw", 1, sites.size()); } + @Test public void testGetSite() { // Get a site that isn't there @@ -1093,6 +1088,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testUpdateSite() { SiteInfo siteInfo = new SiteInfoImpl(TEST_SITE_PRESET, "testUpdateSite", "changedTitle", "changedDescription", SiteVisibility.PRIVATE, null); @@ -1122,6 +1118,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest checkSiteInfo(siteInfo, TEST_SITE_PRESET, "testUpdateSite", "changedTitle", "changedDescription", SiteVisibility.PUBLIC); } + @Test public void testDeleteSite_DoesNotExist() { // delete a site that isn't there @@ -1136,6 +1133,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testDeleteSite_ViaNodeService() { String siteShortName = "testUpdateSite"; @@ -1155,6 +1153,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testMoveSite_ViaNodeService() { String siteShortName1 = "testMoveSite" + GUID.generate(); @@ -1182,6 +1181,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest /** * This is an integration test for MNT-18014 */ + @Test public void testMoveFolderStructureWithNonInheritedPermission() { //Login to share as the admin user @@ -1287,6 +1287,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return nodeService.getProperties(childAssocs.get(0).getChildRef()).get(ContentModel.PROP_NAME).toString(); } + @Test public void testDeleteSite() { @SuppressWarnings("deprecation") @@ -1332,6 +1333,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest assertTrue(authorityService.authorityExists(testGroup)); } + @Test public void testIsPublic() { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -1381,11 +1383,10 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } + @Test public void testMembership() { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -1562,11 +1563,10 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } + @Test public void testDefaults() { assertFalse(this.siteService.isSiteAdmin(null)); @@ -1575,6 +1575,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest assertNotNull(comparator); } + @Test public void testListSiteMemberships() { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -1663,13 +1664,12 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } + @Test public void testJoinLeave() { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -1751,11 +1751,10 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } + @Test public void testContainer() { // Create a couple of sites as user one @@ -1821,6 +1820,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testSiteGetRoles() { List roles = this.siteService.getSiteRoles(); @@ -1837,6 +1837,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest // For custom roles, see testCustomSiteType() } + @Test public void testCustomSiteProperties() { QName additionalInformationQName = QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "additionalInformation"); @@ -1870,6 +1871,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * it behaves correctly. */ @SuppressWarnings("deprecation") + @Test public void testCustomSiteType() { final String CS_URI = "http://example.com/site"; @@ -1997,6 +1999,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest assertEquals(true, roles.contains(SiteServiceImpl.SITE_MANAGER)); } + @Test public void testGroupMembership() { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -2220,15 +2223,14 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } /** * * See https://issues.alfresco.com/jira/browse/MNT-2229 */ + @Test public void testUserRoleInGroups() { String sitName = "testMembership2" + UUID.randomUUID(); @@ -2255,6 +2257,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * * See https://issues.alfresco.com/jira/browse/JAWS-291 */ + @Test public void testSiteVisibility() { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -2330,9 +2333,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } /** @@ -2370,6 +2371,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * ALF-10343 - When the default public group for sites isn't EVERYBODY, * check that creating and altering sites results in the correct permissions */ + @Test public void testNonDefaultPublicGroupPermissions() throws Exception { // Sanity check the current permissions @@ -2573,6 +2575,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * Lower User membership - should be prevented (last manager) * */ + @Test public void testALFCOM_3109() { // USER_ONE - SiteManager @@ -2638,6 +2641,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * Remove User membership - should be prevented (last manager) * */ + @Test public void testALFCOM_3111() { // USER_ONE - SiteManager @@ -2696,6 +2700,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * Attempt to access a private site by someone that is not a consumer of that site. * */ + @Test public void testETHREEOH_1268() { RetryingTransactionCallback work = new RetryingTransactionCallback() @@ -2728,9 +2733,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(work); - startNewTransaction(); } /** @@ -2740,6 +2743,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * authorities is based on a pattern that uses the site name. * However, you are free to change a site's display name. */ + @Test public void testALF_3200() throws Exception { // Create the site @@ -2779,6 +2783,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest assertEquals(newName2, nodeService.getProperty(siteNodeRef, ContentModel.PROP_TITLE)); } + @Test public void testALF_5556() throws Exception { String siteName = "testALF_5556"; @@ -2800,6 +2805,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testALF8036_PermissionsAfterCopyingFolderBetweenSites() throws Exception { alf8036Impl(true); @@ -2863,6 +2869,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest * ALF-1017 - Non sites in the Sites Space container shouldn't * break the listing methods */ + @Test public void testALF_1017_nonSitesInSitesSpace() throws Exception { // Initially listing is fine @@ -2932,6 +2939,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return siteInfo; } + @Test public void testRenameSite() { // test that changing the name of a site generates an appropriate exception @@ -2994,6 +3002,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest return result; } + @Test public void testPermissionsAfterMovingFolderBetweenSites() throws Exception { alf8036Impl(false); @@ -3001,6 +3010,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest // == Test the JavaScript API == + @Test public void testJSAPI() throws Exception { // Create a site with a custom property @@ -3020,6 +3030,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest this.scriptService.executeScript(location, model); } + @Test public void testListMembersInfo() { String siteShortName = "testMemberInfo"; @@ -3079,6 +3090,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest /** * From CLOUD-957, insure that GROUP_EVERYONE does not have read access to private sites' containers. */ + @Test public void testPrivateSite() throws Exception { String siteName = GUID.generate(); @@ -3095,6 +3107,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest /** * From CLOUD-957, insure that GROUP_EVERYONE does not have read access to moderated sites' containers. */ + @Test public void testModeratedSite() throws Exception { String siteName = GUID.generate(); @@ -3111,6 +3124,7 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest /** * From MNT-14452, insure that GROUP_EVERYONE have read access to public sites' containers. */ + @Test public void testChangeSiteVisibility() { String siteName = GUID.generate(); diff --git a/src/test/java/org/alfresco/repo/template/XSLTProcessorTest.java b/src/test/java/org/alfresco/repo/template/XSLTProcessorTest.java index 82432e92f7..3ecac2a830 100644 --- a/src/test/java/org/alfresco/repo/template/XSLTProcessorTest.java +++ b/src/test/java/org/alfresco/repo/template/XSLTProcessorTest.java @@ -45,13 +45,17 @@ import org.alfresco.util.GUID; import org.alfresco.util.XMLUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * @author Brian * */ @Category({BaseSpringTestsCategory.class}) +@Transactional public class XSLTProcessorTest extends BaseAlfrescoSpringTest { private final static Log log = LogFactory.getLog(XSLTProcessorTest.class); @@ -61,16 +65,10 @@ public class XSLTProcessorTest extends BaseAlfrescoSpringTest private TemplateService templateService; private Repository repositoryHelper; - /* - * (non-Javadoc) - * - * @see org.alfresco.util.BaseAlfrescoSpringTest#onSetUpInTransaction() - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); this.nodeService = (NodeService) this.applicationContext.getBean("NodeService"); this.contentService = (ContentService) this.applicationContext.getBean("ContentService"); this.fileFolderService = (FileFolderService) this.applicationContext.getBean("FileFolderService"); @@ -80,6 +78,7 @@ public class XSLTProcessorTest extends BaseAlfrescoSpringTest this.companyHome = repositoryHelper.getCompanyHome(); } + @Test public void testSimplestStringTemplate() throws Exception { try @@ -102,6 +101,7 @@ public class XSLTProcessorTest extends BaseAlfrescoSpringTest } } + @Test public void testSimplestNodeTemplate() throws Exception { try @@ -126,6 +126,7 @@ public class XSLTProcessorTest extends BaseAlfrescoSpringTest } } + @Test public void testLocalisedNodeTemplate() throws Exception { // This should have the same result as testSimplestNodeTemplate as the localization should be ignored for node templates. @@ -151,6 +152,7 @@ public class XSLTProcessorTest extends BaseAlfrescoSpringTest } } + @Test public void testSimplestClasspathTemplate() throws Exception { try @@ -174,6 +176,7 @@ public class XSLTProcessorTest extends BaseAlfrescoSpringTest } } + @Test public void testLocalisedClasspathTemplate() throws Exception { try @@ -214,6 +217,7 @@ public class XSLTProcessorTest extends BaseAlfrescoSpringTest } + @Test public void testTemplateServiceBinding() throws Exception { try diff --git a/src/test/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java b/src/test/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java index 1c0d3e07e3..cf58ee9dea 100644 --- a/src/test/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/thumbnail/ThumbnailServiceImplTest.java @@ -46,8 +46,10 @@ import org.alfresco.repo.content.transform.AbstractContentTransformerTest; import org.alfresco.repo.content.transform.ContentTransformer; import org.alfresco.repo.content.transform.magick.ImageResizeOptions; import org.alfresco.repo.content.transform.magick.ImageTransformationOptions; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoOracle9Dialect; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect; +import org.alfresco.repo.domain.dialect.DB2Dialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.Oracle9Dialect; +import org.alfresco.repo.domain.dialect.SQLServerDialect; import org.alfresco.repo.jscript.ClasspathScriptLocation; import org.alfresco.repo.model.Repository; import org.alfresco.repo.thumbnail.script.ScriptThumbnailService; @@ -87,7 +89,6 @@ import org.alfresco.service.namespace.QNamePattern; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.OwnJVMTestsCategory; -import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; import org.alfresco.util.TempFileProvider; @@ -97,9 +98,12 @@ import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.spi.LoggingEvent; -import org.hibernate.dialect.DB2Dialect; -import org.hibernate.dialect.Dialect; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * Thumbnail service implementation unit test @@ -108,6 +112,9 @@ import org.junit.experimental.categories.Category; * @author Neil McErlean */ @Category(OwnJVMTestsCategory.class) +@Transactional +@ContextConfiguration({"classpath:alfresco/application-context.xml", + "classpath:org/alfresco/repo/thumbnail/test-thumbnail-context.xml"}) public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest { private static Log logger = LogFactory.getLog(ThumbnailServiceImplTest.class); @@ -132,14 +139,10 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest private static final long TEST_LONG_RUNNING_TRANSFORM_TIME = 5000; private static final String TEST_LONG_RUNNING_PROPERTY_VALUE = "NewValue"; - /** - * Called during the transaction setup - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the required services this.secureNodeService = (NodeService) this.applicationContext.getBean("NodeService"); @@ -164,18 +167,6 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest .getChildRef(); } - @Override protected String[] getConfigLocations() - { - List configLocations = new ArrayList(); - for (String config : ApplicationContextHelper.CONFIG_LOCATIONS) - { - configLocations.add(config); - } - configLocations.add("classpath:org/alfresco/repo/thumbnail/test-thumbnail-context.xml"); - - return configLocations.toArray(new String[0]); - } - private void checkTransformer() { ContentTransformer transformer = this.contentService.getImageTransformer(); @@ -190,6 +181,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testCreateRenditionThumbnailFromImage() throws Exception { QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); @@ -212,6 +204,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest outputThumbnailTempContentLocation(thumbnail0, "jpg", "doclib test"); } + @Test public void testCreateRenditionThumbnailFromPdf() throws Exception { QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); @@ -234,6 +227,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest outputThumbnailTempContentLocation(thumbnail0, "jpg", "doclib test"); } + @Test public void testCreateRenditionThumbnailFromPdfPage2() throws Exception { ImageTransformationOptions options = new ImageTransformationOptions(); @@ -267,6 +261,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest System.out.println("doclib_2 test: " + tempFile.getPath()); } + @Test public void testCreateThumbnailFromImage() throws Exception { checkTransformer(); @@ -338,6 +333,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest outputThumbnailTempContentLocation(thumbnail4, "jpg", "half2 - 50%x50%, from gif"); } + @Test public void testDuplicationNames() throws Exception { checkTransformer(); @@ -367,6 +363,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest /** * @since 3.5.0 */ + @Test public void testCreateFailingThumbnail() throws Exception { //see REPO-1528 @@ -383,9 +380,9 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest // It should not be renditioned and should not be marked as having any failed thumbnails. assertFalse(secureNodeService.hasAspect(corruptNode, RenditionModel.ASPECT_RENDITIONED)); assertFalse(secureNodeService.hasAspect(corruptNode, ContentModel.ASPECT_FAILED_THUMBNAIL_SOURCE)); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); // Attempt to perform a thumbnail that we know will fail. transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -467,8 +464,9 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest /** * Inbound rule must not be applied on failed thumbnail * - * @see MNT-10914 + * see MNT-10914 */ + @Test public void testRuleExecutionOnFailedThumbnailChild() throws Exception { // create inbound rule on folder @@ -483,8 +481,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest rule.applyToChildren(true); services.getRuleService().saveRule(folder, rule); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); final NodeRef corruptNode = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() { @@ -542,6 +540,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest * * @since 4.0.1 */ + @Test public void testCreateTransientlyFailingThumbnail() throws Exception { Map props = new HashMap(); @@ -560,9 +559,9 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest // It should not be renditioned and should not be marked as having any failed thumbnails. assertFalse(secureNodeService.hasAspect(testNode, RenditionModel.ASPECT_RENDITIONED)); assertFalse(secureNodeService.hasAspect(testNode, ContentModel.ASPECT_FAILED_THUMBNAIL_SOURCE)); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); // Attempt to perform a thumbnail that we know will fail. transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -593,6 +592,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest }); } + @Test public void testThumbnailUpdate() throws Exception { checkTransformer(); @@ -618,6 +618,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest assertEquals(ContentModel.TYPE_THUMBNAIL, secureNodeService.getType(thumbnail1)); } + @Test public void testGetThumbnailByName() throws Exception { checkTransformer(); @@ -715,6 +716,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest * * @throws IOException */ + @Test public void testIfNodesExistsAfterCreateThumbnail() throws IOException { // Add the log appender to the root logger @@ -727,8 +729,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); ThumbnailDefinition details = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(qname.getLocalName()); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // create thumbnail transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() @@ -751,6 +753,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest /** * See REPO-1580, MNT-17113, REPO-1644 (and related) */ + @Test public void testLastThumbnailModificationDataContentUpdates() throws Exception { final NodeRef pdfOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_PDF); @@ -761,8 +764,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest details.getTransformationOptions(), "doclib"); assertNotNull(thumbnail); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); Thread.sleep(1000); @@ -791,6 +794,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest /** * See REPO-2257, MNT-17661 */ + @Test public void testLastThumbnailModificationDataContentCopy() throws Exception { final NodeRef pdfOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_PDF); @@ -801,8 +805,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest details.getTransformationOptions(), "doclib"); assertNotNull(thumbnail); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); Thread.sleep(1000); @@ -820,6 +824,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest /** * See REPO-1580, MNT-17113 (and related) */ + @Test public void testLockedContent() throws Exception { NodeRef sharedHomeNodeRef = repositoryHelper.getSharedHome(); @@ -836,10 +841,9 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest lockService.lock(pdfOrig, LockType.READ_ONLY_LOCK); - setComplete(); - endTransaction(); - - startNewTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); authenticationComponent.setCurrentUser(user2); @@ -856,12 +860,12 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest details.getTransformationOptions(), "doclib"); assertNotNull(thumbnail); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); Thread.sleep(1000); - startNewTransaction(); + TestTransaction.start(); authenticationComponent.setCurrentUser(user1); @@ -873,10 +877,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest lockService.unlock(pdfOrig, false); secureNodeService.deleteNode(pdfOrig); - setComplete(); - endTransaction(); - - startNewTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); } private void setNewContent(NodeRef noderef, String quickFileName, String mimetype) throws IOException @@ -1070,6 +1072,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest } @SuppressWarnings("deprecation") + @Test public void testAutoUpdate() throws Exception { checkTransformer(); @@ -1081,8 +1084,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest final NodeRef thumbnail = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, details .getMimetype(), details.getTransformationOptions(), details.getName()); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1106,6 +1109,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest // Thread.sleep(1000); } + @Test public void testHTMLToImageAndSWF() throws Exception { NodeRef nodeRef = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_HTML); @@ -1137,6 +1141,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest } } + @Test public void testThumbnailServiceCreateApi() throws Exception { // Create a second folder @@ -1220,6 +1225,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest outputThumbnailTempContentLocation(thumbnail1, "png", "'null' - 64x64, marked as thumbnail"); } + @Test public void testRegistry() { ThumbnailRegistry thumbnailRegistry = this.thumbnailService.getThumbnailRegistry(); @@ -1233,6 +1239,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest // == Test the JavaScript API == + @Test public void testJSAPI() throws Exception { NodeRef jpgOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG); @@ -1254,6 +1261,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest * This test method tests the thumbnail placeholders which are handled in the {@link ScriptThumbnailService}. * See ALF-6566. */ + @Test public void testPlaceHoldersByMimeType() throws Exception { // Retrieve the classpath paths for all the standard icon resources for doclib. @@ -1328,8 +1336,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest actionService.executeAction(createThumbnailAction, source, true, true); } - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); // Thumbnailing process(es) are running in other threads, do the // concurrent work here @@ -1403,6 +1411,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testLongRunningThumbnails() throws Exception { logger.debug("Starting testLongRunningThumbnails"); @@ -1420,6 +1429,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest * @throws Exception * @see MNT-15135 */ + @Test public void testUpdatePropertyDuringLongRunningThumbnail() throws Exception { //see REPO-1528 @@ -1466,6 +1476,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testCreateMultipleLongRunningThumbnails() throws Exception { logger.debug("Starting testCreateMultipleLongRunningThumbnails"); @@ -1572,8 +1583,8 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest private boolean shouldTestBeSkippedForCurrentDB() { Dialect dialect = (Dialect) applicationContext.getBean("dialect"); - return dialect instanceof AlfrescoOracle9Dialect - || dialect instanceof AlfrescoSQLServerDialect + return dialect instanceof Oracle9Dialect + || dialect instanceof SQLServerDialect || dialect instanceof DB2Dialect; } } diff --git a/src/test/java/org/alfresco/repo/thumbnail/conditions/NodeEligibleForRethumbnailingEvaluatorTest.java b/src/test/java/org/alfresco/repo/thumbnail/conditions/NodeEligibleForRethumbnailingEvaluatorTest.java index 1e7a29b262..1c4c18977f 100644 --- a/src/test/java/org/alfresco/repo/thumbnail/conditions/NodeEligibleForRethumbnailingEvaluatorTest.java +++ b/src/test/java/org/alfresco/repo/thumbnail/conditions/NodeEligibleForRethumbnailingEvaluatorTest.java @@ -43,7 +43,11 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * This class tests {@link NodeEligibleForRethumbnailingEvaluator}. @@ -52,6 +56,7 @@ import org.junit.experimental.categories.Category; * @since 3.5.0 */ @Category(OwnJVMTestsCategory.class) +@Transactional public class NodeEligibleForRethumbnailingEvaluatorTest extends BaseSpringTest { private final QName thumbnailDef1 = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "thumbDef1"); @@ -72,13 +77,9 @@ public class NodeEligibleForRethumbnailingEvaluatorTest extends BaseSpringTest * No thumbnails. 1 failed attempt 2 seconds ago. */ private NodeRef recentlyFailedNodeRef; - - /** - * @see org.springframework.test.AbstractTransactionalSpringContextTests#onSetUpInTransaction() - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { final Date now = new Date(); final Date twoSecondsAgo = new Date(now.getTime() - 2000); @@ -117,13 +118,14 @@ public class NodeEligibleForRethumbnailingEvaluatorTest extends BaseSpringTest nodeService.setProperty(thumbDef1FailureNode, ContentModel.PROP_FAILURE_COUNT, 1); } - @Override - public void onTearDownInTransaction() + @After + public void after() { nodeService.deleteStore(testStoreRef); } @SuppressWarnings("deprecation") + @Test public void testNodeWithNoFailedThumbnails() { // Such a node is always eligible for thumbnailing. @@ -135,13 +137,14 @@ public class NodeEligibleForRethumbnailingEvaluatorTest extends BaseSpringTest failureHandlingOptions.getRetryCount()); condition.setParameterValue(NodeEligibleForRethumbnailingEvaluator.PARAM_QUIET_PERIOD, 0L); condition.setParameterValue(NodeEligibleForRethumbnailingEvaluator.PARAM_QUIET_PERIOD_RETRIES_ENABLED, true); - + NodeEligibleForRethumbnailingEvaluator evaluator = (NodeEligibleForRethumbnailingEvaluator)this.applicationContext.getBean(NodeEligibleForRethumbnailingEvaluator.NAME); - + assertTrue(evaluator.evaluate(condition, newUnthumbnailedNodeRef)); } + @Test public void testNodeWithFailedThumbnails() { // A "non-difficult" node is one which is not yet known to be difficult to thumbnail. diff --git a/src/test/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java b/src/test/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java index 4b98962815..87e8d1742a 100644 --- a/src/test/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java +++ b/src/test/java/org/alfresco/repo/transaction/RetryingTransactionHelperTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.transaction; import java.util.ArrayList; @@ -35,14 +35,13 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; - import javax.transaction.Status; import javax.transaction.UserTransaction; - import junit.framework.TestCase; - import org.alfresco.error.ExceptionStackUtil; import org.alfresco.model.ContentModel; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.permissions.AccessDeniedException; @@ -63,13 +62,9 @@ import org.alfresco.util.transaction.TransactionListenerAdapter; import org.apache.commons.lang.mutable.MutableInt; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.SessionFactory; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.MySQLInnoDBDialect; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; import org.springframework.dao.ConcurrencyFailureException; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; /** * Tests the transaction retrying behaviour with various failure modes. @@ -502,32 +497,6 @@ public class RetryingTransactionHelperTest extends TestCase } } - public void testLostConnectionRecovery() - { - RetryingTransactionCallback killConnectionCallback = new RetryingTransactionCallback() - { - private boolean killed = false; - public Object execute() throws Throwable - { - // Do some work - nodeService.deleteNode(workingNodeRef); - // Successful upon retry - if (killed) - { - return null; - } - // Kill the connection the first time - HibernateConnectionKiller killer = new HibernateConnectionKiller(); - killer.setSessionFactory((SessionFactory)ctx.getBean("sessionFactory")); - killer.killConnection(); - killed = true; - return null; - } - }; - // This should work - txnHelper.doInTransaction(killConnectionCallback); - } - public void testZeroAndNegativeRetries() { final MutableInt callCount = new MutableInt(0); @@ -829,16 +798,4 @@ public class RetryingTransactionHelperTest extends TestCase } } - - /** - * Helper class to kill the session's DB connection - */ - private class HibernateConnectionKiller extends HibernateDaoSupport - { - @SuppressWarnings("deprecation") - private void killConnection() throws Exception - { - getSession().connection().rollback(); - } - } } diff --git a/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java b/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java index ade0b0238e..9a4e0b3a81 100644 --- a/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/transaction/TransactionServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.transaction; import javax.transaction.RollbackException; @@ -32,6 +32,8 @@ import javax.transaction.UserTransaction; import junit.framework.TestCase; import org.alfresco.model.ContentModel; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; @@ -46,8 +48,6 @@ import org.alfresco.service.transaction.ReadOnlyServerException; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.PropertyMap; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.PostgreSQLDialect; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; import org.springframework.dao.InvalidDataAccessApiUsageException; diff --git a/src/test/java/org/alfresco/repo/transfer/NodeCrawlerTest.java b/src/test/java/org/alfresco/repo/transfer/NodeCrawlerTest.java index 4c612bda16..e929fad37b 100644 --- a/src/test/java/org/alfresco/repo/transfer/NodeCrawlerTest.java +++ b/src/test/java/org/alfresco/repo/transfer/NodeCrawlerTest.java @@ -50,6 +50,8 @@ import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; import org.alfresco.util.testing.category.LuceneTests; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; /** @@ -68,18 +70,20 @@ public class NodeCrawlerTest extends BaseAlfrescoSpringTest * Called during the transaction setup */ @SuppressWarnings("deprecation") - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the required services - this.nodeService = (NodeService) this.getApplicationContext().getBean("NodeService"); - this.serviceRegistry = (ServiceRegistry) this.getApplicationContext().getBean("ServiceRegistry"); - this.nodeCrawlerFactory = (NodeCrawlerFactory) this.getApplicationContext().getBean("NodeCrawlerFactory"); - Repository repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper"); + this.nodeService = (NodeService) applicationContext.getBean("NodeService"); + this.serviceRegistry = (ServiceRegistry) applicationContext.getBean("ServiceRegistry"); + this.nodeCrawlerFactory = (NodeCrawlerFactory) applicationContext.getBean("NodeCrawlerFactory"); + Repository repositoryHelper = (Repository) applicationContext.getBean("repositoryHelper"); this.companyHome = repositoryHelper.getCompanyHome(); } + @Test public void testContentClassFilter() throws Exception { NodeRef node1 = makeNode(companyHome, ContentModel.TYPE_BASE); @@ -122,6 +126,7 @@ public class NodeCrawlerTest extends BaseAlfrescoSpringTest } + @Test public void testChildAssociationFinder() { makeNode(companyHome, ContentModel.TYPE_BASE); @@ -157,6 +162,7 @@ public class NodeCrawlerTest extends BaseAlfrescoSpringTest assertEquals(node15, new ArrayList(results).get(0)); } + @Test public void testCrawler() { NodeRef node8 = makeNode(companyHome, ContentModel.TYPE_FOLDER); diff --git a/src/test/java/org/alfresco/repo/transfer/RepoTransferReceiverImplTest.java b/src/test/java/org/alfresco/repo/transfer/RepoTransferReceiverImplTest.java index 4ff06c4b8b..a786b343a5 100644 --- a/src/test/java/org/alfresco/repo/transfer/RepoTransferReceiverImplTest.java +++ b/src/test/java/org/alfresco/repo/transfer/RepoTransferReceiverImplTest.java @@ -79,9 +79,13 @@ import org.alfresco.util.GUID; import org.alfresco.util.testing.category.LuceneTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.ArgumentCaptor; +import org.springframework.test.context.transaction.TestTransaction; import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.DefaultTransactionDefinition; /** @@ -91,6 +95,7 @@ import org.springframework.transaction.support.DefaultTransactionDefinition; */ @SuppressWarnings("deprecation") @Category({BaseSpringTestsCategory.class}) +@Transactional public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest { private static int fileCount = 0; @@ -105,19 +110,10 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest private Repository repositoryHelper; private NamespaceService namespaceService; - @Override - public void runBare() throws Throwable + @Before + public void before() throws Exception { - preventTransaction(); - super.runBare(); - } - - /** - * Called during the transaction setup - */ - protected void onSetUp() throws Exception - { - super.onSetUp(); + super.before(); System.out.println("java.io.tmpdir == " + System.getProperty("java.io.tmpdir")); // Get the required services @@ -129,21 +125,21 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest this.transactionService = (TransactionService) this.applicationContext.getBean("transactionComponent"); this.authenticationComponent = (AuthenticationComponent) this.applicationContext .getBean("authenticationComponent"); - this.receiver = (RepoTransferReceiverImpl) this.getApplicationContext().getBean("transferReceiver"); - this.policyComponent = (PolicyComponent) this.getApplicationContext().getBean("policyComponent"); - this.searchService = (SearchService) this.getApplicationContext().getBean("searchService"); - this.repositoryHelper = (Repository) this.getApplicationContext().getBean("repositoryHelper"); - this.namespaceService = (NamespaceService) this.getApplicationContext().getBean("namespaceService"); + this.receiver = (RepoTransferReceiverImpl) this.applicationContext.getBean("transferReceiver"); + this.policyComponent = (PolicyComponent) this.applicationContext.getBean("policyComponent"); + this.searchService = (SearchService) this.applicationContext.getBean("searchService"); + this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper"); + this.namespaceService = (NamespaceService) this.applicationContext.getBean("namespaceService"); this.dummyContent = "This is some dummy content."; this.dummyContentBytes = dummyContent.getBytes("UTF-8"); - setTransactionDefinition(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW)); authenticationComponent.setSystemUserAsCurrentUser(); - startNewTransaction(); guestHome = repositoryHelper.getGuestHome(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); } + @Test public void testDelete() { log.debug("start testDelete"); @@ -381,75 +377,57 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest log.info("end testLockTimeout"); } + @Test public void testSaveContent() throws Exception { log.info("start testSaveContent"); - - final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); - - startNewTransaction(); + String transferId = receiver.start("1234", true, receiver.getVersion()); try { - String transferId = receiver.start("1234", true, receiver.getVersion()); - try - { - String contentId = "mytestcontent"; - receiver.saveContent(transferId, contentId, new ByteArrayInputStream(dummyContentBytes)); - File contentFile = new File(receiver.getStagingFolder(transferId), contentId); - assertTrue(contentFile.exists()); - assertEquals(dummyContentBytes.length, contentFile.length()); - } - finally - { - receiver.end(transferId); - } + String contentId = "mytestcontent"; + receiver.saveContent(transferId, contentId, new ByteArrayInputStream(dummyContentBytes)); + File contentFile = new File(receiver.getStagingFolder(transferId), contentId); + assertTrue(contentFile.exists()); + assertEquals(dummyContentBytes.length, contentFile.length()); } finally { - endTransaction(); + receiver.end(transferId); } } + @Test public void testSaveSnapshot() throws Exception { log.info("start testSaveSnapshot"); - - final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); - - startNewTransaction(); + + String transferId = receiver.start("1234", true, receiver.getVersion()); + File snapshotFile = null; try { - String transferId = receiver.start("1234", true, receiver.getVersion()); - File snapshotFile = null; - try - { - TransferManifestNode node = createContentNode(); - List nodes = new ArrayList(); - nodes.add(node); - String snapshot = createSnapshot(nodes); + TransferManifestNode node = createContentNode(); + List nodes = new ArrayList(); + nodes.add(node); + String snapshot = createSnapshot(nodes); - receiver.saveSnapshot(transferId, new ByteArrayInputStream(snapshot.getBytes("UTF-8"))); + receiver.saveSnapshot(transferId, new ByteArrayInputStream(snapshot.getBytes("UTF-8"))); - File stagingFolder = receiver.getStagingFolder(transferId); - snapshotFile = new File(stagingFolder, "snapshot.xml"); - assertTrue(snapshotFile.exists()); - assertEquals(snapshot.getBytes("UTF-8").length, snapshotFile.length()); - } - finally - { - receiver.end(transferId); - if (snapshotFile != null) - { - assertFalse(snapshotFile.exists()); - } - } + File stagingFolder = receiver.getStagingFolder(transferId); + snapshotFile = new File(stagingFolder, "snapshot.xml"); + assertTrue(snapshotFile.exists()); + assertEquals(snapshot.getBytes("UTF-8").length, snapshotFile.length()); } finally { - endTransaction(); + receiver.end(transferId); + if (snapshotFile != null) + { + assertFalse(snapshotFile.exists()); + } } } + @Test public void testBasicCommit() throws Exception { log.info("start testBasicCommit"); @@ -547,6 +525,7 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testMoreComplexCommit() throws Exception { log.info("start testMoreComplexCommit"); @@ -691,6 +670,7 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest * @throws Exception */ @SuppressWarnings("unchecked") + @Test public void testNodeDeleteAndRestore() throws Exception { log.info("start testNodeDeleteAndRestore"); @@ -1094,6 +1074,7 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testJira_ALF_2772() throws Exception { log.debug("start testJira_ALF_2772"); @@ -1307,6 +1288,7 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest * @throws Exception */ + @Test public void testMNT11057() throws Exception { String folder1Name = "H1"; @@ -1314,8 +1296,7 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest String folder3Name = "H3"; //Step 1 transfer from repo A (H1 -> H2) - setDefaultRollback(true); - startNewTransaction(); + TestTransaction.start(); String transferIdA1 = receiver.start("transferFromRepoA1", true, receiver.getVersion()); @@ -1329,10 +1310,9 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest nodesA1.add(folder1A1); nodesA1.add(folder2A1); - endTransaction(); - - this.setDefaultRollback(false); - startNewTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); try { String snapshot = createSnapshot(nodesA1, "repo A"); @@ -1354,12 +1334,12 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest finally { receiver.end(transferIdA1); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); } //Step 2 trasfer from repo B (H1 -> H3) - setDefaultRollback(true); - startNewTransaction(); + TestTransaction.start(); String transferIdB1 = receiver.start("transferFromRepoB1", true, receiver.getVersion()); @@ -1372,10 +1352,9 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest nodesB1.add(folder1B1); nodesB1.add(folder3B1); - endTransaction(); - - this.setDefaultRollback(false); - startNewTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); + TestTransaction.start(); try { String snapshot = createSnapshot(nodesB1, "repo B"); @@ -1391,7 +1370,8 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest finally { receiver.end(transferIdB1); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); } assertTrue(nodeService.exists(folder1A1.getNodeRef())); @@ -1408,7 +1388,7 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest log.info("has Alien"); assertTrue(nodeService.hasAspect(folder3B1.getNodeRef(), TransferModel.ASPECT_ALIEN)); - startNewTransaction(); + TestTransaction.start(); moveNode(folder3A1, folder1A1); moveNode(folder2A1, folder3A1); @@ -1419,11 +1399,12 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest nodesA1.add(folder3A1); nodesA1.add(folder2A1); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); //Step 3 transfer from repo A again (H2 is moved to newly created H3 on A: H1 -> H3 -> H2) - startNewTransaction(); + TestTransaction.start(); try { String transferId = receiver.start("transferFromRepoA1Again", true, receiver.getVersion()); @@ -1441,27 +1422,25 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest } finally { - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); } } + @Test public void testAsyncCommit() throws Exception { log.info("start testAsyncCommit"); - - this.setDefaultRollback(false); - localTestAsyncCommit(); } private String localTestAsyncCommit() throws Exception, InterruptedException { - startNewTransaction(); final String transferId = receiver.start("1234", true, receiver.getVersion()); - endTransaction(); - startNewTransaction(); + TestTransaction.start(); final List nodes = new ArrayList(); final TransferManifestNormalNode node1 = createContentNode(); nodes.add(node1); @@ -1491,24 +1470,28 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest associatePeers(node1, node2); moveNode(node2, node11); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); String snapshot = createSnapshot(nodes); - startNewTransaction(); + TestTransaction.start(); receiver.saveSnapshot(transferId, new ByteArrayInputStream(snapshot.getBytes("UTF-8"))); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); for (TransferManifestNode node : nodes) { - startNewTransaction(); + TestTransaction.start(); receiver.saveContent(transferId, node.getUuid(), new ByteArrayInputStream(dummyContentBytes)); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); } - startNewTransaction(); + TestTransaction.start(); receiver.commitAsync(transferId); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); log.debug("Posted request for commit"); @@ -1517,15 +1500,16 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest while (progress == null || !TransferProgress.getTerminalStatuses().contains(progress.getStatus())) { Thread.sleep(500); - startNewTransaction(); + TestTransaction.start(); progress = progressMonitor.getProgress(transferId); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); log.debug("Progress indication: " + progress.getStatus() + ": " + progress.getCurrentPosition() + "/" + progress.getEndPosition()); } assertEquals(TransferProgress.Status.COMPLETE, progress.getStatus()); - startNewTransaction(); + TestTransaction.start(); try { assertTrue(nodeService.getAspects(node1.getNodeRef()).contains(ContentModel.ASPECT_ATTACHABLE)); @@ -1537,17 +1521,16 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest } finally { - endTransaction(); + TestTransaction.end(); } return transferId; } + @Test public void testAsyncCommitWithSummaryReport() throws Exception { log.info("start testAsyncCommitWithSummaryReport"); - - this.setDefaultRollback(false); - Properties properties = (Properties) this.getApplicationContext().getBean("global-properties"); + Properties properties = (Properties) this.applicationContext.getBean("global-properties"); //save the value of this summary report property to restore later String prevValue = properties.getProperty(TransferCommons.TS_SIMPLE_REPORT); try @@ -1571,13 +1554,12 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest } } + @Test public void testAsyncCommitWithOutSummaryReport() throws Exception { log.info("start testAsyncCommitWithOutSummaryReport"); - this.setDefaultRollback(false); - this.setDefaultRollback(false); - Properties properties = (Properties) this.getApplicationContext().getBean("global-properties"); + Properties properties = (Properties) this.applicationContext.getBean("global-properties"); //save the value of this summary report property to restore later String prevValue = properties.getProperty(TransferCommons.TS_SIMPLE_REPORT); try @@ -1608,7 +1590,7 @@ public class RepoTransferReceiverImplTest extends BaseAlfrescoSpringTest // check the destination report was generated and // check that the simplified destination transfer report was // generated - FileFolderService fileFolderService = (FileFolderService) this.getApplicationContext().getBean("fileFolderService"); + FileFolderService fileFolderService = (FileFolderService) this.applicationContext.getBean("fileFolderService"); NodeRef destinationReportNodeRef = new NodeRef(transferId); assertTrue(nodeService.exists(destinationReportNodeRef)); diff --git a/src/test/java/org/alfresco/repo/transfer/TransferServiceImplTest.java b/src/test/java/org/alfresco/repo/transfer/TransferServiceImplTest.java index 904b4bfcec..722e0bd2bb 100644 --- a/src/test/java/org/alfresco/repo/transfer/TransferServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/transfer/TransferServiceImplTest.java @@ -25,9 +25,6 @@ */ package org.alfresco.repo.transfer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - import java.io.BufferedReader; import java.io.File; import java.io.FileWriter; @@ -45,27 +42,16 @@ import java.util.Locale; import java.util.Map; import java.util.Queue; import java.util.Set; - -import javax.xml.XMLConstants; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; - import org.alfresco.model.ContentModel; -import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.model.Repository; import org.alfresco.repo.security.authentication.AuthenticationComponent; -import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; -import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; +import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transfer.manifest.TransferManifestNodeFactory; import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.lock.LockService; -import org.alfresco.service.cmr.lock.LockType; import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ContentData; @@ -78,11 +64,7 @@ import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.Path; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.search.CategoryService; -import org.alfresco.service.cmr.search.CategoryService.Depth; -import org.alfresco.service.cmr.search.ResultSet; -import org.alfresco.service.cmr.search.ResultSetRow; import org.alfresco.service.cmr.search.SearchService; -import org.alfresco.service.cmr.security.AccessPermission; import org.alfresco.service.cmr.security.MutableAuthenticationService; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PersonService; @@ -91,7 +73,6 @@ import org.alfresco.service.cmr.transfer.TransferCallback; import org.alfresco.service.cmr.transfer.TransferDefinition; import org.alfresco.service.cmr.transfer.TransferEvent; import org.alfresco.service.cmr.transfer.TransferEventBegin; -import org.alfresco.service.cmr.transfer.TransferEventReport; import org.alfresco.service.cmr.transfer.TransferException; import org.alfresco.service.cmr.transfer.TransferReceiver; import org.alfresco.service.cmr.transfer.TransferService; @@ -103,16 +84,21 @@ import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.transaction.TransactionService; import org.alfresco.test_category.BaseSpringTestsCategory; -import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.GUID; import org.alfresco.util.Pair; -import org.alfresco.util.PropertyMap; import org.alfresco.util.TempFileProvider; -import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.RedundantTests; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; -import org.springframework.util.ResourceUtils; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * Unit test for TransferServiceImpl @@ -122,8 +108,8 @@ import org.springframework.util.ResourceUtils; * @author Mark Rogers */ @SuppressWarnings("deprecation") -@Category({BaseSpringTestsCategory.class, LuceneTests.class}) -public class TransferServiceImplTest extends BaseAlfrescoSpringTest +@Category({BaseSpringTestsCategory.class}) +public class TransferServiceImplTest extends BaseAlfrescoSpringTest { private TransferService transferService; private ContentService contentService; @@ -152,10 +138,10 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest /** * Called during the transaction setup */ - protected void onSetUp() throws Exception + @Before + public void before() throws Exception { - - super.onSetUp(); + super.before(); // Get the required services this.transferService = (TransferService)this.applicationContext.getBean("TransferService"); @@ -184,28 +170,26 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest REPO_ID_B = descriptorService.getCurrentRepositoryDescriptor().getId(); authenticationComponent.setSystemUserAsCurrentUser(); - assertNotNull("receiver is null", this.receiver); - } - - @Override - public void runBare() throws Throwable - { - preventTransaction(); - super.runBare(); + assertNotNull("receiver is null", this.receiver); + + TestTransaction.flagForCommit(); + TestTransaction.end(); } + @Test public void testSetup() { assertEquals( "Must run without transactions", TxnReadState.TXN_NONE, AlfrescoTransactionSupport.getTransactionReadState()); } - + /** * Test create target. * * @throws Exception */ + @Test public void testCreateTarget() throws Exception { String name = "Test Transfer Target " + GUID.generate(); @@ -270,6 +254,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testCreateTargetSyntax2() throws Exception { String name = "Test Transfer Target " + GUID.generate(); @@ -345,6 +330,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testGetTransferTargets() throws Exception { String nameA = "Test Transfer Target " + GUID.generate(); @@ -379,6 +365,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testALF6565() throws Exception { String nameA = GUID.generate(); @@ -423,6 +410,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * Test of Get All Transfer Targets By Group */ //TODO Test not complete - can't yet put targets in different groups + @Test public void testGetAllTransferTargetsByGroup() throws Exception { String getMe = "Test Transfer Target " + GUID.generate(); @@ -461,6 +449,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest /** * */ + @Test public void testUpdateTransferTarget() throws Exception { String updateMe = "Test Transfer Target " + GUID.generate(); @@ -565,6 +554,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest /** * */ + @Test public void testDeleteTransferTarget() throws Exception { String deleteMe = "deleteMe"; @@ -613,6 +603,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } + @Test public void testEnableTransferTarget() throws Exception { String targetName = "enableMe"; @@ -676,6 +667,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testTransferOneNode() throws Exception { final String CONTENT_TITLE = "ContentTitle"; @@ -1040,6 +1032,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testMoveNode() throws Exception { final String CONTENT_TITLE = "ContentTitle"; @@ -1228,6 +1221,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to he same instance of alfresco. */ + @Test public void testManyNodes() throws Exception { final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); @@ -1488,9 +1482,9 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testPathBasedUpdate() throws Exception { - endTransaction(); final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); final String CONTENT_TITLE = "ContentTitle"; @@ -1654,6 +1648,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testAsyncCallback() throws Exception { final int MAX_SLEEPS = 5; @@ -1860,6 +1855,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testAsyncCancel() throws Exception { final int MAX_SLEEPS = 5; @@ -1872,7 +1868,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest final String targetName = "testAsyncCallback"; final NodeRef guestHome = repositoryHelper.getGuestHome(); - final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); +// final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); class TestContext { @@ -1941,7 +1937,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } }; - final TestContext testContext = tran.doInTransaction(setupCB); + final TestContext testContext = transactionService.getRetryingTransactionHelper().doInTransaction(setupCB, false, true); /** * The transfer report is a plain report of the transfer - no async shenanigans to worry about @@ -2062,7 +2058,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - tran.doInTransaction(transferAsyncCB); + transactionService.getRetryingTransactionHelper().doInTransaction(transferAsyncCB); /** @@ -2120,6 +2116,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * Turn it on by turning debug logging on for this class or by changing the "runTest" value; */ + @Test public void testTransferOneNodeWithBigContent() throws Exception { /** @@ -2262,6 +2259,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testEmptyContent() throws Exception { final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); @@ -2529,9 +2527,9 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testRepeatUpdateOfContent() throws Exception { - final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); final String CONTENT_TITLE = "ContentTitle"; final Locale CONTENT_LOCALE = Locale.GERMAN; final String CONTENT_ENCODING = "UTF-8"; @@ -2598,7 +2596,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } }; - final TestContext testContext = tran.doInTransaction(setupCB); + final TestContext testContext = transactionService.getRetryingTransactionHelper().doInTransaction(setupCB, false, true); RetryingTransactionCallback updateContentCB = new RetryingTransactionCallback() { @@ -2654,9 +2652,9 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest { logger.debug("testRepeatUpdateContent - iteration:" + i); testContext.contentString = String.valueOf(i); - tran.doInTransaction(updateContentCB); - tran.doInTransaction(transferCB); - tran.doInTransaction(checkTransferCB); + transactionService.getRetryingTransactionHelper().doInTransaction(updateContentCB); + transactionService.getRetryingTransactionHelper().doInTransaction(transferCB); + transactionService.getRetryingTransactionHelper().doInTransaction(checkTransferCB); } } // test repeat update content @@ -2674,6 +2672,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testReplaceNode() throws Exception { final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); @@ -3052,6 +3051,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testPeerAssocs() throws Exception { final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); @@ -3259,6 +3259,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testExistingNodes() throws Exception { final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); @@ -3430,6 +3431,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ @Category(RedundantTests.class) + @Test public void testCategoriesAndTags() throws Exception { final String CONTENT_TITLE = "ContentTitle"; @@ -3441,8 +3443,6 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest final String TAG_1_NAME = "tag1"; final String TAG_2_NAME = "tag2"; - final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper(); - class TestContext { TransferTarget transferMe; @@ -3492,7 +3492,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest return ctx; } }; - final TestContext testContext = tran.doInTransaction(setupCB); + final TestContext testContext = transactionService.getRetryingTransactionHelper().doInTransaction(setupCB); /** * Step 1: Transfer our which has a tag @@ -3511,7 +3511,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest return null; } }; - tran.doInTransaction(transferCB); + transactionService.getRetryingTransactionHelper().doInTransaction(transferCB); RetryingTransactionCallback validateStep1CB = new RetryingTransactionCallback() { @@ -3527,8 +3527,8 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest List tags = taggingService.getTags(testContext.contentNodeRef); assertNotNull(tags); - assertTrue(tags.size() == 1); - assertTrue(tags.contains(TAG_1_NAME)); + assertEquals(1, tags.size()); + assertTrue(tags.contains(TAG_1_NAME)); // Now add another tag for step number 2 taggingService.addTag(testContext.contentNodeRef, TAG_2_NAME); @@ -3536,14 +3536,14 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } }; - tran.doInTransaction(validateStep1CB); + transactionService.getRetryingTransactionHelper().doInTransaction(validateStep1CB); /** * Step 2: * Transfer our node again - With another tag */ logger.debug("Second transfer - add a second tag"); - tran.doInTransaction(transferCB); + transactionService.getRetryingTransactionHelper().doInTransaction(transferCB); RetryingTransactionCallback validateStep2CB = new RetryingTransactionCallback() { @@ -3566,7 +3566,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } }; - tran.doInTransaction(validateStep2CB); + transactionService.getRetryingTransactionHelper().doInTransaction(validateStep2CB); /** * Step 3 - delete a tag @@ -3582,11 +3582,11 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } }; - tran.doInTransaction(deleteTagCB); + transactionService.getRetryingTransactionHelper().doInTransaction(deleteTagCB); logger.debug("Transfer again - this is to delete a tag"); - tran.doInTransaction(transferCB); + transactionService.getRetryingTransactionHelper().doInTransaction(transferCB); // should probably be in contentModel final QName ASPECT_GENERAL_CLASSIFIABLE = ContentModel.ASPECT_GEN_CLASSIFIABLE; @@ -3608,7 +3608,7 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } }; - tran.doInTransaction(validateStep3CB); + transactionService.getRetryingTransactionHelper().doInTransaction(validateStep3CB); /** * Step 4 - update to add a category that already exists @@ -3666,11 +3666,11 @@ public class TransferServiceImplTest extends BaseAlfrescoSpringTest } }; - tran.doInTransaction(step4WriteContentCB); + transactionService.getRetryingTransactionHelper().doInTransaction(step4WriteContentCB); - tran.doInTransaction(transferCB); + transactionService.getRetryingTransactionHelper().doInTransaction(transferCB); - tran.doInTransaction(validateStep4CB); + transactionService.getRetryingTransactionHelper().doInTransaction(validateStep4CB); } // testCategoriesAndTags diff --git a/src/test/java/org/alfresco/repo/transfer/TransferServiceToBeRefactoredTest.java b/src/test/java/org/alfresco/repo/transfer/TransferServiceToBeRefactoredTest.java index 2d70e9c537..34c04762e0 100644 --- a/src/test/java/org/alfresco/repo/transfer/TransferServiceToBeRefactoredTest.java +++ b/src/test/java/org/alfresco/repo/transfer/TransferServiceToBeRefactoredTest.java @@ -94,8 +94,12 @@ import org.alfresco.util.GUID; import org.alfresco.util.Pair; import org.alfresco.util.PropertyMap; import org.alfresco.util.testing.category.LuceneTests; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.test.context.transaction.TestTransaction; import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.util.ResourceUtils; @@ -111,6 +115,7 @@ import org.springframework.util.ResourceUtils; */ @SuppressWarnings("deprecation") @Category({BaseSpringTestsCategory.class, LuceneTests.class}) +@Transactional public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest { private TransferService transferService; @@ -134,27 +139,18 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest String REPO_ID_A = "RepoIdA"; String REPO_ID_B; String REPO_ID_C = "RepoIdC"; - - @Override - public void runBare() throws Throwable - { - preventTransaction(); - super.runBare(); - } - /** - * Called during the transaction setup - */ - protected void onSetUp() throws Exception + @Before + public void before() throws Exception { + super.before(); + + TestTransaction.end(); // Catch transactions left dangling by inadequate transaction handling during test failures if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE) { fail("Dangling transaction at start of test."); } - - super.onSetUp(); - // Get the required services this.transferService = (TransferService)this.applicationContext.getBean("TransferService"); this.contentService = (ContentService)this.applicationContext.getBean("ContentService"); @@ -179,7 +175,7 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest REPO_ID_B = descriptorService.getCurrentRepositoryDescriptor().getId(); authenticationComponent.setSystemUserAsCurrentUser(); - setTransactionDefinition(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW)); +// setTransactionDefinition(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW)); assertNotNull("receiver is null", this.receiver); } @@ -188,10 +184,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * * This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testTransferReport() throws Exception { - setDefaultRollback(false); - final NodeRef guestHome = repositoryHelper.getGuestHome(); /** @@ -285,8 +280,7 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * Step 1. * Call the transfer method. to get a failed transfer - orphan nodes exist */ - setDefaultRollback(true); - startNewTransaction(); + TestTransaction.start(); try { TestTransferCallback callback = new TestTransferCallback(); @@ -342,11 +336,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest } finally { - endTransaction(); + TestTransaction.end(); } - - setDefaultRollback(false); - + /** * Now validate the client side error transfer report against the xsd file */ @@ -622,10 +614,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * restore node A2 (and A4 and A5 cascade restore) * transfer */ + @Test public void testTransferSyncNodes() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; final Locale CONTENT_LOCALE = Locale.GERMAN; final String CONTENT_STRING = "Hello"; @@ -1333,10 +1324,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * (A5, A6, A7 and A8 should be deleted A2 and A4 remain since they contain alien content.) * */ + @Test public void testTransferInvadedByLocalAlienNodes() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; final Locale CONTENT_LOCALE = Locale.JAPAN; final String CONTENT_STRING = "Hello"; @@ -2017,10 +2007,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * * @throws Exception */ + @Test public void testLocalAlienRestore() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; /** @@ -2347,10 +2336,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest *

* This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testTransferWithPermissions() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; final Locale CONTENT_LOCALE = Locale.GERMAN; final String CONTENT_STRING = "Hello"; @@ -2683,10 +2671,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * Step 5 * remove locks on A and B - transfer without read only flag - content should all be unlocked. */ + @Test public void testReadOnlyFlag() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; final Locale CONTENT_LOCALE = Locale.GERMAN; final String CONTENT_STRING = "The quick brown fox"; @@ -3079,6 +3066,7 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * transfer * */ + @Test public void testTwoRepoSync() throws Exception { /** @@ -3089,7 +3077,6 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * create node B6. Fake its transfered aspect to be from Repo B, Non Alien. * transfer (sync) */ - setDefaultRollback(false); final String CONTENT_TITLE = "ContentTitle"; final Locale CONTENT_LOCALE = Locale.GERMAN; @@ -3400,10 +3387,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * Step 5. Delete C3 - A2 dest images folder uninvaded. */ + @Test public void testMultiRepoTransfer() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; final String targetName = "testMultiRepoTransfer"; @@ -3827,10 +3813,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * A4 should be invaded by B due to B6 but not by A. * C2Dest should not be invaded. */ + @Test public void testMultiRepoTransferMove() throws Exception { - setDefaultRollback(false); - final String localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId(); final String CONTENT_TITLE = "ContentTitle"; @@ -4234,10 +4219,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest *

* This is a unit test so it does some shenanigans to send to the same instance of alfresco. */ + @Test public void testCopyTransferredNode() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; /** @@ -4465,10 +4449,9 @@ public class TransferServiceToBeRefactoredTest extends BaseAlfrescoSpringTest * B6 Copy not invaded. * */ + @Test public void testCopyAlien() throws Exception { - setDefaultRollback(false); - final String CONTENT_TITLE = "ContentTitle"; final String targetName = "testCopyAlien"; diff --git a/src/test/java/org/alfresco/repo/transfer/manifest/ManifestIntegrationTest.java b/src/test/java/org/alfresco/repo/transfer/manifest/ManifestIntegrationTest.java index cc184fc094..1949a05abc 100644 --- a/src/test/java/org/alfresco/repo/transfer/manifest/ManifestIntegrationTest.java +++ b/src/test/java/org/alfresco/repo/transfer/manifest/ManifestIntegrationTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.transfer.manifest; import java.io.BufferedReader; @@ -61,7 +61,10 @@ import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; import org.alfresco.util.TempFileProvider; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Integration test for Transfer Manifest @@ -69,6 +72,7 @@ import org.junit.experimental.categories.Category; * @author Mark Rogers */ @Category(BaseSpringTestsCategory.class) +@Transactional public class ManifestIntegrationTest extends BaseAlfrescoSpringTest { private TransferService transferService; @@ -77,12 +81,10 @@ public class ManifestIntegrationTest extends BaseAlfrescoSpringTest private DictionaryService dictionaryService; private NodeService mlAwareNodeService; - /** - * Called during the transaction setup - */ - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the required services this.transferService = (TransferService)this.applicationContext.getBean("TransferService"); @@ -92,6 +94,7 @@ public class ManifestIntegrationTest extends BaseAlfrescoSpringTest this.mlAwareNodeService = (NodeService) this.applicationContext.getBean("mlAwareNodeService"); } + @Test public void testSnapshot() throws Exception { // Snapshot a transfer node diff --git a/src/test/java/org/alfresco/repo/transfer/script/ScriptTransferServiceTest.java b/src/test/java/org/alfresco/repo/transfer/script/ScriptTransferServiceTest.java index f120b0d9b0..a8123ca8fd 100644 --- a/src/test/java/org/alfresco/repo/transfer/script/ScriptTransferServiceTest.java +++ b/src/test/java/org/alfresco/repo/transfer/script/ScriptTransferServiceTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.transfer.script; import java.util.HashMap; @@ -43,9 +43,12 @@ import org.alfresco.service.cmr.transfer.TransferTarget; import org.alfresco.test_category.BaseSpringTestsCategory; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseAlfrescoSpringTest; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.mockito.Matchers; import org.mockito.Mockito; +import org.springframework.transaction.annotation.Transactional; /** * Script Transfer unit test @@ -53,6 +56,7 @@ import org.mockito.Mockito; * @author Mark Rogers */ @Category(BaseSpringTestsCategory.class) +@Transactional public class ScriptTransferServiceTest extends BaseAlfrescoSpringTest { @@ -61,12 +65,12 @@ public class ScriptTransferServiceTest extends BaseAlfrescoSpringTest private ScriptService scriptService; private ScriptTransferService scriptTransferService; - - - @SuppressWarnings("deprecation") - protected void onSetUpInTransaction() throws Exception + + + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the required services this.scriptService = (ScriptService)this.applicationContext.getBean("ScriptService"); @@ -75,7 +79,7 @@ public class ScriptTransferServiceTest extends BaseAlfrescoSpringTest } // == Test the JavaScript API == - + @Test public void testJSAPI() throws Exception { /** diff --git a/src/test/java/org/alfresco/repo/version/BaseVersionStoreTest.java b/src/test/java/org/alfresco/repo/version/BaseVersionStoreTest.java index 68d1bda954..a0976e58c7 100644 --- a/src/test/java/org/alfresco/repo/version/BaseVersionStoreTest.java +++ b/src/test/java/org/alfresco/repo/version/BaseVersionStoreTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.version; import java.io.Serializable; @@ -62,7 +62,11 @@ import org.alfresco.service.cmr.version.VersionService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.BaseSpringTest; +import org.junit.Before; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +@Transactional public abstract class BaseVersionStoreTest extends BaseSpringTest { /* @@ -71,6 +75,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest protected NodeService dbNodeService; protected VersionService versionService; protected ContentService contentService; + @Autowired protected DictionaryDAO dictionaryDAO; protected MutableAuthenticationService authenticationService; protected TransactionService transactionService; @@ -141,17 +146,7 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest * Test user details */ private static final String PWD = "admin"; - - /** - * Sets the meta model dao - * - * @param dictionaryDAO the meta model dao - */ - public void setDictionaryDAO(DictionaryDAO dictionaryDAO) - { - this.dictionaryDAO = dictionaryDAO; - } - + public void setVersionService(VersionService versionService) { this.versionService = versionService; @@ -160,7 +155,8 @@ public abstract class BaseVersionStoreTest extends BaseSpringTest /** * Called during the transaction setup */ - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { // Set the multi value if required if (this.multiValue == null) diff --git a/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java b/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java index 470a3f300a..531293efb0 100644 --- a/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/version/ContentServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.version; import org.alfresco.error.AlfrescoRuntimeException; @@ -40,9 +40,12 @@ import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.TransformationOptions; import org.alfresco.service.cmr.version.Version; import org.alfresco.test_category.OwnJVMTestsCategory; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import java.util.HashMap; +import org.springframework.transaction.annotation.Transactional; /** * Tests for retrieving frozen content from a verioned node @@ -50,6 +53,7 @@ import java.util.HashMap; * @author Roy Wetherall */ @Category(OwnJVMTestsCategory.class) +@Transactional public class ContentServiceImplTest extends BaseVersionStoreTest { /** @@ -60,14 +64,12 @@ public class ContentServiceImplTest extends BaseVersionStoreTest /** * The version content store */ - private ContentService contentService; - - /** - * Called during the transaction setup - */ - protected void onSetUpInTransaction() throws Exception + private ContentService contentService; + + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the instance of the required content service this.contentService = (ContentService)this.applicationContext.getBean("contentService"); @@ -76,6 +78,7 @@ public class ContentServiceImplTest extends BaseVersionStoreTest /** * Test getReader */ + @Test public void testGetReader() { // Create a new versionable node @@ -103,6 +106,7 @@ public class ContentServiceImplTest extends BaseVersionStoreTest assertEquals(UPDATED_CONTENT, contentReader2.getContentString()); } + @Test public void testTransformAndNulls() { NodeRef versionableNode = createNewVersionableNode(); @@ -182,6 +186,7 @@ public class ContentServiceImplTest extends BaseVersionStoreTest /** * Test getWriter */ + @Test public void testGetWriter() { // Create a new versionable node diff --git a/src/test/java/org/alfresco/repo/version/NodeServiceImplTest.java b/src/test/java/org/alfresco/repo/version/NodeServiceImplTest.java index b0e6a11622..b1f536912c 100644 --- a/src/test/java/org/alfresco/repo/version/NodeServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/version/NodeServiceImplTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.version; import java.io.Serializable; @@ -55,12 +55,16 @@ import org.alfresco.util.TestWithUserUtils; import org.alfresco.util.debug.NodeStoreInspector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * @author Roy Wetherall */ @Category(OwnJVMTestsCategory.class) +@Transactional public class NodeServiceImplTest extends BaseVersionStoreTest { private static Log logger = LogFactory.getLog(NodeServiceImplTest.class); @@ -86,13 +90,11 @@ public class NodeServiceImplTest extends BaseVersionStoreTest */ private NodeRef dummyNodeRef = null; private QName dummyQName = null; - - /** - * Called during the transaction setup - */ - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); // Get the node service by name this.versionStoreNodeService = (NodeService)this.applicationContext.getBean("versionNodeService"); @@ -107,6 +109,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getType */ + @Test public void testGetType() { // Create a new versionable node @@ -124,6 +127,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getProperties */ + @Test public void testGetProperties() { // Create a new versionable node @@ -162,6 +166,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getProperty */ + @Test public void testGetProperty() { // Create a new versionable node @@ -191,6 +196,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getChildAssocs */ + @Test public void testGetChildAssocs() { if (logger.isTraceEnabled()) @@ -251,6 +257,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getAssociationTargets */ + @Test public void testGetAssociationTargets() { // Create a new versionable node @@ -275,6 +282,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest * Tests get target associations by property value.

* See MNT-14504 for more details. */ + @Test public void testGetTargetAssocsByPropertyValue() { // Create a new versionable node @@ -298,6 +306,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test hasAspect */ + @Test public void testHasAspect() { // Create a new versionable node @@ -320,6 +329,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getAspects */ + @Test public void testGetAspects() { // Create a new versionable node @@ -341,6 +351,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getParentAssocs */ + @Test public void testGetParentAssocs() { // Create a new versionable node @@ -362,6 +373,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getPrimaryParent */ + @Test public void testGetPrimaryParent() { // Create a new versionable node @@ -409,6 +421,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test addAspect */ + @Test public void testAddAspect() { try @@ -431,6 +444,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test removeAspect */ + @Test public void testRemoveAspect() { try @@ -452,6 +466,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test delete node */ + @Test public void testDeleteNode() { try @@ -471,6 +486,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test addChild */ + @Test public void testAddChild() { try @@ -494,6 +510,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test removeChild */ + @Test public void testRemoveChild() { try @@ -515,6 +532,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test setProperties */ + @Test public void testSetProperties() { try @@ -536,6 +554,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test setProperty */ + @Test public void testSetProperty() { try @@ -558,6 +577,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test createAssociation */ + @Test public void testCreateAssociation() { try @@ -580,6 +600,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test removeAssociation */ + @Test public void testRemoveAssociation() { try @@ -602,6 +623,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getAssociationSources */ + @Test public void testGetAssociationSources() { try @@ -623,6 +645,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getPath */ + @Test public void testGetPath() { Path path = this.versionStoreNodeService.getPath(this.dummyNodeRef); @@ -631,6 +654,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest /** * Test getPaths */ + @Test public void testGetPaths() { List paths = this.versionStoreNodeService.getPaths(this.dummyNodeRef, false); @@ -643,6 +667,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest * database or database connection WRT unicode, this is a * test that'll hopefully break in testing and alert us! */ + @Test public void testUnicodeNamesAndProperties() { // Get our cache objects @@ -736,6 +761,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest * that does not already have versionable aspect * version history of this node should be deleted */ + @Test public void testALF1793AddVersionableAspect() { // Create a new versionable node and create new version @@ -762,6 +788,7 @@ public class NodeServiceImplTest extends BaseVersionStoreTest assertNotNull(version); } + @Test public void testTakeOwnershipPermission() { NodeService proxyNodeService = (NodeService) applicationContext.getBean("NodeService"); diff --git a/src/test/java/org/alfresco/repo/version/VersionServiceImplTest.java b/src/test/java/org/alfresco/repo/version/VersionServiceImplTest.java index 497407b142..bb378d76bd 100644 --- a/src/test/java/org/alfresco/repo/version/VersionServiceImplTest.java +++ b/src/test/java/org/alfresco/repo/version/VersionServiceImplTest.java @@ -76,14 +76,21 @@ import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.GUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; +import org.springframework.test.annotation.Commit; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * versionService test class. * * @author Roy Wetherall, janv */ +@Transactional @Category(OwnJVMTestsCategory.class) public class VersionServiceImplTest extends BaseVersionStoreTest { @@ -110,10 +117,10 @@ public class VersionServiceImplTest extends BaseVersionStoreTest private List excludedOnUpdateProps; private Properties globalProperties; - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); + super.before(); personService = (PersonService) applicationContext.getBean("personService"); versionableAspect = (VersionableAspect) applicationContext.getBean("versionableAspect"); excludedOnUpdateProps = versionableAspect.getExcludedOnUpdateProps(); @@ -121,15 +128,15 @@ public class VersionServiceImplTest extends BaseVersionStoreTest globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true"); } - @Override - protected void onTearDownAfterTransaction() throws Exception + @After + public void after() throws Exception { - super.onTearDownAfterTransaction(); versionableAspect.setExcludedOnUpdateProps(excludedOnUpdateProps); versionableAspect.afterDictionaryInit(); globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "false"); } + @Test public void testSetup() { // NOOP @@ -142,6 +149,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * 1) Create three versions with comments. Then revert to v1. All comments must be exist. * 2) Create three versions. Add comment to the latest two versions (v2 and v3). Then revert to v1. Comments must be exist. */ + @Test public void testDiscussableAspect() { final String V1_COMMENT = "

Comment for version 1

"; @@ -267,6 +275,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest } // MNT-13647, MNT-13719 check for comment count in node property + @Test public void testCommentsCountProperty() { final String COMMENT = "

Comment

"; @@ -285,6 +294,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Tests the creation of the initial version of a versionable node */ + @Test public void testCreateIntialVersion() { NodeRef versionableNode = createNewVersionableNode(); @@ -294,6 +304,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test creating a version history with many versions from the same workspace */ + @Test public void testCreateManyVersionsSameWorkspace() { NodeRef versionableNode = createNewVersionableNode(); @@ -308,11 +319,12 @@ public class VersionServiceImplTest extends BaseVersionStoreTest assertEquals(3, vh.getAllVersions().size()); // TODO check list of versions ... ! - } + } /** * Tests the creation of multiple versions of a versionable node with null version properties */ + @Test public void testCreateManyVersionsWithNullVersionProperties() { this.versionProperties = null; @@ -330,6 +342,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test versioning a non versionable node ie: no version apsect */ + @Test public void testCreateInitialVersionWhenNotVersionable() { NodeRef node = createNewNode(); // not marked as versionable @@ -339,6 +352,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test retrieving the current version for a node with multiple versions */ + @Test public void testGetCurrentVersion() { NodeRef versionableNode = createNewVersionableNode(); @@ -370,6 +384,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test versioning the children of a versionable node */ + @Test public void testVersioningChildren() { NodeRef versionableNode = createNewVersionableNode(); @@ -395,6 +410,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test versioning many nodes in one go */ + @Test public void testVersioningManyNodes() { NodeRef versionableNode = createNewVersionableNode(); @@ -477,6 +493,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Tests the version history */ + @Test public void testNoVersionHistory() { NodeRef nodeRef = createNewVersionableNode(); @@ -489,6 +506,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * Tests getVersionHistory when all the entries in the version history * are from the same workspace. */ + @Test public void testGetVersionHistorySameWorkspace() { NodeRef versionableNode = createNewVersionableNode(); @@ -504,6 +522,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * Same as testGetVersionHistorySameWorkspace except that the order of * of db ids is mixed up and a comparator is need to fix it (MNT-226). */ + @Test public void testIdsOutOfOrder() { if (versionService instanceof Version2ServiceImpl) @@ -516,6 +535,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Same as testIdsOutOfOrder but without the comparator so should fail. */ + @Test public void testIdsOutOfOrderFails() { if (versionService instanceof Version2ServiceImpl) @@ -633,6 +653,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * Test revert */ @SuppressWarnings("unused") + @Test public void testRevert() { // Create a versionable node @@ -771,6 +792,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test reverting a node that has comments, see ALF-13129 */ + @Test public void testRevertWithComments() { NodeRef versionableNode = createNewVersionableNode(); @@ -854,6 +876,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test that secondary association is present after revert, see MNT-11756 */ + @Test public void testAssociationIsPresentAfterRevert() { // Create Order @@ -946,6 +969,8 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * Test reverting from Share */ @SuppressWarnings("unused") + @Commit + @Test public void testScriptNodeRevert() { CheckOutCheckInService checkOutCheckIn = @@ -1034,17 +1059,6 @@ public class VersionServiceImplTest extends BaseVersionStoreTest assertEquals(VALUE_1, nodeService.getProperty(newNode.getNodeRef(), PROP_1)); // Will be a new version though - TODO Is this correct? assertEquals("0.5", nodeService.getProperty(newNode.getNodeRef(), ContentModel.PROP_VERSION_LABEL)); - - // All done - setComplete(); - try - { - endTransaction(); - } - catch(Throwable e) - { - fail("Transaction failed: " + e); - } } /** @@ -1058,6 +1072,8 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * */ @SuppressWarnings("unused") + @Commit + @Test public void testScriptNodeRevertWithChangeType() { CheckOutCheckInService checkOutCheckInService = @@ -1087,22 +1103,12 @@ public class VersionServiceImplTest extends BaseVersionStoreTest ScriptNode newNode = scriptNode.revert("History", false, version1.getVersionLabel()); assertEquals("0.3", nodeService.getProperty(newNode.getNodeRef(), ContentModel.PROP_VERSION_LABEL)); assertEquals(TEST_TYPE_QNAME, nodeService.getType(newNode.getNodeRef())); - - // All done - setComplete(); - try - { - endTransaction(); - } - catch(Throwable e) - { - fail("Transaction failed: " + e); - } } /** * Test restore */ + @Test public void testRestore() { // Try and restore a node without any version history @@ -1218,6 +1224,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test deleteVersionHistory */ + @Test public void testDeleteVersionHistory() { // Create a versionable node @@ -1272,6 +1279,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * Test testDeleteLastVersion * MNT-13097. Revert content if the last version was chosen. */ + @Test public void testDeleteLastVersion() { // Use 1.0, 2.0 etc for the main part @@ -1349,6 +1357,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Test deleteVersion */ + @Test public void testDeleteVersion() { // Use 1.0, 2.0 etc for the main part @@ -1547,13 +1556,14 @@ public class VersionServiceImplTest extends BaseVersionStoreTest assertNull(version); } + @Test public void testAutoVersionOnInitialVersionOn() { // Create a versionable node final NodeRef versionableNode = createNewVersionableNode(); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1588,16 +1598,17 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testAutoVersionOff() { // Create a versionable node final NodeRef versionableNode = createNewVersionableNode(); this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION, false); - - setComplete(); - endTransaction(); - + + TestTransaction.flagForCommit(); + TestTransaction.end(); + // The initial version should have been created now transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() @@ -1628,6 +1639,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testInitialVersionOff() { // Create node (this node has some content) @@ -1642,9 +1654,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest TEST_TYPE_QNAME, props2).getChildRef(); this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, props); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); // The initial version should NOT have been created @@ -1661,30 +1673,33 @@ public class VersionServiceImplTest extends BaseVersionStoreTest } + @Test public void testAddVersionableAspectWithNoVersionType() { // No version-type specified when adding the aspect NodeRef nodeRef = createNodeWithVersionType(null); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); assertCorrectVersionLabel(nodeRef, "1.0"); } + @Test public void testAddVersionableAspectWithMinorVersionType() { // MINOR version-type specified when adding the aspect NodeRef nodeRef = createNodeWithVersionType(VersionType.MINOR); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); assertCorrectVersionLabel(nodeRef, "0.1"); } + @Test public void testAddVersionableAspectWithMajorVersionType() { // MAJOR version-type specified when adding the aspect NodeRef nodeRef = createNodeWithVersionType(VersionType.MAJOR); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); assertCorrectVersionLabel(nodeRef, "1.0"); } @@ -1728,6 +1743,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest return nodeRef; } + @Test public void testAddRemoveVersionableAspect() { HashMap props2 = new HashMap(); @@ -1739,9 +1755,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest TEST_TYPE_QNAME, props2).getChildRef(); this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1788,6 +1804,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testAutoRemovalOfVersionHistory() { StoreRef spacesStoreRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); @@ -1802,9 +1819,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest ContentModel.TYPE_CONTENT, props2).getChildRef(); this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, null); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1858,14 +1875,15 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testAutoVersionOnUpdatePropsOnly() { // test auto-version props on final NodeRef versionableNode = createNewVersionableNode(); this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1910,16 +1928,12 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); - + TestTransaction.start(); // test auto-version props off - - startNewTransaction(); - final NodeRef versionableNode2 = createNewVersionableNode(); this.dbNodeService.setProperty(versionableNode2, ContentModel.PROP_AUTO_VERSION_PROPS, false); - - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -1950,14 +1964,15 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testAutoVersionOnUpdatePropsOnlyWithExcludes() { // test auto-version props on - without any excludes final NodeRef versionableNode = createNewVersionableNode(); this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @@ -2137,6 +2152,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testAutoVersionWithPropsOnRevert() { // test auto-version props on - without any excludes @@ -2159,8 +2175,8 @@ public class VersionServiceImplTest extends BaseVersionStoreTest versionService.getVersionHistory(versionableNode).getVersion("1.0")); // Ready to test - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end();; // Check the first version is now 2.0 transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() @@ -2293,13 +2309,14 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testALF5618() { final NodeRef versionableNode = createNewVersionableNode(); this.dbNodeService.setProperty(versionableNode, ContentModel.PROP_AUTO_VERSION_PROPS, true); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); final String lockToken = "opaquelocktoken:" + versionableNode.getId() + ":admin"; @@ -2352,6 +2369,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest }); } + @Test public void testAR807() { QName prop = QName.createQName("http://www.alfresco.org/test/versionstorebasetest/1.0", "intProp"); @@ -2381,8 +2399,9 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Check that the version type property is actually set when creating a new version. * - * @see https://issues.alfresco.com/jira/browse/MNT-14681 + * see MNT-14681 */ + @Test public void testVersionTypeIsSet() { ChildAssociationRef childAssociation = nodeService.createNode(this.rootNodeRef, ContentModel.ASSOC_CHILDREN, @@ -2404,6 +2423,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /** * Check read permission for the frozen node */ + @Test public void testHasPermission() { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); @@ -2444,6 +2464,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * Check permissions for the frozen node if the store protocol is swapped from "version" to "workspace" * MNT-6877 */ + @Test public void testHasPermissionSwappedProtocol() { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); @@ -2480,6 +2501,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest assertEquals(AccessStatus.DENIED, permissionService.hasPermission(versionNodeRefSwapped, PermissionService.READ)); } + @Test public void testALF_3962() { NodeRef versionableNode = createNode(true, QName.createQName("http://www.alfresco.org/model/action/1.0", "action")); @@ -2552,6 +2574,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest * Ensure that versioning actions don't alter the auditable * aspect properties on the original nodes */ + @Test public void testVersioningAndAuditable() throws Exception { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); if(!authenticationDAO.userExists(USER_NAME_A)) @@ -2600,6 +2623,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest assertEquals(true, nodeService.hasAspect(nodeA, ContentModel.ASPECT_VERSIONABLE)); } + @Test public void testEnsureVersioningEnabled() throws Exception { AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); @@ -2704,6 +2728,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest /* * It should be possible to create a version for a locked node, see ALF-16540 */ + @Test public void testVersionLockedNode() { transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() @@ -2826,6 +2851,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest System.out.println("Finished: " + fileCount); } + @Test public void test_MNT10404() { String test_run = System.currentTimeMillis() + ""; @@ -2913,6 +2939,7 @@ public class VersionServiceImplTest extends BaseVersionStoreTest } } + @Test public void test_MNT14143() { // Create a non-versionable node diff --git a/src/test/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java b/src/test/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java index 2bed2a5063..f97fad6468 100644 --- a/src/test/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java +++ b/src/test/java/org/alfresco/repo/workflow/AbstractMultitenantWorkflowTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.workflow; @@ -52,7 +52,11 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.After; +import org.junit.Before; import org.junit.Test; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.transaction.annotation.Transactional; /** @@ -60,6 +64,8 @@ import org.junit.Test; * @since 4.0 * */ +@Transactional +@ContextConfiguration({"classpath:tenant/mt-*context.xml"}) public abstract class AbstractMultitenantWorkflowTest extends BaseSpringTest { protected static final String XML = MimetypeMap.MIMETYPE_XML; @@ -207,12 +213,10 @@ public abstract class AbstractMultitenantWorkflowTest extends BaseSpringTest assertEquals(path2Id, tasks.get(0).getPath().getId()); } - - @SuppressWarnings("deprecation") - @Override - protected void onSetUpBeforeTransaction() throws Exception + + @Before + public void before() throws Exception { - super.onSetUpBeforeTransaction(); this.serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); this.tenantService= (TenantService) applicationContext.getBean("tenantService"); this.tenantAdminService= (TenantAdminService) applicationContext.getBean("tenantAdminService"); @@ -244,13 +248,11 @@ public abstract class AbstractMultitenantWorkflowTest extends BaseSpringTest }); } - @SuppressWarnings("deprecation") - @Override - protected void onTearDown() throws Exception + @After + public void after() throws Exception { wfTestHelper.tearDown(); - super.onTearDown(); WorkflowSuiteContextShutdownTest.closeContext(); } @@ -267,16 +269,6 @@ public abstract class AbstractMultitenantWorkflowTest extends BaseSpringTest ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); return classLoader.getResourceAsStream(resource); } - - /** - * {@inheritDoc} - */ - @Override - protected String[] getConfigLocations() - { - return new String[] {ApplicationContextHelper.CONFIG_LOCATIONS[0], - "classpath:tenant/mt-*context.xml"}; - } protected abstract String getTestDefinitionPath(); protected abstract String getTestDefinitionKey(); diff --git a/src/test/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java b/src/test/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java index ad6ca29b1a..29869837a5 100644 --- a/src/test/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java +++ b/src/test/java/org/alfresco/repo/workflow/AbstractWorkflowServiceIntegrationTest.java @@ -72,7 +72,11 @@ import org.alfresco.util.GUID; import org.alfresco.util.collections.CollectionUtils; import org.alfresco.util.collections.Function; import org.alfresco.util.testing.category.LuceneTests; +import org.junit.After; +import org.junit.Before; import org.junit.experimental.categories.Category; +import org.springframework.test.context.transaction.TestTransaction; +import org.springframework.transaction.annotation.Transactional; /** * @author Nick Smith @@ -80,6 +84,7 @@ import org.junit.experimental.categories.Category; * @since 3.4.e */ @Category(LuceneTests.class) +@Transactional public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringTest { private static final String XML = MimetypeMap.MIMETYPE_XML; @@ -383,9 +388,9 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT transactionService.setAllowWrite(true); assertTrue(workflowService.isTaskEditable(currentTask, USER2)); assertTrue(workflowService.isTaskReassignable(currentTask, USER2)); - - setComplete(); - endTransaction(); + + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @Override @@ -396,7 +401,6 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT return null; } }); - startNewTransaction(); } public void testPooledTaskCapabilities() @@ -564,8 +568,8 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT assertFalse(workflowService.isTaskReassignable(currentTask, USER2)); assertFalse(workflowService.isTaskReassignable(currentTask, USER3)); - setComplete(); - endTransaction(); + TestTransaction.flagForCommit(); + TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @Override @@ -576,7 +580,6 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT return null; } }); - startNewTransaction(); } public void testGetWorkflowTaskDefinitions() @@ -1337,10 +1340,9 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT } @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); this.workflowService = serviceRegistry.getWorkflowService(); this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent"); @@ -1386,10 +1388,9 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT } @SuppressWarnings("deprecation") - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { - endTransaction(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback() { @Override @@ -1400,8 +1401,6 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT groupManager.clearGroups(); personManager.clearPeople(); authenticationComponent.clearCurrentSecurityContext(); - - AbstractWorkflowServiceIntegrationTest.super.onTearDownInTransaction(); return null; } }); diff --git a/src/test/java/org/alfresco/repo/workflow/StartWorkflowActionExecuterTest.java b/src/test/java/org/alfresco/repo/workflow/StartWorkflowActionExecuterTest.java index 2fa0f28b0b..095ff907b6 100644 --- a/src/test/java/org/alfresco/repo/workflow/StartWorkflowActionExecuterTest.java +++ b/src/test/java/org/alfresco/repo/workflow/StartWorkflowActionExecuterTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.workflow; import java.util.Date; @@ -40,7 +40,10 @@ import org.alfresco.service.namespace.QName; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; import org.junit.experimental.categories.Category; +import org.springframework.transaction.annotation.Transactional; /** * Start Advanced Workflow action execution test @@ -48,6 +51,7 @@ import org.junit.experimental.categories.Category; * @author David Caruana */ @Category(OwnJVMTestsCategory.class) +@Transactional public class StartWorkflowActionExecuterTest extends BaseSpringTest { private NodeService nodeService; @@ -57,13 +61,8 @@ public class StartWorkflowActionExecuterTest extends BaseSpringTest private NodeRef nodeRef; private StartWorkflowActionExecuter executer; - - /** - * Called at the begining of all tests - */ - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { this.nodeService = (NodeService)this.applicationContext.getBean("nodeService"); this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService"); @@ -87,6 +86,7 @@ public class StartWorkflowActionExecuterTest extends BaseSpringTest /** * Test execution */ + @Test public void testExecution() { // Execute the action diff --git a/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java b/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java index 3e931a6be4..b33985ea4a 100644 --- a/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java +++ b/src/test/java/org/alfresco/repo/workflow/activiti/AbstractActivitiComponentTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.repo.workflow.activiti; @@ -81,7 +81,6 @@ import org.mockito.stubbing.Answer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; /** @@ -93,7 +92,6 @@ import org.springframework.transaction.annotation.Transactional; @ContextConfiguration(locations={"classpath:test-database-context.xml", "classpath:activiti/test-activiti-component-context.xml", "classpath:alfresco/activiti-context.xml"}) -@TransactionConfiguration(transactionManager="transactionManager", defaultRollback=true) @Transactional public class AbstractActivitiComponentTest { diff --git a/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java b/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java index 402cb08b9d..5f4701079b 100644 --- a/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java +++ b/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiTimerExecutionTest.java @@ -39,6 +39,7 @@ import org.activiti.engine.runtime.Job; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.security.authentication.AuthenticationComponent; +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.person.TestPersonManager; import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.workflow.BPMEngineRegistry; @@ -56,6 +57,9 @@ import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.namespace.QName; import org.alfresco.util.BaseSpringTest; import org.alfresco.util.GUID; +import org.junit.Before; +import org.junit.Test; +import org.springframework.transaction.annotation.Transactional; /** * Test to verify timer execution autentication and transaction behaviour. @@ -63,6 +67,7 @@ import org.alfresco.util.GUID; * @author Frederik Heremans * @since 3.4.e */ +@Transactional public class ActivitiTimerExecutionTest extends BaseSpringTest { @@ -81,11 +86,9 @@ public class ActivitiTimerExecutionTest extends BaseSpringTest private TestPersonManager personManager; @SuppressWarnings("deprecation") + @Test public void testTimerExecutionAuthentication() throws Exception { - this.setComplete(); - this.endTransaction(); - try { WorkflowInstance taskAssigneeWorkflowInstance = transactionHelper @@ -110,7 +113,7 @@ public class ActivitiTimerExecutionTest extends BaseSpringTest return path.getInstance(); } - }); + }, false, true); // No timers should be available after a while they should have been executed, otherwise test fails waitForTimersToBeExecuted(taskAssigneeWorkflowInstance.getId()); @@ -136,11 +139,9 @@ public class ActivitiTimerExecutionTest extends BaseSpringTest } @SuppressWarnings("deprecation") + @Test public void testTimerExecutionTransactionRollback() throws Exception { - this.setComplete(); - this.endTransaction(); - try { WorkflowInstance workflowInstance = transactionHelper @@ -149,7 +150,8 @@ public class ActivitiTimerExecutionTest extends BaseSpringTest public WorkflowInstance execute() throws Throwable { // Create test person - personManager.createPerson(USER1); + NodeRef person = personManager.createPerson(USER1); + assertNotNull(person); WorkflowDefinition definition = deployDefinition("activiti/testTimerTransaction.bpmn20.xml"); @@ -165,7 +167,7 @@ public class ActivitiTimerExecutionTest extends BaseSpringTest return path.getInstance(); } - }); + }, false, true); String processInstanceId = BPMEngineRegistry.getLocalId(workflowInstance.getId()); @@ -193,11 +195,19 @@ public class ActivitiTimerExecutionTest extends BaseSpringTest assertTrue(fullExceptionStacktrace.contains("Activiti engine rocks!")); // Check if alfresco-changes that were performed are rolled back - NodeRef personNode = personManager.get(USER1); - NodeRef userHomeNode = (NodeRef)nodeService.getProperty(personNode, ContentModel.PROP_HOMEFOLDER); - - String homeFolderName = (String) nodeService.getProperty(userHomeNode, ContentModel.PROP_NAME); - assertNotSame("User home changed", homeFolderName); + transactionHelper.doInTransaction((RetryingTransactionHelper.RetryingTransactionCallback) () -> + { + AuthenticationUtil.runAsSystem(() -> + { + NodeRef personNode = personManager.get(USER1); + NodeRef userHomeNode = (NodeRef)nodeService.getProperty(personNode, ContentModel.PROP_HOMEFOLDER); + + String homeFolderName = (String) nodeService.getProperty(userHomeNode, ContentModel.PROP_NAME); + assertNotSame("User home changed", homeFolderName); + return null; + }); + return null; + }, false, true); } finally { @@ -236,10 +246,9 @@ public class ActivitiTimerExecutionTest extends BaseSpringTest } }); } - - @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + + @Before + public void before() throws Exception { ServiceRegistry registry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY); this.workflowService = registry.getWorkflowService(); diff --git a/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowServiceIntegrationTest.java b/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowServiceIntegrationTest.java index a387577918..de77392398 100644 --- a/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowServiceIntegrationTest.java +++ b/src/test/java/org/alfresco/repo/workflow/activiti/ActivitiWorkflowServiceIntegrationTest.java @@ -65,6 +65,7 @@ import org.alfresco.service.namespace.QName; import org.alfresco.util.GUID; import org.alfresco.util.testing.category.LuceneTests; import org.alfresco.util.testing.category.RedundantTests; +import org.junit.Test; import org.junit.experimental.categories.Category; /** @@ -82,6 +83,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ public static final String ACTIVITI_TEST_TIMER_BPMN20_XML = "activiti/testTimer.bpmn20.xml"; public static final String ACTIVITI_TEST_WITH_SUB_PROCESS_XML = "activiti/testWorkflowWithSubprocess.xml"; + @Test public void testOutcome() throws Exception { WorkflowDefinition definition = deployDefinition("alfresco/workflow/review.bpmn20.xml"); @@ -121,6 +123,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertEquals("Approve", outcome); } + @Test public void testStartTaskEndsAutomatically() { // Deploy the test workflow definition which uses the @@ -146,6 +149,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ * tasks are defaulted to a priority of 50 (which is invalid). I'm testing that the code I wrote decides this is an * invalid number and sets it to the default value (2). */ + @Test public void testPriorityIsValid() { WorkflowDefinition definition = deployDefinition("activiti/testCustomActiviti.bpmn20.xml"); @@ -171,6 +175,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ } } + @Test public void testReviewAndPooledNotModifiedDate() { authenticationComponent.setSystemUserAsCurrentUser(); @@ -212,6 +217,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertEquals(lastModifiedDate, nodeService.getProperty(addedNodeRef, ContentModel.PROP_MODIFIED)); } + @Test public void testGetWorkflowTaskDefinitionsWithMultiInstanceTask() { // Test added to validate fix for ALF-14224 @@ -226,6 +232,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ } // Added after MNT-17601. Failed to find any completed tasks when the workflow had a sub process. + @Test public void testCompletedTaskInWorkflowWithSubProcess() { WorkflowDefinition definition = deployDefinition(ACTIVITI_TEST_WITH_SUB_PROCESS_XML); @@ -236,6 +243,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertEquals("Alfresco User Task", taskDefs.get(1).getNode().getTitle()); } + @Test public void testAccessStartTaskAsAssigneeFromTaskPartOfProcess() { // Test added to validate fix for CLOUD-1929 - start-task can be accesses by assignee of a task @@ -305,6 +313,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ /** * Test to validate fix for ALF-19822 */ + @Test public void testMultiInstanceListenersCalled() throws Exception { // start pooled review and approve workflow @@ -348,6 +357,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ /** * Test to validate fix for WOR-107 */ + @Test public void testLongTextValues() throws Exception { String veryLongTextValue = getLongString(10000); @@ -380,6 +390,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ /** * Test for MNT-11247 */ + @Test public void testAssignmentListener() { WorkflowDefinition definition = deployDefinition(getAssignmentListenerDefinitionPath()); @@ -411,6 +422,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ /** * Test for MNT-14366 */ + @Test public void testWorkflowRecreatedUser() { WorkflowDefinition definition = deployDefinition("alfresco/workflow/review.bpmn20.xml"); @@ -515,6 +527,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ } @Category(RedundantTests.class) + @Test public void testStartWorkflowFromTaskListener() throws Exception { WorkflowDefinition testDefinition = deployDefinition("activiti/testStartWfFromListener.bpmn20.xml"); @@ -548,6 +561,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ } } + @Test public void testWorkflowWithNodes() throws Exception { authenticationComponent.setSystemUserAsCurrentUser(); @@ -608,6 +622,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertTrue(multi); } + @Test public void testWorkflowVarious() throws Exception { WorkflowDefinition definition = deployDefinition(getTestDefinitionPath()); @@ -640,6 +655,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ } + @Test public void testWorkflowQueries() throws Exception { WorkflowDefinition definition = deployDefinition(getTestDefinitionPath()); @@ -662,6 +678,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertNotNull(completed); } + @Test public void testBuildWorkflowWithNoUserTasks() throws Exception { // Deploy a definition containing only a service task @@ -683,6 +700,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertNotNull(historicProcessInstance); } + @Test public void testNonAdminCannotDeployWorkflowBySwitchingNodeType() { // Test precondition @@ -700,6 +718,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertNull("Workflow should not be deployed", workflowDef); } + @Test public void testNonAdminCannotDeployWorkflowBySwitchingNodeTypeEvenInCorrectLocation() { // Test precondition @@ -722,6 +741,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ } } + @Test public void testAdminCanDeployBySwitchingContentTypeToWorkflow() { // This test should pass, as the workflow is in the correct location @@ -753,6 +773,7 @@ public class ActivitiWorkflowServiceIntegrationTest extends AbstractWorkflowServ assertTrue(path.isActive()); } + @Test public void testAdminCannotDeployBySwitchingContentTypeToWorkflowWhenLocationIsNotValid() { // This should fail to deploy the workflow as it is in the wrong location. diff --git a/src/test/java/org/alfresco/util/BaseAlfrescoSpringTest.java b/src/test/java/org/alfresco/util/BaseAlfrescoSpringTest.java index e3ee5b5a99..bce77f36ed 100644 --- a/src/test/java/org/alfresco/util/BaseAlfrescoSpringTest.java +++ b/src/test/java/org/alfresco/util/BaseAlfrescoSpringTest.java @@ -42,6 +42,9 @@ import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.service.transaction.TransactionService; +import org.junit.After; +import org.junit.Before; +import org.springframework.transaction.annotation.Transactional; /** * Base Alfresco test. @@ -52,6 +55,7 @@ import org.alfresco.service.transaction.TransactionService; * * @author Roy Wetherall */ +@Transactional public abstract class BaseAlfrescoSpringTest extends BaseSpringTest { /** The node service */ @@ -75,15 +79,10 @@ public abstract class BaseAlfrescoSpringTest extends BaseSpringTest protected AuthenticationComponent authenticationComponent; - /** - * On setup in transaction override - */ @SuppressWarnings("deprecation") - @Override - protected void onSetUpInTransaction() throws Exception + @Before + public void before() throws Exception { - super.onSetUpInTransaction(); - // Get a reference to the node service this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); this.contentService = (ContentService) this.applicationContext.getBean("contentService"); @@ -101,12 +100,10 @@ public abstract class BaseAlfrescoSpringTest extends BaseSpringTest this.rootNodeRef = this.nodeService.getRootNode(this.storeRef); } - @SuppressWarnings("deprecation") - @Override - protected void onTearDownInTransaction() throws Exception + @After + public void after() throws Exception { authenticationService.clearCurrentSecurityContext(); - super.onTearDownInTransaction(); } protected NodeRef createNode(NodeRef parentNode, String name, QName type) diff --git a/src/test/java/org/alfresco/util/BaseSpringTest.java b/src/test/java/org/alfresco/util/BaseSpringTest.java index 015e41099d..5bf8f574d9 100644 --- a/src/test/java/org/alfresco/util/BaseSpringTest.java +++ b/src/test/java/org/alfresco/util/BaseSpringTest.java @@ -1,34 +1,38 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.springframework.orm.hibernate3.SessionFactoryUtils; -import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests; +import junit.framework.TestCase; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; /** * Base test class providing Hibernate sessions. @@ -40,66 +44,12 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest * * @author Derek Hulley */ -public abstract class BaseSpringTest extends AbstractTransactionalDataSourceSpringContextTests +@RunWith(SpringRunner.class) +@ContextConfiguration({"classpath:alfresco/application-context.xml"}) +public abstract class BaseSpringTest extends TestCase { - /** protected so that it gets populated if autowiring is done by variable name **/ - protected SessionFactory sessionFactory; - - /** - * Constructor - */ - public BaseSpringTest() - { - // TODO temporarily switch default to auto-wire by name - this.setAutowireMode(AUTOWIRE_BY_NAME); - //this.setDependencyCheck(false); - - } - - /** - * Setter present for in case autowiring is done by type - * - * @param sessionFactory - */ - public void setSessionFactory(SessionFactory sessionFactory) - { - this.sessionFactory = sessionFactory; - } - - /** - * @return Returns the existing session attached to the thread. - * A new session will not be created. - */ - protected Session getSession() - { - return SessionFactoryUtils.getSession(sessionFactory, true); - } - - /** - * Forces the session to flush to the database (without commiting) and clear the - * cache. This ensures that all reads against the session are fresh instances, - * which gives the assurance that the DB read/write operations occur correctly. - */ - protected void flushAndClear() - { - getSession().flush(); - getSession().clear(); - } - - /** - * Get the config locations - * - * @return an array containing the config locations - */ - @Override - protected String[] getConfigLocations() - { - - if (logger.isDebugEnabled()) - { - logger.debug("Getting config locations"); - } - return ApplicationContextHelper.CONFIG_LOCATIONS; - } + public Log logger = LogFactory.getLog(getClass().getName()); + @Autowired + protected ApplicationContext applicationContext; } diff --git a/src/test/java/org/alfresco/util/CronTriggerBeanSystemTest.java b/src/test/java/org/alfresco/util/CronTriggerBeanSystemTest.java deleted file mode 100644 index ed681d0548..0000000000 --- a/src/test/java/org/alfresco/util/CronTriggerBeanSystemTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ - -package org.alfresco.util; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -/** - * This class tests the CronTriggerBean within the full Alfresco context. - * This test runs in about 45 seconds. - * - * @author Ahmed Owian - */ -public class CronTriggerBeanSystemTest -{ - private ClassPathXmlApplicationContext context; - - @Before - public void setUp() throws Exception - { - this.context = (ClassPathXmlApplicationContext) ApplicationContextHelper.getApplicationContext(); - } - - /** - * All CronTriggerBean classes should be configured with a delay - * to allow the server to start before the jobs run. - */ - @Test - public void testAllCronTriggerBeansHaveDelay() - { - Map beans = this.context - .getBeansOfType(org.alfresco.util.CronTriggerBean.class); - assertFalse(beans.isEmpty()); - List undelayedJobs = new ArrayList<>(); - - for (Map.Entry entry : beans.entrySet()) - { - CronTriggerBean bean = entry.getValue(); - if (bean.getStartDelay() == 0) - { - undelayedJobs.add(entry.getKey()); - } - } - - assertTrue("Undelayed CronTriggerBeans: " + undelayedJobs, undelayedJobs.isEmpty()); - } -} diff --git a/src/test/java/org/alfresco/util/CronTriggerBeanTest.java b/src/test/java/org/alfresco/util/CronTriggerBeanTest.java deleted file mode 100644 index 5bc91597d5..0000000000 --- a/src/test/java/org/alfresco/util/CronTriggerBeanTest.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.quartz.Job; -import org.quartz.JobDetail; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.Scheduler; -import org.quartz.impl.StdSchedulerFactory; -import org.springframework.beans.BeansException; -import org.springframework.context.support.ClassPathXmlApplicationContext; - - -/** - * This class tests that the CronTriggerBean correctly delays jobs when specified. - * This test runs in about 25 seconds. - * - * @author Ahmed Owian - */ -public class CronTriggerBeanTest -{ - // One second - an arbitrarily small amount of time to allow for the - // scheduler to start the jobs - final long PRECISION_LEEWAY = 1000L; - final long INTERVAL = 1000L;// One run every second - - private ClassPathXmlApplicationContext context; - private Scheduler scheduler; - - private static Map> dummyJobRuns; - private static Object lockToken = new Object(); - - @Before - public void setUp() throws Exception - { - dummyJobRuns = new HashMap>(); - this.context = null; - this.scheduler = null; - } - - @After - public void tearDown() throws Exception - { - try - { - this.scheduler.shutdown(); - } - catch (Exception e) - { - // do nothing - } - - try - { - context.close(); - } - catch (Exception e) - { - // do nothing - } - } - - /** - * Ensures that jobs that are coded without a delay run without delay. - * @throws Exception - */ - @Test - public void testCodedCronTriggerBean() throws Exception - { - final String JOB_NAME = "codedCronJob"; - List jobRuns = this.getRunList(JOB_NAME); - assertEquals(0, jobRuns.size()); - scheduler = StdSchedulerFactory.getDefaultScheduler(); - scheduler.start(); - CronTriggerBean ctBean = new CronTriggerBean(); - ctBean.setBeanName("Dummy"); - ctBean.setCronExpression("0/1 * * * * ? *"); - ctBean.setEnabled(true); - JobDetail jobDetail = new JobDetail(JOB_NAME, "DefaultGroup", DummyJob.class); - ctBean.setJobDetail(jobDetail); - ctBean.setScheduler(scheduler); - ctBean.afterPropertiesSet(); - - assertJobRunsAfterInterval(jobRuns); - scheduler.shutdown(); - this.assertJobStopsAfterShutdown(jobRuns); - } - - /** - * Ensures that jobs that are configured without a delay run without delay. - * @throws BeansException - * @throws Exception - */ - @Test - public void testConfiguredCronTriggerBean() throws BeansException, Exception - { - final String JOB_NAME = "configuredCronJob"; - List jobRuns = this.getRunList(JOB_NAME); - assertEquals(0, jobRuns.size()); - context = new ClassPathXmlApplicationContext("alfresco/scheduler-core-context.xml", - "org/alfresco/util/test-scheduled-jobs-context.xml"); - CronTriggerBean ctBean = context.getBean("cronTriggerBean", CronTriggerBean.class); - scheduler = ctBean.getScheduler(); - scheduler.start(); - - assertJobRunsAfterInterval(jobRuns); - context.close(); // When the context closes, the scheduler should close, - // thereby stopping the job - assertJobStopsAfterShutdown(jobRuns); - } - - /** - * Ensures that jobs that are coded with a delay run after the delay. - * @throws Exception - */ - @Test - public void testCodedDelayedCronTriggerBean() throws Exception - { - final String JOB_NAME = "codedDelayedCronJob"; - List jobRuns = this.getRunList(JOB_NAME); - assertEquals(0, jobRuns.size()); - CronTriggerBean ctBean = new CronTriggerBean(); - ctBean.setBeanName("Dummy"); - ctBean.setCronExpression("0/1 * * * * ? *"); - ctBean.setEnabled(true); - JobDetail jobDetail = new JobDetail(JOB_NAME, "DefaultGroup", DummyJob.class); - ctBean.setJobDetail(jobDetail); - scheduler = StdSchedulerFactory.getDefaultScheduler(); - ctBean.setScheduler(scheduler); - final long START_DELAY = 4000L; - ctBean.setStartDelay(START_DELAY); - - final long PRE_SCHEDULING = System.currentTimeMillis(); - ctBean.afterPropertiesSet(); // This is when the trigger is actually - // scheduled - long startTime = ctBean.getTrigger().getStartTime().getTime(); - assertTrue("The startTime should be the time when the trigger is scheduled plus the START_DELAY.", - startTime - PRE_SCHEDULING - START_DELAY <= PRECISION_LEEWAY); - assertEquals(0, jobRuns.size()); - - scheduler.start(); - assertJobDoesNotRunBeforeStartTime(jobRuns, startTime); - assertJobRunsAfterInterval(jobRuns); - scheduler.shutdown(); - assertJobStopsAfterShutdown(jobRuns); - } - - /** - * Ensures that jobs that are configured with a delay run after the delay. - * @throws BeansException - * @throws Exception - */ - @Test - public void testConfiguredDelayedCronTriggerBean() throws BeansException, Exception - { - final String JOB_NAME = "configuredDelayedCronJob"; - List jobRuns = this.getRunList(JOB_NAME); - assertEquals(0, jobRuns.size()); - - // Captures the system time before the Spring context is initialized and - // the triggers are scheduled - final long PRE_INITIALIZATION = System.currentTimeMillis(); - context = new ClassPathXmlApplicationContext("alfresco/scheduler-core-context.xml", - "org/alfresco/util/test-scheduled-jobs-context.xml"); - CronTriggerBean ctBean = context.getBean("cronTriggerBeanDelayed", CronTriggerBean.class); - final long START_DELAY = ctBean.getStartDelay(); - long startTime = ctBean.getTrigger().getStartTime().getTime(); - assertTrue("The startTime should be the time when the Spring context is initialized plus the START_DELAY.", - startTime - PRE_INITIALIZATION - START_DELAY <= PRECISION_LEEWAY); - assertEquals(0, jobRuns.size()); - - scheduler = ctBean.getScheduler(); - scheduler.start(); - assertJobDoesNotRunBeforeStartTime(jobRuns, startTime); - assertJobRunsAfterInterval(jobRuns); - context.close(); // When the context closes, the scheduler should close, - // thereby stopping the job - assertJobStopsAfterShutdown(jobRuns); - } - - private void assertJobStopsAfterShutdown(List jobRuns) throws InterruptedException - { - // Gives the job one final interval to stop, but after that, there - // should be no more runs - Thread.sleep(INTERVAL); - int runs = jobRuns.size(); - Thread.sleep(INTERVAL); - assertEquals(runs, jobRuns.size()); - Thread.sleep(INTERVAL); - assertEquals(runs, jobRuns.size()); - } - - private void assertJobRunsAfterInterval(List jobRuns) throws InterruptedException - { - // After the interval, there should be at least one run - Thread.sleep(INTERVAL); - assertTrue(jobRuns.size() > 0); - } - - private void assertJobDoesNotRunBeforeStartTime(List jobRuns, long startTime) - throws InterruptedException - { - // Synchronizing on an object prevents jobs from running while checking - synchronized (lockToken) - { - // It should not run before the start time - while (System.currentTimeMillis() < startTime) - { - assertEquals(0, jobRuns.size()); - Thread.sleep(20); // Sleeps so as to not take up all the CPU - } - } - } - - public static class DummyJob implements Job - { - public void execute(JobExecutionContext context) throws JobExecutionException - { - synchronized (lockToken) - { - long now = System.currentTimeMillis(); - ArrayList runs = dummyJobRuns.get(context.getJobDetail().getName()); - if (runs == null) - { - runs = new ArrayList(); - dummyJobRuns.put(context.getJobDetail().getName(), runs); - } - runs.add(now); - } - } - } - - private List getRunList(String jobName) - { - ArrayList runs = dummyJobRuns.get(jobName); - if (runs == null) - { - runs = new ArrayList(); - dummyJobRuns.put(jobName, runs); - } - return runs; - } -} diff --git a/src/test/java/org/alfresco/util/bean/HierarchicalBeanLoaderTest.java b/src/test/java/org/alfresco/util/bean/HierarchicalBeanLoaderTest.java new file mode 100644 index 0000000000..4900d19240 --- /dev/null +++ b/src/test/java/org/alfresco/util/bean/HierarchicalBeanLoaderTest.java @@ -0,0 +1,100 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2018 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.util.bean; + +import java.util.AbstractCollection; +import java.util.AbstractList; +import java.util.Collection; +import java.util.TreeSet; +import junit.framework.TestCase; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @see HierarchicalBeanLoader + * + * @author Derek Hulley + * @since 3.2SP1 + */ +public class HierarchicalBeanLoaderTest extends TestCase +{ + private ClassPathXmlApplicationContext ctx; + + private String getBean(Class clazz, boolean setBeforeInit) throws Exception + { + if (setBeforeInit) + { + System.setProperty("hierarchy-test.dialect", clazz.getName()); + } + ctx = new ClassPathXmlApplicationContext("bean-loader/hierarchical-bean-loader-test-context.xml"); + if (!setBeforeInit) + { + System.setProperty("hierarchy-test.dialect", clazz.getName()); + } + return (String) ctx.getBean("test.someString"); + } + + public void tearDown() + { + try + { + ctx.close(); + } + catch (Throwable e) + { + } + } + + public void testSuccess1() throws Throwable + { + String str = getBean(TreeSet.class, true); + assertEquals("Bean value incorrect", "TreeSet", str); + } + + public void testSuccess2() throws Throwable + { + String str = getBean(AbstractList.class, true); + assertEquals("Bean value incorrect", "AbstractList", str); + } + + public void testSuccess3() throws Throwable + { + String str = getBean(AbstractCollection.class, true); + assertEquals("Bean value incorrect", "AbstractCollection", str); + } + + public void testFailure1() throws Throwable + { + try + { + getBean(Collection.class, true); + fail("Should not be able to retrieve bean using class " + Collection.class); + } + catch (Throwable e) + { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/org/alfresco/util/resource/HierarchicalResourceLoaderTest.java b/src/test/java/org/alfresco/util/resource/HierarchicalResourceLoaderTest.java new file mode 100644 index 0000000000..a56971f32f --- /dev/null +++ b/src/test/java/org/alfresco/util/resource/HierarchicalResourceLoaderTest.java @@ -0,0 +1,177 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.util.resource; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.AbstractCollection; +import java.util.AbstractList; +import java.util.AbstractSet; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.TreeSet; + +import junit.framework.TestCase; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.springframework.core.io.Resource; + +/** + * @see HierarchicalResourceLoader + * + * @author Derek Hulley + * @since 3.2 (Mobile) + */ +public class HierarchicalResourceLoaderTest extends TestCase +{ + private HierarchicalResourceLoader getLoader( + Class baseClazz, + Class clazz) throws Throwable + { + HierarchicalResourceLoader loader = new HierarchicalResourceLoader(); + loader.setDialectBaseClass(baseClazz.getName()); + loader.setDialectClass(clazz.getName()); + loader.afterPropertiesSet(); + return loader; + } + + /** + * Check that unmatched hierarchies are detected + */ + public void testMismatchDetection() throws Throwable + { + // First, do a successful few + getLoader(AbstractCollection.class, TreeSet.class); + getLoader(AbstractCollection.class, HashSet.class); + getLoader(AbstractCollection.class, ArrayList.class); + getLoader(AbstractCollection.class, AbstractCollection.class); + // Now blow up a bit + try + { + getLoader(Collection.class, Object.class).getResource("abc"); + fail("Failed to detect incompatible class hierarchy"); + } + catch (RuntimeException e) + { + // Expected + } + try + { + getLoader(ArrayList.class, AbstractCollection.class).getResource("abc"); + fail("Failed to detect incompatible class hierarchy"); + } + catch (RuntimeException e) + { + // Expected + } + } + + private void checkResource(Resource resource, String check) throws Throwable + { + assertNotNull("Resource not found", resource); + assertTrue("Resource doesn't exist", resource.exists()); + InputStream is = resource.getInputStream(); + StringBuilder builder = new StringBuilder(128); + byte[] bytes = new byte[128]; + InputStream tempIs = null; + try + { + tempIs = new BufferedInputStream(is, 128); + int count = -2; + while (count != -1) + { + // do we have something previously read? + if (count > 0) + { + String toWrite = new String(bytes, 0, count, "UTF-8"); + builder.append(toWrite); + } + // read the next set of bytes + count = tempIs.read(bytes); + } + } + catch (IOException e) + { + throw new AlfrescoRuntimeException("Unable to read stream", e); + } + finally + { + // close the input stream + try + { + is.close(); + } + catch (Exception e) + { + } + } + // The string + String fileValue = builder.toString(); + assertEquals("Incorrect file retrieved: ", check, fileValue); + } + + private static final String RESOURCE = "classpath:resource-loader/#resource.dialect#/file.txt"; + /** + * Check that resource loading works. + * + * The data available is: + *
+     * classpatch:resource-loader/
+     *    java.util.AbstractCollection
+     *    java.util.AbstractList
+     *    java.util.TreeSet 
+     * 
+ * With each folder containing a text file with the name of the folder. + */ + public void testResourceLoading() throws Throwable + { + // First, do a successful few + HierarchicalResourceLoader bean; + Resource resource; + + bean = getLoader(AbstractCollection.class, TreeSet.class); + resource = bean.getResource(RESOURCE); + checkResource(resource, "java.util.TreeSet"); + + bean = getLoader(AbstractCollection.class, AbstractSet.class); + resource = bean.getResource(RESOURCE); + checkResource(resource, "java.util.AbstractCollection"); + + bean = getLoader(AbstractCollection.class, AbstractCollection.class); + resource = bean.getResource(RESOURCE); + checkResource(resource, "java.util.AbstractCollection"); + + bean = getLoader(AbstractCollection.class, ArrayList.class); + resource = bean.getResource(RESOURCE); + checkResource(resource, "java.util.AbstractList"); + + bean = getLoader(AbstractCollection.class, AbstractList.class); + resource = bean.getResource(RESOURCE); + checkResource(resource, "java.util.AbstractList"); + } +} diff --git a/src/test/java/org/alfresco/util/schemacomp/DefaultComparisonUtilsTest.java b/src/test/java/org/alfresco/util/schemacomp/DefaultComparisonUtilsTest.java index 122574d59e..23c0bfe8bd 100644 --- a/src/test/java/org/alfresco/util/schemacomp/DefaultComparisonUtilsTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/DefaultComparisonUtilsTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp; @@ -36,11 +36,11 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.util.schemacomp.Difference.Where; import org.alfresco.util.schemacomp.model.AbstractDbObject; import org.alfresco.util.schemacomp.model.DbObject; import org.alfresco.util.schemacomp.validator.DbValidator; -import org.hibernate.dialect.Dialect; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -58,7 +58,8 @@ public class DefaultComparisonUtilsTest private @Mock Results differences; private DefaultComparisonUtils comparisonUtils; private DiffContext ctx; - private @Mock Dialect dialect; + @Mock + private Dialect dialect; @Before public void setUp() diff --git a/src/test/java/org/alfresco/util/schemacomp/ExportDbTest.java b/src/test/java/org/alfresco/util/schemacomp/ExportDbTest.java index 554b4ad8ba..e06e531042 100644 --- a/src/test/java/org/alfresco/util/schemacomp/ExportDbTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/ExportDbTest.java @@ -28,7 +28,10 @@ package org.alfresco.util.schemacomp; import javax.sql.DataSource; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoMariaDBDialect; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MariaDBDialect; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; +import org.alfresco.repo.domain.dialect.PostgreSQLDialect; import org.alfresco.test_category.OwnJVMTestsCategory; import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.schemacomp.model.Schema; @@ -39,14 +42,11 @@ import org.alfresco.util.schemacomp.test.exportdb.PostgreSQLDialectExportTester; import org.alfresco.util.testing.category.DBTests; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.MySQLDialect; -import org.hibernate.dialect.PostgreSQLDialect; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.context.ApplicationContext; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.PlatformTransactionManager; /** @@ -66,7 +66,7 @@ public class ExportDbTest private ExportDb exporter; private Dialect dialect; private DataSource dataSource; - private SimpleJdbcTemplate jdbcTemplate; + private JdbcTemplate jdbcTemplate; private PlatformTransactionManager tx; private AbstractExportTester exportTester; private static final Log logger = LogFactory.getLog(ExportDbTest.class); @@ -78,7 +78,7 @@ public class ExportDbTest ctx = ApplicationContextHelper.getApplicationContext(); dataSource = (DataSource) ctx.getBean("dataSource"); tx = (PlatformTransactionManager) ctx.getBean("transactionManager"); - jdbcTemplate = new SimpleJdbcTemplate(dataSource); + jdbcTemplate = new JdbcTemplate(dataSource); exporter = new ExportDb(ctx); exporter.setNamePrefix("export_test_"); dialect = (Dialect) ctx.getBean("dialect"); @@ -98,11 +98,11 @@ public class ExportDbTest { exportTester = new PostgreSQLDialectExportTester(exporter, tx, jdbcTemplate); } - else if (AlfrescoMariaDBDialect.class.isAssignableFrom(dialectClass)) + else if (MariaDBDialect.class.isAssignableFrom(dialectClass)) { exportTester = new AlfrescoMariaDBDialectExportTester(exporter, tx, jdbcTemplate); } - else if (MySQLDialect.class.isAssignableFrom(dialectClass)) + else if (MySQLInnoDBDialect.class.isAssignableFrom(dialectClass)) { exportTester = new MySQLDialectExportTester(exporter, tx, jdbcTemplate); } diff --git a/src/test/java/org/alfresco/util/schemacomp/SchemaComparatorTest.java b/src/test/java/org/alfresco/util/schemacomp/SchemaComparatorTest.java index 4146caf533..3e08f39a70 100644 --- a/src/test/java/org/alfresco/util/schemacomp/SchemaComparatorTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/SchemaComparatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ /* * Copytarget (C) 2005-2011 Alfresco Software Limited. * @@ -61,6 +61,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import org.alfresco.repo.domain.dialect.Dialect; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; import org.alfresco.util.schemacomp.Difference.Where; import org.alfresco.util.schemacomp.model.DbObject; import org.alfresco.util.schemacomp.model.Index; @@ -69,8 +71,6 @@ import org.alfresco.util.schemacomp.model.Schema; import org.alfresco.util.schemacomp.model.Table; import org.alfresco.util.schemacomp.validator.DbValidator; import org.alfresco.util.schemacomp.validator.NameValidator; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.MySQL5InnoDBDialect; import org.junit.Before; import org.junit.Test; @@ -91,7 +91,7 @@ public class SchemaComparatorTest { reference = new Schema("schema", "alf_", 590, true); target = new Schema("schema", "alf_", 590, true); - dialect = new MySQL5InnoDBDialect(); + dialect = new MySQLInnoDBDialect(); } diff --git a/src/test/java/org/alfresco/util/schemacomp/ValidatingVisitorTest.java b/src/test/java/org/alfresco/util/schemacomp/ValidatingVisitorTest.java index 438ea74b6a..2d968589fb 100644 --- a/src/test/java/org/alfresco/util/schemacomp/ValidatingVisitorTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/ValidatingVisitorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp; @@ -30,12 +30,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.alfresco.repo.domain.dialect.MySQLInnoDBDialect; import org.alfresco.util.schemacomp.model.DbObject; import org.alfresco.util.schemacomp.model.Index; import org.alfresco.util.schemacomp.model.Schema; import org.alfresco.util.schemacomp.model.Table; import org.alfresco.util.schemacomp.validator.DbValidator; -import org.hibernate.dialect.MySQL5InnoDBDialect; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; @@ -67,7 +67,7 @@ public class ValidatingVisitorTest { refTable = new Table("reference_table"); refIndex = new Index(refTable, "index_name", Arrays.asList("a", "b", "c")); - ctx = new DiffContext(new MySQL5InnoDBDialect(), refSchema, targetSchema); + ctx = new DiffContext(new MySQLInnoDBDialect(), refSchema, targetSchema); visitor = new ValidatingVisitor(ctx); validators = new ArrayList(); diff --git a/src/test/java/org/alfresco/util/schemacomp/model/AbstractDbObjectTest.java b/src/test/java/org/alfresco/util/schemacomp/model/AbstractDbObjectTest.java index f8a823af47..8c40b62ea5 100644 --- a/src/test/java/org/alfresco/util/schemacomp/model/AbstractDbObjectTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/model/AbstractDbObjectTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.model; import static org.junit.Assert.assertEquals; @@ -33,6 +33,7 @@ import static org.mockito.Mockito.inOrder; import java.util.Arrays; import java.util.List; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.util.schemacomp.DbObjectVisitor; import org.alfresco.util.schemacomp.DbProperty; import org.alfresco.util.schemacomp.DiffContext; @@ -40,7 +41,6 @@ import org.alfresco.util.schemacomp.Difference.Where; import org.alfresco.util.schemacomp.Results; import org.alfresco.util.schemacomp.validator.AbstractDbValidator; import org.alfresco.util.schemacomp.validator.DbValidator; -import org.hibernate.dialect.Dialect; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -59,7 +59,8 @@ public class AbstractDbObjectTest private ConcreteDbObject dbObject; private @Mock Results differences; private DiffContext ctx; - private @Mock Dialect dialect; + @Mock + private Dialect dialect; /** * @throws java.lang.Exception diff --git a/src/test/java/org/alfresco/util/schemacomp/model/DbObjectTestBase.java b/src/test/java/org/alfresco/util/schemacomp/model/DbObjectTestBase.java index cd2c47e2d1..d6a4dd101a 100644 --- a/src/test/java/org/alfresco/util/schemacomp/model/DbObjectTestBase.java +++ b/src/test/java/org/alfresco/util/schemacomp/model/DbObjectTestBase.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.model; import static org.mockito.Mockito.inOrder; @@ -30,12 +30,12 @@ import static org.mockito.Mockito.inOrder; import java.util.ArrayList; import java.util.List; +import org.alfresco.repo.domain.dialect.Dialect; import org.alfresco.util.schemacomp.ComparisonUtils; import org.alfresco.util.schemacomp.DbObjectVisitor; import org.alfresco.util.schemacomp.DbProperty; import org.alfresco.util.schemacomp.DiffContext; import org.alfresco.util.schemacomp.Results; -import org.hibernate.dialect.Dialect; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -51,7 +51,8 @@ import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) public abstract class DbObjectTestBase { - protected @Mock Dialect dialect; + @Mock + protected Dialect dialect; protected @Mock Results differences; protected DiffContext ctx; protected @Mock ComparisonUtils comparisonUtils; diff --git a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AbstractExportTester.java b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AbstractExportTester.java index 84528a8e60..dbe09c1b9a 100644 --- a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AbstractExportTester.java +++ b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AbstractExportTester.java @@ -1,42 +1,42 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.test.exportdb; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - import org.alfresco.util.schemacomp.ExportDb; import org.alfresco.util.schemacomp.ExportDbTest; import org.alfresco.util.schemacomp.model.DbObject; import org.alfresco.util.schemacomp.model.Schema; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.PlatformTransactionManager; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + /** * Base class for DBMS-specific ExportDb tests. * @@ -47,10 +47,10 @@ public abstract class AbstractExportTester { protected ExportDb exporter; protected PlatformTransactionManager tx; - protected SimpleJdbcTemplate jdbcTemplate; + protected JdbcTemplate jdbcTemplate; private final static Log log = LogFactory.getLog(AbstractExportTester.class); - public AbstractExportTester(ExportDb exporter, PlatformTransactionManager tx, SimpleJdbcTemplate jdbcTemplate) + public AbstractExportTester(ExportDb exporter, PlatformTransactionManager tx, JdbcTemplate jdbcTemplate) { this.exporter = exporter; this.tx = tx; diff --git a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AlfrescoMariaDBDialectExportTester.java b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AlfrescoMariaDBDialectExportTester.java index 37592b9293..e50758b1c2 100644 --- a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AlfrescoMariaDBDialectExportTester.java +++ b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/AlfrescoMariaDBDialectExportTester.java @@ -25,18 +25,25 @@ */ package org.alfresco.util.schemacomp.test.exportdb; +import java.util.Iterator; import org.alfresco.util.schemacomp.ExportDb; import org.alfresco.util.schemacomp.ExportDbTest; -import org.alfresco.util.schemacomp.model.*; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.alfresco.util.schemacomp.model.Column; +import org.alfresco.util.schemacomp.model.DbObject; +import org.alfresco.util.schemacomp.model.ForeignKey; +import org.alfresco.util.schemacomp.model.Index; +import org.alfresco.util.schemacomp.model.PrimaryKey; +import org.alfresco.util.schemacomp.model.Schema; +import org.alfresco.util.schemacomp.model.Table; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.transaction.support.TransactionTemplate; -import java.util.Iterator; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; /** * MySQL specific test for the ExportDb class. @@ -54,7 +61,7 @@ public class AlfrescoMariaDBDialectExportTester extends AbstractExportTester * @param jdbcTemplate */ public AlfrescoMariaDBDialectExportTester(ExportDb exporter, PlatformTransactionManager tx, - SimpleJdbcTemplate jdbcTemplate) + JdbcTemplate jdbcTemplate) { super(exporter, tx, jdbcTemplate); } diff --git a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java index 7d975b7867..c7b107b9b8 100644 --- a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java +++ b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/MySQLDialectExportTester.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.test.exportdb; import static org.junit.Assert.assertEquals; @@ -40,7 +40,7 @@ import org.alfresco.util.schemacomp.model.Index; import org.alfresco.util.schemacomp.model.PrimaryKey; import org.alfresco.util.schemacomp.model.Schema; import org.alfresco.util.schemacomp.model.Table; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallbackWithoutResult; @@ -62,7 +62,7 @@ public class MySQLDialectExportTester extends AbstractExportTester * @param jdbcTemplate */ public MySQLDialectExportTester(ExportDb exporter, PlatformTransactionManager tx, - SimpleJdbcTemplate jdbcTemplate) + JdbcTemplate jdbcTemplate) { super(exporter, tx, jdbcTemplate); } diff --git a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java index ab0b365522..b4aba302dc 100644 --- a/src/test/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java +++ b/src/test/java/org/alfresco/util/schemacomp/test/exportdb/PostgreSQLDialectExportTester.java @@ -1,36 +1,31 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.test.exportdb; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; - import java.util.Iterator; - import org.alfresco.util.schemacomp.ExportDb; import org.alfresco.util.schemacomp.ExportDbTest; import org.alfresco.util.schemacomp.model.Column; @@ -41,12 +36,16 @@ import org.alfresco.util.schemacomp.model.PrimaryKey; import org.alfresco.util.schemacomp.model.Schema; import org.alfresco.util.schemacomp.model.Sequence; import org.alfresco.util.schemacomp.model.Table; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.transaction.support.TransactionTemplate; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; + /** * Test implementation for the PostgreSQL database dialect. * @@ -62,7 +61,7 @@ public class PostgreSQLDialectExportTester extends AbstractExportTester * @param jdbcTemplate * @param tx */ - public PostgreSQLDialectExportTester(ExportDb exporter, PlatformTransactionManager tx, SimpleJdbcTemplate jdbcTemplate) + public PostgreSQLDialectExportTester(ExportDb exporter, PlatformTransactionManager tx, JdbcTemplate jdbcTemplate) { super(exporter, tx, jdbcTemplate); } diff --git a/src/test/java/org/alfresco/util/schemacomp/validator/IndexColumnsValidatorTest.java b/src/test/java/org/alfresco/util/schemacomp/validator/IndexColumnsValidatorTest.java index 91f0d4be92..ee934740d9 100644 --- a/src/test/java/org/alfresco/util/schemacomp/validator/IndexColumnsValidatorTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/validator/IndexColumnsValidatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.validator; import static org.junit.Assert.assertEquals; @@ -32,12 +32,12 @@ import java.util.Arrays; import java.util.regex.Pattern; import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.repo.domain.dialect.Oracle9Dialect; import org.alfresco.util.schemacomp.DiffContext; import org.alfresco.util.schemacomp.Results; import org.alfresco.util.schemacomp.ValidationResult; import org.alfresco.util.schemacomp.model.Index; import org.alfresco.util.schemacomp.model.Table; -import org.hibernate.dialect.Oracle10gDialect; import org.junit.Before; import org.junit.Test; @@ -57,7 +57,7 @@ public class IndexColumnsValidatorTest { validator = new IndexColumnsValidator(); validationResults = new Results(); - ctx = new DiffContext(new Oracle10gDialect(), validationResults, null, null); + ctx = new DiffContext(new Oracle9Dialect(), validationResults, null, null); } @Test diff --git a/src/test/java/org/alfresco/util/schemacomp/validator/NameValidatorTest.java b/src/test/java/org/alfresco/util/schemacomp/validator/NameValidatorTest.java index d0685ab17f..b30319289b 100644 --- a/src/test/java/org/alfresco/util/schemacomp/validator/NameValidatorTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/validator/NameValidatorTest.java @@ -1,28 +1,28 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.util.schemacomp.validator; @@ -31,12 +31,12 @@ import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.regex.Pattern; +import org.alfresco.repo.domain.dialect.Oracle9Dialect; import org.alfresco.util.schemacomp.DiffContext; import org.alfresco.util.schemacomp.Results; import org.alfresco.util.schemacomp.ValidationResult; import org.alfresco.util.schemacomp.model.DbObject; import org.alfresco.util.schemacomp.model.Index; -import org.hibernate.dialect.Oracle10gDialect; import org.junit.Before; import org.junit.Test; @@ -56,7 +56,7 @@ public class NameValidatorTest { validator = new NameValidator(); validationResults = new Results(); - ctx = new DiffContext(new Oracle10gDialect(), validationResults, null, null); + ctx = new DiffContext(new Oracle9Dialect(), validationResults, null, null); } @Test diff --git a/src/test/java/org/alfresco/util/schemacomp/validator/TypeNameOnlyValidatorTest.java b/src/test/java/org/alfresco/util/schemacomp/validator/TypeNameOnlyValidatorTest.java index 0ebc7705cc..5eca346ec5 100644 --- a/src/test/java/org/alfresco/util/schemacomp/validator/TypeNameOnlyValidatorTest.java +++ b/src/test/java/org/alfresco/util/schemacomp/validator/TypeNameOnlyValidatorTest.java @@ -25,13 +25,9 @@ */ package org.alfresco.util.schemacomp.validator; -import static org.junit.Assert.fail; -import static org.junit.Assert.assertEquals; - import java.util.ArrayList; - import org.alfresco.error.AlfrescoRuntimeException; -import org.alfresco.repo.domain.hibernate.dialect.AlfrescoSQLServerDialect; +import org.alfresco.repo.domain.dialect.SQLServerDialect; import org.alfresco.util.schemacomp.DiffContext; import org.alfresco.util.schemacomp.Results; import org.alfresco.util.schemacomp.model.Column; @@ -40,6 +36,9 @@ import org.alfresco.util.schemacomp.model.Index; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + /** * Tests for the TypeNameOnlyValidator class. @@ -57,7 +56,7 @@ public class TypeNameOnlyValidatorTest { validator = new TypeNameOnlyValidator(); validationResults = new Results(); - ctx = new DiffContext(new AlfrescoSQLServerDialect(), validationResults, null, null); + ctx = new DiffContext(new SQLServerDialect(), validationResults, null, null); } @Test diff --git a/src/test/resources/alfresco/ibatis/ibatis-test-context.xml b/src/test/resources/alfresco/ibatis/ibatis-test-context.xml index 6879b6ca05..5eeba6f3be 100644 --- a/src/test/resources/alfresco/ibatis/ibatis-test-context.xml +++ b/src/test/resources/alfresco/ibatis/ibatis-test-context.xml @@ -9,7 +9,7 @@ - classpath:alfresco/ibatis/org.hibernate.dialect.Dialect/query-test-common-SqlMap.xml + classpath:alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-test-common-SqlMap.xml diff --git a/src/test/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-test-common-SqlMap.xml b/src/test/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-test-common-SqlMap.xml similarity index 100% rename from src/test/resources/alfresco/ibatis/org.hibernate.dialect.Dialect/query-test-common-SqlMap.xml rename to src/test/resources/alfresco/ibatis/org.alfresco.repo.domain.dialect.Dialect/query-test-common-SqlMap.xml diff --git a/src/test/resources/bean-loader/hierarchical-bean-loader-test-context.xml b/src/test/resources/bean-loader/hierarchical-bean-loader-test-context.xml new file mode 100644 index 0000000000..92bf3810b8 --- /dev/null +++ b/src/test/resources/bean-loader/hierarchical-bean-loader-test-context.xml @@ -0,0 +1,44 @@ + + + + + + + + false + + + SYSTEM_PROPERTIES_MODE_OVERRIDE + + + false + + + + + + test.someString.#bean.dialect# + + + java.lang.String + + + java.util.AbstractCollection + + + ${hierarchy-test.dialect} + + + + + + + + + + + + + + diff --git a/src/test/resources/ibatis/hierarchy-test/hierarchy-test-SqlMapConfig.xml b/src/test/resources/ibatis/hierarchy-test/hierarchy-test-SqlMapConfig.xml new file mode 100644 index 0000000000..843092498d --- /dev/null +++ b/src/test/resources/ibatis/hierarchy-test/hierarchy-test-SqlMapConfig.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/test/resources/ibatis/hierarchy-test/hierarchy-test-context.xml b/src/test/resources/ibatis/hierarchy-test/hierarchy-test-context.xml new file mode 100644 index 0000000000..2caaecdf80 --- /dev/null +++ b/src/test/resources/ibatis/hierarchy-test/hierarchy-test-context.xml @@ -0,0 +1,52 @@ + + + + + + false + + + SYSTEM_PROPERTIES_MODE_OVERRIDE + + + false + + + + + + java.util.AbstractCollection + + + ${hierarchy-test.dialect} + + + + + + + + + + classpath:ibatis/hierarchy-test/hierarchy-test-SqlMapConfig.xml + + + + + + + + + + java:comp/env/jdbc/dataSource + + + + + + + diff --git a/src/test/resources/ibatis/hierarchy-test/java.util.AbstractCollection/hierarchy-test-SqlMap.xml b/src/test/resources/ibatis/hierarchy-test/java.util.AbstractCollection/hierarchy-test-SqlMap.xml new file mode 100644 index 0000000000..f1b361e9aa --- /dev/null +++ b/src/test/resources/ibatis/hierarchy-test/java.util.AbstractCollection/hierarchy-test-SqlMap.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/ibatis/hierarchy-test/java.util.AbstractList/hierarchy-test-SqlMap.xml b/src/test/resources/ibatis/hierarchy-test/java.util.AbstractList/hierarchy-test-SqlMap.xml new file mode 100644 index 0000000000..bc4fee54e8 --- /dev/null +++ b/src/test/resources/ibatis/hierarchy-test/java.util.AbstractList/hierarchy-test-SqlMap.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/ibatis/hierarchy-test/java.util.TreeSet/hierarchy-test-SqlMap.xml b/src/test/resources/ibatis/hierarchy-test/java.util.TreeSet/hierarchy-test-SqlMap.xml new file mode 100644 index 0000000000..d02053dfbc --- /dev/null +++ b/src/test/resources/ibatis/hierarchy-test/java.util.TreeSet/hierarchy-test-SqlMap.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml b/src/test/resources/org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml index ee14c4ecd7..280e6eb733 100644 --- a/src/test/resources/org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml +++ b/src/test/resources/org/alfresco/repo/content/transform/FailoverContentTransformerTest-context.xml @@ -1,7 +1,9 @@ - - - + + @@ -45,8 +47,7 @@ + class="org.alfresco.repo.content.transform.TestHtml2PdfTriggeredFlag" /> - - - - - - - org.alfresco.util.CronTriggerBeanTest$DummyJob - - - configuredDelayedCronJob - - - - - - org.alfresco.util.CronTriggerBeanTest$DummyJob - - - configuredCronJob - - - - - - true - - - org.alfresco.repo.scheduler.AlfrescoSchedulerFactory - - - - - - - - - DefaultScheduler - - - - false - - - - - - - - - - - - - - 0/1 * * * * ? - - - dummyTriggerBean - - - - - - - - - - - - - - 0/1 * * * * ? - - - dummyTriggerBeanDelayed - - - 4000 - - - - diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle/script_a.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle/script_a.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle/script_a.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle/script_a.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle/script_b.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle/script_b.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle/script_b.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle/script_b.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle/script_c.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle/script_c.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle/script_c.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle/script_c.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle2/post_script.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle2/post_script.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle2/post_script.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle2/post_script.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle2/script_a.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle2/script_a.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle2/script_a.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle2/script_a.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle2/script_b.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle2/script_b.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/bundle2/script_b.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/bundle2/script_b.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/custom-delimiter.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/custom-delimiter.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/custom-delimiter.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/custom-delimiter.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/empty-delimiter.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/empty-delimiter.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/empty-delimiter.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/empty-delimiter.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/generic.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/generic.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/generic.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/generic.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/override.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/override.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/override.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/override.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/unterminated-custom-delimiter.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/unterminated-custom-delimiter.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/unterminated-custom-delimiter.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/unterminated-custom-delimiter.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.Dialect/wrong-usage-delimiter.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/wrong-usage-delimiter.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.Dialect/wrong-usage-delimiter.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.Dialect/wrong-usage-delimiter.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.MySQLInnoDBDialect/override.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/override.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.MySQLInnoDBDialect/override.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/override.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.MySQLInnoDBDialect/specific.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/specific.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.MySQLInnoDBDialect/specific.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.MySQLInnoDBDialect/specific.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.PostgreSQLDialect/override.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.PostgreSQLDialect/override.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.PostgreSQLDialect/override.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.PostgreSQLDialect/override.sql diff --git a/src/test/resources/scriptexec/org.hibernate.dialect.PostgreSQLDialect/specific.sql b/src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.PostgreSQLDialect/specific.sql similarity index 100% rename from src/test/resources/scriptexec/org.hibernate.dialect.PostgreSQLDialect/specific.sql rename to src/test/resources/scriptexec/org.alfresco.repo.domain.dialect.PostgreSQLDialect/specific.sql diff --git a/src/test/resources/scriptexec/script-exec-test.xml b/src/test/resources/scriptexec/script-exec-test.xml index 42967f2668..1151e8c1a4 100644 --- a/src/test/resources/scriptexec/script-exec-test.xml +++ b/src/test/resources/scriptexec/script-exec-test.xml @@ -1,14 +1,11 @@ - + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> + - - - @@ -19,5 +16,5 @@ - + diff --git a/src/test/resources/tenant/mt-admin-context.xml b/src/test/resources/tenant/mt-admin-context.xml index b066fb04f2..85e732a454 100644 --- a/src/test/resources/tenant/mt-admin-context.xml +++ b/src/test/resources/tenant/mt-admin-context.xml @@ -1,18 +1,19 @@ - - - + - - - - - - + + + + + + diff --git a/src/test/resources/test/alfresco/test-database-context.xml b/src/test/resources/test/alfresco/test-database-context.xml index d033d7bd71..0b0971a6b5 100644 --- a/src/test/resources/test/alfresco/test-database-context.xml +++ b/src/test/resources/test/alfresco/test-database-context.xml @@ -5,20 +5,6 @@ - - - - - - classpath:test/alfresco/test-hibernate-cfg.properties - - - - true - - - @@ -86,38 +72,4 @@ ${db.pool.statements.max} - - - - - - - - true - - - - - - - - - - - - - SYNCHRONIZATION_ALWAYS - - - - - - diff --git a/src/test/resources/test/alfresco/test-hibernate-cfg.properties b/src/test/resources/test/alfresco/test-hibernate-cfg.properties deleted file mode 100644 index 795d8d0dad..0000000000 --- a/src/test/resources/test/alfresco/test-hibernate-cfg.properties +++ /dev/null @@ -1,28 +0,0 @@ -# -# Hibernate configuration -# - -# The Hibernate Dialect: -# As of V3.1, the dialect is automatically detected. -# It is still possible to set the dialect explicitly, for example: -hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect -hibernate.hbm2ddl.auto=update -hibernate.jdbc.use_streams_for_binary=true -hibernate.show_sql=false -hibernate.cache.use_query_cache=false -hibernate.max_fetch_depth=10 -hibernate.cache.provider_class=org.alfresco.repo.cache.DefaultCacheProvider -hibernate.cache.use_second_level_cache=true -hibernate.default_batch_fetch_size=1 -hibernate.jdbc.batch_size=32 -hibernate.connection.release_mode=auto -hibernate.connection.isolation=2 - -#hibernate.query.substitutions= -#hibernate.jdbc.use_get_generated_keys=false - -# Oracle Schema Distinction: -# See https://issues.alfresco.com/jira/browse/ETHREEOH-680 -# Metadata queries to Oracle have to be limited by schema name -# when multiple instances of Alfresco are installed on an Oracle server. -#hibernate.default_schema=