DATAKV-22

+ add simple integration test for the container
This commit is contained in:
Costin Leau
2011-01-18 20:29:13 +02:00
parent 2d1669730c
commit ba55d19c7f
3 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2011 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.keyvalue.redis.listener.adapter;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.data.keyvalue.redis.listener.RedisMessageListenerContainer;
/**
* @author Costin Leau
*/
public class ContainerXmlSetupTest {
@Test
public void testContainerSetup() throws Exception {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(
"/org/springframework/data/keyvalue/redis/listener/container.xml");
RedisMessageListenerContainer container = ctx.getBean("redisContainer", RedisMessageListenerContainer.class);
assertTrue(container.isRunning());
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright 2011 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.keyvalue.redis.listener.adapter;
/**
* @author Costin Leau
*/
public class RedisMDP {
public void handle(String message) {
System.out.println("Received message " + message);
}
}

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="messageListener"
class="org.springframework.data.keyvalue.redis.listener.adapter.MessageListenerAdapter">
<constructor-arg>
<bean class="org.springframework.data.keyvalue.redis.listener.adapter.RedisMDP" />
</constructor-arg>
</bean>
<bean id="connectionFactory" class="org.springframework.data.keyvalue.redis.connection.jedis.JedisConnectionFactory"/>
<bean id="redisContainer"
class="org.springframework.data.keyvalue.redis.listener.RedisMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory" />
<property name="messageListeners">
<map>
<entry key-ref="messageListener">
<bean class="org.springframework.data.keyvalue.redis.listener.ChannelTopic">
<constructor-arg value="chatroom" />
</bean>
</entry>
</map>
</property>
</bean>
</beans>