Skip to content

Commit f86affe

Browse files
philwebbjhoeller
authored andcommitted
Extract integration test classes from package-info
Extract the inner classes from package-info into their own files to prevent local build problems and to make them easier to find.
1 parent fff3813 commit f86affe

File tree

5 files changed

+92
-38
lines changed

5 files changed

+92
-38
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.core.env.scan1;
18+
19+
import org.springframework.context.annotation.Configuration;
20+
import org.springframework.context.annotation.Import;
21+
22+
@Configuration
23+
@Import({ DevConfig.class, ProdConfig.class })
24+
class Config {
25+
26+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.core.env.scan1;
18+
19+
import org.springframework.context.annotation.Bean;
20+
import org.springframework.context.annotation.Configuration;
21+
import org.springframework.context.annotation.Profile;
22+
23+
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
24+
@Configuration
25+
class DevConfig {
26+
27+
@Bean
28+
public Object devBean() {
29+
return new Object();
30+
}
31+
32+
}

src/test/java/org/springframework/core/env/scan1/package-info.java renamed to src/test/java/org/springframework/core/env/scan1/ProdConfig.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,20 @@
1414
* limitations under the License.
1515
*/
1616

17-
/**
18-
* Mirrors the structure of beans and environment-specific config files
19-
* in EnvironmentIntegrationTests-context.xml
20-
*/
21-
package org.springframework.core.env.scan1;
2217

23-
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME;
24-
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME;
18+
package org.springframework.core.env.scan1;
2519

2620
import org.springframework.context.annotation.Bean;
2721
import org.springframework.context.annotation.Configuration;
28-
import org.springframework.context.annotation.Import;
2922
import org.springframework.context.annotation.Profile;
3023

31-
@Configuration
32-
@Import({DevConfig.class, ProdConfig.class})
33-
class Config {
34-
}
35-
36-
@Profile(DEV_ENV_NAME)
37-
@Configuration
38-
class DevConfig {
39-
@Bean
40-
public Object devBean() {
41-
return new Object();
42-
}
43-
}
44-
45-
@Profile(PROD_ENV_NAME)
24+
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
4625
@Configuration
4726
class ProdConfig {
27+
4828
@Bean
4929
public Object prodBean() {
5030
return new Object();
5131
}
32+
5233
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2002-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.core.env.scan2;
18+
19+
import org.springframework.context.annotation.Profile;
20+
import org.springframework.stereotype.Component;
21+
22+
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
23+
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME)
24+
class DevBean {
25+
}

src/test/java/org/springframework/core/env/scan2/package-info.java renamed to src/test/java/org/springframework/core/env/scan2/ProdBean.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
/**
18-
* Mirrors the structure of beans and environment-specific config files
19-
* in EnvironmentIntegrationTests-context.xml
20-
*/
21-
package org.springframework.core.env.scan2;
2217

23-
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME;
24-
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME;
25-
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME;
26-
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME;
18+
package org.springframework.core.env.scan2;
2719

2820
import org.springframework.context.annotation.Profile;
2921
import org.springframework.stereotype.Component;
3022

31-
@Profile(DEV_ENV_NAME)
32-
@Component(DEV_BEAN_NAME)
33-
class DevBean { }
23+
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
24+
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME)
25+
class ProdBean {
3426

35-
@Profile(PROD_ENV_NAME)
36-
@Component(PROD_BEAN_NAME)
37-
class ProdBean { }
27+
}

0 commit comments

Comments
 (0)