Skip to content

Commit

Permalink
INT-799: Remove Core Deps from s-i-test
Browse files Browse the repository at this point in the history
JIRA: https://jira.spring.io/browse/INT-799

Some test classes (e.g. `TestUtils`) were duplicated in core to avoid cyclic
dependency.

Now that core messaging has been moved to spring-messaging, it is possible
to remove the dependencies on `spring-integration-core` from `spring-integration-test`.

A few minor test cases have been moved to `spring-integration-core`.

The simple polishing to the `build.gradle` and `ServiceActivatorOnMockitoMockTests`
  • Loading branch information
garyrussell authored and artembilan committed Dec 8, 2015
1 parent 5850022 commit d16cd97
Show file tree
Hide file tree
Showing 27 changed files with 343 additions and 522 deletions.
18 changes: 5 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,7 @@ subprojects { subproject ->

// dependencies that are common across all java projects
dependencies {
testCompile ("junit:junit:$junitVersion") {
exclude group: 'org.hamcrest'
}
testCompile "log4j:log4j:$log4jVersion"
testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
testCompile ("org.mockito:mockito-core:$mockitoVersion") {
exclude group: 'org.hamcrest'
}
testCompile "org.springframework:spring-test:$springVersion"
if (!(subproject.name ==~ /.*-(core|test)/)) {
if (!(subproject.name ==~ /.*-test/)) {
testCompile project(":spring-integration-test")
}

Expand Down Expand Up @@ -256,18 +247,19 @@ subprojects { subproject ->
}

project('spring-integration-test') {
description = 'Spring Integration Test Support'
description = 'Spring Integration Test Support - **No SI Dependencies Allowed**'
dependencies {
compile project(":spring-integration-core")
compile ("junit:junit:$junitVersion") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile "org.hamcrest:hamcrest-all:$hamcrestVersion"
compile ("org.mockito:mockito-core:$mockitoVersion") {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
compile "org.springframework:spring-context:$springVersion"
compile "org.springframework:spring-messaging:$springVersion"
compile "org.springframework:spring-test:$springVersion"
compile "log4j:log4j:$log4jVersion" // TEMPORARY - DO NOT RELEASE
compile ("log4j:log4j:$log4jVersion", optional)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.MutableMessageBuilder;
import org.springframework.integration.support.SmartLifecycleRoleController;
import org.springframework.integration.test.util.LogAdjustingTestSupport;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<bean id="singleAnnotatedMethodOnClass" class="org.mockito.Mockito"
factory-method="mock">
<constructor-arg
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleAnnotatedMethodOnClass" />
value="org.springframework.integration.handler.ServiceActivatorOnMockitoMockTests.SingleAnnotatedMethodOnClass" />
</bean>

<int:chain input-channel="in" output-channel="out">
Expand All @@ -31,7 +31,7 @@
<bean id="singleMethodOnClass" class="org.mockito.Mockito"
factory-method="mock">
<constructor-arg
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleMethodOnClass" />
value="org.springframework.integration.handler.ServiceActivatorOnMockitoMockTests.SingleMethodOnClass" />
</bean>

<int:chain input-channel="in" output-channel="out">
Expand All @@ -42,7 +42,7 @@
<bean id="singleMethodAcceptingHeaderOnClass" class="org.mockito.Mockito"
factory-method="mock">
<constructor-arg
value="org.springframework.integration.test.mockito.ServiceActivatorOnMockitoMockTests.SingleMethodAcceptingHeaderOnClass" />
value="org.springframework.integration.handler.ServiceActivatorOnMockitoMockTests.SingleMethodAcceptingHeaderOnClass" />
</bean>

<int:channel id="out">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.springframework.integration.test.mockito;
package org.springframework.integration.handler;

import static org.mockito.Mockito.verify;

Expand All @@ -27,6 +27,7 @@
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

Expand Down Expand Up @@ -79,10 +80,9 @@ public void shouldInvokeMockedSingleMethodOnClass() {
verify(singleMethodOnClass).move("SingleMethodOnClass");
}

@SuppressWarnings("deprecation")
public static class SingleMethodAcceptingHeaderOnClass {

public String move(@org.springframework.integration.annotation.Header("s") String s) {
public String move(@Header("s") String s) {
return s;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
* limitations under the License.
*/

package org.springframework.integration.test.matcher;
package org.springframework.integration.message;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.any;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;

import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.springframework.integration.test.matcher.HeaderMatcher.hasAllHeaders;
Expand All @@ -43,8 +42,9 @@
import org.hamcrest.Matcher;
import org.junit.Before;
import org.junit.Test;
import org.springframework.messaging.Message;

import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;

/**
* @author Alex Peters
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<int:transformer input-channel="inputChannel" output-channel="outputChannel" expression="payload.toUpperCase()"/>

<int:channel id="outputChannel"/>

<int:transformer input-channel="inputChannel2" output-channel="outputChannel2" expression="payload.toUpperCase()"/>

<int:channel id="outputChannel2">
<int:queue/>
</int:channel>

</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2002-2015 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.support;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.springframework.integration.test.matcher.HeaderMatcher.hasHeader;
import static org.springframework.integration.test.matcher.PayloadMatcher.hasPayload;

import java.util.ArrayList;
import java.util.List;

import org.springframework.integration.test.support.AbstractRequestResponseScenarioTests;
import org.springframework.integration.test.support.MessageValidator;
import org.springframework.integration.test.support.PayloadValidator;
import org.springframework.integration.test.support.RequestResponseScenario;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration
public class MessageScenariosTests extends AbstractRequestResponseScenarioTests {

@Override
protected List<RequestResponseScenario> defineRequestResponseScenarios() {
List<RequestResponseScenario> scenarios= new ArrayList<RequestResponseScenario>();
RequestResponseScenario scenario1 = new RequestResponseScenario(
"inputChannel","outputChannel")
.setPayload("hello")
.setResponseValidator(new PayloadValidator<String>() {
@Override
protected void validateResponse(String response) {
assertEquals("HELLO",response);
}
});

scenarios.add(scenario1);

RequestResponseScenario scenario2 = new RequestResponseScenario(
"inputChannel","outputChannel")
.setMessage(MessageBuilder.withPayload("hello").setHeader("foo", "bar").build())
.setResponseValidator(new MessageValidator() {
@Override
protected void validateMessage(Message<?> message) {
assertThat(message,hasPayload("HELLO"));
assertThat(message,hasHeader("foo","bar"));
}
});

scenarios.add(scenario2);

RequestResponseScenario scenario3 = new RequestResponseScenario(
"inputChannel2","outputChannel2")
.setMessage(MessageBuilder.withPayload("hello").setHeader("foo", "bar").build())
.setResponseValidator(new MessageValidator() {
@Override
protected void validateMessage(Message<?> message) {
assertThat(message,hasPayload("HELLO"));
assertThat(message,hasHeader("foo","bar"));
}
});

scenarios.add(scenario3);

return scenarios;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2015 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
* 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,
Expand All @@ -14,29 +14,29 @@
* limitations under the License.
*/

package org.springframework.integration.test.support;
package org.springframework.integration.support;

import static org.junit.Assert.assertEquals;

import org.springframework.integration.test.support.PayloadValidator;
import org.springframework.integration.test.support.RequestResponseScenario;
import org.springframework.integration.test.support.SingleRequestResponseScenarioTests;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration("MessageScenariosTests-context.xml")
@ContextConfiguration("MessageScenariosTests-context.xml")
public class SingleScenarioTests extends SingleRequestResponseScenarioTests {

/* (non-Javadoc)
* @see org.springframework.integration.test.support.SingleRequestResponseScenarioTest#defineRequestResponseScenario()
*/

@Override
protected RequestResponseScenario defineRequestResponseScenario() {
RequestResponseScenario scenario = new RequestResponseScenario(
"inputChannel","outputChannel")
.setPayload("hello")
.setResponseValidator(new PayloadValidator<String>() {
@Override
protected void validateResponse(String response) {
assertEquals("HELLO",response);
}
});
"inputChannel","outputChannel")
.setPayload("hello")
.setResponseValidator(new PayloadValidator<String>() {
@Override
protected void validateResponse(String response) {
assertEquals("HELLO",response);
}
});
return scenario;
}
}

This file was deleted.

Loading

0 comments on commit d16cd97

Please sign in to comment.