Resolve runbundles for CXF upgrade (#15473)

* Resolve runbundles for CXF upgrade

Related to openhab/openhab-core#3770

Signed-off-by: Wouter Born <github@maindrain.net>

* Replace Grizzly JAX-RS Client with Jetty HTTP client in hueemulation tests

It seems that the Grizzly JAX-RS Client implementation does not work well with the new CXF dependencies on the classpath.
As we do not use Grizzly anywhere else it is probably best to also stop using the Grizzly HTTP Server in these tests in the future.

Signed-off-by: Wouter Born <github@maindrain.net>

---------

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2023-08-23 09:14:15 +02:00 committed by GitHub
parent 5f31eeb506
commit 626c6bde4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 166 additions and 185 deletions

View File

@ -22,13 +22,17 @@ import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Dictionary; import java.util.Dictionary;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.ws.rs.client.Client; import org.eclipse.jetty.client.HttpClient;
import javax.ws.rs.client.ClientBuilder; import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.util.StringContentProvider;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.logging.LoggingFeature;
@ -61,7 +65,7 @@ import org.osgi.service.cm.ConfigurationAdmin;
public class CommonSetup { public class CommonSetup {
public String basePath; public String basePath;
public Client client; public HttpClient client;
public ConfigStore cs; public ConfigStore cs;
public HttpServer server; public HttpServer server;
@ -150,12 +154,17 @@ public class CommonSetup {
log2.setLevel(Level.OFF); log2.setLevel(Level.OFF);
server = GrizzlyHttpServerFactory.createHttpServer(URI.create(basePath), rc); server = GrizzlyHttpServerFactory.createHttpServer(URI.create(basePath), rc);
client = ClientBuilder.newClient(); client = new HttpClient();
try {
client.start();
} catch (Exception e) {
throw new IllegalStateException("Failed to start HttpClient", e);
}
} }
public void dispose() throws Exception { public void dispose() throws Exception {
if (client != null) { if (client != null) {
client.close(); client.stop();
} }
if (server != null) { if (server != null) {
server.shutdownNow(); server.shutdownNow();
@ -163,4 +172,33 @@ public class CommonSetup {
mocksCloseable.close(); mocksCloseable.close();
} }
public ContentResponse sendDelete(String path) throws InterruptedException, TimeoutException, ExecutionException {
return client.newRequest(basePath + path).method(HttpMethod.DELETE).send();
}
public ContentResponse sendGet() throws InterruptedException, TimeoutException, ExecutionException {
return client.newRequest(basePath).method(HttpMethod.GET).send();
}
public ContentResponse sendGet(String path) throws InterruptedException, TimeoutException, ExecutionException {
return client.newRequest(basePath + path).method(HttpMethod.GET).send();
}
public ContentResponse sendPost(String content) throws InterruptedException, TimeoutException, ExecutionException {
return client.newRequest(basePath).method(HttpMethod.POST).header(HttpHeader.CONTENT_TYPE, "application/json")
.content(new StringContentProvider(content)).send();
}
public ContentResponse sendPost(String path, String content)
throws InterruptedException, TimeoutException, ExecutionException {
return client.newRequest(basePath + path).method(HttpMethod.POST)
.header(HttpHeader.CONTENT_TYPE, "application/json").content(new StringContentProvider(content)).send();
}
public ContentResponse sendPut(String path, String content)
throws InterruptedException, TimeoutException, ExecutionException {
return client.newRequest(basePath + path).method(HttpMethod.PUT)
.header(HttpHeader.CONTENT_TYPE, "application/json").content(new StringContentProvider(content)).send();
}
} }

View File

@ -20,10 +20,8 @@ import static org.mockito.Mockito.verify;
import java.io.IOException; import java.io.IOException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jetty.client.api.ContentResponse;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -196,14 +194,13 @@ public class LightsAndGroupsTests {
} }
@Test @Test
public void changeSwitchState() { public void changeSwitchState() throws Exception {
assertThat(((HueStatePlug) cs.ds.lights.get("1").state).on, is(false)); assertThat(((HueStatePlug) cs.ds.lights.get("1").state).on, is(false));
String body = "{'on':true}"; String body = "{'on':true}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights/1/state").request() ContentResponse response = commonSetup.sendPut("/testuser/lights/1/state", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
assertThat(((HueStatePlug) cs.ds.lights.get("1").state).on, is(true)); assertThat(((HueStatePlug) cs.ds.lights.get("1").state).on, is(true));
verify(commonSetup.eventPublisher).post(argThat((Event t) -> { verify(commonSetup.eventPublisher).post(argThat((Event t) -> {
assertThat(t.getPayload(), is("{\"type\":\"OnOff\",\"value\":\"ON\"}")); assertThat(t.getPayload(), is("{\"type\":\"OnOff\",\"value\":\"ON\"}"));
@ -212,14 +209,13 @@ public class LightsAndGroupsTests {
} }
@Test @Test
public void changeGroupItemSwitchState() { public void changeGroupItemSwitchState() throws Exception {
assertThat(((HueStatePlug) cs.ds.groups.get("10").action).on, is(false)); assertThat(((HueStatePlug) cs.ds.groups.get("10").action).on, is(false));
String body = "{'on':true}"; String body = "{'on':true}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/groups/10/action").request() ContentResponse response = commonSetup.sendPut("/testuser/groups/10/action", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
assertThat(((HueStatePlug) cs.ds.groups.get("10").action).on, is(true)); assertThat(((HueStatePlug) cs.ds.groups.get("10").action).on, is(true));
verify(commonSetup.eventPublisher).post(argThat((Event t) -> { verify(commonSetup.eventPublisher).post(argThat((Event t) -> {
assertThat(t.getPayload(), is("{\"type\":\"OnOff\",\"value\":\"ON\"}")); assertThat(t.getPayload(), is("{\"type\":\"OnOff\",\"value\":\"ON\"}"));
@ -228,43 +224,40 @@ public class LightsAndGroupsTests {
} }
@Test @Test
public void changeOnValue() { public void changeOnValue() throws Exception {
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(false)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(false));
String body = "{'on':true}"; String body = "{'on':true}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights/2/state").request() ContentResponse response = commonSetup.sendPut("/testuser/lights/2/state", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
String entity = response.readEntity(String.class); String entity = response.getContentAsString();
assertThat(entity, is("[{\"success\":{\"/lights/2/state/on\":true}}]")); assertThat(entity, is("[{\"success\":{\"/lights/2/state/on\":true}}]"));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true));
} }
@Test @Test
public void changeOnAndBriValues() { public void changeOnAndBriValues() throws Exception {
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(false)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(false));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(1)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(1));
String body = "{'on':true,'bri':200}"; String body = "{'on':true,'bri':200}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights/2/state").request() ContentResponse response = commonSetup.sendPut("/testuser/lights/2/state", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(200)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(200));
} }
@Test @Test
public void changeHueSatValues() { public void changeHueSatValues() throws Exception {
HueLightEntry hueDevice = cs.ds.lights.get("2"); HueLightEntry hueDevice = cs.ds.lights.get("2");
hueDevice.item.setState(OnOffType.ON); hueDevice.item.setState(OnOffType.ON);
hueDevice.state.as(HueStateColorBulb.class).on = true; hueDevice.state.as(HueStateColorBulb.class).on = true;
String body = "{'hue':1000,'sat':50}"; String body = "{'hue':1000,'sat':50}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights/2/state").request() ContentResponse response = commonSetup.sendPut("/testuser/lights/2/state", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).hue, is(1000)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).hue, is(1000));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).sat, is(50)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).sat, is(50));
@ -276,16 +269,15 @@ public class LightsAndGroupsTests {
* Amazon echos are setting ct only, if commanded to turn a light white. * Amazon echos are setting ct only, if commanded to turn a light white.
*/ */
@Test @Test
public void changeCtValue() { public void changeCtValue() throws Exception {
HueLightEntry hueDevice = cs.ds.lights.get("2"); HueLightEntry hueDevice = cs.ds.lights.get("2");
hueDevice.item.setState(OnOffType.ON); hueDevice.item.setState(OnOffType.ON);
hueDevice.state.as(HueStateColorBulb.class).on = true; hueDevice.state.as(HueStateColorBulb.class).on = true;
String body = "{'ct':500}"; String body = "{'ct':500}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights/2/state").request() ContentResponse response = commonSetup.sendPut("/testuser/lights/2/state", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
body = response.readEntity(String.class); body = response.getContentAsString();
assertThat(body, containsString("success")); assertThat(body, containsString("success"));
assertThat(body, containsString("ct")); assertThat(body, containsString("ct"));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true));
@ -297,16 +289,15 @@ public class LightsAndGroupsTests {
} }
@Test @Test
public void switchOnWithXY() { public void switchOnWithXY() throws Exception {
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(false)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(false));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(1)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(1));
String body = "{'on':true,'bri':200,'xy':[0.5119,0.4147]}"; String body = "{'on':true,'bri':200,'xy':[0.5119,0.4147]}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights/2/state").request() ContentResponse response = commonSetup.sendPut("/testuser/lights/2/state", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
assertThat(response.readEntity(String.class), containsString("xy")); assertThat(response.getContentAsString(), containsString("xy"));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).on, is(true));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(200)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).bri, is(200));
assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).xy[0], is(0.5119)); assertThat(((HueStateColorBulb) cs.ds.lights.get("2").state).xy[0], is(0.5119));
@ -319,20 +310,20 @@ public class LightsAndGroupsTests {
} }
@Test @Test
public void allLightsAndSingleLight() { public void allLightsAndSingleLight() throws Exception {
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights").request().get(); ContentResponse response = commonSetup.sendGet("/testuser/lights");
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
String body = response.readEntity(String.class); String body = response.getContentAsString();
assertThat(body, containsString("switch")); assertThat(body, containsString("switch"));
assertThat(body, containsString("color")); assertThat(body, containsString("color"));
assertThat(body, containsString("white")); assertThat(body, containsString("white"));
// Single light access test // Single light access test
response = commonSetup.client.target(commonSetup.basePath + "/testuser/lights/2").request().get(); response = commonSetup.sendGet("/testuser/lights/2");
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
body = response.readEntity(String.class); body = response.getContentAsString();
assertThat(body, containsString("color")); assertThat(body, containsString("color"));
} }

View File

@ -22,10 +22,8 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Random; import java.util.Random;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jetty.client.api.ContentResponse;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -158,13 +156,12 @@ public class RulesTests {
@SuppressWarnings("null") @SuppressWarnings("null")
@Test @Test
public void addGetRemoveRuleViaRest() { public void addGetRemoveRuleViaRest() throws Exception {
// 1. Create // 1. Create
String body = "{\"name\":\"test name\",\"description\":\"\",\"owner\":\"\",\"conditions\":[{\"address\":\"/lights/switch1/state/on\",\"operator\":\"dx\"}],\"actions\":[{\"address\":\"/lights/switch1/state\",\"method\":\"PUT\",\"body\":\"{\\u0027on\\u0027:true}\"}]}"; String body = "{\"name\":\"test name\",\"description\":\"\",\"owner\":\"\",\"conditions\":[{\"address\":\"/lights/switch1/state/on\",\"operator\":\"dx\"}],\"actions\":[{\"address\":\"/lights/switch1/state\",\"method\":\"PUT\",\"body\":\"{\\u0027on\\u0027:true}\"}]}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/rules").request() ContentResponse response = commonSetup.sendPost("/testuser/rules", body);
.post(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
// 1.1 Check for entry // 1.1 Check for entry
Entry<String, HueRuleEntry> idAndEntry = cs.ds.rules.entrySet().stream().findAny().get(); Entry<String, HueRuleEntry> idAndEntry = cs.ds.rules.entrySet().stream().findAny().get();
@ -180,21 +177,19 @@ public class RulesTests {
assertThat(rule.getActions().get(0).getTypeUID(), is("rules.HttpAction")); assertThat(rule.getActions().get(0).getTypeUID(), is("rules.HttpAction"));
// 2. Get // 2. Get
response = commonSetup.client.target(commonSetup.basePath + "/testuser/rules/" + idAndEntry.getKey()).request() response = commonSetup.sendGet("/testuser/rules/" + idAndEntry.getKey());
.get();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
HueSceneEntry fromJson = new Gson().fromJson(response.readEntity(String.class), HueSceneEntry.class); HueSceneEntry fromJson = new Gson().fromJson(response.getContentAsString(), HueSceneEntry.class);
assertThat(fromJson.name, is(idAndEntry.getValue().name)); assertThat(fromJson.name, is(idAndEntry.getValue().name));
// 3. Remove // 3. Remove
response = commonSetup.client.target(commonSetup.basePath + "/testuser/rules/" + idAndEntry.getKey()).request() response = commonSetup.sendDelete("/testuser/rules/" + idAndEntry.getKey());
.delete();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertTrue(cs.ds.rules.isEmpty()); assertTrue(cs.ds.rules.isEmpty());
} }
@Test @Test
public void updateRuleViaRest() { public void updateRuleViaRest() throws Exception {
HueCommand command = new HueCommand("/api/testuser/lights/switch1/state", "PUT", "{'on':true}"); HueCommand command = new HueCommand("/api/testuser/lights/switch1/state", "PUT", "{'on':true}");
HueRuleEntry.Condition condition = new HueRuleEntry.Condition("/lights/switch1/state/on", Operator.dx, null); HueRuleEntry.Condition condition = new HueRuleEntry.Condition("/lights/switch1/state/on", Operator.dx, null);
@ -209,10 +204,9 @@ public class RulesTests {
// Modify (just the name) // Modify (just the name)
String body = "{ 'name':'A new name'}"; String body = "{ 'name':'A new name'}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/rules/demo1").request() ContentResponse response = commonSetup.sendPut("/testuser/rules/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("name")); assertThat(response.getContentAsString(), containsString("name"));
Entry<String, HueRuleEntry> idAndEntry = cs.ds.rules.entrySet().stream().findAny().get(); Entry<String, HueRuleEntry> idAndEntry = cs.ds.rules.entrySet().stream().findAny().get();
HueRuleEntry entry = idAndEntry.getValue(); HueRuleEntry entry = idAndEntry.getValue();
@ -231,10 +225,9 @@ public class RulesTests {
// Modify (Change condition) // Modify (Change condition)
body = "{\"conditions\":[{\"address\":\"/lights/switch1/state/on\",\"operator\":\"ddx\"}]}"; body = "{\"conditions\":[{\"address\":\"/lights/switch1/state/on\",\"operator\":\"ddx\"}]}";
response = commonSetup.client.target(commonSetup.basePath + "/testuser/rules/demo1").request() response = commonSetup.sendPut("/testuser/rules/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("conditions")); assertThat(response.getContentAsString(), containsString("conditions"));
idAndEntry = cs.ds.rules.entrySet().stream().findAny().get(); idAndEntry = cs.ds.rules.entrySet().stream().findAny().get();
entry = idAndEntry.getValue(); entry = idAndEntry.getValue();
@ -243,10 +236,9 @@ public class RulesTests {
// Modify (Change action) // Modify (Change action)
body = "{\"actions\":[{\"address\":\"/lights/switch2/state\",\"method\":\"PUT\",\"body\":\"{\\u0027on\\u0027:false}\"}]}"; body = "{\"actions\":[{\"address\":\"/lights/switch2/state\",\"method\":\"PUT\",\"body\":\"{\\u0027on\\u0027:false}\"}]}";
response = commonSetup.client.target(commonSetup.basePath + "/testuser/rules/demo1").request() response = commonSetup.sendPut("/testuser/rules/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("actions")); assertThat(response.getContentAsString(), containsString("actions"));
idAndEntry = cs.ds.rules.entrySet().stream().findAny().get(); idAndEntry = cs.ds.rules.entrySet().stream().findAny().get();
entry = idAndEntry.getValue(); entry = idAndEntry.getValue();
@ -255,7 +247,7 @@ public class RulesTests {
} }
@Test @Test
public void getAll() { public void getAll() throws Exception {
HueCommand command = new HueCommand("/api/testuser/lights/switch1/state", "PUT", "{'on':true}"); HueCommand command = new HueCommand("/api/testuser/lights/switch1/state", "PUT", "{'on':true}");
HueRuleEntry.Condition condition = new HueRuleEntry.Condition("/lights/switch1/state/on", Operator.dx, null); HueRuleEntry.Condition condition = new HueRuleEntry.Condition("/lights/switch1/state/on", Operator.dx, null);
@ -268,10 +260,10 @@ public class RulesTests {
ruleRegistry.add(rule); ruleRegistry.add(rule);
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/rules").request().get(); ContentResponse response = commonSetup.sendGet("/testuser/rules");
Type type = new TypeToken<Map<String, HueRuleEntry>>() { Type type = new TypeToken<Map<String, HueRuleEntry>>() {
}.getType(); }.getType();
String body = response.readEntity(String.class); String body = response.getContentAsString();
Map<String, HueRuleEntry> fromJson = new Gson().fromJson(body, type); Map<String, HueRuleEntry> fromJson = new Gson().fromJson(body, type);
HueRuleEntry entry = fromJson.get("demo1"); HueRuleEntry entry = fromJson.get("demo1");
assertThat(entry.name, is("test name")); assertThat(entry.name, is("test name"));

View File

@ -21,10 +21,8 @@ import java.lang.reflect.Type;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jetty.client.api.ContentResponse;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.hamcrest.CoreMatchers; import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
@ -131,13 +129,12 @@ public class SceneTests {
@SuppressWarnings("null") @SuppressWarnings("null")
@Test @Test
public void addGetRemoveSceneViaRest() { public void addGetRemoveSceneViaRest() throws Exception {
// 1. Create // 1. Create
String body = "{ 'name':'Cozy dinner', 'recycle':false, 'lights':['switch1','white1'], 'type':'LightScene'}"; String body = "{ 'name':'Cozy dinner', 'recycle':false, 'lights':['switch1','white1'], 'type':'LightScene'}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/scenes").request() ContentResponse response = commonSetup.sendPost("/testuser/scenes", body);
.post(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
// 1.1 Check for scene entry // 1.1 Check for scene entry
Entry<String, HueSceneEntry> entry = cs.ds.scenes.entrySet().stream().findAny().get(); Entry<String, HueSceneEntry> entry = cs.ds.scenes.entrySet().stream().findAny().get();
@ -152,22 +149,20 @@ public class SceneTests {
assertThat(rule.getActions().get(1).getId(), is("white1")); assertThat(rule.getActions().get(1).getId(), is("white1"));
// 2. Get // 2. Get
response = commonSetup.client.target(commonSetup.basePath + "/testuser/scenes/" + entry.getKey()).request() response = commonSetup.sendGet("/testuser/scenes/" + entry.getKey());
.get();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
HueSceneEntry fromJson = new Gson().fromJson(response.readEntity(String.class), HueSceneEntry.class); HueSceneEntry fromJson = new Gson().fromJson(response.getContentAsString(), HueSceneEntry.class);
assertThat(fromJson.name, is(entry.getValue().name)); assertThat(fromJson.name, is(entry.getValue().name));
// 3. Remove // 3. Remove
response = commonSetup.client.target(commonSetup.basePath + "/testuser/scenes/" + entry.getKey()).request() response = commonSetup.sendDelete("/testuser/scenes/" + entry.getKey());
.delete();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertTrue(cs.ds.scenes.isEmpty()); assertTrue(cs.ds.scenes.isEmpty());
} }
@SuppressWarnings("null") @SuppressWarnings("null")
@Test @Test
public void updateSceneViaRest() { public void updateSceneViaRest() throws Exception {
Rule rule = RuleBuilder.create("demo1").withTags("scene").withName("Some name") // Rule rule = RuleBuilder.create("demo1").withTags("scene").withName("Some name") //
.withActions(Scenes.actionFromState("switch1", (Command) OnOffType.ON)).build(); .withActions(Scenes.actionFromState("switch1", (Command) OnOffType.ON)).build();
@ -175,10 +170,9 @@ public class SceneTests {
// 3. Modify (just the name) // 3. Modify (just the name)
String body = "{ 'name':'A new name'}"; String body = "{ 'name':'A new name'}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/scenes/demo1").request() ContentResponse response = commonSetup.sendPut("/testuser/scenes/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("name")); assertThat(response.getContentAsString(), containsString("name"));
Entry<String, HueSceneEntry> sceneEntry = cs.ds.scenes.entrySet().stream().findAny().get(); Entry<String, HueSceneEntry> sceneEntry = cs.ds.scenes.entrySet().stream().findAny().get();
assertThat(sceneEntry.getValue().name, is("A new name")); assertThat(sceneEntry.getValue().name, is("A new name"));
@ -195,10 +189,9 @@ public class SceneTests {
// Without store lights // Without store lights
body = "{ 'lights':['white1']}"; body = "{ 'lights':['white1']}";
response = commonSetup.client.target(commonSetup.basePath + "/testuser/scenes/demo1").request() response = commonSetup.sendPut("/testuser/scenes/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("lights")); assertThat(response.getContentAsString(), containsString("lights"));
sceneEntry = cs.ds.scenes.entrySet().stream().findAny().get(); sceneEntry = cs.ds.scenes.entrySet().stream().findAny().get();
assertThat(sceneEntry.getValue().name, is("Some name")); // should not have changed assertThat(sceneEntry.getValue().name, is("Some name")); // should not have changed
@ -207,26 +200,25 @@ public class SceneTests {
// With store lights // With store lights
body = "{ 'lights':['white1'], 'storelightstate':true }"; body = "{ 'lights':['white1'], 'storelightstate':true }";
response = commonSetup.client.target(commonSetup.basePath + "/testuser/scenes/demo1").request() response = commonSetup.sendPut("/testuser/scenes/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("lights")); assertThat(response.getContentAsString(), containsString("lights"));
sceneEntry = cs.ds.scenes.entrySet().stream().findAny().get(); sceneEntry = cs.ds.scenes.entrySet().stream().findAny().get();
assertThat(sceneEntry.getValue().lights.get(0), is("white1")); assertThat(sceneEntry.getValue().lights.get(0), is("white1"));
} }
@Test @Test
public void getAll() { public void getAll() throws Exception {
Rule rule = RuleBuilder.create("demo1").withTags("scene") // Rule rule = RuleBuilder.create("demo1").withTags("scene") //
.withActions(Scenes.actionFromState("switch1", (Command) OnOffType.ON)).build(); .withActions(Scenes.actionFromState("switch1", (Command) OnOffType.ON)).build();
ruleRegistry.add(rule); ruleRegistry.add(rule);
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/scenes").request().get(); ContentResponse response = commonSetup.sendGet("/testuser/scenes");
Type type = new TypeToken<Map<String, HueSceneEntry>>() { Type type = new TypeToken<Map<String, HueSceneEntry>>() {
}.getType(); }.getType();
Map<String, HueSceneEntry> fromJson = new Gson().fromJson(response.readEntity(String.class), type); Map<String, HueSceneEntry> fromJson = new Gson().fromJson(response.getContentAsString(), type);
assertTrue(fromJson.containsKey("demo1")); assertTrue(fromJson.containsKey("demo1"));
} }
} }

View File

@ -25,10 +25,8 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Random; import java.util.Random;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jetty.client.api.ContentResponse;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -143,14 +141,13 @@ public class ScheduleTests {
@SuppressWarnings("null") @SuppressWarnings("null")
@Test @Test
public void addGetRemoveScheduleViaRest() { public void addGetRemoveScheduleViaRest() throws Exception {
// 1. Create // 1. Create
String body = "{ 'name':'Wake up', 'description':'My wake up alarm', 'localtime':'2015-06-30T14:24:40'," + // String body = "{ 'name':'Wake up', 'description':'My wake up alarm', 'localtime':'2015-06-30T14:24:40'," + //
"'command':{'address':'/api/testuser/lights/1/state','method':'PUT','body':'{\"on\":true}'} }"; "'command':{'address':'/api/testuser/lights/1/state','method':'PUT','body':'{\"on\":true}'} }";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/schedules").request() ContentResponse response = commonSetup.sendPost("/testuser/schedules", body);
.post(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("success")); assertThat(response.getContentAsString(), containsString("success"));
// 1.1 Check for entry // 1.1 Check for entry
Entry<String, HueScheduleEntry> entry = cs.ds.schedules.entrySet().stream().findAny().get(); Entry<String, HueScheduleEntry> entry = cs.ds.schedules.entrySet().stream().findAny().get();
@ -167,22 +164,20 @@ public class ScheduleTests {
assertThat(rule.getActions().get(0).getTypeUID(), is("rules.HttpAction")); assertThat(rule.getActions().get(0).getTypeUID(), is("rules.HttpAction"));
// 2. Get // 2. Get
response = commonSetup.client.target(commonSetup.basePath + "/testuser/schedules/" + entry.getKey()).request() response = commonSetup.sendGet("/testuser/schedules/" + entry.getKey());
.get();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
HueSceneEntry fromJson = new Gson().fromJson(response.readEntity(String.class), HueSceneEntry.class); HueSceneEntry fromJson = new Gson().fromJson(response.getContentAsString(), HueSceneEntry.class);
assertThat(fromJson.name, is(entry.getValue().name)); assertThat(fromJson.name, is(entry.getValue().name));
// 3. Remove // 3. Remove
response = commonSetup.client.target(commonSetup.basePath + "/testuser/schedules/" + entry.getKey()).request() response = commonSetup.sendDelete("/testuser/schedules/" + entry.getKey());
.delete();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertTrue(cs.ds.schedules.isEmpty()); assertTrue(cs.ds.schedules.isEmpty());
} }
@SuppressWarnings("null") @SuppressWarnings("null")
@Test @Test
public void updateScheduleViaRest() { public void updateScheduleViaRest() throws Exception {
HueCommand command = new HueCommand("/api/testuser/lights/1/state", "PUT", "{'on':true}"); HueCommand command = new HueCommand("/api/testuser/lights/1/state", "PUT", "{'on':true}");
String localtime = "2020-02-01T12:12:00"; String localtime = "2020-02-01T12:12:00";
@ -194,10 +189,9 @@ public class ScheduleTests {
// Modify (just the name) // Modify (just the name)
String body = "{ 'name':'A new name'}"; String body = "{ 'name':'A new name'}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/schedules/demo1").request() ContentResponse response = commonSetup.sendPut("/testuser/schedules/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("name")); assertThat(response.getContentAsString(), containsString("name"));
Entry<String, HueScheduleEntry> entry = cs.ds.schedules.entrySet().stream().findAny().get(); Entry<String, HueScheduleEntry> entry = cs.ds.schedules.entrySet().stream().findAny().get();
assertThat(entry.getValue().name, is("A new name")); assertThat(entry.getValue().name, is("A new name"));
@ -217,10 +211,9 @@ public class ScheduleTests {
// Modify (Change time) // Modify (Change time)
body = "{ 'localtime':'2015-06-30T14:24:40'}"; body = "{ 'localtime':'2015-06-30T14:24:40'}";
response = commonSetup.client.target(commonSetup.basePath + "/testuser/schedules/demo1").request() response = commonSetup.sendPut("/testuser/schedules/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("localtime")); assertThat(response.getContentAsString(), containsString("localtime"));
entry = cs.ds.schedules.entrySet().stream().findAny().get(); entry = cs.ds.schedules.entrySet().stream().findAny().get();
assertThat(entry.getValue().name, is("test name")); // should not have changed assertThat(entry.getValue().name, is("test name")); // should not have changed
@ -229,10 +222,9 @@ public class ScheduleTests {
// Modify (Change command) // Modify (Change command)
body = "{ 'command':{'address':'/api/testuser/lights/2/state','method':'PUT','body':'{\"on\":true}'} }"; body = "{ 'command':{'address':'/api/testuser/lights/2/state','method':'PUT','body':'{\"on\":true}'} }";
response = commonSetup.client.target(commonSetup.basePath + "/testuser/schedules/demo1").request() response = commonSetup.sendPut("/testuser/schedules/demo1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
assertThat(response.readEntity(String.class), containsString("command")); assertThat(response.getContentAsString(), containsString("command"));
entry = cs.ds.schedules.entrySet().stream().findAny().get(); entry = cs.ds.schedules.entrySet().stream().findAny().get();
assertThat(entry.getValue().name, is("test name")); // should not have changed assertThat(entry.getValue().name, is("test name")); // should not have changed
@ -241,7 +233,7 @@ public class ScheduleTests {
} }
@Test @Test
public void getAll() { public void getAll() throws Exception {
HueCommand command = new HueCommand("/api/testuser/lights/1/state", "POST", "{'on':true}"); HueCommand command = new HueCommand("/api/testuser/lights/1/state", "POST", "{'on':true}");
String localtime = "2020-02-01T12:12:00"; String localtime = "2020-02-01T12:12:00";
@ -251,10 +243,10 @@ public class ScheduleTests {
ruleRegistry.add(rule); ruleRegistry.add(rule);
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/schedules").request().get(); ContentResponse response = commonSetup.sendGet("/testuser/schedules");
Type type = new TypeToken<Map<String, HueSceneEntry>>() { Type type = new TypeToken<Map<String, HueSceneEntry>>() {
}.getType(); }.getType();
Map<String, HueSceneEntry> fromJson = new Gson().fromJson(response.readEntity(String.class), type); Map<String, HueSceneEntry> fromJson = new Gson().fromJson(response.getContentAsString(), type);
assertTrue(fromJson.containsKey("demo1")); assertTrue(fromJson.containsKey("demo1"));
} }

View File

@ -16,12 +16,9 @@ import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -54,6 +51,8 @@ public class SensorTests {
protected @NonNullByDefault({}) ItemRegistry itemRegistry; protected @NonNullByDefault({}) ItemRegistry itemRegistry;
protected @NonNullByDefault({}) ConfigStore cs; protected @NonNullByDefault({}) ConfigStore cs;
private @NonNullByDefault({}) HttpClient httpClient;
Sensors subject = new Sensors(); Sensors subject = new Sensors();
private void addItemToReg(GenericItem item, State state, String label) { private void addItemToReg(GenericItem item, State state, String label) {
@ -63,7 +62,7 @@ public class SensorTests {
} }
@BeforeEach @BeforeEach
public void setUp() throws IOException { public void setUp() throws Exception {
commonSetup = new CommonSetup(false); commonSetup = new CommonSetup(false);
itemRegistry = new DummyItemRegistry(); itemRegistry = new DummyItemRegistry();
@ -74,6 +73,9 @@ public class SensorTests {
subject.itemRegistry = itemRegistry; subject.itemRegistry = itemRegistry;
subject.activate(); subject.activate();
httpClient = new HttpClient();
httpClient.start();
// Add simulated sensor items // Add simulated sensor items
addItemToReg(new SwitchItem("switch1"), OnOffType.ON, "name1"); addItemToReg(new SwitchItem("switch1"), OnOffType.ON, "name1");
addItemToReg(new ContactItem("contact1"), OpenClosedType.OPEN, ""); addItemToReg(new ContactItem("contact1"), OpenClosedType.OPEN, "");
@ -91,34 +93,35 @@ public class SensorTests {
} }
@Test @Test
public void renameSensor() { public void renameSensor() throws Exception {
assertThat(cs.ds.sensors.get("switch1").name, is("name1")); assertThat(cs.ds.sensors.get("switch1").name, is("name1"));
String body = "{'name':'name2'}"; String body = "{'name':'name2'}";
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/sensors/switch1").request() ContentResponse response = commonSetup.sendPut("/testuser/sensors/switch1", body);
.put(Entity.json(body));
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
body = response.readEntity(String.class);
body = response.getContentAsString();
assertThat(body, containsString("success")); assertThat(body, containsString("success"));
assertThat(body, containsString("name")); assertThat(body, containsString("name"));
assertThat(cs.ds.sensors.get("switch1").name, is("name2")); assertThat(cs.ds.sensors.get("switch1").name, is("name2"));
} }
@Test @Test
public void allAndSingleSensor() { public void allAndSingleSensor() throws Exception {
Response response = commonSetup.client.target(commonSetup.basePath + "/testuser/sensors").request().get(); ContentResponse response = commonSetup.sendGet("/testuser/sensors");
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
String body = response.readEntity(String.class); String body = response.getContentAsString();
assertThat(body, containsString("switch1")); assertThat(body, containsString("switch1"));
assertThat(body, containsString("color1")); assertThat(body, containsString("color1"));
assertThat(body, containsString("white1")); assertThat(body, containsString("white1"));
// Single light access test // Single light access test
response = commonSetup.client.target(commonSetup.basePath + "/testuser/sensors/switch1").request().get(); response = commonSetup.sendGet("/testuser/sensors/switch1");
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
body = response.readEntity(String.class); body = response.getContentAsString();
assertThat(body, containsString("CLIPGenericFlag")); assertThat(body, containsString("CLIPGenericFlag"));
} }
} }

View File

@ -20,9 +20,7 @@ import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Dictionary; import java.util.Dictionary;
import javax.ws.rs.client.Entity; import org.eclipse.jetty.client.api.ContentResponse;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -94,27 +92,24 @@ public class UsersAndConfigTests {
} }
@Test @Test
public void addUser() { public void addUser() throws Exception {
// GET should fail // GET should fail
assertEquals(405, commonSetup.client.target(commonSetup.basePath).request().get().getStatus()); assertEquals(405, commonSetup.sendGet().getStatus());
String body = "{'username':'testuser','devicetype':'app#device'}"; String body = "{'username':'testuser','devicetype':'app#device'}";
Response response;
HueResponse[] r;
// Post should create a user, except: if linkbutton not enabled // Post should create a user, except: if linkbutton not enabled
response = commonSetup.client.target(commonSetup.basePath).request().post(Entity.json(body)); ContentResponse response = commonSetup.sendPost(body);
assertThat(response.getStatus(), is(200)); assertThat(response.getStatus(), is(200));
r = commonSetup.cs.gson.fromJson(response.readEntity(String.class), HueResponse[].class); HueResponse[] r = commonSetup.cs.gson.fromJson(response.getContentAsString(), HueResponse[].class);
assertNotNull(r[0].error); assertNotNull(r[0].error);
// Post should create a user // Post should create a user
commonSetup.cs.ds.config.linkbutton = true; commonSetup.cs.ds.config.linkbutton = true;
response = commonSetup.client.target(commonSetup.basePath).request().post(Entity.json(body)); response = commonSetup.sendPost(body);
assertThat(response.getStatus(), is(200)); assertThat(response.getStatus(), is(200));
JsonElement e = JsonParser.parseString(response.readEntity(String.class)).getAsJsonArray().get(0); JsonElement e = JsonParser.parseString(response.getContentAsString()).getAsJsonArray().get(0);
e = e.getAsJsonObject().get("success"); e = e.getAsJsonObject().get("success");
HueSuccessResponseCreateUser rc = commonSetup.cs.gson.fromJson(e, HueSuccessResponseCreateUser.class); HueSuccessResponseCreateUser rc = commonSetup.cs.gson.fromJson(e, HueSuccessResponseCreateUser.class);
assertNotNull(rc); assertNotNull(rc);
@ -122,19 +117,17 @@ public class UsersAndConfigTests {
} }
@Test @Test
public void unauthorizedAccessTest() { public void unauthorizedAccessTest() throws Exception {
// Unauthorized config // Unauthorized config
Response response; ContentResponse response = commonSetup.sendGet("/config");
response = commonSetup.client.target(commonSetup.basePath + "/config").request().get();
assertThat(response.getStatus(), is(200)); assertThat(response.getStatus(), is(200));
HueUnauthorizedConfig config = new Gson().fromJson(response.readEntity(String.class), HueUnauthorizedConfig config = new Gson().fromJson(response.getContentAsString(), HueUnauthorizedConfig.class);
HueUnauthorizedConfig.class);
assertThat(config.bridgeid, is(commonSetup.cs.ds.config.bridgeid)); assertThat(config.bridgeid, is(commonSetup.cs.ds.config.bridgeid));
assertThat(config.name, is(commonSetup.cs.ds.config.name)); assertThat(config.name, is(commonSetup.cs.ds.config.name));
// Invalid user name // Invalid user name
response = commonSetup.client.target(commonSetup.basePath + "/invalid/config").request().get(); response = commonSetup.sendGet("/invalid/config");
assertThat(response.getStatus(), is(403)); assertThat(response.getStatus(), is(403));
assertThat(response.readEntity(String.class), containsString("error")); assertThat(response.getContentAsString(), containsString("error"));
} }
} }

View File

@ -26,8 +26,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;
import org.eclipse.jetty.client.api.ContentResponse;
import org.glassfish.grizzly.osgi.httpservice.HttpServiceImpl; import org.glassfish.grizzly.osgi.httpservice.HttpServiceImpl;
import org.glassfish.grizzly.osgi.httpservice.OSGiMainHandler; import org.glassfish.grizzly.osgi.httpservice.OSGiMainHandler;
import org.glassfish.grizzly.osgi.httpservice.util.Logger; import org.glassfish.grizzly.osgi.httpservice.util.Logger;
@ -102,8 +102,8 @@ public class UpnpTests {
} }
@Test @Test
public void descriptionWithoutAddress() { public void descriptionWithoutAddress() throws Exception {
Response response = commonSetup.client.target(descriptionPath).request().get(); ContentResponse response = commonSetup.client.newRequest(descriptionPath).send();
assertEquals(404, response.getStatus()); assertEquals(404, response.getStatus());
} }
@ -113,9 +113,9 @@ public class UpnpTests {
HueEmulationConfigWithRuntime r = subject.createConfiguration(null); HueEmulationConfigWithRuntime r = subject.createConfiguration(null);
r = subject.performAddressTest(r); r = subject.performAddressTest(r);
subject.applyConfiguration(r); subject.applyConfiguration(r);
Response response = commonSetup.client.target(descriptionPath).request().get(); ContentResponse response = commonSetup.client.newRequest(descriptionPath).send();
assertEquals(200, response.getStatus()); assertEquals(200, response.getStatus());
String body = response.readEntity(String.class); String body = response.getContentAsString();
assertThat(body, is(subject.xmlDocWithAddress)); assertThat(body, is(subject.xmlDocWithAddress));
if (r == null) { if (r == null) {

View File

@ -69,7 +69,6 @@ Fragment-Host: org.openhab.automation.jsscriptingnashorn
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -52,7 +52,6 @@ Fragment-Host: org.openhab.binding.astro
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -78,7 +78,6 @@ Fragment-Host: org.openhab.binding.avmfritz
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -84,7 +84,6 @@ Fragment-Host: org.openhab.binding.hue
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -64,7 +64,6 @@ Fragment-Host: org.openhab.binding.max
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -84,7 +84,6 @@ Fragment-Host: org.openhab.binding.mielecloud
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -72,7 +72,6 @@ Fragment-Host: org.openhab.binding.modbus
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -105,8 +105,6 @@ Import-Package: \
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
jakarta.ws.rs-api;version='[2.1.6,2.1.7)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -105,8 +105,6 @@ Import-Package: \
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
jakarta.ws.rs-api;version='[2.1.6,2.1.7)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -106,8 +106,6 @@ Import-Package: \
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
jakarta.ws.rs-api;version='[2.1.6,2.1.7)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -26,19 +26,10 @@ Fragment-Host: org.openhab.binding.nest
org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\ org.glassfish.hk2.osgi-resource-locator;version='[1.0.3,1.0.4)',\
org.apache.aries.javax.jax.rs-api;version='[1.0.1,1.0.2)',\ org.apache.aries.javax.jax.rs-api;version='[1.0.1,1.0.2)',\
jakarta.annotation-api;version='[1.3.5,1.3.6)',\ jakarta.annotation-api;version='[1.3.5,1.3.6)',\
jakarta.xml.soap-api;version='[1.4.2,1.4.3)',\
jakarta.xml.ws-api;version='[2.3.3,2.3.4)',\
org.apache.aries.component-dsl.component-dsl;version='[1.2.2,1.2.3)',\ org.apache.aries.component-dsl.component-dsl;version='[1.2.2,1.2.3)',\
org.apache.ws.xmlschema.core;version='[2.2.5,2.2.6)',\
stax2-api;version='[4.2.1,4.2.2)',\ stax2-api;version='[4.2.1,4.2.2)',\
jakarta.inject.jakarta.inject-api;version='[2.0.0,2.0.1)',\ jakarta.inject.jakarta.inject-api;version='[2.0.0,2.0.1)',\
org.glassfish.hk2.external.javax.inject;version='[2.4.0,2.4.1)',\ org.glassfish.hk2.external.javax.inject;version='[2.4.0,2.4.1)',\
org.apache.cxf.cxf-core;version='[3.4.5,3.4.6)',\
org.apache.cxf.cxf-rt-frontend-jaxrs;version='[3.4.5,3.4.6)',\
org.apache.cxf.cxf-rt-rs-client;version='[3.4.5,3.4.6)',\
org.apache.cxf.cxf-rt-rs-sse;version='[3.4.5,3.4.6)',\
org.apache.cxf.cxf-rt-security;version='[3.4.5,3.4.6)',\
org.apache.cxf.cxf-rt-transports-http;version='[3.4.5,3.4.6)',\
si-units;version='[2.1.0,2.1.1)',\ si-units;version='[2.1.0,2.1.1)',\
si.uom.si-quantity;version='[2.1.0,2.1.1)',\ si.uom.si-quantity;version='[2.1.0,2.1.1)',\
org.apache.aries.jax.rs.whiteboard;version='[2.0.0,2.0.1)',\ org.apache.aries.jax.rs.whiteboard;version='[2.0.0,2.0.1)',\
@ -111,4 +102,11 @@ Fragment-Host: org.openhab.binding.nest
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\
uom-lib-common;version='[2.2.0,2.2.1)',\ uom-lib-common;version='[2.2.0,2.2.1)',\
com.fasterxml.woodstox.woodstox-core;version='[6.5.1,6.5.2)' com.fasterxml.woodstox.woodstox-core;version='[6.5.1,6.5.2)',\
org.apache.cxf.cxf-core;version='[3.6.1,3.6.2)',\
org.apache.cxf.cxf-rt-frontend-jaxrs;version='[3.6.1,3.6.2)',\
org.apache.cxf.cxf-rt-rs-client;version='[3.6.1,3.6.2)',\
org.apache.cxf.cxf-rt-rs-sse;version='[3.6.1,3.6.2)',\
org.apache.cxf.cxf-rt-security;version='[3.6.1,3.6.2)',\
org.apache.cxf.cxf-rt-transports-http;version='[3.6.1,3.6.2)',\
org.apache.ws.xmlschema.core;version='[2.3.0,2.3.1)'

View File

@ -68,7 +68,6 @@ Fragment-Host: org.openhab.binding.ntp
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -71,7 +71,6 @@ Fragment-Host: org.openhab.binding.systeminfo
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -75,7 +75,6 @@ Fragment-Host: org.openhab.binding.tradfri
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -80,7 +80,6 @@ Fragment-Host: org.openhab.binding.wemo
org.openhab.core.thing;version='[4.1.0,4.1.1)',\ org.openhab.core.thing;version='[4.1.0,4.1.1)',\
org.openhab.core.transform;version='[4.1.0,4.1.1)',\ org.openhab.core.transform;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\

View File

@ -62,7 +62,6 @@ Fragment-Host: org.openhab.persistence.mapdb
org.openhab.persistence.mapdb;version='[4.1.0,4.1.1)',\ org.openhab.persistence.mapdb;version='[4.1.0,4.1.1)',\
org.openhab.persistence.mapdb.tests;version='[4.1.0,4.1.1)',\ org.openhab.persistence.mapdb.tests;version='[4.1.0,4.1.1)',\
org.openhab.base-fixes;version='[1.0.0,1.0.1)',\ org.openhab.base-fixes;version='[1.0.0,1.0.1)',\
org.osgi.service.cm;version='[1.6.0,1.6.1)',\
javax.measure.unit-api;version='[2.2.0,2.2.1)',\ javax.measure.unit-api;version='[2.2.0,2.2.1)',\
org.apiguardian.api;version='[1.1.2,1.1.3)',\ org.apiguardian.api;version='[1.1.2,1.1.3)',\
tech.units.indriya;version='[2.2.0,2.2.1)',\ tech.units.indriya;version='[2.2.0,2.2.1)',\