use of org.apache.commons.httpclient.methods.StringRequestEntity in project cloudstack by apache.
the class NeutronNodeAdapterTest method gsonNeutronPortMarshalingTest.
@Test
public void gsonNeutronPortMarshalingTest() throws NeutronRestApiException {
NeutronNode node = new NeutronNode("node-test", "test");
NeutronNodeWrapper nodeWrapper = new NeutronNodeWrapper(node);
StringRequestEntity entity;
try {
entity = new StringRequestEntity(gsonNeutronNode.toJson(nodeWrapper), "application/json", null);
String actual = entity.getContent();
Assert.assertEquals(jsonString, actual);
} catch (UnsupportedEncodingException e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.commons.httpclient.methods.StringRequestEntity in project cloudstack by apache.
the class NeutronNetworkAdapterTest method gsonNeutronNetworkMarshalingTest.
@Test
public void gsonNeutronNetworkMarshalingTest() throws NeutronRestApiException {
NeutronNetwork network = new NeutronNetwork();
network.setId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
network.setName("test_gre");
network.setNetworkType("test");
network.setSegmentationId(1001);
network.setShared(true);
network.setTenantId("wilder");
NeutronNetworkWrapper networkWrapper = new NeutronNetworkWrapper();
networkWrapper.setNetwork(network);
StringRequestEntity entity;
try {
entity = new StringRequestEntity(gsonNeutronNetwork.toJson(networkWrapper), "application/json", null);
String actual = entity.getContent();
Assert.assertEquals(jsonString, actual);
} catch (UnsupportedEncodingException e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.commons.httpclient.methods.StringRequestEntity in project cloudstack by apache.
the class NeutronPortAdapterTest method gsonNeutronPortMarshalingTest.
@Test
public void gsonNeutronPortMarshalingTest() throws NeutronRestApiException {
NeutronPort port = new NeutronPort();
port.setId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setName("test_gre");
port.setAdminStateUp(true);
port.setDeviceId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setMacAddress("ca31aa7f-84c7-416d-bc00-1f84927367e0");
port.setNetworkId(UUID.fromString("ca31aa7f-84c7-416d-bc00-1f84927367e0"));
port.setStatus("ACTIVE");
port.setTenantId("wilder");
NeutronPortWrapper portWrapper = new NeutronPortWrapper();
portWrapper.setPort(port);
StringRequestEntity entity;
try {
entity = new StringRequestEntity(gsonNeutronPort.toJson(portWrapper), "application/json", null);
String actual = entity.getContent();
Assert.assertEquals(jsonString, actual);
} catch (UnsupportedEncodingException e) {
Assert.fail(e.getMessage());
}
}
use of org.apache.commons.httpclient.methods.StringRequestEntity in project cloudstack by apache.
the class NeutronNetworksNorthboundAction method updateNeutronNetwork.
public <T> void updateNeutronNetwork(final String networkId, final NeutronNetworkWrapper newNetworkWrapper) throws NeutronRestApiException {
try {
String uri = NeutronNorthboundEnum.NETWORK_PARAM_URI.getUri();
uri = MessageFormat.format(uri, networkId);
StringRequestEntity entity = new StringRequestEntity(gsonNeutronNetwork.toJson(newNetworkWrapper), JSON_CONTENT_TYPE, null);
executePut(uri, entity);
} catch (UnsupportedEncodingException e) {
throw new NeutronRestApiException("Failed to encode json request body", e);
}
}
use of org.apache.commons.httpclient.methods.StringRequestEntity in project cloudstack by apache.
the class NeutronPortsNorthboundAction method updateNeutronPort.
public <T> void updateNeutronPort(final String portId, final NeutronPortWrapper newPortWrapper) throws NeutronRestApiException {
try {
String uri = NeutronNorthboundEnum.PORTS_PARAM_URI.getUri();
uri = MessageFormat.format(uri, portId);
StringRequestEntity entity = new StringRequestEntity(gsonNeutronPort.toJson(newPortWrapper), JSON_CONTENT_TYPE, null);
executePut(uri, entity);
} catch (UnsupportedEncodingException e) {
throw new NeutronRestApiException("Failed to encode json request body", e);
}
}
Aggregations