You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by na...@apache.org on 2022/01/27 07:24:01 UTC
[ignite-extensions] branch master updated: IGNITE-15753 Adds Spring version compatibility tests for cache and tx integrations. (#80)
This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-extensions.git
The following commit(s) were added to refs/heads/master by this push:
new e534200 IGNITE-15753 Adds Spring version compatibility tests for cache and tx integrations. (#80)
e534200 is described below
commit e534200f9ad94003a5864ee56968f29d53e0b20d
Author: Mikhail Petrov <32...@users.noreply.github.com>
AuthorDate: Thu Jan 27 10:20:24 2022 +0300
IGNITE-15753 Adds Spring version compatibility tests for cache and tx integrations. (#80)
---
modules/spring-cache-ext/pom.xml | 36 +++
.../src/test/java/config/ignite-client-node.xml | 59 +++++
.../spring/IgniteSpringCacheCompatibilityTest.java | 277 +++++++++++++++++++++
.../testsuites/IgniteSpringCacheTestSuite.java | 4 +-
modules/spring-tx-ext/pom.xml | 43 ++++
.../src/test/java/config/ignite-client-node.xml | 53 ++++
.../IgniteSpringTransactionsTestSuite.java | 4 +-
.../IgniteSpringTransactionsCompatibilityTest.java | 265 ++++++++++++++++++++
8 files changed, 739 insertions(+), 2 deletions(-)
diff --git a/modules/spring-cache-ext/pom.xml b/modules/spring-cache-ext/pom.xml
index c7c399e..37a1441 100644
--- a/modules/spring-cache-ext/pom.xml
+++ b/modules/spring-cache-ext/pom.xml
@@ -70,6 +70,14 @@
<dependency>
<groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-compatibility</artifactId>
+ <version>${ignite.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
<artifactId>ignite-log4j</artifactId>
<version>${ignite.version}</version>
<scope>test</scope>
@@ -91,7 +99,35 @@
</dependency>
</dependencies>
+ <!--
+ We need this repository because the com.ibm.websphere:uow:6.0.2.17 dependency has been removed from the
+ Maven central repository. We are concerned about this because org.springframework.spring-tx with versions 5.1.0
+ and earlier depend on it. Even so, it is marked as optional in the spring-tx pom file -
+ the Maven Dependency plugin, that we use in the compatibility tests to automate test dependencies downloading,
+ tries to load it.
+
+ @see IgniteSpringCacheCompatibilityTest
+ -->
+ <repositories>
+ <repository>
+ <id>maven-redhat-repo-id</id>
+ <name>maven-redhat-repo-name</name>
+ <url>https://origin-maven.repository.redhat.com/ga</url>
+ </repository>
+ </repositories>
+
<build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <useManifestOnlyJar>false</useManifestOnlyJar>
+ <forkCount>1</forkCount>
+ </configuration>
+ </plugin>
+ </plugins>
+
<testResources>
<testResource>
<directory>src/test/java</directory>
diff --git a/modules/spring-cache-ext/src/test/java/config/ignite-client-node.xml b/modules/spring-cache-ext/src/test/java/config/ignite-client-node.xml
new file mode 100644
index 0000000..5819881
--- /dev/null
+++ b/modules/spring-cache-ext/src/test/java/config/ignite-client-node.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite configuration with all defaults and enabled events.
+ Used for testing IgniteSink running Ignite in a client mode.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Enable client mode. -->
+ <property name="clientMode" value="true"/>
+
+ <property name="igniteInstanceName" value="ignite-client-node"/>
+
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="binaryConfiguration">
+ <bean class="org.apache.ignite.configuration.BinaryConfiguration">
+ <property name="compactFooter" value="true"/>
+ </bean>
+ </property>
+
+ <property name="localHost" value="127.0.0.1"/>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
diff --git a/modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteSpringCacheCompatibilityTest.java b/modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteSpringCacheCompatibilityTest.java
new file mode 100644
index 0000000..81f0829
--- /dev/null
+++ b/modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteSpringCacheCompatibilityTest.java
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.spring;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.client.ClientCache;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.compatibility.testframework.junits.Dependency;
+import org.apache.ignite.compatibility.testframework.junits.IgniteCompatibilityAbstractTest;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.GridJavaProcess;
+import org.apache.ignite.internal.util.typedef.F;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.KeyGenerator;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import static org.apache.ignite.compatibility.IgniteReleasedVersion.VER_2_11_0;
+import static org.apache.ignite.compatibility.IgniteReleasedVersion.since;
+import static org.apache.ignite.configuration.ClientConnectorConfiguration.DFLT_PORT;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
+import static org.apache.ignite.testframework.GridTestUtils.cartesianProduct;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+@RunWith(Parameterized.class)
+public class IgniteSpringCacheCompatibilityTest extends IgniteCompatibilityAbstractTest {
+ /** */
+ private static final Collection<String> TEST_SPRING_VERSIONS = Arrays.asList(
+ "4.3.0.RELEASE",
+ "5.0.0.RELEASE",
+ "5.1.0.RELEASE",
+ "5.2.0.RELEASE",
+ "5.3.0"
+ );
+
+ /** */
+ private static final String TEST_CACHE_NAME = "testCache";
+
+ /** */
+ @Parameterized.Parameters(name = "Ignite Version {0}, Spring Version {1}")
+ public static Iterable<Object[]> versions() {
+ return cartesianProduct(F.concat(true, VER_STR, since(VER_2_11_0)), TEST_SPRING_VERSIONS);
+ }
+
+ /** */
+ @Parameterized.Parameter
+ public String igniteVer;
+
+ /** */
+ @Parameterized.Parameter(1)
+ public String springVer;
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected @NotNull Collection<Dependency> getDependencies(String ver) {
+ if (!F.isEmpty(ver))
+ return super.getDependencies(ver);
+
+ Collection<Dependency> res = new ArrayList<>();
+
+ res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, false));
+ res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, true));
+ res.add(new Dependency("spring", "org.apache.ignite", "ignite-spring", igniteVer, false));
+
+ res.add(new Dependency("spring-context", "org.springframework", "spring-context", springVer, false));
+ res.add(new Dependency("spring-beans", "org.springframework", "spring-beans", springVer, false));
+ res.add(new Dependency("spring-core", "org.springframework", "spring-core", springVer, false));
+ res.add(new Dependency("spring-aop", "org.springframework", "spring-aop", springVer, false));
+ res.add(new Dependency("spring-expression", "org.springframework", "spring-expression", springVer, false));
+
+ if (VER_2_11_0.toString().equals(igniteVer)) {
+ res.add(new Dependency("spring-tx", "org.springframework", "spring-tx", springVer, false));
+ res.add(new Dependency("spring-jdbc", "org.springframework", "spring-jdbc", springVer, false));
+ }
+
+ return res;
+ }
+
+ /** */
+ protected void processNodeConfiguration(IgniteConfiguration cfg) {
+ cfg.setCacheConfiguration(new CacheConfiguration<>(TEST_CACHE_NAME))
+ .setBinaryConfiguration(new BinaryConfiguration()
+ .setCompactFooter(true));
+ }
+
+ /** */
+ @Test
+ public void testCompatibility() throws Exception {
+ startGrid(1, igniteVer, this::processNodeConfiguration, ignite -> {});
+
+ GridJavaProcess proc = GridJavaProcess.exec(
+ TestRunner.class.getName(),
+ "",
+ log,
+ log::info,
+ null,
+ null,
+ getProcessProxyJvmArgs(""),
+ null
+ );
+
+ try {
+ assertTrue(waitForCondition(() -> !proc.getProcess().isAlive(), getTestTimeout()));
+
+ assertEquals(0, proc.getProcess().exitValue());
+ }
+ finally {
+ if (proc.getProcess().isAlive())
+ proc.kill();
+ }
+ }
+
+ /** */
+ public static class TestRunner {
+ /** */
+ private static void doIgniteClientConnectionTest() {
+ try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
+ ctx.register(ClientInstanceApplicationContext.class);
+ ctx.refresh();
+
+ GridSpringCacheTestService svc = ctx.getBean(GridSpringCacheTestService.class);
+
+ IgniteClient cli = ctx.getBean(IgniteClient.class);
+
+ ClientCache<Integer, String> cache = cli.cache(TEST_CACHE_NAME);
+
+ cache.clear();
+ svc.reset();
+
+ for (int i = 0; i < 3; i++) {
+ assertEquals("value" + i, svc.simpleKey(i));
+ assertEquals("value" + i, svc.simpleKey(i));
+ }
+
+ assertEquals(3, svc.called());
+ assertEquals(3, cache.size());
+
+ for (int i = 0; i < 3; i++)
+ assertEquals("value" + i, cache.get(i));
+ }
+ }
+
+ /** */
+ private static void doIgniteNodeConnectionTest() {
+ try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
+ ctx.register(IgniteNodeApplicationContext.class);
+ ctx.refresh();
+
+ GridSpringCacheTestService svc = ctx.getBean(GridSpringCacheTestService.class);
+
+ Ignite cli = ctx.getBean(Ignite.class);
+
+ IgniteCache<Integer, String> cache = cli.cache(TEST_CACHE_NAME);
+
+ cache.clear();
+ svc.reset();
+
+ for (int i = 0; i < 3; i++) {
+ assertEquals("value" + i, svc.simpleKey(i));
+ assertEquals("value" + i, svc.simpleKey(i));
+ }
+
+ assertEquals(3, svc.called());
+ assertEquals(3, cache.size());
+
+ for (int i = 0; i < 3; i++)
+ assertEquals("value" + i, cache.get(i));
+ }
+ }
+
+ /** */
+ public static void main(String[] args) {
+ doIgniteNodeConnectionTest();
+
+ doIgniteClientConnectionTest();
+ }
+
+ /** */
+ @Configuration
+ @EnableCaching
+ public static class ClientInstanceApplicationContext extends CachingConfigurerSupport {
+ /** */
+ @Bean
+ public GridSpringCacheTestService cacheService() {
+ return new GridSpringCacheTestService();
+ }
+
+ /** */
+ @Bean
+ public IgniteClient igniteClient() {
+ return Ignition.startClient(new ClientConfiguration()
+ .setAddresses("127.0.0.1:" + DFLT_PORT)
+ .setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true)));
+ }
+
+ /** */
+ @Bean
+ public AbstractCacheManager cacheManager(IgniteClient cli) {
+ return new IgniteClientSpringCacheManager().setClientInstance(cli);
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyGenerator keyGenerator() {
+ return new GridSpringCacheTestKeyGenerator();
+ }
+ }
+
+ /** */
+ @Configuration
+ @EnableCaching
+ public static class IgniteNodeApplicationContext extends CachingConfigurerSupport {
+ /** */
+ @Bean
+ public GridSpringCacheTestService cacheService() {
+ return new GridSpringCacheTestService();
+ }
+
+ /** */
+ @Bean
+ public Ignite igniteInstance() {
+ return Ignition.start("config/ignite-client-node.xml");
+ }
+
+ /** */
+ @Bean
+ @Override public AbstractCacheManager cacheManager() {
+ SpringCacheManager mgr = new SpringCacheManager();
+
+ mgr.setIgniteInstanceName("ignite-client-node");
+
+ return mgr;
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyGenerator keyGenerator() {
+ return new GridSpringCacheTestKeyGenerator();
+ }
+ }
+ }
+}
+
diff --git a/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java b/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java
index 0c5dc9e..560df16 100644
--- a/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java
+++ b/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java
@@ -21,6 +21,7 @@ import org.apache.ignite.cache.spring.GridSpringCacheManagerMultiJvmSelfTest;
import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest;
import org.apache.ignite.cache.spring.GridSpringCacheManagerSpringBeanSelfTest;
import org.apache.ignite.cache.spring.IgniteClientSpringCacheManagerTest;
+import org.apache.ignite.cache.spring.IgniteSpringCacheCompatibilityTest;
import org.apache.ignite.cache.spring.SpringCacheManagerContextInjectionTest;
import org.apache.ignite.cache.spring.SpringCacheTest;
import org.junit.runner.RunWith;
@@ -36,7 +37,8 @@ import org.junit.runners.Suite;
SpringCacheManagerContextInjectionTest.class,
SpringCacheTest.class,
GridSpringCacheManagerMultiJvmSelfTest.class,
- IgniteClientSpringCacheManagerTest.class
+ IgniteClientSpringCacheManagerTest.class,
+ IgniteSpringCacheCompatibilityTest.class
})
public class IgniteSpringCacheTestSuite {
}
diff --git a/modules/spring-tx-ext/pom.xml b/modules/spring-tx-ext/pom.xml
index 268c6a1..530d3f8 100644
--- a/modules/spring-tx-ext/pom.xml
+++ b/modules/spring-tx-ext/pom.xml
@@ -92,6 +92,21 @@
</dependency>
<dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>${xstream.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-compatibility</artifactId>
+ <version>${ignite.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring-data-commons</artifactId>
<version>${ignite-spring-data-commons.version}</version>
@@ -99,7 +114,35 @@
</dependency>
</dependencies>
+ <!--
+ We need this repository because the com.ibm.websphere:uow:6.0.2.17 dependency has been removed from the
+ Maven central repository. We are concerned about this because org.springframework.spring-tx with versions 5.1.0
+ and earlier depend on it. Even so, it is marked as optional in the spring-tx pom file -
+ the Maven Dependency plugin, that we use in the compatibility tests to automate test dependencies downloading,
+ tries to load it.
+
+ @see IgniteSpringTransactionsCompatibilityTest
+ -->
+ <repositories>
+ <repository>
+ <id>maven-redhat-repo-id</id>
+ <name>maven-redhat-repo-name</name>
+ <url>https://origin-maven.repository.redhat.com/ga</url>
+ </repository>
+ </repositories>
+
<build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <useManifestOnlyJar>false</useManifestOnlyJar>
+ <forkCount>1</forkCount>
+ </configuration>
+ </plugin>
+ </plugins>
+
<testResources>
<testResource>
<directory>src/test/java</directory>
diff --git a/modules/spring-tx-ext/src/test/java/config/ignite-client-node.xml b/modules/spring-tx-ext/src/test/java/config/ignite-client-node.xml
new file mode 100644
index 0000000..6bc9587
--- /dev/null
+++ b/modules/spring-tx-ext/src/test/java/config/ignite-client-node.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite configuration with all defaults and enabled events.
+ Used for testing IgniteSink running Ignite in a client mode.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <!-- Enable client mode. -->
+ <property name="clientMode" value="true"/>
+
+ <property name="igniteInstanceName" value="ignite-client-node"/>
+
+ <property name="peerClassLoadingEnabled" value="true"/>
+
+ <property name="localHost" value="127.0.0.1"/>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
diff --git a/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java b/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java
index 4034111..643d71e 100644
--- a/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java
+++ b/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java
@@ -21,6 +21,7 @@ import org.apache.ignite.cache.store.spring.CacheSpringStoreSessionListenerSelfT
import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSelfTest;
import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSpringBeanSelfTest;
import org.apache.ignite.transactions.spring.IgniteClientSpringTransactionManagerTest;
+import org.apache.ignite.transactions.spring.IgniteSpringTransactionsCompatibilityTest;
import org.apache.ignite.transactions.spring.SpringTransactionManagerContextInjectionTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -34,7 +35,8 @@ import org.junit.runners.Suite;
GridSpringTransactionManagerSpringBeanSelfTest.class,
IgniteClientSpringTransactionManagerTest.class,
SpringTransactionManagerContextInjectionTest.class,
- CacheSpringStoreSessionListenerSelfTest.class
+ CacheSpringStoreSessionListenerSelfTest.class,
+ IgniteSpringTransactionsCompatibilityTest.class
})
public class IgniteSpringTransactionsTestSuite {
}
diff --git a/modules/spring-tx-ext/src/test/java/org/apache/ignite/transactions/spring/IgniteSpringTransactionsCompatibilityTest.java b/modules/spring-tx-ext/src/test/java/org/apache/ignite/transactions/spring/IgniteSpringTransactionsCompatibilityTest.java
new file mode 100644
index 0000000..3ca2733
--- /dev/null
+++ b/modules/spring-tx-ext/src/test/java/org/apache/ignite/transactions/spring/IgniteSpringTransactionsCompatibilityTest.java
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.transactions.spring;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.client.ClientCache;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.compatibility.testframework.junits.Dependency;
+import org.apache.ignite.compatibility.testframework.junits.IgniteCompatibilityAbstractTest;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.GridJavaProcess;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteProductVersion;
+import org.apache.ignite.springdata.proxy.IgniteCacheProxy;
+import org.apache.ignite.springdata.proxy.IgniteClientCacheProxy;
+import org.apache.ignite.springdata.proxy.IgniteNodeCacheProxy;
+import org.jetbrains.annotations.NotNull;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.compatibility.IgniteReleasedVersion.VER_2_11_0;
+import static org.apache.ignite.compatibility.IgniteReleasedVersion.VER_2_8_0;
+import static org.apache.ignite.compatibility.IgniteReleasedVersion.since;
+import static org.apache.ignite.configuration.ClientConnectorConfiguration.DFLT_PORT;
+import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
+import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.apache.ignite.testframework.GridTestUtils.cartesianProduct;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
+
+/** */
+@RunWith(Parameterized.class)
+public class IgniteSpringTransactionsCompatibilityTest extends IgniteCompatibilityAbstractTest {
+ /** */
+ private static final Collection<String> TEST_SPRING_VERSIONS = Arrays.asList(
+ "4.3.0.RELEASE",
+ "5.0.0.RELEASE",
+ "5.1.0.RELEASE",
+ "5.2.0.RELEASE",
+ "5.3.0"
+ );
+
+ /** */
+ private static final String TEST_CACHE_NAME = "testCache";
+
+ /** */
+ @Parameterized.Parameters(name = "IgniteVersion={0}, SpringVersion={1}")
+ public static Iterable<Object[]> versions() {
+ return cartesianProduct(F.concat(true, VER_STR, since(VER_2_8_0)), TEST_SPRING_VERSIONS);
+
+ }
+
+ /** */
+ @Parameterized.Parameter
+ public String igniteVer;
+
+ /** */
+ @Parameterized.Parameter(1)
+ public String springVer;
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected @NotNull Collection<Dependency> getDependencies(String ver) {
+ if (!F.isEmpty(ver))
+ return super.getDependencies(ver);
+
+ Collection<Dependency> res = new ArrayList<>();
+
+ res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, false));
+ res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, true));
+ res.add(new Dependency("spring", "org.apache.ignite", "ignite-spring", igniteVer, false));
+
+ res.add(new Dependency("spring-tx", "org.springframework", "spring-tx", springVer, false));
+ res.add(new Dependency("spring-context", "org.springframework", "spring-context", springVer, false));
+ res.add(new Dependency("spring-beans", "org.springframework", "spring-beans", springVer, false));
+ res.add(new Dependency("spring-core", "org.springframework", "spring-core", springVer, false));
+ res.add(new Dependency("spring-aop", "org.springframework", "spring-aop", springVer, false));
+ res.add(new Dependency("spring-expression", "org.springframework", "spring-expression", springVer, false));
+
+ if (IgniteProductVersion.fromString(igniteVer).compareTo(VER_2_11_0.version()) <= 0)
+ res.add(new Dependency("spring-jdbc", "org.springframework", "spring-jdbc", springVer, false));
+
+ return res;
+ }
+
+ /** */
+ protected void processNodeConfiguration(IgniteConfiguration cfg) {
+ cfg.setCacheConfiguration(new CacheConfiguration<>(TEST_CACHE_NAME)
+ .setAtomicityMode(TRANSACTIONAL));
+ }
+
+ /** */
+ @Test
+ public void testCompatibility() throws Exception {
+ startGrid(1, igniteVer, this::processNodeConfiguration, ignite -> {});
+
+ GridJavaProcess proc = GridJavaProcess.exec(
+ TestRunner.class.getName(),
+ "",
+ log,
+ log::info,
+ null,
+ null,
+ getProcessProxyJvmArgs(""),
+ null
+ );
+
+ try {
+ assertTrue(waitForCondition(() -> !proc.getProcess().isAlive(), getTestTimeout()));
+
+ assertEquals(0, proc.getProcess().exitValue());
+ }
+ finally {
+ if (proc.getProcess().isAlive())
+ proc.kill();
+ }
+ }
+
+ /** */
+ public static class TestRunner {
+ /** */
+ private static void doIgniteClientConnectionTest() {
+ try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
+ ctx.register(IgniteClientSpringTransactionManagerApplicationContext.class);
+ ctx.refresh();
+
+ GridSpringTransactionService svc = ctx.getBean(GridSpringTransactionService.class);
+
+ IgniteClient cli = ctx.getBean(IgniteClient.class);
+
+ ClientCache<Integer, String> cache = cli.cache(TEST_CACHE_NAME);
+
+ cache.clear();
+
+ IgniteCacheProxy<Integer, String> cacheProxy = new IgniteClientCacheProxy<>(cache);
+
+ svc.put(cacheProxy, 1);
+
+ assertThrowsWithCause(() -> svc.putWithError(cacheProxy, 1), NumberFormatException.class);
+
+ assertEquals(1, cache.size());
+ }
+ }
+
+ /** */
+ private static void doIgniteNodeConnectionTest() {
+ try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
+ ctx.register(IgniteNodeSpringTransactionManagerApplicationContext.class);
+ ctx.refresh();
+
+ GridSpringTransactionService svc = ctx.getBean(GridSpringTransactionService.class);
+
+ Ignite cli = ctx.getBean(Ignite.class);
+
+ IgniteCache<Integer, String> cache = cli.cache(TEST_CACHE_NAME);
+
+ cache.clear();
+
+ IgniteCacheProxy<Integer, String> cacheProxy = new IgniteNodeCacheProxy<>(cache);
+
+ svc.put(cacheProxy, 1);
+
+ assertThrowsWithCause(() -> svc.putWithError(cacheProxy, 1), NumberFormatException.class);
+
+ assertEquals(1, cache.size());
+ }
+ }
+
+ /** */
+ public static void main(String[] args) {
+ doIgniteNodeConnectionTest();
+
+ doIgniteClientConnectionTest();
+ }
+
+ /** */
+ @Configuration
+ @EnableTransactionManagement
+ public static class IgniteNodeSpringTransactionManagerApplicationContext {
+ /** */
+ @Bean
+ public GridSpringTransactionService transactionService() {
+ return new GridSpringTransactionService();
+ }
+
+ /** */
+ @Bean
+ public Ignite ignite() {
+ return Ignition.start("config/ignite-client-node.xml");
+ }
+
+ /** */
+ @Bean
+ public AbstractSpringTransactionManager transactionManager() {
+ SpringTransactionManager mgr = new SpringTransactionManager();
+
+ mgr.setIgniteInstanceName("ignite-client-node");
+
+ return mgr;
+ }
+ }
+
+ /** */
+ @Configuration
+ @EnableTransactionManagement
+ public static class IgniteClientSpringTransactionManagerApplicationContext {
+ /** */
+ @Bean
+ public GridSpringTransactionService transactionService() {
+ return new GridSpringTransactionService();
+ }
+
+ /** */
+ @Bean
+ public IgniteClient igniteClient() {
+ return Ignition.startClient(new ClientConfiguration()
+ .setAddresses("127.0.0.1:" + DFLT_PORT));
+ }
+
+ /** */
+ @Bean
+ public AbstractSpringTransactionManager transactionManager(IgniteClient cli) {
+ IgniteClientSpringTransactionManager mgr = new IgniteClientSpringTransactionManager();
+
+ mgr.setClientInstance(cli);
+
+ return mgr;
+ }
+ }
+ }
+}
+