GH-169: Upgrade and prepare for release

Fixes GH-169 (https://github.com/spring-projects/spring-integration-extensions/issues/169)

* Upgrade Gradle and dependencies
* Apply Checkstyle
This commit is contained in:
Artem Bilan
2017-01-23 15:33:30 -05:00
parent ab73b6cd2c
commit 6e7b4cfcc7
41 changed files with 2364 additions and 2011 deletions

View File

@@ -1,27 +1,28 @@
buildscript {
repositories {
maven { url 'http://repo.spring.io/plugins-release' }
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
classpath 'io.spring.gradle:spring-io-plugin:0.0.5.RELEASE'
classpath 'io.spring.gradle:dependency-management-plugin:1.0.0.RC2'
classpath 'io.spring.gradle:spring-io-plugin:0.0.6.RELEASE'
}
}
plugins {
id "org.sonarqube" version "1.2"
id 'java'
id 'eclipse'
id 'idea'
id 'jacoco'
id 'checkstyle'
id 'org.sonarqube' version '2.1'
}
description = 'Spring Integration Hazelcast Support'
apply plugin: 'java'
apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply plugin: 'eclipse'
apply plugin: 'jacoco'
apply plugin: 'idea'
group = 'org.springframework.integration'
repositories {
if (version.endsWith('BUILD-SNAPSHOT') || project.hasProperty('platformVersion')) {
maven { url 'http://repo.spring.io/libs-snapshot' }
@@ -41,12 +42,20 @@ if (project.hasProperty('platformVersion')) {
}
}
sourceCompatibility = targetCompatibility = 1.7
compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
ext {
hazelcastVersion = '3.6.4'
slf4jVersion = '1.7.21'
springIntegrationVersion = '4.3.1.BUILD-SNAPSHOT'
hazelcastVersion = '3.7.4'
slf4jVersion = '1.7.22'
springIntegrationVersion = '4.3.6.RELEASE'
idPrefix = 'hazelcast'
@@ -69,7 +78,12 @@ sourceSets {
}
jacoco {
toolVersion = "0.7.6.201602180812"
toolVersion = "0.7.8"
}
checkstyle {
configFile = file("$rootDir/src/checkstyle/checkstyle.xml")
toolVersion = "6.16.1"
}
// enable all compiler warnings; individual projects may customize further
@@ -86,9 +100,6 @@ dependencies {
testRuntime "org.slf4j:slf4j-log4j12:$slf4jVersion"
}
// enable all compiler warnings; individual projects may customize further
[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all,-options']
test {
// suppress all console output during testing unless running `gradle -i`
logging.captureStandardOutput(LogLevel.INFO)

View File

@@ -1,6 +1,6 @@
#Wed Jul 06 16:58:06 EDT 2016
#Mon Jan 23 13:52:31 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh
##############################################################################
##
@@ -154,11 +154,19 @@ if $cygwin ; then
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@@ -49,7 +49,6 @@ goto fail
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +59,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line

View File

@@ -0,0 +1,17 @@
^\Q/*\E$
^\Q * Copyright \E20\d\d(\-20\d\d)?\Q the original author or authors.\E$
^\Q *\E$
^\Q * Licensed under the Apache License, Version 2.0 (the "License");\E$
^\Q * you may not use this file except in compliance with the License.\E$
^\Q * You may obtain a copy of the License at\E$
^\Q *\E$
^\Q * http://www.apache.org/licenses/LICENSE-2.0\E$
^\Q *\E$
^\Q * Unless required by applicable law or agreed to in writing, software\E$
^\Q * distributed under the License is distributed on an "AS IS" BASIS,\E$
^\Q * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\E$
^\Q * See the License for the specific language governing permissions and\E$
^\Q * limitations under the License.\E$
^\Q */\E$
^$
^.*$

View File

@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files="package-info\.java" checks=".*" />
<suppress files="[\\/]test[\\/]" checks="RequireThis" />
<suppress files="[\\/]test[\\/]" checks="FinalClass" />
<suppress files="[\\/]test[\\/]" checks="AvoidStaticImport" />
<suppress files="[\\/]test[\\/]" checks="InnerTypeLast" />
<suppress files="[\\/]test[\\/]" checks="Javadoc*" />
</suppressions>

View File

@@ -0,0 +1,183 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="src/checkstyle/checkstyle-suppressions.xml" />
</module>
<!-- Root Checks -->
<module name="RegexpHeader">
<property name="headerFile" value="src/checkstyle/checkstyle-header.txt" />
<property name="fileExtensions" value="java" />
</module>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf"/>
</module>
<!-- TreeWalker Checks -->
<module name="TreeWalker">
<!-- Annotations -->
<module name="AnnotationUseStyle">
<property name="elementStyle" value="compact" />
</module>
<module name="MissingOverride" />
<module name="PackageAnnotation" />
<module name="AnnotationLocation">
<property name="allowSamelineSingleParameterlessAnnotation"
value="false" />
</module>
<!-- Block Checks -->
<module name="EmptyBlock">
<property name="option" value="text" />
</module>
<module name="LeftCurly" />
<module name="RightCurly">
<property name="option" value="alone" />
</module>
<module name="NeedBraces" />
<module name="AvoidNestedBlocks" />
<!-- Class Design -->
<module name="FinalClass" />
<module name="InterfaceIsType" />
<module name="HideUtilityClassConstructor" />
<module name="MutableException" />
<module name="InnerTypeLast" />
<module name="OneTopLevelClass" />
<!-- Coding -->
<module name="CovariantEquals" />
<module name="EmptyStatement" />
<module name="EqualsHashCode" />
<module name="InnerAssignment" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" />
<module name="NestedForDepth">
<property name="max" value="3" />
</module>
<module name="NestedIfDepth">
<property name="max" value="4" />
</module>
<module name="NestedTryDepth">
<property name="max" value="3" />
</module>
<module name="MultipleVariableDeclarations" />
<module name="RequireThis">
<property name="checkMethods" value="false" />
</module>
<module name="OneStatementPerLine" />
<!-- Imports -->
<module name="AvoidStarImport" />
<module name="AvoidStaticImport">
<property name="excludes"
value="org.assertj.core.api.Assertions.*,
org.junit.Assert.*,
org.junit.Assume.*,
org.junit.internal.matchers.ThrowableMessageMatcher.*,
org.hamcrest.CoreMatchers.*,
org.hamcrest.Matchers.*,
org.mockito.Mockito.*,
org.mockito.BDDMockito.*,
org.mockito.Matchers.*" />
</module>
<module name="IllegalImport" />
<module name="RedundantImport" />
<module name="UnusedImports">
<property name="processJavadoc" value="true" />
</module>
<module name="ImportOrder">
<property name="groups" value="java,/^javax?\./,org,org.springframework,*" />
<property name="ordered" value="true" />
<property name="separated" value="true" />
<property name="option" value="top" />
<property name="sortStaticImportsAlphabetically" value="true" />
</module>
<!-- Javadoc Comments -->
<module name="JavadocType">
<property name="scope" value="package"/>
<property name="authorFormat" value=".+\s.+"/>
</module>
<module name="JavadocMethod">
<property name="allowMissingJavadoc" value="true" />
</module>
<module name="JavadocVariable">
<property name="scope" value="public"/>
</module>
<module name="JavadocStyle">
<property name="checkEmptyJavadoc" value="true"/>
</module>
<module name="NonEmptyAtclauseDescription" />
<module name="JavadocTagContinuationIndentation">
<property name="offset" value="0"/>
</module>
<module name="AtclauseOrder">
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF"/>
<property name="tagOrder" value="@param, @author, @since, @see, @version, @serial, @deprecated"/>
</module>
<module name="AtclauseOrder">
<property name="target" value="METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
<property name="tagOrder" value="@param, @return, @throws, @since, @deprecated, @see"/>
</module>
<!-- Miscellaneous -->
<module name="CommentsIndentation">
<property name="tokens" value="BLOCK_COMMENT_BEGIN" />
</module>
<module name="UpperEll" />
<module name="ArrayTypeStyle" />
<module name="OuterTypeFilename" />
<!-- Modifiers -->
<module name="RedundantModifier" />
<!-- Regexp -->
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* +\t*\S" />
<property name="message"
value="Line has leading space characters; indentation should be performed with tabs only." />
<property name="ignoreComments" value="true" />
</module>
<module name="RegexpSinglelineJava">
<property name="maximum" value="0"/>
<property name="format" value="org\.mockito\..*Mockito\.(when|doThrow|doAnswer)" />
<property name="message"
value="Please use BDDMockito instead of Mockito.(when|doThrow|doAnswer)." />
<property name="ignoreComments" value="true" />
</module>
<!--<module name="RegexpSinglelineJava">
<property name="maximum" value="0"/>
<property name="format" value="org\.junit\.Assert\.assert" />
<property name="message"
value="Please use AssertJ imports." />
<property name="ignoreComments" value="true" />
</module>-->
<module name="Regexp">
<property name="format" value="[ \t]+$" />
<property name="illegalPattern" value="true" />
<property name="message" value="Trailing whitespace" />
</module>
<module name="Regexp">
<property name="format" value="System.(out|err).print" />
<property name="illegalPattern" value="true" />
<property name="message" value="System.out or .err" />
</module>
<!-- Whitespace -->
<module name="GenericWhitespace" />
<module name="MethodParamPad" />
<module name="NoWhitespaceAfter" >
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
</module>
<module name="NoWhitespaceBefore" />
<module name="ParenPad" />
<module name="TypecastParenPad" />
<module name="WhitespaceAfter" />
<module name="WhitespaceAround" />
</module>
</module>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -17,14 +17,45 @@
package org.springframework.integration.hazelcast;
/**
* Enumeration of Cache Event Types
* Enumeration of Cache Event Types.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*
* @see org.springframework.integration.hazelcast.inbound.AbstractHazelcastMessageProducer
*/
public enum CacheEventType {
ADDED, REMOVED, UPDATED, EVICTED, EVICT_ALL, CLEAR_ALL;
/**
* The Hazelcast ADDED event.
*/
ADDED,
/**
* The Hazelcast REMOVED event.
*/
REMOVED,
/**
* The Hazelcast UPDATED event.
*/
UPDATED,
/**
* The Hazelcast EVICTED event.
*/
EVICTED,
/**
* The Hazelcast EVICT_ALL event.
*/
EVICT_ALL,
/**
* The Hazelcast CLEAR_ALL event.
*/
CLEAR_ALL
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -17,14 +17,25 @@
package org.springframework.integration.hazelcast;
/**
* Enumeration of Cache Listening Policy Type
* Enumeration of Cache Listening Policy Type.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*
* @see org.springframework.integration.hazelcast.inbound.AbstractHazelcastMessageProducer
*/
public enum CacheListeningPolicyType {
SINGLE, ALL;
/**
* Only the local Hazelcast node can accept event.
*/
SINGLE,
/**
* All subscribed members can accept event.
*/
ALL
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -17,10 +17,13 @@
package org.springframework.integration.hazelcast;
/**
* Enumeration of Hazelcast Cluster Monitor Types
* Enumeration of Hazelcast Cluster Monitor Types.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*
* @see org.springframework.integration.hazelcast.inbound.HazelcastClusterMonitorMessageProducer
* @see com.hazelcast.core.MembershipListener
* @see com.hazelcast.core.DistributedObjectListener
@@ -30,6 +33,29 @@ package org.springframework.integration.hazelcast;
*/
public enum ClusterMonitorType {
MEMBERSHIP, DISTRIBUTED_OBJECT, MIGRATION, LIFECYCLE, CLIENT;
/**
* The membership listener mode.
*/
MEMBERSHIP,
/**
* The distributed object listener mode.
*/
DISTRIBUTED_OBJECT,
/**
* The migration listener mode.
*/
MIGRATION,
/**
* The listener listener mode.
*/
LIFECYCLE,
/**
* The client listener mode.
*/
CLIENT
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -17,14 +17,36 @@
package org.springframework.integration.hazelcast;
/**
* Enumeration of Distributed SQL Iteration Type
* Enumeration of Distributed SQL Iteration Type.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*
* @see org.springframework.integration.hazelcast.inbound.HazelcastDistributedSQLMessageSource
* @see com.hazelcast.core.IMap
*/
public enum DistributedSQLIterationType {
ENTRY, KEY, LOCAL_KEY, VALUE
/**
* The {@link com.hazelcast.core.IMap#entrySet()} to iterate.
*/
ENTRY,
/**
* The {@link com.hazelcast.core.IMap#keySet()} to iterate.
*/
KEY,
/**
* The {@link com.hazelcast.core.IMap#localKeySet()} to iterate.
*/
LOCAL_KEY,
/**
* The {@link com.hazelcast.core.IMap#values()} to iterate.
*/
VALUE
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -17,21 +17,35 @@
package org.springframework.integration.hazelcast;
/**
* Hazelcast Message Headers
* Hazelcast Message Headers.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
public abstract class HazelcastHeaders {
private static final String PREFIX = "hazelcast_";
/**
* The event type header name.
*/
public static final String EVENT_TYPE = PREFIX + "eventType";
/**
* The member header name.
*/
public static final String MEMBER = PREFIX + "member";
/**
* The cache name header name.
*/
public static final String CACHE_NAME = PREFIX + "cacheName";
/**
* The publishing time header name.
*/
public static final String PUBLISHING_TIME = PREFIX + "publishingTime";
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -36,9 +36,11 @@ import com.hazelcast.core.ReplicatedMap;
* Common Validator for Hazelcast Integration. It validates cache types and events.
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
public class HazelcastIntegrationDefinitionValidator {
public final class HazelcastIntegrationDefinitionValidator {
public static <E extends Enum<E>> Set<String> validateEnumType(final Class<E> enumType, final String types) {
Set<String> typeSet = StringUtils.commaDelimitedListToSet(StringUtils.trimAllWhitespace(types));
@@ -100,4 +102,7 @@ public class HazelcastIntegrationDefinitionValidator {
}
}
private HazelcastIntegrationDefinitionValidator() {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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,9 +37,15 @@ import com.hazelcast.core.MultiMap;
*/
public class HazelcastLocalInstanceRegistrar implements SmartInitializingSingleton {
/**
* The name for the Hazelcast MultiMap used for membership registration.
*/
public static final String SPRING_INTEGRATION_INTERNAL_CLUSTER_MULTIMAP =
"SPRING_INTEGRATION_INTERNAL_CLUSTER_MULTIMAP";
/**
* The name for the Hazelcast Lock used for membership registration.
*/
public static final String SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK = "SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK";
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -66,7 +66,7 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
}
protected Set<String> getCacheEvents() {
return cacheEvents;
return this.cacheEvents;
}
public void setCacheEventTypes(String cacheEventTypes) {
@@ -79,7 +79,7 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
}
protected CacheListeningPolicyType getCacheListeningPolicy() {
return cacheListeningPolicy;
return this.cacheListeningPolicy;
}
public void setCacheListeningPolicy(CacheListeningPolicyType cacheListeningPolicy) {
@@ -88,13 +88,18 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
}
protected String getHazelcastRegisteredEventListenerId() {
return hazelcastRegisteredEventListenerId;
return this.hazelcastRegisteredEventListenerId;
}
protected void setHazelcastRegisteredEventListenerId(String hazelcastRegisteredEventListenerId) {
this.hazelcastRegisteredEventListenerId = hazelcastRegisteredEventListenerId;
}
/**
* A base event listener abstraction.
*
* @param <E> the event type
*/
protected abstract class AbstractHazelcastEventListener<E> {
protected abstract void processEvent(E event);
@@ -102,7 +107,7 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
protected abstract Message<?> toMessage(E event);
protected void sendMessage(E event, InetSocketAddress socketAddress,
CacheListeningPolicyType cacheListeningPolicyType) {
CacheListeningPolicyType cacheListeningPolicyType) {
if (CacheListeningPolicyType.ALL == cacheListeningPolicyType || isEventAcceptable(socketAddress)) {
AbstractHazelcastMessageProducer.this.sendMessage(toMessage(event));
}
@@ -141,6 +146,12 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
}
/**
* The {@link AbstractHazelcastEventListener} implementation for the {@link AbstractIMapEvent}s.
*
* @param <K> the entry key type
* @param <V> the entry value type
*/
protected final class HazelcastEntryListener<K, V> extends
AbstractHazelcastEventListener<AbstractIMapEvent> implements EntryListener<K, V> {
@@ -177,8 +188,8 @@ public abstract class AbstractHazelcastMessageProducer extends MessageProducerSu
@Override
protected void processEvent(AbstractIMapEvent event) {
if (getCacheEvents().contains(event.getEventType().toString())) {
if (logger.isDebugEnabled()) {
logger.debug("Received Event : " + event);
if (AbstractHazelcastMessageProducer.this.logger.isDebugEnabled()) {
AbstractHazelcastMessageProducer.this.logger.debug("Received Event : " + event);
}
sendMessage(event, event.getMember().getSocketAddress(), getCacheListeningPolicy());
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2015-2017 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -97,25 +97,14 @@ public class LeaderInitiator implements SmartLifecycle, DisposableBean, Applicat
private boolean customPublisher = false;
/**
* @see SmartLifecycle
*/
private volatile boolean autoStartup = true;
/**
* @see SmartLifecycle which is an extension of org.springframework.context.Phased
*/
private volatile int phase;
/**
* Flag that indicates whether the leadership election for
* this {@link #candidate} is running.
*/
private volatile boolean running;
/**
* Construct a {@link LeaderInitiator} with a default candidate.
*
* @param client Hazelcast client
*/
public LeaderInitiator(HazelcastInstance client) {
@@ -124,7 +113,6 @@ public class LeaderInitiator implements SmartLifecycle, DisposableBean, Applicat
/**
* Construct a {@link LeaderInitiator}.
*
* @param client Hazelcast client
* @param candidate leadership election candidate
*/
@@ -146,6 +134,7 @@ public class LeaderInitiator implements SmartLifecycle, DisposableBean, Applicat
}
/**
* The context of the initiator or null if not running.
* @return the context (or null if not running)
*/
public Context getContext() {
@@ -214,6 +203,7 @@ public class LeaderInitiator implements SmartLifecycle, DisposableBean, Applicat
}
/**
* {@code true} if leadership election for this {@link #candidate} is running.
* @return true if leadership election for this {@link #candidate} is running
*/
@Override
@@ -248,7 +238,7 @@ public class LeaderInitiator implements SmartLifecycle, DisposableBean, Applicat
if (this.locked) {
LeaderInitiator.this.leaderEventPublisher.publishOnGranted(LeaderInitiator.this,
this.context, this.role);
LeaderInitiator.this.candidate.onGranted(context);
LeaderInitiator.this.candidate.onGranted(this.context);
Thread.sleep(Long.MAX_VALUE);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -13,22 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.hazelcast.message;
import org.springframework.util.Assert;
/**
* Hazelcast Message Payload for Entry Events
* Hazelcast Message Payload for Entry Events.
*
* @param <K> the entry key type
* @param <V> the entry value type
*
* @author Eren Avsarogullari
* @author Artem Bilan
*
* @since 1.0.0
*/
public class EntryEventMessagePayload<K, V> {
/**
* The entry key.
*/
public final K key;
/**
* The entry value.
*/
public final V value;
/**
* The entry old value if any.
*/
public final V oldValue;
public EntryEventMessagePayload(final K key, final V value, final V oldValue) {
@@ -40,27 +55,31 @@ public class EntryEventMessagePayload<K, V> {
@Override
public String toString() {
return "EntryEventMessagePayload [key=" + key + ", value=" + value + ", oldValue=" + oldValue + "]";
return "EntryEventMessagePayload [key=" + this.key + ", value=" + this.value + ", oldValue=" + this.oldValue + "]";
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EntryEventMessagePayload<?, ?> that = (EntryEventMessagePayload<?, ?>) o;
return key.equals(that.key) && !(value != null ? !value.equals(that.value)
: that.value != null) && !(oldValue != null
? !oldValue.equals(that.oldValue) : that.oldValue != null);
return this.key.equals(that.key) && !(this.value != null ? !this.value.equals(that.value)
: that.value != null) && !(this.oldValue != null
? !this.oldValue.equals(that.oldValue) : that.oldValue != null);
}
@Override
public int hashCode() {
int result = key.hashCode();
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (oldValue != null ? oldValue.hashCode() : 0);
int result = this.key.hashCode();
result = 31 * result + (this.value != null ? this.value.hashCode() : 0);
result = 31 * result + (this.oldValue != null ? this.oldValue.hashCode() : 0);
return result;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -17,6 +17,7 @@
package org.springframework.integration.hazelcast;
import java.io.Serializable;
import java.util.Objects;
/**
* User Bean for Hazelcast Integration Unit Tests
@@ -87,48 +88,29 @@ public class HazelcastIntegrationTestUser implements Comparable<HazelcastIntegra
+ age + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + age;
result = prime * result + id;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((surname == null) ? 0 : surname.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
HazelcastIntegrationTestUser other = (HazelcastIntegrationTestUser) obj;
if (age != other.age)
return false;
if (id != other.id)
return false;
if (name == null) {
if (other.name != null)
return false;
}
else if (!name.equals(other.name))
return false;
if (surname == null) {
if (other.surname != null)
return false;
}
else if (!surname.equals(other.surname))
return false;
return true;
}
@Override
public int compareTo(HazelcastIntegrationTestUser user) {
return (this.id < user.getId()) ? -1: (this.id > user.getId()) ? 1 : 0;
return (this.id < user.getId()) ? -1 : (this.id > user.getId()) ? 1 : 0;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
HazelcastIntegrationTestUser that = (HazelcastIntegrationTestUser) o;
return id == that.id &&
age == that.age &&
Objects.equals(name, that.name) &&
Objects.equals(surname, that.surname);
}
@Override
public int hashCode() {
return Objects.hash(id, name, surname, age);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -22,12 +22,12 @@ import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvi
import org.springframework.messaging.Message;
/**
* {@link MessageHandler} advice class for Hazelcast Integration Unit Tests.
* {@link AbstractRequestHandlerAdvice} advice class for Hazelcast Integration Unit Tests.
*
* @author Eren Avsarogullari
* @since 1.0.0
*/
public class HazelcastTestRequestHandlerAdvice extends AbstractRequestHandlerAdvice {
public class HazelcastTestRequestHandlerAdvice extends AbstractRequestHandlerAdvice {
public CountDownLatch executeLatch = null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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,9 +16,9 @@
package org.springframework.integration.hazelcast.inbound;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import javax.annotation.Resource;
@@ -51,127 +51,127 @@ import com.hazelcast.core.IMap;
@SuppressWarnings("unchecked")
public class HazelcastCQDistributedMapInboundChannelAdapterTests {
@Autowired
private PollableChannel cqMapChannel1;
@Autowired
private PollableChannel cqMapChannel1;
@Autowired
private PollableChannel cqMapChannel2;
@Autowired
private PollableChannel cqMapChannel2;
@Autowired
private PollableChannel cqMapChannel3;
@Autowired
private PollableChannel cqMapChannel3;
@Autowired
private PollableChannel cqMapChannel4;
@Autowired
private PollableChannel cqMapChannel4;
@Autowired
private PollableChannel cqMapChannel5;
@Autowired
private PollableChannel cqMapChannel5;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap5;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> cqDistributedMap5;
@Test
public void testContinuousQueryForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(cqDistributedMap1,
cqMapChannel1, "cqDistributedMap1");
}
@Test
public void testContinuousQueryForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(cqDistributedMap1,
cqMapChannel1, "cqDistributedMap1");
}
@Test
public void testContinuousQueryForOnlyREMOVEDEntryEvent() {
cqDistributedMap2
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
cqDistributedMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
cqDistributedMap2.remove(2);
Message<?> msg =
cqMapChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
assertEquals("cqDistributedMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testContinuousQueryForOnlyREMOVEDEntryEvent() {
cqDistributedMap2
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
cqDistributedMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
cqDistributedMap2.remove(2);
Message<?> msg =
cqMapChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
assertEquals("cqDistributedMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
@Test
public void testContinuousQueryForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(cqDistributedMap3,
cqMapChannel3, "cqDistributedMap3");
}
@Test
public void testContinuousQueryForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(cqDistributedMap3,
cqMapChannel3, "cqDistributedMap3");
}
@Test
public void testContinuousQueryForOnlyUPDATEDEntryEvent() {
cqDistributedMap4
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
cqDistributedMap4
.put(1, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
Message<?> msg =
cqMapChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.UPDATED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
assertEquals("cqDistributedMap4",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testContinuousQueryForOnlyUPDATEDEntryEvent() {
cqDistributedMap4
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
cqDistributedMap4
.put(1, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
Message<?> msg =
cqMapChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.UPDATED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
assertEquals("cqDistributedMap4",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
assertEquals(Integer.valueOf(1),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
assertEquals(Integer.valueOf(1),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
@Test
public void testContinuousQueryForOnlyUPDATEDEntryEventWhenIncludeValueIsFalse() {
HazelcastInboundChannelAdapterTestUtils
.testContinuousQueryForUPDATEDEntryEventWhenIncludeValueIsFalse(
cqDistributedMap5, cqMapChannel5, "cqDistributedMap5");
}
@Test
public void testContinuousQueryForOnlyUPDATEDEntryEventWhenIncludeValueIsFalse() {
HazelcastInboundChannelAdapterTestUtils
.testContinuousQueryForUPDATEDEntryEventWhenIncludeValueIsFalse(
cqDistributedMap5, cqMapChannel5, "cqDistributedMap5");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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,9 +16,10 @@
package org.springframework.integration.hazelcast.inbound;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -53,135 +54,136 @@ import com.hazelcast.core.MigrationEvent;
@DirtiesContext
public class HazelcastClusterMonitorInboundChannelAdapterTests {
private static final String TEST_GROUP_NAME1 = "Test_Group_Name1";
private static final String TEST_GROUP_NAME1 = "Test_Group_Name1";
@Autowired
private PollableChannel cmChannel1;
@Autowired
private PollableChannel cmChannel1;
@Autowired
private PollableChannel cmChannel2;
@Autowired
private PollableChannel cmChannel2;
@Autowired
private PollableChannel cmChannel3;
@Autowired
private PollableChannel cmChannel3;
@Autowired
private PollableChannel cmChannel4;
@Autowired
private PollableChannel cmChannel4;
@Autowired
private PollableChannel cmChannel5;
@Autowired
private PollableChannel cmChannel5;
@Autowired
private PollableChannel cmChannel6;
@Autowired
private PollableChannel cmChannel6;
@Autowired
private HazelcastInstance hazelcastInstance;
@Autowired
private HazelcastInstance hazelcastInstance;
@Autowired
private HazelcastInstance hazelcastInstance2;
@Autowired
private HazelcastInstance hazelcastInstance2;
@Autowired
private HazelcastInstance hazelcastInstance3;
@Autowired
private HazelcastInstance hazelcastInstance3;
@Test
public void testMembershipEvent() {
HazelcastInboundChannelAdapterTestUtils
.testMembershipEvent(hazelcastInstance, cmChannel1, "testKey1", "testValue1");
}
@Test
public void testMembershipEvent() {
HazelcastInboundChannelAdapterTestUtils
.testMembershipEvent(hazelcastInstance, cmChannel1, "testKey1", "testValue1");
}
@Test
public void testDistributedObjectEvent() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedObjectEventByChannelAndHazelcastInstance(cmChannel2,
hazelcastInstance, "Test_Distributed_Map4");
}
@Test
public void testDistributedObjectEvent() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedObjectEventByChannelAndHazelcastInstance(cmChannel2,
hazelcastInstance, "Test_Distributed_Map4");
}
@Test
public void testMigrationEvent() {
final IMap<Integer, String> distributedMap =
hazelcastInstance3.getMap("Test_Distributed_Map2");
distributedMap.put(1, "TestValue1");
distributedMap.put(2, "TestValue2");
@Test
public void testMigrationEvent() {
final IMap<Integer, String> distributedMap =
hazelcastInstance3.getMap("Test_Distributed_Map2");
distributedMap.put(1, "TestValue1");
distributedMap.put(2, "TestValue2");
hazelcastInstance3.getLifecycleService().terminate();
final Message<?> msg =
cmChannel3.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyMigrationEvent(msg);
}
hazelcastInstance3.getLifecycleService().terminate();
final Message<?> msg = this.cmChannel3.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyMigrationEvent(msg);
}
@Test
public void testLifecycleEvent() throws InterruptedException {
hazelcastInstance2.getLifecycleService().terminate();
@Test
public void testLifecycleEvent() {
hazelcastInstance2.getLifecycleService().terminate();
Message<?> msg =
cmChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyLifecycleEvent(msg, LifecycleState.SHUTTING_DOWN);
Message<?> msg =
cmChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyLifecycleEvent(msg, LifecycleState.SHUTTING_DOWN);
msg = cmChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyLifecycleEvent(msg, LifecycleState.SHUTDOWN);
}
msg = cmChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyLifecycleEvent(msg, LifecycleState.SHUTDOWN);
}
@Test
public void testClientEvent() {
testClientEventByChannelAndGroupName(cmChannel5, TEST_GROUP_NAME1);
}
@Test
public void testClientEvent() {
testClientEventByChannelAndGroupName(cmChannel5, TEST_GROUP_NAME1);
}
@Test
public void testMultipleMonitorTypes() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedObjectEventByChannelAndHazelcastInstance(cmChannel6,
hazelcastInstance, "Test_Distributed_Map5");
@Test
public void testMultipleMonitorTypes() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedObjectEventByChannelAndHazelcastInstance(cmChannel6,
hazelcastInstance, "Test_Distributed_Map5");
HazelcastInboundChannelAdapterTestUtils
.testMembershipEvent(hazelcastInstance, cmChannel6, "testKey2", "testValue2");
}
HazelcastInboundChannelAdapterTestUtils
.testMembershipEvent(hazelcastInstance, cmChannel6, "testKey2", "testValue2");
}
private void testClientEventByChannelAndGroupName(final PollableChannel channel,
final String groupName) {
final HazelcastInstance client = getHazelcastClientByGroupName(groupName);
private void testClientEventByChannelAndGroupName(final PollableChannel channel,
final String groupName) {
final HazelcastInstance client = getHazelcastClientByGroupName(groupName);
Message<?> msg = channel.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyClientEvent(msg);
Message<?> msg = channel.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyClientEvent(msg);
client.getLifecycleService().terminate();
client.getLifecycleService().terminate();
msg = channel.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyClientEvent(msg);
}
msg = channel.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
verifyClientEvent(msg);
}
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");
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");
return HazelcastClient.newHazelcastClient(cfg);
}
return HazelcastClient.newHazelcastClient(cfg);
}
private void verifyMigrationEvent(final Message<?> msg) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof MigrationEvent);
assertNotNull(((MigrationEvent) msg.getPayload()).getStatus());
assertNotNull(((MigrationEvent) msg.getPayload()).getNewOwner());
assertNotNull(((MigrationEvent) msg.getPayload()).getOldOwner());
}
private void verifyMigrationEvent(final Message<?> msg) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof MigrationEvent);
assertNotNull(((MigrationEvent) msg.getPayload()).getStatus());
assertNotNull(((MigrationEvent) msg.getPayload()).getNewOwner());
private void verifyLifecycleEvent(final Message<?> msg,
final LifecycleState lifecycleState) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof LifecycleEvent);
assertEquals(lifecycleState, ((LifecycleEvent) msg.getPayload()).getState());
}
// Newer Hazelcast versions doesn't populated 'oldOwner' if we drop member on the same host
assertNull(((MigrationEvent) msg.getPayload()).getOldOwner());
}
private void verifyClientEvent(final Message<?> msg) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof Client);
assertEquals(ClientType.JAVA, ((Client) msg.getPayload()).getClientType());
assertNotNull(((Client) msg.getPayload()).getSocketAddress());
}
private void verifyLifecycleEvent(final Message<?> msg,
final LifecycleState lifecycleState) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof LifecycleEvent);
assertEquals(lifecycleState, ((LifecycleEvent) msg.getPayload()).getState());
}
private void verifyClientEvent(final Message<?> msg) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof Client);
assertEquals(ClientType.JAVA, ((Client) msg.getPayload()).getClientType());
assertNotNull(((Client) msg.getPayload()).getSocketAddress());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -48,56 +48,56 @@ import com.hazelcast.core.IList;
@DirtiesContext
public class HazelcastDistributedListEventDrivenInboundChannelAdapterTests {
@Autowired
private PollableChannel edListChannel1;
@Autowired
private PollableChannel edListChannel1;
@Autowired
private PollableChannel edListChannel2;
@Autowired
private PollableChannel edListChannel2;
@Autowired
private PollableChannel edListChannel3;
@Autowired
private PollableChannel edListChannel3;
@Resource
private IList<HazelcastIntegrationTestUser> edDistributedList1;
@Resource
private IList<HazelcastIntegrationTestUser> edDistributedList1;
@Resource
private IList<HazelcastIntegrationTestUser> edDistributedList2;
@Resource
private IList<HazelcastIntegrationTestUser> edDistributedList2;
@Resource
private IList<HazelcastIntegrationTestUser> edDistributedList3;
@Resource
private IList<HazelcastIntegrationTestUser> edDistributedList3;
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedList1.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg = edListChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.ADDED.toString(), msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
assertEquals(1, ((HazelcastIntegrationTestUser) msg.getPayload()).getId());
assertEquals("TestName1", ((HazelcastIntegrationTestUser) msg.getPayload()).getName());
assertEquals("TestSurname1", ((HazelcastIntegrationTestUser) msg.getPayload()).getSurname());
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedList1.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg = edListChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.ADDED.toString(), msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
assertEquals(1, ((HazelcastIntegrationTestUser) msg.getPayload()).getId());
assertEquals("TestName1", ((HazelcastIntegrationTestUser) msg.getPayload()).getName());
assertEquals("TestSurname1", ((HazelcastIntegrationTestUser) msg.getPayload()).getSurname());
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
HazelcastIntegrationTestUser user = new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2");
edDistributedList2.add(user);
edDistributedList2.remove(user);
Message<?> msg = edListChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.REMOVED.toString(), msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
assertEquals(2, ((HazelcastIntegrationTestUser) msg.getPayload()).getId());
assertEquals("TestName2", ((HazelcastIntegrationTestUser) msg.getPayload()).getName());
assertEquals("TestSurname2", ((HazelcastIntegrationTestUser) msg.getPayload()).getSurname());
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
HazelcastIntegrationTestUser user = new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2");
edDistributedList2.add(user);
edDistributedList2.remove(user);
Message<?> msg = edListChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
assertEquals(EntryEventType.REMOVED.toString(), msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
assertEquals(2, ((HazelcastIntegrationTestUser) msg.getPayload()).getId());
assertEquals("TestName2", ((HazelcastIntegrationTestUser) msg.getPayload()).getName());
assertEquals("TestSurname2", ((HazelcastIntegrationTestUser) msg.getPayload()).getSurname());
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(edDistributedList3, edListChannel3);
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(edDistributedList3, edListChannel3);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -48,114 +48,114 @@ import com.hazelcast.core.IMap;
@SuppressWarnings("unchecked")
public class HazelcastDistributedMapEventDrivenInboundChannelAdapterTests {
@Autowired
private PollableChannel edMapChannel1;
@Autowired
private PollableChannel edMapChannel1;
@Autowired
private PollableChannel edMapChannel2;
@Autowired
private PollableChannel edMapChannel2;
@Autowired
private PollableChannel edMapChannel3;
@Autowired
private PollableChannel edMapChannel3;
@Autowired
private PollableChannel edMapChannel4;
@Autowired
private PollableChannel edMapChannel4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> edDistributedMap4;
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(edDistributedMap1,
edMapChannel1, "edDistributedMap1");
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(edDistributedMap1,
edMapChannel1, "edDistributedMap1");
}
@Test
public void testEventDrivenForOnlyUPDATEDEntryEvent() {
edDistributedMap2
.put(2, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edDistributedMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
Message<?> msg =
edMapChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.UPDATED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edDistributedMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testEventDrivenForOnlyUPDATEDEntryEvent() {
edDistributedMap2
.put(2, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edDistributedMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
Message<?> msg =
edMapChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.UPDATED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edDistributedMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
edDistributedMap3
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edDistributedMap3
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
edDistributedMap3.remove(2);
Message<?> msg =
edMapChannel3.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edDistributedMap3",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
edDistributedMap3
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edDistributedMap3
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
edDistributedMap3.remove(2);
Message<?> msg =
edMapChannel3.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edDistributedMap3",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(edDistributedMap4, edMapChannel4,
"edDistributedMap4");
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(edDistributedMap4, edMapChannel4,
"edDistributedMap4");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -46,69 +46,69 @@ import com.hazelcast.core.IQueue;
@DirtiesContext
public class HazelcastDistributedQueueEventDrivenInboundChannelAdapterTests {
@Autowired
private PollableChannel edQueueChannel1;
@Autowired
private PollableChannel edQueueChannel1;
@Autowired
private PollableChannel edQueueChannel2;
@Autowired
private PollableChannel edQueueChannel2;
@Autowired
private PollableChannel edQueueChannel3;
@Autowired
private PollableChannel edQueueChannel3;
@Resource
private IQueue<HazelcastIntegrationTestUser> edDistributedQueue1;
@Resource
private IQueue<HazelcastIntegrationTestUser> edDistributedQueue1;
@Resource
private IQueue<HazelcastIntegrationTestUser> edDistributedQueue2;
@Resource
private IQueue<HazelcastIntegrationTestUser> edDistributedQueue2;
@Resource
private IQueue<HazelcastIntegrationTestUser> edDistributedQueue3;
@Resource
private IQueue<HazelcastIntegrationTestUser> edDistributedQueue3;
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedQueue1
.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg =
edQueueChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(1, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedQueue1
.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg =
edQueueChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(1, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
HazelcastIntegrationTestUser user =
new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2");
edDistributedQueue2.add(user);
edDistributedQueue2.remove(user);
Message<?> msg =
edQueueChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(2, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
HazelcastIntegrationTestUser user =
new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2");
edDistributedQueue2.add(user);
edDistributedQueue2.remove(user);
Message<?> msg =
edQueueChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(2, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(edDistributedQueue3,
edQueueChannel3);
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(edDistributedQueue3,
edQueueChannel3);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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,52 +42,52 @@ import com.hazelcast.core.IMap;
@DirtiesContext
public class HazelcastDistributedSQLInboundChannelAdapterTests {
@Autowired
private PollableChannel dsMapChannel1;
@Autowired
private PollableChannel dsMapChannel1;
@Autowired
private PollableChannel dsMapChannel2;
@Autowired
private PollableChannel dsMapChannel2;
@Autowired
private PollableChannel dsMapChannel3;
@Autowired
private PollableChannel dsMapChannel3;
@Autowired
private PollableChannel dsMapChannel4;
@Autowired
private PollableChannel dsMapChannel4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> dsDistributedMap4;
@Test
public void testDistributedSQLForOnlyENTRYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForENTRYIterationType(dsDistributedMap1, dsMapChannel1);
}
@Test
public void testDistributedSQLForOnlyENTRYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForENTRYIterationType(dsDistributedMap1, dsMapChannel1);
}
@Test
public void testDistributedSQLForOnlyKEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForKEYIterationType(dsDistributedMap2, dsMapChannel2);
}
@Test
public void testDistributedSQLForOnlyKEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForKEYIterationType(dsDistributedMap2, dsMapChannel2);
}
@Test
public void testDistributedSQLForOnlyLOCAL_KEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForLOCAL_KEYIterationType(dsDistributedMap3, dsMapChannel3);
}
@Test
public void testDistributedSQLForOnlyLOCAL_KEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForLOCAL_KEYIterationType(dsDistributedMap3, dsMapChannel3);
}
@Test
public void testDistributedSQLForOnlyVALUEIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForVALUEIterationType(dsDistributedMap4, dsMapChannel4);
}
@Test
public void testDistributedSQLForOnlyVALUEIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForVALUEIterationType(dsDistributedMap4, dsMapChannel4);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -46,69 +46,69 @@ import com.hazelcast.core.ISet;
@DirtiesContext
public class HazelcastDistributedSetEventDrivenInboundChannelAdapterTests {
@Autowired
private PollableChannel edSetChannel1;
@Autowired
private PollableChannel edSetChannel1;
@Autowired
private PollableChannel edSetChannel2;
@Autowired
private PollableChannel edSetChannel2;
@Autowired
private PollableChannel edSetChannel3;
@Autowired
private PollableChannel edSetChannel3;
@Resource
private ISet<HazelcastIntegrationTestUser> edDistributedSet1;
@Resource
private ISet<HazelcastIntegrationTestUser> edDistributedSet1;
@Resource
private ISet<HazelcastIntegrationTestUser> edDistributedSet2;
@Resource
private ISet<HazelcastIntegrationTestUser> edDistributedSet2;
@Resource
private ISet<HazelcastIntegrationTestUser> edDistributedSet3;
@Resource
private ISet<HazelcastIntegrationTestUser> edDistributedSet3;
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedSet1
.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg =
edSetChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(1, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edDistributedSet1
.add(new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg =
edSetChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(1, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname1",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
HazelcastIntegrationTestUser user =
new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2");
edDistributedSet2.add(user);
edDistributedSet2.remove(user);
Message<?> msg =
edSetChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(2, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
HazelcastIntegrationTestUser user =
new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2");
edDistributedSet2.add(user);
edDistributedSet2.remove(user);
Message<?> msg =
edSetChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.toString(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE).toString());
Assert
.assertEquals(2, (((HazelcastIntegrationTestUser) msg.getPayload()).getId()));
Assert.assertEquals("TestName2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getName()));
Assert.assertEquals("TestSurname2",
(((HazelcastIntegrationTestUser) msg.getPayload()).getSurname()));
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(edDistributedSet3,
edSetChannel3);
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(edDistributedSet3,
edSetChannel3);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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,16 +42,16 @@ import com.hazelcast.core.ITopic;
@DirtiesContext
public class HazelcastDistributedTopicEventDrivenInboundChannelAdapterTests {
@Autowired
private PollableChannel edTopicChannel1;
@Autowired
private PollableChannel edTopicChannel1;
@Resource
private ITopic<HazelcastIntegrationTestUser> edDistributedTopic1;
@Resource
private ITopic<HazelcastIntegrationTestUser> edDistributedTopic1;
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForTopicMessageEvent(edDistributedTopic1, edTopicChannel1);
}
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForTopicMessageEvent(edDistributedTopic1, edTopicChannel1);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -49,91 +49,91 @@ import com.hazelcast.core.MultiMap;
@SuppressWarnings("unchecked")
public class HazelcastMultiMapEventDrivenInboundChannelAdapterTests {
@Autowired
private PollableChannel edMultiMapChannel1;
@Autowired
private PollableChannel edMultiMapChannel1;
@Autowired
private PollableChannel edMultiMapChannel2;
@Autowired
private PollableChannel edMultiMapChannel2;
@Autowired
private PollableChannel edMultiMapChannel3;
@Autowired
private PollableChannel edMultiMapChannel3;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> edMultiMap1;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> edMultiMap1;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> edMultiMap2;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> edMultiMap2;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> edMultiMap3;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> edMultiMap3;
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edMultiMap1
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg =
edMultiMapChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edMultiMap1",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edMultiMap1
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg =
edMultiMapChannel1.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edMultiMap1",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertEquals(Integer.valueOf(1),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
Assert.assertEquals(Integer.valueOf(1),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
edMultiMap2
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edMultiMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
edMultiMap2.remove(2);
Message<?> msg =
edMultiMapChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edMultiMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
edMultiMap2
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edMultiMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
edMultiMap2.remove(2);
Message<?> msg =
edMultiMapChannel2.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edMultiMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertNull(((EntryEventMessagePayload<?, ?>) msg.getPayload()).value);
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertNull(((EntryEventMessagePayload<?, ?>) msg.getPayload()).value);
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForMultiMapEntryEvents(edMultiMap3, edMultiMapChannel3,
"edMultiMap3");
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForMultiMapEntryEvents(edMultiMap3, edMultiMapChannel3,
"edMultiMap3");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -48,137 +48,137 @@ import com.hazelcast.core.ReplicatedMap;
@SuppressWarnings("unchecked")
public class HazelcastReplicatedMapEventDrivenInboundChannelAdapterTests {
@Autowired
private PollableChannel edReplicatedMapChannel1;
@Autowired
private PollableChannel edReplicatedMapChannel1;
@Autowired
private PollableChannel edReplicatedMapChannel2;
@Autowired
private PollableChannel edReplicatedMapChannel2;
@Autowired
private PollableChannel edReplicatedMapChannel3;
@Autowired
private PollableChannel edReplicatedMapChannel3;
@Autowired
private PollableChannel edReplicatedMapChannel4;
@Autowired
private PollableChannel edReplicatedMapChannel4;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap1;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap1;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap2;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap2;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap3;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap3;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap4;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> edReplicatedMap4;
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edReplicatedMap1
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg = edReplicatedMapChannel1
.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edReplicatedMap1",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testEventDrivenForOnlyADDEDEntryEvent() {
edReplicatedMap1
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg = edReplicatedMapChannel1
.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.ADDED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edReplicatedMap1",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertEquals(Integer.valueOf(1),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
Assert.assertEquals(Integer.valueOf(1),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
@Test
public void testEventDrivenForOnlyUPDATEDEntryEvent() {
edReplicatedMap2
.put(2, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edReplicatedMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
Message<?> msg = edReplicatedMapChannel2
.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
@Test
public void testEventDrivenForOnlyUPDATEDEntryEvent() {
edReplicatedMap2
.put(2, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edReplicatedMap2
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
Message<?> msg = edReplicatedMapChannel2
.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.UPDATED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edReplicatedMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.UPDATED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edReplicatedMap2",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(1,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname1",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).value).getSurname());
}
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
edReplicatedMap3
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edReplicatedMap3
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
edReplicatedMap3.remove(2);
Message<?> msg = edReplicatedMapChannel3
.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edReplicatedMap3",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
@Test
public void testEventDrivenForOnlyREMOVEDEntryEvent() {
edReplicatedMap3
.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
edReplicatedMap3
.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
edReplicatedMap3.remove(2);
Message<?> msg = edReplicatedMapChannel3
.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT);
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
Assert.assertTrue(msg.getPayload() instanceof EntryEventMessagePayload);
Assert.assertNotNull(msg.getHeaders().get(HazelcastHeaders.MEMBER));
Assert.assertEquals(EntryEventType.REMOVED.name(),
msg.getHeaders().get(HazelcastHeaders.EVENT_TYPE));
Assert.assertEquals("edReplicatedMap3",
msg.getHeaders().get(HazelcastHeaders.CACHE_NAME));
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
Assert.assertEquals(Integer.valueOf(2),
((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).key);
Assert.assertEquals(2,
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getId());
Assert.assertEquals("TestName2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getName());
Assert.assertEquals("TestSurname2",
(((EntryEventMessagePayload<Integer, HazelcastIntegrationTestUser>) msg
.getPayload()).oldValue).getSurname());
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForReplicatedMapEntryEvents(edReplicatedMap4,
edReplicatedMapChannel4, "edReplicatedMap4");
}
@Test
public void testEventDrivenForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForReplicatedMapEntryEvents(edReplicatedMap4,
edReplicatedMapChannel4, "edReplicatedMap4");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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,48 +40,48 @@ import com.hazelcast.core.IMap;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = HazelcastIntegrationInboundTestConfiguration.class,
loader = AnnotationConfigContextLoader.class)
loader = AnnotationConfigContextLoader.class)
@DirtiesContext
public class HazelcastCQDistributedMapInboundChannelAdapterConfigTests {
@Autowired
private PollableChannel cqDistributedMapChannel1;
@Autowired
private PollableChannel cqDistributedMapChannel1;
@Autowired
private PollableChannel cqDistributedMapChannel2;
@Autowired
private PollableChannel cqDistributedMapChannel2;
@Autowired
private PollableChannel cqDistributedMapChannel3;
@Autowired
private PollableChannel cqDistributedMapChannel3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap1;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap3;
@Test
public void testContinuousQueryForADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(testCQDistributedMap1,
cqDistributedMapChannel1, "Test_CQ_Distributed_Map1");
}
@Test
public void testContinuousQueryForADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(testCQDistributedMap1,
cqDistributedMapChannel1, "Test_CQ_Distributed_Map1");
}
@Test
public void testContinuousQueryForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(testCQDistributedMap2,
cqDistributedMapChannel2, "Test_CQ_Distributed_Map2");
}
@Test
public void testContinuousQueryForALLEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(testCQDistributedMap2,
cqDistributedMapChannel2, "Test_CQ_Distributed_Map2");
}
@Test
public void testContinuousQueryForUPDATEDEntryEventWhenIncludeValueIsFalse() {
HazelcastInboundChannelAdapterTestUtils
.testContinuousQueryForUPDATEDEntryEventWhenIncludeValueIsFalse(
testCQDistributedMap3, cqDistributedMapChannel3,
"Test_CQ_Distributed_Map3");
}
@Test
public void testContinuousQueryForUPDATEDEntryEventWhenIncludeValueIsFalse() {
HazelcastInboundChannelAdapterTestUtils
.testContinuousQueryForUPDATEDEntryEventWhenIncludeValueIsFalse(
testCQDistributedMap3, cqDistributedMapChannel3,
"Test_CQ_Distributed_Map3");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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,27 +39,27 @@ import com.hazelcast.core.HazelcastInstance;
@DirtiesContext
public class HazelcastClusterMonitorInboundChannelAdapterConfigTests {
@Autowired
private PollableChannel cmonChannel;
@Autowired
private PollableChannel cmonChannel;
@Autowired
private PollableChannel cmonChannel2;
@Autowired
private PollableChannel cmonChannel2;
@Autowired
private HazelcastInstance testHazelcastInstance;
@Autowired
private HazelcastInstance testHazelcastInstance;
@Test
public void testConfigDrivenMembershipEvent() {
HazelcastInboundChannelAdapterTestUtils
.testMembershipEvent(testHazelcastInstance, cmonChannel, "testKey1",
"testValue1");
}
@Test
public void testConfigDrivenMembershipEvent() {
HazelcastInboundChannelAdapterTestUtils
.testMembershipEvent(testHazelcastInstance, cmonChannel, "testKey1",
"testValue1");
}
@Test
public void testConfigDrivenDistributedObjectEvent() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedObjectEventByChannelAndHazelcastInstance(cmonChannel2,
testHazelcastInstance, "Test_Distributed_Map3");
}
@Test
public void testConfigDrivenDistributedObjectEvent() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedObjectEventByChannelAndHazelcastInstance(cmonChannel2,
testHazelcastInstance, "Test_Distributed_Map3");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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,60 +40,60 @@ import com.hazelcast.core.IMap;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = HazelcastIntegrationInboundTestConfiguration.class,
loader = AnnotationConfigContextLoader.class)
loader = AnnotationConfigContextLoader.class)
@DirtiesContext
public class HazelcastDistributedSQLInboundChannelAdapterConfigTests {
@Autowired
private PollableChannel dsDistributedMapChannel;
@Autowired
private PollableChannel dsDistributedMapChannel;
@Autowired
private PollableChannel dsDistributedMapChannel2;
@Autowired
private PollableChannel dsDistributedMapChannel2;
@Autowired
private PollableChannel dsDistributedMapChannel3;
@Autowired
private PollableChannel dsDistributedMapChannel3;
@Autowired
private PollableChannel dsDistributedMapChannel4;
@Autowired
private PollableChannel dsDistributedMapChannel4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap3;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap4;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap4;
@Test
public void testDistributedSQLForENTRYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForENTRYIterationType(testDSDistributedMap,
dsDistributedMapChannel);
}
@Test
public void testDistributedSQLForENTRYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForENTRYIterationType(testDSDistributedMap,
dsDistributedMapChannel);
}
@Test
public void testDistributedSQLForKEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForKEYIterationType(testDSDistributedMap2,
dsDistributedMapChannel2);
}
@Test
public void testDistributedSQLForKEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForKEYIterationType(testDSDistributedMap2,
dsDistributedMapChannel2);
}
@Test
public void testDistributedSQLForLOCAL_KEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForLOCAL_KEYIterationType(testDSDistributedMap3,
dsDistributedMapChannel3);
}
@Test
public void testDistributedSQLForLOCAL_KEYIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForLOCAL_KEYIterationType(testDSDistributedMap3,
dsDistributedMapChannel3);
}
@Test
public void testDistributedSQLForVALUEIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForVALUEIterationType(testDSDistributedMap4,
dsDistributedMapChannel4);
}
@Test
public void testDistributedSQLForVALUEIterationType() {
HazelcastInboundChannelAdapterTestUtils
.testDistributedSQLForVALUEIterationType(testDSDistributedMap4,
dsDistributedMapChannel4);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -46,111 +46,111 @@ import com.hazelcast.core.ReplicatedMap;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = HazelcastIntegrationInboundTestConfiguration.class,
loader = AnnotationConfigContextLoader.class)
loader = AnnotationConfigContextLoader.class)
@DirtiesContext
public class HazelcastEventDrivenInboundChannelAdapterConfigTests {
@Autowired
private PollableChannel distributedMapChannel;
@Autowired
private PollableChannel distributedMapChannel;
@Autowired
private PollableChannel distributedMapChannel2;
@Autowired
private PollableChannel distributedMapChannel2;
@Autowired
private PollableChannel distributedListChannel;
@Autowired
private PollableChannel distributedListChannel;
@Autowired
private PollableChannel distributedSetChannel;
@Autowired
private PollableChannel distributedSetChannel;
@Autowired
private PollableChannel distributedQueueChannel;
@Autowired
private PollableChannel distributedQueueChannel;
@Autowired
private PollableChannel topicChannel;
@Autowired
private PollableChannel topicChannel;
@Autowired
private PollableChannel replicatedMapChannel;
@Autowired
private PollableChannel replicatedMapChannel;
@Autowired
private PollableChannel multiMapChannel;
@Autowired
private PollableChannel multiMapChannel;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap2;
@Resource
private IList<HazelcastIntegrationTestUser> testDistributedList;
@Resource
private IList<HazelcastIntegrationTestUser> testDistributedList;
@Resource
private ISet<HazelcastIntegrationTestUser> testDistributedSet;
@Resource
private ISet<HazelcastIntegrationTestUser> testDistributedSet;
@Resource
private IQueue<HazelcastIntegrationTestUser> testDistributedQueue;
@Resource
private IQueue<HazelcastIntegrationTestUser> testDistributedQueue;
@Resource
private ITopic<HazelcastIntegrationTestUser> testTopic;
@Resource
private ITopic<HazelcastIntegrationTestUser> testTopic;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> testReplicatedMap;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> testReplicatedMap;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> testMultiMap;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> testMultiMap;
@Test
public void testEventDrivenForADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(testDistributedMap,
distributedMapChannel, "Test_Distributed_Map");
}
@Test
public void testEventDrivenForADDEDEntryEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForADDEDDistributedMapEntryEvent(testDistributedMap,
distributedMapChannel, "Test_Distributed_Map");
}
@Test
public void testEventDrivenForEntryEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(testDistributedMap2,
distributedMapChannel2, "Test_Distributed_Map2");
}
@Test
public void testEventDrivenForEntryEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedMapEntryEvents(testDistributedMap2,
distributedMapChannel2, "Test_Distributed_Map2");
}
@Test
public void testEventDrivenForDistributedListItemEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(testDistributedList,
distributedListChannel);
}
@Test
public void testEventDrivenForDistributedListItemEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(testDistributedList,
distributedListChannel);
}
@Test
public void testEventDrivenForDistributedSetItemEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(testDistributedSet,
distributedSetChannel);
}
@Test
public void testEventDrivenForDistributedSetItemEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(testDistributedSet,
distributedSetChannel);
}
@Test
public void testEventDrivenForDistributedQueueItemEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(testDistributedQueue,
distributedQueueChannel);
}
@Test
public void testEventDrivenForDistributedQueueItemEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForDistributedCollectionItemEvents(testDistributedQueue,
distributedQueueChannel);
}
@Test
public void testEventDrivenForADDEDMessageEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForTopicMessageEvent(testTopic, topicChannel);
}
@Test
public void testEventDrivenForADDEDMessageEvent() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForTopicMessageEvent(testTopic, topicChannel);
}
@Test
public void testEventDrivenForReplicatedMapEntryEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForReplicatedMapEntryEvents(testReplicatedMap,
replicatedMapChannel, "Test_Replicated_Map");
}
@Test
public void testEventDrivenForReplicatedMapEntryEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForReplicatedMapEntryEvents(testReplicatedMap,
replicatedMapChannel, "Test_Replicated_Map");
}
@Test
public void testEventDrivenForMultiMapEntryEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForMultiMapEntryEvents(testMultiMap, multiMapChannel,
"Test_Multi_Map");
}
@Test
public void testEventDrivenForMultiMapEntryEvents() {
HazelcastInboundChannelAdapterTestUtils
.testEventDrivenForMultiMapEntryEvents(testMultiMap, multiMapChannel,
"Test_Multi_Map");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -50,330 +50,330 @@ import com.hazelcast.core.ReplicatedMap;
@EnableIntegration
public class HazelcastIntegrationInboundTestConfiguration {
@Bean
public PollableChannel distributedMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedMapChannel2() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedMapChannel2() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedListChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedListChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedSetChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedSetChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedQueueChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel distributedQueueChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel topicChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel topicChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel multiMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel multiMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel replicatedMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel replicatedMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel cqDistributedMapChannel1() {
return new QueueChannel();
}
@Bean
public PollableChannel cqDistributedMapChannel1() {
return new QueueChannel();
}
@Bean
public PollableChannel cqDistributedMapChannel2() {
return new QueueChannel();
}
@Bean
public PollableChannel cqDistributedMapChannel2() {
return new QueueChannel();
}
@Bean
public PollableChannel cqDistributedMapChannel3() {
return new QueueChannel();
}
@Bean
public PollableChannel cqDistributedMapChannel3() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel2() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel2() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel3() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel3() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel4() {
return new QueueChannel();
}
@Bean
public PollableChannel dsDistributedMapChannel4() {
return new QueueChannel();
}
@Bean
public PollableChannel cmonChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel cmonChannel() {
return new QueueChannel();
}
@Bean
public PollableChannel cmonChannel2() {
return new QueueChannel();
}
@Bean
public PollableChannel cmonChannel2() {
return new QueueChannel();
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap() {
return testHazelcastInstance().getMap("Test_Distributed_Map");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap() {
return testHazelcastInstance().getMap("Test_Distributed_Map");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap2() {
return testHazelcastInstance().getMap("Test_Distributed_Map2");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDistributedMap2() {
return testHazelcastInstance().getMap("Test_Distributed_Map2");
}
@Bean
public IList<HazelcastIntegrationTestUser> testDistributedList() {
return testHazelcastInstance().getList("Test_Distributed_List");
}
@Bean
public IList<HazelcastIntegrationTestUser> testDistributedList() {
return testHazelcastInstance().getList("Test_Distributed_List");
}
@Bean
public ISet<HazelcastIntegrationTestUser> testDistributedSet() {
return testHazelcastInstance().getSet("Test_Distributed_Set");
}
@Bean
public ISet<HazelcastIntegrationTestUser> testDistributedSet() {
return testHazelcastInstance().getSet("Test_Distributed_Set");
}
@Bean
public IQueue<HazelcastIntegrationTestUser> testDistributedQueue() {
return testHazelcastInstance().getQueue("Test_Distributed_Queue");
}
@Bean
public IQueue<HazelcastIntegrationTestUser> testDistributedQueue() {
return testHazelcastInstance().getQueue("Test_Distributed_Queue");
}
@Bean
public ITopic<HazelcastIntegrationTestUser> testTopic() {
return testHazelcastInstance().getTopic("Test_Topic");
}
@Bean
public ITopic<HazelcastIntegrationTestUser> testTopic() {
return testHazelcastInstance().getTopic("Test_Topic");
}
@Bean
public MultiMap<Integer, HazelcastIntegrationTestUser> testMultiMap() {
return testHazelcastInstance().getMultiMap("Test_Multi_Map");
}
@Bean
public MultiMap<Integer, HazelcastIntegrationTestUser> testMultiMap() {
return testHazelcastInstance().getMultiMap("Test_Multi_Map");
}
@Bean
public ReplicatedMap<Integer, HazelcastIntegrationTestUser> testReplicatedMap() {
return testHazelcastInstance().getReplicatedMap("Test_Replicated_Map");
}
@Bean
public ReplicatedMap<Integer, HazelcastIntegrationTestUser> testReplicatedMap() {
return testHazelcastInstance().getReplicatedMap("Test_Replicated_Map");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap1() {
return testHazelcastInstance().getMap("Test_CQ_Distributed_Map1");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap1() {
return testHazelcastInstance().getMap("Test_CQ_Distributed_Map1");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap2() {
return testHazelcastInstance().getMap("Test_CQ_Distributed_Map2");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap2() {
return testHazelcastInstance().getMap("Test_CQ_Distributed_Map2");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap3() {
return testHazelcastInstance().getMap("Test_CQ_Distributed_Map3");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testCQDistributedMap3() {
return testHazelcastInstance().getMap("Test_CQ_Distributed_Map3");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap2() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map2");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap2() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map2");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap3() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map3");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap3() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map3");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap4() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map4");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> testDSDistributedMap4() {
return testHazelcastInstance().getMap("Test_DS_Distributed_Map4");
}
@Bean
public HazelcastInstance testHazelcastInstance() {
return Hazelcast.newHazelcastInstance();
}
@Bean
public HazelcastInstance testHazelcastInstance() {
return Hazelcast.newHazelcastInstance();
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedMap());
producer.setOutputChannel(distributedMapChannel());
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedMap());
producer.setOutputChannel(distributedMapChannel());
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer2() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedMap2());
producer.setOutputChannel(distributedMapChannel2());
producer.setCacheEventTypes("ADDED,REMOVED,UPDATED,CLEAR_ALL");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer2() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedMap2());
producer.setOutputChannel(distributedMapChannel2());
producer.setCacheEventTypes("ADDED,REMOVED,UPDATED,CLEAR_ALL");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer3() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedList());
producer.setOutputChannel(distributedListChannel());
producer.setCacheEventTypes("ADDED,REMOVED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer3() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedList());
producer.setOutputChannel(distributedListChannel());
producer.setCacheEventTypes("ADDED,REMOVED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer4() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedSet());
producer.setOutputChannel(distributedSetChannel());
producer.setCacheEventTypes("ADDED,REMOVED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer4() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedSet());
producer.setOutputChannel(distributedSetChannel());
producer.setCacheEventTypes("ADDED,REMOVED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer5() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedQueue());
producer.setOutputChannel(distributedQueueChannel());
producer.setCacheEventTypes("ADDED,REMOVED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer5() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testDistributedQueue());
producer.setOutputChannel(distributedQueueChannel());
producer.setCacheEventTypes("ADDED,REMOVED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer6() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testTopic());
producer.setOutputChannel(topicChannel());
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer6() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testTopic());
producer.setOutputChannel(topicChannel());
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer7() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testReplicatedMap());
producer.setOutputChannel(replicatedMapChannel());
producer.setCacheEventTypes("ADDED,REMOVED,UPDATED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer7() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testReplicatedMap());
producer.setOutputChannel(replicatedMapChannel());
producer.setCacheEventTypes("ADDED,REMOVED,UPDATED");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer8() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testMultiMap());
producer.setOutputChannel(multiMapChannel());
producer.setCacheEventTypes("ADDED,REMOVED,CLEAR_ALL");
return producer;
}
@Bean
public HazelcastEventDrivenMessageProducer hazelcastEventDrivenMessageProducer8() {
final HazelcastEventDrivenMessageProducer producer =
new HazelcastEventDrivenMessageProducer(testMultiMap());
producer.setOutputChannel(multiMapChannel());
producer.setCacheEventTypes("ADDED,REMOVED,CLEAR_ALL");
return producer;
}
@Bean
public HazelcastContinuousQueryMessageProducer hazelcastContinuousQueryMessageProducer() {
final HazelcastContinuousQueryMessageProducer producer =
new HazelcastContinuousQueryMessageProducer(testCQDistributedMap1(),
"name=TestName1");
producer.setOutputChannel(cqDistributedMapChannel1());
return producer;
}
@Bean
public HazelcastContinuousQueryMessageProducer hazelcastContinuousQueryMessageProducer() {
final HazelcastContinuousQueryMessageProducer producer =
new HazelcastContinuousQueryMessageProducer(testCQDistributedMap1(),
"name=TestName1");
producer.setOutputChannel(cqDistributedMapChannel1());
return producer;
}
@Bean
public HazelcastContinuousQueryMessageProducer hazelcastContinuousQueryMessageProducer2() {
final HazelcastContinuousQueryMessageProducer producer =
new HazelcastContinuousQueryMessageProducer(testCQDistributedMap2(),
"name=TestName1 OR name=TestName2");
producer.setOutputChannel(cqDistributedMapChannel2());
producer.setCacheEventTypes("ADDED,REMOVED,UPDATED,CLEAR_ALL");
return producer;
}
@Bean
public HazelcastContinuousQueryMessageProducer hazelcastContinuousQueryMessageProducer2() {
final HazelcastContinuousQueryMessageProducer producer =
new HazelcastContinuousQueryMessageProducer(testCQDistributedMap2(),
"name=TestName1 OR name=TestName2");
producer.setOutputChannel(cqDistributedMapChannel2());
producer.setCacheEventTypes("ADDED,REMOVED,UPDATED,CLEAR_ALL");
return producer;
}
@Bean
public HazelcastContinuousQueryMessageProducer hazelcastContinuousQueryMessageProducer3() {
final HazelcastContinuousQueryMessageProducer producer =
new HazelcastContinuousQueryMessageProducer(testCQDistributedMap3(),
"surname=TestSurname2");
producer.setOutputChannel(cqDistributedMapChannel3());
producer.setCacheEventTypes("UPDATED");
producer.setIncludeValue(false);
return producer;
}
@Bean
public HazelcastContinuousQueryMessageProducer hazelcastContinuousQueryMessageProducer3() {
final HazelcastContinuousQueryMessageProducer producer =
new HazelcastContinuousQueryMessageProducer(testCQDistributedMap3(),
"surname=TestSurname2");
producer.setOutputChannel(cqDistributedMapChannel3());
producer.setCacheEventTypes("UPDATED");
producer.setIncludeValue(false);
return producer;
}
@Bean
public HazelcastClusterMonitorMessageProducer hazelcastClusterMonitorMessageProducer() {
final HazelcastClusterMonitorMessageProducer producer =
new HazelcastClusterMonitorMessageProducer(testHazelcastInstance());
producer.setOutputChannel(cmonChannel());
return producer;
}
@Bean
public HazelcastClusterMonitorMessageProducer hazelcastClusterMonitorMessageProducer() {
final HazelcastClusterMonitorMessageProducer producer =
new HazelcastClusterMonitorMessageProducer(testHazelcastInstance());
producer.setOutputChannel(cmonChannel());
return producer;
}
@Bean
public HazelcastClusterMonitorMessageProducer hazelcastClusterMonitorMessageProducer2() {
final HazelcastClusterMonitorMessageProducer producer =
new HazelcastClusterMonitorMessageProducer(testHazelcastInstance());
producer.setOutputChannel(cmonChannel2());
producer.setMonitorEventTypes("DISTRIBUTED_OBJECT");
return producer;
}
@Bean
public HazelcastClusterMonitorMessageProducer hazelcastClusterMonitorMessageProducer2() {
final HazelcastClusterMonitorMessageProducer producer =
new HazelcastClusterMonitorMessageProducer(testHazelcastInstance());
producer.setOutputChannel(cmonChannel2());
producer.setMonitorEventTypes("DISTRIBUTED_OBJECT");
return producer;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap(),
"name='TestName4' AND surname='TestSurname4'");
messageSource.setIterationType(DistributedSQLIterationType.ENTRY);
return messageSource;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap(),
"name='TestName4' AND surname='TestSurname4'");
messageSource.setIterationType(DistributedSQLIterationType.ENTRY);
return messageSource;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel2",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource2() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap2(),
"name='TestName1' AND surname='TestSurname1'");
messageSource.setIterationType(DistributedSQLIterationType.KEY);
return messageSource;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel2",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource2() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap2(),
"name='TestName1' AND surname='TestSurname1'");
messageSource.setIterationType(DistributedSQLIterationType.KEY);
return messageSource;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel3",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource3() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap3(),
"age > 5");
messageSource.setIterationType(DistributedSQLIterationType.LOCAL_KEY);
return messageSource;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel3",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource3() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap3(),
"age > 5");
messageSource.setIterationType(DistributedSQLIterationType.LOCAL_KEY);
return messageSource;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel4",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource4() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap4(),
"name='TestName3' AND surname='TestSurname3'");
messageSource.setIterationType(DistributedSQLIterationType.VALUE);
return messageSource;
}
@Bean
@InboundChannelAdapter(value = "dsDistributedMapChannel4",
poller = @Poller(maxMessagesPerPoll = "1"))
public HazelcastDistributedSQLMessageSource hazelcastDistributedSQLMessageSource4() {
final HazelcastDistributedSQLMessageSource messageSource =
new HazelcastDistributedSQLMessageSource(testDSDistributedMap4(),
"name='TestName3' AND surname='TestSurname3'");
messageSource.setIterationType(DistributedSQLIterationType.VALUE);
return messageSource;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -48,17 +48,18 @@ import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.spi.exception.DistributedObjectDestroyedException;
/**
* Util Class for Hazelcast Inbound Channel Adapters Test Support
* Util Class for Hazelcast Inbound Channel Adapters Test Support.
*
* @author Eren Avsarogullari
* @since 1.0.0
*/
@SuppressWarnings("unchecked")
public class HazelcastInboundChannelAdapterTestUtils {
public final class HazelcastInboundChannelAdapterTestUtils {
public static final int TIMEOUT = 20_000;
public static void verifyEntryEvent(Message<?> msg, String cacheName,
EntryEventType event) {
EntryEventType event) {
Assert.assertNotNull(msg);
Assert.assertNotNull(msg.getPayload());
if (event == EntryEventType.CLEAR_ALL || event == EntryEventType.EVICT_ALL) {
@@ -348,7 +349,7 @@ public class HazelcastInboundChannelAdapterTestUtils {
}
public static void testMembershipEvent(final HazelcastInstance instance,
final PollableChannel channel, final String key, final String value) {
final PollableChannel channel, final String key, final String value) {
Member member = instance.getCluster().getMembers().iterator().next();
member.setStringAttribute(key, value);
@@ -380,7 +381,7 @@ public class HazelcastInboundChannelAdapterTestUtils {
}
private static void verifyMembershipEvent(final Message<?> msg,
final int membershipEvent) {
final int membershipEvent) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof MembershipEvent);
@@ -390,8 +391,8 @@ public class HazelcastInboundChannelAdapterTestUtils {
}
private static void verifyDistributedObjectEvent(final Message<?> msg,
final DistributedObjectEvent.EventType eventType,
final String distributedObjectName) {
final DistributedObjectEvent.EventType eventType,
final String distributedObjectName) {
assertNotNull(msg);
assertNotNull(msg.getPayload());
assertTrue(msg.getPayload() instanceof DistributedObjectEvent);
@@ -401,4 +402,7 @@ public class HazelcastInboundChannelAdapterTestUtils {
.getName(), distributedObjectName);
}
private HazelcastInboundChannelAdapterTestUtils() {
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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,
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.hazelcast.leader;
import static org.hamcrest.CoreMatchers.is;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -60,7 +60,7 @@ import com.hazelcast.core.MultiMap;
import com.hazelcast.core.ReplicatedMap;
/**
* Hazelcast Outbound Channel Adapter Test Class
* Hazelcast Outbound Channel Adapter Test Class.
*
* @author Eren Avsarogullari
* @author Artem Bilan
@@ -69,405 +69,405 @@ import com.hazelcast.core.ReplicatedMap;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@DirtiesContext
@SuppressWarnings({"rawtypes", "unchecked"})
@SuppressWarnings({ "rawtypes", "unchecked" })
public class HazelcastOutboundChannelAdapterTests {
private static final String DISTRIBUTED_MAP = "distributedMap";
private static final String DISTRIBUTED_MAP = "distributedMap";
private static final String CACHE_HEADER = "CACHE_HEADER";
private static final String CACHE_HEADER = "CACHE_HEADER";
private final MessageBuilderFactory messageBuilderFactory =
new DefaultMessageBuilderFactory();
private final MessageBuilderFactory messageBuilderFactory =
new DefaultMessageBuilderFactory();
@Autowired
@Qualifier("firstMapChannel")
private MessageChannel firstMapChannel;
@Autowired
@Qualifier("firstMapChannel")
private MessageChannel firstMapChannel;
@Autowired
@Qualifier("secondMapChannel")
private MessageChannel secondMapChannel;
@Autowired
@Qualifier("secondMapChannel")
private MessageChannel secondMapChannel;
@Autowired
@Qualifier("thirdMapChannel")
private MessageChannel thirdMapChannel;
@Autowired
@Qualifier("thirdMapChannel")
private MessageChannel thirdMapChannel;
@Autowired
@Qualifier("fourthMapChannel")
private MessageChannel fourthMapChannel;
@Autowired
@Qualifier("fourthMapChannel")
private MessageChannel fourthMapChannel;
@Autowired
@Qualifier("fifthMapChannel")
private MessageChannel fifthMapChannel;
@Autowired
@Qualifier("fifthMapChannel")
private MessageChannel fifthMapChannel;
@Autowired
@Qualifier("sixthMapChannel")
private MessageChannel sixthMapChannel;
@Autowired
@Qualifier("sixthMapChannel")
private MessageChannel sixthMapChannel;
@Autowired
@Qualifier("bulkMapChannel")
private MessageChannel bulkMapChannel;
@Autowired
@Qualifier("bulkMapChannel")
private MessageChannel bulkMapChannel;
@Autowired
@Qualifier("multiMapChannel")
private MessageChannel multiMapChannel;
@Autowired
@Qualifier("multiMapChannel")
private MessageChannel multiMapChannel;
@Autowired
@Qualifier("replicatedMapChannel")
private MessageChannel replicatedMapChannel;
@Autowired
@Qualifier("replicatedMapChannel")
private MessageChannel replicatedMapChannel;
@Autowired
@Qualifier("bulkReplicatedMapChannel")
private MessageChannel bulkReplicatedMapChannel;
@Autowired
@Qualifier("bulkReplicatedMapChannel")
private MessageChannel bulkReplicatedMapChannel;
@Autowired
@Qualifier("listChannel")
private MessageChannel listChannel;
@Autowired
@Qualifier("listChannel")
private MessageChannel listChannel;
@Autowired
@Qualifier("bulkListChannel")
private MessageChannel bulkListChannel;
@Autowired
@Qualifier("bulkListChannel")
private MessageChannel bulkListChannel;
@Autowired
@Qualifier("setChannel")
private MessageChannel setChannel;
@Autowired
@Qualifier("setChannel")
private MessageChannel setChannel;
@Autowired
@Qualifier("bulkSetChannel")
private MessageChannel bulkSetChannel;
@Autowired
@Qualifier("bulkSetChannel")
private MessageChannel bulkSetChannel;
@Autowired
@Qualifier("queueChannel")
private MessageChannel queueChannel;
@Autowired
@Qualifier("queueChannel")
private MessageChannel queueChannel;
@Autowired
@Qualifier("bulkQueueChannel")
private MessageChannel bulkQueueChannel;
@Autowired
@Qualifier("bulkQueueChannel")
private MessageChannel bulkQueueChannel;
@Autowired
@Qualifier("topicChannel")
private MessageChannel topicChannel;
@Autowired
@Qualifier("topicChannel")
private MessageChannel topicChannel;
@Autowired
@Qualifier("lockChannel")
private MessageChannel lockChannel;
@Autowired
@Qualifier("lockChannel")
private MessageChannel lockChannel;
@Resource
private Map<?, ?> distributedMap;
@Resource
private Map<?, ?> distributedMap;
@Resource
private Map<?, ?> distributedBulkMap;
@Resource
private Map<?, ?> distributedBulkMap;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> multiMap;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> multiMap;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> bulkReplicatedMap;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> bulkReplicatedMap;
@Resource
private List<HazelcastIntegrationTestUser> distributedList;
@Resource
private List<HazelcastIntegrationTestUser> distributedList;
@Resource
private List<HazelcastIntegrationTestUser> distributedBulkList;
@Resource
private List<HazelcastIntegrationTestUser> distributedBulkList;
@Resource
private Set<HazelcastIntegrationTestUser> distributedSet;
@Resource
private Set<HazelcastIntegrationTestUser> distributedBulkSet;
@Resource
private Queue<HazelcastIntegrationTestUser> distributedQueue;
@Resource
private Queue<HazelcastIntegrationTestUser> distributedBulkQueue;
@Resource
private ITopic<HazelcastIntegrationTestUser> topic;
@Autowired
@Qualifier("testFirstMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testFirstMapRequestHandlerAdvice;
@Autowired
@Qualifier("testSecondMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testSecondMapRequestHandlerAdvice;
@Autowired
@Qualifier("testThirdMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testThirdMapRequestHandlerAdvice;
@Autowired
@Qualifier("testFourthMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testFourthMapRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkMapRequestHandlerAdvice;
@Autowired
@Qualifier("testMultiMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testMultiMapRequestHandlerAdvice;
@Autowired
@Qualifier("testReplicatedMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testReplicatedMapRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkReplicatedMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkReplicatedMapRequestHandlerAdvice;
@Autowired
@Qualifier("testListRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testListRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkListRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkListRequestHandlerAdvice;
@Autowired
@Qualifier("testSetRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testSetRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkSetRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkSetRequestHandlerAdvice;
@Autowired
@Qualifier("testQueueRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testQueueRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkQueueRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkQueueRequestHandlerAdvice;
@Autowired
@Qualifier("testTopicRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testTopicRequestHandlerAdvice;
@Before
public void setUp() {
this.distributedMap.clear();
this.distributedBulkMap.clear();
this.distributedList.clear();
this.distributedBulkList.clear();
this.distributedSet.clear();
this.distributedBulkSet.clear();
this.distributedQueue.clear();
this.distributedBulkQueue.clear();
this.multiMap.clear();
this.replicatedMap.clear();
this.bulkReplicatedMap.clear();
}
@Test
public void testWriteToDistributedMap() throws InterruptedException {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedMap(this.firstMapChannel, this.distributedMap,
this.testFirstMapRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testBulkWriteToDistributedMap(this.bulkMapChannel, this.distributedBulkMap,
this.testBulkMapRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedMapWhenCacheExpressionIsSet()
throws InterruptedException {
sendMessageWithCacheHeaderToChannel(this.secondMapChannel, CACHE_HEADER,
DISTRIBUTED_MAP);
assertTrue(this.testSecondMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyMapForPayload(new TreeMap(this.distributedMap));
}
@Test
public void testWriteToDistributedMapWhenHazelcastHeaderIsSet()
throws InterruptedException {
sendMessageWithCacheHeaderToChannel(this.thirdMapChannel,
HazelcastHeaders.CACHE_NAME, DISTRIBUTED_MAP);
assertTrue(this.testThirdMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyMapForPayload(new TreeMap(this.distributedMap));
}
@Test
public void testWriteToDistributedMapWhenExtractPayloadIsFalse()
throws InterruptedException {
sendMessageWithCacheHeaderToChannel(this.fourthMapChannel,
HazelcastHeaders.CACHE_NAME, DISTRIBUTED_MAP);
assertTrue(this.testFourthMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
verifyMapForMessage(new TreeMap(this.distributedMap));
}
@Test
public void testWriteToMultiMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToMultiMap(this.multiMapChannel, this.multiMap,
this.testMultiMapRequestHandlerAdvice);
}
@Test
public void testWriteToReplicatedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToReplicatedMap(this.replicatedMapChannel, this.replicatedMap,
this.testReplicatedMapRequestHandlerAdvice);
}
@Test
public void testBulkWriteToReplicatedMap() throws InterruptedException {
Map<Integer, HazelcastIntegrationTestUser> userMap =
new HashMap<>(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userMap
.put(index, HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkReplicatedMapChannel.send(new GenericMessage<>(userMap));
assertTrue(this.testBulkReplicatedMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyMapForPayload(new TreeMap(this.bulkReplicatedMap));
}
@Test
public void testWriteToDistributedList() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedList(this.listChannel, this.distributedList,
this.testListRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedList() throws InterruptedException {
List<HazelcastIntegrationTestUser> userList =
new ArrayList<>(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userList.add(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkListChannel.send(new GenericMessage<>(userList));
assertTrue(this.testBulkListRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyCollection(this.distributedBulkList,
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Test
public void testWriteToDistributedSet() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedSet(this.setChannel, this.distributedSet,
this.testSetRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedSet() throws InterruptedException {
Set<HazelcastIntegrationTestUser> userSet =
new HashSet<>(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userSet.add(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkSetChannel.send(new GenericMessage<>(userSet));
assertTrue(this.testBulkSetRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
final List<HazelcastIntegrationTestUser> list =
new ArrayList(this.distributedBulkSet);
Collections.sort(list);
HazelcastOutboundChannelAdapterTestUtils
.verifyCollection(list, HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Test
public void testWriteToDistributedQueue() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedQueue(this.queueChannel, this.distributedQueue,
this.testQueueRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedQueue() throws InterruptedException {
Queue<HazelcastIntegrationTestUser> userQueue =
new ArrayBlockingQueue(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userQueue.add(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkQueueChannel.send(new GenericMessage<>(userQueue));
assertTrue(this.testBulkQueueRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyCollection(this.distributedBulkQueue,
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Test
public void testWriteToTopic() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToTopic(this.topicChannel, this.topic,
this.testTopicRequestHandlerAdvice);
}
@Test(expected = MessageHandlingException.class)
public void testWriteToDistributedMapWhenCacheIsNotSet() {
this.fifthMapChannel.send(new GenericMessage<>(
HazelcastOutboundChannelAdapterTestUtils.getTestUser(1)));
}
@Test(expected = MessageHandlingException.class)
public void testWriteToDistributedMapWhenKeyExpressionIsNotSet() {
Message<HazelcastIntegrationTestUser> message = this.messageBuilderFactory
.withPayload(HazelcastOutboundChannelAdapterTestUtils.getTestUser(1))
.setHeader(HazelcastHeaders.CACHE_NAME, DISTRIBUTED_MAP).build();
this.sixthMapChannel.send(message);
}
@Test(expected = MessageHandlingException.class)
public void testWriteToLock() {
this.lockChannel.send(new GenericMessage<>("foo"));
}
private void sendMessageWithCacheHeaderToChannel(final MessageChannel channel,
final String headerName, final String distributedObjectName) {
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
Message<HazelcastIntegrationTestUser> message = this.messageBuilderFactory
.withPayload(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index))
.setHeader(headerName, distributedObjectName).build();
channel.send(message);
}
}
private void verifyMapForMessage(
final Map<Integer, Message<HazelcastIntegrationTestUser>> map) {
int index = 1;
assertNotNull(map);
assertEquals(true, map.size() == HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (Entry<Integer, Message<HazelcastIntegrationTestUser>> entry : map.entrySet()) {
assertNotNull(entry);
assertEquals(index, entry.getKey().intValue());
assertTrue(entry.getValue().getHeaders().size() > 0);
HazelcastOutboundChannelAdapterTestUtils
.verifyHazelcastIntegrationTestUser(entry.getValue().getPayload(), index);
index++;
}
}
@Resource
private Set<HazelcastIntegrationTestUser> distributedSet;
@Resource
private Set<HazelcastIntegrationTestUser> distributedBulkSet;
@Resource
private Queue<HazelcastIntegrationTestUser> distributedQueue;
@Resource
private Queue<HazelcastIntegrationTestUser> distributedBulkQueue;
@Resource
private ITopic<HazelcastIntegrationTestUser> topic;
@Autowired
@Qualifier("testFirstMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testFirstMapRequestHandlerAdvice;
@Autowired
@Qualifier("testSecondMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testSecondMapRequestHandlerAdvice;
@Autowired
@Qualifier("testThirdMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testThirdMapRequestHandlerAdvice;
@Autowired
@Qualifier("testFourthMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testFourthMapRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkMapRequestHandlerAdvice;
@Autowired
@Qualifier("testMultiMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testMultiMapRequestHandlerAdvice;
@Autowired
@Qualifier("testReplicatedMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testReplicatedMapRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkReplicatedMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkReplicatedMapRequestHandlerAdvice;
@Autowired
@Qualifier("testListRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testListRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkListRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkListRequestHandlerAdvice;
@Autowired
@Qualifier("testSetRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testSetRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkSetRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkSetRequestHandlerAdvice;
@Autowired
@Qualifier("testQueueRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testQueueRequestHandlerAdvice;
@Autowired
@Qualifier("testBulkQueueRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testBulkQueueRequestHandlerAdvice;
@Autowired
@Qualifier("testTopicRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice testTopicRequestHandlerAdvice;
@Before
public void setUp() {
this.distributedMap.clear();
this.distributedBulkMap.clear();
this.distributedList.clear();
this.distributedBulkList.clear();
this.distributedSet.clear();
this.distributedBulkSet.clear();
this.distributedQueue.clear();
this.distributedBulkQueue.clear();
this.multiMap.clear();
this.replicatedMap.clear();
this.bulkReplicatedMap.clear();
}
@Test
public void testWriteToDistributedMap() throws InterruptedException {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedMap(this.firstMapChannel, this.distributedMap,
this.testFirstMapRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testBulkWriteToDistributedMap(this.bulkMapChannel, this.distributedBulkMap,
this.testBulkMapRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedMapWhenCacheExpressionIsSet()
throws InterruptedException {
sendMessageWithCacheHeaderToChannel(this.secondMapChannel, CACHE_HEADER,
DISTRIBUTED_MAP);
assertTrue(this.testSecondMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyMapForPayload(new TreeMap(this.distributedMap));
}
@Test
public void testWriteToDistributedMapWhenHazelcastHeaderIsSet()
throws InterruptedException {
sendMessageWithCacheHeaderToChannel(this.thirdMapChannel,
HazelcastHeaders.CACHE_NAME, DISTRIBUTED_MAP);
assertTrue(this.testThirdMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyMapForPayload(new TreeMap(this.distributedMap));
}
@Test
public void testWriteToDistributedMapWhenExtractPayloadIsFalse()
throws InterruptedException {
sendMessageWithCacheHeaderToChannel(this.fourthMapChannel,
HazelcastHeaders.CACHE_NAME, DISTRIBUTED_MAP);
assertTrue(this.testFourthMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
verifyMapForMessage(new TreeMap(this.distributedMap));
}
@Test
public void testWriteToMultiMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToMultiMap(this.multiMapChannel, this.multiMap,
this.testMultiMapRequestHandlerAdvice);
}
@Test
public void testWriteToReplicatedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToReplicatedMap(this.replicatedMapChannel, this.replicatedMap,
this.testReplicatedMapRequestHandlerAdvice);
}
@Test
public void testBulkWriteToReplicatedMap() throws InterruptedException {
Map<Integer, HazelcastIntegrationTestUser> userMap =
new HashMap<>(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userMap
.put(index, HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkReplicatedMapChannel.send(new GenericMessage<>(userMap));
assertTrue(this.testBulkReplicatedMapRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyMapForPayload(new TreeMap(this.bulkReplicatedMap));
}
@Test
public void testWriteToDistributedList() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedList(this.listChannel, this.distributedList,
this.testListRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedList() throws InterruptedException {
List<HazelcastIntegrationTestUser> userList =
new ArrayList<>(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userList.add(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkListChannel.send(new GenericMessage<>(userList));
assertTrue(this.testBulkListRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyCollection(this.distributedBulkList,
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Test
public void testWriteToDistributedSet() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedSet(this.setChannel, this.distributedSet,
this.testSetRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedSet() throws InterruptedException {
Set<HazelcastIntegrationTestUser> userSet =
new HashSet<>(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userSet.add(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkSetChannel.send(new GenericMessage<>(userSet));
assertTrue(this.testBulkSetRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
final List<HazelcastIntegrationTestUser> list =
new ArrayList(this.distributedBulkSet);
Collections.sort(list);
HazelcastOutboundChannelAdapterTestUtils
.verifyCollection(list, HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Test
public void testWriteToDistributedQueue() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedQueue(this.queueChannel, this.distributedQueue,
this.testQueueRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedQueue() throws InterruptedException {
Queue<HazelcastIntegrationTestUser> userQueue =
new ArrayBlockingQueue(HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
userQueue.add(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index));
}
this.bulkQueueChannel.send(new GenericMessage<>(userQueue));
assertTrue(this.testBulkQueueRequestHandlerAdvice.executeLatch
.await(10, TimeUnit.SECONDS));
HazelcastOutboundChannelAdapterTestUtils
.verifyCollection(this.distributedBulkQueue,
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Test
public void testWriteToTopic() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToTopic(this.topicChannel, this.topic,
this.testTopicRequestHandlerAdvice);
}
@Test(expected = MessageHandlingException.class)
public void testWriteToDistributedMapWhenCacheIsNotSet() {
this.fifthMapChannel.send(new GenericMessage<>(
HazelcastOutboundChannelAdapterTestUtils.getTestUser(1)));
}
@Test(expected = MessageHandlingException.class)
public void testWriteToDistributedMapWhenKeyExpressionIsNotSet() {
Message<HazelcastIntegrationTestUser> message = this.messageBuilderFactory
.withPayload(HazelcastOutboundChannelAdapterTestUtils.getTestUser(1))
.setHeader(HazelcastHeaders.CACHE_NAME, DISTRIBUTED_MAP).build();
this.sixthMapChannel.send(message);
}
@Test(expected = MessageHandlingException.class)
public void testWriteToLock() {
this.lockChannel.send(new GenericMessage<>("foo"));
}
private void sendMessageWithCacheHeaderToChannel(final MessageChannel channel,
final String headerName, final String distributedObjectName) {
for (int index = 1;
index <= HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT; index++) {
Message<HazelcastIntegrationTestUser> message = this.messageBuilderFactory
.withPayload(HazelcastOutboundChannelAdapterTestUtils.getTestUser(index))
.setHeader(headerName, distributedObjectName).build();
channel.send(message);
}
}
private void verifyMapForMessage(
final Map<Integer, Message<HazelcastIntegrationTestUser>> map) {
int index = 1;
assertNotNull(map);
assertEquals(true, map.size() == HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
for (Entry<Integer, Message<HazelcastIntegrationTestUser>> entry : map.entrySet()) {
assertNotNull(entry);
assertEquals(index, entry.getKey().intValue());
assertTrue(entry.getValue().getHeaders().size() > 0);
HazelcastOutboundChannelAdapterTestUtils
.verifyHazelcastIntegrationTestUser(entry.getValue().getPayload(), index);
index++;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -34,13 +34,13 @@ import org.springframework.integration.hazelcast.outbound.HazelcastCacheWritingM
import org.springframework.integration.hazelcast.outbound.util.HazelcastOutboundChannelAdapterTestUtils;
import org.springframework.messaging.MessageChannel;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.ITopic;
import com.hazelcast.core.MultiMap;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.core.DistributedObject;
/**
* Configuration Class for Hazelcast Integration Outbound Test
@@ -49,252 +49,252 @@ import com.hazelcast.core.DistributedObject;
* @since 1.0.0
*/
@Configuration
@ComponentScan(basePackages = {"org.springframework.integration.hazelcast.*"})
@ComponentScan(basePackages = { "org.springframework.integration.hazelcast.*" })
@EnableIntegration
@IntegrationComponentScan("org.springframework.integration.hazelcast.outbound")
public class HazelcastIntegrationOutboundTestConfiguration {
@Bean
public MessageChannel distMapChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distMapChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distMapBulkChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distMapBulkChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distListChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distListChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distSetChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distSetChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distQueueChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel distQueueChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel topicChannel2() {
return new DirectChannel();
}
@Bean
public MessageChannel topicChannel2() {
return new DirectChannel();
}
@Bean
public MessageChannel multiMapChannel2() {
return new DirectChannel();
}
@Bean
public MessageChannel multiMapChannel2() {
return new DirectChannel();
}
@Bean
public MessageChannel replicatedMapChannel2() {
return new DirectChannel();
}
@Bean
public MessageChannel replicatedMapChannel2() {
return new DirectChannel();
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> distMap() {
return testHzInstance().getMap("Distributed_Map1");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> distMap() {
return testHzInstance().getMap("Distributed_Map1");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> distBulkMap() {
return testHzInstance().getMap("Distributed_Bulk_Map1");
}
@Bean
public IMap<Integer, HazelcastIntegrationTestUser> distBulkMap() {
return testHzInstance().getMap("Distributed_Bulk_Map1");
}
@Bean
public List<HazelcastIntegrationTestUser> distList() {
return testHzInstance().getList("Distributed_List1");
}
@Bean
public List<HazelcastIntegrationTestUser> distList() {
return testHzInstance().getList("Distributed_List1");
}
@Bean
public Set<HazelcastIntegrationTestUser> distSet() {
return testHzInstance().getSet("Distributed_Set1");
}
@Bean
public Set<HazelcastIntegrationTestUser> distSet() {
return testHzInstance().getSet("Distributed_Set1");
}
@Bean
public Queue<HazelcastIntegrationTestUser> distQueue() {
return testHzInstance().getQueue("Distributed_Queue1");
}
@Bean
public Queue<HazelcastIntegrationTestUser> distQueue() {
return testHzInstance().getQueue("Distributed_Queue1");
}
@Bean
public ITopic<HazelcastIntegrationTestUser> topic() {
return testHzInstance().getTopic("Topic1");
}
@Bean
public ITopic<HazelcastIntegrationTestUser> topic() {
return testHzInstance().getTopic("Topic1");
}
@Bean
public MultiMap<Integer, HazelcastIntegrationTestUser> multiMap() {
return testHzInstance().getMultiMap("Multi_Map1");
}
@Bean
public MultiMap<Integer, HazelcastIntegrationTestUser> multiMap() {
return testHzInstance().getMultiMap("Multi_Map1");
}
@Bean
public ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap() {
return testHzInstance().getReplicatedMap("Replicated_Map1");
}
@Bean
public ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap() {
return testHzInstance().getReplicatedMap("Replicated_Map1");
}
@Bean
public HazelcastInstance testHzInstance() {
return Hazelcast.newHazelcastInstance();
}
@Bean
public HazelcastInstance testHzInstance() {
return Hazelcast.newHazelcastInstance();
}
@Bean
public HazelcastTestRequestHandlerAdvice distMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice distMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice distBulkMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(1);
}
@Bean
public HazelcastTestRequestHandlerAdvice distBulkMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(1);
}
@Bean
public HazelcastTestRequestHandlerAdvice distListRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice distListRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice distSetRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice distSetRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice distQueueRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice distQueueRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice topicRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice topicRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice multiMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice multiMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice replicatedMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
public HazelcastTestRequestHandlerAdvice replicatedMapRequestHandlerAdvice() {
return new HazelcastTestRequestHandlerAdvice(
HazelcastOutboundChannelAdapterTestUtils.DATA_COUNT);
}
@Bean
@ServiceActivator(inputChannel = "distMapChannel", adviceChain = "distMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(distMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "distMapChannel", adviceChain = "distMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(distMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
@Bean
@ServiceActivator(inputChannel = "distMapBulkChannel",
adviceChain = "distBulkMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler2() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(distBulkMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "distMapBulkChannel",
adviceChain = "distBulkMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler2() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(distBulkMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
@Bean
@ServiceActivator(inputChannel = "distListChannel",
adviceChain = "distListRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler3() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject((DistributedObject) distList());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "distListChannel",
adviceChain = "distListRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler3() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject((DistributedObject) distList());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
@Bean
@ServiceActivator(inputChannel = "distSetChannel",
adviceChain = "distSetRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler4() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject((DistributedObject) distSet());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "distSetChannel",
adviceChain = "distSetRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler4() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject((DistributedObject) distSet());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
@Bean
@ServiceActivator(inputChannel = "distQueueChannel",
adviceChain = "distQueueRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler5() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject((DistributedObject) distQueue());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "distQueueChannel",
adviceChain = "distQueueRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler5() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject((DistributedObject) distQueue());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
@Bean
@ServiceActivator(inputChannel = "topicChannel2",
adviceChain = "topicRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler6() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(topic());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "topicChannel2",
adviceChain = "topicRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler6() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(topic());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
@Bean
@ServiceActivator(inputChannel = "multiMapChannel2",
adviceChain = "multiMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler7() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(multiMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "multiMapChannel2",
adviceChain = "multiMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler7() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(multiMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
@Bean
@ServiceActivator(inputChannel = "replicatedMapChannel2",
adviceChain = "replicatedMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler8() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(replicatedMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
@Bean
@ServiceActivator(inputChannel = "replicatedMapChannel2",
adviceChain = "replicatedMapRequestHandlerAdvice")
public HazelcastCacheWritingMessageHandler hazelcastCacheWritingMessageHandler8() {
final HazelcastCacheWritingMessageHandler handler =
new HazelcastCacheWritingMessageHandler();
handler.setDistributedObject(replicatedMap());
handler
.setKeyExpression(new SpelExpressionParser().parseExpression("payload.id"));
handler.setExtractPayload(true);
return handler;
}
return handler;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2016 the original author or authors.
* Copyright 2015-2017 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.
@@ -49,151 +49,151 @@ import com.hazelcast.core.ReplicatedMap;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = HazelcastIntegrationOutboundTestConfiguration.class,
loader = AnnotationConfigContextLoader.class)
loader = AnnotationConfigContextLoader.class)
@DirtiesContext
public class HazelcastOutboundChannelAdapterConfigTests {
@Autowired
@Qualifier("distMapChannel")
private MessageChannel distMapChannel;
@Autowired
@Qualifier("distMapChannel")
private MessageChannel distMapChannel;
@Autowired
@Qualifier("distMapBulkChannel")
private MessageChannel distMapBulkChannel;
@Autowired
@Qualifier("distMapBulkChannel")
private MessageChannel distMapBulkChannel;
@Autowired
@Qualifier("distListChannel")
private MessageChannel distListChannel;
@Autowired
@Qualifier("distListChannel")
private MessageChannel distListChannel;
@Autowired
@Qualifier("distSetChannel")
private MessageChannel distSetChannel;
@Autowired
@Qualifier("distSetChannel")
private MessageChannel distSetChannel;
@Autowired
@Qualifier("distQueueChannel")
private MessageChannel distQueueChannel;
@Autowired
@Qualifier("distQueueChannel")
private MessageChannel distQueueChannel;
@Autowired
@Qualifier("topicChannel2")
private MessageChannel topicChannel2;
@Autowired
@Qualifier("topicChannel2")
private MessageChannel topicChannel2;
@Autowired
@Qualifier("multiMapChannel2")
private MessageChannel multiMapChannel2;
@Autowired
@Qualifier("multiMapChannel2")
private MessageChannel multiMapChannel2;
@Autowired
@Qualifier("replicatedMapChannel2")
private MessageChannel replicatedMapChannel2;
@Autowired
@Qualifier("replicatedMapChannel2")
private MessageChannel replicatedMapChannel2;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> distMap;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> distMap;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> distBulkMap;
@Resource
private IMap<Integer, HazelcastIntegrationTestUser> distBulkMap;
@Resource
private List<HazelcastIntegrationTestUser> distList;
@Resource
private List<HazelcastIntegrationTestUser> distList;
@Resource
private Set<HazelcastIntegrationTestUser> distSet;
@Resource
private Set<HazelcastIntegrationTestUser> distSet;
@Resource
private Queue<HazelcastIntegrationTestUser> distQueue;
@Resource
private Queue<HazelcastIntegrationTestUser> distQueue;
@Resource
private ITopic<HazelcastIntegrationTestUser> topic;
@Resource
private ITopic<HazelcastIntegrationTestUser> topic;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> multiMap;
@Resource
private MultiMap<Integer, HazelcastIntegrationTestUser> multiMap;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap;
@Resource
private ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap;
@Autowired
@Qualifier("distMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distMapRequestHandlerAdvice;
@Autowired
@Qualifier("distMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distMapRequestHandlerAdvice;
@Autowired
@Qualifier("distBulkMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distBulkMapRequestHandlerAdvice;
@Autowired
@Qualifier("distBulkMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distBulkMapRequestHandlerAdvice;
@Autowired
@Qualifier("distListRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distListRequestHandlerAdvice;
@Autowired
@Qualifier("distListRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distListRequestHandlerAdvice;
@Autowired
@Qualifier("distSetRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distSetRequestHandlerAdvice;
@Autowired
@Qualifier("distSetRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distSetRequestHandlerAdvice;
@Autowired
@Qualifier("distQueueRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distQueueRequestHandlerAdvice;
@Autowired
@Qualifier("distQueueRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice distQueueRequestHandlerAdvice;
@Autowired
@Qualifier("topicRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice topicRequestHandlerAdvice;
@Autowired
@Qualifier("topicRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice topicRequestHandlerAdvice;
@Autowired
@Qualifier("multiMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice multiMapRequestHandlerAdvice;
@Autowired
@Qualifier("multiMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice multiMapRequestHandlerAdvice;
@Autowired
@Qualifier("replicatedMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice replicatedMapRequestHandlerAdvice;
@Autowired
@Qualifier("replicatedMapRequestHandlerAdvice")
private HazelcastTestRequestHandlerAdvice replicatedMapRequestHandlerAdvice;
@Test
public void testWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedMap(this.distMapChannel, this.distMap,
this.distMapRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedMap(this.distMapChannel, this.distMap,
this.distMapRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testBulkWriteToDistributedMap(this.distMapBulkChannel, this.distBulkMap,
this.distBulkMapRequestHandlerAdvice);
}
@Test
public void testBulkWriteToDistributedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testBulkWriteToDistributedMap(this.distMapBulkChannel, this.distBulkMap,
this.distBulkMapRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedList() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedList(this.distListChannel, this.distList,
this.distListRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedList() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedList(this.distListChannel, this.distList,
this.distListRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedSet() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedSet(this.distSetChannel, this.distSet,
this.distSetRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedSet() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedSet(this.distSetChannel, this.distSet,
this.distSetRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedQueue() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedQueue(this.distQueueChannel, this.distQueue,
this.distQueueRequestHandlerAdvice);
}
@Test
public void testWriteToDistributedQueue() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToDistributedQueue(this.distQueueChannel, this.distQueue,
this.distQueueRequestHandlerAdvice);
}
@Test
public void testWriteToTopic() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToTopic(this.topicChannel2, this.topic, this.topicRequestHandlerAdvice);
}
@Test
public void testWriteToTopic() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToTopic(this.topicChannel2, this.topic, this.topicRequestHandlerAdvice);
}
@Test
public void testWriteToMultiMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToMultiMap(this.multiMapChannel2, this.multiMap,
this.multiMapRequestHandlerAdvice);
}
@Test
public void testWriteToMultiMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToMultiMap(this.multiMapChannel2, this.multiMap,
this.multiMapRequestHandlerAdvice);
}
@Test
public void testWriteToReplicatedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToReplicatedMap(this.replicatedMapChannel2, this.replicatedMap,
this.replicatedMapRequestHandlerAdvice);
}
@Test
public void testWriteToReplicatedMap() {
HazelcastOutboundChannelAdapterTestUtils
.testWriteToReplicatedMap(this.replicatedMapChannel2, this.replicatedMap,
this.replicatedMapRequestHandlerAdvice);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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.
@@ -22,8 +22,8 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -51,8 +51,8 @@ import com.hazelcast.core.ReplicatedMap;
*
* @since 1.0.0
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class HazelcastOutboundChannelAdapterTestUtils {
@SuppressWarnings({ "unchecked", "rawtypes" })
public final class HazelcastOutboundChannelAdapterTestUtils {
public static final int DATA_COUNT = 100;
@@ -63,14 +63,14 @@ public class HazelcastOutboundChannelAdapterTestUtils {
public static final String TEST_SURNAME = "Test_Surname";
public static void testWriteToDistributedMap(MessageChannel channel,
Map<?, ?> distributedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
Map<?, ?> distributedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
testWriteToMap(channel, distributedMap, requestHandlerAdvice);
}
private static void testWriteToMap(MessageChannel channel,
Map<?, ?> distributedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
Map<?, ?> distributedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
try {
sendMessageToChannel(channel);
assertTrue(requestHandlerAdvice.executeLatch.await(10, TimeUnit.SECONDS));
@@ -82,8 +82,8 @@ public class HazelcastOutboundChannelAdapterTestUtils {
}
public static void testBulkWriteToDistributedMap(MessageChannel channel,
Map<?, ?> distributedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
Map<?, ?> distributedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
try {
Map<Integer, HazelcastIntegrationTestUser> userMap =
new HashMap<>(DATA_COUNT);
@@ -102,8 +102,8 @@ public class HazelcastOutboundChannelAdapterTestUtils {
}
public static void testWriteToMultiMap(MessageChannel channel,
MultiMap<Integer, HazelcastIntegrationTestUser> multiMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
MultiMap<Integer, HazelcastIntegrationTestUser> multiMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
try {
sendMessageToChannel(channel);
assertTrue(requestHandlerAdvice.executeLatch.await(10, TimeUnit.SECONDS));
@@ -115,20 +115,20 @@ public class HazelcastOutboundChannelAdapterTestUtils {
}
public static void testWriteToReplicatedMap(MessageChannel channel,
ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
ReplicatedMap<Integer, HazelcastIntegrationTestUser> replicatedMap,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
testWriteToMap(channel, replicatedMap, requestHandlerAdvice);
}
public static void testWriteToDistributedList(MessageChannel channel,
List<HazelcastIntegrationTestUser> distributedList,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
List<HazelcastIntegrationTestUser> distributedList,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
testWriteToDistributedCollection(channel, distributedList, requestHandlerAdvice);
}
private static void testWriteToDistributedCollection(MessageChannel channel,
Collection<HazelcastIntegrationTestUser> distributedList,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
Collection<HazelcastIntegrationTestUser> distributedList,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
try {
sendMessageToChannel(channel);
assertTrue(requestHandlerAdvice.executeLatch.await(10, TimeUnit.SECONDS));
@@ -140,8 +140,8 @@ public class HazelcastOutboundChannelAdapterTestUtils {
}
public static void testWriteToDistributedSet(MessageChannel channel,
Set<HazelcastIntegrationTestUser> distributedSet,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
Set<HazelcastIntegrationTestUser> distributedSet,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
try {
sendMessageToChannel(channel);
assertTrue(requestHandlerAdvice.executeLatch.await(10, TimeUnit.SECONDS));
@@ -155,14 +155,14 @@ public class HazelcastOutboundChannelAdapterTestUtils {
}
public static void testWriteToDistributedQueue(MessageChannel channel,
Queue<HazelcastIntegrationTestUser> distributedQueue,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
Queue<HazelcastIntegrationTestUser> distributedQueue,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
testWriteToDistributedCollection(channel, distributedQueue, requestHandlerAdvice);
}
public static void testWriteToTopic(MessageChannel channel,
ITopic<HazelcastIntegrationTestUser> topic,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
ITopic<HazelcastIntegrationTestUser> topic,
HazelcastTestRequestHandlerAdvice requestHandlerAdvice) {
try {
topic.addMessageListener(new MessageListener() {
@@ -244,4 +244,7 @@ public class HazelcastOutboundChannelAdapterTestUtils {
}
}
private HazelcastOutboundChannelAdapterTestUtils() {
}
}