Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Munilla2019-06-25 10:32:51 -0400
committerChristophe Munilla2019-06-25 10:32:51 -0400
commit32f036fb38c298d8cf5554cb0b1a982b2f7a9dd3 (patch)
tree9ed4b508c62c2b1d11520ba48c847abab9f9d110
parentfddc791f36b08d2536d24181fd130de6493c3b68 (diff)
downloadorg.eclipse.sensinact.gateway-32f036fb38c298d8cf5554cb0b1a982b2f7a9dd3.tar.gz
org.eclipse.sensinact.gateway-32f036fb38c298d8cf5554cb0b1a982b2f7a9dd3.tar.xz
org.eclipse.sensinact.gateway-32f036fb38c298d8cf5554cb0b1a982b2f7a9dd3.zip
Allow to declare packet type in annotation
the HttpTaskConfiguration handle the packet type definition for the returned Http response - It is no more necessary to use an HttpTaskConfigurator Update tests and reactive them
-rw-r--r--platform/southbound/http/http-device/pom.xml147
-rw-r--r--platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/SimpleHttpResponse.java1
-rw-r--r--platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpChildTaskConfiguration.java10
-rw-r--r--platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpTaskConfiguration.java10
-rw-r--r--platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/smpl/SimpleTaskConfigurator.java22
-rw-r--r--platform/southbound/http/http-device/src/test/java/org/eclipse/sensinact/gateway/sthbnd/http/test/TestHttpDevice.java81
6 files changed, 210 insertions, 61 deletions
diff --git a/platform/southbound/http/http-device/pom.xml b/platform/southbound/http/http-device/pom.xml
index 6521df69..94f2bf1d 100644
--- a/platform/southbound/http/http-device/pom.xml
+++ b/platform/southbound/http/http-device/pom.xml
@@ -115,27 +115,90 @@
<phase>generate-test-resources</phase>
<configuration>
<artifactItems>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component</artifactId>
+ <version>1.4.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.component.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.cm</artifactId>
+ <version>1.6.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.cm.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype</artifactId>
+ <version>1.3.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.metatype.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.namespace.extender</artifactId>
+ <version>1.0.1</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.namespace.extender.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.promise</artifactId>
+ <version>1.0.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.util.promise.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.function</artifactId>
+ <version>1.0.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.util.function.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.log</artifactId>
+ <version>1.3.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.osgi.service.log.jar</destFileName>
+ </artifactItem>
<artifactItem>
<groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>1.9.10</version>
+ <artifactId>org.apache.felix.log</artifactId>
+ <version>1.2.0</version>
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>org.apache.felix.configadmin.jar</destFileName>
+ <destFileName>org.apache.felix.log.jar</destFileName>
</artifactItem>
<artifactItem>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>${osgi.compendium.version}</version>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.fileinstall</artifactId>
+ <version>3.6.4</version>
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>org.osgi.compendium.jar</destFileName>
+ <destFileName>org.apache.felix.fileinstall.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.9.12</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.configadmin.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework.security</artifactId>
- <version>2.4.0</version>
+ <version>2.6.1</version>
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
<destFileName>org.apache.felix.framework.security.jar</destFileName>
</artifactItem>
+ <artifactItem>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr</artifactId>
+ <version>2.1.16</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.apache.felix.scr.jar</destFileName>
+ </artifactItem>
<artifactItem>
<groupId>org.eclipse.sensinact.gateway</groupId>
<artifactId>sensinact-utils</artifactId>
@@ -158,26 +221,33 @@
<destFileName>sensinact-datastore-api.jar</destFileName>
</artifactItem>
<artifactItem>
+ <groupId>org.eclipse.sensinact.gateway.sthbnd.mqtt</groupId>
+ <artifactId>mqtt-utils</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>mqtt-utils.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.paho</groupId>
+ <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+ <version>1.2.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>org.eclipse.paho.client.mqttv3.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
<groupId>org.eclipse.sensinact.gateway</groupId>
<artifactId>sensinact-core</artifactId>
<version>${project.version}</version>
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
<destFileName>sensinact-core.jar</destFileName>
</artifactItem>
- <artifactItem>
- <groupId>org.eclipse.sensinact.gateway</groupId>
- <artifactId>sensinact-signature-validator</artifactId>
- <version>${project.version}</version>
- <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>sensinact-signature-validator.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.eclipse.sensinact.gateway</groupId>
- <artifactId>sensinact-framework-extension</artifactId>
- <version>${project.version}</version>
- <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>sensinact-framework-extension.jar</destFileName>
- </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-signature-validator</artifactId>
+ <version>${project.version}</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-signature-validator.jar</destFileName>
+ </artifactItem>
<artifactItem>
<groupId>org.eclipse.sensinact.gateway</groupId>
<artifactId>sensinact-security-none</artifactId>
@@ -186,13 +256,6 @@
<destFileName>sensinact-security-none.jar</destFileName>
</artifactItem>
<artifactItem>
- <groupId>org.eclipse.sensinact.gateway.tools</groupId>
- <artifactId>sensinact-test-configuration</artifactId>
- <version>${project.version}</version>
- <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>sensinact-test-configuration.jar</destFileName>
- </artifactItem>
- <artifactItem>
<groupId>org.eclipse.sensinact.gateway</groupId>
<artifactId>sensinact-generic</artifactId>
<version>${project.version}</version>
@@ -205,7 +268,21 @@
<version>${project.version}</version>
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
<destFileName>sensinact-northbound-access.jar</destFileName>
- </artifactItem>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.25</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>slf4j-api.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.16</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>slf4j-simple.jar</destFileName>
+ </artifactItem>
<artifactItem>
<groupId>org.eclipse.sensinact.gateway.protocol</groupId>
<artifactId>http</artifactId>
@@ -213,15 +290,13 @@
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
<destFileName>http.jar</destFileName>
</artifactItem>
- <!--
<artifactItem>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.servlet-api</artifactId>
+ <version>1.1.2</version>
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>javax.servlet-api.jar</destFileName>
+ <destFileName>org.apache.felix.http.servlet-api.jar</destFileName>
</artifactItem>
- -->
</artifactItems>
</configuration>
</execution>
diff --git a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/SimpleHttpResponse.java b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/SimpleHttpResponse.java
index ea9e93b9..8cdefb63 100644
--- a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/SimpleHttpResponse.java
+++ b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/SimpleHttpResponse.java
@@ -52,6 +52,7 @@ public class SimpleHttpResponse extends HttpResponse {
}
} catch (Exception e) {
+ e.printStackTrace();
return new HttpPacket(this.getHeaders(), this.content);
}
}
diff --git a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpChildTaskConfiguration.java b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpChildTaskConfiguration.java
index 5466ae86..7d05c7bb 100644
--- a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpChildTaskConfiguration.java
+++ b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpChildTaskConfiguration.java
@@ -13,6 +13,7 @@
*/
package org.eclipse.sensinact.gateway.sthbnd.http.annotation;
+import org.eclipse.sensinact.gateway.sthbnd.http.HttpPacket;
import org.eclipse.sensinact.gateway.sthbnd.http.smpl.HttpTaskConfigurator;
import java.lang.annotation.Documented;
@@ -22,8 +23,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented
@Retention(RUNTIME)
-/**
- */ public @interface HttpChildTaskConfiguration {
+public @interface HttpChildTaskConfiguration {
public static final String DEFAULT_ACCEPT_TYPE = "#EMPTY#";
public static final String DEFAULT_CONTENT_TYPE = "#EMPTY#";
public static final String DEFAULT_SCHEME = "#EMPTY#";
@@ -48,11 +48,13 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
boolean direct() default false;
- Class<? extends HttpTaskConfigurator> content() default HttpTaskConfigurator.class;
-
String identifier();
KeyValuePair[] query() default {};
KeyValuePair[] headers() default {};
+
+ Class<? extends HttpTaskConfigurator> content() default HttpTaskConfigurator.class;
+
+ Class<? extends HttpPacket> packet() default HttpPacket.class;
}
diff --git a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpTaskConfiguration.java b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpTaskConfiguration.java
index 80749a12..d286bf56 100644
--- a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpTaskConfiguration.java
+++ b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/annotation/HttpTaskConfiguration.java
@@ -13,6 +13,7 @@
*/
package org.eclipse.sensinact.gateway.sthbnd.http.annotation;
+import org.eclipse.sensinact.gateway.sthbnd.http.HttpPacket;
import org.eclipse.sensinact.gateway.sthbnd.http.smpl.HttpTaskConfigurator;
import java.lang.annotation.Documented;
@@ -22,8 +23,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented
@Retention(RUNTIME)
-/**
- */ public @interface HttpTaskConfiguration {
+public @interface HttpTaskConfiguration {
public static final String DEFAULT_ACCEPT_TYPE = "text/plain";
public static final String DEFAULT_CONTENT_TYPE = "text/plain";
public static final String DEFAULT_SCHEME = "http";
@@ -47,9 +47,11 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
boolean direct() default false;
- Class<? extends HttpTaskConfigurator> content() default HttpTaskConfigurator.class;
-
KeyValuePair[] query() default {};
KeyValuePair[] headers() default {};
+
+ Class<? extends HttpTaskConfigurator> content() default HttpTaskConfigurator.class;
+
+ Class<? extends HttpPacket> packet() default HttpPacket.class;
}
diff --git a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/smpl/SimpleTaskConfigurator.java b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/smpl/SimpleTaskConfigurator.java
index d53d3cc5..381c153f 100644
--- a/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/smpl/SimpleTaskConfigurator.java
+++ b/platform/southbound/http/http-device/src/main/java/org/eclipse/sensinact/gateway/sthbnd/http/smpl/SimpleTaskConfigurator.java
@@ -11,6 +11,7 @@
package org.eclipse.sensinact.gateway.sthbnd.http.smpl;
import org.eclipse.sensinact.gateway.generic.Task.CommandType;
+import org.eclipse.sensinact.gateway.sthbnd.http.HttpPacket;
import org.eclipse.sensinact.gateway.sthbnd.http.annotation.HttpChildTaskConfiguration;
import org.eclipse.sensinact.gateway.sthbnd.http.annotation.HttpTaskConfiguration;
import org.eclipse.sensinact.gateway.sthbnd.http.annotation.KeyValuePair;
@@ -70,6 +71,8 @@ class SimpleTaskConfigurator implements HttpTaskBuilder {
private Map<String, List<String>> query = null;
private Map<String, List<String>> headers = null;
+ private Class<? extends HttpPacket> packetType = null;
+
private HttpTaskConfigurator contentBuilder = null;
private HttpTaskConfigurator urlBuilder = null;
@@ -111,9 +114,10 @@ class SimpleTaskConfigurator implements HttpTaskBuilder {
this.urlBuilder = urlBuilder;
this.command = command;
this.direct = annotation != null ? annotation.direct() : parent.direct();
+ this.packetType = annotation != null && HttpPacket.class != annotation.packet() ? annotation.packet() : parent.packet();
this.query = new HashMap<String, List<String>>();
-
+
KeyValuePair[] queryParameters = join(annotation == null ? null : annotation.query(), parent.query());
int index = 0;
@@ -146,13 +150,12 @@ class SimpleTaskConfigurator implements HttpTaskBuilder {
}
Class<? extends HttpTaskConfigurator> taskContentConfigurationType = annotation != null && HttpTaskConfigurator.class != annotation.content() ? annotation.content() : parent.content();
- if (taskContentConfigurationType == null || taskContentConfigurationType == HttpTaskConfigurator.class) {
- return;
- }
- try {
- this.contentBuilder = taskContentConfigurationType.newInstance();
- } catch (Exception e) {
- this.endpoint.getMediator().error(e);
+ if (taskContentConfigurationType != null && taskContentConfigurationType != HttpTaskConfigurator.class) {
+ try {
+ this.contentBuilder = taskContentConfigurationType.newInstance();
+ } catch (Exception e) {
+ this.endpoint.getMediator().error(e);
+ }
}
}
@@ -254,6 +257,9 @@ class SimpleTaskConfigurator implements HttpTaskBuilder {
task.addHeader(this.resolve(task, entry.getKey()), this.resolve(task, values.get(index)));
}
}
+ if(this.packetType!=HttpPacket.class) {
+ task.setPacketType(this.packetType);
+ }
task.setAccept(this.resolve(task, acceptType));
task.setContentType(this.resolve(task, contentType));
task.setHttpMethod(this.resolve(task, httpMethod));
diff --git a/platform/southbound/http/http-device/src/test/java/org/eclipse/sensinact/gateway/sthbnd/http/test/TestHttpDevice.java b/platform/southbound/http/http-device/src/test/java/org/eclipse/sensinact/gateway/sthbnd/http/test/TestHttpDevice.java
index a05c3ac1..5866b734 100644
--- a/platform/southbound/http/http-device/src/test/java/org/eclipse/sensinact/gateway/sthbnd/http/test/TestHttpDevice.java
+++ b/platform/southbound/http/http-device/src/test/java/org/eclipse/sensinact/gateway/sthbnd/http/test/TestHttpDevice.java
@@ -152,6 +152,7 @@ public class TestHttpDevice extends MidOSGiTest {
@Test
public void testHttpTask() throws Throwable {
+ Thread.sleep(5000);
callback.setRemoteEntity(new JSONObject().put("serviceProviderId", "TestForSensiNactGateway").put("serviceId", "service1").put("resourceId", "temperature").put("data", 24));
this.initializeMoke(new File("src/test/resources/resources.xml").toURI().toURL(), new File("./extra-src/test/resources/MANIFEST.MF"), new File("./extra-src/test/resources/meta"), new File("./target/extra-test-classes"));
@@ -178,10 +179,13 @@ public class TestHttpDevice extends MidOSGiTest {
response = (SnaMessage) midVariable.toOSGi(getMethod, new Object[]{DataResource.VALUE});
jsonObject = new JSONObject(response.getJSON());
assertEquals(25, (int) jsonObject.getJSONObject("response").getInt("value"));
+
+ core.close();
}
@Test
public void testHttpTaskWithProcessingContext() throws Throwable {
+ Thread.sleep(5000);
callback.setRemoteEntity(new JSONObject().put("serviceProviderId", "TestForSensiNactGateway5").put("serviceId", "service1").put("resourceId", "temperature").put("data", 24));
this.initializeMoke(new File("src/test/resources/resources5.xml").toURI().toURL(), new File("./extra-src5/test/resources/MANIFEST.MF"), new File("./extra-src5/test/resources/meta"), new File("./target/extra-test-classes5"));
@@ -207,10 +211,13 @@ public class TestHttpDevice extends MidOSGiTest {
response = (SnaMessage) midVariable.toOSGi(getMethod, new Object[]{DataResource.VALUE});
jsonObject = new JSONObject(response.getJSON());
assertEquals(25, (int) jsonObject.getJSONObject("response").getInt("value"));
+
+ core.close();
}
@Test
public void testHttpTaskWithServicesEnumeration() throws Throwable {
+ Thread.sleep(5000);
callback.setRemoteEntity(new JSONObject().put("serviceProviderId", "TestForSensiNactGateway4").put("serviceId", "service1").put("resourceId", "temperature").put("data", 24));
this.initializeMoke(new File("src/test/resources/resources4.xml").toURI().toURL(), new File("./extra-src4/test/resources/MANIFEST.MF"), new File("./extra-src4/test/resources/meta"), new File("./target/extra-test-classes4"));
@@ -236,10 +243,13 @@ public class TestHttpDevice extends MidOSGiTest {
response = (SnaMessage) midVariable.toOSGi(getMethod, new Object[]{DataResource.VALUE});
jsonObject = new JSONObject(response.getJSON());
assertEquals(25, (int) jsonObject.getJSONObject("response").getInt("value"));
+
+ core.close();
}
@Test
public void testChainedHttpTask() throws Throwable {
+ Thread.sleep(5000);
callback.setRemoteEntity(new JSONObject().put("serviceProviderId", "TestForSensiNactGateway3").put("serviceId", "service1").put("resourceId", "temperature").put("data", 24));
this.initializeMoke(new File("src/test/resources/resources3.xml").toURI().toURL(), new File("./extra-src3/test/resources/MANIFEST.MF"), new File("./extra-src3/test/resources/meta"), new File("./target/extra-test-classes3"));
@@ -256,10 +266,13 @@ public class TestHttpDevice extends MidOSGiTest {
SnaMessage response = (SnaMessage) midVariable.toOSGi(getMethod, new Object[]{DataResource.VALUE});
JSONObject jsonObject = new JSONObject(response.getJSON());
assertEquals(24, (int) jsonObject.getJSONObject("response").getInt("value"));
+
+ core.close();
}
@Test
public void testHttpDeviceReccurrent() throws Throwable {
+ Thread.sleep(5000);
callback.setRemoteEntity(new JSONObject().put("serviceProviderId", "TestForSensiNactGateway2").put("serviceId", "service1").put("resourceId", "temperature").put("data", 24));
this.initializeMoke(new File("src/test/resources/resources2.xml").toURI().toURL(), new File("./extra-src2/test/resources/MANIFEST.MF"), new File("./extra-src2/test/resources/meta"), new File("./target/extra-test-classes2"));
@@ -294,6 +307,8 @@ public class TestHttpDevice extends MidOSGiTest {
response = (SnaMessage) midVariable.toOSGi(getMethod, new Object[]{DataResource.VALUE});
jsonObject = new JSONObject(response.getJSON());
assertEquals(32, (int) jsonObject.getJSONObject("response").getInt("value"));
+
+ core.close();
}
/**
@@ -302,21 +317,69 @@ public class TestHttpDevice extends MidOSGiTest {
*/
@Override
protected void doInit(Map configuration) {
- configuration.put("felix.auto.start.1", "file:target/felix/bundle/org.osgi.compendium.jar " + "file:target/felix/bundle/org.apache.felix.configadmin.jar " + "file:target/felix/bundle/org.apache.felix.framework.security.jar ");
-
- configuration.put("felix.auto.install.2", "file:target/felix/bundle/sensinact-utils.jar " + "file:target/felix/bundle/sensinact-common.jar " + "file:target/felix/bundle/sensinact-datastore-api.jar " + "file:target/felix/bundle/sensinact-framework-extension.jar " + "file:target/felix/bundle/sensinact-security-none.jar " + "file:target/felix/bundle/sensinact-generic.jar " + "file:target/felix/bundle/http.jar " + "file:target/felix/bundle/sensinact-northbound-access.jar ");
-
- configuration.put("felix.auto.start.2", "file:target/felix/bundle/sensinact-test-configuration.jar " + "file:target/felix/bundle/sensinact-core.jar " + "file:target/felix/bundle/sensinact-signature-validator.jar ");
- configuration.put("felix.auto.start.3", "file:target/felix/bundle/dynamicBundle.jar");
+
+ configuration.put("felix.auto.start.1",
+ "file:target/felix/bundle/org.osgi.service.component.jar "+
+ "file:target/felix/bundle/org.osgi.service.cm.jar "+
+ "file:target/felix/bundle/org.osgi.service.metatype.jar "+
+ "file:target/felix/bundle/org.osgi.namespace.extender.jar "+
+ "file:target/felix/bundle/org.osgi.util.promise.jar "+
+ "file:target/felix/bundle/org.osgi.util.function.jar "+
+ "file:target/felix/bundle/org.osgi.service.log.jar " +
+ "file:target/felix/bundle/org.apache.felix.log.jar " +
+ "file:target/felix/bundle/org.apache.felix.scr.jar " +
+ "file:target/felix/bundle/org.apache.felix.fileinstall.jar " +
+ "file:target/felix/bundle/org.apache.felix.configadmin.jar " +
+ "file:target/felix/bundle/org.apache.felix.framework.security.jar ");
+ configuration.put("felix.auto.install.2",
+ "file:target/felix/bundle/org.eclipse.paho.client.mqttv3.jar " +
+ "file:target/felix/bundle/mqtt-utils.jar " +
+ "file:target/felix/bundle/sensinact-utils.jar " +
+ "file:target/felix/bundle/sensinact-common.jar " +
+ "file:target/felix/bundle/sensinact-datastore-api.jar " +
+ "file:target/felix/bundle/sensinact-security-none.jar " +
+ "file:target/felix/bundle/sensinact-generic.jar " +
+ "file:target/felix/bundle/slf4j-api.jar " +
+ "file:target/felix/bundle/slf4j-simple.jar");
+ configuration.put("felix.auto.start.2",
+ "file:target/felix/bundle/sensinact-signature-validator.jar " +
+ "file:target/felix/bundle/sensinact-core.jar ");
+ configuration.put("felix.auto.start.3",
+ "file:target/felix/bundle/http.jar " +
+ "file:target/felix/bundle/sensinact-northbound-access.jar ");
+ configuration.put("felix.auto.start.4",
+ "file:target/felix/bundle/dynamicBundle.jar ");
configuration.put("org.eclipse.sensinact.gateway.security.jks.filename", "target/felix/bundle/keystore.jks");
configuration.put("org.eclipse.sensinact.gateway.security.jks.password", "sensiNact_team");
+
+ configuration.put("org.eclipse.sensinact.gateway.location.latitude", "45.2d");
+ configuration.put("org.eclipse.sensinact.gateway.location.longitude", "5.7d");
+
+ configuration.put("org.osgi.service.http.port", "8898");
+ configuration.put("org.apache.felix.http.jettyEnabled", true);
+ configuration.put("org.apache.felix.http.whiteboardEnabled", true);
+
+ try {
+ String fileName = "sensinact.config";
+ File testFile = new File(new File("src/test/resources"), fileName);
+ URL testFileURL = testFile.toURI().toURL();
+ FileOutputStream output = new FileOutputStream(new File(loadDir,fileName));
+ byte[] testCng = IOUtils.read(testFileURL.openStream(), true);
+ IOUtils.write(testCng, output);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
}
private void initializeMoke(URL resource, File manifestFile, File... sourceDirectories) throws Exception {
File tmpDirectory = new File("./target/felix/tmp");
- new File(tmpDirectory, "resources.xml").delete();
- new File(tmpDirectory, "dynamicBundle.jar").delete();
-
+ if(!tmpDirectory.exists()) {
+ tmpDirectory.mkdir();
+ } else {
+ new File(tmpDirectory, "resources.xml").delete();
+ new File(tmpDirectory, "dynamicBundle.jar").delete();
+ }
FileOutputStream output = null;
byte[] resourcesBytes = IOUtils.read(resource.openStream());
output = new FileOutputStream(new File(tmpDirectory, "resources.xml"));

Back to the top