X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Ftest%2FMediaTypesTest.java;h=5a2c964b8b15a8eb46c6fea2cc46e77c350cdcdf;hp=bbedd2b42b5093dbf70e6011e94218689debbfd7;hb=4063669aa69554b0513aac11c7a4e20fa066fa06;hpb=15105ea803f97e89ae274148abd3208776319d2c diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java index bbedd2b42b..5a2c964b8b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java @@ -1,3 +1,10 @@ +/* + * 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; @@ -8,7 +15,6 @@ import static org.mockito.Mockito.verify; 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; @@ -17,6 +23,7 @@ import java.io.UnsupportedEncodingException; 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; @@ -63,11 +70,11 @@ public class MediaTypesTest extends 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)); @@ -89,7 +96,7 @@ public class MediaTypesTest extends JerseyTest { 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); @@ -111,7 +118,7 @@ public class MediaTypesTest extends JerseyTest { 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); @@ -133,7 +140,7 @@ public class MediaTypesTest extends JerseyTest { 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)); @@ -153,7 +160,7 @@ public class MediaTypesTest extends JerseyTest { 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)); @@ -172,7 +179,7 @@ public class MediaTypesTest extends JerseyTest { @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)); @@ -192,7 +199,7 @@ public class MediaTypesTest extends JerseyTest { 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);