if (nextEvent.isStartElement()) {
StartElement startElement = (StartElement) nextEvent;
if (startElement.getName().getLocalPart().equals("lf111")) {
- Iterator prefixes = startElement.getNamespaceContext().getPrefixes("augment:augment:module");
+ Iterator<?> prefixes = startElement.getNamespaceContext().getPrefixes("augment:augment:module");
while (prefixes.hasNext() && aaModulePrefix == null) {
String prefix = (String) prefixes.next();
if (nextEvent.isStartElement()) {
StartElement startElement = (StartElement) nextEvent;
if (startElement.getName().getLocalPart().equals("lf111")) {
- Iterator prefixes = startElement.getNamespaceContext().getPrefixes("augment:module:leaf:list");
+ Iterator<?> prefixes = startElement.getNamespaceContext().getPrefixes("augment:module:leaf:list");
while (prefixes.hasNext() && aModuleLfLstPrefix == null) {
String prefix = (String) prefixes.next();
MutableSimpleNode<?> lf111 = NodeFactory.createMutableSimpleNode(TestUtils.buildQName("lf111", "augment:augment:module", "2014-01-17"),
lst11, instanceIdentifier,null,null);
-
-
+
+
lst11.getChildren().add(lf111);
lst11.init();
cont1.getChildren().add(lst11);
cont1.init();
-
+
cont.getChildren().add(cont1);
cont.init();
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.opendaylight.yangtools.yang.data.api.CompositeNode;
public class MediaTypesTest extends JerseyTest {
-
+
private static RestconfService restconfService;
private static String jsonData;
private static String xmlData;
-
+
@BeforeClass
public static void init() throws IOException {
restconfService = mock(RestconfService.class);
InputStream xmlStream = RestconfImplTest.class.getResourceAsStream("/parts/ietf-interfaces_interfaces.xml");
xmlData = TestUtils.getDocumentInPrintableForm(TestUtils.loadDocumentFrom(xmlStream));
}
-
+
@Override
protected Application configure() {
/* enable/disable Jersey logs to console */
JsonToCompositeNodeProvider.INSTANCE);
return resourceConfig;
}
-
+
@Test
public void testPostOperationsWithInputDataMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/operations/";
verify(restconfService, times(5)).invokeRpc(eq(uriPath), any(CompositeNode.class));
post(uri, null, MediaType.TEXT_XML, xmlData);
verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(CompositeNode.class));
-
+
// negative tests
post(uri, MediaType.TEXT_PLAIN, MediaType.TEXT_XML, xmlData);
verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(CompositeNode.class));
post(uri, MediaType.TEXT_XML, MediaType.TEXT_PLAIN, xmlData);
verify(restconfService, times(6)).invokeRpc(eq(uriPath), any(CompositeNode.class));
}
-
+
@Test
public void testGetConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
verify(restconfService, times(4)).readConfigurationData(uriPath);
get(uri, MediaType.TEXT_XML);
verify(restconfService, times(5)).readConfigurationData(uriPath);
-
+
// negative tests
get(uri, MediaType.TEXT_PLAIN);
verify(restconfService, times(5)).readConfigurationData(uriPath);
}
-
+
@Test
public void testGetOperationalMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/operational/";
verify(restconfService, times(4)).readOperationalData(uriPath);
get(uri, MediaType.TEXT_XML);
verify(restconfService, times(5)).readOperationalData(uriPath);
-
+
// negative tests
get(uri, MediaType.TEXT_PLAIN);
verify(restconfService, times(5)).readOperationalData(uriPath);
}
-
+
@Test
public void testPutConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
put(uri, "fooMediaType", MediaType.TEXT_XML, xmlData);
verify(restconfService, times(6)).updateConfigurationData(eq(uriPath), any(CompositeNode.class));
}
-
+
@Test
public void testPostConfigWithPathMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
post(uri, "fooMediaType", MediaType.TEXT_XML, xmlData);
verify(restconfService, times(6)).createConfigurationData(eq(uriPath), any(CompositeNode.class));
}
-
+
@Test
public void testPostConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
post(uri, "fooMediaType", MediaType.TEXT_XML, xmlData);
verify(restconfService, times(6)).createConfigurationData(any(CompositeNode.class));
}
-
+
@Test
public void testDeleteConfigMediaTypes() throws UnsupportedEncodingException {
String uriPrefix = "/config/";
target(uri).request("fooMediaType").delete();
verify(restconfService, times(1)).deleteConfigurationData(uriPath);
}
-
+
private int get(String uri, String acceptMediaType) {
return target(uri).request(acceptMediaType).get().getStatus();
}
-
+
private int put(String uri, String acceptMediaType, String contentTypeMediaType, String data) {
if (acceptMediaType == null) {
return target(uri).request().put(Entity.entity(data, contentTypeMediaType)).getStatus();
}
return target(uri).request(acceptMediaType).put(Entity.entity(data, contentTypeMediaType)).getStatus();
}
-
+
private int post(String uri, String acceptMediaType, String contentTypeMediaType, String data) {
if (acceptMediaType == null) {
if (contentTypeMediaType == null || data == null) {
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
import javax.ws.rs.core.Application;
import javax.ws.rs.ext.ContextResolver;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlRootElement;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import org.opendaylight.controller.northbound.bundlescanner.IBundleScanService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+
/**
* Instance of javax.ws.rs.core.Application used to return the classes
* that will be instantiated for JAXRS processing. This hooks onto the
* bundle scanner service to provide JAXB classes to JAX-RS for prorcessing.
*/
-@SuppressWarnings("unchecked")
public class NorthboundApplication extends Application {
public static final String JAXRS_RESOURCES_MANIFEST_NAME = "Jaxrs-Resources";
public static final String JAXRS_EXCLUDES_MANIFEST_NAME = "Jaxrs-Exclude-Types";
}
private static final IBundleScanService lookupBundleScanner(BundleContext ctx) {
- ServiceReference svcRef = ctx.getServiceReference(IBundleScanService.class);
+ ServiceReference<?> svcRef = ctx.getServiceReference(IBundleScanService.class);
if (svcRef == null) {
throw new ServiceException("Unable to lookup IBundleScanService");
}