Skip to content

Commit 9262989

Browse files
Only enable integrationtest bootstrap class locally through alf global property
1 parent 2dc5070 commit 9262989

File tree

6 files changed

+39
-24
lines changed

6 files changed

+39
-24
lines changed

apix-docker/70/debug-extension.docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
environment:
77
- DEBUG=true
88
- SHARE_HOST=alfresco-share
9+
- GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true
910
alfresco-share:
1011
image: hub.xenit.eu/public/alfresco-share-community:7.0.0
1112
ports:

apix-docker/71/debug-extension.docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
environment:
77
- DEBUG=true
88
- SHARE_HOST=alfresco-share
9+
- GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true
910
alfresco-share:
1011
image: hub.xenit.eu/public/alfresco-share-community:7.1
1112
ports:

apix-docker/72/debug-extension.docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
environment:
77
- DEBUG=true
88
- SHARE_HOST=alfresco-share
9+
- GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true
910
alfresco-share:
1011
image: hub.xenit.eu/public/alfresco-share-community:7.2
1112
ports:

apix-docker/73/debug-extension.docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
environment:
77
- DEBUG=true
88
- SHARE_HOST=alfresco-share
9+
- GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true
910
alfresco-share:
1011
image: docker.io/xenit/alfresco-share-community:7.3
1112
ports:

apix-docker/74/debug-extension.docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ services:
66
environment:
77
- DEBUG=true
88
- SHARE_HOST=alfresco-share
9+
- GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true
910
alfresco-share:
1011
image: docker.io/xenit/alfresco-share-community:7.4
1112
ports:

apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java

+34-24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.Serializable;
44
import java.util.HashMap;
55
import java.util.Map;
6+
import java.util.Properties;
67
import org.alfresco.model.ContentModel;
78
import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator;
89
import org.alfresco.repo.nodelocator.NodeLocatorService;
@@ -14,52 +15,61 @@
1415
import org.alfresco.service.namespace.QName;
1516
import org.springframework.beans.factory.InitializingBean;
1617
import org.springframework.beans.factory.annotation.Autowired;
18+
import org.springframework.beans.factory.annotation.Qualifier;
1719
import org.springframework.stereotype.Component;
1820

1921
@Component
2022
public class Bootstrap implements InitializingBean {
2123

2224
public static final String WELL_KNOWN_TESTNODE_NAME = "well-known-testnode";
25+
private static final String ENABLED_GLOBAL_PROPERTIES_KEY = "eu.xenit.apix.integrationtest.bootstrap.enabled";
2326

2427
private RetryingTransactionHelper transactionHelper;
2528
private NodeLocatorService nodeLocator;
2629
private NodeService nodeService;
30+
private Properties globalProperties;
2731

2832
@Autowired
2933
public Bootstrap(
3034
RetryingTransactionHelper retryingTransactionHelper,
3135
NodeLocatorService nodeLocatorService,
32-
NodeService nodeService
36+
NodeService nodeService,
37+
@Qualifier("global-properties") Properties globalProperties
3338
) {
3439
this.transactionHelper = retryingTransactionHelper;
3540
this.nodeLocator = nodeLocatorService;
3641
this.nodeService = nodeService;
42+
this.globalProperties = globalProperties;
3743
}
3844

3945
@Override
4046
public void afterPropertiesSet() throws Exception {
41-
AuthenticationUtil.runAsSystem(
42-
() -> transactionHelper.doInTransaction(
43-
() -> {
44-
NodeRef companyHome = nodeLocator.getNode(CompanyHomeNodeLocator.NAME, null, null);
45-
NodeRef wellKnownTestNode = nodeService.getChildByName(companyHome, ContentModel.ASSOC_CONTAINS, WELL_KNOWN_TESTNODE_NAME);
46-
if (wellKnownTestNode == null) {
47-
Map<QName, Serializable> folderProperties = new HashMap<>();
48-
folderProperties.put(ContentModel.PROP_NAME, WELL_KNOWN_TESTNODE_NAME);
49-
folderProperties.put(ContentModel.PROP_NODE_UUID, WELL_KNOWN_TESTNODE_NAME);
50-
nodeService.createNode(
51-
companyHome,
52-
ContentModel.ASSOC_CONTAINS,
53-
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, WELL_KNOWN_TESTNODE_NAME),
54-
ContentModel.TYPE_FOLDER,
55-
folderProperties
56-
);
57-
}
58-
return null;
59-
},
60-
false,
61-
true
62-
)
63-
);
47+
if (Boolean.parseBoolean(globalProperties.getProperty(ENABLED_GLOBAL_PROPERTIES_KEY))) {
48+
AuthenticationUtil.runAsSystem(
49+
() -> transactionHelper.doInTransaction(
50+
() -> {
51+
NodeRef companyHome = nodeLocator.getNode(CompanyHomeNodeLocator.NAME, null, null);
52+
NodeRef wellKnownTestNode = nodeService.getChildByName(companyHome,
53+
ContentModel.ASSOC_CONTAINS, WELL_KNOWN_TESTNODE_NAME);
54+
if (wellKnownTestNode == null) {
55+
Map<QName, Serializable> folderProperties = new HashMap<>();
56+
folderProperties.put(ContentModel.PROP_NAME, WELL_KNOWN_TESTNODE_NAME);
57+
folderProperties.put(ContentModel.PROP_NODE_UUID, WELL_KNOWN_TESTNODE_NAME);
58+
nodeService.createNode(
59+
companyHome,
60+
ContentModel.ASSOC_CONTAINS,
61+
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
62+
WELL_KNOWN_TESTNODE_NAME),
63+
ContentModel.TYPE_FOLDER,
64+
folderProperties
65+
);
66+
}
67+
return null;
68+
},
69+
false,
70+
true
71+
)
72+
);
73+
}
6474
}
6575
}

0 commit comments

Comments
 (0)