CCM NG:
- Database cleanup scripts for tests now running before test methods and not after. This means that the database is still intact after a test is run. Useful for debugging. - ContentSectionSetup now add content types to content section - Some things for the Documents tab in the content centre git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4578 8810af33-2d31-482b-a856-94f89814c4df
parent
c6c137945d
commit
bc466c0618
|
|
@ -22,8 +22,10 @@ import com.arsdigita.bebop.BoxPanel;
|
||||||
import com.arsdigita.bebop.Form;
|
import com.arsdigita.bebop.Form;
|
||||||
import com.arsdigita.bebop.Label;
|
import com.arsdigita.bebop.Label;
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Text;
|
||||||
import com.arsdigita.bebop.event.PrintEvent;
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
import com.arsdigita.bebop.event.PrintListener;
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
import com.arsdigita.bebop.form.OptionGroup;
|
import com.arsdigita.bebop.form.OptionGroup;
|
||||||
import com.arsdigita.bebop.form.SingleSelect;
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
import com.arsdigita.bebop.form.Submit;
|
import com.arsdigita.bebop.form.Submit;
|
||||||
|
|
@ -47,6 +49,7 @@ import org.librecms.contentsection.privileges.TypePrivileges;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TooManyListenersException;
|
import java.util.TooManyListenersException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A form element which displays a select box of all content types available
|
* A form element which displays a select box of all content types available
|
||||||
|
|
@ -73,7 +76,7 @@ public abstract class NewItemForm extends Form {
|
||||||
* Construct a new NewItemForm. It sets a vertical BoxPanel as the component
|
* Construct a new NewItemForm. It sets a vertical BoxPanel as the component
|
||||||
* container.
|
* container.
|
||||||
*
|
*
|
||||||
* @param name the name attribute of the form.
|
* @param name the name attribute of the form.
|
||||||
* @param orientation
|
* @param orientation
|
||||||
*/
|
*/
|
||||||
public NewItemForm(final String name, final int orientation) {
|
public NewItemForm(final String name, final int orientation) {
|
||||||
|
|
@ -87,16 +90,16 @@ public abstract class NewItemForm extends Form {
|
||||||
|
|
||||||
// create and add an "empty" component
|
// create and add an "empty" component
|
||||||
emptyLabel = new Label(
|
emptyLabel = new Label(
|
||||||
new GlobalizedMessage("cms.ui.authoring.no_types_registered",
|
new GlobalizedMessage("cms.ui.authoring.no_types_registered",
|
||||||
CmsConstants.CMS_BUNDLE),
|
CmsConstants.CMS_BUNDLE),
|
||||||
false);
|
false);
|
||||||
emptyLabel.setIdAttr("empty_label");
|
emptyLabel.setIdAttr("empty_label");
|
||||||
panel.add(emptyLabel);
|
panel.add(emptyLabel);
|
||||||
|
|
||||||
createLabel = new Label(
|
createLabel = new Label(
|
||||||
new GlobalizedMessage("cms.ui.authoring.create_new",
|
new GlobalizedMessage("cms.ui.authoring.create_new",
|
||||||
CmsConstants.CMS_BUNDLE),
|
CmsConstants.CMS_BUNDLE),
|
||||||
false);
|
false);
|
||||||
createLabel.setIdAttr("create_label");
|
createLabel.setIdAttr("create_label");
|
||||||
panel.add(createLabel);
|
panel.add(createLabel);
|
||||||
|
|
||||||
|
|
@ -108,35 +111,41 @@ public abstract class NewItemForm extends Form {
|
||||||
// Read the content section's content types and add them as options
|
// Read the content section's content types and add them as options
|
||||||
@Override
|
@Override
|
||||||
public void prepare(final PrintEvent event) {
|
public void prepare(final PrintEvent event) {
|
||||||
final OptionGroup optionGroup = (OptionGroup) event
|
final OptionGroup target = (OptionGroup) event
|
||||||
.getTarget();
|
.getTarget();
|
||||||
optionGroup.clearOptions();
|
target.clearOptions();
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
// gather the content types of this section into a list
|
// gather the content types of this section into a list
|
||||||
final ContentSection section = getContentSection(state);
|
final ContentSection section = getContentSection(state);
|
||||||
final ContentType parentType;
|
// final ContentType parentType;
|
||||||
final List<ContentType> typesCollection;
|
final List<ContentType> typesCollection;
|
||||||
final Long singleTypeID = (Long) state.getValue(
|
final Long singleTypeID = (Long) state.getValue(
|
||||||
new LongParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
new LongParameter(ItemSearch.SINGLE_TYPE_PARAM));
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
|
final NewItemFormController controller = cdiUtil.findBean(
|
||||||
|
NewItemFormController.class);
|
||||||
final ContentTypeRepository typeRepo = cdiUtil.findBean(
|
final ContentTypeRepository typeRepo = cdiUtil.findBean(
|
||||||
ContentTypeRepository.class);
|
ContentTypeRepository.class);
|
||||||
final PermissionChecker permissionChecker = cdiUtil
|
final PermissionChecker permissionChecker = cdiUtil
|
||||||
.findBean(PermissionChecker.class);
|
.findBean(PermissionChecker.class);
|
||||||
|
|
||||||
if (singleTypeID == null) {
|
// if (singleTypeID == null) {
|
||||||
parentType = null;
|
// parentType = null;
|
||||||
} else {
|
// } else {
|
||||||
parentType = typeRepo.findById(singleTypeID).get();
|
// parentType = typeRepo.findById(singleTypeID).get();
|
||||||
}
|
// }
|
||||||
|
// typesCollection = section.getContentTypes().stream()
|
||||||
|
// .filter(type -> permissionChecker.isPermitted(
|
||||||
|
// TypePrivileges.USE_TYPE,
|
||||||
|
// type))
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
typesCollection = controller.getContentTypes(section);
|
||||||
|
|
||||||
typesCollection = section.getContentTypes().stream()
|
typesCollection.forEach(type -> target.addOption(
|
||||||
.filter(type -> permissionChecker.isPermitted(
|
new Option(Long.toString(type.getObjectId()),
|
||||||
TypePrivileges.USE_TYPE,
|
new Text(type.getContentItemClass()))));
|
||||||
type))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -188,7 +197,7 @@ public abstract class NewItemForm extends Form {
|
||||||
|
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final NewItemFormController controller = cdiUtil.findBean(
|
final NewItemFormController controller = cdiUtil.findBean(
|
||||||
NewItemFormController.class);
|
NewItemFormController.class);
|
||||||
boolean isEmpty = !controller.hasContentTypes(section);
|
boolean isEmpty = !controller.hasContentTypes(section);
|
||||||
|
|
||||||
createLabel.setVisible(state, !isEmpty);
|
createLabel.setVisible(state, !isEmpty);
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,27 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.ui.authoring;
|
package com.arsdigita.cms.ui.authoring;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import org.librecms.contentsection.ContentSection;
|
import org.librecms.contentsection.ContentSection;
|
||||||
import org.librecms.contentsection.ContentSectionRepository;
|
import org.librecms.contentsection.ContentSectionRepository;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import org.libreccm.security.PermissionChecker;
|
||||||
|
import org.libreccm.security.Role;
|
||||||
|
import org.libreccm.security.RoleRepository;
|
||||||
|
import org.libreccm.security.Shiro;
|
||||||
|
import org.libreccm.security.User;
|
||||||
|
import org.librecms.contentsection.ContentType;
|
||||||
|
import org.librecms.contentsection.ContentTypeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class for the {@link NewItemForm}.
|
* Controller class for the {@link NewItemForm}.
|
||||||
|
|
@ -39,26 +50,65 @@ class NewItemFormController {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private EntityManager entityManager;
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Shiro shiro;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private PermissionChecker permissionChecker;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private RoleRepository roleRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ContentSectionRepository sectionRepo;
|
private ContentSectionRepository sectionRepo;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ContentTypeRepository typeRepo;
|
||||||
|
|
||||||
@Transactional(Transactional.TxType.REQUIRED)
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
protected boolean hasContentTypes(final ContentSection section) {
|
protected boolean hasContentTypes(final ContentSection section) {
|
||||||
Objects.requireNonNull(section, "Can't work with null for the section.");
|
Objects.requireNonNull(section, "Can't work with null for the section.");
|
||||||
|
|
||||||
// final Optional<ContentSection> contentSection = sectionRepo.findById(
|
final Optional<User> user = shiro.getUser();
|
||||||
// section.getObjectId());
|
if (!user.isPresent()) {
|
||||||
//
|
return false;
|
||||||
// if (contentSection.isPresent()) {
|
}
|
||||||
final TypedQuery<Long> query = entityManager.createNamedQuery("ContentSection.countContentTypes", Long.class);
|
|
||||||
query.setParameter("section", section);
|
final List<Role> roles = user.get().getRoleMemberships().stream()
|
||||||
return query.getSingleResult() > 0;
|
.map(membership -> membership.getRole())
|
||||||
// } else {
|
.collect(Collectors.toList());
|
||||||
// throw new UnexpectedErrorException(String.format(
|
|
||||||
// "ContentSection %s was passed to this method but does not exist "
|
final TypedQuery<Boolean> query = entityManager.createNamedQuery(
|
||||||
// + "in the database.",
|
"ContentSection.hasUsableContentTypes", Boolean.class);
|
||||||
// Objects.toString(section)));
|
query.setParameter("section", section);
|
||||||
// }
|
query.setParameter("roles", roles);
|
||||||
|
query.setParameter("isSysAdmin", permissionChecker.isPermitted("*"));
|
||||||
|
|
||||||
|
return query.getSingleResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected List<ContentType> getContentTypes(final ContentSection section) {
|
||||||
|
Objects.requireNonNull(section);
|
||||||
|
|
||||||
|
final Optional<User> user = shiro.getUser();
|
||||||
|
if (!user.isPresent()) {
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<Role> roles = user.get().getRoleMemberships().stream()
|
||||||
|
.map(membership -> membership.getRole())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
final TypedQuery<ContentType> query = entityManager.createNamedQuery(
|
||||||
|
"ContentSection.findUsableContentTypes",
|
||||||
|
ContentType.class);
|
||||||
|
query.setParameter("section", section);
|
||||||
|
query.setParameter("roles", roles);
|
||||||
|
query.setParameter("isSysAdmin", permissionChecker.isPermitted("*"));
|
||||||
|
|
||||||
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,12 @@ import java.util.ArrayList;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import org.libreccm.core.CoreConstants;
|
||||||
|
|
||||||
import org.libreccm.workflow.WorkflowTemplate;
|
import org.libreccm.workflow.WorkflowTemplate;
|
||||||
import org.librecms.contentsection.privileges.AssetPrivileges;
|
import org.librecms.contentsection.privileges.AssetPrivileges;
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
import org.librecms.contentsection.privileges.TypePrivileges;
|
||||||
import org.librecms.lifecycle.LifecycleDefinition;
|
import org.librecms.lifecycle.LifecycleDefinition;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
|
@ -57,29 +59,53 @@ import static org.librecms.CmsConstants.*;
|
||||||
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
|
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
|
||||||
@NamedQueries({
|
@NamedQueries({
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentSection.findById",
|
name = "ContentSection.findById",
|
||||||
query = "SELECT S FROM ContentSection s WHERE s.objectId = :objectId")
|
query = "SELECT S FROM ContentSection s WHERE s.objectId = :objectId")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentSection.findByLabel",
|
name = "ContentSection.findByLabel",
|
||||||
query = "SELECT s FROM ContentSection s WHERE s.label = :label")
|
query = "SELECT s FROM ContentSection s WHERE s.label = :label")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentSection.findContentTypes",
|
name = "ContentSection.findUsableContentTypes",
|
||||||
query = "SELECT t FROM ContentType t WHERE t.contentSection = :section")
|
query = "SELECT t FROM ContentType t "
|
||||||
|
+ "WHERE t.contentSection = :section "
|
||||||
|
+ "AND "
|
||||||
|
+ "(t IN (SELECT p.object FROM Permission p "
|
||||||
|
+ "WHERE p.grantedPrivilege = '"
|
||||||
|
+ TypePrivileges.USE_TYPE + "' "
|
||||||
|
+ "AND p.grantee in :roles) "
|
||||||
|
+ "OR true = :isSysAdmin)")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentSection.countContentTypes",
|
name = "ContentSection.countUsableContentTypes",
|
||||||
query
|
query = "SELECT COUNT(t) FROM ContentType t "
|
||||||
= "SELECT COUNT(t) FROM ContentType t WHERE t.contentSection = :section"
|
+ "WHERE t.contentSection = :section "
|
||||||
)
|
+ "AND "
|
||||||
|
+ "(t IN (SELECT p.object FROM Permission p "
|
||||||
|
+ "WHERE p.grantedPrivilege = '"
|
||||||
|
+ TypePrivileges.USE_TYPE + "' "
|
||||||
|
+ "AND p.grantee IN :roles) "
|
||||||
|
+ "OR true = :isSysAdmin)")
|
||||||
,
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "ContentSection.findPermissions",
|
name = "ContentSection.hasUsableContentTypes",
|
||||||
query = "SELECT p FROM Permission p "
|
query = "SELECT (CASE WHEN COUNT(t) > 0 THEN true ELSE false END)"
|
||||||
+ "WHERE (p.object = :section "
|
+ "FROM ContentType t "
|
||||||
+ " OR p.object = :rootDocumentsFolder"
|
+ "WHERE t.contentSection = :section "
|
||||||
+ " OR p.object = :rootAssetsFolder) "
|
+ "AND "
|
||||||
|
+ "(t IN (SELECT p.object FROM Permission p "
|
||||||
|
+ "WHERE p.grantedPrivilege = '"
|
||||||
|
+ TypePrivileges.USE_TYPE + "' "
|
||||||
|
+ "AND p.grantee IN :roles) "
|
||||||
|
+ "OR true = :isSysAdmin)")
|
||||||
|
,
|
||||||
|
@NamedQuery(
|
||||||
|
name = "ContentSection.findPermissions",
|
||||||
|
query = "SELECT p FROM Permission p "
|
||||||
|
+ "WHERE (p.object = :section "
|
||||||
|
+ " OR p.object = :rootDocumentsFolder"
|
||||||
|
+ " OR p.object = :rootAssetsFolder) "
|
||||||
+ "AND p.grantee = :role")
|
+ "AND p.grantee = :role")
|
||||||
})
|
})
|
||||||
//@ApplicationType(
|
//@ApplicationType(
|
||||||
|
|
@ -149,39 +175,39 @@ public class ContentSection extends CcmApplication implements Serializable {
|
||||||
inverseJoinColumns = {
|
inverseJoinColumns = {
|
||||||
@JoinColumn(name = "ROLE_ID")
|
@JoinColumn(name = "ROLE_ID")
|
||||||
})
|
})
|
||||||
private List<Role> roles;
|
private List<Role> roles = new ArrayList<>();
|
||||||
|
|
||||||
@Column(name = "DEFAULT_LOCALE")
|
@Column(name = "DEFAULT_LOCALE")
|
||||||
private Locale defaultLocale;
|
private Locale defaultLocale;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "contentSection")
|
@OneToMany(mappedBy = "contentSection")
|
||||||
private List<ContentType> contentTypes;
|
private List<ContentType> contentTypes = new ArrayList<>();
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS",
|
name = "CONTENT_SECTION_LIFECYCLE_DEFINITIONS",
|
||||||
schema = DB_SCHEMA,
|
schema = DB_SCHEMA,
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "CONTENT_SECTION_ID")
|
@JoinColumn(name = "CONTENT_SECTION_ID")
|
||||||
},
|
},
|
||||||
inverseJoinColumns = {
|
inverseJoinColumns = {
|
||||||
@JoinColumn(name = "LIFECYCLE_DEFINITION_ID")
|
@JoinColumn(name = "LIFECYCLE_DEFINITION_ID")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
private List<LifecycleDefinition> lifecycleDefinitions;
|
private List<LifecycleDefinition> lifecycleDefinitions = new ArrayList<>();
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
name = "CONTENT_SECTION_WORKFLOW_TEMPLATES",
|
name = "CONTENT_SECTION_WORKFLOW_TEMPLATES",
|
||||||
schema = DB_SCHEMA,
|
schema = DB_SCHEMA,
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "CONTENT_SECTION_ID")
|
@JoinColumn(name = "CONTENT_SECTION_ID")
|
||||||
},
|
},
|
||||||
inverseJoinColumns = {
|
inverseJoinColumns = {
|
||||||
@JoinColumn(name = "WORKFLOW_TEMPLATE_ID")
|
@JoinColumn(name = "WORKFLOW_TEMPLATE_ID")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
private List<WorkflowTemplate> workflowTemplates;
|
private List<WorkflowTemplate> workflowTemplates = new ArrayList<>();
|
||||||
|
|
||||||
public ContentSection() {
|
public ContentSection() {
|
||||||
roles = new ArrayList<>();
|
roles = new ArrayList<>();
|
||||||
|
|
@ -301,7 +327,7 @@ public class ContentSection extends CcmApplication implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setLifecycleDefinitions(
|
protected void setLifecycleDefinitions(
|
||||||
final List<LifecycleDefinition> lifecycleDefinitions) {
|
final List<LifecycleDefinition> lifecycleDefinitions) {
|
||||||
this.lifecycleDefinitions = lifecycleDefinitions;
|
this.lifecycleDefinitions = lifecycleDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,7 +336,7 @@ public class ContentSection extends CcmApplication implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeLifecycleDefinition(
|
protected void removeLifecycleDefinition(
|
||||||
final LifecycleDefinition definition) {
|
final LifecycleDefinition definition) {
|
||||||
lifecycleDefinitions.remove(definition);
|
lifecycleDefinitions.remove(definition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -319,7 +345,7 @@ public class ContentSection extends CcmApplication implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setWorkflowTemplates(
|
protected void setWorkflowTemplates(
|
||||||
final List<WorkflowTemplate> workflowTemplates) {
|
final List<WorkflowTemplate> workflowTemplates) {
|
||||||
this.workflowTemplates = workflowTemplates;
|
this.workflowTemplates = workflowTemplates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -397,23 +423,23 @@ public class ContentSection extends CcmApplication implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
public String toString(final String data) {
|
public String toString(final String data) {
|
||||||
return super.toString(String.format(
|
return super.toString(String.format(
|
||||||
", label = \"%s\", "
|
", label = \"%s\", "
|
||||||
+ "rootDocumentsFolder = \"%s\", "
|
+ "rootDocumentsFolder = \"%s\", "
|
||||||
+ "rootAssetsFolder = \"%s\", "
|
+ "rootAssetsFolder = \"%s\", "
|
||||||
+ "pageResolverClass = \"%s\", "
|
+ "pageResolverClass = \"%s\", "
|
||||||
+ "itemResolverClass = \"%s\", "
|
+ "itemResolverClass = \"%s\", "
|
||||||
+ "templateResolverClass = \"%s\", "
|
+ "templateResolverClass = \"%s\", "
|
||||||
+ "xmlGeneratorClass = \"%s\", "
|
+ "xmlGeneratorClass = \"%s\", "
|
||||||
+ "defaultLocale = \"%s\"%s",
|
+ "defaultLocale = \"%s\"%s",
|
||||||
label,
|
label,
|
||||||
Objects.toString(rootDocumentsFolder),
|
Objects.toString(rootDocumentsFolder),
|
||||||
Objects.toString(rootAssetsFolder),
|
Objects.toString(rootAssetsFolder),
|
||||||
pageResolverClass,
|
pageResolverClass,
|
||||||
itemResolverClass,
|
itemResolverClass,
|
||||||
templateResolverClass,
|
templateResolverClass,
|
||||||
xmlGeneratorClass,
|
xmlGeneratorClass,
|
||||||
Objects.toString(defaultLocale),
|
Objects.toString(defaultLocale),
|
||||||
data));
|
data));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import org.librecms.contenttypes.News;
|
||||||
import org.librecms.dispatcher.MultilingualItemResolver;
|
import org.librecms.dispatcher.MultilingualItemResolver;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.logging.Level;
|
import org.librecms.contentsection.privileges.TypePrivileges;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -49,12 +49,12 @@ import java.util.logging.Level;
|
||||||
public class ContentSectionSetup extends AbstractCcmApplicationSetup {
|
public class ContentSectionSetup extends AbstractCcmApplicationSetup {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(
|
private static final Logger LOGGER = LogManager.getLogger(
|
||||||
ContentSectionSetup.class);
|
ContentSectionSetup.class);
|
||||||
|
|
||||||
private static final String INITIAL_CONTENT_SECTIONS
|
private static final String INITIAL_CONTENT_SECTIONS
|
||||||
= "org.librecms.initial_content_sections";
|
= "org.librecms.initial_content_sections";
|
||||||
private static final String DEFAULT_ITEM_RESOLVER
|
private static final String DEFAULT_ITEM_RESOLVER
|
||||||
= "org.librecms.default_item_resolver";
|
= "org.librecms.default_item_resolver";
|
||||||
private static final String[] DEFAULT_TYPES = new String[]{
|
private static final String[] DEFAULT_TYPES = new String[]{
|
||||||
Article.class.getName(),
|
Article.class.getName(),
|
||||||
Event.class.getName(),
|
Event.class.getName(),
|
||||||
|
|
@ -70,14 +70,14 @@ public class ContentSectionSetup extends AbstractCcmApplicationSetup {
|
||||||
final String sectionNames;
|
final String sectionNames;
|
||||||
if (getIntegrationProps().containsKey(INITIAL_CONTENT_SECTIONS)) {
|
if (getIntegrationProps().containsKey(INITIAL_CONTENT_SECTIONS)) {
|
||||||
sectionNames = getIntegrationProps().getProperty(
|
sectionNames = getIntegrationProps().getProperty(
|
||||||
INITIAL_CONTENT_SECTIONS);
|
INITIAL_CONTENT_SECTIONS);
|
||||||
LOGGER.info(
|
LOGGER.info(
|
||||||
"Found names for initial content sections in integration "
|
"Found names for initial content sections in integration "
|
||||||
+ "properties: {}", sectionNames);
|
+ "properties: {}", sectionNames);
|
||||||
} else {
|
} else {
|
||||||
sectionNames = "info";
|
sectionNames = "info";
|
||||||
LOGGER.info("No initial content sections definied integration "
|
LOGGER.info("No initial content sections definied integration "
|
||||||
+ "properties, using default: {}", sectionNames);
|
+ "properties, using default: {}", sectionNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final String contentSectionName : sectionNames.split(",")) {
|
for (final String contentSectionName : sectionNames.split(",")) {
|
||||||
|
|
@ -96,21 +96,21 @@ public class ContentSectionSetup extends AbstractCcmApplicationSetup {
|
||||||
section.setLabel(sectionName);
|
section.setLabel(sectionName);
|
||||||
|
|
||||||
if (getIntegrationProps().getProperty(DEFAULT_ITEM_RESOLVER) == null
|
if (getIntegrationProps().getProperty(DEFAULT_ITEM_RESOLVER) == null
|
||||||
|| getIntegrationProps().getProperty(DEFAULT_ITEM_RESOLVER)
|
|| getIntegrationProps().getProperty(DEFAULT_ITEM_RESOLVER)
|
||||||
.trim().isEmpty()) {
|
.trim().isEmpty()) {
|
||||||
section.setItemResolverClass(getIntegrationProps().getProperty(
|
section.setItemResolverClass(getIntegrationProps().getProperty(
|
||||||
DEFAULT_ITEM_RESOLVER));
|
DEFAULT_ITEM_RESOLVER));
|
||||||
} else {
|
} else {
|
||||||
section.setItemResolverClass(MultilingualItemResolver.class
|
section.setItemResolverClass(MultilingualItemResolver.class
|
||||||
.getName());
|
.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.debug("New content section properties: "
|
LOGGER.debug("New content section properties: "
|
||||||
+ "uuid = {}; "
|
+ "uuid = {}; "
|
||||||
+ "applicationType = \"{}\"; "
|
+ "applicationType = \"{}\"; "
|
||||||
+ "primaryUrl = \"{}\"; "
|
+ "primaryUrl = \"{}\"; "
|
||||||
+ "displayName = \"{}\"; "
|
+ "displayName = \"{}\"; "
|
||||||
+ "label = \"{}\"",
|
+ "label = \"{}\"",
|
||||||
section.getUuid(),
|
section.getUuid(),
|
||||||
section.getApplicationType(),
|
section.getApplicationType(),
|
||||||
section.getPrimaryUrl(),
|
section.getPrimaryUrl(),
|
||||||
|
|
@ -138,8 +138,12 @@ public class ContentSectionSetup extends AbstractCcmApplicationSetup {
|
||||||
getEntityManager().persist(rootFolder);
|
getEntityManager().persist(rootFolder);
|
||||||
getEntityManager().persist(rootAssetFolder);
|
getEntityManager().persist(rootAssetFolder);
|
||||||
|
|
||||||
|
LOGGER.debug(
|
||||||
|
"Creating default roles and permissions for content section "
|
||||||
|
+ "'{}'...",
|
||||||
|
sectionName);
|
||||||
final Role alertRecipient = createRole(String.format(
|
final Role alertRecipient = createRole(String.format(
|
||||||
"%s_" + ALERT_RECIPIENT, sectionName));
|
"%s_" + ALERT_RECIPIENT, sectionName));
|
||||||
final Role author = createRole(String.format("%s_" + AUTHOR,
|
final Role author = createRole(String.format("%s_" + AUTHOR,
|
||||||
sectionName));
|
sectionName));
|
||||||
final Role editor = createRole(String.format("%s_" + EDITOR,
|
final Role editor = createRole(String.format("%s_" + EDITOR,
|
||||||
|
|
@ -149,7 +153,7 @@ public class ContentSectionSetup extends AbstractCcmApplicationSetup {
|
||||||
final Role publisher = createRole(String.format("%s_" + PUBLISHER,
|
final Role publisher = createRole(String.format("%s_" + PUBLISHER,
|
||||||
sectionName));
|
sectionName));
|
||||||
final Role contentReader = createRole(String.format(
|
final Role contentReader = createRole(String.format(
|
||||||
"%s_" + CONTENT_READER, sectionName));
|
"%s_" + CONTENT_READER, sectionName));
|
||||||
|
|
||||||
grantPermissions(author,
|
grantPermissions(author,
|
||||||
rootFolder,
|
rootFolder,
|
||||||
|
|
@ -254,60 +258,103 @@ public class ContentSectionSetup extends AbstractCcmApplicationSetup {
|
||||||
section.addRole(publisher);
|
section.addRole(publisher);
|
||||||
section.addRole(contentReader);
|
section.addRole(contentReader);
|
||||||
|
|
||||||
|
LOGGER.debug("Setting ItemResolver for content section '{}'...",
|
||||||
|
sectionName);
|
||||||
final String itemResolverClassName;
|
final String itemResolverClassName;
|
||||||
if (getIntegrationProps().containsKey(String.format("%s.item_resolver",
|
if (getIntegrationProps().containsKey(String.format("%s.item_resolver",
|
||||||
sectionName))) {
|
sectionName))) {
|
||||||
|
|
||||||
itemResolverClassName = getIntegrationProps().getProperty(
|
itemResolverClassName = getIntegrationProps().getProperty(
|
||||||
String.format("%s.item_resolver",
|
String.format("%s.item_resolver",
|
||||||
sectionName));
|
sectionName));
|
||||||
|
LOGGER.debug("integration.properties contains setting for the item "
|
||||||
|
+ "resolver of content section '{}'. Using "
|
||||||
|
+ "item resolver '{}'.",
|
||||||
|
sectionName, itemResolverClassName);
|
||||||
} else if (getIntegrationProps().containsKey("default_item_resolver")) {
|
} else if (getIntegrationProps().containsKey("default_item_resolver")) {
|
||||||
itemResolverClassName = getIntegrationProps().getProperty(
|
itemResolverClassName = getIntegrationProps().getProperty(
|
||||||
"default_item_resolver_name");
|
"default_item_resolver_name");
|
||||||
|
LOGGER.debug("integration.properties contains setting for the "
|
||||||
|
+ "default item resolver. Using item "
|
||||||
|
+ "resolver '{}'.",
|
||||||
|
itemResolverClassName);
|
||||||
} else {
|
} else {
|
||||||
itemResolverClassName = MultilingualItemResolver.class.getName();
|
itemResolverClassName = MultilingualItemResolver.class.getName();
|
||||||
|
LOGGER.debug("integration.properties contains *no* setting for item "
|
||||||
|
+ "resolver. Using default item resolver '{}'.",
|
||||||
|
itemResolverClassName);
|
||||||
}
|
}
|
||||||
section.setItemResolverClass(itemResolverClassName);
|
section.setItemResolverClass(itemResolverClassName);
|
||||||
|
|
||||||
|
LOGGER.debug("Adding default content types to content section '{}'...",
|
||||||
|
sectionName);
|
||||||
final String[] types;
|
final String[] types;
|
||||||
if (getIntegrationProps().containsKey(String.format("%s.content_types",
|
if (getIntegrationProps().containsKey(String.format("%s.content_types",
|
||||||
sectionName))) {
|
sectionName))) {
|
||||||
final String typesStr = getIntegrationProps().getProperty(String
|
final String typesStr = getIntegrationProps().getProperty(String
|
||||||
.format("%s.content_types", sectionName));
|
.format("%s.content_types", sectionName));
|
||||||
|
LOGGER.debug("integration.properties contains setting for content "
|
||||||
|
+ "types of section '{}': {}",
|
||||||
|
sectionName,
|
||||||
|
typesStr);
|
||||||
types = typesStr.split(",");
|
types = typesStr.split(",");
|
||||||
} else if (getIntegrationProps().containsKey("default_content_types")) {
|
} else if (getIntegrationProps().containsKey("default_content_types")) {
|
||||||
final String typesStr = getIntegrationProps().getProperty(
|
final String typesStr = getIntegrationProps().getProperty(
|
||||||
"default_content_types");
|
"default_content_types");
|
||||||
|
LOGGER.debug("integration.properties contains setting for default "
|
||||||
|
+ "content types for all sections: {}",
|
||||||
|
typesStr);
|
||||||
types = typesStr.split(",");
|
types = typesStr.split(",");
|
||||||
} else {
|
} else {
|
||||||
|
LOGGER.debug("integration.properties contains not settings for "
|
||||||
|
+ "default content types. Using internal default: {}",
|
||||||
|
String.join(", ", DEFAULT_TYPES));
|
||||||
types = DEFAULT_TYPES;
|
types = DEFAULT_TYPES;
|
||||||
}
|
}
|
||||||
Arrays.stream(types).forEach(type -> addContentTypeToSection(section,
|
Arrays.stream(types).forEach(type -> addContentTypeToSection(section,
|
||||||
type));
|
type,
|
||||||
|
author,
|
||||||
|
editor,
|
||||||
|
manager));
|
||||||
|
|
||||||
getEntityManager().merge(section);
|
getEntityManager().merge(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addContentTypeToSection(final ContentSection section,
|
private void addContentTypeToSection(final ContentSection section,
|
||||||
final String contentType) {
|
final String contentType,
|
||||||
|
final Role... roles) {
|
||||||
final String typeClassName = contentType.trim();
|
final String typeClassName = contentType.trim();
|
||||||
|
LOGGER.debug("Adding content type '{}' to content section '{}'...",
|
||||||
|
contentType,
|
||||||
|
section.getPrimaryUrl());
|
||||||
final Class<?> clazz;
|
final Class<?> clazz;
|
||||||
try {
|
try {
|
||||||
clazz = Class.forName(typeClassName);
|
clazz = Class.forName(typeClassName);
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
throw new UnexpectedErrorException(String.format(
|
throw new UnexpectedErrorException(String.format(
|
||||||
"No class for content type '%s'.", typeClassName));
|
"No class for content type '%s'.", typeClassName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContentItem.class.isAssignableFrom(clazz)) {
|
if (ContentItem.class.isAssignableFrom(clazz)) {
|
||||||
|
LOGGER.warn("'{}' is not is assignable from '{}'!",
|
||||||
|
ContentItem.class.getName(),
|
||||||
|
clazz.getName());
|
||||||
final ContentType type = new ContentType();
|
final ContentType type = new ContentType();
|
||||||
type.setContentSection(section);
|
type.setContentSection(section);
|
||||||
|
type.setUuid(UUID.randomUUID().toString());
|
||||||
type.setContentItemClass(clazz.getName());
|
type.setContentItemClass(clazz.getName());
|
||||||
|
getEntityManager().persist(type);
|
||||||
section.addContentType(type);
|
section.addContentType(type);
|
||||||
|
|
||||||
|
Arrays.stream(roles)
|
||||||
|
.forEach(role -> grantPermission(role,
|
||||||
|
TypePrivileges.USE_TYPE,
|
||||||
|
type));
|
||||||
} else {
|
} else {
|
||||||
throw new UnexpectedErrorException(String.format(
|
throw new UnexpectedErrorException(String.format(
|
||||||
"The class '%s' is not a sub class of '%s'.",
|
"The class '%s' is not a sub class of '%s'.",
|
||||||
clazz.getName(),
|
clazz.getName(),
|
||||||
ContentItem.class.getName()));
|
ContentItem.class.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -62,7 +63,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class AttachmentListManagerTest {
|
public class AttachmentListManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -61,7 +62,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ContentItemL10NManagerTest {
|
public class ContentItemL10NManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
@ -98,66 +100,67 @@ public class ContentItemL10NManagerTest {
|
||||||
@Deployment
|
@Deployment
|
||||||
public static WebArchive createDeployment() {
|
public static WebArchive createDeployment() {
|
||||||
return ShrinkWrap
|
return ShrinkWrap
|
||||||
.create(WebArchive.class,
|
.create(WebArchive.class,
|
||||||
"LibreCCM-org.librecms.contentsection.ContentItemManagerTest.war")
|
"LibreCCM-org.librecms.contentsection.ContentItemManagerTest.war").
|
||||||
.addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
||||||
.addPackage(org.libreccm.categorization.Categorization.class
|
.addPackage(org.libreccm.categorization.Categorization.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||||
.addPackage(org.libreccm.configuration.Configuration.class
|
.addPackage(org.libreccm.configuration.Configuration.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
.addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class
|
.addPackage(org.libreccm.l10n.LocalizedString.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addClass(org.libreccm.portation.Portable.class)
|
.addClass(org.libreccm.portation.Portable.class)
|
||||||
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
.addPackage(com.arsdigita.bebop.Component.class.getPackage())
|
.addPackage(com.arsdigita.bebop.Component.class.getPackage())
|
||||||
.addPackage(com.arsdigita.bebop.util.BebopConstants.class
|
.addPackage(com.arsdigita.bebop.util.BebopConstants.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addClass(com.arsdigita.kernel.KernelConfig.class)
|
.addClass(com.arsdigita.kernel.KernelConfig.class)
|
||||||
.addClass(com.arsdigita.runtime.CCMResourceManager.class)
|
.addClass(com.arsdigita.runtime.CCMResourceManager.class)
|
||||||
.addClass(com.arsdigita.dispatcher.RequestContext.class)
|
.addClass(com.arsdigita.dispatcher.RequestContext.class)
|
||||||
.addClass(com.arsdigita.dispatcher.AccessDeniedException.class)
|
.addClass(com.arsdigita.dispatcher.AccessDeniedException.class)
|
||||||
.addClass(com.arsdigita.cms.dispatcher.ContentItemDispatcher.class)
|
.addClass(
|
||||||
.addClass(com.arsdigita.dispatcher.Dispatcher.class)
|
com.arsdigita.cms.dispatcher.ContentItemDispatcher.class).
|
||||||
.addClass(
|
addClass(com.arsdigita.dispatcher.Dispatcher.class)
|
||||||
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class)
|
.addClass(
|
||||||
.addClass(
|
com.arsdigita.ui.admin.applications.AbstractAppInstanceForm.class).
|
||||||
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class)
|
addClass(
|
||||||
.addClass(
|
com.arsdigita.ui.admin.applications.AbstractAppSettingsPane.class).
|
||||||
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class)
|
addClass(
|
||||||
.addClass(
|
com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm.class).
|
||||||
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class)
|
addClass(
|
||||||
.addClass(org.librecms.dispatcher.ItemResolver.class)
|
com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane.class).
|
||||||
.addPackage(com.arsdigita.util.Lockable.class.getPackage())
|
addClass(org.librecms.dispatcher.ItemResolver.class)
|
||||||
.addPackage(com.arsdigita.web.BaseServlet.class.getPackage())
|
.addPackage(com.arsdigita.util.Lockable.class.getPackage())
|
||||||
.addPackage(org.librecms.Cms.class.getPackage())
|
.addPackage(com.arsdigita.web.BaseServlet.class.getPackage())
|
||||||
.addPackage(org.librecms.contentsection.Asset.class.getPackage())
|
.addPackage(org.librecms.Cms.class.getPackage())
|
||||||
.addPackage(org.librecms.contentsection.AttachmentList.class
|
.addPackage(org.librecms.contentsection.Asset.class.getPackage()).
|
||||||
.getPackage())
|
addPackage(org.librecms.contentsection.AttachmentList.class
|
||||||
.addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.librecms.contentsection.ContentSection.class
|
.addPackage(org.librecms.lifecycle.Lifecycle.class.getPackage())
|
||||||
.getPackage())
|
.addPackage(org.librecms.contentsection.ContentSection.class
|
||||||
.addPackage(org.librecms.contenttypes.Article.class.getPackage())
|
.getPackage())
|
||||||
.addClass(com.arsdigita.kernel.security.SecurityConfig.class)
|
.addPackage(org.librecms.contenttypes.Article.class.getPackage()).
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
addClass(com.arsdigita.kernel.security.SecurityConfig.class)
|
||||||
.getPackage())
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
// .addAsLibraries(getModuleDependencies())
|
.getPackage())
|
||||||
.addAsLibraries(getCcmCoreDependencies())
|
// .addAsLibraries(getModuleDependencies())
|
||||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
.addAsLibraries(getCcmCoreDependencies())
|
||||||
.addAsResource(
|
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||||
"configs/org/librecms/contentsection/ContentItemManagerTest/log4j2.xml",
|
.addAsResource(
|
||||||
"log4j2.xml")
|
"configs/org/librecms/contentsection/ContentItemManagerTest/log4j2.xml",
|
||||||
.addAsResource("test-persistence.xml",
|
"log4j2.xml")
|
||||||
"META-INF/persistence.xml")
|
.addAsResource("test-persistence.xml",
|
||||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
"META-INF/persistence.xml")
|
||||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||||
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -176,7 +179,7 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(10)
|
@InSequence(10)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
public void verifyHasLanguage() {
|
public void verifyHasLanguage() {
|
||||||
shiro.getSystemUser().execute(() -> {
|
shiro.getSystemUser().execute(() -> {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
|
|
@ -201,7 +204,7 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@InSequence(20)
|
@InSequence(20)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
public void hasLanguageItemIsNull() {
|
public void hasLanguageItemIsNull() {
|
||||||
final ContentItem item = null;
|
final ContentItem item = null;
|
||||||
|
|
@ -218,7 +221,7 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@InSequence(30)
|
@InSequence(30)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
public void hasLanguageLanguageIsNull() {
|
public void hasLanguageLanguageIsNull() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
|
|
@ -236,11 +239,11 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(40)
|
@InSequence(40)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/after-add-language.xml",
|
+ "ContentItemL10NManagerTest/after-add-language.xml",
|
||||||
excludeColumns = {"timestamp"})
|
excludeColumns = {"timestamp"})
|
||||||
public void addLanguage() {
|
public void addLanguage() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
assertThat(item.isPresent(), is(true));
|
assertThat(item.isPresent(), is(true));
|
||||||
|
|
@ -256,10 +259,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(50)
|
@InSequence(50)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
public void addLanguageAlreadyPresent() {
|
public void addLanguageAlreadyPresent() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
assertThat(item.isPresent(), is(true));
|
assertThat(item.isPresent(), is(true));
|
||||||
|
|
@ -276,10 +279,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@InSequence(60)
|
@InSequence(60)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
public void addLanguageItemIsNull() {
|
public void addLanguageItemIsNull() {
|
||||||
final ContentItem item = null;
|
final ContentItem item = null;
|
||||||
|
|
@ -295,10 +298,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@InSequence(20)
|
@InSequence(20)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
public void addLanguageLanguageIsNull() {
|
public void addLanguageLanguageIsNull() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
|
|
@ -314,11 +317,11 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(70)
|
@InSequence(70)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/after-remove-language.xml",
|
+ "ContentItemL10NManagerTest/after-remove-language.xml",
|
||||||
excludeColumns = {"timestamp"})
|
excludeColumns = {"timestamp"})
|
||||||
public void removeLanguage() {
|
public void removeLanguage() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
assertThat(item.isPresent(), is(true));
|
assertThat(item.isPresent(), is(true));
|
||||||
|
|
@ -334,10 +337,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(80)
|
@InSequence(80)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
public void removeNotPresentLanguage() {
|
public void removeNotPresentLanguage() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
assertThat(item.isPresent(), is(true));
|
assertThat(item.isPresent(), is(true));
|
||||||
|
|
@ -354,10 +357,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@InSequence(90)
|
@InSequence(90)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
public void removeLanguageItemIsNull() {
|
public void removeLanguageItemIsNull() {
|
||||||
final ContentItem item = null;
|
final ContentItem item = null;
|
||||||
|
|
@ -374,10 +377,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@InSequence(100)
|
@InSequence(100)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
public void removeLanguageLanguageIsNull() {
|
public void removeLanguageLanguageIsNull() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
|
|
@ -394,11 +397,11 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(120)
|
@InSequence(120)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/after-normalize.xml",
|
+ "ContentItemL10NManagerTest/after-normalize.xml",
|
||||||
excludeColumns = {"timestamp"})
|
excludeColumns = {"timestamp"})
|
||||||
public void normalizeItem() {
|
public void normalizeItem() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10200L);
|
final Optional<ContentItem> item = itemRepo.findById(-10200L);
|
||||||
assertThat(item.isPresent(), is(true));
|
assertThat(item.isPresent(), is(true));
|
||||||
|
|
@ -414,10 +417,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(130)
|
@InSequence(130)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
public void normalizeItemAlreadyNormalized() {
|
public void normalizeItemAlreadyNormalized() {
|
||||||
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
final Optional<ContentItem> item = itemRepo.findById(-10100L);
|
||||||
assertThat(item.isPresent(), is(true));
|
assertThat(item.isPresent(), is(true));
|
||||||
|
|
@ -435,10 +438,10 @@ public class ContentItemL10NManagerTest {
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@InSequence(140)
|
@InSequence(140)
|
||||||
@UsingDataSet("datasets/org/librecms/contentsection/"
|
@UsingDataSet("datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/librecms/contentsection/"
|
value = "datasets/org/librecms/contentsection/"
|
||||||
+ "ContentItemL10NManagerTest/data.xml")
|
+ "ContentItemL10NManagerTest/data.xml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
public void normalizeItemNull() {
|
public void normalizeItemNull() {
|
||||||
final ContentItem item = null;
|
final ContentItem item = null;
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -69,7 +70,8 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ContentItemManagerTest {
|
public class ContentItemManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
import org.libreccm.security.User;
|
import org.libreccm.security.User;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -68,7 +69,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ContentItemPermissionTest {
|
public class ContentItemPermissionTest {
|
||||||
|
|
||||||
private static final String QUERY = "SELECT i FROM ContentItem i "
|
private static final String QUERY = "SELECT i FROM ContentItem i "
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
import org.jboss.arquillian.persistence.CreateSchema;
|
import org.jboss.arquillian.persistence.CreateSchema;
|
||||||
import org.jboss.arquillian.persistence.PersistenceTest;
|
import org.jboss.arquillian.persistence.PersistenceTest;
|
||||||
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
import org.jboss.arquillian.persistence.UsingDataSet;
|
import org.jboss.arquillian.persistence.UsingDataSet;
|
||||||
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
|
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
|
||||||
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
||||||
|
|
@ -60,7 +61,8 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ContentItemRepositoryTest {
|
public class ContentItemRepositoryTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.container.test.api.ShouldThrowException;
|
import org.jboss.arquillian.container.test.api.ShouldThrowException;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
import org.libreccm.workflow.WorkflowTemplate;
|
import org.libreccm.workflow.WorkflowTemplate;
|
||||||
import org.libreccm.workflow.WorkflowTemplateRepository;
|
import org.libreccm.workflow.WorkflowTemplateRepository;
|
||||||
import org.librecms.contentsection.privileges.ItemPrivileges;
|
import org.librecms.contentsection.privileges.ItemPrivileges;
|
||||||
|
|
@ -75,7 +76,8 @@ import org.librecms.lifecycle.LifecycleDefinitionRepository;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ContentSectionManagerTest {
|
public class ContentSectionManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -63,7 +64,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ContentTypeRepositoryTest {
|
public class ContentTypeRepositoryTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ import javax.inject.Inject;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -60,7 +61,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class FolderManagerTest {
|
public class FolderManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ import javax.activation.MimeTypeParseException;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -60,7 +61,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
//@Transactional(TransactionMode.COMMIT)
|
//@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_cms_schema.sql"})
|
@CreateSchema({"create_ccm_cms_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ItemAttachmentManagerTest {
|
public class ItemAttachmentManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,11 @@ public final class CoreConstants {
|
||||||
* Constant for the {@code system} privilege.
|
* Constant for the {@code system} privilege.
|
||||||
*/
|
*/
|
||||||
public static final String PRIVILEGE_SYSTEM = "system";
|
public static final String PRIVILEGE_SYSTEM = "system";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the system administrator role.
|
||||||
|
*/
|
||||||
|
public static final String SYS_ADMIN_ROLE = "system-administrator";
|
||||||
|
|
||||||
private CoreConstants() {
|
private CoreConstants() {
|
||||||
//Nothing
|
//Nothing
|
||||||
|
|
|
||||||
|
|
@ -70,47 +70,61 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
|
||||||
@NamedQueries({
|
@NamedQueries({
|
||||||
@NamedQuery(name = "Role.findByName",
|
@NamedQuery(name = "Role.findByName",
|
||||||
query = "SELECT r FROM Role r "
|
query = "SELECT r FROM Role r "
|
||||||
+ "WHERE r.name = :name"),
|
+ "WHERE r.name = :name")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.count",
|
name = "Role.count",
|
||||||
query = "SELECT COUNT(r) FROM Role r"),
|
query = "SELECT COUNT(r) FROM Role r")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.findAllOrderedByRoleName",
|
name = "Role.findAllOrderedByRoleName",
|
||||||
query = "SELECT r FROM Role r ORDER BY r.name"),
|
query = "SELECT r FROM Role r ORDER BY r.name")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.findAllOrderedByRoleNameLimit",
|
name = "Role.findAllOrderedByRoleNameLimit",
|
||||||
query = "SELECT r FROM Role r ORDER BY r.name "),
|
query = "SELECT r FROM Role r ORDER BY r.name ")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.findAllOrderedByRoleNameDesc",
|
name = "Role.findAllOrderedByRoleNameDesc",
|
||||||
query = "SELECT r FROM Role r ORDER BY r.name DESC"),
|
query = "SELECT r FROM Role r ORDER BY r.name DESC")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.searchByName",
|
name = "Role.searchByName",
|
||||||
query = "SELECT r FROM Role r "
|
query = "SELECT r FROM Role r "
|
||||||
+ "WHERE LOWER(r.name) LIKE CONCAT(LOWER(:name), '%') "
|
+ "WHERE LOWER(r.name) LIKE CONCAT(LOWER(:name), '%') "
|
||||||
+ "ORDER BY r.name "),
|
+ "ORDER BY r.name ")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.searchByNameCount",
|
name = "Role.searchByNameCount",
|
||||||
query = "SELECT COUNT(r.name) FROM Role r "
|
query = "SELECT COUNT(r.name) FROM Role r "
|
||||||
+ "WHERE LOWER(r.name) LIKE CONCAT(LOWER(:name), '%') "
|
+ "WHERE LOWER(r.name) LIKE CONCAT(LOWER(:name), '%') "
|
||||||
+ "GROUP BY r.name "
|
+ "GROUP BY r.name "
|
||||||
+ "ORDER BY r.name "),
|
+ "ORDER BY r.name ")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.findByPrivilege",
|
name = "Role.findByPrivilege",
|
||||||
query = "SELECT r FROM Role r JOIN r.permissions p "
|
query = "SELECT r FROM Role r JOIN r.permissions p "
|
||||||
+ "WHERE p.grantedPrivilege = :privilege "
|
+ "WHERE p.grantedPrivilege = :privilege "
|
||||||
+ "ORDER BY r.name"),
|
+ "ORDER BY r.name")
|
||||||
|
,
|
||||||
@NamedQuery(
|
@NamedQuery(
|
||||||
name = "Role.findByPrivilegeAndObject",
|
name = "Role.findByPrivilegeAndObject",
|
||||||
query = "SELECT r FROM Role r JOIN r.permissions p "
|
query = "SELECT r FROM Role r JOIN r.permissions p "
|
||||||
+ "WHERE p.grantedPrivilege = :privilege "
|
+ "WHERE p.grantedPrivilege = :privilege "
|
||||||
+ "AND p.object = :object "
|
+ "AND p.object = :object "
|
||||||
+ "ORDER BY r.name")
|
+ "ORDER BY r.name")
|
||||||
|
,
|
||||||
|
@NamedQuery(
|
||||||
|
name = "Role.findRolesOfUser",
|
||||||
|
query = "SELECT r.role FROM RoleMembership r "
|
||||||
|
+ "WHERE r.member = :user")
|
||||||
})
|
})
|
||||||
@NamedEntityGraphs({
|
@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = Role.ENTITY_GRPAH_WITH_MEMBERS,
|
name = Role.ENTITY_GRPAH_WITH_MEMBERS,
|
||||||
attributeNodes = {
|
attributeNodes = {
|
||||||
@NamedAttributeNode(value = "memberships"),}),
|
@NamedAttributeNode(value = "memberships"),})
|
||||||
|
,
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = Role.ENTITY_GRPAH_WITH_PERMISSIONS,
|
name = Role.ENTITY_GRPAH_WITH_PERMISSIONS,
|
||||||
attributeNodes = {
|
attributeNodes = {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public class SystemUsersSetup {
|
||||||
admin.setPassword(adminPassword);
|
admin.setPassword(adminPassword);
|
||||||
|
|
||||||
final Role adminRole = new Role();
|
final Role adminRole = new Role();
|
||||||
adminRole.setName("system-administrator");
|
adminRole.setName(CoreConstants.SYS_ADMIN_ROLE);
|
||||||
|
|
||||||
final RoleMembership membership = new RoleMembership();
|
final RoleMembership membership = new RoleMembership();
|
||||||
membership.setRole(adminRole);
|
membership.setRole(adminRole);
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link CategoryManager}.
|
* Tests for the {@link CategoryManager}.
|
||||||
|
|
@ -70,7 +71,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class CategoryManagerTest {
|
public class CategoryManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -65,7 +66,8 @@ import java.util.Optional;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class CategoryRepositoryTest {
|
public class CategoryRepositoryTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link ConfigurationManager}.
|
* Tests for the {@link ConfigurationManager}.
|
||||||
|
|
@ -62,7 +63,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ConfigurationManagerTest {
|
public class ConfigurationManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link CcmObjectRepository} which is the foundation for many
|
* Tests for the {@link CcmObjectRepository} which is the foundation for many
|
||||||
|
|
@ -67,7 +68,8 @@ import java.util.Optional;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class CcmObjectRepositoryTest {
|
public class CcmObjectRepositoryTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
@ -98,32 +100,33 @@ public class CcmObjectRepositoryTest {
|
||||||
@Deployment
|
@Deployment
|
||||||
public static WebArchive createDeployment() {
|
public static WebArchive createDeployment() {
|
||||||
return ShrinkWrap
|
return ShrinkWrap
|
||||||
.create(WebArchive.class,
|
.create(WebArchive.class,
|
||||||
"LibreCCM-org.libreccm.core.CcmObjectRepositoryTest.war")
|
"LibreCCM-org.libreccm.core.CcmObjectRepositoryTest.war").
|
||||||
.addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
addPackage(org.libreccm.auditing.CcmRevision.class.getPackage())
|
||||||
.addPackage(org.libreccm.categorization.Categorization.class
|
.addPackage(org.libreccm.categorization.Categorization.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.configuration.Configuration.class.
|
.addPackage(org.libreccm.configuration.Configuration.class.
|
||||||
getPackage())
|
getPackage())
|
||||||
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
||||||
.addPackage(org.libreccm.security.PermissionChecker.class
|
addPackage(org.libreccm.security.PermissionChecker.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.getPackage())
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
getPackage())
|
||||||
.getPackage())
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||||
.addClass(org.libreccm.portation.Portable.class)
|
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
.addAsLibraries(getModuleDependencies())
|
.addClass(org.libreccm.portation.Portable.class)
|
||||||
.addAsResource("test-persistence.xml",
|
.addAsLibraries(getModuleDependencies())
|
||||||
"META-INF/persistence.xml")
|
.addAsResource("test-persistence.xml",
|
||||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
"META-INF/persistence.xml")
|
||||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||||
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -160,7 +163,7 @@ public class CcmObjectRepositoryTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||||
+ "after-save-changed.yml")
|
+ "after-save-changed.yml")
|
||||||
@InSequence(4)
|
@InSequence(4)
|
||||||
public void datasetOnly2() {
|
public void datasetOnly2() {
|
||||||
System.out.println("Dataset loaded successfully.");
|
System.out.println("Dataset loaded successfully.");
|
||||||
|
|
@ -274,9 +277,9 @@ public class CcmObjectRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||||
+ "after-save-new.yml",
|
+ "after-save-new.yml",
|
||||||
excludeColumns = {"object_id", "uuid"})
|
excludeColumns = {"object_id", "uuid"})
|
||||||
@InSequence(300)
|
@InSequence(300)
|
||||||
public void saveNewCcmObject() {
|
public void saveNewCcmObject() {
|
||||||
final CcmObject obj = new CcmObject();
|
final CcmObject obj = new CcmObject();
|
||||||
|
|
@ -294,9 +297,9 @@ public class CcmObjectRepositoryTest {
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||||
+ "after-save-changed.yml",
|
+ "after-save-changed.yml",
|
||||||
excludeColumns = {"object_id"})
|
excludeColumns = {"object_id"})
|
||||||
@InSequence(400)
|
@InSequence(400)
|
||||||
public void saveChangedCcmObject() {
|
public void saveChangedCcmObject() {
|
||||||
final CcmObject obj = ccmObjectRepository.findById(-20L).get();
|
final CcmObject obj = ccmObjectRepository.findById(-20L).get();
|
||||||
|
|
@ -318,16 +321,16 @@ public class CcmObjectRepositoryTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes one of the {@link CcmObject}s in the database by using
|
* Deletes one of the {@link CcmObject}s in the database by using
|
||||||
* {@link CcmObjectRepository#delete(java.lang.Object)} and verifies that
|
* {@link CcmObjectRepository#delete(java.lang.Object)} and verifies that
|
||||||
* the object has been removed from the test database.
|
* the object has been removed from the test database.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
@UsingDataSet("datasets/org/libreccm/core/CcmObjectRepositoryTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
value = "datasets/org/libreccm/core/CcmObjectRepositoryTest/"
|
||||||
+ "after-delete.yml",
|
+ "after-delete.yml",
|
||||||
excludeColumns = {"object_id"})
|
excludeColumns = {"object_id"})
|
||||||
@InSequence(600)
|
@InSequence(600)
|
||||||
public void deleteCcmObject() {
|
public void deleteCcmObject() {
|
||||||
final CcmObject obj = ccmObjectRepository.findById(-20L).get();
|
final CcmObject obj = ccmObjectRepository.findById(-20L).get();
|
||||||
|
|
@ -337,7 +340,7 @@ public class CcmObjectRepositoryTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that {@link CcmObjectRepository#delete(java.lang.Object)} throws
|
* Verifies that {@link CcmObjectRepository#delete(java.lang.Object)} throws
|
||||||
* a {@link IllegalArgumentException} if called with {@link null} for the
|
* a {@link IllegalArgumentException} if called with {@link null} for the
|
||||||
* object to delete.
|
* object to delete.
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import javax.persistence.EntityManager;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,7 +56,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ConfigurationLoaderTest {
|
public class ConfigurationLoaderTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import org.libreccm.tests.categories.IntegrationTest;
|
||||||
|
|
||||||
import javax.faces.bean.RequestScoped;
|
import javax.faces.bean.RequestScoped;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies;
|
import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies;
|
||||||
|
|
||||||
|
|
@ -57,8 +58,8 @@ import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
@RequestScoped
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class CoreDataImportTest {
|
public class CoreDataImportTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -62,7 +63,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class AuthorizationInterceptorTest {
|
public class AuthorizationInterceptorTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -61,7 +62,8 @@ import java.util.Optional;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema("create_ccm_core_schema.sql")
|
@CreateSchema("create_ccm_core_schema.sql")
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ChallengeManagerTest {
|
public class ChallengeManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -59,7 +60,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class GroupManagerTest {
|
public class GroupManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import org.junit.runner.RunWith;
|
||||||
import org.libreccm.tests.categories.IntegrationTest;
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -65,7 +66,8 @@ import java.util.Optional;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema("create_ccm_core_schema.sql")
|
@CreateSchema("create_ccm_core_schema.sql")
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class GroupRepositoryTest {
|
public class GroupRepositoryTest {
|
||||||
|
|
||||||
private static final String ADMINS = "admins";
|
private static final String ADMINS = "admins";
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -66,7 +67,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema("create_ccm_core_schema.sql")
|
@CreateSchema("create_ccm_core_schema.sql")
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class OneTimeAuthManagerTest {
|
public class OneTimeAuthManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ import static org.junit.Assert.assertThat;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -63,7 +64,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class PartyRepositoryTest {
|
public class PartyRepositoryTest {
|
||||||
|
|
||||||
private static final String MMUSTER = "mmuster";
|
private static final String MMUSTER = "mmuster";
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -69,7 +70,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class PermissionCheckerTest {
|
public class PermissionCheckerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import org.libreccm.categorization.CategorizationConstants;
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.core.CoreConstants;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests (run in a Application Server by Arquillian} for the
|
* Integration tests (run in a Application Server by Arquillian} for the
|
||||||
|
|
@ -67,7 +68,8 @@ import java.util.List;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript(value = {"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class PermissionManagerTest {
|
public class PermissionManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
@ -107,36 +109,36 @@ public class PermissionManagerTest {
|
||||||
@Deployment
|
@Deployment
|
||||||
public static WebArchive createDeployment() {
|
public static WebArchive createDeployment() {
|
||||||
return ShrinkWrap
|
return ShrinkWrap
|
||||||
.create(WebArchive.class,
|
.create(WebArchive.class,
|
||||||
"LibreCCM-org.libreccm.security.PermissionManagerTest.war").
|
"LibreCCM-org.libreccm.security.PermissionManagerTest.war").
|
||||||
addPackage(org.libreccm.categorization.Categorization.class
|
addPackage(org.libreccm.categorization.Categorization.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.configuration.Configuration.class
|
.addPackage(org.libreccm.configuration.Configuration.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
||||||
addPackage(org.libreccm.security.User.class.getPackage())
|
addPackage(org.libreccm.security.User.class.getPackage())
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()).
|
.addPackage(com.arsdigita.kernel.KernelConfig.class.getPackage()).
|
||||||
addPackage(com.arsdigita.kernel.security.SecurityConfig.class
|
addPackage(com.arsdigita.kernel.security.SecurityConfig.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||||
.addClass(org.libreccm.portation.Portable.class)
|
.addClass(org.libreccm.portation.Portable.class)
|
||||||
.addAsLibraries(getModuleDependencies())
|
.addAsLibraries(getModuleDependencies())
|
||||||
.addAsResource("test-persistence.xml",
|
.addAsResource("test-persistence.xml",
|
||||||
"META-INF/persistence.xml")
|
"META-INF/persistence.xml")
|
||||||
.addAsResource("configs/shiro.ini", "shiro.ini")
|
.addAsResource("configs/shiro.ini", "shiro.ini")
|
||||||
.addAsWebInfResource("test-web.xml", "web.xml")
|
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||||
.addAsWebInfResource("META-INF/beans.xml", "beans.xml");
|
.addAsWebInfResource("META-INF/beans.xml", "beans.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -175,11 +177,11 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "after-grant.yml",
|
+ "after-grant.yml",
|
||||||
excludeColumns = {"permission_id"})
|
excludeColumns = {"permission_id"})
|
||||||
@InSequence(200)
|
@InSequence(200)
|
||||||
public void grantPermission() {
|
public void grantPermission() {
|
||||||
final Role role2 = roleRepository.findByName("role2").get();
|
final Role role2 = roleRepository.findByName("role2").get();
|
||||||
|
|
@ -200,10 +202,10 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "data.yml")
|
+ "data.yml")
|
||||||
@InSequence(210)
|
@InSequence(210)
|
||||||
public void grantPermissionAgain() {
|
public void grantPermissionAgain() {
|
||||||
final Role role1 = roleRepository.findByName("role1").get();
|
final Role role1 = roleRepository.findByName("role1").get();
|
||||||
|
|
@ -222,11 +224,11 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
|
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "data-recursivly.yml")
|
+ "data-recursivly.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "after-grant-recursivly.yml",
|
+ "after-grant-recursivly.yml",
|
||||||
excludeColumns = {"permission_id"})
|
excludeColumns = {"permission_id"})
|
||||||
@InSequence(211)
|
@InSequence(211)
|
||||||
public void grantPermissionRecursively() {
|
public void grantPermissionRecursively() {
|
||||||
final Role role1 = roleRepository.findByName("role1").get();
|
final Role role1 = roleRepository.findByName("role1").get();
|
||||||
|
|
@ -247,7 +249,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(220)
|
@InSequence(220)
|
||||||
public void grantPermissionPrivilegeNull() throws Throwable {
|
public void grantPermissionPrivilegeNull() throws Throwable {
|
||||||
|
|
@ -255,7 +257,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.grantPrivilege(null, role1));
|
() -> permissionManager.grantPrivilege(null, role1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +273,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(225)
|
@InSequence(225)
|
||||||
public void grantPermissionOnObjectPrivilegeNull() throws Throwable {
|
public void grantPermissionOnObjectPrivilegeNull() throws Throwable {
|
||||||
|
|
@ -280,7 +282,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.grantPrivilege(null, role1, object1));
|
() -> permissionManager.grantPrivilege(null, role1, object1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +298,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(230)
|
@InSequence(230)
|
||||||
public void grantPermissionEmptyPrivilege() throws Throwable {
|
public void grantPermissionEmptyPrivilege() throws Throwable {
|
||||||
|
|
@ -304,7 +306,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.grantPrivilege("", role1));
|
() -> permissionManager.grantPrivilege("", role1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -320,7 +322,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(235)
|
@InSequence(235)
|
||||||
public void grantPermissionOnObjectEmptyPrivilege() throws Throwable {
|
public void grantPermissionOnObjectEmptyPrivilege() throws Throwable {
|
||||||
|
|
@ -329,7 +331,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.grantPrivilege("", role1, object1));
|
() -> permissionManager.grantPrivilege("", role1, object1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -345,13 +347,13 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(240)
|
@InSequence(240)
|
||||||
public void grantPermissionToRoleNull() throws Throwable {
|
public void grantPermissionToRoleNull() throws Throwable {
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.grantPrivilege("privilege", null));
|
() -> permissionManager.grantPrivilege("privilege", null));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -367,7 +369,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(240)
|
@InSequence(240)
|
||||||
public void grantPermissionOnObjectToRoleNull() throws Throwable {
|
public void grantPermissionOnObjectToRoleNull() throws Throwable {
|
||||||
|
|
@ -375,9 +377,9 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.grantPrivilege("privilege",
|
() -> permissionManager.grantPrivilege("privilege",
|
||||||
null,
|
null,
|
||||||
object1));
|
object1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -393,7 +395,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(250)
|
@InSequence(250)
|
||||||
public void grantPermissionNullObject() throws Throwable {
|
public void grantPermissionNullObject() throws Throwable {
|
||||||
|
|
@ -401,9 +403,9 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.grantPrivilege("privilege1",
|
() -> permissionManager.grantPrivilege("privilege1",
|
||||||
role1,
|
role1,
|
||||||
null));
|
null));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -418,11 +420,11 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "after-revoke.yml",
|
+ "after-revoke.yml",
|
||||||
excludeColumns = {"permission_id"})
|
excludeColumns = {"permission_id"})
|
||||||
@InSequence(300)
|
@InSequence(300)
|
||||||
public void revokePermission() {
|
public void revokePermission() {
|
||||||
final Role role1 = roleRepository.findByName("role1").get();
|
final Role role1 = roleRepository.findByName("role1").get();
|
||||||
|
|
@ -444,16 +446,16 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "data.yml")
|
+ "data.yml")
|
||||||
@InSequence(310)
|
@InSequence(310)
|
||||||
public void revokeNotExistingPermission() throws Throwable {
|
public void revokeNotExistingPermission() throws Throwable {
|
||||||
final Role role1 = roleRepository.findByName("role1").get();
|
final Role role1 = roleRepository.findByName("role1").get();
|
||||||
|
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege("privilege999", role1));
|
() -> permissionManager.revokePrivilege("privilege999", role1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -462,10 +464,10 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
|
@UsingDataSet("datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "after-grant-recursivly.yml")
|
+ "after-grant-recursivly.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "after-revoke-recursivly.yml")
|
+ "after-revoke-recursivly.yml")
|
||||||
@InSequence(311)
|
@InSequence(311)
|
||||||
public void revokePermissionRecursivly() {
|
public void revokePermissionRecursivly() {
|
||||||
final Role role1 = roleRepository.findByName("role1").get();
|
final Role role1 = roleRepository.findByName("role1").get();
|
||||||
|
|
@ -485,19 +487,19 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "data.yml")
|
+ "data.yml")
|
||||||
@InSequence(310)
|
@InSequence(310)
|
||||||
public void revokeNotExistingPermissionOnObject() {
|
public void revokeNotExistingPermissionOnObject() {
|
||||||
final Role role1 = roleRepository.findByName("role1").get();
|
final Role role1 = roleRepository.findByName("role1").get();
|
||||||
final CcmObject object1 = ccmObjectRepository.findById(-20001L).get();
|
final CcmObject object1 = ccmObjectRepository.findById(-20001L).get();
|
||||||
|
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege("privilege999",
|
() -> permissionManager.revokePrivilege("privilege999",
|
||||||
role1,
|
role1,
|
||||||
object1));
|
object1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -510,7 +512,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(320)
|
@InSequence(320)
|
||||||
public void revokePermissionPrivilegeNull() throws Throwable {
|
public void revokePermissionPrivilegeNull() throws Throwable {
|
||||||
|
|
@ -518,7 +520,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege(null, role1));
|
() -> permissionManager.revokePrivilege(null, role1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -534,7 +536,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(320)
|
@InSequence(320)
|
||||||
public void revokePermissionOnObjectPrivilegeNull() throws Throwable {
|
public void revokePermissionOnObjectPrivilegeNull() throws Throwable {
|
||||||
|
|
@ -543,8 +545,8 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.
|
() -> permissionManager.
|
||||||
revokePrivilege(null, role1, object1));
|
revokePrivilege(null, role1, object1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -560,7 +562,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(330)
|
@InSequence(330)
|
||||||
public void revokePermissionEmptyPrivilege() throws Throwable {
|
public void revokePermissionEmptyPrivilege() throws Throwable {
|
||||||
|
|
@ -568,7 +570,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege("", role1));
|
() -> permissionManager.revokePrivilege("", role1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -583,9 +585,9 @@ public class PermissionManagerTest {
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
@Test(expected
|
@Test(expected
|
||||||
= IllegalArgumentException.class)
|
= IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(320)
|
@InSequence(320)
|
||||||
public void revokePermissionOnObjectEmptyPrivilege() throws Throwable {
|
public void revokePermissionOnObjectEmptyPrivilege() throws Throwable {
|
||||||
|
|
@ -594,7 +596,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege("", role1, object1));
|
() -> permissionManager.revokePrivilege("", role1, object1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -609,15 +611,15 @@ public class PermissionManagerTest {
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
@Test(expected
|
@Test(expected
|
||||||
= IllegalArgumentException.class)
|
= IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(340)
|
@InSequence(340)
|
||||||
public void revokePermissionFromRoleNull() throws Throwable {
|
public void revokePermissionFromRoleNull() throws Throwable {
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege("privilege1", null));
|
() -> permissionManager.revokePrivilege("privilege1", null));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -633,7 +635,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(345)
|
@InSequence(345)
|
||||||
public void revokePermissionOnObjectFromRoleNull() throws Throwable {
|
public void revokePermissionOnObjectFromRoleNull() throws Throwable {
|
||||||
|
|
@ -641,9 +643,9 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege("privilege1",
|
() -> permissionManager.revokePrivilege("privilege1",
|
||||||
null,
|
null,
|
||||||
object1));
|
object1));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -659,7 +661,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(350)
|
@InSequence(350)
|
||||||
public void revokePermissionNullObject() throws Throwable {
|
public void revokePermissionNullObject() throws Throwable {
|
||||||
|
|
@ -667,9 +669,9 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.revokePrivilege("privilege2",
|
() -> permissionManager.revokePrivilege("privilege2",
|
||||||
role1,
|
role1,
|
||||||
null));
|
null));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -684,18 +686,18 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldMatchDataSet(
|
@ShouldMatchDataSet(
|
||||||
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
value = "datasets/org/libreccm/security/PermissionManagerTest/"
|
||||||
+ "after-copy.yml",
|
+ "after-copy.yml",
|
||||||
excludeColumns = {"permission_id"})
|
excludeColumns = {"permission_id"})
|
||||||
@InSequence(400)
|
@InSequence(400)
|
||||||
public void copyPermissions() throws Throwable {
|
public void copyPermissions() throws Throwable {
|
||||||
final CcmObject object2 = ccmObjectRepository.findById(-20002L).get();
|
final CcmObject object2 = ccmObjectRepository.findById(-20002L).get();
|
||||||
final CcmObject object3 = ccmObjectRepository.findById(-20003L).get();
|
final CcmObject object3 = ccmObjectRepository.findById(-20003L).get();
|
||||||
|
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.copyPermissions(object2, object3));
|
() -> permissionManager.copyPermissions(object2, object3));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -708,7 +710,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(410)
|
@InSequence(410)
|
||||||
public void copyPermissionsNullSource() throws Throwable {
|
public void copyPermissionsNullSource() throws Throwable {
|
||||||
|
|
@ -716,7 +718,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.copyPermissions(null, object3));
|
() -> permissionManager.copyPermissions(null, object3));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -732,7 +734,7 @@ public class PermissionManagerTest {
|
||||||
*/
|
*/
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
"datasets/org/libreccm/security/PermissionManagerTest/data.yml")
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(420)
|
@InSequence(420)
|
||||||
public void copyPermissionsNullTarget() throws Throwable {
|
public void copyPermissionsNullTarget() throws Throwable {
|
||||||
|
|
@ -740,7 +742,7 @@ public class PermissionManagerTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shiro.getSystemUser().execute(
|
shiro.getSystemUser().execute(
|
||||||
() -> permissionManager.copyPermissions(object2, null));
|
() -> permissionManager.copyPermissions(object2, null));
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
throw ex.getCause();
|
throw ex.getCause();
|
||||||
}
|
}
|
||||||
|
|
@ -756,9 +758,9 @@ public class PermissionManagerTest {
|
||||||
public void verifyListPrivileges() {
|
public void verifyListPrivileges() {
|
||||||
|
|
||||||
final List<String> corePrivileges = permissionManager
|
final List<String> corePrivileges = permissionManager
|
||||||
.listDefiniedPrivileges(CoreConstants.class);
|
.listDefiniedPrivileges(CoreConstants.class);
|
||||||
final List<String> catPrivileges = permissionManager
|
final List<String> catPrivileges = permissionManager
|
||||||
.listDefiniedPrivileges(CategorizationConstants.class);
|
.listDefiniedPrivileges(CategorizationConstants.class);
|
||||||
|
|
||||||
assertThat(corePrivileges, is(not(nullValue())));
|
assertThat(corePrivileges, is(not(nullValue())));
|
||||||
assertThat(corePrivileges.isEmpty(), is(false));
|
assertThat(corePrivileges.isEmpty(), is(false));
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -58,7 +59,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class RoleManagerTest {
|
public class RoleManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link RoleRepository}. Note. We are not enabling the
|
* Tests for the {@link RoleRepository}. Note. We are not enabling the
|
||||||
|
|
@ -69,7 +70,8 @@ import java.util.Optional;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class RoleRepositoryTest {
|
public class RoleRepositoryTest {
|
||||||
|
|
||||||
private static final String ADMINISTRATOR = "administrator";
|
private static final String ADMINISTRATOR = "administrator";
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -65,7 +66,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class SecuredCollectionTest {
|
public class SecuredCollectionTest {
|
||||||
|
|
||||||
private static final String ACCESS_DENIED = "Access denied";
|
private static final String ACCESS_DENIED = "Access denied";
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -66,7 +67,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class SecuredIteratorTest {
|
public class SecuredIteratorTest {
|
||||||
|
|
||||||
private static final String ACCESS_DENIED = "Access denied";
|
private static final String ACCESS_DENIED = "Access denied";
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -64,7 +65,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ShiroTest {
|
public class ShiroTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ import static org.junit.Assert.*;
|
||||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||||
|
|
||||||
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -63,7 +64,8 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class UserManagerTest {
|
public class UserManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ import java.util.Optional;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -65,7 +66,8 @@ import javax.persistence.PersistenceContext;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class UserRepositoryTest {
|
public class UserRepositoryTest {
|
||||||
|
|
||||||
private static final String NOBODY = "nobody";
|
private static final String NOBODY = "nobody";
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import org.jboss.arquillian.persistence.CleanupUsingScript;
|
||||||
import org.jboss.arquillian.persistence.CreateSchema;
|
import org.jboss.arquillian.persistence.CreateSchema;
|
||||||
import org.jboss.arquillian.persistence.PersistenceTest;
|
import org.jboss.arquillian.persistence.PersistenceTest;
|
||||||
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
import org.jboss.arquillian.persistence.UsingDataSet;
|
import org.jboss.arquillian.persistence.UsingDataSet;
|
||||||
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
|
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
|
||||||
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
||||||
|
|
@ -63,7 +64,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_shortcuts_schema.sql"})
|
@CreateSchema({"create_ccm_shortcuts_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ShortcutManagerTest {
|
public class ShortcutManagerTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ import java.util.Optional;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
import org.jboss.arquillian.persistence.TestExecutionPhase;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
@ -59,7 +60,8 @@ import static org.junit.Assert.*;
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_shortcuts_schema.sql"})
|
@CreateSchema({"create_ccm_shortcuts_schema.sql"})
|
||||||
@CleanupUsingScript({"cleanup.sql"})
|
@CleanupUsingScript(value = {"cleanup.sql"},
|
||||||
|
phase = TestExecutionPhase.BEFORE)
|
||||||
public class ShortcutRepositoryTest {
|
public class ShortcutRepositoryTest {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue