remove MockHttpServletRequest.java, MockHttpServletResponse.java in favor of Spring 3.1 mock classes

INT-2247 polishing

Revert imports
This commit is contained in:
Oleg Zhurakousky
2012-05-08 13:01:34 -04:00
committed by Gary Russell
parent 66a9df5641
commit f7ba317733
8 changed files with 20 additions and 133 deletions

View File

@@ -1,55 +0,0 @@
/*
* Copyright 2002-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.integration.http;
import org.springframework.core.SpringVersion;
/**
* Modified version of the MockHttpServletRequest that sets the "Content-Type"
* header so that it will be available from a ServletServerHttpRequest instance.
*
* @author Mark Fisher
* @since 2.0
*/
public class MockHttpServletRequest extends org.springframework.mock.web.MockHttpServletRequest {
public MockHttpServletRequest() {
super();
}
public MockHttpServletRequest(String method, String url) {
super(method, url);
}
@Override
public void setContentType(String contentType) {
String springVersion = SpringVersion.getVersion();
if (springVersion != null && springVersion.startsWith("3.0")) {
this.addHeader("Content-Type", contentType);
}
else {
super.setContentType(contentType);
}
}
@Override
public String getContentType() {
return this.getHeader("Content-Type");
}
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright 2002-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.integration.http;
import org.springframework.core.SpringVersion;
/**
* Modified version of the MockHttpServletResponse that sets the "Content-Type"
* header so that it will be available from a ServletServerHttpResponse instance.
*
* @author Mark Fisher
* @since 2.0
*/
public class MockHttpServletResponse extends org.springframework.mock.web.MockHttpServletResponse {
public MockHttpServletResponse() {
super();
}
@Override
public void setContentType(String contentType) {
String springVersion = SpringVersion.getVersion();
if (springVersion != null && springVersion.startsWith("3.0")) {
this.addHeader("Content-Type", contentType);
}
else {
super.setContentType(contentType);
}
}
@Override
public String getContentType() {
return (String) this.getHeader("Content-Type");
}
}

View File

@@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -44,13 +43,12 @@ import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.http.MockHttpServletRequest;
import org.springframework.integration.http.inbound.HttpRequestHandlingController;
import org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway;
import org.springframework.integration.http.support.DefaultHttpHeaderMapper;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.annotation.ExpectedException;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.MultiValueMap;
@@ -177,9 +175,8 @@ public class HttpInboundChannelAdapterParserTests {
assertEquals("clinton", message.getHeaders().get("lname"));
}
@Test
@Test(expected=SpelEvaluationException.class)
// INT-1677
@ExpectedException(SpelEvaluationException.class)
public void withNameAndExpressionsNoPath() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");

View File

@@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -44,12 +43,12 @@ import org.springframework.integration.MessageHeaders;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.http.MockHttpServletRequest;
import org.springframework.integration.http.MockHttpServletResponse;
import org.springframework.integration.http.inbound.HttpRequestHandlingController;
import org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway;
import org.springframework.integration.http.support.DefaultHttpHeaderMapper;
import org.springframework.integration.test.util.TestUtils;
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;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -26,8 +26,7 @@ import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.http.MockHttpServletRequest;
import org.springframework.integration.http.inbound.HttpRequestHandlingController;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.validation.Errors;
import org.springframework.validation.ObjectError;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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.
@@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
@@ -38,8 +37,7 @@ import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.http.MockHttpServletRequest;
import org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.SerializationUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -19,6 +19,7 @@ package org.springframework.integration.http.inbound;
import java.util.Map;
import org.junit.Test;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.Message;
@@ -26,7 +27,7 @@ import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.http.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import static org.junit.Assert.assertEquals;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,11 @@
package org.springframework.integration.http.support;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import java.net.URI;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -29,7 +34,7 @@ import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
@@ -38,12 +43,6 @@ import org.springframework.integration.MessageHeaders;
import org.springframework.integration.mapping.HeaderMapper;
import org.springframework.util.CollectionUtils;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertNull;
/**
* @author Oleg Zhurakousky
* @author Mark Fisher
@@ -460,7 +459,7 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
public void validateCustomHeadersWithNonStringValuesAndDefaultConverterOnly() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
mapper.setOutboundHeaderNames(new String[] {"customHeader*"});
ConversionService cs = ConversionServiceFactory.createDefaultConversionService();
ConversionService cs = new DefaultConversionService();
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("integrationConversionService", cs);
mapper.setBeanFactory(beanFactory);
@@ -481,7 +480,7 @@ public class DefaultHttpHeaderMapperFromMessageInboundTests {
public void validateCustomHeadersWithNonStringValuesAndDefaultConverterWithCustomConverter() throws Exception{
DefaultHttpHeaderMapper mapper = new DefaultHttpHeaderMapper();
mapper.setOutboundHeaderNames(new String[] {"customHeader*"});
GenericConversionService cs = ConversionServiceFactory.createDefaultConversionService();
GenericConversionService cs = new DefaultConversionService();
cs.addConverter(new TestClassConverter());
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerSingleton("integrationConversionService", cs);