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 javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.opendaylight.controller.sal.core.api.mount.MountInstance;
import org.opendaylight.controller.sal.core.api.mount.MountService;
import org.opendaylight.controller.sal.rest.impl.JsonToCompositeNodeProvider;
+import org.opendaylight.controller.sal.rest.impl.RestconfDocumentedExceptionMapper;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
resourceConfig = resourceConfig.registerInstances(restconfImpl, StructuredDataToXmlProvider.INSTANCE,
StructuredDataToJsonProvider.INSTANCE, XmlToCompositeNodeProvider.INSTANCE,
JsonToCompositeNodeProvider.INSTANCE);
+ resourceConfig.registerClasses( RestconfDocumentedExceptionMapper.class );
return resourceConfig;
}
*/
@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.FAILED);
assertEquals(500, put(uri, MediaType.APPLICATION_XML, xmlData));
+
+ assertEquals( 400, put(uri, MediaType.APPLICATION_JSON, "" ));
+ }
+
+ @Test
+ public void putConfigStatusCodesEmptyBody() throws UnsupportedEncodingException {
+ String uri = "/config/ietf-interfaces:interfaces/interface/eth0";
+ Response resp = target(uri).request( MediaType.APPLICATION_JSON).put(Entity.entity( "", MediaType.APPLICATION_JSON));
+ assertEquals( 400, put(uri, MediaType.APPLICATION_JSON, "" ));
}
@Test
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));
- 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));
}
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));
}