Start version 2.0.0

Fixes https://github.com/spring-projects/spring-integration-extensions/issues/197

* Upgrade dependencies
* Fix deprecations; logic according new Hazelcast
* Fix tests for CP Subsystem
* Upgrade Gradle
* Prepare for release
This commit is contained in:
Artem Bilan
2019-11-05 14:50:30 -05:00
parent f6f686f128
commit fe6ffee60c
50 changed files with 475 additions and 274 deletions

View File

@@ -535,4 +535,6 @@ public LockRegistry lockRegistry() {
}
```
When used with a shared `MessageGroupStore` (e.g. `Aggregator` store management), the `HazelcastLockRegistry` can be use to provide this functionality across multiple application instances, such that only one instance can manipulate the group at a time.
When used with a shared `MessageGroupStore` (e.g. `Aggregator` store management), the `HazelcastLockRegistry` can be use to provide this functionality across multiple application instances, such that only one instance can manipulate the group at a time.
NOTE: For all the distributed operations the CP Subsystem must be enabled on `HazelcastInstance`.

View File

@@ -1,22 +1,13 @@
buildscript {
repositories {
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.2.RELEASE'
classpath 'io.spring.gradle:spring-io-plugin:0.0.8.RELEASE'
}
}
plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'jacoco'
id 'org.sonarqube' version '2.8'
id 'checkstyle'
id 'org.sonarqube' version '2.5'
id 'org.ajoberstar.grgit' version '3.1.1'
id "io.spring.dependency-management" version '1.0.8.RELEASE'
}
description = 'Spring Integration Hazelcast Support'
apply from: "${rootProject.projectDir}/publish-maven.gradle"
@@ -30,32 +21,15 @@ repositories {
maven { url 'https://repo.spring.io/libs-milestone' }
}
if (project.hasProperty('platformVersion')) {
apply plugin: 'spring-io'
dependencyManagement {
springIoTestRuntime {
imports {
mavenBom "io.spring.platform:platform-bom:${platformVersion}"
}
}
}
}
compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
ext {
hazelcastVersion = '3.8.9'
slf4jVersion = '1.7.25'
springIntegrationVersion = '4.3.20.BUILD-SNAPSHOT'
hazelcastVersion = '3.12.4'
slf4jVersion = '1.7.28'
springIntegrationVersion = '5.2.1.RELEASE'
idPrefix = 'hazelcast'
@@ -78,12 +52,12 @@ sourceSets {
}
jacoco {
toolVersion = "0.7.9"
toolVersion = '0.8.4'
}
checkstyle {
configFile = file("$rootDir/src/checkstyle/checkstyle.xml")
toolVersion = "8.0"
toolVersion = '8.25'
}
// enable all compiler warnings; individual projects may customize further
@@ -103,9 +77,9 @@ dependencies {
test {
// suppress all console output during testing unless running `gradle -i`
logging.captureStandardOutput(LogLevel.INFO)
jvmArgs "-Dhazelcast.logging.type=slf4j"
jvmArgs '-Dhazelcast.logging.type=slf4j'
maxHeapSize = "1024m"
maxHeapSize = '1024m'
jacoco {
append = false
destinationFile = file("$buildDir/jacoco.exec")
@@ -121,12 +95,12 @@ jacocoTestReport {
}
task sourcesJar(type: Jar) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc
}
@@ -137,13 +111,13 @@ artifacts {
sonarqube {
properties {
property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
property "sonar.links.homepage", linkHomepage
property "sonar.links.ci", linkCi
property "sonar.links.issue", linkIssue
property "sonar.links.scm", linkScmUrl
property "sonar.links.scm_dev", linkScmDevConnection
property "sonar.java.coveragePlugin", "jacoco"
property 'sonar.jacoco.reportPath', "${buildDir.name}/jacoco.exec"
property 'sonar.links.homepage', linkHomepage
property 'sonar.links.ci', linkCi
property 'sonar.links.issue', linkIssue
property 'sonar.links.scm', linkScmUrl
property 'sonar.links.scm_dev', linkScmDevConnection
property 'sonar.java.coveragePlugin', 'jacoco'
}
}
@@ -155,17 +129,17 @@ task api(type: Javadoc) {
options.author = true
options.header = rootProject.description
options.overview = 'src/api/overview.html'
options.stylesheetFile = file("src/api/stylesheet.css")
options.stylesheetFile = file('src/api/stylesheet.css')
source = sourceSets.main.allJava
classpath = project.sourceSets.main.compileClasspath
destinationDir = new File(buildDir, "api")
destinationDir = new File(buildDir, 'api')
}
task schemaZip(type: Zip) {
group = 'Distribution'
classifier = 'schema'
description = "Builds -${classifier} archive containing all " +
archiveClassifier = 'schema'
description = "Builds -${archiveClassifier} archive containing all " +
"XSDs for deployment at static.springframework.org/schema."
duplicatesStrategy = 'exclude'
@@ -190,8 +164,8 @@ task schemaZip(type: Zip) {
task docsZip(type: Zip) {
group = 'Distribution'
classifier = 'docs'
description = "Builds -${classifier} archive containing api " +
archiveClassifier = 'docs'
description = "Builds -${archiveClassifier} archive containing api " +
"for deployment at static.spring.io/spring-integration/docs."
from('src/dist') {
@@ -205,8 +179,8 @@ task docsZip(type: Zip) {
task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
group = 'Distribution'
classifier = 'dist'
description = "Builds -${classifier} archive, containing all jars and docs, " +
archiveClassifier = 'dist'
description = "Builds -${archiveClassifier} archive, containing all jars and docs, " +
"suitable for community download page."
ext.baseDir = "${project.name}-${project.version}";
@@ -218,11 +192,11 @@ task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
into "${baseDir}"
}
from(zipTree(docsZip.archivePath)) {
from(zipTree(docsZip.archiveFile)) {
into "${baseDir}/docs"
}
from(zipTree(schemaZip.archivePath)) {
from(zipTree(schemaZip.archiveFile)) {
into "${baseDir}/schema"
}
@@ -237,11 +211,11 @@ task distZip(type: Zip, dependsOn: [docsZip, schemaZip]) {
// Not published by default; only for use when building from source.
task depsZip(type: Zip, dependsOn: distZip) { zipTask ->
group = 'Distribution'
classifier = 'dist-with-deps'
description = "Builds -${classifier} archive, containing everything " +
"in the -${distZip.classifier} archive plus all dependencies."
archiveClassifier = 'dist-with-deps'
description = "Builds -${archiveClassifier} archive, containing everything " +
"in the -${distZip.archiveClassifier} archive plus all dependencies."
from zipTree(distZip.archivePath)
from zipTree(distZip.archiveFile)
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(":${zipTask.name}")) {

View File

@@ -1,2 +1 @@
version=1.0.1.BUILD-SNAPSHOT
org.gradle.daemon=true
version=2.0.0.BUILD-SNAPSHOT

View File

@@ -1,6 +1,5 @@
#Fri Jul 07 17:27:53 EDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip

View File

@@ -1,5 +1,21 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed 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
#
# https://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.
#
##############################################################################
##
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

View File

@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@@ -14,6 +14,17 @@ install {
def customizePom(pom, gradleProject) {
pom.whenConfigured { generatedPom ->
// sort to make pom dependencies order consistent to ease comparison of older poms
generatedPom.dependencies = generatedPom.dependencies.sort { dep ->
"$dep.scope:$dep.groupId:$dep.artifactId"
}
def managedVersions = dependencyManagement.managedVersions
generatedPom.dependencies.findAll{dep -> !dep.version }.each { dep ->
dep.version = managedVersions["${dep.groupId}:${dep.artifactId}"]
}
// respect 'optional' and 'provided' dependencies
gradleProject.optionalDeps.each { dep ->
generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true
@@ -31,7 +42,7 @@ def customizePom(pom, gradleProject) {
generatedPom.project {
name = gradleProject.description
description = gradleProject.description
url = linkHomepage
url = 'https://github.com/spring-projects/spring-integration-aws'
organization {
name = 'SpringIO'
url = 'https://spring.io'
@@ -43,18 +54,27 @@ def customizePom(pom, gradleProject) {
distribution 'repo'
}
}
scm {
url = linkScmUrl
connection = 'scm:git:' + linkScmConnection
developerConnection = 'scm:git:' + linkScmDevConnection
url = 'https://github.com/spring-projects/spring-integration-aws'
connection = 'scm:git:git://github.com/spring-projects/spring-integration-aws'
developerConnection = 'scm:git:git://github.com/spring-projects/spring-integration-aws'
}
developers {
developer {
id = 'erenavsarogullari'
name = 'Eren Avsarogullari'
email = 'erenavsarogullari@gmail.com'
id = 'amolnayak311'
name = 'Amol Nayak'
email = 'amolnayak311@gmail.com'
}
developer {
id = 'ghillert'
name = 'Gunnar Hillert'
email = 'ghillert@pivotal.io'
}
developer {
id = 'abilan'
name = 'Artem Bilan'
email = 'abilan@pivotal.io'
}
}
}

View File

@@ -103,9 +103,7 @@
<property name="scope" value="package"/>
<property name="authorFormat" value=".+\s.+"/>
</module>
<module name="JavadocMethod">
<property name="allowMissingJavadoc" value="true" />
</module>
<module name="JavadocMethod"/>
<module name="JavadocVariable">
<property name="scope" value="public"/>
</module>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -96,7 +96,7 @@ public class HazelcastLocalInstanceRegistrar implements SmartInitializingSinglet
}
private void syncConfigurationMultiMap(HazelcastInstance hazelcastInstance) {
Lock lock = hazelcastInstance.getLock(SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK);
Lock lock = hazelcastInstance.getCPSubsystem().getLock(SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK);
lock.lock();
try {
MultiMap<SocketAddress, SocketAddress> multiMap = hazelcastInstance

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.MapEvent;
import com.hazelcast.core.MultiMap;
import com.hazelcast.instance.EndpointQualifier;
/**
* Hazelcast Base Event-Driven Message Producer.
@@ -118,10 +119,9 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
final Set<HazelcastInstance> hazelcastInstanceSet = Hazelcast.getAllHazelcastInstances();
final Set<SocketAddress> localSocketAddressesSet = getLocalSocketAddresses(hazelcastInstanceSet);
return localSocketAddressesSet.isEmpty() ||
(!localSocketAddressesSet.isEmpty()
&& (localSocketAddressesSet.contains(socketAddress) ||
isEventComingFromNonRegisteredHazelcastInstance(hazelcastInstanceSet.iterator().next(),
localSocketAddressesSet, socketAddress)));
localSocketAddressesSet.contains(socketAddress)
|| isEventComingFromNonRegisteredHazelcastInstance(hazelcastInstanceSet.iterator().next(),
localSocketAddressesSet, socketAddress);
}
@@ -193,19 +193,20 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
if (AbstractHazelcastMessageProducer.this.logger.isDebugEnabled()) {
AbstractHazelcastMessageProducer.this.logger.debug("Received Event : " + event);
}
sendMessage(event, event.getMember().getSocketAddress(), getCacheListeningPolicy());
sendMessage(event,
event.getMember().getSocketAddress(EndpointQualifier.MEMBER), getCacheListeningPolicy());
}
}
@Override
@SuppressWarnings("unchecked")
protected Message<?> toMessage(AbstractIMapEvent event) {
final Map<String, Object> headers = new HashMap<String, Object>();
final Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastHeaders.EVENT_TYPE, event.getEventType().name());
headers.put(HazelcastHeaders.MEMBER, event.getMember().getSocketAddress());
headers.put(HazelcastHeaders.MEMBER, event.getMember().getSocketAddress(EndpointQualifier.MEMBER));
headers.put(HazelcastHeaders.CACHE_NAME, event.getName());
if (event instanceof EntryEvent) {
@SuppressWarnings("unchecked")
EntryEvent<K, V> entryEvent = (EntryEvent<K, V>) event;
EntryEventMessagePayload<K, V> messagePayload = new EntryEventMessagePayload<>(entryEvent.getKey(),
entryEvent.getValue(), entryEvent.getOldValue());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2018 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import com.hazelcast.core.Message;
import com.hazelcast.core.MessageListener;
import com.hazelcast.core.MultiMap;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.instance.EndpointQualifier;
import com.hazelcast.map.listener.MapListener;
/**
@@ -140,7 +141,8 @@ public class HazelcastEventDrivenMessageProducer extends AbstractHazelcastMessag
@Override
protected void processEvent(ItemEvent<E> event) {
if (getCacheEvents().contains(event.getEventType().toString())) {
sendMessage(event, event.getMember().getSocketAddress(), getCacheListeningPolicy());
sendMessage(event,
event.getMember().getSocketAddress(EndpointQualifier.MEMBER), getCacheListeningPolicy());
}
if (logger.isDebugEnabled()) {
@@ -152,7 +154,7 @@ public class HazelcastEventDrivenMessageProducer extends AbstractHazelcastMessag
protected org.springframework.messaging.Message<?> toMessage(ItemEvent<E> event) {
final Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastHeaders.EVENT_TYPE, event.getEventType().name());
headers.put(HazelcastHeaders.MEMBER, event.getMember().getSocketAddress());
headers.put(HazelcastHeaders.MEMBER, event.getMember().getSocketAddress(EndpointQualifier.MEMBER));
return getMessageBuilderFactory().withPayload(event.getItem()).copyHeaders(headers).build();
}
@@ -169,7 +171,8 @@ public class HazelcastEventDrivenMessageProducer extends AbstractHazelcastMessag
@Override
protected void processEvent(Message<E> event) {
sendMessage(event, event.getPublishingMember().getSocketAddress(), getCacheListeningPolicy());
sendMessage(event,
event.getPublishingMember().getSocketAddress(EndpointQualifier.MEMBER), getCacheListeningPolicy());
if (logger.isDebugEnabled()) {
logger.debug("Received Message : " + event);
@@ -181,7 +184,8 @@ public class HazelcastEventDrivenMessageProducer extends AbstractHazelcastMessag
Assert.notNull(event.getMessageObject(), "message must not be null");
final Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastHeaders.MEMBER, event.getPublishingMember().getSocketAddress());
headers.put(HazelcastHeaders.MEMBER,
event.getPublishingMember().getSocketAddress(EndpointQualifier.MEMBER));
headers.put(HazelcastHeaders.CACHE_NAME, event.getSource());
headers.put(HazelcastHeaders.PUBLISHING_TIME, event.getPublishTime());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2018 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ import org.springframework.integration.support.leader.LockRegistryLeaderInitiato
import org.springframework.util.Assert;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ILock;
import com.hazelcast.cp.lock.FencedLock;
/**
* Bootstrap leadership {@link org.springframework.integration.leader.Candidate candidates}
@@ -106,7 +106,7 @@ public class LeaderInitiator implements SmartLifecycle, DisposableBean, Applicat
/**
* Hazelcast distributed lock.
*/
private volatile ILock lock;
private volatile FencedLock lock;
private boolean customPublisher = false;
@@ -210,7 +210,7 @@ public class LeaderInitiator implements SmartLifecycle, DisposableBean, Applicat
@Override
public synchronized void start() {
if (!this.running) {
this.lock = this.client.getLock(this.candidate.getRole());
this.lock = this.client.getCPSubsystem().getLock(this.candidate.getRole());
this.leaderSelector = new LeaderSelector();
this.running = true;
this.future = this.executorService.submit(this.leaderSelector);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,23 +27,28 @@ import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.MembershipAdapter;
import com.hazelcast.core.MembershipEvent;
import com.hazelcast.core.MultiMap;
import com.hazelcast.instance.EndpointQualifier;
/**
* Hazelcast {@link MembershipAdapter} in order to listen for membership updates in the cluster.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
public class HazelcastMembershipListener extends MembershipAdapter {
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
SocketAddress removedMemberSocketAddress = membershipEvent.getMember().getSocketAddress();
SocketAddress removedMemberSocketAddress =
membershipEvent.getMember().getSocketAddress(EndpointQualifier.MEMBER);
Set<HazelcastInstance> hazelcastLocalInstanceSet = Hazelcast.getAllHazelcastInstances();
if (!hazelcastLocalInstanceSet.isEmpty()) {
HazelcastInstance hazelcastInstance = hazelcastLocalInstanceSet.iterator().next();
Lock lock = hazelcastInstance
.getLock(HazelcastLocalInstanceRegistrar.SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK);
Lock lock =
hazelcastInstance.getCPSubsystem()
.getLock(HazelcastLocalInstanceRegistrar.SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK);
lock.lock();
try {
MultiMap<SocketAddress, SocketAddress> configMultiMap = hazelcastInstance

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public class HazelcastLockRegistry implements LockRegistry {
@Override
public Lock obtain(Object lockKey) {
Assert.isInstanceOf(String.class, lockKey);
return this.client.getLock((String) lockKey);
return this.client.getCPSubsystem().getLock((String) lockKey);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@ import com.hazelcast.core.MultiMap;
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
public class HazelcastCacheWritingMessageHandler extends AbstractMessageHandler {
@@ -71,14 +72,14 @@ public class HazelcastCacheWritingMessageHandler extends AbstractMessageHandler
}
@Override
protected void onInit() throws Exception {
protected void onInit() {
super.onInit();
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(getBeanFactory());
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
protected void handleMessageInternal(final Message<?> message) throws Exception {
protected void handleMessageInternal(final Message<?> message) {
Object objectToStore = message;
if (this.extractPayload) {
objectToStore = message.getPayload();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,6 +57,16 @@ public class HazelcastMessageStore extends AbstractKeyValueMessageStore {
this.map.put(id, objectToStore);
}
@Override
protected void doStoreIfAbsent(Object id, Object objectToStore) {
this.map.putIfAbsent(id, objectToStore);
}
@Override
protected void doRemoveAll(Collection<Object> ids) {
this.map.removeAll((mapEntry) -> ids.contains(mapEntry.getKey()));
}
@Override
protected Object doRemove(Object id) {
return this.map.remove(id);

View File

@@ -8,8 +8,7 @@
<constructor-arg value="distList"/>
</bean>
<bean id="hzInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<bean id="hzInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance">
<constructor-arg>
<bean class="com.hazelcast.config.Config">
<property name="instanceName" value="Test_Hazelcast_Instance"/>

View File

@@ -16,13 +16,14 @@
package org.springframework.integration.hazelcast;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,10 +33,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.core.IList;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Integration Definition Validator Test Class
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@@ -46,13 +51,18 @@ public class HazelcastIntegrationDefinitionValidatorTests {
@Resource
private IList<HazelcastIntegrationTestUser> distList;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testValidateEnumType() {
final String cacheEventTypes =
" ADDED, REMOVED, UPDATED, EVICTED, EVICT_ALL, CLEAR_ALL ";
final Set<String> typeSet = HazelcastIntegrationDefinitionValidator
.validateEnumType(CacheEventType.class, cacheEventTypes);
assertTrue(typeSet.size() == 6);
assertEquals(6, typeSet.size());
for (String type : typeSet) {
Enum.valueOf(CacheEventType.class, type);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@ import org.springframework.messaging.Message;
* {@link AbstractRequestHandlerAdvice} advice class for Hazelcast Integration Unit Tests.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
public class HazelcastTestRequestHandlerAdvice extends AbstractRequestHandlerAdvice {
@@ -36,7 +38,7 @@ public class HazelcastTestRequestHandlerAdvice extends AbstractRequestHandlerAdv
}
@Override
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) throws Exception {
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) {
try {
return callback.execute();
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<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="instance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance">
<constructor-arg>
<bean class="com.hazelcast.config.Config">
<property name="CPSubsystemConfig">
<bean class="com.hazelcast.config.cp.CPSubsystemConfig">
<property name="CPMemberCount" value="3"/>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
<bean id="instance2" parent="instance"/>
<bean id="instance3" parent="instance"/>
</beans>

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="cqMapChannel1">
<int:queue/>
</int:channel>
@@ -32,41 +34,38 @@
<int-hazelcast:cq-inbound-channel-adapter channel="cqMapChannel1" cache="cqDistributedMap1"
predicate="name=TestName1"/>
<int-hazelcast:cq-inbound-channel-adapter channel="cqMapChannel2" cache="cqDistributedMap2" cache-events="REMOVED"
predicate="name=TestName2" include-value="true"/>
predicate="name=TestName2"/>
<int-hazelcast:cq-inbound-channel-adapter channel="cqMapChannel3" cache="cqDistributedMap3"
cache-events="ADDED,REMOVED,UPDATED,CLEAR_ALL"
predicate="name=TestName1 OR name=TestName2"/>
<int-hazelcast:cq-inbound-channel-adapter channel="cqMapChannel4" cache="cqDistributedMap4" cache-events="UPDATED"
predicate="surname=TestSurname2" include-value="true"/>
predicate="surname=TestSurname2"/>
<int-hazelcast:cq-inbound-channel-adapter channel="cqMapChannel5" cache="cqDistributedMap5" cache-events="UPDATED"
predicate="surname=TestSurname2" include-value="false"/>
<bean id="cqDistributedMap1" factory-bean="cqInstance" factory-method="getMap">
<bean id="cqDistributedMap1" factory-bean="instance" factory-method="getMap">
<constructor-arg value="cqDistributedMap1"/>
</bean>
<bean id="cqDistributedMap2" factory-bean="cqInstance" factory-method="getMap">
<bean id="cqDistributedMap2" factory-bean="instance" factory-method="getMap">
<constructor-arg value="cqDistributedMap2"/>
</bean>
<bean id="cqDistributedMap3" factory-bean="cqInstance" factory-method="getMap">
<bean id="cqDistributedMap3" factory-bean="instance" factory-method="getMap">
<constructor-arg value="cqDistributedMap3"/>
</bean>
<bean id="cqDistributedMap4" factory-bean="cqInstance" factory-method="getMap">
<bean id="cqDistributedMap4" factory-bean="instance" factory-method="getMap">
<constructor-arg value="cqDistributedMap4"/>
</bean>
<bean id="cqDistributedMap5" factory-bean="cqInstance" factory-method="getMap">
<bean id="cqDistributedMap5" factory-bean="instance" factory-method="getMap">
<constructor-arg value="cqDistributedMap5"/>
</bean>
<bean id="cqInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -38,6 +39,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.core.IMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Continuous Query Inbound Channel Adapter Unit Test Class
@@ -81,6 +83,11 @@ public class HazelcastCQDistributedMapInboundChannelAdapterTests {
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap5;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testContinuousQueryForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.AfterClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,16 +44,18 @@ import com.hazelcast.core.IMap;
import com.hazelcast.core.LifecycleEvent;
import com.hazelcast.core.LifecycleEvent.LifecycleState;
import com.hazelcast.core.MigrationEvent;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Cluster Monitor Inbound Channel Adapter Unit Test Class
*
* @author Eren Avsarogullari
* @since 1.0.0
* @author Artem Bilan
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@DirtiesContext
@Ignore("Hard to reach CP consensus with limited number of members in two clusters")
public class HazelcastClusterMonitorInboundChannelAdapterTests {
private static final String TEST_GROUP_NAME1 = "Test_Group_Name1";
@@ -83,6 +87,11 @@ public class HazelcastClusterMonitorInboundChannelAdapterTests {
@Autowired
private HazelcastInstance hazelcastInstance3;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testMembershipEvent() {
HazelcastInboundChannelAdapterTestUtils
@@ -151,7 +160,6 @@ public class HazelcastClusterMonitorInboundChannelAdapterTests {
private HazelcastInstance getHazelcastClientByGroupName(final String groupName) {
final GroupConfig groupConfig = new GroupConfig();
groupConfig.setName(groupName);
groupConfig.setPassword("dev-pass");
final ClientConfig cfg = new ClientConfig();
cfg.setGroupConfig(groupConfig);
cfg.getNetworkConfig().addAddress("127.0.0.1:5701");

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="edListChannel1">
<int:queue/>
</int:channel>
@@ -23,28 +25,22 @@
</int:channel>
<int-hazelcast:inbound-channel-adapter channel="edListChannel1" cache="edDistributedList1"/>
<int-hazelcast:inbound-channel-adapter channel="edListChannel2" cache="edDistributedList2" cache-events="REMOVED"
cache-listening-policy="SINGLE"/>
<int-hazelcast:inbound-channel-adapter channel="edListChannel2" cache="edDistributedList2" cache-events="REMOVED"/>
<int-hazelcast:inbound-channel-adapter channel="edListChannel3" cache="edDistributedList3"
cache-events="ADDED,REMOVED"/>
<bean id="edDistributedList1" factory-bean="edListInstance" factory-method="getList">
<bean id="edDistributedList1" factory-bean="instance" factory-method="getList">
<constructor-arg value="edDistributedList1"/>
</bean>
<bean id="edDistributedList2" factory-bean="edListInstance" factory-method="getList">
<bean id="edDistributedList2" factory-bean="instance" factory-method="getList">
<constructor-arg value="edDistributedList2"/>
</bean>
<bean id="edDistributedList3" factory-bean="edListInstance" factory-method="getList">
<bean id="edDistributedList3" factory-bean="instance" factory-method="getList">
<constructor-arg value="edDistributedList3"/>
</bean>
<bean id="edListInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,6 +37,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.core.IList;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Distributed List Event Driven Inbound Channel Adapter Test Class
@@ -66,6 +68,11 @@ public class HazelcastDistributedListEventDrivenInboundChannelAdapterTests {
@Resource
private IList<HazelcastIntegrationTestUser> edDistributedList3;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedList1.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="edMapChannel1">
<int:queue/>
</int:channel>
@@ -27,33 +29,28 @@
</int:channel>
<int-hazelcast:inbound-channel-adapter channel="edMapChannel1" cache="edDistributedMap1"/>
<int-hazelcast:inbound-channel-adapter channel="edMapChannel2" cache="edDistributedMap2" cache-events="UPDATED"/>
<int-hazelcast:inbound-channel-adapter channel="edMapChannel3" cache="edDistributedMap3" cache-events="REMOVED"
cache-listening-policy="SINGLE"/>
<int-hazelcast:inbound-channel-adapter channel="edMapChannel3" cache="edDistributedMap3" cache-events="REMOVED"/>
<int-hazelcast:inbound-channel-adapter channel="edMapChannel4" cache="edDistributedMap4"
cache-events="ADDED,REMOVED,UPDATED,CLEAR_ALL"/>
<bean id="edDistributedMap1" factory-bean="edMapInstance" factory-method="getMap">
<bean id="edDistributedMap1" factory-bean="instance" factory-method="getMap">
<constructor-arg value="edDistributedMap1"/>
</bean>
<bean id="edDistributedMap2" factory-bean="edMapInstance" factory-method="getMap">
<bean id="edDistributedMap2" factory-bean="instance" factory-method="getMap">
<constructor-arg value="edDistributedMap2"/>
</bean>
<bean id="edDistributedMap3" factory-bean="edMapInstance" factory-method="getMap">
<bean id="edDistributedMap3" factory-bean="instance" factory-method="getMap">
<constructor-arg value="edDistributedMap3"/>
</bean>
<bean id="edDistributedMap4" factory-bean="edMapInstance" factory-method="getMap">
<bean id="edDistributedMap4" factory-bean="instance" factory-method="getMap">
<constructor-arg value="edDistributedMap4"/>
</bean>
<bean id="edMapInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.hazelcast.inbound;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,6 +36,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.core.IMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Distributed Map Event Driven Inbound Channel Adapter Test
@@ -72,6 +74,11 @@ public class HazelcastDistributedMapEventDrivenInboundChannelAdapterTests {
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap4;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="edQueueChannel1">
<int:queue/>
</int:channel>
@@ -22,30 +24,24 @@
<int:queue/>
</int:channel>
<int-hazelcast:inbound-channel-adapter channel="edQueueChannel1" cache="edDistributedQueue1"
cache-listening-policy="SINGLE"/>
<int-hazelcast:inbound-channel-adapter channel="edQueueChannel1" cache="edDistributedQueue1"/>
<int-hazelcast:inbound-channel-adapter channel="edQueueChannel2" cache="edDistributedQueue2"
cache-events="REMOVED"/>
<int-hazelcast:inbound-channel-adapter channel="edQueueChannel3" cache="edDistributedQueue3"
cache-events="ADDED,REMOVED"/>
<bean id="edDistributedQueue1" factory-bean="edQueueInstance" factory-method="getQueue">
<bean id="edDistributedQueue1" factory-bean="instance" factory-method="getQueue">
<constructor-arg value="edDistributedQueue1"/>
</bean>
<bean id="edDistributedQueue2" factory-bean="edQueueInstance" factory-method="getQueue">
<bean id="edDistributedQueue2" factory-bean="instance" factory-method="getQueue">
<constructor-arg value="edDistributedQueue2"/>
</bean>
<bean id="edDistributedQueue3" factory-bean="edQueueInstance" factory-method="getQueue">
<bean id="edDistributedQueue3" factory-bean="instance" factory-method="getQueue">
<constructor-arg value="edDistributedQueue3"/>
</bean>
<bean id="edQueueInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.hazelcast.inbound;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,6 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.core.IQueue;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Distributed Queue Event Driven Inbound Channel Adapter Test
@@ -64,6 +66,11 @@ public class HazelcastDistributedQueueEventDrivenInboundChannelAdapterTests {
@Resource
private IQueue<HazelcastIntegrationTestUser> edDistributedQueue3;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedQueue1

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="dsMapChannel1">
<int:queue/>
</int:channel>
@@ -37,36 +39,29 @@
</int-hazelcast:ds-inbound-channel-adapter>
<int-hazelcast:ds-inbound-channel-adapter channel="dsMapChannel3" cache="dsDistributedMap3"
iteration-type="LOCAL_KEY" distributed-sql="age > 10 AND age &lt;= 20">
iteration-type="KEY" distributed-sql="age > 10 AND age &lt;= 20">
<int:poller fixed-delay="100"/>
</int-hazelcast:ds-inbound-channel-adapter>
<int-hazelcast:ds-inbound-channel-adapter channel="dsMapChannel4" cache="dsDistributedMap4" iteration-type="VALUE"
<int-hazelcast:ds-inbound-channel-adapter channel="dsMapChannel4" cache="dsDistributedMap4"
distributed-sql="age > 20 AND age &lt;= 30">
<int:poller fixed-delay="100"/>
</int-hazelcast:ds-inbound-channel-adapter>
<bean id="dsDistributedMap1" factory-bean="dsInstance" factory-method="getMap">
<bean id="dsDistributedMap1" factory-bean="instance" factory-method="getMap">
<constructor-arg value="dsDistributedMap1"/>
</bean>
<bean id="dsDistributedMap2" factory-bean="dsInstance" factory-method="getMap">
<bean id="dsDistributedMap2" factory-bean="instance" factory-method="getMap">
<constructor-arg value="dsDistributedMap2"/>
</bean>
<bean id="dsDistributedMap3" factory-bean="dsInstance" factory-method="getMap">
<bean id="dsDistributedMap3" factory-bean="instance" factory-method="getMap">
<constructor-arg value="dsDistributedMap3"/>
</bean>
<bean id="dsDistributedMap4" factory-bean="dsInstance" factory-method="getMap">
<bean id="dsDistributedMap4" factory-bean="instance" factory-method="getMap">
<constructor-arg value="dsDistributedMap4"/>
</bean>
<bean id="dsInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.hazelcast.inbound;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,6 +31,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.IMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Distributed SQL Inbound Channel Adapter Test
@@ -66,6 +68,11 @@ public class HazelcastDistributedSQLInboundChannelAdapterTests {
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap4;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testDistributedSQLForOnlyENTRYIterationType() {
HazelcastInboundChannelAdapterTestUtils

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="edSetChannel1">
<int:queue/>
</int:channel>
@@ -25,25 +27,18 @@
<int-hazelcast:inbound-channel-adapter channel="edSetChannel1" cache="edDistributedSet1"/>
<int-hazelcast:inbound-channel-adapter channel="edSetChannel2" cache="edDistributedSet2" cache-events="REMOVED"/>
<int-hazelcast:inbound-channel-adapter channel="edSetChannel3" cache="edDistributedSet3"
cache-events="ADDED,REMOVED" cache-listening-policy="SINGLE"/>
cache-events="ADDED,REMOVED"/>
<bean id="edDistributedSet1" factory-bean="edSetInstance" factory-method="getSet">
<bean id="edDistributedSet1" factory-bean="instance" factory-method="getSet">
<constructor-arg value="edDistributedSet1"/>
</bean>
<bean id="edDistributedSet2" factory-bean="edSetInstance" factory-method="getSet">
<bean id="edDistributedSet2" factory-bean="instance" factory-method="getSet">
<constructor-arg value="edDistributedSet2"/>
</bean>
<bean id="edDistributedSet3" factory-bean="edSetInstance" factory-method="getSet">
<bean id="edDistributedSet3" factory-bean="instance" factory-method="getSet">
<constructor-arg value="edDistributedSet3"/>
</bean>
<bean id="edSetInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.hazelcast.inbound;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,6 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.core.ISet;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Distributed Set Event Driven Inbound Channel Adapter Test
@@ -64,6 +66,11 @@ public class HazelcastDistributedSetEventDrivenInboundChannelAdapterTests {
@Resource
private ISet<HazelcastIntegrationTestUser> edDistributedSet3;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedSet1

View File

@@ -10,21 +10,16 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="edTopicChannel1">
<int:queue/>
</int:channel>
<int-hazelcast:inbound-channel-adapter channel="edTopicChannel1" cache="edDistributedTopic1"/>
<bean id="edDistributedTopic1" factory-bean="edTopicInstance" factory-method="getTopic">
<bean id="edDistributedTopic1" factory-bean="instance" factory-method="getTopic">
<constructor-arg value="edDistributedTopic1"/>
</bean>
<bean id="edTopicInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.hazelcast.inbound;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,6 +31,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.ITopic;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Distributed Topic Event Driven Inbound Channel Adapter Test
@@ -48,6 +50,11 @@ public class HazelcastDistributedTopicEventDrivenInboundChannelAdapterTests {
@Resource
private ITopic<HazelcastIntegrationTestUser> edDistributedTopic1;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="edMultiMapChannel1">
<int:queue/>
</int:channel>
@@ -23,28 +25,20 @@
</int:channel>
<int-hazelcast:inbound-channel-adapter channel="edMultiMapChannel1" cache="edMultiMap1"/>
<int-hazelcast:inbound-channel-adapter channel="edMultiMapChannel2" cache="edMultiMap2" cache-events="REMOVED"
cache-listening-policy="SINGLE"/>
<int-hazelcast:inbound-channel-adapter channel="edMultiMapChannel2" cache="edMultiMap2" cache-events="REMOVED"/>
<int-hazelcast:inbound-channel-adapter channel="edMultiMapChannel3" cache="edMultiMap3"
cache-events="ADDED,REMOVED,CLEAR_ALL"/>
<bean id="edMultiMap1" factory-bean="edMultiMapInstance" factory-method="getMultiMap">
<bean id="edMultiMap1" factory-bean="instance" factory-method="getMultiMap">
<constructor-arg value="edMultiMap1"/>
</bean>
<bean id="edMultiMap2" factory-bean="edMultiMapInstance" factory-method="getMultiMap">
<bean id="edMultiMap2" factory-bean="instance" factory-method="getMultiMap">
<constructor-arg value="edMultiMap2"/>
</bean>
<bean id="edMultiMap3" factory-bean="edMultiMapInstance" factory-method="getMultiMap">
<bean id="edMultiMap3" factory-bean="instance" factory-method="getMultiMap">
<constructor-arg value="edMultiMap3"/>
</bean>
<bean id="edMultiMapInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.hazelcast.inbound;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,6 +36,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.core.MultiMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast MultiMap Event Driven Inbound Channel Adapter Test
@@ -67,6 +69,11 @@ public class HazelcastMultiMapEventDrivenInboundChannelAdapterTests {
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> edMultiMap3;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edMultiMap1

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="edReplicatedMapChannel1">
<int:queue/>
</int:channel>
@@ -34,27 +36,20 @@
<int-hazelcast:inbound-channel-adapter channel="edReplicatedMapChannel4" cache="edReplicatedMap4"
cache-events="ADDED,REMOVED,UPDATED"/>
<bean id="edReplicatedMap1" factory-bean="edReplicatedMapInstance" factory-method="getReplicatedMap">
<bean id="edReplicatedMap1" factory-bean="instance" factory-method="getReplicatedMap">
<constructor-arg value="edReplicatedMap1"/>
</bean>
<bean id="edReplicatedMap2" factory-bean="edReplicatedMapInstance" factory-method="getReplicatedMap">
<bean id="edReplicatedMap2" factory-bean="instance" factory-method="getReplicatedMap">
<constructor-arg value="edReplicatedMap2"/>
</bean>
<bean id="edReplicatedMap3" factory-bean="edReplicatedMapInstance" factory-method="getReplicatedMap">
<bean id="edReplicatedMap3" factory-bean="instance" factory-method="getReplicatedMap">
<constructor-arg value="edReplicatedMap3"/>
</bean>
<bean id="edReplicatedMap4" factory-bean="edReplicatedMapInstance" factory-method="getReplicatedMap">
<bean id="edReplicatedMap4" factory-bean="instance" factory-method="getReplicatedMap">
<constructor-arg value="edReplicatedMap4"/>
</bean>
<bean id="edReplicatedMapInstance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.hazelcast.inbound;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,6 +36,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.EntryEventType;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Replicated Map Event Driven Inbound Channel Adapter Test
@@ -72,6 +74,11 @@ public class HazelcastReplicatedMapEventDrivenInboundChannelAdapterTests {
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap4;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edReplicatedMap1

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.integration.hazelcast.inbound.config;
import javax.annotation.PreDestroy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.InboundChannelAdapter;
@@ -31,6 +33,7 @@ import org.springframework.integration.hazelcast.inbound.HazelcastDistributedSQL
import org.springframework.integration.hazelcast.inbound.HazelcastEventDrivenMessageProducer;
import org.springframework.messaging.PollableChannel;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IList;
@@ -40,17 +43,23 @@ import com.hazelcast.core.ISet;
import com.hazelcast.core.ITopic;
import com.hazelcast.core.MultiMap;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Configuration Class for Hazelcast Integration Inbound Test
*
* @author Eren Avsarogullari
* @since 1.0.0
* @author Artem Bilan
*/
@Configuration
@EnableIntegration
public class HazelcastIntegrationInboundTestConfiguration {
@PreDestroy
public void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Bean
public PollableChannel distributedMapChannel() {
return new QueueChannel();
@@ -212,8 +221,26 @@ public class HazelcastIntegrationInboundTestConfiguration {
}
@Bean
public Config hazelcastConfig() {
Config config = new Config();
config.getCPSubsystemConfig().setCPMemberCount(3)
.setSessionHeartbeatIntervalSeconds(1);
return config;
}
@Bean(destroyMethod = "")
public HazelcastInstance testHazelcastInstance() {
return Hazelcast.newHazelcastInstance();
return Hazelcast.newHazelcastInstance(hazelcastConfig());
}
@Bean(destroyMethod = "")
public HazelcastInstance testHazelcastInstance2() {
return Hazelcast.newHazelcastInstance(hazelcastConfig());
}
@Bean(destroyMethod = "")
public HazelcastInstance testHazelcastInstance3() {
return Hazelcast.newHazelcastInstance(hazelcastConfig());
}
@Bean(HazelcastLocalInstanceRegistrar.BEAN_NAME)
@@ -367,7 +394,7 @@ public class HazelcastIntegrationInboundTestConfiguration {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap3(),
"age > 5");
messageSource.setIterationType(DistributedSQLIterationType.LOCAL_KEY);
messageSource.setIterationType(DistributedSQLIterationType.KEY);
return messageSource;
}

View File

@@ -56,7 +56,7 @@ import com.hazelcast.spi.exception.DistributedObjectDestroyedException;
@SuppressWarnings("unchecked")
public final class HazelcastInboundChannelAdapterTestUtils {
public static final int TIMEOUT = 20_000;
public static final int TIMEOUT = 30_000;
public static void verifyEntryEvent(Message<?> msg, String cacheName,
EntryEventType event) {
@@ -350,7 +350,7 @@ public final class HazelcastInboundChannelAdapterTestUtils {
public static void testMembershipEvent(final HazelcastInstance instance,
final PollableChannel channel, final String key, final String value) {
Member member = instance.getCluster().getMembers().iterator().next();
Member member = instance.getCluster().getLocalMember();
member.setStringAttribute(key, value);
Message<?> msg = channel.receive(TIMEOUT);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,14 +14,13 @@
* limitations under the License.
*/
package org.springframework.integration.hazelcast.leader;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.spy;
import java.util.ArrayList;
@@ -29,6 +28,7 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,8 +45,10 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Tests for hazelcast leader election.
@@ -73,6 +75,11 @@ public class LeaderInitiatorTests {
@Autowired
private LeaderInitiator initiator;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testLeaderElections() throws Exception {
assertThat(this.candidate.onGrantedLatch.await(5, TimeUnit.SECONDS), is(true));
@@ -174,7 +181,6 @@ public class LeaderInitiatorTests {
initiator1.destroy();
CountDownLatch onGranted = new CountDownLatch(1);
DefaultCandidate candidate = spy(new DefaultCandidate());
@@ -218,8 +224,26 @@ public class LeaderInitiatorTests {
}
@Bean
public Config hazelcastConfig() {
Config config = new Config();
config.getCPSubsystemConfig().setCPMemberCount(3)
.setSessionHeartbeatIntervalSeconds(1);
return config;
}
@Bean(destroyMethod = "")
public HazelcastInstance hazelcastInstance() {
return Hazelcast.newHazelcastInstance();
return Hazelcast.newHazelcastInstance(hazelcastConfig());
}
@Bean(destroyMethod = "")
public HazelcastInstance hazelcastInstance2() {
return Hazelcast.newHazelcastInstance(hazelcastConfig());
}
@Bean(destroyMethod = "")
public HazelcastInstance hazelcastInstance3() {
return Hazelcast.newHazelcastInstance(hazelcastConfig());
}
@Bean
@@ -250,7 +274,7 @@ public class LeaderInitiatorTests {
CountDownLatch onEventLatch = new CountDownLatch(1);
ArrayList<AbstractLeaderEvent> events = new ArrayList<AbstractLeaderEvent>();
ArrayList<AbstractLeaderEvent> events = new ArrayList<>();
@Override
public void onApplicationEvent(AbstractLeaderEvent event) {
@@ -282,6 +306,11 @@ public class LeaderInitiatorTests {
this.revoked.countDown();
}
@Override
public void publishOnFailedToAcquire(Object source, Context context, String role) {
}
@Override
public void publishOnGranted(Object source, Context context, String role) {
this.initiator = (LeaderInitiator) source;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,31 +35,43 @@ import java.util.concurrent.locks.Lock;
import org.junit.AfterClass;
import org.junit.Test;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ILock;
import com.hazelcast.cp.lock.FencedLock;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* @author Artem Bilan
*/
public class HazelcastLockRegistryTests {
private static final HazelcastInstance instance = Hazelcast.newHazelcastInstance();
private static Config config = new Config();
static {
config.getCPSubsystemConfig().setCPMemberCount(3);
}
private static final HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
private static final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
private static final HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
@AfterClass
public static void destroy() throws Exception {
instance.shutdown();
public static void destroy() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testLock() throws Exception {
public void testLock() {
HazelcastLockRegistry registry = new HazelcastLockRegistry(instance);
for (int i = 0; i < 10; i++) {
Lock lock = registry.obtain("foo");
lock.lock();
try {
assertTrue(((ILock) lock).isLocked());
assertTrue(((ILock) lock).isLockedByCurrentThread());
assertTrue(((FencedLock) lock).isLocked());
assertTrue(((FencedLock) lock).isLockedByCurrentThread());
}
finally {
lock.unlock();
@@ -74,8 +86,8 @@ public class HazelcastLockRegistryTests {
Lock lock = registry.obtain("foo");
lock.lockInterruptibly();
try {
assertTrue(((ILock) lock).isLocked());
assertTrue(((ILock) lock).isLockedByCurrentThread());
assertTrue(((FencedLock) lock).isLocked());
assertTrue(((FencedLock) lock).isLockedByCurrentThread());
}
finally {
lock.unlock();
@@ -84,7 +96,7 @@ public class HazelcastLockRegistryTests {
}
@Test
public void testReentrantLock() throws Exception {
public void testReentrantLock() {
HazelcastLockRegistry registry = new HazelcastLockRegistry(instance);
for (int i = 0; i < 10; i++) {
Lock lock1 = registry.obtain("foo");

View File

@@ -52,8 +52,8 @@ public class HazelcastMetadataStoreTests {
}
@AfterClass
public static void destroy() throws Exception {
instance.shutdown();
public static void destroy() {
instance.getLifecycleService().terminate();
}
@Before

View File

@@ -10,6 +10,8 @@
http://www.springframework.org/schema/integration/hazelcast
https://www.springframework.org/schema/integration/hazelcast/spring-integration-hazelcast.xsd">
<import resource="classpath:org/springframework/integration/hazelcast/common-config.xml"/>
<int:channel id="firstMapChannel"/>
<int:channel id="secondMapChannel"/>
@@ -225,7 +227,7 @@
<constructor-arg value="distributedMap"/>
</bean>
<bean id="distributedBulkMap" factory-bean="instance" factory-method="getMap">
<bean id="distributedBulkMap" factory-bean="instance2" factory-method="getMap">
<constructor-arg value="distributedBulkMap"/>
</bean>
@@ -265,19 +267,14 @@
<constructor-arg value="bulkReplicatedMap"/>
</bean>
<bean id="topic" factory-bean="instance" factory-method="getTopic">
<bean id="topic" factory-bean="instance3" factory-method="getTopic">
<constructor-arg value="topic"/>
</bean>
<bean id="myLock" factory-bean="instance" factory-method="getLock">
<bean id="cpSubsystem" factory-bean="instance" factory-method="getCPSubsystem"/>
<bean id="myLock" factory-bean="cpSubsystem" factory-method="getLock">
<constructor-arg value="myLock"/>
</bean>
<bean id="instance" class="com.hazelcast.core.Hazelcast" factory-method="newHazelcastInstance"
destroy-method="shutdown">
<constructor-arg>
<bean class="com.hazelcast.config.Config"/>
</constructor-arg>
</bean>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -58,12 +59,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.hazelcast.core.ITopic;
import com.hazelcast.core.MultiMap;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Outbound Channel Adapter Test Class.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@@ -247,6 +250,11 @@ public class HazelcastOutboundChannelAdapterTests {
@Qualifier("testTopicRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testTopicRequestHandlerAdvice;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Before
public void setUp() {
this.distributedMap.clear();
@@ -263,7 +271,7 @@ public class HazelcastOutboundChannelAdapterTests {
}
@Test
public void testWriteToDistributedMap() throws InterruptedException {
public void testWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedMap(this.firstMapChannel, this.distributedMap,
this.testFirstMapRequestHandlerAdvice);
@@ -459,7 +467,7 @@ public class HazelcastOutboundChannelAdapterTests {
final Map<Integer, Message<HazelcastIntegrationTestUser>> map) {
int index = 1;
assertNotNull(map);
assertEquals(true, map.size() == HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
assertEquals(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT, map.size());
for (Entry<Integer, Message<HazelcastIntegrationTestUser>> entry : map.entrySet()) {
assertNotNull(entry);
assertEquals(index, entry.getKey().intValue());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@ import java.util.List;
import java.util.Queue;
import java.util.Set;
import javax.annotation.PreDestroy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -41,11 +43,14 @@ import com.hazelcast.core.IMap;
import com.hazelcast.core.ITopic;
import com.hazelcast.core.MultiMap;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Configuration Class for Hazelcast Integration Outbound Test
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
@Configuration
@@ -54,6 +59,11 @@ import com.hazelcast.core.ReplicatedMap;
@IntegrationComponentScan("org.springframework.integration.hazelcast.outbound")
public class HazelcastIntegrationOutboundTestConfiguration {
@PreDestroy
public void terminate() {
HazelcastInstanceFactory.terminateAll();
}
@Bean
public MessageChannel distMapChannel() {
return new DirectChannel();
@@ -134,7 +144,7 @@ public class HazelcastIntegrationOutboundTestConfiguration {
return testHzInstance().getReplicatedMap("Replicated_Map1");
}
@Bean
@Bean(destroyMethod = "")
public HazelcastInstance testHzInstance() {
return Hazelcast.newHazelcastInstance();
}

View File

@@ -22,6 +22,7 @@ import java.util.Set;
import javax.annotation.Resource;
import org.junit.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,6 +41,7 @@ import com.hazelcast.core.IMap;
import com.hazelcast.core.ITopic;
import com.hazelcast.core.MultiMap;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
/**
* Hazelcast Outbound Channel Adapter JavaConfig driven Unit Test Class
@@ -141,6 +143,11 @@ public class HazelcastOutboundChannelAdapterConfigTests {
@Qualifier("replicatedMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice replicatedMapRequestHandlerAdvice;
@AfterClass
public static void shutdown() {
HazelcastInstanceFactory.terminateAll();
}
@Test
public void testWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,24 +55,24 @@ public class HazelcastMessageStoreTests {
private static IMap<Object, Object> map;
@BeforeClass
public static void init() throws Exception {
public static void init() {
instance = Hazelcast.newHazelcastInstance();
map = instance.getMap("customTestsMessageStore");
store = new HazelcastMessageStore(map);
}
@AfterClass
public static void destroy() throws Exception {
instance.shutdown();
public static void destroy() {
instance.getLifecycleService().terminate();
}
@Before
public void clean() throws Exception {
public void clean() {
map.clear();
}
@Test
public void testWithMessageHistory() throws Exception {
public void testWithMessageHistory() {
Message<?> message = new GenericMessage<>("Hello");
DirectChannel fooChannel = new DirectChannel();
@@ -94,7 +94,7 @@ public class HazelcastMessageStoreTests {
}
@Test
public void testAddAndRemoveMessagesFromMessageGroup() throws Exception {
public void testAddAndRemoveMessagesFromMessageGroup() {
String groupId = "X";
List<Message<?>> messages = new ArrayList<>();
for (int i = 0; i < 25; i++) {
@@ -110,7 +110,7 @@ public class HazelcastMessageStoreTests {
}
@Test
public void addAndGetMessage() throws Exception {
public void addAndGetMessage() {
Message<?> message = MessageBuilder.withPayload("test").build();
store.addMessage(message);
@@ -119,14 +119,14 @@ public class HazelcastMessageStoreTests {
}
@Test
public void customMap() throws Exception {
public void customMap() {
assertSame(map, TestUtils.getPropertyValue(store, "map"));
HazelcastMessageStore store2 = new HazelcastMessageStore(instance);
assertNotSame(map, TestUtils.getPropertyValue(store2, "map"));
}
@Test
public void messageStoreSize() throws Exception {
public void messageStoreSize() {
Message<?> message1 = MessageBuilder.withPayload("test").build();
Message<?> message2 = MessageBuilder.withPayload("test").build();
store.addMessage(message1);