Skip to content

Commit b1bd61e

Browse files
committed
BroadleafCommerce#1127 Added IntegrationSetup files for both Site and Admin for use with Spock/Groovy Integration Tests
1 parent 546061c commit b1bd61e

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* #%L
3+
* BroadleafCommerce Custom Field
4+
* %%
5+
* Copyright (C) 2009 - 2014 Broadleaf Commerce
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package org.broadleafcommerce.test
21+
22+
import org.springframework.test.annotation.DirtiesContext
23+
import org.springframework.test.context.ContextConfiguration
24+
import org.springframework.test.context.ContextHierarchy
25+
import org.springframework.test.context.transaction.TransactionConfiguration
26+
import org.springframework.test.context.web.WebAppConfiguration
27+
28+
import spock.lang.Specification
29+
30+
/**
31+
* Base Integration Test Setup groovy file for Admin based integration tests. This base class has all the
32+
* applicationContext's shared by Integration tests for Admin based testing. Extend from this class on a
33+
* per project basis with another setup file that contains only an @ContextHeirarchy(@ContextConfiguration)
34+
* that references this "adminContexts" ContextConfiguration and add only the contexts, in the locations
35+
* parameter, that you need to run your tests at that level. Then extend off of that setup file with your
36+
* actual integration tests. IntegrationSetup files should not have any code in their body's.
37+
*
38+
* @author austinrooke
39+
*
40+
*/
41+
@TransactionConfiguration(transactionManager = "blTransactionManager")
42+
@ContextHierarchy([
43+
@ContextConfiguration(name = "adminContexts",
44+
locations = ["classpath:/bl-open-admin-contentClient-applicationContext.xml",
45+
"classpath:/bl-open-admin-contentCreator-applicationContext.xml",
46+
"classpath:/bl-admin-applicationContext.xml"],
47+
loader = BroadleafGenericGroovyXmlWebContextLoader.class)
48+
])
49+
@DirtiesContext
50+
@WebAppConfiguration
51+
class AdminIntegrationSetup extends Specification {
52+
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* #%L
3+
* BroadleafCommerce Custom Field
4+
* %%
5+
* Copyright (C) 2009 - 2014 Broadleaf Commerce
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package org.broadleafcommerce.test
21+
22+
import org.springframework.test.annotation.DirtiesContext
23+
import org.springframework.test.context.ContextConfiguration
24+
import org.springframework.test.context.ContextHierarchy
25+
import org.springframework.test.context.transaction.TransactionConfiguration
26+
import org.springframework.test.context.web.WebAppConfiguration
27+
28+
import spock.lang.Specification
29+
30+
/**
31+
* Base Integration Test Setup groovy file for Site based integration tests. This base class has all the
32+
* applicationContext's shared by Integration tests for Site based testing. Extend from this class on a
33+
* per project basis with another setup file that contains only an @ContextHeirarchy(@ContextConfiguration)
34+
* that references this "siteContexts" ContextConfiguration and add only the contexts, in the locations
35+
* parameter, that you need to run your tests at that level. Then extend off of that setup file with your
36+
* actual integration tests. IntegrationSetup files should not have any code in their body's.
37+
*
38+
* @author austinrooke
39+
*
40+
*/
41+
@TransactionConfiguration(transactionManager = "blTransactionManager")
42+
@ContextHierarchy([
43+
@ContextConfiguration(name = "siteContexts",
44+
locations = ["classpath:/bl-open-admin-contentClient-applicationContext.xml"],
45+
loader = BroadleafGenericGroovyXmlWebContextLoader.class)
46+
])
47+
@DirtiesContext
48+
@WebAppConfiguration
49+
class SiteIntegrationSetup extends Specification {
50+
51+
}

0 commit comments

Comments
 (0)