INT-2916 - Upgrade to JUnit 4.11 in support of JDK7

For reference see: https://jira.springsource.org/browse/INT-2916

Changes:

* INT-2919 - Upgrade Spring Data Gemfire to 1.2.2.RELEASE
* Exclude Hamcrest transitive dependency from JUnit (as already explicitly declared)
* Set sourceCompatibility in build.gradle to 1.6
* Set targetCompatibility in build.gradle to 1.6
* Upgrade Hamcrest to 1.3 and fix deprications
  - Corematcher is(*class) change to is(instanceOf(*class))
  - Change org.junit.internal.matchers.TypeSafeMatcher to org.hamcrest.TypeSafeMatcher
  - Change import org.junit.matchers.JUnitMatchers.containsString to org.hamcrest.CoreMatchers.containsString
  - Change import org.junit.matchers.JUnitMatchers.both to org.hamcrest.CoreMatchers.both
  - Change import org.junit.matchers.JUnitMatchers.containsString to org.hamcrest.CoreMatchers.containsString
* Fix JUnit deprecations
  - changed junit.framework.Assert to org.junit.Assert
* Add few missing licenses headers to tests
* Marked several test classes with: @DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
  - SplitterIntegrationTests
  - GatewayInvokingMessageHandlerTests
  - FileToChannelIntegrationTests
  - FileInboundChannelAdapterWithRecursiveDirectoryTests
  - JdbcMessageStoreChannelTests
  - ChatMessageInboundChannelAdapterParserTests
* 3 Tests ignored (Still needs to be addressed):
  - testOperationOnPrototypeBean
  - testFailOperationWithCustomScope
  - testOperationOfControlBus
* Update SQL script (test-failure):
  - spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/config/outboundSchema.sql
  - add drop table statements
  - add ignore-failures="DROPS" to "jdbcOutboundChannelAdapterCommonConfig.xml"

INT-2916 - Code Review Changes

INT-2916 - Fix ignored Tests

Fix 3 previously ignored tests in *GroovyControlBusTests*:

* testOperationOnPrototypeBean
* testFailOperationWithCustomScope
* testOperationOfControlBus

INT-2916 - CI Build Testing

INT-2963 - Remove JDK7 Compilation Warnings

* Upgrade Mockito to 1.9.5
* Fix failing SubscribableJmsChannelTests

INT-2916 - Standardize Hamcrest assertions
Ensure Hamcrest assertions are standardized to: is(instanceOf(...))
This commit is contained in:
Gunnar Hillert
2013-02-06 15:51:58 -05:00
committed by Gary Russell
parent 3c98b371fa
commit 0271acaf4c
183 changed files with 1730 additions and 1482 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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.
@@ -25,7 +25,7 @@ import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
import junit.framework.Assert;
import org.junit.Assert;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.Before;
@@ -37,8 +37,9 @@ import org.w3c.dom.Node;
import org.xml.sax.InputSource;
/**
*
*
* @author Jonas Partner
* @author Gunnar Hillert
*
*/
public class DefaultXmlPayloadConverterTests {
@@ -86,27 +87,27 @@ public class DefaultXmlPayloadConverterTests {
Node n = converter.convertToNode(testDocument);
XMLAssert.assertXMLEqual(testDocument, (Document) n);
}
@Test
public void testGetSourcePassingDocumet() throws Exception{
Source source = converter.convertToSource(testDocument);
assertEquals(DOMSource.class, source.getClass());
}
@Test
public void testGetSourcePassingString() throws Exception{
Source source = converter.convertToSource(testDocumentAsString);
assertEquals(StringSource.class, source.getClass());
}
@Test
public void testGetSourcePassingSource() throws Exception{
SAXSource passedInSource = new SAXSource();
Source source = converter.convertToSource(passedInSource);
assertEquals(source, passedInSource);
}
@Test(expected=MessagingException.class)
public void testInvalidPayload(){
converter.convertToSource(12);
@@ -118,6 +119,6 @@ public class DefaultXmlPayloadConverterTests {
Node n = converter.convertToNode(new DOMSource(element));
assertTrue("Wrong node returned", element == n);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2013 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,8 +16,8 @@
package org.springframework.integration.xml.config;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import org.w3c.dom.Document;
@@ -49,25 +49,26 @@ import org.springframework.test.context.ContextConfiguration;
* @author Jonas Partner
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Gunnar Hillert
*/
@ContextConfiguration
public class XPathRouterParserTests {
String channelConfig = "<si:channel id='test-input'/> <si:channel id='outputOne'><si:queue capacity='10'/></si:channel>" +
"<si:channel id='defaultOutput'><si:queue capacity='10'/></si:channel>";
@Autowired @Qualifier("test-input")
MessageChannel inputChannel;
@Autowired @Qualifier("outputOne")
QueueChannel outputChannel;
@Autowired @Qualifier("defaultOutput")
QueueChannel defaultOutput;
ConfigurableApplicationContext appContext;
public EventDrivenConsumer buildContext(String routerDef){
appContext = TestXmlApplicationContextHelper.getTestAppContext( channelConfig + routerDef);
appContext.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
@@ -75,15 +76,15 @@ public class XPathRouterParserTests {
consumer.start();
return consumer;
}
@After
public void tearDown(){
if(appContext != null){
appContext.close();
}
}
@Test
public void testSimpleStringExpression() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<name>outputOne</name>");
@@ -125,41 +126,41 @@ public class XPathRouterParserTests {
"<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/ns1:name/ns2:type' namespace-map='nsMap'/>");
buffer.append("</si-xml:xpath-router>");
buffer.append("<util:map id='nsMap'><entry key='ns1' value='www.example.org' /><entry key='ns2' value='www.example.org2' /></util:map>");
buildContext(buffer.toString());
inputChannel.send(docMessage);
assertEquals("Wrong number of messages", 1, outputChannel.getQueueSize());
}
@Test
public void testSetResolutionRequiredFalse() throws Exception {
StringBuffer contextBuffer = new StringBuffer("<si-xml:xpath-router id='router' resolution-required='false' input-channel='test-input'><si-xml:xpath-expression expression='/name'/></si-xml:xpath-router>");
EventDrivenConsumer consumer = buildContext(contextBuffer.toString());
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
Object handler = accessor.getPropertyValue("handler");
accessor = new DirectFieldAccessor(handler);
Object resolutionRequired = accessor.getPropertyValue("resolutionRequired");
assertEquals("Resolution required not set to false ", false, resolutionRequired);
}
@Test
public void testSetResolutionRequiredTrue() throws Exception {
StringBuffer contextBuffer = new StringBuffer("<si-xml:xpath-router id='router' resolution-required='true' input-channel='test-input'><si-xml:xpath-expression expression='/name'/></si-xml:xpath-router>");
EventDrivenConsumer consumer = buildContext(contextBuffer.toString());
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
Object handler = accessor.getPropertyValue("handler");
accessor = new DirectFieldAccessor(handler);
Object resolutionRequired = accessor.getPropertyValue("resolutionRequired");
assertEquals("Resolution required not set to true ", true, resolutionRequired);
}
@Test
public void testSetDefaultOutputChannel() throws Exception {
StringBuffer contextBuffer = new StringBuffer("<si-xml:xpath-router id='router' default-output-channel='defaultOutput' input-channel='test-input'><si-xml:xpath-expression expression='/name'/></si-xml:xpath-router>");
EventDrivenConsumer consumer = buildContext(contextBuffer.toString());
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
Object handler = accessor.getPropertyValue("handler");
accessor = new DirectFieldAccessor(handler);
@@ -171,7 +172,7 @@ public class XPathRouterParserTests {
@Test
public void testWithDynamicChanges() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
MessageChannel inputChannel = ac.getBean("xpathRouterEmptyChannel", MessageChannel.class);
PollableChannel channelA = ac.getBean("channelA", PollableChannel.class);
PollableChannel channelB = ac.getBean("channelB", PollableChannel.class);
@@ -180,7 +181,7 @@ public class XPathRouterParserTests {
inputChannel.send(docMessage);
assertNotNull(channelA.receive(10));
assertNull(channelB.receive(10));
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterEmpty", EventDrivenConsumer.class);
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
xpathRouter.setChannelMapping("channelA", "channelB");
@@ -191,7 +192,7 @@ public class XPathRouterParserTests {
@Test
public void testWithDynamicChangesWithExistingMappings() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
MessageChannel inputChannel = ac.getBean("xpathRouterWithMappingChannel", MessageChannel.class);
PollableChannel channelA = ac.getBean("channelA", PollableChannel.class);
PollableChannel channelB = ac.getBean("channelB", PollableChannel.class);
@@ -200,7 +201,7 @@ public class XPathRouterParserTests {
inputChannel.send(docMessage);
assertNull(channelA.receive(10));
assertNotNull(channelB.receive(10));
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterWithMapping", EventDrivenConsumer.class);
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
xpathRouter.removeChannelMapping("channelA");
@@ -208,11 +209,11 @@ public class XPathRouterParserTests {
assertNotNull(channelA.receive(10));
assertNull(channelB.receive(10));
}
@Test
public void testWithDynamicChangesWithExistingMappingsAndMultiChannel() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
MessageChannel inputChannel = ac.getBean("multiChannelRouterChannel", MessageChannel.class);
PollableChannel channelA = ac.getBean("channelA", PollableChannel.class);
PollableChannel channelB = ac.getBean("channelB", PollableChannel.class);
@@ -222,7 +223,7 @@ public class XPathRouterParserTests {
assertNotNull(channelA.receive(10));
assertNotNull(channelA.receive(10));
assertNull(channelB.receive(10));
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterWithMappingMultiChannel", EventDrivenConsumer.class);
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
xpathRouter.removeChannelMapping("channelA");
@@ -233,7 +234,7 @@ public class XPathRouterParserTests {
}
@Test
public void testWithStringEvaluationType() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
MessageChannel inputChannel = ac.getBean("xpathStringChannel", MessageChannel.class);
PollableChannel channelA = ac.getBean("channelA", PollableChannel.class);
Document doc = XmlTestUtil.getDocumentForString("<channelA/>");
@@ -266,7 +267,7 @@ public class XPathRouterParserTests {
return super.convertToDocument(object);
}
}
public static class MyChannelResolver extends BeanFactoryChannelResolver{}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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,8 +16,8 @@
package org.springframework.integration.xml.config;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
@@ -33,6 +33,7 @@ import org.w3c.dom.Document;
/**
* @author Jonas Partner
* @author Oleg Zhurakousky
* @author Gunnar Hillert
*/
@ContextConfiguration
public class XmlPayloadValidatingFilterParserTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 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.
@@ -21,7 +21,7 @@ import static org.junit.Assert.assertTrue;
import javax.xml.transform.dom.DOMResult;
import junit.framework.Assert;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.integration.support.MessageBuilder;
@@ -41,6 +41,7 @@ import org.springframework.xml.transform.StringResult;
/**
* @author Jonas Partner
* @author Mark Fisher
* @author Gunnar Hillert
*/
public class XsltPayloadTransformerParserTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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,7 +16,7 @@
package org.springframework.integration.xml.transformer;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertTrue;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
@@ -36,6 +36,7 @@ import org.springframework.xml.transform.StringResult;
/**
* @author Jonas Partner
* @author Dave Turanski
* @author Gunnar Hillert
*/
public class ResultToStringTransformerTests {
@@ -57,7 +58,7 @@ public class ResultToStringTransformerTests {
String transformedString = (String) transformed;
assertXMLEqual("Wrong content", doc, transformedString);
}
@Test
public void testWithOutputProperties() throws Exception {
String formattedDoc = "<order><orderItem>test</orderItem></order>";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2013 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,14 +34,15 @@ import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
import org.w3c.dom.Document;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
/**
* @author Jonas Partner
* @author Oleg Zhurakousky
* @author Gunnar Hillert
*/
public class XsltPayloadTransformerTests {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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.
@@ -15,9 +15,9 @@
*/
package org.springframework.integration.xml.transformer;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import java.util.Properties;
@@ -40,6 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Oleg Zhurakousky
* @author Jonas Partner
* @author Gunnar Hillert
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)