+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.sal.restconf.impl.test;
import static org.mockito.Matchers.any;
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 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;
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.DATA+JSON, Draft02.MediaTypes.DATA+JSON, jsonData);
+ post(uri, Draft02.MediaTypes.OPERATION+JSON, Draft02.MediaTypes.OPERATION+JSON, jsonData);
verify(restconfService, times(1)).invokeRpc(eq(uriPath), any(CompositeNode.class));
- post(uri, Draft02.MediaTypes.DATA+XML, Draft02.MediaTypes.DATA+XML, xmlData);
+ post(uri, Draft02.MediaTypes.OPERATION+XML, Draft02.MediaTypes.OPERATION+XML, xmlData);
verify(restconfService, times(2)).invokeRpc(eq(uriPath), any(CompositeNode.class));
post(uri, MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON, jsonData);
verify(restconfService, times(3)).invokeRpc(eq(uriPath), any(CompositeNode.class));
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);
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);
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));
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));
@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));
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);