Skip to content

Commit 98cc37c

Browse files
Refactored tests
1 parent 06e8b64 commit 98cc37c

25 files changed

+132
-105
lines changed
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package software.xdev.spring.data.eclipse.store.integration.shared;
16+
package software.xdev.spring.data.eclipse.store.integration;
1717

1818
import static org.eclipse.store.storage.embedded.types.EmbeddedStorage.Foundation;
1919

@@ -30,13 +30,9 @@
3030

3131
import software.xdev.spring.data.eclipse.store.helper.StorageDirectoryNameProvider;
3232
import software.xdev.spring.data.eclipse.store.repository.config.EclipseStoreClientConfiguration;
33-
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
3433

3534

3635
@Configuration
37-
@EnableEclipseStoreRepositories(
38-
value = "software.xdev.spring.data.eclipse.store.integration.shared",
39-
clientConfigurationClass = TestConfiguration.class)
4036
public class TestConfiguration extends EclipseStoreClientConfiguration
4137
{
4238
private final String storageDirectory = StorageDirectoryNameProvider.getNewStorageDirectoryPath();

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/IsolatedTestAnnotations.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@
2424

2525
import org.junit.jupiter.api.extension.ExtendWith;
2626
import org.springframework.test.annotation.DirtiesContext;
27-
import org.springframework.test.context.ContextConfiguration;
2827
import org.springframework.test.context.junit.jupiter.SpringExtension;
2928

3029

3130
@Retention(RetentionPolicy.RUNTIME)
3231
@Target(ElementType.TYPE)
3332
@ExtendWith(SpringExtension.class)
34-
@ContextConfiguration(classes = {IsolatedTestConfiguration.class})
3533
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD)
3634
public @interface IsolatedTestAnnotations
3735
{

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/IsolatedTestConfiguration.java

Lines changed: 0 additions & 65 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* The repositories of these tests are seperated from each other. That means that e.g. the
3+
* {@link software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types.TypesTest} can't access the
4+
* {@link software.xdev.spring.data.eclipse.store.integration.isolated.tests.keywords.MinimalRepository}.
5+
*/
6+
package software.xdev.spring.data.eclipse.store.integration.isolated;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/keywords/KeywordsTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import org.junit.jupiter.api.Disabled;
2020
import org.junit.jupiter.api.Test;
2121
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.test.context.ContextConfiguration;
2223

2324
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2425
import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
25-
import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestConfiguration;
2626

2727

2828
/**
@@ -31,10 +31,11 @@
3131
* keywords</a>
3232
*/
3333
@IsolatedTestAnnotations
34+
@ContextConfiguration(classes = {KeywordsTestConfiguration.class})
3435
class KeywordsTest
3536
{
3637
@Autowired
37-
private IsolatedTestConfiguration configuration;
38+
private KeywordsTestConfiguration configuration;
3839

3940
@Test
4041
@Disabled("For now we don't need 'existsBy'")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
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+
* http://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+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.keywords;
17+
18+
import org.springframework.context.annotation.Configuration;
19+
20+
import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
21+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
22+
23+
24+
@Configuration
25+
@EnableEclipseStoreRepositories(clientConfigurationClass = KeywordsTestConfiguration.class)
26+
public class KeywordsTestConfiguration extends TestConfiguration
27+
{
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
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+
* http://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+
package software.xdev.spring.data.eclipse.store.integration.isolated.tests.special.types;
17+
18+
import org.springframework.context.annotation.Configuration;
19+
20+
import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
21+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
22+
23+
24+
@Configuration
25+
@EnableEclipseStoreRepositories(clientConfigurationClass = SpecialTypesTestConfiguration.class)
26+
public class SpecialTypesTestConfiguration extends TestConfiguration
27+
{
28+
}

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/special/types/TypesTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@
2626
import org.junit.jupiter.params.provider.MethodSource;
2727
import org.springframework.beans.factory.annotation.Autowired;
2828
import org.springframework.context.ApplicationContext;
29+
import org.springframework.test.context.ContextConfiguration;
2930

3031
import software.xdev.spring.data.eclipse.store.exceptions.DataTypeNotSupportedException;
3132
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
3233
import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations;
33-
import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestConfiguration;
3434
import software.xdev.spring.data.eclipse.store.repository.interfaces.EclipseStoreRepository;
3535

3636

3737
@IsolatedTestAnnotations
38+
@ContextConfiguration(classes = {SpecialTypesTestConfiguration.class})
3839
class TypesTest
3940
{
4041
public static final String TYPES_DATA_SOURCE =
@@ -45,7 +46,7 @@ class TypesTest
4546
+ ".TypesData#generateNotWorkingData";
4647

4748
@Autowired
48-
private IsolatedTestConfiguration configuration;
49+
private SpecialTypesTestConfiguration configuration;
4950

5051
@ParameterizedTest
5152
@MethodSource(TYPES_DATA_SOURCE)

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/DefaultTestAnnotations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@Retention(RetentionPolicy.RUNTIME)
3232
@Target(ElementType.TYPE)
3333
@ExtendWith(SpringExtension.class)
34-
@ContextConfiguration(classes = {TestConfiguration.class})
34+
@ContextConfiguration(classes = {SharedTestConfiguration.class})
3535
@DirtiesContext(classMode = BEFORE_EACH_TEST_METHOD)
3636
public @interface DefaultTestAnnotations
3737
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright © 2023 XDEV Software (https://xdev.software)
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+
* http://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+
package software.xdev.spring.data.eclipse.store.integration.shared;
17+
18+
import org.springframework.context.annotation.Configuration;
19+
20+
import software.xdev.spring.data.eclipse.store.integration.TestConfiguration;
21+
import software.xdev.spring.data.eclipse.store.repository.config.EnableEclipseStoreRepositories;
22+
23+
24+
@Configuration
25+
@EnableEclipseStoreRepositories(
26+
value = "software.xdev.spring.data.eclipse.store.integration.shared",
27+
clientConfigurationClass = SharedTestConfiguration.class)
28+
public class SharedTestConfiguration extends TestConfiguration
29+
{
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* These tests SHARE their repositories. That's not ideal and should be changed in the future.
3+
*/
4+
package software.xdev.spring.data.eclipse.store.integration.shared;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/ChangeRootTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2525
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
26-
import software.xdev.spring.data.eclipse.store.integration.shared.TestConfiguration;
26+
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
2727
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.Node;
2828
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.NodeRepository;
2929

@@ -39,7 +39,7 @@ public class ChangeRootTests
3939
@Autowired
4040
private NodeRepository repository;
4141
@Autowired
42-
private TestConfiguration configuration;
42+
private SharedTestConfiguration configuration;
4343

4444
//@formatter:off
4545
/**

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/ConcurrencyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
3535
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
36-
import software.xdev.spring.data.eclipse.store.integration.shared.TestConfiguration;
36+
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
3737
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.Customer;
3838
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerRepository;
3939

@@ -47,7 +47,7 @@ class ConcurrencyTest
4747
private CustomerRepository repository;
4848

4949
@Autowired
50-
private TestConfiguration configuration;
50+
private SharedTestConfiguration configuration;
5151

5252
private final List<Customer> testCustomers =
5353
IntStream.range(1, 100).mapToObj((i) -> new Customer(CUSTOMER_NO + i, "")).toList();

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/FinalTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import software.xdev.spring.data.eclipse.store.helper.TestData;
2626
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2727
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
28-
import software.xdev.spring.data.eclipse.store.integration.shared.TestConfiguration;
28+
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
2929
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.immutables.CustomerWithFinal;
3030
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.immutables.CustomerWithFinalChild;
3131
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.immutables.CustomerWithFinalChildRepository;
@@ -45,7 +45,7 @@ class FinalTest
4545
CustomerWithFinalIdRepository withFinalIdRepository;
4646

4747
@Autowired
48-
TestConfiguration configuration;
48+
SharedTestConfiguration configuration;
4949

5050
@Test
5151
void testSaveAndFindSingle()

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/HashSetTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import software.xdev.spring.data.eclipse.store.helper.TestData;
2626
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2727
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
28-
import software.xdev.spring.data.eclipse.store.integration.shared.TestConfiguration;
28+
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
2929
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerRepositoryWithHashSet;
3030
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerRepositoryWithNonFinalHashSet;
3131
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerWithHashSet;
@@ -41,7 +41,7 @@ class HashSetTest
4141
private CustomerRepositoryWithNonFinalHashSet nonFinalRepository;
4242

4343
@Autowired
44-
private TestConfiguration configuration;
44+
private SharedTestConfiguration configuration;
4545

4646
@Test
4747
void testSaveAndFindAll()

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/IdTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import software.xdev.spring.data.eclipse.store.helper.TestData;
2828
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2929
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
30-
import software.xdev.spring.data.eclipse.store.integration.shared.TestConfiguration;
30+
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
3131
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdInt;
3232
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdIntRepository;
3333
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.id.CustomerWithIdInteger;
@@ -49,7 +49,7 @@
4949
class IdTest
5050
{
5151
@Autowired
52-
private TestConfiguration configuration;
52+
private SharedTestConfiguration configuration;
5353

5454
@Test
5555
void testCreateSingleWithAutoIdInteger(@Autowired final CustomerWithIdIntegerRepository customerRepository)

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/InheritanceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import software.xdev.spring.data.eclipse.store.helper.TestData;
2525
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2626
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
27-
import software.xdev.spring.data.eclipse.store.integration.shared.TestConfiguration;
27+
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
2828
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.ChildCustomer;
2929
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.ChildCustomerRepository;
3030
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.ParentCustomer;
@@ -43,7 +43,7 @@ class InheritanceTest
4343
@Autowired
4444
private SubCustomerRepository subCustomerRepository;
4545
@Autowired
46-
private TestConfiguration configuration;
46+
private SharedTestConfiguration configuration;
4747

4848
@Test
4949
void testSaveChildFindParent()

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/shared/tests/JpaCompatibilityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import software.xdev.spring.data.eclipse.store.helper.TestData;
2626
import software.xdev.spring.data.eclipse.store.helper.TestUtil;
2727
import software.xdev.spring.data.eclipse.store.integration.shared.DefaultTestAnnotations;
28-
import software.xdev.spring.data.eclipse.store.integration.shared.TestConfiguration;
28+
import software.xdev.spring.data.eclipse.store.integration.shared.SharedTestConfiguration;
2929
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerRepositoryWithQuery;
3030
import software.xdev.spring.data.eclipse.store.integration.shared.repositories.CustomerWithQuery;
3131

@@ -37,7 +37,7 @@ class JpaCompatibilityTest
3737
private CustomerRepositoryWithQuery customerRepository;
3838

3939
@Autowired
40-
private TestConfiguration configuration;
40+
private SharedTestConfiguration configuration;
4141

4242
@Test
4343
void testUseQueryAnnotationFindAll()

0 commit comments

Comments
 (0)