Compiler warnings
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-function-adapter-openwhisk</artifactId>
|
<artifactId>spring-cloud-function-adapter-openwhisk</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.function.context.FunctionCatalog;
|
import org.springframework.cloud.function.context.FunctionCatalog;
|
||||||
import org.springframework.cloud.function.context.catalog.FunctionInspector;
|
import org.springframework.cloud.function.context.catalog.FunctionInspector;
|
||||||
@@ -55,7 +56,6 @@ public class OpenWhiskFunctionInitializer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private FunctionProperties properties;
|
private FunctionProperties properties;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
logger.info("Initializing - OpenWhisk Function Initializer");
|
logger.info("Initializing - OpenWhisk Function Initializer");
|
||||||
if (!this.initialized.compareAndSet(false, true)) {
|
if (!this.initialized.compareAndSet(false, true)) {
|
||||||
@@ -65,9 +65,11 @@ public class OpenWhiskFunctionInitializer {
|
|||||||
String type = this.properties.getType();
|
String type = this.properties.getType();
|
||||||
if ("function".equals(type)) {
|
if ("function".equals(type)) {
|
||||||
this.function = this.catalog.lookup(Function.class, name);
|
this.function = this.catalog.lookup(Function.class, name);
|
||||||
} else if ("consumer".equals(type)) {
|
}
|
||||||
|
else if ("consumer".equals(type)) {
|
||||||
this.consumer = this.catalog.lookup(Consumer.class, name);
|
this.consumer = this.catalog.lookup(Consumer.class, name);
|
||||||
} else if ("supplier".equals(type)) {
|
}
|
||||||
|
else if ("supplier".equals(type)) {
|
||||||
this.supplier = this.catalog.lookup(Supplier.class, name);
|
this.supplier = this.catalog.lookup(Supplier.class, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,15 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.function.adapter.openwhisk;
|
package org.springframework.cloud.function.adapter.openwhisk;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
@@ -31,10 +37,6 @@ import org.springframework.context.annotation.Scope;
|
|||||||
import org.springframework.test.context.TestPropertySource;
|
import org.springframework.test.context.TestPropertySource;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
@@ -65,14 +67,14 @@ public class OpenWhiskActionHandlerTest {
|
|||||||
actionRequest.setValue(eventData);
|
actionRequest.setValue(eventData);
|
||||||
Object result = actionHandler.run(actionRequest);
|
Object result = actionHandler.run(actionRequest);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertEquals("{\"result\":{\"name\":\"Spring\",\"message\":\"Hello, Spring\"}}", result);
|
assertEquals("{\"result\":{\"name\":\"Spring\",\"message\":\"Hello, Spring\"}}",
|
||||||
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHandlerWithoutPayload() {
|
public void testHandlerWithoutPayload() {
|
||||||
Map<String, String> testData = new HashMap<>();
|
Map<String, String> testData = new HashMap<>();
|
||||||
testData.put("name", "Spring");
|
testData.put("name", "Spring");
|
||||||
Map<String, Object> eventData = new HashMap<>();
|
|
||||||
actionHandler.init(new OpenWhiskInitRequest());
|
actionHandler.init(new OpenWhiskInitRequest());
|
||||||
OpenWhiskActionRequest actionRequest = new OpenWhiskActionRequest();
|
OpenWhiskActionRequest actionRequest = new OpenWhiskActionRequest();
|
||||||
actionRequest.setActionName("test_action");
|
actionRequest.setActionName("test_action");
|
||||||
@@ -82,8 +84,8 @@ public class OpenWhiskActionHandlerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ContextFunctionCatalogAutoConfiguration.class,
|
@Import({ ContextFunctionCatalogAutoConfiguration.class,
|
||||||
JacksonAutoConfiguration.class})
|
JacksonAutoConfiguration.class })
|
||||||
protected static class OWFunctionConfig {
|
protected static class OWFunctionConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@@ -97,7 +99,6 @@ public class OpenWhiskActionHandlerTest {
|
|||||||
return new OpenWhiskActionHandler();
|
return new OpenWhiskActionHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FunctionProperties properties() {
|
public FunctionProperties properties() {
|
||||||
return new FunctionProperties();
|
return new FunctionProperties();
|
||||||
@@ -125,7 +126,8 @@ public class OpenWhiskActionHandlerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void setMessage(String message) {
|
||||||
this.message = String.format(GREETINGS_FORMAT, this.name != null ? name : "nobody");
|
this.message = String.format(GREETINGS_FORMAT,
|
||||||
|
this.name != null ? name : "nobody");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.function.compiler.java;
|
package org.springframework.cloud.function.compiler.java;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates a name with the bytes for its class definition.
|
* Encapsulates a name with the bytes for its class definition.
|
||||||
*
|
*
|
||||||
@@ -36,7 +34,9 @@ public class CompiledClassDefinition {
|
|||||||
if (classname.startsWith("/")) {
|
if (classname.startsWith("/")) {
|
||||||
classname = classname.substring(1);
|
classname = classname.substring(1);
|
||||||
}
|
}
|
||||||
classname = classname.replace('/', '.').substring(0, classname.length()-6); //strip off .class
|
classname = classname.replace('/', '.').substring(0, classname.length() - 6); // strip
|
||||||
|
// off
|
||||||
|
// .class
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -47,8 +47,10 @@ public class CompiledClassDefinition {
|
|||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CompiledClassDefinition(name=" + getName() + ",#bytes=" + getBytes().length + ")";
|
return "CompiledClassDefinition(name=" + getName() + ",#bytes="
|
||||||
|
+ getBytes().length + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClassName() {
|
public String getClassName() {
|
||||||
|
|||||||
@@ -47,7 +47,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
|
<artifactId>spring-cloud-stream-binder-servlet</artifactId>
|
||||||
<version>${servlet-binder.version}</version>
|
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
Reference in New Issue
Block a user