summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
6958a92)
If slash (/) should be part of path parameter from URI it can be specified with %2F
placeholder.
e.g. list which key is "ke/y_1" CAN'T be specified as
list_name/ke/y_1
but should be constructed as
list_name/ke%2Fy_1
It is also necessary to add to target distribution folder
/opendaylight/configuration/config.ini
following line
org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
Change-Id: Id07e7969247f3b60a44b808c95dac6375cebc011
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
# Embedded Tomcat configuration File
org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml
# Embedded Tomcat configuration File
org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml
+org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
# Open Flow related system parameters
# TCP port on which the controller is listening (default 6633)
# Open Flow related system parameters
# TCP port on which the controller is listening (default 6633)
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.Encoded;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/config/{identifier:.+}")
@Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
@Path("/config/{identifier:.+}")
@Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
- public StructuredData readConfigurationData(@PathParam("identifier") String identifier);
+ public StructuredData readConfigurationData(@Encoded @PathParam("identifier") String identifier);
@GET
@Path("/operational/{identifier:.+}")
@Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
@GET
@Path("/operational/{identifier:.+}")
@Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
- public StructuredData readOperationalData(@PathParam("identifier") String identifier);
+ public StructuredData readOperationalData(@Encoded @PathParam("identifier") String identifier);
@PUT
@Path("/config/{identifier:.+}")
@Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
@PUT
@Path("/config/{identifier:.+}")
@Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
- public Response updateConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
+ public Response updateConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
@POST
@Path("/config/{identifier:.+}")
@Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
@POST
@Path("/config/{identifier:.+}")
@Consumes({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
- public Response createConfigurationData(@PathParam("identifier") String identifier, CompositeNode payload);
+ public Response createConfigurationData(@Encoded @PathParam("identifier") String identifier, CompositeNode payload);
@DELETE
@Path("/config/{identifier:.+}")
@DELETE
@Path("/config/{identifier:.+}")
- public Response deleteConfigurationData(@PathParam("identifier") String identifier);
+ public Response deleteConfigurationData(@Encoded @PathParam("identifier") String identifier);
@GET
@Path("/streams/stream/{identifier:.+}")
@GET
@Path("/streams/stream/{identifier:.+}")
- public Response subscribeToStream(@PathParam("identifier") String identifier, @Context UriInfo uriInfo);
+ public Response subscribeToStream(@Encoded @PathParam("identifier") String identifier, @Context UriInfo uriInfo);
val static MOUNT_MODULE = "yang-ext"
val static MOUNT_NODE = "mount"
public val static MOUNT = "yang-ext:mount"
val static MOUNT_MODULE = "yang-ext"
val static MOUNT_NODE = "mount"
public val static MOUNT = "yang-ext:mount"
+ val static URI_ENCODING_CHAR_SET = "ISO-8859-1"
+ val static URI_SLASH_PLACEHOLDER = "%2F";
@Property
var SchemaContext globalSchema;
@Property
var SchemaContext globalSchema;
private def InstanceIdWithSchemaNode toIdentifier(String restconfInstance, boolean toMountPointIdentifier) {
checkPreconditions
private def InstanceIdWithSchemaNode toIdentifier(String restconfInstance, boolean toMountPointIdentifier) {
checkPreconditions
- val pathArgs = Lists.newArrayList(Splitter.on("/").split(restconfInstance))
+ val encodedPathArgs = Lists.newArrayList(Splitter.on("/").split(restconfInstance))
+ val pathArgs = urlPathArgsDecode(encodedPathArgs)
pathArgs.omitFirstAndLastEmptyString
if (pathArgs.empty) {
return null;
pathArgs.omitFirstAndLastEmptyString
if (pathArgs.empty) {
return null;
private def toUriString(Object object) {
if(object === null) return "";
private def toUriString(Object object) {
if(object === null) return "";
- return URLEncoder.encode(object.toString)
+// return object.toString.replace("/",URI_SLASH_PLACEHOLDER)
+ return URLEncoder.encode(object.toString,URI_ENCODING_CHAR_SET)
}
private def InstanceIdWithSchemaNode collectPathArguments(InstanceIdentifierBuilder builder, List<String> strings,
}
private def InstanceIdWithSchemaNode collectPathArguments(InstanceIdentifierBuilder builder, List<String> strings,
+
+ def urlPathArgsDecode(List<String> strings) {
+ val List<String> decodedPathArgs = new ArrayList();
+ for (pathArg : strings) {
+ decodedPathArgs.add(URLDecoder.decode(pathArg, URI_ENCODING_CHAR_SET))
+ }
+ return decodedPathArgs
+ }
+
import static org.mockito.Mockito.when;
import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.JSON;
import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML;
import static org.mockito.Mockito.when;
import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.JSON;
import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.XML;
-import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.createUri;
import java.io.IOException;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
public void testPostOperationsWithInputDataMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/operations/";
String uriPath = "ietf-interfaces:interfaces";
public void testPostOperationsWithInputDataMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/operations/";
String uriPath = "ietf-interfaces:interfaces";
- String uri = createUri(uriPrefix, uriPath);
+ String uri = uriPrefix + uriPath;
when(restconfService.invokeRpc(eq(uriPath), any(CompositeNode.class))).thenReturn(null);
post(uri, Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+JSON, jsonData);
verify(restconfService, times(1)).invokeRpc(eq(uriPath), any(CompositeNode.class));
when(restconfService.invokeRpc(eq(uriPath), any(CompositeNode.class))).thenReturn(null);
post(uri, Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+JSON, jsonData);
verify(restconfService, times(1)).invokeRpc(eq(uriPath), any(CompositeNode.class));
public void testGetConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
public void testGetConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
- String uri = createUri(uriPrefix, uriPath);
+ String uri = uriPrefix + uriPath;
when(restconfService.readConfigurationData(uriPath)).thenReturn(null);
get(uri, Draft02.MediaTypes.DATA+JSON);
verify(restconfService, times(1)).readConfigurationData(uriPath);
when(restconfService.readConfigurationData(uriPath)).thenReturn(null);
get(uri, Draft02.MediaTypes.DATA+JSON);
verify(restconfService, times(1)).readConfigurationData(uriPath);
public void testGetOperationalMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/operational/";
String uriPath = "ietf-interfaces:interfaces";
public void testGetOperationalMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/operational/";
String uriPath = "ietf-interfaces:interfaces";
- String uri = createUri(uriPrefix, uriPath);
+ String uri = uriPrefix + uriPath;
when(restconfService.readOperationalData(uriPath)).thenReturn(null);
get(uri, Draft02.MediaTypes.DATA+JSON);
verify(restconfService, times(1)).readOperationalData(uriPath);
when(restconfService.readOperationalData(uriPath)).thenReturn(null);
get(uri, Draft02.MediaTypes.DATA+JSON);
verify(restconfService, times(1)).readOperationalData(uriPath);
public void testPutConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
public void testPutConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
- String uri = createUri(uriPrefix, uriPath);
+ String uri = uriPrefix + uriPath;
when(restconfService.updateConfigurationData(eq(uriPath), any(CompositeNode.class))).thenReturn(null);
put(uri, null, Draft02.MediaTypes.DATA+JSON, jsonData);
verify(restconfService, times(1)).updateConfigurationData(eq(uriPath), any(CompositeNode.class));
when(restconfService.updateConfigurationData(eq(uriPath), any(CompositeNode.class))).thenReturn(null);
put(uri, null, Draft02.MediaTypes.DATA+JSON, jsonData);
verify(restconfService, times(1)).updateConfigurationData(eq(uriPath), any(CompositeNode.class));
public void testPostConfigWithPathMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
public void testPostConfigWithPathMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
- String uri = createUri(uriPrefix, uriPath);
+ String uri = uriPrefix + uriPath;
when(restconfService.createConfigurationData(eq(uriPath), any(CompositeNode.class))).thenReturn(null);
post(uri, null, Draft02.MediaTypes.DATA+JSON, jsonData);
verify(restconfService, times(1)).createConfigurationData(eq(uriPath), any(CompositeNode.class));
when(restconfService.createConfigurationData(eq(uriPath), any(CompositeNode.class))).thenReturn(null);
post(uri, null, Draft02.MediaTypes.DATA+JSON, jsonData);
verify(restconfService, times(1)).createConfigurationData(eq(uriPath), any(CompositeNode.class));
@Test
public void testPostConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
@Test
public void testPostConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
- String uri = createUri(uriPrefix, "");
+ String uri = uriPrefix;
when(restconfService.createConfigurationData(any(CompositeNode.class))).thenReturn(null);
post(uri, null, Draft02.MediaTypes.DATA+JSON, jsonData);
verify(restconfService, times(1)).createConfigurationData(any(CompositeNode.class));
when(restconfService.createConfigurationData(any(CompositeNode.class))).thenReturn(null);
post(uri, null, Draft02.MediaTypes.DATA+JSON, jsonData);
verify(restconfService, times(1)).createConfigurationData(any(CompositeNode.class));
public void testDeleteConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
public void testDeleteConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
String uriPath = "ietf-interfaces:interfaces";
- String uri = createUri(uriPrefix, uriPath);
+ String uri = uriPrefix + uriPath;
when(restconfService.deleteConfigurationData(eq(uriPath))).thenReturn(null);
target(uri).request("fooMediaType").delete();
verify(restconfService, times(1)).deleteConfigurationData(uriPath);
when(restconfService.deleteConfigurationData(eq(uriPath))).thenReturn(null);
target(uri).request("fooMediaType").delete();
verify(restconfService, times(1)).deleteConfigurationData(uriPath);
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.createUri;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
@Test
public void deleteConfigStatusCodes() throws UnsupportedEncodingException {
@Test
public void deleteConfigStatusCodes() throws UnsupportedEncodingException {
- String uri = createUri("/config/", "test-interface:interfaces");
+ String uri = "/config/test-interface:interfaces";
Future<RpcResult<TransactionStatus>> dummyFuture = createFuture(TransactionStatus.COMMITED);
when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
Response response = target(uri).request(MediaType.APPLICATION_XML).delete();
Future<RpcResult<TransactionStatus>> dummyFuture = createFuture(TransactionStatus.COMMITED);
when(brokerFacade.commitConfigurationDataDelete(any(InstanceIdentifier.class))).thenReturn(dummyFuture);
Response response = target(uri).request(MediaType.APPLICATION_XML).delete();
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.createUri;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
@Test
public void getOperationalStatusCodes() throws UnsupportedEncodingException {
mockReadOperationalDataMethod();
@Test
public void getOperationalStatusCodes() throws UnsupportedEncodingException {
mockReadOperationalDataMethod();
- String uri = createUri("/operational/", "ietf-interfaces:interfaces/interface/eth0");
+ String uri = "/operational/ietf-interfaces:interfaces/interface/eth0";
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
- uri = createUri("/operational/", "wrong-module:interfaces/interface/eth0");
+ uri = "/operational/wrong-module:interfaces/interface/eth0";
assertEquals(400, get(uri, MediaType.APPLICATION_XML));
}
assertEquals(400, get(uri, MediaType.APPLICATION_XML));
}
@Test
public void getConfigStatusCodes() throws UnsupportedEncodingException {
mockReadConfigurationDataMethod();
@Test
public void getConfigStatusCodes() throws UnsupportedEncodingException {
mockReadConfigurationDataMethod();
- String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
+ String uri = "/config/ietf-interfaces:interfaces/interface/eth0";
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
- uri = createUri("/config/", "wrong-module:interfaces/interface/eth0");
+ uri = "/config/wrong-module:interfaces/interface/eth0";
assertEquals(400, get(uri, MediaType.APPLICATION_XML));
}
assertEquals(400, get(uri, MediaType.APPLICATION_XML));
}
ControllerContext.getInstance().setMountService(mockMountService);
ControllerContext.getInstance().setMountService(mockMountService);
- String uri = createUri("/config/",
- "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/cont1");
+ String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/cont1";
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
- uri = createUri("/config/", "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1");
+ uri = "/config/ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1";
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
}
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
}
ControllerContext.getInstance().setMountService(mockMountService);
ControllerContext.getInstance().setMountService(mockMountService);
- String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/");
+ String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/";
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
}
assertEquals(200, get(uri, MediaType.APPLICATION_XML));
}
public void getModulesTest() throws UnsupportedEncodingException, FileNotFoundException {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
public void getModulesTest() throws UnsupportedEncodingException, FileNotFoundException {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
- String uri = createUri("/modules", "");
+ String uri = "/modules";
Response response = target(uri).request("application/yang.api+json").get();
validateModulesResponseJson(response);
Response response = target(uri).request("application/yang.api+json").get();
validateModulesResponseJson(response);
public void getModuleTest() throws FileNotFoundException, UnsupportedEncodingException {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
public void getModuleTest() throws FileNotFoundException, UnsupportedEncodingException {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
- String uri = createUri("/modules/module/module2/2014-01-02", "");
+ String uri = "/modules/module/module2/2014-01-02";
Response response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
Response response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
public void getOperationsTest() throws FileNotFoundException, UnsupportedEncodingException {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
public void getOperationsTest() throws FileNotFoundException, UnsupportedEncodingException {
ControllerContext.getInstance().setGlobalSchema(schemaContextModules);
- String uri = createUri("/operations", "");
+ String uri = "/operations";
Response response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
Response response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
controllerContext.setMountService(mockMountService);
controllerContext.setMountService(mockMountService);
- String uri = createUri("/operations/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/");
+ String uri = "/operations/ietf-interfaces:interfaces/interface/0/yang-ext:mount/";
Response response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
Response response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
controllerContext.setMountService(mockMountService);
controllerContext.setMountService(mockMountService);
- String uri = createUri("/modules/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/");
+ String uri = "/modules/ietf-interfaces:interfaces/interface/0/yang-ext:mount/";
Response response = target(uri).request("application/yang.api+json").get();
assertEquals(200, response.getStatus());
Response response = target(uri).request("application/yang.api+json").get();
assertEquals(200, response.getStatus());
controllerContext.setMountService(mockMountService);
controllerContext.setMountService(mockMountService);
- String uri = createUri("/modules/module/",
- "ietf-interfaces:interfaces/interface/0/yang-ext:mount/module1-behind-mount-point/2014-02-03");
+ String uri = "/modules/module/ietf-interfaces:interfaces/interface/0/yang-ext:mount/module1-behind-mount-point/2014-02-03";
Response response = target(uri).request("application/yang.api+json").get();
assertEquals(200, response.getStatus());
Response response = target(uri).request("application/yang.api+json").get();
assertEquals(200, response.getStatus());
*/
package org.opendaylight.controller.sal.restconf.impl.test;
*/
package org.opendaylight.controller.sal.restconf.impl.test;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URLEncoder;
-
-import com.google.common.base.Charsets;
-
public class RestOperationUtils {
public static final String JSON = "+json";
public class RestOperationUtils {
public static final String JSON = "+json";
private RestOperationUtils() {
}
private RestOperationUtils() {
}
-
- public static String createUri(String prefix, String encodedPart) throws UnsupportedEncodingException {
- return URI.create(prefix + URLEncoder.encode(encodedPart, Charsets.US_ASCII.name()).toString()).toASCIIString();
- }
public void postOperationsStatusCodes() throws UnsupportedEncodingException {
controllerContext.setSchemas(schemaContextTestModule);
mockInvokeRpc(cnSnDataOutput, true);
public void postOperationsStatusCodes() throws UnsupportedEncodingException {
controllerContext.setSchemas(schemaContextTestModule);
mockInvokeRpc(cnSnDataOutput, true);
- String uri = createUri("/operations/", "test-module:rpc-test");
+ String uri = "/operations/test-module:rpc-test";
assertEquals(200, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
mockInvokeRpc(null, true);
assertEquals(200, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
mockInvokeRpc(null, true);
mockInvokeRpc(null, false);
assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
mockInvokeRpc(null, false);
assertEquals(500, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
- uri = createUri("/operations/", "test-module:rpc-wrongtest");
+ uri = "/operations/test-module:rpc-wrongtest";
assertEquals(404, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
}
assertEquals(404, post(uri, MediaType.APPLICATION_XML, xmlDataRpcInput));
}
public void postConfigOnlyStatusCodes() throws UnsupportedEncodingException {
controllerContext.setSchemas(schemaContextYangsIetf);
mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
public void postConfigOnlyStatusCodes() throws UnsupportedEncodingException {
controllerContext.setSchemas(schemaContextYangsIetf);
mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
- String uri = createUri("/config", "");
+ String uri = "/config";
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
mockCommitConfigurationDataPostMethod(null);
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataAbsolutePath));
mockCommitConfigurationDataPostMethod(null);
public void postConfigStatusCodes() throws UnsupportedEncodingException {
controllerContext.setSchemas(schemaContextYangsIetf);
mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
public void postConfigStatusCodes() throws UnsupportedEncodingException {
controllerContext.setSchemas(schemaContextYangsIetf);
mockCommitConfigurationDataPostMethod(TransactionStatus.COMMITED);
- String uri = createUri("/config/", "ietf-interfaces:interfaces");
+ String uri = "/config/ietf-interfaces:interfaces";
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
mockCommitConfigurationDataPostMethod(null);
assertEquals(204, post(uri, MediaType.APPLICATION_XML, xmlDataInterfaceAbsolutePath));
mockCommitConfigurationDataPostMethod(null);
ControllerContext.getInstance().setMountService(mockMountService);
ControllerContext.getInstance().setMountService(mockMountService);
- String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/");
+ String uri = "/config/ietf-interfaces:interfaces/interface/0/";
assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData4));
assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData4));
- uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont");
+ uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont";
assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData3));
}
assertEquals(204, post(uri, Draft02.MediaTypes.DATA + XML, xmlData3));
}
ArgumentCaptor<InstanceIdentifier> instanceIdCaptor = ArgumentCaptor.forClass(InstanceIdentifier.class);
ArgumentCaptor<CompositeNode> compNodeCaptor = ArgumentCaptor.forClass(CompositeNode.class);
ArgumentCaptor<InstanceIdentifier> instanceIdCaptor = ArgumentCaptor.forClass(InstanceIdentifier.class);
ArgumentCaptor<CompositeNode> compNodeCaptor = ArgumentCaptor.forClass(CompositeNode.class);
- String URI_1 = createUri("/config", "");
+ String URI_1 = "/config";
assertEquals(204, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface));
verify(brokerFacade).commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
String identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces]";
assertEquals(identifier, instanceIdCaptor.getValue().getPath().toString());
assertEquals(204, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface));
verify(brokerFacade).commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
String identifier = "[(urn:ietf:params:xml:ns:yang:test-interface?revision=2014-07-01)interfaces]";
assertEquals(identifier, instanceIdCaptor.getValue().getPath().toString());
- String URI_2 = createUri("/config/", "test-interface:interfaces");
+ String URI_2 = "/config/test-interface:interfaces";
assertEquals(204, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData));
verify(brokerFacade, times(2))
.commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
assertEquals(204, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData));
verify(brokerFacade, times(2))
.commitConfigurationDataPost(instanceIdCaptor.capture(), compNodeCaptor.capture());
when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
.thenReturn(null);
when(brokerFacade.commitConfigurationDataPost(any(InstanceIdentifier.class), any(CompositeNode.class)))
.thenReturn(null);
- String URI_1 = createUri("/config", "");
+ String URI_1 = "/config";
assertEquals(202, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface));
assertEquals(202, post(URI_1, Draft02.MediaTypes.DATA + XML, xmlTestInterface));
- String URI_2 = createUri("/config/", "test-interface:interfaces");
+ String URI_2 = "/config/test-interface:interfaces";
assertEquals(202, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData));
}
assertEquals(202, post(URI_2, Draft02.MediaTypes.DATA + XML, xmlBlockData));
}
- private String createUri(String prefix, String encodedPart) throws UnsupportedEncodingException {
- return URI.create(prefix + URLEncoder.encode(encodedPart, Charsets.US_ASCII.name()).toString()).toASCIIString();
- }
-
private static void initMocking() {
controllerContext = ControllerContext.getInstance();
controllerContext.setSchemas(schemaContext);
private static void initMocking() {
controllerContext = ControllerContext.getInstance();
controllerContext.setSchemas(schemaContext);
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.createUri;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.IOException;
*/
@Test
public void putConfigStatusCodes() throws UnsupportedEncodingException {
*/
@Test
public void putConfigStatusCodes() throws UnsupportedEncodingException {
- String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/eth0");
+ String uri = "/config/ietf-interfaces:interfaces/interface/eth0";
mockCommitConfigurationDataPutMethod(TransactionStatus.COMMITED);
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData));
mockCommitConfigurationDataPutMethod(TransactionStatus.COMMITED);
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData));
ControllerContext.getInstance().setMountService(mockMountService);
ControllerContext.getInstance().setMountService(mockMountService);
- String uri = createUri("/config/", "ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont");
+ String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont";
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
- uri = createUri("/config/", "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont");
+ uri = "/config/ietf-interfaces:interfaces/yang-ext:mount/test-module:cont";
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
}
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
}
ControllerContext.getInstance().setMountService(mockMountService);
ControllerContext.getInstance().setMountService(mockMountService);
- String uri = createUri("/config/", "ietf-interfaces:interfaces/yang-ext:mount");
+ String uri = "/config/ietf-interfaces:interfaces/yang-ext:mount";
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData3));
}
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData3));
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
-import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.createUri;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;
@Test
public void testCallRpcCallGet() throws UnsupportedEncodingException, InterruptedException {
@Test
public void testCallRpcCallGet() throws UnsupportedEncodingException, InterruptedException {
- String uri = createUri("/operations/", "sal-remote:create-data-change-event-subscription");
+ String uri = "/operations/sal-remote:create-data-change-event-subscription";
Response responseWithStreamName = post(uri, MediaType.APPLICATION_XML, getRpcInput());
String xmlResponse = responseWithStreamName.readEntity(String.class);
assertNotNull(xmlResponse);
assertTrue(xmlResponse.contains("<stream-name>ietf-interfaces:interfaces/ietf-interfaces:interface/eth0</stream-name>"));
Response responseWithStreamName = post(uri, MediaType.APPLICATION_XML, getRpcInput());
String xmlResponse = responseWithStreamName.readEntity(String.class);
assertNotNull(xmlResponse);
assertTrue(xmlResponse.contains("<stream-name>ietf-interfaces:interfaces/ietf-interfaces:interface/eth0</stream-name>"));
- uri = createUri("/streams/stream/", "ietf-interfaces:interfaces/ietf-interfaces:interface/eth0");
+ uri = "/streams/stream/ietf-interfaces:interfaces/ietf-interfaces:interface/eth0";
Response responseWithRedirectionUri = get(uri, MediaType.APPLICATION_XML);
final URI websocketServerUri = responseWithRedirectionUri.getLocation();
assertNotNull(websocketServerUri);
Response responseWithRedirectionUri = get(uri, MediaType.APPLICATION_XML);
final URI websocketServerUri = responseWithRedirectionUri.getLocation();
assertNotNull(websocketServerUri);