checkstyle WhiteAround

WhiteAroundCheck script
This commit is contained in:
Gary Russell
2016-04-05 13:29:21 -04:00
parent 842aded9a4
commit 05cc7be644
508 changed files with 2027 additions and 1916 deletions

View File

@@ -37,6 +37,6 @@ public interface ScriptExecutor {
* @param variables The variables.
* @return The result of the execution.
*/
Object executeScript(ScriptSource scriptSource, Map<String,Object> variables);
Object executeScript(ScriptSource scriptSource, Map<String, Object> variables);
}

View File

@@ -41,7 +41,7 @@ import org.springframework.integration.scripting.ScriptExecutor;
@Override
protected Object postProcess(Object result, ScriptEngine scriptEngine, String script, Bindings bindings) {
Object newResult= result;
Object newResult = result;
if (newResult == null) {
String returnVariableName = PythonVariableParser.parseReturnVariable(script);
if (bindings != null) {
@@ -55,9 +55,9 @@ import org.springframework.integration.scripting.ScriptExecutor;
}
public static class PythonVariableParser {
public static String parseReturnVariable(String script){
public static String parseReturnVariable(String script) {
String[] lines = script.trim().split("\n");
String lastLine = lines[lines.length -1];
String lastLine = lines[lines.length - 1];
String[] tokens = lastLine.split("=");
return tokens[0].trim();
}

View File

@@ -89,7 +89,7 @@ public class ScriptExecutingMessageProcessor extends AbstractScriptExecutingMess
@Override
protected Object executeScript(ScriptSource scriptSource, Map<String, Object> variables) throws Exception {
Assert.notNull(scriptSource, "scriptSource must not be null");
return this.scriptExecutor.executeScript(scriptSource,variables);
return this.scriptExecutor.executeScript(scriptSource, variables);
}
}

View File

@@ -25,7 +25,7 @@ import org.springframework.integration.scripting.ScriptExecutor;
public abstract class ScriptExecutorFactory {
public static ScriptExecutor getScriptExecutor(String language) {
if (language.equalsIgnoreCase("python") || language.equalsIgnoreCase("jython")){
if (language.equalsIgnoreCase("python") || language.equalsIgnoreCase("jython")) {
return new PythonScriptExecutor();
}
else if (language.equalsIgnoreCase("ruby") || language.equalsIgnoreCase("jruby")) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -51,13 +51,13 @@ public class Jsr223HeaderEnricherTests {
private QueueChannel outputB;
@Test
public void referencedScript() throws Exception{
public void referencedScript() throws Exception {
inputA.send(new GenericMessage<String>("Hello"));
assertEquals("jruby", outputA.receive(20000).getHeaders().get("TEST_HEADER"));
}
@Test
public void inlineScript() throws Exception{
public void inlineScript() throws Exception {
inputB.send(new GenericMessage<String>("Hello"));
assertEquals("js", outputB.receive(20000).getHeaders().get("TEST_HEADER"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2016 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.
@@ -84,7 +84,7 @@ public class Jsr223RefreshTests {
}
public InputStream getInputStream() throws IOException {
if (++count>scripts.length-1) {
if (++count > scripts.length - 1) {
count = 0;
}
return new ByteArrayInputStream(scripts[count].getBytes());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -82,7 +82,7 @@ public class Jsr223ServiceActivatorTests {
// different
assertFalse(value1.substring(value1.indexOf(":") + 1, value1.lastIndexOf(":"))
.equals(value2.substring(value1.indexOf(":") + 1, value1.lastIndexOf(":"))));
assertFalse(value1.substring(value1.indexOf(":") +1, value1.lastIndexOf(":"))
assertFalse(value1.substring(value1.indexOf(":") + 1, value1.lastIndexOf(":"))
.equals(value1.substring(value1.lastIndexOf(":"))));
assertFalse(value2.substring(value1.indexOf(":") + 1, value1.lastIndexOf(":"))

View File

@@ -46,10 +46,10 @@ public class Jsr223ScriptExecutingMessageProcessorTests {
executor = ScriptExecutorFactory.getScriptExecutor("jruby");
}
@Test
public void testExecuteWithVariables(){
Map<String,Object> vars = new HashMap<String,Object>();
vars.put("one",1);
vars.put("two","two");
public void testExecuteWithVariables() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("one", 1);
vars.put("two", "two");
vars.put("three", 3);
ScriptSource scriptSource = new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/print_message.rb"));
@@ -61,11 +61,11 @@ public class Jsr223ScriptExecutingMessageProcessorTests {
Object obj = messageProcessor.processMessage(message);
assertEquals("hello modified",obj.toString().substring(0,"hello modified".length()));
assertEquals("hello modified", obj.toString().substring(0, "hello modified".length()));
}
@Test
public void testWithNoVars(){
public void testWithNoVars() {
ScriptSource scriptSource = new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/print_message.rb"));
ScriptExecutingMessageProcessor messageProcessor = new ScriptExecutingMessageProcessor(scriptSource, executor);
@@ -75,7 +75,7 @@ public class Jsr223ScriptExecutingMessageProcessorTests {
Object obj = messageProcessor.processMessage(message);
assertEquals("hello modified",obj.toString().substring(0,"hello modified".length()));
assertEquals("hello modified", obj.toString().substring(0, "hello modified".length()));
}
}

View File

@@ -47,23 +47,23 @@ public class PythonScriptExecutorTests {
@Test
public void testLiteral() {
Object obj = executor.executeScript(new StaticScriptSource("3+4") );
assertEquals(7,obj);
assertEquals(7, obj);
obj = executor.executeScript(new StaticScriptSource("'hello,world'") );
assertEquals("hello,world",obj);
assertEquals("hello,world", obj);
}
@Test
public void test1() {
Object obj = executor.executeScript(new StaticScriptSource("x=2") );
assertEquals(2,obj);
assertEquals(2, obj);
}
@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);
assertEquals(2, obj);
}
@Test
@@ -91,9 +91,9 @@ public class PythonScriptExecutorTests {
@Test
public void testEmbeddedVariable() {
Map<String,Object> variables = new HashMap<String,Object>();
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("scope", "world");
Object obj = executor.executeScript(new StaticScriptSource("\"hello, %s\"% scope"),variables);
assertEquals("hello, world",obj);
Object obj = executor.executeScript(new StaticScriptSource("\"hello, %s\"% scope"), variables);
assertEquals("hello, world", obj);
}
}

View File

@@ -34,10 +34,10 @@ public class PythonVariableParserTests {
@Test
public void testBasic() throws IOException {
String var = PythonScriptExecutor.PythonVariableParser.parseReturnVariable("x=2");
assertEquals("x",var);
assertEquals("x", var);
var = PythonScriptExecutor.PythonVariableParser.parseReturnVariable("\n\n\nx = 2\n\n\n");
assertEquals("x",var);
assertEquals("x", var);
var = PythonScriptExecutor.PythonVariableParser.parseReturnVariable("\n\n\nx\n\n\n");
}
@@ -48,6 +48,6 @@ public class PythonVariableParserTests {
ScriptSource source =
new ResourceScriptSource(new ClassPathResource("/org/springframework/integration/scripting/jsr223/test2.py"));
String var = PythonScriptExecutor.PythonVariableParser.parseReturnVariable(source.getScriptAsString());
assertEquals("bar",var);
assertEquals("bar", var);
}
}