-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport 5.x/testing imporvements #236
base: master-5.x
Are you sure you want to change the base?
Changes from all commits
0903496
4980bf2
a41b570
2dc5070
9262989
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package eu.xenit.apix.bootstrap; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import org.alfresco.model.ContentModel; | ||
import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator; | ||
import org.alfresco.repo.nodelocator.NodeLocatorService; | ||
import org.alfresco.repo.security.authentication.AuthenticationUtil; | ||
import org.alfresco.repo.transaction.RetryingTransactionHelper; | ||
import org.alfresco.service.cmr.repository.NodeRef; | ||
import org.alfresco.service.cmr.repository.NodeService; | ||
import org.alfresco.service.namespace.NamespaceService; | ||
import org.alfresco.service.namespace.QName; | ||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class Bootstrap implements InitializingBean { | ||
|
||
public static final String WELL_KNOWN_TESTNODE_NAME = "well-known-testnode"; | ||
private static final String ENABLED_GLOBAL_PROPERTIES_KEY = "eu.xenit.apix.integrationtest.bootstrap.enabled"; | ||
|
||
private RetryingTransactionHelper transactionHelper; | ||
private NodeLocatorService nodeLocator; | ||
private NodeService nodeService; | ||
private Properties globalProperties; | ||
|
||
@Autowired | ||
public Bootstrap( | ||
RetryingTransactionHelper retryingTransactionHelper, | ||
NodeLocatorService nodeLocatorService, | ||
NodeService nodeService, | ||
@Qualifier("global-properties") Properties globalProperties | ||
) { | ||
this.transactionHelper = retryingTransactionHelper; | ||
this.nodeLocator = nodeLocatorService; | ||
this.nodeService = nodeService; | ||
this.globalProperties = globalProperties; | ||
} | ||
|
||
@Override | ||
public void afterPropertiesSet() throws Exception { | ||
if (Boolean.parseBoolean(globalProperties.getProperty(ENABLED_GLOBAL_PROPERTIES_KEY))) { | ||
AuthenticationUtil.runAsSystem( | ||
() -> transactionHelper.doInTransaction( | ||
() -> { | ||
NodeRef companyHome = nodeLocator.getNode(CompanyHomeNodeLocator.NAME, null, null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be aware there is also https://github.com/xenit-eu/alfred-api/blob/master/alfred-api-integrationtests-client/alfresco/src/main/java/eu/xenit/alfred/api/tests/JavaApiBaseTest.java#L53 which may overlap? Non-blocking... |
||
NodeRef wellKnownTestNode = nodeService.getChildByName(companyHome, | ||
ContentModel.ASSOC_CONTAINS, WELL_KNOWN_TESTNODE_NAME); | ||
if (wellKnownTestNode == null) { | ||
Map<QName, Serializable> folderProperties = new HashMap<>(); | ||
folderProperties.put(ContentModel.PROP_NAME, WELL_KNOWN_TESTNODE_NAME); | ||
folderProperties.put(ContentModel.PROP_NODE_UUID, WELL_KNOWN_TESTNODE_NAME); | ||
nodeService.createNode( | ||
companyHome, | ||
ContentModel.ASSOC_CONTAINS, | ||
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, | ||
WELL_KNOWN_TESTNODE_NAME), | ||
ContentModel.TYPE_FOLDER, | ||
folderProperties | ||
); | ||
} | ||
return null; | ||
}, | ||
false, | ||
true | ||
) | ||
); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ plugins { | |
id 'eu.xenit.de' version '3.1.0' apply false | ||
id 'eu.xenit.amp' version '1.1.0' apply false | ||
id 'eu.xenit.alfresco' version '1.1.0' apply false | ||
id 'eu.xenit.docker-alfresco' version '5.3.1' apply false | ||
id 'eu.xenit.docker-compose' version '5.3.1' apply false | ||
id 'eu.xenit.docker-alfresco' version '5.5.0' apply false | ||
id 'eu.xenit.docker-compose' version '5.5.0' apply false | ||
id 'eu.xenit.alfresco-remote-testrunner' version '2.0.1' apply false | ||
} | ||
|
||
|
@@ -23,6 +23,7 @@ ext { | |
jackson_version = '2.8.3' | ||
care4alfVersion = '2.3.0' | ||
http_version = '4.3.4' // Used by integration tests | ||
ootbee_version = '1.2.2.0' // Used in docker image for testing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is only used once, why not keep it locally, close to where it is used? It makes development easier since there is less switching needed. |
||
} | ||
|
||
subprojects { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These defaults can lead to silent failures when the image is not built. I prefer to keep them out.