Merge "BUG-1140: inPort disappeared from match"
authorEd Warnicke <eaw@cisco.com>
Wed, 18 Jun 2014 12:59:05 +0000 (12:59 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 18 Jun 2014 12:59:05 +0000 (12:59 +0000)
47 files changed:
opendaylight/connectionmanager/implementation/src/main/java/org/opendaylight/controller/connectionmanager/internal/ConnectionManager.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/rest/api/RestconfService.java
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/MediaTypesTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestconfDocumentedExceptionMapperTest.java
opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/nested-module.yang [new file with mode: 0644]
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/NetconfServerSessionListener.java
opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/SubtreeFilterTest.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/getConfig_reply_unfiltered.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/logback-test.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/post-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/pre-filter.xml [new file with mode: 0644]
opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/request.xml [new file with mode: 0644]
opendaylight/netconf/netconf-monitoring/src/main/java/org/opendaylight/controller/netconf/monitoring/osgi/NetconfMonitoringOperationService.java
opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/SSHTest.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/mapping/AbstractNetconfOperation.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlElement.java
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlNetconfConstants.java
opendaylight/sal/connection/implementation/src/main/java/org/opendaylight/controller/sal/connection/implementation/internal/ConnectionService.java

index ebc5692..d76c094 100644 (file)
@@ -261,7 +261,7 @@ public class ConnectionManager implements IConnectionManager,
             Map<ConnectionConstants, String> params) {
         if (connectionService == null)
             return null;
-        Node node = connectionService.connect(connectionIdentifier, params);
+        Node node = connectionService.connect(type, connectionIdentifier, params);
         AbstractScheme scheme = schemes.get(activeScheme);
         if (scheme != null && node != null)
             scheme.addNode(node);
index 4d9b198..056be72 100644 (file)
@@ -107,13 +107,15 @@ public interface RestconfService {
     @Path("/config/{identifier:.+}")
     @Produces({Draft02.MediaTypes.DATA+JSON,Draft02.MediaTypes.DATA+XML,
                MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_XML})
-    public StructuredData readConfigurationData(@Encoded @PathParam("identifier") String identifier);
+    public StructuredData readConfigurationData(@Encoded @PathParam("identifier") String identifier,
+                                                @Context UriInfo depth);
 
     @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(@Encoded @PathParam("identifier") String identifier);
+    public StructuredData readOperationalData(@Encoded @PathParam("identifier") String identifier,
+                                              @Context UriInfo depth);
 
     @PUT
     @Path("/config/{identifier:.+}")
index c0ce90e..7b6dcd5 100644 (file)
@@ -49,6 +49,7 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdent
 import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
+import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -71,6 +72,7 @@ import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
@@ -566,7 +568,7 @@ public class RestconfImpl implements RestconfService {
     }
 
     @Override
-    public StructuredData readConfigurationData(final String identifier) {
+    public StructuredData readConfigurationData(final String identifier, UriInfo info) {
         final InstanceIdWithSchemaNode iiWithData = this.controllerContext.toInstanceIdentifier(identifier);
         CompositeNode data = null;
         MountInstance mountPoint = iiWithData.getMountPoint();
@@ -577,11 +579,57 @@ public class RestconfImpl implements RestconfService {
             data = broker.readConfigurationData(iiWithData.getInstanceIdentifier());
         }
 
+        data = pruneDataAtDepth( data, parseDepthParameter( info ) );
         return new StructuredData(data, iiWithData.getSchemaNode(), iiWithData.getMountPoint());
     }
 
+    @SuppressWarnings("unchecked")
+    private <T extends Node<?>> T pruneDataAtDepth( T node, Integer depth ) {
+        if( depth == null ) {
+            return node;
+        }
+
+        if( node instanceof CompositeNode ) {
+            ImmutableList.Builder<Node<?>> newChildNodes = ImmutableList.<Node<?>> builder();
+            if( depth > 1 ) {
+                for( Node<?> childNode: ((CompositeNode)node).getValue() ) {
+                    newChildNodes.add( pruneDataAtDepth( childNode, depth - 1 ) );
+                }
+            }
+
+            return (T) ImmutableCompositeNode.create( node.getNodeType(), newChildNodes.build() );
+        }
+        else { // SimpleNode
+            return node;
+        }
+    }
+
+    private Integer parseDepthParameter( UriInfo info ) {
+        String param = info.getQueryParameters( false ).getFirst( "depth" );
+        if( Strings.isNullOrEmpty( param ) || "unbounded".equals( param ) ) {
+            return null;
+        }
+
+        try {
+            Integer depth = Integer.valueOf( param );
+            if( depth < 1 ) {
+                throw new RestconfDocumentedException( new RestconfError(
+                        ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE, "Invalid depth parameter: " + depth,
+                        null, "The depth parameter must be an integer > 1 or \"unbounded\"" ) );
+            }
+
+            return depth;
+        }
+        catch( NumberFormatException e ) {
+            throw new RestconfDocumentedException( new RestconfError(
+                    ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
+                    "Invalid depth parameter: " + e.getMessage(),
+                    null, "The depth parameter must be an integer > 1 or \"unbounded\"" ) );
+        }
+    }
+
     @Override
-    public StructuredData readOperationalData(final String identifier) {
+    public StructuredData readOperationalData(final String identifier, UriInfo info) {
         final InstanceIdWithSchemaNode iiWithData = this.controllerContext.toInstanceIdentifier(identifier);
         CompositeNode data = null;
         MountInstance mountPoint = iiWithData.getMountPoint();
@@ -592,6 +640,7 @@ public class RestconfImpl implements RestconfService {
             data = broker.readOperationalData(iiWithData.getInstanceIdentifier());
         }
 
+        data = pruneDataAtDepth( data, parseDepthParameter( info ) );
         return new StructuredData(data, iiWithData.getSchemaNode(), mountPoint);
     }
 
index 2037fd4..319603d 100644 (file)
@@ -23,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;
@@ -96,21 +97,21 @@ public class MediaTypesTest extends JerseyTest {
         String uriPrefix = "/config/";
         String uriPath = "ietf-interfaces:interfaces";
         String uri = uriPrefix + uriPath;
-        when(restconfService.readConfigurationData(uriPath)).thenReturn(null);
+        when(restconfService.readConfigurationData(eq(uriPath), any(UriInfo.class))).thenReturn(null);
         get(uri, Draft02.MediaTypes.DATA+JSON);
-        verify(restconfService, times(1)).readConfigurationData(uriPath);
+        verify(restconfService, times(1)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, Draft02.MediaTypes.DATA+XML);
-        verify(restconfService, times(2)).readConfigurationData(uriPath);
+        verify(restconfService, times(2)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_JSON);
-        verify(restconfService, times(3)).readConfigurationData(uriPath);
+        verify(restconfService, times(3)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_XML);
-        verify(restconfService, times(4)).readConfigurationData(uriPath);
+        verify(restconfService, times(4)).readConfigurationData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.TEXT_XML);
-        verify(restconfService, times(5)).readConfigurationData(uriPath);
+        verify(restconfService, times(5)).readConfigurationData(eq(uriPath), any(UriInfo.class));
 
         // negative tests
         get(uri, MediaType.TEXT_PLAIN);
-        verify(restconfService, times(5)).readConfigurationData(uriPath);
+        verify(restconfService, times(5)).readConfigurationData(eq(uriPath), any(UriInfo.class));
     }
 
     @Test
@@ -118,21 +119,21 @@ public class MediaTypesTest extends JerseyTest {
         String uriPrefix = "/operational/";
         String uriPath = "ietf-interfaces:interfaces";
         String uri = uriPrefix + uriPath;
-        when(restconfService.readOperationalData(uriPath)).thenReturn(null);
+        when(restconfService.readOperationalData(eq(uriPath), any(UriInfo.class))).thenReturn(null);
         get(uri, Draft02.MediaTypes.DATA+JSON);
-        verify(restconfService, times(1)).readOperationalData(uriPath);
+        verify(restconfService, times(1)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, Draft02.MediaTypes.DATA+XML);
-        verify(restconfService, times(2)).readOperationalData(uriPath);
+        verify(restconfService, times(2)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_JSON);
-        verify(restconfService, times(3)).readOperationalData(uriPath);
+        verify(restconfService, times(3)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.APPLICATION_XML);
-        verify(restconfService, times(4)).readOperationalData(uriPath);
+        verify(restconfService, times(4)).readOperationalData(eq(uriPath), any(UriInfo.class));
         get(uri, MediaType.TEXT_XML);
-        verify(restconfService, times(5)).readOperationalData(uriPath);
+        verify(restconfService, times(5)).readOperationalData(eq(uriPath), any(UriInfo.class));
 
         // negative tests
         get(uri, MediaType.TEXT_PLAIN);
-        verify(restconfService, times(5)).readOperationalData(uriPath);
+        verify(restconfService, times(5)).readOperationalData(eq(uriPath), any(UriInfo.class));
     }
 
     @Test
index 893622f..f0a232f 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.controller.sal.restconf.impl.test;
 
-import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.io.FileNotFoundException;
+import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -24,17 +26,23 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 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;
@@ -45,6 +53,7 @@ import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
 import org.opendaylight.controller.sal.restconf.impl.BrokerFacade;
 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
+import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -52,10 +61,28 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
+import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 
 public class RestGetOperationTest extends JerseyTest {
 
+    static class NodeData {
+        Object key;
+        Object data; // List for a CompositeNode, value Object for a SimpleNode
+
+        NodeData( Object key, Object data ) {
+            this.key = key;
+            this.data = data;
+        }
+    }
+
     private static BrokerFacade brokerFacade;
     private static RestconfImpl restconfImpl;
     private static SchemaContext schemaContextYangsIetf;
@@ -588,4 +615,314 @@ public class RestGetOperationTest extends JerseyTest {
         return null;
     }
 
+    @Test
+    public void getDataWithUriDepthParameterTest() throws UnsupportedEncodingException {
+
+        ControllerContext.getInstance().setGlobalSchema( schemaContextModules );
+
+        CompositeNode depth1Cont = toCompositeNode(
+            toCompositeNodeData( toNestedQName( "depth1-cont" ),
+                toCompositeNodeData( toNestedQName( "depth2-cont1" ),
+                    toCompositeNodeData( toNestedQName( "depth3-cont1" ),
+                        toCompositeNodeData( toNestedQName( "depth4-cont1" ),
+                            toSimpleNodeData( toNestedQName( "depth5-leaf1" ), "depth5-leaf1-value" )
+                        ),
+                        toSimpleNodeData( toNestedQName( "depth4-leaf1" ), "depth4-leaf1-value" )
+                    ),
+                    toSimpleNodeData( toNestedQName( "depth3-leaf1" ), "depth3-leaf1-value" )
+                ),
+                toCompositeNodeData( toNestedQName( "depth2-cont2" ),
+                    toCompositeNodeData( toNestedQName( "depth3-cont2" ),
+                        toCompositeNodeData( toNestedQName( "depth4-cont2" ),
+                            toSimpleNodeData( toNestedQName( "depth5-leaf2" ), "depth5-leaf2-value" )
+                        ),
+                        toSimpleNodeData( toNestedQName( "depth4-leaf2" ), "depth4-leaf2-value" )
+                    ),
+                    toSimpleNodeData( toNestedQName( "depth3-leaf2" ), "depth3-leaf2-value" )
+                ),
+                toSimpleNodeData( toNestedQName( "depth2-leaf1" ), "depth2-leaf1-value" )
+            ) );
+
+        when( brokerFacade.readConfigurationData( any( InstanceIdentifier.class ) ) )
+            .thenReturn( depth1Cont );
+
+        // Test config with depth 1
+
+        Response response = target( "/config/nested-module:depth1-cont" ).queryParam( "depth", "1" )
+                                .request( "application/xml" ).get();
+
+        verifyXMLResponse( response, expectEmptyContainer( "depth1-cont" ) );
+
+        // Test config with depth 2
+
+        response = target( "/config/nested-module:depth1-cont" ).queryParam( "depth", "2" )
+                       .request( "application/xml" ).get();
+
+//        String xml="<depth1-cont><depth2-cont1/><depth2-cont2/><depth2-leaf1>depth2-leaf1-value</depth2-leaf1></depth1-cont>";
+//        Response mr=mock(Response.class);
+//        when(mr.getEntity()).thenReturn( new java.io.StringBufferInputStream(xml) );
+
+        verifyXMLResponse( response,
+            expectContainer( "depth1-cont",
+                expectEmptyContainer( "depth2-cont1" ),
+                expectEmptyContainer( "depth2-cont2" ),
+                expectLeaf( "depth2-leaf1", "depth2-leaf1-value" )
+            ) );
+
+        // Test config with depth 3
+
+        response = target( "/config/nested-module:depth1-cont" ).queryParam( "depth", "3" )
+                       .request( "application/xml" ).get();
+
+        verifyXMLResponse( response,
+            expectContainer( "depth1-cont",
+                expectContainer( "depth2-cont1",
+                    expectEmptyContainer( "depth3-cont1" ),
+                    expectLeaf( "depth3-leaf1", "depth3-leaf1-value" )
+                ),
+                expectContainer( "depth2-cont2",
+                    expectEmptyContainer( "depth3-cont2" ),
+                    expectLeaf( "depth3-leaf2", "depth3-leaf2-value" )
+                ),
+                expectLeaf( "depth2-leaf1", "depth2-leaf1-value" )
+           ) );
+
+        // Test config with depth 4
+
+        response = target( "/config/nested-module:depth1-cont" ).queryParam( "depth", "4" )
+                      .request( "application/xml" ).get();
+
+        verifyXMLResponse( response,
+            expectContainer( "depth1-cont",
+                expectContainer( "depth2-cont1",
+                    expectContainer( "depth3-cont1",
+                        expectEmptyContainer( "depth4-cont1" ),
+                        expectLeaf( "depth4-leaf1", "depth4-leaf1-value" )
+                    ),
+                    expectLeaf( "depth3-leaf1", "depth3-leaf1-value" )
+                ),
+                expectContainer( "depth2-cont2",
+                    expectContainer( "depth3-cont2",
+                        expectEmptyContainer( "depth4-cont2" ),
+                        expectLeaf( "depth4-leaf2", "depth4-leaf2-value" )
+                    ),
+                    expectLeaf( "depth3-leaf2", "depth3-leaf2-value" )
+                ),
+                expectLeaf( "depth2-leaf1", "depth2-leaf1-value" )
+            ) );
+
+        // Test config with depth 5
+
+        response = target( "/config/nested-module:depth1-cont" ).queryParam( "depth", "5" )
+                       .request( "application/xml" ).get();
+
+        verifyXMLResponse( response,
+            expectContainer( "depth1-cont",
+                expectContainer( "depth2-cont1",
+                    expectContainer( "depth3-cont1",
+                        expectContainer( "depth4-cont1",
+                            expectLeaf( "depth5-leaf1", "depth5-leaf1-value" )
+                        ),
+                        expectLeaf( "depth4-leaf1", "depth4-leaf1-value" )
+                    ),
+                    expectLeaf( "depth3-leaf1", "depth3-leaf1-value" )
+                ),
+                expectContainer( "depth2-cont2",
+                    expectContainer( "depth3-cont2",
+                        expectContainer( "depth4-cont2",
+                            expectLeaf( "depth5-leaf2", "depth5-leaf2-value" )
+                        ),
+                        expectLeaf( "depth4-leaf2", "depth4-leaf2-value" )
+                    ),
+                    expectLeaf( "depth3-leaf2", "depth3-leaf2-value" )
+                ),
+                expectLeaf( "depth2-leaf1", "depth2-leaf1-value" )
+            ) );
+
+        // Test config with depth unbounded
+
+        response = target( "/config/nested-module:depth1-cont" ).queryParam( "depth", "unbounded" )
+                       .request( "application/xml" ).get();
+
+        verifyXMLResponse( response,
+            expectContainer( "depth1-cont",
+                expectContainer( "depth2-cont1",
+                    expectContainer( "depth3-cont1",
+                        expectContainer( "depth4-cont1",
+                            expectLeaf( "depth5-leaf1", "depth5-leaf1-value" )
+                        ),
+                        expectLeaf( "depth4-leaf1", "depth4-leaf1-value" )
+                    ),
+                    expectLeaf( "depth3-leaf1", "depth3-leaf1-value" )
+                ),
+                expectContainer( "depth2-cont2",
+                    expectContainer( "depth3-cont2",
+                        expectContainer( "depth4-cont2",
+                            expectLeaf( "depth5-leaf2", "depth5-leaf2-value" )
+                        ),
+                        expectLeaf( "depth4-leaf2", "depth4-leaf2-value" )
+                    ),
+                    expectLeaf( "depth3-leaf2", "depth3-leaf2-value" )
+                ),
+                expectLeaf( "depth2-leaf1", "depth2-leaf1-value" )
+            ) );
+
+        // Test operational
+
+        CompositeNode depth2Cont1 = toCompositeNode(
+            toCompositeNodeData( toNestedQName( "depth2-cont1" ),
+                toCompositeNodeData( toNestedQName( "depth3-cont1" ),
+                    toCompositeNodeData( toNestedQName( "depth4-cont1" ),
+                        toSimpleNodeData( toNestedQName( "depth5-leaf1" ), "depth5-leaf1-value" )
+                    ),
+                    toSimpleNodeData( toNestedQName( "depth4-leaf1" ), "depth4-leaf1-value" )
+                ),
+                toSimpleNodeData( toNestedQName( "depth3-leaf1" ), "depth3-leaf1-value" )
+            ) );
+
+        when( brokerFacade.readOperationalData( any( InstanceIdentifier.class ) ) )
+             .thenReturn( depth2Cont1 );
+
+        response = target( "/operational/nested-module:depth1-cont/depth2-cont1" )
+                       .queryParam( "depth", "3" ).request( "application/xml" ).get();
+
+        verifyXMLResponse( response,
+            expectContainer( "depth2-cont1",
+                expectContainer( "depth3-cont1",
+                    expectEmptyContainer( "depth4-cont1" ),
+                    expectLeaf( "depth4-leaf1", "depth4-leaf1-value" )
+                ),
+                expectLeaf( "depth3-leaf1", "depth3-leaf1-value" )
+            ) );
+    }
+
+    @Test
+    public void getDataWithInvalidDepthParameterTest() {
+
+        ControllerContext.getInstance().setGlobalSchema( schemaContextModules );
+
+        final MultivaluedMap<String,String> paramMap = new MultivaluedHashMap<>();
+        paramMap.putSingle( "depth", "1o" );
+        UriInfo mockInfo = mock( UriInfo.class );
+        when( mockInfo.getQueryParameters( false ) ).thenAnswer(
+            new Answer<MultivaluedMap<String,String>>() {
+                @Override
+                public MultivaluedMap<String, String> answer( InvocationOnMock invocation ) {
+                    return paramMap;
+                }
+            } );
+
+        getDataWithInvalidDepthParameterTest( mockInfo );
+
+        paramMap.putSingle( "depth", "0" );
+        getDataWithInvalidDepthParameterTest( mockInfo );
+
+        paramMap.putSingle( "depth", "-1" );
+        getDataWithInvalidDepthParameterTest( mockInfo );
+    }
+
+    private void getDataWithInvalidDepthParameterTest( UriInfo uriInfo ) {
+        try {
+            restconfImpl.readConfigurationData( "nested-module:depth1-cont", uriInfo );
+            fail( "Expected RestconfDocumentedException" );
+        }
+        catch( RestconfDocumentedException e ) {
+            assertTrue( "Unexpected error message: " + e.getErrors().get( 0 ).getErrorMessage(),
+                        e.getErrors().get( 0 ).getErrorMessage().contains( "depth" ) );
+        }
+    }
+
+    private void verifyXMLResponse( Response response, NodeData nodeData ) {
+
+        Document doc = TestUtils.loadDocumentFrom( (InputStream) response.getEntity() );
+        assertNotNull( "Could not parse XML document", doc );
+
+        //System.out.println(TestUtils.getDocumentInPrintableForm( doc ));
+
+        verifyContainerElement( doc.getDocumentElement(), nodeData );
+    }
+
+    @SuppressWarnings("unchecked")
+    private void verifyContainerElement( Element element, NodeData nodeData ) {
+
+        assertEquals( "Element local name", nodeData.key, element.getNodeName() );
+
+        NodeList childNodes = element.getChildNodes();
+        if( nodeData.data == null ) { // empty container
+            assertTrue( "Expected no child elements for \"" + element.getNodeName() + "\"",
+                        childNodes.getLength() == 0 );
+            return;
+        }
+
+        Map<String,NodeData> expChildMap = Maps.newHashMap();
+        for( NodeData expChild: (List<NodeData>)nodeData.data ) {
+            expChildMap.put( expChild.key.toString(), expChild );
+        }
+
+        for( int i = 0; i < childNodes.getLength(); i++ ) {
+            org.w3c.dom.Node actualChild = childNodes.item( i );
+            if( !( actualChild instanceof Element ) ) {
+                continue;
+            }
+
+            Element actualElement = (Element)actualChild;
+            NodeData expChild = expChildMap.remove( actualElement.getNodeName() );
+            assertNotNull( "Unexpected child element for parent \"" + element.getNodeName() +
+                           "\": " + actualElement.getNodeName(), expChild );
+
+            if( expChild.data == null || expChild.data instanceof List ) {
+                verifyContainerElement( actualElement, expChild );
+            }
+            else {
+                assertEquals( "Text content for element: " + actualElement.getNodeName(),
+                              expChild.data, actualElement.getTextContent() );
+            }
+        }
+
+        if( !expChildMap.isEmpty() ) {
+            fail( "Missing elements for parent \"" + element.getNodeName() +
+                  "\": " + expChildMap.keySet() );
+        }
+    }
+
+    private NodeData expectContainer( String name, NodeData... childData ) {
+        return new NodeData( name, Lists.newArrayList( childData ) );
+    }
+
+    private NodeData expectEmptyContainer( String name ) {
+        return new NodeData( name, null );
+    }
+
+    private NodeData expectLeaf( String name, Object value ) {
+        return new NodeData( name, value );
+    }
+
+    private QName toNestedQName( String localName ) {
+        return QName.create( "urn:nested:module", "2014-06-3", localName );
+    }
+
+    @SuppressWarnings("unchecked")
+    private CompositeNode toCompositeNode( NodeData nodeData ) {
+        CompositeNodeBuilder<ImmutableCompositeNode> builder = ImmutableCompositeNode.builder();
+        builder.setQName( (QName) nodeData.key );
+
+        for( NodeData child: (List<NodeData>)nodeData.data ) {
+            if( child.data instanceof List ) {
+                builder.add( toCompositeNode( child ) );
+            }
+            else {
+                builder.addLeaf( (QName) child.key, child.data );
+            }
+        }
+
+        return builder.toInstance();
+    }
+
+    private NodeData toCompositeNodeData( QName key, NodeData... childData ) {
+        return new NodeData( key, Lists.newArrayList( childData ) );
+    }
+
+    private NodeData toSimpleNodeData( QName key, Object value ) {
+        return new NodeData( key, value );
+    }
 }
index 3f984c2..e146cf8 100644 (file)
@@ -34,6 +34,7 @@ import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.xpath.XPath;
@@ -220,7 +221,7 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest {
 
     void stageMockEx( final RestconfDocumentedException ex ) {
         reset( mockRestConf );
-        when( mockRestConf.readOperationalData( any( String.class ) ) ).thenThrow( ex );
+        when( mockRestConf.readOperationalData( any( String.class ), any( UriInfo.class ) ) ).thenThrow( ex );
     }
 
     void testJsonResponse( final RestconfDocumentedException ex, final Status expStatus, final ErrorType expErrorType,
@@ -776,8 +777,8 @@ public class RestconfDocumentedExceptionMapperTest extends JerseyTest {
 
         // The StructuredDataToJsonProvider should throw a RestconfDocumentedException with no data
 
-        when( mockRestConf.readOperationalData( any( String.class ) ) )
-        .thenReturn( new StructuredData( null, null, null ) );
+        when( mockRestConf.readOperationalData( any( String.class ), any( UriInfo.class ) ) )
+            .thenReturn( new StructuredData( null, null, null ) );
 
         Response resp = target("/operational/foo").request( MediaType.APPLICATION_JSON ).get();
 
diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/nested-module.yang b/opendaylight/md-sal/sal-rest-connector/src/test/resources/modules/nested-module.yang
new file mode 100644 (file)
index 0000000..590743c
--- /dev/null
@@ -0,0 +1,47 @@
+module nested-module {
+    namespace "urn:nested:module";
+    prefix "nested";
+    revision "2014-06-3";
+
+    container depth1-cont {
+        container depth2-cont1 {
+            container depth3-cont1 {
+                container depth4-cont1 {
+                    leaf depth5-leaf1 {
+                        type string;
+                    }
+                }
+                
+                leaf depth4-leaf1 {
+                    type string;
+                }
+            }
+            
+            leaf depth3-leaf1 {
+                type string;
+            }
+        }
+        
+        container depth2-cont2 {
+            container depth3-cont2 {
+                container depth4-cont2 {
+                    leaf depth5-leaf2 {
+                        type string;
+                    }
+                }
+                
+                leaf depth4-leaf2 {
+                    type string;
+                }
+            }
+            
+            leaf depth3-leaf2 {
+                type string;
+            }
+        }
+        
+        leaf depth2-leaf1 {
+            type string;
+        }
+    }
+} 
\ No newline at end of file
index 48b4bbc..867ad60 100644 (file)
@@ -103,10 +103,7 @@ public class Get extends AbstractConfigNetconfOperation {
         xml.checkName(XmlNetconfConstants.GET);
         xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
 
-        // Filter option - unsupported
-        if (xml.getChildElements(XmlNetconfConstants.FILTER).size() != 0){
-            throw new UnsupportedOperationException("Unsupported option " + XmlNetconfConstants.FILTER + " for " + XmlNetconfConstants.GET);
-        }
+        // Filter option: ignore for now, TODO only load modules specified by the filter
     }
 
     @Override
index 03e0176..bc059d3 100644 (file)
@@ -9,6 +9,8 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig;
 
 import com.google.common.base.Optional;
+import java.util.Set;
+import javax.management.ObjectName;
 import org.opendaylight.controller.config.util.ConfigRegistryClient;
 import org.opendaylight.controller.config.util.ConfigTransactionClient;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
@@ -30,9 +32,6 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import javax.management.ObjectName;
-import java.util.Set;
-
 public class GetConfig extends AbstractConfigNetconfOperation {
 
     public static final String GET_CONFIG = "get-config";
@@ -65,11 +64,7 @@ public class GetConfig extends AbstractConfigNetconfOperation {
         logger.debug("Setting source datastore to '{}'", sourceParsed);
         Datastore sourceDatastore = Datastore.valueOf(sourceParsed);
 
-        // Filter option - unsupported
-        if (xml.getChildElements(XmlNetconfConstants.FILTER).size() != 0){
-            throw new UnsupportedOperationException("Unsupported option " + XmlNetconfConstants.FILTER + " for "
-                    + GET_CONFIG);
-        }
+        // Filter option: ignore for now, TODO only load modules specified by the filter
 
         return sourceDatastore;
 
index 75be1f8..54ad18a 100644 (file)
@@ -13,10 +13,10 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
 import org.opendaylight.controller.netconf.api.NetconfSessionListener;
 import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
 import org.opendaylight.controller.netconf.impl.mapping.operations.DefaultCloseSession;
+import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter;
 import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
 import org.opendaylight.controller.netconf.util.messages.SendErrorExceptionUtil;
 import org.opendaylight.controller.netconf.util.xml.XmlElement;
@@ -98,7 +98,7 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
             session.onIncommingRpcFail();
             throw new IllegalStateException("Unable to process incoming message " + netconfMessage, e);
         } catch (NetconfDocumentedException e) {
-            logger.trace("Error occured while processing mesage {}",e);
+            logger.trace("Error occurred while processing message",e);
             session.onOutgoingRpcError();
             session.onIncommingRpcFail();
             SendErrorExceptionUtil.sendErrorMessage(session, e, netconfMessage);
@@ -111,6 +111,8 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
         logger.info("Session {} closed successfully", session.getSessionId());
     }
 
+
+
     private NetconfMessage processDocument(final NetconfMessage netconfMessage, NetconfServerSession session)
             throws NetconfDocumentedException {
 
@@ -123,6 +125,8 @@ public class NetconfServerSessionListener implements NetconfSessionListener<Netc
 
             Document rpcReply = operationRouter.onNetconfMessage(incomingDocument, session);
 
+            rpcReply = SubtreeFilter.applySubtreeFilter(incomingDocument, rpcReply);
+
             session.onIncommingRpcSuccess();
 
             responseDocument.appendChild(responseDocument.importNode(rpcReply.getDocumentElement(), true));
diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/SubtreeFilter.java
new file mode 100644 (file)
index 0000000..bfc7df5
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * 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.netconf.impl;
+
+import com.google.common.base.Optional;
+import java.io.IOException;
+import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.util.mapping.AbstractNetconfOperation.OperationNameAndNamespace;
+import org.opendaylight.controller.netconf.util.xml.XmlElement;
+import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * See <a href="http://tools.ietf.org/html/rfc6241#section-6">rfc6241</a> for details.
+ */
+public class SubtreeFilter {
+    private static final Logger logger = LoggerFactory.getLogger(SubtreeFilter.class);
+
+    static Document applySubtreeFilter(Document requestDocument, Document rpcReply) throws NetconfDocumentedException {
+        // FIXME: rpcReply document must be reread otherwise some nodes do not inherit namespaces. (services/service)
+        try {
+            rpcReply = XmlUtil.readXmlToDocument(XmlUtil.toString(rpcReply, true));
+        } catch (SAXException | IOException e) {
+            logger.error("Cannot transform document", e);
+            throw new NetconfDocumentedException("Cannot transform document");
+        }
+
+        OperationNameAndNamespace operationNameAndNamespace = new OperationNameAndNamespace(requestDocument);
+        if (XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0.equals(operationNameAndNamespace.getNamespace()) &&
+                XmlNetconfConstants.GET.equals(operationNameAndNamespace.getOperationName()) ||
+                XmlNetconfConstants.GET_CONFIG.equals(operationNameAndNamespace.getOperationName())) {
+            // process subtree filtering here, in case registered netconf operations do
+            // not implement filtering.
+            Optional<XmlElement> maybeFilter = operationNameAndNamespace.getOperationElement().getOnlyChildElementOptionally(
+                    XmlNetconfConstants.FILTER, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0);
+            if (maybeFilter.isPresent() && (
+                    "subtree".equals(maybeFilter.get().getAttribute("type"))||
+                            "subtree".equals(maybeFilter.get().getAttribute("type", XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))
+            )) {
+
+
+                // do
+                return filtered(maybeFilter.get(), rpcReply);
+            }
+        }
+        return rpcReply; // return identical document
+    }
+
+    private static Document filtered(XmlElement filter, Document originalReplyDocument) throws NetconfDocumentedException {
+        Document result = XmlUtil.newDocument();
+        // even if filter is empty, copy /rpc/data
+        Element rpcReply = originalReplyDocument.getDocumentElement();
+        Node rpcReplyDst = result.importNode(rpcReply, false);
+        result.appendChild(rpcReplyDst);
+        XmlElement dataSrc = XmlElement.fromDomElement(rpcReply).getOnlyChildElement("data", XmlNetconfConstants.RFC4741_TARGET_NAMESPACE);
+        Element dataDst = (Element) result.importNode(dataSrc.getDomElement(), false);
+        rpcReplyDst.appendChild(dataDst);
+        addSubtree(filter, dataSrc, XmlElement.fromDomElement(dataDst));
+
+        return result;
+    }
+
+    private static void addSubtree(XmlElement filter, XmlElement src, XmlElement dst) {
+        for (XmlElement srcChild : src.getChildElements()) {
+            for (XmlElement filterChild : filter.getChildElements()) {
+                addSubtree2(filterChild, srcChild, dst);
+            }
+        }
+    }
+
+    private static MatchingResult addSubtree2(XmlElement filter, XmlElement src, XmlElement dstParent) {
+        Document document = dstParent.getDomElement().getOwnerDocument();
+        MatchingResult matches = matches(src, filter);
+        if (matches != MatchingResult.NO_MATCH && matches != MatchingResult.CONTENT_MISMATCH) {
+            // copy srcChild to dst
+            boolean filterHasChildren = filter.getChildElements().isEmpty() == false;
+            // copy to depth if this is leaf of filter tree
+            Element copied = (Element) document.importNode(src.getDomElement(), filterHasChildren == false);
+            boolean shouldAppend = filterHasChildren == false;
+            if (filterHasChildren) { // this implies TAG_MATCH
+                // do the same recursively
+                int numberOfTextMatchingChildren = 0;
+                for (XmlElement srcChild : src.getChildElements()) {
+                    for (XmlElement filterChild : filter.getChildElements()) {
+                        MatchingResult childMatch = addSubtree2(filterChild, srcChild, XmlElement.fromDomElement(copied));
+                        if (childMatch == MatchingResult.CONTENT_MISMATCH) {
+                            return MatchingResult.NO_MATCH;
+                        }
+                        if (childMatch == MatchingResult.CONTENT_MATCH) {
+                            numberOfTextMatchingChildren++;
+                        }
+                        shouldAppend |= childMatch != MatchingResult.NO_MATCH;
+                    }
+                }
+                // if only text matching child filters are specified..
+                if (numberOfTextMatchingChildren == filter.getChildElements().size()) {
+                    // force all children to be added (to depth). This is done by copying parent node to depth.
+                    // implies shouldAppend == true
+                    copied = (Element) document.importNode(src.getDomElement(), true);
+                }
+            }
+            if (shouldAppend) {
+                dstParent.getDomElement().appendChild(copied);
+            }
+        }
+        return matches;
+    }
+
+    /**
+     * Shallow compare src node to filter: tag name and namespace must match.
+     * If filter node has no children and has text content, it also must match.
+     */
+    private static MatchingResult matches(XmlElement src, XmlElement filter) {
+        boolean tagMatch = src.getName().equals(filter.getName()) &&
+                src.getNamespaceOptionally().equals(filter.getNamespaceOptionally());
+        MatchingResult result = null;
+        if (tagMatch) {
+            // match text content
+            Optional<String> maybeText = filter.getOnlyTextContentOptionally();
+            if (maybeText.isPresent()) {
+                if (maybeText.equals(src.getOnlyTextContentOptionally())) {
+                    result = MatchingResult.CONTENT_MATCH;
+                } else {
+                    result = MatchingResult.CONTENT_MISMATCH;
+                }
+            }
+            // match attributes, combination of content and tag is not supported
+            if (result == null) {
+                for (Attr attr : filter.getAttributes().values()) {
+                    // ignore namespace declarations
+                    if (XmlUtil.XMLNS_URI.equals(attr.getNamespaceURI()) == false ) {
+                        // find attr with matching localName(),  namespaceURI(),  == value() in src
+                        String found = src.getAttribute(attr.getLocalName(), attr.getNamespaceURI());
+                        if (attr.getValue().equals(found) && result != MatchingResult.NO_MATCH) {
+                            result = MatchingResult.TAG_MATCH;
+                        } else {
+                            result = MatchingResult.NO_MATCH;
+                        }
+                    }
+                }
+            }
+            if (result == null) {
+                result = MatchingResult.TAG_MATCH;
+            }
+        }
+        if (result == null) {
+            result = MatchingResult.NO_MATCH;
+        }
+        logger.debug("Matching {} to {} resulted in {}", src, filter, tagMatch);
+        return result;
+    }
+
+    enum MatchingResult {
+        NO_MATCH, TAG_MATCH, CONTENT_MATCH, CONTENT_MISMATCH
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/SubtreeFilterTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/SubtreeFilterTest.java
new file mode 100644 (file)
index 0000000..b118343
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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.netconf.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+@RunWith(value = Parameterized.class)
+public class SubtreeFilterTest {
+    private static final Logger logger = LoggerFactory.getLogger(SubtreeFilterTest.class);
+
+    private final int directoryIndex;
+
+    @Parameters
+    public static Collection<Object[]> data() {
+        List<Object[]> result = new ArrayList<>();
+        for (int i = 0; i <= 8; i++) {
+            result.add(new Object[]{i});
+        }
+        return result;
+    }
+
+    public SubtreeFilterTest(int directoryIndex) {
+        this.directoryIndex = directoryIndex;
+    }
+
+    @Before
+    public void setUp(){
+        XMLUnit.setIgnoreWhitespace(true);
+    }
+
+    @Test
+    public void test() throws Exception {
+        Document requestDocument = getDocument("request.xml");
+        Document preFilterDocument = getDocument("pre-filter.xml");
+        Document postFilterDocument = getDocument("post-filter.xml");
+        Document actualPostFilterDocument = SubtreeFilter.applySubtreeFilter(requestDocument, preFilterDocument);
+        logger.info("Actual document: {}", XmlUtil.toString(actualPostFilterDocument));
+        Diff diff = XMLUnit.compareXML(postFilterDocument, actualPostFilterDocument);
+        assertTrue(diff.toString(), diff.similar());
+
+    }
+
+    public Document getDocument(String fileName) throws SAXException, IOException {
+        return XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/subtree/" + directoryIndex + "/" +
+                fileName));
+    }
+}
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/getConfig_reply_unfiltered.xml b/opendaylight/netconf/netconf-impl/src/test/resources/getConfig_reply_unfiltered.xml
new file mode 100644 (file)
index 0000000..3c2765a
--- /dev/null
@@ -0,0 +1,439 @@
+<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-2">
+  <data>
+    <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">
+          prefix:toaster-provider-impl
+        </type>
+        <name>toaster-provider-impl</name>
+        <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-notification-service
+          </type>
+          <name>binding-notification-broker</name>
+        </notification-service>
+        <rpc-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-rpc-registry
+          </type>
+          <name>binding-rpc-broker</name>
+        </rpc-registry>
+        <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-data-broker
+          </type>
+          <name>binding-data-broker</name>
+        </data-broker>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          prefix:sal-netconf-connector
+        </type>
+        <name>controller-config</name>
+        <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">1830</port>
+        <connection-timeout-millis xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          20000
+        </connection-timeout-millis>
+        <between-attempts-timeout-millis
+                xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">2000
+        </between-attempts-timeout-millis>
+        <sleep-factor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">1.5</sleep-factor>
+        <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</password>
+        <dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
+            prefix:dom-broker-osgi-registry
+          </type>
+          <name>dom-broker</name>
+        </dom-registry>
+        <client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">
+            prefix:netconf-client-dispatcher
+          </type>
+          <name>global-netconf-dispatcher</name>
+        </client-dispatcher>
+        <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</username>
+        <address xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">127.0.0.1</address>
+        <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
+          <name>global-netconf-processing-executor</name>
+        </processing-executor>
+        <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>
+        <binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-broker-osgi-registry
+          </type>
+          <name>binding-osgi-broker</name>
+        </binding-registry>
+        <max-connection-attempts xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">0
+        </max-connection-attempts>
+        <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
+          <name>global-event-executor</name>
+        </event-executor>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+          prefix:netconf-client-dispatcher
+        </type>
+        <name>global-netconf-dispatcher</name>
+        <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+          <name>global-worker-group</name>
+        </worker-thread-group>
+        <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
+          <name>global-timer</name>
+        </timer>
+        <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+          <name>global-boss-group</name>
+        </boss-thread-group>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:logback:config">prefix:logback</type>
+        <name>singleton</name>
+        <console-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <threshold-filter>ERROR</threshold-filter>
+          <name>STDOUT</name>
+          <encoder-pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</encoder-pattern>
+        </console-appenders>
+        <file-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <append>true</append>
+          <file-name>logs/audit.log</file-name>
+          <name>audit-file</name>
+          <encoder-pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} %msg %n</encoder-pattern>
+        </file-appenders>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>WARN</level>
+          <logger-name>org.opendaylight.controller.logging.bridge</logger-name>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>INFO</level>
+          <logger-name>audit</logger-name>
+          <appenders>audit-file</appenders>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>ERROR</level>
+          <logger-name>ROOT</logger-name>
+          <appenders>STDOUT</appenders>
+          <appenders>opendaylight.log</appenders>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>INFO</level>
+          <logger-name>org.opendaylight</logger-name>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>INFO</level>
+          <logger-name>org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort</logger-name>
+          <appenders>opendaylight.log</appenders>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>TRACE</level>
+          <logger-name>org.opendaylight.controller.netconf</logger-name>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>WARN</level>
+          <logger-name>io.netty</logger-name>
+        </loggers>
+        <rolling-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <append>true</append>
+          <max-file-size>10MB</max-file-size>
+          <file-name>logs/opendaylight.log</file-name>
+          <name>opendaylight.log</name>
+          <file-name-pattern>logs/opendaylight.%d.log.zip</file-name-pattern>
+          <encoder-pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{35} - %msg%n</encoder-pattern>
+          <clean-history-on-start>false</clean-history-on-start>
+          <max-history>1</max-history>
+          <rolling-policy-type>TimeBasedRollingPolicy</rolling-policy-type>
+        </rolling-appenders>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:shutdown:impl">prefix:shutdown</type>
+        <name>shutdown</name>
+        <secret xmlns="urn:opendaylight:params:xml:ns:yang:controller:shutdown:impl"/>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:timer">
+          prefix:netty-hashed-wheel-timer
+        </type>
+        <name>global-timer</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">
+          prefix:netty-threadgroup-fixed
+        </type>
+        <name>global-boss-group</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">
+          prefix:netty-threadgroup-fixed
+        </type>
+        <name>global-worker-group</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+          prefix:schema-service-singleton
+        </type>
+        <name>yang-schema-service</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl
+        </type>
+        <name>inmemory-dom-broker</name>
+        <async-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-async-data-broker
+          </type>
+          <name>inmemory-data-broker</name>
+        </async-data-broker>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+          prefix:dom-inmemory-data-broker
+        </type>
+        <name>inmemory-data-broker</name>
+        <schema-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:schema-service</type>
+          <name>yang-schema-service</name>
+        </schema-service>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">
+          prefix:threadpool-flexible
+        </type>
+        <name>global-netconf-processing-executor</name>
+        <threadFactory xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+          <name>global-netconf-processing-executor-threadfactory</name>
+        </threadFactory>
+        <minThreadCount xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">1
+        </minThreadCount>
+        <max-thread-count xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">4
+        </max-thread-count>
+        <keepAliveMillis xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">600000
+        </keepAliveMillis>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor">
+          prefix:netty-global-event-executor
+        </type>
+        <name>singleton</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          prefix:binding-broker-impl
+        </type>
+        <name>binding-broker-impl</name>
+        <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-notification-service
+          </type>
+          <name>binding-notification-broker</name>
+        </notification-service>
+        <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-data-broker
+          </type>
+          <name>binding-data-broker</name>
+        </data-broker>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          prefix:runtime-generated-mapping
+        </type>
+        <name>runtime-mapping-singleton</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          prefix:binding-notification-broker
+        </type>
+        <name>binding-notification-broker</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          prefix:binding-data-compatible-broker
+        </type>
+        <name>inmemory-binding-data-broker</name>
+        <dom-async-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
+            prefix:dom-broker-osgi-registry
+          </type>
+          <name>dom-broker</name>
+        </dom-async-broker>
+        <binding-mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+            prefix:binding-dom-mapping-service
+          </type>
+          <name>runtime-mapping-singleton</name>
+        </binding-mapping-service>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">
+          prefix:threadfactory-naming
+        </type>
+        <name>global-netconf-processing-executor-threadfactory</name>
+        <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">
+          remote-connector-processing-executor
+        </name-prefix>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">
+          prefix:kitchen-service-impl
+        </type>
+        <name>kitchen-service-impl</name>
+        <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-notification-service
+          </type>
+          <name>binding-notification-broker</name>
+        </notification-service>
+        <rpc-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+            prefix:binding-rpc-registry
+          </type>
+          <name>binding-rpc-broker</name>
+        </rpc-registry>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
+          prefix:remote-zeromq-rpc-server
+        </type>
+        <name>remoter</name>
+        <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port>
+        <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">
+            prefix:dom-broker-osgi-registry
+          </type>
+          <name>dom-broker</name>
+        </dom-broker>
+      </module>
+    </modules>
+    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:schema-service</type>
+        <instance>
+          <name>yang-schema-service</name>
+          <provider>/modules/module[type='schema-service-singleton'][name='yang-schema-service']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry
+        </type>
+        <instance>
+          <name>dom-broker</name>
+          <provider>/modules/module[type='dom-broker-impl'][name='inmemory-dom-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-async-data-broker
+        </type>
+        <instance>
+          <name>inmemory-data-broker</name>
+          <provider>/modules/module[type='dom-inmemory-data-broker'][name='inmemory-data-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
+        <instance>
+          <name>global-netconf-processing-executor</name>
+          <provider>/modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+        <instance>
+          <name>global-netconf-processing-executor-threadfactory</name>
+          <provider>
+            /modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory']
+          </provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          prefix:binding-dom-mapping-service
+        </type>
+        <instance>
+          <name>runtime-mapping-singleton</name>
+          <provider>/modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
+        <instance>
+          <name>global-timer</name>
+          <provider>/modules/module[type='netty-hashed-wheel-timer'][name='global-timer']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+        <instance>
+          <name>global-boss-group</name>
+          <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-boss-group']</provider>
+        </instance>
+        <instance>
+          <name>global-worker-group</name>
+          <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-worker-group']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
+        <instance>
+          <name>global-event-executor</name>
+          <provider>/modules/module[type='netty-global-event-executor'][name='singleton']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-rpc-registry
+        </type>
+        <instance>
+          <name>binding-rpc-broker</name>
+          <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+          prefix:binding-notification-service
+        </type>
+        <instance>
+          <name>binding-notification-broker</name>
+          <provider>/modules/module[type='binding-notification-broker'][name='binding-notification-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+          prefix:binding-broker-osgi-registry
+        </type>
+        <instance>
+          <name>binding-osgi-broker</name>
+          <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker
+        </type>
+        <instance>
+          <name>binding-data-broker</name>
+          <provider>/modules/module[type='binding-data-compatible-broker'][name='inmemory-binding-data-broker']
+          </provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">
+          prefix:kitchen-service
+        </type>
+        <instance>
+          <name>kitchen-service</name>
+          <provider>/modules/module[type='kitchen-service-impl'][name='kitchen-service-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">
+          prefix:netconf-client-dispatcher
+        </type>
+        <instance>
+          <name>global-netconf-dispatcher</name>
+          <provider>/modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher']</provider>
+        </instance>
+      </service>
+    </services>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/logback-test.xml b/opendaylight/netconf/netconf-impl/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..74714a0
--- /dev/null
@@ -0,0 +1,13 @@
+<configuration scan="true">
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="error">
+    <appender-ref ref="STDOUT" />
+  </root>
+  <logger name="org.opendaylight.controller.netconf" level="TRACE"/>
+</configuration>
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/post-filter.xml
new file mode 100644 (file)
index 0000000..4abe6a3
--- /dev/null
@@ -0,0 +1,48 @@
+<!--
+  ~ 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
+  -->
+
+<rpc-reply message-id="0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/pre-filter.xml
new file mode 100644 (file)
index 0000000..031409b
--- /dev/null
@@ -0,0 +1,40 @@
+<rpc-reply message-id="0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/0/request.xml
new file mode 100644 (file)
index 0000000..8d49a7f
--- /dev/null
@@ -0,0 +1,5 @@
+<rpc message-id="0"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get>
+  </get>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/post-filter.xml
new file mode 100644 (file)
index 0000000..1ad3f20
--- /dev/null
@@ -0,0 +1,5 @@
+<rpc-reply message-id="1"
+           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+  </data>
+</rpc-reply>
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/pre-filter.xml
new file mode 100644 (file)
index 0000000..8fd61e1
--- /dev/null
@@ -0,0 +1,40 @@
+<rpc-reply message-id="1" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/1/request.xml
new file mode 100644 (file)
index 0000000..2579aa6
--- /dev/null
@@ -0,0 +1,7 @@
+<rpc message-id="1"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get>
+    <filter type="subtree">
+    </filter>
+  </get>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/post-filter.xml
new file mode 100644 (file)
index 0000000..e974b59
--- /dev/null
@@ -0,0 +1,35 @@
+<rpc-reply message-id="2" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/pre-filter.xml
new file mode 100644 (file)
index 0000000..a399e57
--- /dev/null
@@ -0,0 +1,48 @@
+<!--
+  ~ 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
+  -->
+
+<rpc-reply message-id="2" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/2/request.xml
new file mode 100644 (file)
index 0000000..7b549b9
--- /dev/null
@@ -0,0 +1,13 @@
+<rpc message-id="2"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get-config>
+    <source>
+      <running/>
+    </source>
+    <filter type="subtree">
+      <top xmlns="http://example.com/schema/1.2/config">
+        <users/>
+      </top>
+    </filter>
+  </get-config>
+</rpc>
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/post-filter.xml
new file mode 100644 (file)
index 0000000..e379d49
--- /dev/null
@@ -0,0 +1,26 @@
+<!--
+  ~ 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
+  -->
+
+<rpc-reply message-id="3"
+           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+        </user>
+        <user>
+          <name>fred</name>
+        </user>
+        <user>
+          <name>barney</name>
+        </user>
+      </users>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/pre-filter.xml
new file mode 100644 (file)
index 0000000..42f451b
--- /dev/null
@@ -0,0 +1,48 @@
+<!--
+  ~ 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
+  -->
+
+<rpc-reply message-id="3" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/3/request.xml
new file mode 100644 (file)
index 0000000..771f136
--- /dev/null
@@ -0,0 +1,25 @@
+<!--
+  ~ 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
+  -->
+
+<rpc message-id="3"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get-config>
+    <source>
+      <running/>
+    </source>
+    <filter type="subtree">
+      <top xmlns="http://example.com/schema/1.2/config">
+        <users>
+          <user>
+            <name/>
+          </user>
+        </users>
+      </top>
+    </filter>
+  </get-config>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/post-filter.xml
new file mode 100644 (file)
index 0000000..c701ba0
--- /dev/null
@@ -0,0 +1,18 @@
+<rpc-reply message-id="4"
+           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+      </users>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/pre-filter.xml
new file mode 100644 (file)
index 0000000..f2f2cbb
--- /dev/null
@@ -0,0 +1,48 @@
+<!--
+  ~ 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
+  -->
+
+<rpc-reply message-id="4" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/4/request.xml
new file mode 100644 (file)
index 0000000..04c8149
--- /dev/null
@@ -0,0 +1,17 @@
+<rpc message-id="4"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get-config>
+    <source>
+      <running/>
+    </source>
+    <filter type="subtree">
+      <top xmlns="http://example.com/schema/1.2/config">
+        <users>
+          <user>
+            <name>fred</name>
+          </user>
+        </users>
+      </top>
+    </filter>
+  </get-config>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/post-filter.xml
new file mode 100644 (file)
index 0000000..d6ffd00
--- /dev/null
@@ -0,0 +1,14 @@
+<rpc-reply message-id="5"
+           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+        </user>
+      </users>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/pre-filter.xml
new file mode 100644 (file)
index 0000000..7e3f721
--- /dev/null
@@ -0,0 +1,40 @@
+<rpc-reply message-id="5" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/5/request.xml
new file mode 100644 (file)
index 0000000..3581988
--- /dev/null
@@ -0,0 +1,19 @@
+<rpc message-id="5"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get-config>
+    <source>
+      <running/>
+    </source>
+    <filter type="subtree">
+      <top xmlns="http://example.com/schema/1.2/config">
+        <users>
+          <user>
+            <name>fred</name>
+            <type/>
+            <full-name/>
+          </user>
+        </users>
+      </top>
+    </filter>
+  </get-config>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/post-filter.xml
new file mode 100644 (file)
index 0000000..05eb019
--- /dev/null
@@ -0,0 +1,22 @@
+<rpc-reply message-id="6"
+           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <company-info>
+            <id>2</id>
+          </company-info>
+        </user>
+      </users>
+    </top>
+  </data>
+</rpc-reply>
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/pre-filter.xml
new file mode 100644 (file)
index 0000000..71dd628
--- /dev/null
@@ -0,0 +1,48 @@
+<!--
+  ~ 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
+  -->
+
+<rpc-reply message-id="6" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/6/request.xml
new file mode 100644 (file)
index 0000000..c4a410d
--- /dev/null
@@ -0,0 +1,32 @@
+<rpc message-id="6"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get-config>
+    <source>
+      <running/>
+    </source>
+    <filter type="subtree">
+      <top xmlns="http://example.com/schema/1.2/config">
+        <users>
+          <user>
+            <name>root</name>
+            <company-info/>
+          </user>
+          <user>
+            <name>fred</name>
+            <company-info>
+              <id/>
+            </company-info>
+          </user>
+          <user>
+            <name>barney</name>
+            <type>superuser</type>
+            <company-info>
+              <dept/>
+            </company-info>
+          </user>
+        </users>
+      </top>
+    </filter>
+  </get-config>
+</rpc>
+
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/post-filter.xml
new file mode 100644 (file)
index 0000000..676ba22
--- /dev/null
@@ -0,0 +1,13 @@
+<rpc-reply message-id="7"
+           xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <t:top xmlns:t="http://example.com/schema/1.2/stats">
+      <t:interfaces>
+        <t:interface t:ifName="eth0">
+          <t:ifInOctets>45621</t:ifInOctets>
+          <t:ifOutOctets>774344</t:ifOutOctets>
+        </t:interface>
+      </t:interfaces>
+    </t:top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/pre-filter.xml
new file mode 100644 (file)
index 0000000..ef88283
--- /dev/null
@@ -0,0 +1,52 @@
+<rpc-reply message-id="7" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <data>
+    <top xmlns="http://example.com/schema/1.2/config">
+      <users>
+        <user>
+          <name>root</name>
+          <type>superuser</type>
+          <full-name>Charlie Root</full-name>
+          <company-info>
+            <dept>1</dept>
+            <id>1</id>
+          </company-info>
+        </user>
+        <user>
+          <name>fred</name>
+          <type>admin</type>
+          <full-name>Fred Flintstone</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>2</id>
+          </company-info>
+        </user>
+        <user>
+          <name>barney</name>
+          <type>admin</type>
+          <full-name>Barney Rubble</full-name>
+          <company-info>
+            <dept>2</dept>
+            <id>3</id>
+          </company-info>
+        </user>
+      </users>
+      <groups>
+        <group>
+          <name>admin</name>
+        </group>
+      </groups>
+    </top>
+    <prefix:top xmlns:prefix="http://example.com/schema/1.2/stats">
+      <prefix:interfaces>
+        <prefix:interface prefix:ifName="eth0">
+          <prefix:ifInOctets>45621</prefix:ifInOctets>
+          <prefix:ifOutOctets>774344</prefix:ifOutOctets>
+        </prefix:interface>
+        <prefix:interface prefix:ifName="eth1">
+          <prefix:ifInOctets>1</prefix:ifInOctets>
+          <prefix:ifOutOctets>1</prefix:ifOutOctets>
+        </prefix:interface>
+      </prefix:interfaces>
+    </prefix:top>
+  </data>
+</rpc-reply>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/7/request.xml
new file mode 100644 (file)
index 0000000..4bbbaba
--- /dev/null
@@ -0,0 +1,12 @@
+<rpc message-id="7"
+     xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+  <get>
+    <filter type="subtree">
+      <t:top xmlns:t="http://example.com/schema/1.2/stats">
+        <t:interfaces>
+          <t:interface t:ifName="eth0"/>
+        </t:interfaces>
+      </t:top>
+    </filter>
+  </get>
+</rpc>
\ No newline at end of file
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/post-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/post-filter.xml
new file mode 100644 (file)
index 0000000..3498b02
--- /dev/null
@@ -0,0 +1,115 @@
+<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-6">
+  <data>
+    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:schema-service</type>
+        <instance>
+          <name>yang-schema-service</name>
+          <provider>/modules/module[type='schema-service-singleton'][name='yang-schema-service']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+        <instance>
+          <name>dom-broker</name>
+          <provider>/modules/module[type='dom-broker-impl'][name='inmemory-dom-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-async-data-broker</type>
+        <instance>
+          <name>inmemory-data-broker</name>
+          <provider>/modules/module[type='dom-inmemory-data-broker'][name='inmemory-data-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
+        <instance>
+          <name>global-netconf-processing-executor</name>
+          <provider>/modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+        <instance>
+          <name>global-netconf-processing-executor-threadfactory</name>
+          <provider>/modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+        <instance>
+          <name>runtime-mapping-singleton</name>
+          <provider>/modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
+        <instance>
+          <name>global-timer</name>
+          <provider>/modules/module[type='netty-hashed-wheel-timer'][name='global-timer']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+        <instance>
+          <name>global-boss-group</name>
+          <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-boss-group']</provider>
+        </instance>
+        <instance>
+          <name>global-worker-group</name>
+          <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-worker-group']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
+        <instance>
+          <name>global-event-executor</name>
+          <provider>/modules/module[type='netty-global-event-executor'][name='singleton']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-rpc-registry</type>
+        <instance>
+          <name>binding-rpc-broker</name>
+          <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+        <instance>
+          <name>binding-notification-broker</name>
+          <provider>/modules/module[type='binding-notification-broker'][name='binding-notification-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
+        <instance>
+          <name>binding-osgi-broker</name>
+          <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+        <instance>
+          <name>binding-data-broker</name>
+          <provider>/modules/module[type='binding-data-compatible-broker'][name='inmemory-binding-data-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">prefix:kitchen-service</type>
+        <instance>
+          <name>kitchen-service</name>
+          <provider>/modules/module[type='kitchen-service-impl'][name='kitchen-service-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
+        <instance>
+          <name>global-netconf-dispatcher</name>
+          <provider>/modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher']</provider>
+        </instance>
+      </service>
+    </services>
+  </data>
+</rpc-reply>
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/pre-filter.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/pre-filter.xml
new file mode 100644 (file)
index 0000000..8a57b4c
--- /dev/null
@@ -0,0 +1,350 @@
+<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-6">
+  <data>
+    <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">prefix:toaster-provider-impl</type>
+        <name>toaster-provider-impl</name>
+        <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+          <name>binding-notification-broker</name>
+        </notification-service>
+        <rpc-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-rpc-registry</type>
+          <name>binding-rpc-broker</name>
+        </rpc-registry>
+        <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:toaster-provider:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+          <name>binding-data-broker</name>
+        </data-broker>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">prefix:sal-netconf-connector</type>
+        <name>controller-config</name>
+        <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">1830</port>
+        <connection-timeout-millis xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">20000</connection-timeout-millis>
+        <between-attempts-timeout-millis xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">2000</between-attempts-timeout-millis>
+        <sleep-factor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">1.5</sleep-factor>
+        <password xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</password>
+        <dom-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+          <name>dom-broker</name>
+        </dom-registry>
+        <client-dispatcher xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
+          <name>global-netconf-dispatcher</name>
+        </client-dispatcher>
+        <username xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">admin</username>
+        <address xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">127.0.0.1</address>
+        <processing-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
+          <name>global-netconf-processing-executor</name>
+        </processing-executor>
+        <tcp-only xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">false</tcp-only>
+        <binding-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
+          <name>binding-osgi-broker</name>
+        </binding-registry>
+        <max-connection-attempts xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">0</max-connection-attempts>
+        <event-executor xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
+          <name>global-event-executor</name>
+        </event-executor>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">prefix:netconf-client-dispatcher</type>
+        <name>global-netconf-dispatcher</name>
+        <worker-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+          <name>global-worker-group</name>
+        </worker-thread-group>
+        <timer xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
+          <name>global-timer</name>
+        </timer>
+        <boss-thread-group xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:netconf:client:dispatcher">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+          <name>global-boss-group</name>
+        </boss-thread-group>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:logback:config">prefix:logback</type>
+        <name>singleton</name>
+        <console-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <threshold-filter>ERROR</threshold-filter>
+          <name>STDOUT</name>
+          <encoder-pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</encoder-pattern>
+        </console-appenders>
+        <file-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <append>true</append>
+          <file-name>logs/audit.log</file-name>
+          <name>audit-file</name>
+          <encoder-pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} %msg %n</encoder-pattern>
+        </file-appenders>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>WARN</level>
+          <logger-name>org.opendaylight.controller.logging.bridge</logger-name>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>INFO</level>
+          <logger-name>audit</logger-name>
+          <appenders>audit-file</appenders>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>ERROR</level>
+          <logger-name>ROOT</logger-name>
+          <appenders>STDOUT</appenders>
+          <appenders>opendaylight.log</appenders>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>INFO</level>
+          <logger-name>org.opendaylight</logger-name>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>INFO</level>
+          <logger-name>org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort</logger-name>
+          <appenders>opendaylight.log</appenders>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>TRACE</level>
+          <logger-name>org.opendaylight.controller.netconf</logger-name>
+        </loggers>
+        <loggers xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <level>WARN</level>
+          <logger-name>io.netty</logger-name>
+        </loggers>
+        <rolling-appenders xmlns="urn:opendaylight:params:xml:ns:yang:controller:logback:config">
+          <append>true</append>
+          <max-file-size>10MB</max-file-size>
+          <file-name>logs/opendaylight.log</file-name>
+          <name>opendaylight.log</name>
+          <file-name-pattern>logs/opendaylight.%d.log.zip</file-name-pattern>
+          <encoder-pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{35} - %msg%n</encoder-pattern>
+          <clean-history-on-start>false</clean-history-on-start>
+          <max-history>1</max-history>
+          <rolling-policy-type>TimeBasedRollingPolicy</rolling-policy-type>
+        </rolling-appenders>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:shutdown:impl">prefix:shutdown</type>
+        <name>shutdown</name>
+        <secret xmlns="urn:opendaylight:params:xml:ns:yang:controller:shutdown:impl"/>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:timer">prefix:netty-hashed-wheel-timer</type>
+        <name>global-timer</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">prefix:netty-threadgroup-fixed</type>
+        <name>global-boss-group</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:threadgroup">prefix:netty-threadgroup-fixed</type>
+        <name>global-worker-group</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
+        <name>yang-schema-service</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
+        <name>inmemory-dom-broker</name>
+        <async-data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-async-data-broker</type>
+          <name>inmemory-data-broker</name>
+        </async-data-broker>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-inmemory-data-broker</type>
+        <name>inmemory-data-broker</name>
+        <schema-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:schema-service</type>
+          <name>yang-schema-service</name>
+        </schema-service>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">prefix:threadpool-flexible</type>
+        <name>global-netconf-processing-executor</name>
+        <threadFactory xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+          <name>global-netconf-processing-executor-threadfactory</name>
+        </threadFactory>
+        <minThreadCount xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">1</minThreadCount>
+        <max-thread-count xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">4</max-thread-count>
+        <keepAliveMillis xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl:flexible">600000</keepAliveMillis>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor">prefix:netty-global-event-executor</type>
+        <name>singleton</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
+        <name>binding-broker-impl</name>
+        <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+          <name>binding-notification-broker</name>
+        </notification-service>
+        <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+          <name>binding-data-broker</name>
+        </data-broker>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
+        <name>runtime-mapping-singleton</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
+        <name>binding-notification-broker</name>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-compatible-broker</type>
+        <name>inmemory-binding-data-broker</name>
+        <dom-async-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+          <name>dom-broker</name>
+        </dom-async-broker>
+        <binding-mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+          <name>runtime-mapping-singleton</name>
+        </binding-mapping-service>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">prefix:threadfactory-naming</type>
+        <name>global-netconf-processing-executor-threadfactory</name>
+        <name-prefix xmlns="urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl">remote-connector-processing-executor</name-prefix>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">prefix:kitchen-service-impl</type>
+        <name>kitchen-service-impl</name>
+        <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+          <name>binding-notification-broker</name>
+        </notification-service>
+        <rpc-registry xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-rpc-registry</type>
+          <name>binding-rpc-broker</name>
+        </rpc-registry>
+      </module>
+      <module>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">prefix:remote-zeromq-rpc-server</type>
+        <name>remoter</name>
+        <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port>
+        <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+          <name>dom-broker</name>
+        </dom-broker>
+      </module>
+    </modules>
+    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:schema-service</type>
+        <instance>
+          <name>yang-schema-service</name>
+          <provider>/modules/module[type='schema-service-singleton'][name='yang-schema-service']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+        <instance>
+          <name>dom-broker</name>
+          <provider>/modules/module[type='dom-broker-impl'][name='inmemory-dom-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-async-data-broker</type>
+        <instance>
+          <name>inmemory-data-broker</name>
+          <provider>/modules/module[type='dom-inmemory-data-broker'][name='inmemory-data-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadpool</type>
+        <instance>
+          <name>global-netconf-processing-executor</name>
+          <provider>/modules/module[type='threadpool-flexible'][name='global-netconf-processing-executor']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:threadpool">prefix:threadfactory</type>
+        <instance>
+          <name>global-netconf-processing-executor-threadfactory</name>
+          <provider>/modules/module[type='threadfactory-naming'][name='global-netconf-processing-executor-threadfactory']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-dom-mapping-service</type>
+        <instance>
+          <name>runtime-mapping-singleton</name>
+          <provider>/modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-timer</type>
+        <instance>
+          <name>global-timer</name>
+          <provider>/modules/module[type='netty-hashed-wheel-timer'][name='global-timer']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-threadgroup</type>
+        <instance>
+          <name>global-boss-group</name>
+          <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-boss-group']</provider>
+        </instance>
+        <instance>
+          <name>global-worker-group</name>
+          <provider>/modules/module[type='netty-threadgroup-fixed'][name='global-worker-group']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:netty">prefix:netty-event-executor</type>
+        <instance>
+          <name>global-event-executor</name>
+          <provider>/modules/module[type='netty-global-event-executor'][name='singleton']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-rpc-registry</type>
+        <instance>
+          <name>binding-rpc-broker</name>
+          <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-notification-service</type>
+        <instance>
+          <name>binding-notification-broker</name>
+          <provider>/modules/module[type='binding-notification-broker'][name='binding-notification-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
+        <instance>
+          <name>binding-osgi-broker</name>
+          <provider>/modules/module[type='binding-broker-impl'][name='binding-broker-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-data-broker</type>
+        <instance>
+          <name>binding-data-broker</name>
+          <provider>/modules/module[type='binding-data-compatible-broker'][name='inmemory-binding-data-broker']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:kitchen-service:impl">prefix:kitchen-service</type>
+        <instance>
+          <name>kitchen-service</name>
+          <provider>/modules/module[type='kitchen-service-impl'][name='kitchen-service-impl']</provider>
+        </instance>
+      </service>
+      <service>
+        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:netconf">prefix:netconf-client-dispatcher</type>
+        <instance>
+          <name>global-netconf-dispatcher</name>
+          <provider>/modules/module[type='netconf-client-dispatcher'][name='global-netconf-dispatcher']</provider>
+        </instance>
+      </service>
+    </services>
+  </data>
+</rpc-reply>
diff --git a/opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/request.xml b/opendaylight/netconf/netconf-impl/src/test/resources/subtree/8/request.xml
new file mode 100644 (file)
index 0000000..4d71ba4
--- /dev/null
@@ -0,0 +1,12 @@
+<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="m-10">
+  <get-config>
+    <filter xmlns:ns0="urn:ietf:params:xml:ns:netconf:base:1.0" ns0:type="subtree">
+      <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <service/>
+      </services>
+    </filter>
+    <source>
+      <running/>
+    </source>
+  </get-config>
+</rpc>
index 731aad6..e9e92d9 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
 
 public class NetconfMonitoringOperationService implements NetconfOperationService {
 
-    public static final Set<Capability> CAPABILITIES = Sets.<Capability>newHashSet(new Capability() {
+    private static final Set<Capability> CAPABILITIES = Sets.<Capability>newHashSet(new Capability() {
 
         @Override
         public String getCapabilityUri() {
index 4e32e82..2bda51b 100644 (file)
@@ -30,7 +30,7 @@ public class SSHTest {
         AuthProvider authProvider = mock(AuthProvider.class);
         doReturn(PEMGenerator.generate().toCharArray()).when(authProvider).getPEMAsCharArray();
         doReturn(true).when(authProvider).authenticated(anyString(), anyString());
-        NetconfSSHServer thread = NetconfSSHServer.start(1831, NetconfConfigUtil.getNetconfLocalAddress(), authProvider, new NioEventLoopGroup());
+        NetconfSSHServer thread = NetconfSSHServer.start(10831, NetconfConfigUtil.getNetconfLocalAddress(), authProvider, new NioEventLoopGroup());
         Thread.sleep(2000);
         logger.info("Closing socket");
         thread.close();
index 65ca1b7..8837c74 100644 (file)
@@ -47,12 +47,12 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
 
     public static final class OperationNameAndNamespace {
         private final String operationName, namespace;
+        private final XmlElement operationElement;
 
         public OperationNameAndNamespace(Document message) throws NetconfDocumentedException {
             XmlElement requestElement = null;
             requestElement = getRequestElementWithCheck(message);
-
-            XmlElement operationElement = requestElement.getOnlyChildElement();
+            operationElement = requestElement.getOnlyChildElement();
             operationName = operationElement.getName();
             namespace = operationElement.getNamespace();
         }
@@ -64,6 +64,10 @@ public abstract class AbstractNetconfOperation implements NetconfOperation {
         public String getNamespace() {
             return namespace;
         }
+
+        public XmlElement getOperationElement() {
+            return operationElement;
+        }
     }
 
     protected static XmlElement getRequestElementWithCheck(Document message) throws NetconfDocumentedException {
index ac200a0..8780925 100644 (file)
@@ -338,6 +338,17 @@ public final class XmlElement {
         );
     }
 
+    public Optional<String> getOnlyTextContentOptionally() {
+        // only return text content if this node has exactly one Text child node
+        if (element.getChildNodes().getLength() == 1) {
+            Node item = element.getChildNodes().item(0);
+            if (item instanceof Text) {
+                return Optional.of(((Text) item).getWholeText());
+            }
+        }
+        return Optional.absent();
+    }
+
     public String getNamespaceAttribute() throws MissingNameSpaceException {
         String attribute = element.getAttribute(XmlUtil.XMLNS_ATTRIBUTE_KEY);
         if (attribute == null || attribute.equals("")){
index 708f17c..fa72284 100644 (file)
@@ -56,4 +56,5 @@ public final class XmlNetconfConstants {
     // TODO where to store namespace of config ?
     public static final String URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG = "urn:opendaylight:params:xml:ns:yang:controller:config";
     public static final String GET = "get";
+    public static final String GET_CONFIG = "get-config";
 }
index b2cb414..7bd15ff 100644 (file)
@@ -111,7 +111,9 @@ public class ConnectionService implements IPluginOutConnectionService, IConnecti
     @Override
     public Node connect (String type, String connectionIdentifier, Map<ConnectionConstants, String> params) {
         IPluginInConnectionService s = pluginService.get(type);
-        if (s != null) return s.connect(connectionIdentifier, params);
+        if (s != null) {
+            return s.connect(connectionIdentifier, params);
+        }
         return null;
     }
 
@@ -121,7 +123,9 @@ public class ConnectionService implements IPluginOutConnectionService, IConnecti
             for (String pluginType : this.pluginService.keySet()) {
                 IPluginInConnectionService s = pluginService.get(pluginType);
                 Node node = s.connect(connectionIdentifier, params);
-                if (node != null) return node;
+                if (node != null) {
+                    return node;
+                }
             }
         }
         return null;

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.