Search in sources :

Example 1 with SpringExtensionBundle

use of org.alfresco.traitextender.SpringExtensionBundle in project alfresco-repository by Alfresco.

the class VirtualizationIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    ctx = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);
    ;
    virtualizationConfigTestBootstrap = ctx.getBean(VIRTUALIZATION_CONFIG_TEST_BOOTSTRAP_BEAN_ID, VirtualizationConfigTestBootstrap.class);
    // Get the required services
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
    transactionService = serviceRegistry.getTransactionService();
    retryingTransactionHelper = serviceRegistry.getRetryingTransactionHelper();
    nodeService = serviceRegistry.getNodeService();
    contentService = serviceRegistry.getContentService();
    fileAndFolderService = serviceRegistry.getFileFolderService();
    permissionService = serviceRegistry.getPermissionService();
    authenticationComponent = ctx.getBean("authenticationComponent", AuthenticationComponent.class);
    environment = ctx.getBean("actualEnvironment", ActualEnvironment.class);
    typeAndAspectsFormProcessor = ctx.getBean("typeAndAspectsFormProcessor", TypeAndAspectsFormProcessor.class);
    constraints = ctx.getBean("systemTemplateLocations", SystemTemplateLocationsConstraint.class);
    Repository repository = ctx.getBean("repositoryHelper", Repository.class);
    if (!virtualizationConfigTestBootstrap.areVirtualFoldersEnabled()) {
        // "use the force" and enable virtual folders
        SpringExtensionBundle vfBundle = ctx.getBean("smartFoldersBundle", SpringExtensionBundle.class);
        vfBundle.start();
    } else {
        logger.info("Virtual folders are spring-enabled.");
    }
    this.authenticationComponent.setSystemUserAsCurrentUser();
    // start the transaction
    txn = transactionService.getUserTransaction();
    txn.begin();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    companyHomeNodeRef = repository.getCompanyHome();
    testRootFolder = fileAndFolderService.create(companyHomeNodeRef, TEST_ROOT_FOLDER_NAME, ContentModel.TYPE_FOLDER);
    virtualFolder1NodeRef = createVirtualizedFolder(testRootFolder.getNodeRef(), VIRTUAL_FOLDER_1_NAME, TEST_TEMPLATE_1_JSON_SYS_PATH);
    rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    setupMocks();
}
Also used : Repository(org.alfresco.repo.model.Repository) AuthenticationComponent(org.alfresco.repo.security.authentication.AuthenticationComponent) SystemTemplateLocationsConstraint(org.alfresco.repo.virtual.model.SystemTemplateLocationsConstraint) ServiceRegistry(org.alfresco.service.ServiceRegistry) SpringExtensionBundle(org.alfresco.traitextender.SpringExtensionBundle) Before(org.junit.Before)

Example 2 with SpringExtensionBundle

use of org.alfresco.traitextender.SpringExtensionBundle in project alfresco-repository by Alfresco.

the class VirtualizationIntegrationTest method tearDown.

@After
public void tearDown() throws Exception {
    if (!virtualizationConfigTestBootstrap.areVirtualFoldersEnabled()) {
        // "use the force" and disable virtual folders
        SpringExtensionBundle vfBundle = ctx.getBean("smartFoldersBundle", SpringExtensionBundle.class);
        vfBundle.stop();
    }
    if (configuredTemplatesClassPath != null) {
        constraints.setTemplatesParentClasspath(configuredTemplatesClassPath);
        configuredTemplatesClassPath = null;
    }
    authenticationComponent.clearCurrentSecurityContext();
    try {
        txn.rollback();
    } catch (Exception e) {
        logger.error("Test tear down failed. Has the test setup transaction been tempered with ? Hint : " + txnTamperHint, e);
    }
// super.tearDown();
}
Also used : SpringExtensionBundle(org.alfresco.traitextender.SpringExtensionBundle) After(org.junit.After)

Aggregations

SpringExtensionBundle (org.alfresco.traitextender.SpringExtensionBundle)2 Repository (org.alfresco.repo.model.Repository)1 AuthenticationComponent (org.alfresco.repo.security.authentication.AuthenticationComponent)1 SystemTemplateLocationsConstraint (org.alfresco.repo.virtual.model.SystemTemplateLocationsConstraint)1 ServiceRegistry (org.alfresco.service.ServiceRegistry)1 After (org.junit.After)1 Before (org.junit.Before)1