Merge remote-tracking branch 'upstream/master' into 4.0.0-WIP
Conflicts: spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayInterfaceTests.java spring-integration-core/src/test/java/org/springframework/integration/router/config/RouterWithMappingTests.java spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java spring-integration-http/src/test/java/org/springframework/integration/http/inbound/HttpRequestHandlingMessagingGatewayWithPathMappingTests.java spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/AbstractTxTimeoutMessageStoreTests.java spring-integration-jmx/src/main/java/org/springframework/integration/jmx/OperationInvokingMessageHandler.java Resolved.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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. 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.
|
||||
@@ -27,7 +27,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base {@link MessageProcessor} for scripting implementations to extend.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Stefan Reuter
|
||||
* @since 2.0
|
||||
@@ -36,9 +36,9 @@ public abstract class AbstractScriptExecutingMessageProcessor<T> implements Mess
|
||||
|
||||
private final ScriptVariableGenerator scriptVariableGenerator;
|
||||
|
||||
private volatile ClassLoader beanClassLoader;
|
||||
protected volatile ClassLoader beanClassLoader;
|
||||
|
||||
private volatile BeanFactory beanFactory;
|
||||
protected volatile BeanFactory beanFactory;
|
||||
|
||||
protected AbstractScriptExecutingMessageProcessor() {
|
||||
this.scriptVariableGenerator = new DefaultScriptVariableGenerator();
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractScriptExecutingMessageProcessor<T> implements Mess
|
||||
Assert.notNull(scriptVariableGenerator, "scriptVariableGenerator must not be null");
|
||||
this.scriptVariableGenerator = scriptVariableGenerator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Executes the script and returns the result.
|
||||
@@ -69,23 +69,15 @@ public abstract class AbstractScriptExecutingMessageProcessor<T> implements Mess
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
protected ClassLoader getBeanClassLoader() {
|
||||
return this.beanClassLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
protected BeanFactory getBeanFactory() {
|
||||
return this.beanFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses must implement this method to create a script source,
|
||||
* optionally using the message to locate or create the script.
|
||||
*
|
||||
*
|
||||
* @param message the message being processed
|
||||
* @return a ScriptSource to use to create a script
|
||||
*/
|
||||
|
||||
@@ -72,7 +72,6 @@ public class Jsr223ServiceActivatorTests {
|
||||
String value1 = (String) replyChannel.receive(0).getPayload();
|
||||
String value2 = (String) replyChannel.receive(0).getPayload();
|
||||
String value3 = (String) replyChannel.receive(0).getPayload();
|
||||
System.out.println(value1 + "\n" + value2 + "\n" + value3);
|
||||
assertTrue(value1.startsWith("python-test-1-foo - bar"));
|
||||
assertTrue(value2.startsWith("python-test-2-foo - bar"));
|
||||
assertTrue(value3.startsWith("python-test-3-foo - bar"));
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -13,12 +13,12 @@
|
||||
package org.springframework.integration.scripting.jsr223;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.integration.scripting.ScriptExecutor;
|
||||
import org.springframework.integration.scripting.ScriptingException;
|
||||
@@ -30,28 +30,29 @@ import org.springframework.scripting.support.StaticScriptSource;
|
||||
*
|
||||
*/
|
||||
public class Jsr223ScriptExecutorTests {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
public void test() {
|
||||
ScriptExecutor executor = ScriptExecutorFactory.getScriptExecutor("jruby");
|
||||
executor.executeScript(new StaticScriptSource("puts 'hello, world'"));
|
||||
executor.executeScript(new StaticScriptSource("puts 'hello, again'"));
|
||||
|
||||
executor.executeScript(new StaticScriptSource("'hello, world'"));
|
||||
executor.executeScript(new StaticScriptSource("'hello, again'"));
|
||||
|
||||
Map<String,Object> variables = new HashMap<String,Object>();
|
||||
|
||||
|
||||
Map<String,Object> headers = new HashMap<String,Object>();
|
||||
headers.put("one",1);
|
||||
headers.put("two","two");
|
||||
headers.put("three", new Integer(3));
|
||||
|
||||
headers.put("one", 1);
|
||||
headers.put("two", "two");
|
||||
headers.put("three", 3);
|
||||
|
||||
variables.put("payload", "payload");
|
||||
variables.put("headers", headers);
|
||||
|
||||
|
||||
String result = (String)executor.executeScript(
|
||||
new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/print_message.rb")),
|
||||
variables
|
||||
);
|
||||
|
||||
assertEquals("payload modified",result.substring(0,"payload modified".length()));
|
||||
|
||||
assertEquals("payload modified", result.substring(0, "payload modified".length()));
|
||||
}
|
||||
@Test
|
||||
public void testJs(){
|
||||
@@ -59,25 +60,20 @@ public class Jsr223ScriptExecutorTests {
|
||||
Object obj = executor.executeScript(new StaticScriptSource("function js(){ return 'js';} js();"));
|
||||
assertEquals("js",obj.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testPython() {
|
||||
ScriptExecutor executor = ScriptExecutorFactory.getScriptExecutor("python");
|
||||
Object obj = executor.executeScript(new StaticScriptSource("x=2") );
|
||||
assertEquals(2,obj);
|
||||
|
||||
|
||||
obj = executor.executeScript(new StaticScriptSource("def foo(y):\n\tx=y\n\treturn y\nz=foo(2)") );
|
||||
assertEquals(2,obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test(expected = ScriptingException.class)
|
||||
public void testInvalidLanguageThrowsScriptingException() {
|
||||
try {
|
||||
ScriptExecutor executor = ScriptExecutorFactory.getScriptExecutor("foo");
|
||||
executor.executeScript(new StaticScriptSource("x=2"));
|
||||
fail("should throw Exception");
|
||||
} catch (ScriptingException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
ScriptExecutor executor = ScriptExecutorFactory.getScriptExecutor("foo");
|
||||
executor.executeScript(new StaticScriptSource("x=2"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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. 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.
|
||||
@@ -36,39 +36,38 @@ public class PythonScriptExecutorTests {
|
||||
public void init() {
|
||||
executor = new PythonScriptExecutor();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void testLiteral() {
|
||||
Object obj = executor.executeScript(new StaticScriptSource("3+4") );
|
||||
assertEquals(7,obj);
|
||||
|
||||
|
||||
obj = executor.executeScript(new StaticScriptSource("'hello,world'") );
|
||||
assertEquals("hello,world",obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
|
||||
@Test
|
||||
|
||||
public void test1() {
|
||||
Object obj = executor.executeScript(new StaticScriptSource("x=2") );
|
||||
assertEquals(2,obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void test2() {
|
||||
Object obj = executor.executeScript(new StaticScriptSource("def foo(y):\n\tx=y\n\treturn y\nz=foo(2)") );
|
||||
assertEquals(2,obj);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@Test
|
||||
public void test3() {
|
||||
ScriptSource source =
|
||||
ScriptSource source =
|
||||
new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/test3.py"));
|
||||
Object obj = executor.executeScript(source);
|
||||
System.out.println(obj);
|
||||
PyTuple tuple = (PyTuple) obj;
|
||||
assertEquals(1, tuple.get(0));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testEmbeddedVariable() {
|
||||
Map<String,Object> variables = new HashMap<String,Object>();
|
||||
|
||||
Reference in New Issue
Block a user