Skip to content

Commit

Permalink
ALFREDAPI-548-split [Update] Loading in beans via overving and constr…
Browse files Browse the repository at this point in the history
…uctors
  • Loading branch information
codingBenVdS committed Jul 10, 2024
1 parent d4f19b8 commit 0bf836c
Show file tree
Hide file tree
Showing 83 changed files with 491 additions and 904 deletions.
5 changes: 1 addition & 4 deletions apix-docker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ subprojects {
leanImage = true
}

// Isolate the version number ("docker-52" -> "52"). We should find a cleaner way
// Isolate the version number ("docker-231" -> "231"). We should find a cleaner way
def subproject_alfresco_version = project.name.substring(project.name.length() - getTotalNumbersAfterDash(project.name))
dependencies {
alfrescoAmp project(path: ":alfresco:${subproject_alfresco_version}", configuration: 'ampArtifact') // Read in the alfresco V 23.x in with alfred-api amps
alfrescoAmp project(path: ":apix-integrationtests-server", configuration: 'amp') // Read in the alfresco integration-test-server
alfrescoAmp project(path: ':apix-integrationtests:model-amp', configuration: 'ampArchives') // Read the model in for running the integration tests.
alfrescoSM "com.gradecak.alfresco-mvc:alfresco-mvc-rest:${mvc}"
alfrescoSM "com.gradecak.alfresco-mvc:alfresco-mvc-aop:${mvc}"
// import the new JUnit remote server for adding class-beans (Helperclasses)
// implementation project(path: ':apix-integrationtests-server')
// implementation project(path: ':apix-integrationtests:alfresco')
alfrescoSM files(jar)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;

// Runs inside the Alfresco container, See docker logs.
@RunWith(RemoteTestRunner.class)
public class AlfrescoApplicationContextIT {
private static final Logger logger = LoggerFactory.getLogger(AlfrescoApplicationContextIT.class);
Expand Down
5 changes: 2 additions & 3 deletions apix-integrationtests/alfresco/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@ allprojects {
exclude group: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpcore'
}
// // Add services used to the integration test fatjar, since we can't access the ones deployed in Alfresco
// Add services used to the integration test fatjar, since we can't access the ones deployed in Alfresco
testImplementation (project(":apix-impl:apix-impl-${subproject_alfresco_version}")) {
// Already includes apix-interface, we need to exclude it to avoid Linkage errors from
// having 2 of the same classes on the classpath
// (1 in Alfresco from apix-impl AMP + 1 in DE from the integration tests fat jar)
exclude(group: "eu.xenit.alfred.api", module: "apix-interface")
}
// testImplementation project.sourceSets.integrationTest.output

// Read in the integration-test-server static ApplicationContext + Helperclasses
implementation project(path: ":apix-integrationtests-server") // Read in the alfresco integration-test-server
// testImplementation project.sourceSets.integrationTest.output
}
}
// Custom JAR task to include only the specified package
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package eu.xenit.apix;

import com.github.ruediste.remoteJUnit.client.RemoteTestRunner;
import eu.xenit.apix.alfresco.ApixToAlfrescoConversion;
import eu.xenit.apix.server.ApplicationContextProvider;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.transaction.TransactionService;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

@RunWith(RemoteTestRunner.class)
public abstract class BaseApplicationContextTest {
private final static Logger logger = LoggerFactory.getLogger(BaseApplicationContextTest.class);

protected ApixToAlfrescoConversion c;
protected ServiceRegistry serviceRegistry;
protected Repository repository;
protected ApplicationContext testApplicationContext;
protected AuthenticationService authenticationService;
protected SysAdminParams sysAdminParams;
protected TransactionService transactionService;
protected RetryingTransactionHelper transactionHelper;

public BaseApplicationContextTest() {
// initialise the static application-context
testApplicationContext = ApplicationContextProvider.getApplicationContext();
serviceRegistry = testApplicationContext.getBean(ServiceRegistry.class);
c = testApplicationContext.getBean(ApixToAlfrescoConversion.class);
repository = testApplicationContext.getBean(Repository.class);
sysAdminParams = serviceRegistry.getSysAdminParams();
authenticationService = serviceRegistry.getAuthenticationService();
transactionService = testApplicationContext.getBean(TransactionService.class);
transactionHelper = testApplicationContext.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package eu.xenit.apix.rest.staging.tests;

import com.github.ruediste.remoteJUnit.client.RemoteTestRunner;
import eu.xenit.apix.rest.v1.tests.RestV1BaseTest;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@RunWith(RemoteTestRunner.class)
public abstract class StagingBaseTest extends RestV1BaseTest {

private final static Logger logger = LoggerFactory.getLogger(StagingBaseTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,18 @@ public class WorkflowTest extends StagingBaseTest {

private final static Logger logger = LoggerFactory.getLogger(WorkflowTest.class);
private final List<WorkflowPath> wfPaths = new ArrayList<>();
private ApplicationContext testApplicationContext;
private ServiceRegistry serviceRegistry;
private WorkflowService workflowService;
private AuthorityService authorityService;

public WorkflowTest(){
workflowService = this.serviceRegistry.getWorkflowService();
authorityService = this.serviceRegistry.getAuthorityService();
}

@Before
public void setup() {
this.initialiseBeans(); // Setup the RestV1BaseTest Beans
this.cleanUp();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
this.testApplicationContext = ApplicationContextProvider.getApplicationContext();
this.serviceRegistry = (ServiceRegistry) testApplicationContext.getBean(ServiceRegistry.class);


this.workflowService = this.serviceRegistry.getWorkflowService();
this.authorityService = this.serviceRegistry.getAuthorityService();

this.serviceRegistry.getRetryingTransactionHelper()
.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class AllNodeInfoTest extends RestV1BaseTest {

@Before
public void setup() {
this.initialiseBeans(); // Setup the RestV1BaseTest Beans
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

import static org.junit.Assert.assertEquals;

import eu.xenit.apix.alfresco.ApixToAlfrescoConversion;
import eu.xenit.apix.data.NodeRef;
import eu.xenit.apix.server.ApplicationContextProvider;
import java.io.IOException;
import java.util.HashMap;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.service.transaction.TransactionService;
import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Request;
import org.apache.http.util.EntityUtils;
Expand All @@ -22,9 +18,6 @@
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;

/**
* Created by kenneth on 17.03.16.
Expand All @@ -33,22 +26,16 @@ public class AssociationsTest extends RestV1BaseTest {

private final static Logger logger = LoggerFactory.getLogger(AssociationsTest.class);

NodeService nodeService;
TransactionService transactionService;
ApixToAlfrescoConversion c;
private ApplicationContext testApplicationContext;
private ServiceRegistry serviceRegistry;
private NodeService nodeService;

public AssociationsTest(){
// initialise the local beans
nodeService = serviceRegistry.getNodeService();
}

@Before
public void setup() {
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
initialiseBeans(); // Setup the RestV1BaseTest Beans
// initialise the local beans
testApplicationContext = ApplicationContextProvider.getApplicationContext();
serviceRegistry = (ServiceRegistry) testApplicationContext.getBean(ServiceRegistry.class);
nodeService = serviceRegistry.getNodeService();
c = (ApixToAlfrescoConversion) testApplicationContext.getBean(ApixToAlfrescoConversion.class);
transactionService = (TransactionService) testApplicationContext.getBean(TransactionService.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@
import eu.xenit.apix.data.NodeRef;
import eu.xenit.apix.node.ChildParentAssociation;
import eu.xenit.apix.node.INodeService;
import eu.xenit.apix.server.ApplicationContextProvider;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.transaction.TransactionService;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
Expand All @@ -35,7 +32,6 @@
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

/**
* Created by kenneth on 18.03.16.
Expand All @@ -45,12 +41,14 @@ public abstract class BulkTest extends RestV1BaseTest {

public static final String AUTHENTICATION_IN_URL = "alf_ticket=";
private final static Logger logger = LoggerFactory.getLogger(BulkTest.class);
INodeService nodeService;
private INodeService nodeService;
private NodeService alfrescoNodeService;

NodeService alfrescoNodeService;
TransactionService transactionService;
ServiceRegistry serviceRegistry;
ApplicationContext testApplicationContext;
public BulkTest(){
// initialise the local beans
alfrescoNodeService = serviceRegistry.getNodeService();
nodeService = (eu.xenit.apix.alfresco.metadata.NodeService) testApplicationContext.getBean(eu.xenit.apix.alfresco.metadata.NodeService.class); // fetches APIX nodeService
}

private String jsonObjectGetStringFromInt(JSONObject targetObject, String key) {
return String.valueOf(targetObject.getInt(key));
Expand All @@ -59,14 +57,6 @@ private String jsonObjectGetStringFromInt(JSONObject targetObject, String key) {
@Before
public void setup() {
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
// Setup the RestV1BaseTest Beans
initialiseBeans();
// initialise the local beans
testApplicationContext = ApplicationContextProvider.getApplicationContext();
serviceRegistry = (ServiceRegistry) testApplicationContext.getBean(ServiceRegistry.class);
alfrescoNodeService = serviceRegistry.getNodeService();
transactionService = (TransactionService) testApplicationContext.getBean(TransactionService.class);
nodeService = (eu.xenit.apix.alfresco.metadata.NodeService) testApplicationContext.getBean(eu.xenit.apix.alfresco.metadata.NodeService.class); // fetches APIX nodeService
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,36 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import eu.xenit.apix.alfresco.ApixToAlfrescoConversion;
import eu.xenit.apix.data.NodeRef;
import eu.xenit.apix.rest.v1.workingcopies.NoderefResult;
import eu.xenit.apix.server.ApplicationContextProvider;
import java.io.IOException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.transaction.TransactionService;
import org.json.JSONException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;

/**
* Created by kenneth on 31.03.16.
*/
public class CheckoutCheckinTest extends RestV1BaseTest {
private ApplicationContext testApplicationContext;

NodeService nodeService;

TransactionService transactionService;
ApixToAlfrescoConversion c;
private NodeService nodeService;
private NodeRef originalNoderef;
ServiceRegistry serviceRegistry;

@Before
public void setup() {
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
// Setup the RestV1BaseTest Beans
initialiseBeans();
public CheckoutCheckinTest(){
// initialise the local beans
testApplicationContext = ApplicationContextProvider.getApplicationContext();
serviceRegistry = (ServiceRegistry) testApplicationContext.getBean(ServiceRegistry.class);
c = (ApixToAlfrescoConversion) testApplicationContext.getBean(ApixToAlfrescoConversion.class);
transactionService = (TransactionService) testApplicationContext.getBean(TransactionService.class);
nodeService = serviceRegistry.getNodeService();
originalNoderef = init().get(RestV1BaseTest.TESTFILE_NAME);
}

@Before
public void setup() {
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
}

@Test
public void testCheckoutPostAndCheckin() throws IOException, JSONException {
NoderefResult checkoutResult = doPost(makeAlfrescoBaseurlAdmin() + "/apix/v1/workingcopies",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.xenit.apix.alfresco.ApixToAlfrescoConversion;
import eu.xenit.apix.alfresco.metadata.NodeService;
import eu.xenit.apix.comments.Comment;
import eu.xenit.apix.comments.ICommentService;
import eu.xenit.apix.data.NodeRef;
import eu.xenit.apix.server.ApplicationContextProvider;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashMap;
Expand All @@ -35,7 +33,6 @@
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

public class CommentsTest extends RestV1BaseTest {
private static final Logger log = LoggerFactory.getLogger(CommentsTest.class);
Expand All @@ -48,29 +45,21 @@ public class CommentsTest extends RestV1BaseTest {
private static final String PAGESIZE = "pagesize";

private CommentService alfrescoCommentService;

private ICommentService commentService;

private ApixToAlfrescoConversion apixConverter;

private NodeService nodeService;
private RetryingTransactionHelper transactionHelper;
private ApplicationContext testApplicationContext;

@Before
public void setup() {
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
// Setup the RestV1BaseTest Beans
initialiseBeans();
public CommentsTest(){
// initialise the local beans
testApplicationContext = ApplicationContextProvider.getApplicationContext();
nodeService = (eu.xenit.apix.alfresco.metadata.NodeService) testApplicationContext.getBean(eu.xenit.apix.alfresco.metadata.NodeService.class);
transactionHelper = (RetryingTransactionHelper) testApplicationContext.getBean("retryingTransactionHelper", RetryingTransactionHelper.class); // this returns null?
apixConverter = (ApixToAlfrescoConversion) testApplicationContext.getBean(ApixToAlfrescoConversion.class);
commentService= (ICommentService) testApplicationContext.getBean(ICommentService.class);
alfrescoCommentService = (CommentService) testApplicationContext.getBean("commentService", CommentService.class);
}

@Before
public void setup() {
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
}

@Override
public HashMap<String, NodeRef> init() {
HashMap<String, NodeRef> response = super.init();
Expand All @@ -83,7 +72,7 @@ private HashMap<String, NodeRef> initComments(HashMap<String, NodeRef> initializ
Comment comment = commentService.addNewComment(initializedNodeRefs.get(TESTFILE_NAME), commentContent);
initializedNodeRefs.put(COMMENTNODE1, comment.getId());
org.alfresco.service.cmr.repository.NodeRef alfrescoCommentNode2 = alfrescoCommentService
.createComment(apixConverter.alfresco(initializedNodeRefs.get(NOUSERRIGHTS_FILE_NAME)), commentTitle,
.createComment(c.alfresco(initializedNodeRefs.get(NOUSERRIGHTS_FILE_NAME)), commentTitle,
commentContent, false);
initializedNodeRefs.put(COMMENTNODE_NORIGHTS, new NodeRef(alfrescoCommentNode2.toString()));
return initializedNodeRefs;
Expand Down
Loading

0 comments on commit 0bf836c

Please sign in to comment.