INT-647 removed duplicated TestUtils and fixed resulting errors. It would be good to start using JavaConfig finally

This commit is contained in:
Iwein Fuld
2009-09-18 16:12:17 +00:00
parent 28c57bac04
commit 235c0220f5
36 changed files with 411 additions and 709 deletions

View File

@@ -1,26 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.4.0/com.springsource.javax.servlet-2.4.0.jar" sourcepath="/IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.4.0/com.springsource.javax.servlet-sources-2.4.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-sources-3.1.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.easymock/com.springsource.org.easymock.classextension/2.3.0/com.springsource.org.easymock.classextension-2.3.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.6.0/com.springsource.org.junit-4.6.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.6.0/com.springsource.org.junit-sources-4.6.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.M4/org.springframework.asm-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.M4/org.springframework.asm-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.M4/org.springframework.beans-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.M4/org.springframework.beans-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.context/3.0.0.M4/org.springframework.context-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.context/3.0.0.M4/org.springframework.context-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.core/3.0.0.M4/org.springframework.core-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.core/3.0.0.M4/org.springframework.core-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.M4/org.springframework.expression-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.M4/org.springframework.expression-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.test/3.0.0.M4/org.springframework.test-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.test/3.0.0.M4/org.springframework.test-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web/3.0.0.M4/org.springframework.web-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.web/3.0.0.M4/org.springframework.web-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.springframework/org.springframework.web.servlet/3.0.0.M4/org.springframework.web.servlet-3.0.0.M4.jar" sourcepath="/IVY_CACHE/org.springframework/org.springframework.web.servlet/3.0.0.M4/org.springframework.web.servlet-sources-3.0.0.M4.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.mockito/com.springsource.org.mockito/1.6.0/com.springsource.org.mockito-1.6.0.jar" sourcepath="/IVY_CACHE/org.mockito/com.springsource.org.mockito/1.6.0/com.springsource.org.mockito-sources-1.6.0.jar"/>
<classpathentry kind="var" path="IVY_CACHE/org.objenesis/com.springsource.org.objenesis/1.0.0/com.springsource.org.objenesis-1.0.0.jar" sourcepath="/IVY_CACHE/org.objenesis/com.springsource.org.objenesis/1.0.0/com.springsource.org.objenesis-sources-1.0.0.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="src" path="src/main/java" />
<classpathentry kind="src" path="src/main/resources" />
<classpathentry kind="src" output="target/test-classes" path="src/test/java" />
<classpathentry kind="src" path="src/test/resources" />
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.4.0/com.springsource.javax.servlet-2.4.0.jar" sourcepath="/SANDBOX_IVY_CACHE/javax.servlet/com.springsource.javax.servlet/2.4.0/com.springsource.javax.servlet-sources-2.4.0.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.jar" sourcepath="/SANDBOX_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-sources-3.1.0.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/SANDBOX_IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/SANDBOX_IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.0.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.easymock/com.springsource.org.easymock.classextension/2.3.0/com.springsource.org.easymock.classextension-2.3.0.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.junit/com.springsource.org.junit/4.6.0/com.springsource.org.junit-4.6.0.jar" sourcepath="/SANDBOX_IVY_CACHE/org.junit/com.springsource.org.junit/4.6.0/com.springsource.org.junit-sources-4.6.0.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.M4/org.springframework.asm-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.asm/3.0.0.M4/org.springframework.asm-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.M4/org.springframework.beans-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.beans/3.0.0.M4/org.springframework.beans-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.context/3.0.0.M4/org.springframework.context-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.context/3.0.0.M4/org.springframework.context-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.core/3.0.0.M4/org.springframework.core-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.core/3.0.0.M4/org.springframework.core-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.M4/org.springframework.expression-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.expression/3.0.0.M4/org.springframework.expression-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.test/3.0.0.M4/org.springframework.test-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.test/3.0.0.M4/org.springframework.test-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.web/3.0.0.M4/org.springframework.web-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.web/3.0.0.M4/org.springframework.web-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.springframework/org.springframework.web.servlet/3.0.0.M4/org.springframework.web.servlet-3.0.0.M4.jar" sourcepath="/SANDBOX_IVY_CACHE/org.springframework/org.springframework.web.servlet/3.0.0.M4/org.springframework.web.servlet-sources-3.0.0.M4.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.mockito/com.springsource.org.mockito/1.6.0/com.springsource.org.mockito-1.6.0.jar" sourcepath="/SANDBOX_IVY_CACHE/org.mockito/com.springsource.org.mockito/1.6.0/com.springsource.org.mockito-sources-1.6.0.jar" />
<classpathentry kind="var" path="SANDBOX_IVY_CACHE/org.objenesis/com.springsource.org.objenesis/1.0.0/com.springsource.org.objenesis-1.0.0.jar" sourcepath="/SANDBOX_IVY_CACHE/org.objenesis/com.springsource.org.objenesis/1.0.0/com.springsource.org.objenesis-sources-1.0.0.jar" />
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.integration" />
<classpathentry kind="src" path="/org.springframework.integration.test" combineaccessrules="false" />
<classpathentry kind="output" path="target/classes" />
</classpath>

View File

@@ -28,7 +28,8 @@
<dependency org="org.springframework" name="org.springframework.test" rev="${spring.version}" conf="test->runtime"/>
<dependency org="org.mockito" name="com.springsource.org.mockito" rev="1.6.0" conf="test->runtime"/>
<dependency org="org.springframework" name="org.springframework.web.servlet" rev="${spring.version}" conf="compile->runtime"/>
<dependency org="org.springframework.integration" name="org.springframework.integration" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.integration" name="org.springframework.integration" rev="latest.integration" conf="compile->compile"/>
<dependency org="org.springframework.integration" name="org.springframework.integration.test" rev="latest.integration" conf="test->runtime"/>
</dependencies>
</ivy-module>

View File

@@ -16,14 +16,11 @@
package org.springframework.integration.http.config;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.springframework.integration.util.TestUtils.*;
import javax.servlet.http.HttpServletResponse;
import static org.hamcrest.CoreMatchers.any;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -31,11 +28,15 @@ import org.springframework.integration.channel.SubscribableChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.http.HttpInboundEndpoint;
import static org.springframework.integration.test.util.TestUtils.getPropertyValue;
import static org.springframework.integration.test.util.TestUtils.handlerExpecting;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.servlet.http.HttpServletResponse;
/**
* @author Mark Fisher
* @author Iwein Fuld

View File

@@ -1,92 +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.util;
import static org.junit.Assert.assertThat;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.MessageHandler;
import org.springframework.util.Assert;
/**
* This is a utitily class for tests with convenience methods needed in this
* project
*
* Since there cannot be inter project dependencies on test code this utility
* class is copied around. This practice should be deprecated when there is a
* test project.
*
* @author Mark Fisher
* @author Iwein Fuld
*/
public abstract class TestUtils {
public static Object getPropertyValue(Object root, String propertyPath) {
Object value = null;
DirectFieldAccessor accessor = new DirectFieldAccessor(root);
String[] tokens = propertyPath.split("\\.");
for (int i = 0; i < tokens.length; i++) {
value = accessor.getPropertyValue(tokens[i]);
if (value != null) {
accessor = new DirectFieldAccessor(value);
}
else if (i == tokens.length - 1) {
return null;
}
else {
throw new IllegalArgumentException("intermediate property '"
+ tokens[i] + "' is null");
}
}
return value;
}
@SuppressWarnings("unchecked")
public static <T> T getPropertyValue(Object root, String propertyPath,
Class<T> type) {
Object value = getPropertyValue(root, propertyPath);
Assert.isAssignable(type, value.getClass());
return (T) value;
}
@SuppressWarnings("unchecked")
public static MessageHandler handlerExpecting(
final Matcher<Message> expectation) {
return new MessageHandler() {
public void handleMessage(Message<?> message) {
assertThat(message, expectation);
}
};
}
public static Matcher<Message<?>> messageWithPayload(final Object payload) {
return new BaseMatcher<Message<?>>() {
public boolean matches(Object candidate) {
return ((Message<?>) candidate).getPayload().equals(payload);
}
public void describeTo(Description description) {
description.appendText("A message with payload: " + payload);
}
};
}
}