Removed EndpointInterceptor.

This commit is contained in:
Mark Fisher
2008-10-02 02:40:52 +00:00
parent be566ea60b
commit a8ce041a0b
6 changed files with 0 additions and 259 deletions

View File

@@ -1,80 +0,0 @@
/*
* Copyright 2002-2008 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.integration.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.endpoint.EndpointInterceptor;
import org.springframework.integration.endpoint.MessageEndpoint;
import org.springframework.integration.message.StringMessage;
/**
* @author Mark Fisher
*/
public class EndpointInterceptorTests {
@Test
public void testHandlerEndpointWithBeanInterceptors() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"endpointInterceptorTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("endpointWithBeanInterceptors");
testInterceptors(endpoint, context, true);
}
@Test
public void testHandlerEndpointWithRefInterceptors() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"endpointInterceptorTests.xml", this.getClass());
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("endpointWithRefInterceptors");
testInterceptors(endpoint, context, false);
}
@SuppressWarnings("unchecked")
private static void testInterceptors(MessageEndpoint endpoint, ClassPathXmlApplicationContext context, boolean innerBeans) {
MessageChannel channel = null;
TestPreHandleInterceptor preInterceptor = null;
TestPostHandleInterceptor postInterceptor = null;
if (innerBeans) {
channel = (MessageChannel) context.getBean("inputChannelForBeans");
DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
List<EndpointInterceptor> interceptors = (List<EndpointInterceptor>) accessor.getPropertyValue("interceptors");
preInterceptor = (TestPreHandleInterceptor) interceptors.get(0);
postInterceptor = (TestPostHandleInterceptor) interceptors.get(1);
}
else {
channel = (MessageChannel) context.getBean("inputChannelForRefs");
preInterceptor = (TestPreHandleInterceptor) context.getBean("preInterceptor");
postInterceptor = (TestPostHandleInterceptor) context.getBean("postInterceptor");
}
assertEquals(0, preInterceptor.getCount());
assertEquals(0, postInterceptor.getCount());
assertTrue(channel.send(new StringMessage("test")));
assertEquals(1, preInterceptor.getCount());
assertEquals(1, postInterceptor.getCount());
context.stop();
}
}

View File

@@ -1,42 +0,0 @@
/*
* Copyright 2002-2008 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.integration.config;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.integration.endpoint.interceptor.EndpointInterceptorAdapter;
import org.springframework.integration.message.Message;
/**
* @author Mark Fisher
*/
public class TestPostHandleInterceptor extends EndpointInterceptorAdapter {
private AtomicInteger counter = new AtomicInteger();
public int getCount() {
return this.counter.get();
}
@Override
public Message<?> postHandle(Message<?> replyMessage) {
this.counter.incrementAndGet();
return replyMessage;
}
}

View File

@@ -1,42 +0,0 @@
/*
* Copyright 2002-2008 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.integration.config;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.integration.endpoint.interceptor.EndpointInterceptorAdapter;
import org.springframework.integration.message.Message;
/**
* @author Mark Fisher
*/
public class TestPreHandleInterceptor extends EndpointInterceptorAdapter {
private AtomicInteger counter = new AtomicInteger();
public int getCount() {
return this.counter.get();
}
@Override
public Message<?> preHandle(Message<?> message) {
this.counter.incrementAndGet();
return message;
}
}