BUG-459 Remove deprecated NetconfClient class. 14/5514/8
authorMaros Marsalek <mmarsale@cisco.com>
Mon, 3 Mar 2014 12:35:48 +0000 (13:35 +0100)
committerMaros Marsalek <mmarsale@cisco.com>
Mon, 14 Apr 2014 14:05:34 +0000 (16:05 +0200)
NetconfClient moved to test sources, now will be used only by tests.

Change-Id: Ia98abe3f6fa4f05566b71d57c519c2149726bcb6
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
15 files changed:
opendaylight/netconf/netconf-client/pom.xml
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/AbstractNetconfClientNotifySessionListener.java [deleted file]
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java [deleted file]
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java
opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/SimpleNetconfClientSessionListener.java
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SSHNetconfClientLiveTest.java [deleted file]
opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/test/TestingNetconfClient.java [new file with mode: 0644]
opendaylight/netconf/netconf-impl/pom.xml
opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java
opendaylight/netconf/netconf-it/pom.xml
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java

index b0f5f748106ab499ab95983cbb358f84536dbd66..25ed0e7ab120b3b926f2c1cfc5b48ffae4e3a9d4 100644 (file)
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.4</version>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/AbstractNetconfClientNotifySessionListener.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/AbstractNetconfClientNotifySessionListener.java
deleted file mode 100644 (file)
index 6ae966d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2013 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.client;
-
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
-import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
-
-/**
- * Class extending {@link NetconfClientSessionListener} to provide notification capability.
- */
-public abstract class AbstractNetconfClientNotifySessionListener extends SimpleNetconfClientSessionListener {
-    /*
-     * Maybe some capabilities could be expressed as internal NetconfClientSessionListener handlers.
-     * It would enable NetconfClient functionality to be extended by using namespace handlers.
-     * So far let just enable notification capability by extending and let parent class intact.
-     */
-
-    /**
-     * As class purpose is to provide notification capability to session listener
-     * onMessage method is not allowed to be further overridden.
-     * {@see #onNotification(NetconfClientSession, NetconfMessage)}
-     *
-     * @param session {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
-     * @param message {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
-     */
-    @Override
-    public final void onMessage(NetconfClientSession session, NetconfMessage message) {
-        if (isNotification(message)) {
-            onNotification(session, message);
-        } else {
-            super.onMessage(session, message);
-        }
-    }
-
-    /**
-     * Method intended to customize notification processing.
-     *
-     * @param session {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
-     * @param message {@see NetconfClientSessionListener#onMessage(NetconfClientSession, NetconfMessage)}
-     */
-    public abstract void onNotification(NetconfClientSession session, NetconfMessage message);
-
-    private boolean isNotification(NetconfMessage message) {
-        XmlElement xmle = XmlElement.fromDomDocument(message.getDocument());
-        return XmlNetconfConstants.NOTIFICATION_ELEMENT_NAME.equals(xmle.getName()) ;
-    }
-}
diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClient.java
deleted file mode 100644 (file)
index 4cdca20..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2013 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.client;
-
-import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GlobalEventExecutor;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Set;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.protocol.framework.NeverReconnectStrategy;
-import org.opendaylight.protocol.framework.ReconnectStrategy;
-import org.opendaylight.protocol.framework.TimedReconnectStrategy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Stopwatch;
-import com.google.common.collect.Sets;
-
-/**
- * @deprecated Use {@link NetconfClientDispatcher.createClient()} or {@link NetconfClientDispatcher.createReconnectingClient()} instead.
- */
-@Deprecated
-public class NetconfClient implements Closeable {
-
-    private static final Logger logger = LoggerFactory.getLogger(NetconfClient.class);
-
-    public static final int DEFAULT_CONNECT_TIMEOUT = 5000;
-    private final NetconfClientDispatcher dispatch;
-    private final String label;
-    private final NetconfClientSession clientSession;
-    private final NetconfClientSessionListener sessionListener;
-    private final long sessionId;
-    private final InetSocketAddress address;
-
-    // TODO test reconnecting constructor
-    public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectionAttempts,
-            int attemptMsTimeout, NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
-        this(clientLabelForLogging, address, getReconnectStrategy(connectionAttempts, attemptMsTimeout),
-                netconfClientDispatcher);
-    }
-
-    private NetconfClient(String clientLabelForLogging, InetSocketAddress address, ReconnectStrategy strat, NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
-        this.label = clientLabelForLogging;
-        dispatch = netconfClientDispatcher;
-        sessionListener = new SimpleNetconfClientSessionListener();
-        Future<NetconfClientSession> clientFuture = dispatch.createClient(address, sessionListener, strat);
-        this.address = address;
-        clientSession = get(clientFuture);
-        this.sessionId = clientSession.getSessionId();
-    }
-
-    private NetconfClientSession get(Future<NetconfClientSession> clientFuture) throws InterruptedException {
-        try {
-            return clientFuture.get();
-        } catch (CancellationException e) {
-            throw new RuntimeException("Cancelling " + this, e);
-        } catch (ExecutionException e) {
-            throw new IllegalStateException("Unable to create " + this, e);
-        }
-    }
-
-    public static NetconfClient clientFor(String clientLabelForLogging, InetSocketAddress address, ReconnectStrategy strategy, NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
-        return new NetconfClient(clientLabelForLogging,address,strategy,netconfClientDispatcher);
-    }
-
-    public static NetconfClient clientFor(String clientLabelForLogging, InetSocketAddress address,
-            ReconnectStrategy strategy, NetconfClientDispatcher netconfClientDispatcher, NetconfClientSessionListener listener) throws InterruptedException {
-        return new NetconfClient(clientLabelForLogging,address,strategy,netconfClientDispatcher,listener);
-    }
-
-    public NetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectTimeoutMs,
-            NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
-        this(clientLabelForLogging, address,
-                new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, connectTimeoutMs), netconfClientDispatcher);
-    }
-
-    public NetconfClient(String clientLabelForLogging, InetSocketAddress address,
-            NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
-        this(clientLabelForLogging, address, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE,
-                DEFAULT_CONNECT_TIMEOUT), netconfClientDispatcher);
-    }
-
-    public NetconfClient(String clientLabelForLogging, InetSocketAddress address, ReconnectStrategy strategy,
-            NetconfClientDispatcher netconfClientDispatcher, NetconfClientSessionListener listener) throws InterruptedException{
-        this.label = clientLabelForLogging;
-        dispatch = netconfClientDispatcher;
-        sessionListener = listener;
-        Future<NetconfClientSession> clientFuture = dispatch.createClient(address, sessionListener, strategy);
-        this.address = address;
-        clientSession = get(clientFuture);
-        this.sessionId = clientSession.getSessionId();
-    }
-
-    public Future<NetconfMessage> sendRequest(NetconfMessage message) {
-        return ((SimpleNetconfClientSessionListener)sessionListener).sendRequest(message);
-    }
-
-    /**
-     * @deprecated Use {@link sendRequest} instead
-     */
-    @Deprecated
-    public NetconfMessage sendMessage(NetconfMessage message) throws ExecutionException, InterruptedException, TimeoutException {
-        return sendMessage(message, 5, 1000);
-    }
-
-    /**
-     * @deprecated Use {@link sendRequest} instead
-     */
-    @Deprecated
-    public NetconfMessage sendMessage(NetconfMessage message, int attempts, int attemptMsDelay) throws ExecutionException, InterruptedException, TimeoutException {
-        //logger.debug("Sending message: {}",XmlUtil.toString(message.getDocument()));
-        final Stopwatch stopwatch = new Stopwatch().start();
-
-        try {
-            return sendRequest(message).get(attempts * attemptMsDelay, TimeUnit.MILLISECONDS);
-        } finally {
-            stopwatch.stop();
-            logger.debug("Total time spent waiting for response from {}: {} ms", address, stopwatch.elapsed(TimeUnit.MILLISECONDS));
-        }
-    }
-
-    @Override
-    public void close() throws IOException {
-        clientSession.close();
-    }
-
-    public NetconfClientDispatcher getNetconfClientDispatcher() {
-        return dispatch;
-    }
-
-    private static ReconnectStrategy getReconnectStrategy(int connectionAttempts, int attemptMsTimeout) {
-        return new TimedReconnectStrategy(GlobalEventExecutor.INSTANCE, attemptMsTimeout, 1000, 1.0, null,
-                Long.valueOf(connectionAttempts), null);
-    }
-
-    @Override
-    public String toString() {
-        final StringBuffer sb = new StringBuffer("NetconfClient{");
-        sb.append("label=").append(label);
-        sb.append(", sessionId=").append(sessionId);
-        sb.append('}');
-        return sb.toString();
-    }
-
-    public long getSessionId() {
-        return sessionId;
-    }
-
-    public Set<String> getCapabilities() {
-        Preconditions.checkState(clientSession != null, "Client was not initialized successfully");
-        return Sets.newHashSet(clientSession.getServerCapabilities());
-    }
-
-    public NetconfClientSession getClientSession() {
-        return clientSession;
-    }
-}
index bb372b3affc3e379bbff702805d7db6cca2b6b7f..cff214401c0ff2ac8a24548adda3e44c8a4f186b 100644 (file)
@@ -58,8 +58,9 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
 
         if(this.additionalHeader.isPresent()) {
             helloMessage = new NetconfHelloMessage(helloMessage.getDocument(), additionalHeader.get());
-        } else
+        } else {
             helloMessage = new NetconfHelloMessage(helloMessage.getDocument());
+        }
 
         NetconfSessionPreferences proposal = new NetconfSessionPreferences(helloMessage);
         return new NetconfClientSessionNegotiator(proposal, promise, channel, timer,
index e96161c29ad08e36f128252fd805903c3bd3139b..504e4c994915aeafc5d303fc2a56ab4bcf2722d8 100644 (file)
@@ -101,7 +101,7 @@ public class SimpleNetconfClientSessionListener implements NetconfClientSessionL
         }
     }
 
-    final synchronized Future<NetconfMessage> sendRequest(NetconfMessage message) {
+    public final synchronized Future<NetconfMessage> sendRequest(NetconfMessage message) {
         final RequestEntry req = new RequestEntry(GlobalEventExecutor.INSTANCE.<NetconfMessage>newPromise(), message);
 
         requests.add(req);
diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SSHNetconfClientLiveTest.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/SSHNetconfClientLiveTest.java
deleted file mode 100644 (file)
index 1357201..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2013 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.client;
-
-import io.netty.channel.nio.NioEventLoopGroup;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.opendaylight.controller.netconf.util.handler.ssh.authentication.LoginPassword;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-@Ignore
-public class SSHNetconfClientLiveTest {
-    private static final Logger logger = LoggerFactory.getLogger(SSHNetconfClientLiveTest.class);
-
-    NioEventLoopGroup nettyThreadgroup;
-    NetconfSshClientDispatcher netconfClientDispatcher;
-    InetSocketAddress address;
-    final int connectionAttempts = 10, attemptMsTimeout = 1000;
-    final int connectionTimeoutMillis = 20000;
-
-    @Before
-    public void setUp() {
-        nettyThreadgroup = new NioEventLoopGroup();
-
-        netconfClientDispatcher = new NetconfSshClientDispatcher(new LoginPassword(
-                System.getProperty("username"), System.getProperty("password")),
-                nettyThreadgroup, nettyThreadgroup, connectionTimeoutMillis);
-
-        address = new InetSocketAddress(System.getProperty("host"), Integer.parseInt(System.getProperty("port")));
-    }
-
-    @Ignore
-    @Test
-    public void test() throws Exception {
-        //runnable.run();
-    }
-
-    @Test
-    public void testInExecutor() throws Exception {
-        int threads = 4;
-        ExecutorService executorService = Executors.newFixedThreadPool(threads);
-        try {
-            for (int i= 0;i< threads;i++) {
-                InetSocketAddress address = new InetSocketAddress(System.getProperty("host"),
-                        Integer.parseInt(System.getProperty("port")));
-                NetconfRunnable runnable = new NetconfRunnable(address);
-                executorService.execute(runnable);
-            }
-            executorService.shutdown();
-            executorService.awaitTermination(1, TimeUnit.MINUTES);
-
-
-        } finally {
-            executorService.shutdownNow();
-        }
-    }
-
-    class NetconfRunnable implements Runnable {
-        private final InetSocketAddress address;
-
-        NetconfRunnable(InetSocketAddress address) {
-            this.address = address;
-        }
-
-        @Override
-        public void run() {
-            try (NetconfClient netconfClient = new NetconfClient(address.toString(), address, connectionAttempts,
-                    attemptMsTimeout, netconfClientDispatcher);) {
-                logger.info("OK {}", address);
-            } catch (InterruptedException | IOException e) {
-                logger.error("Failed {}", address, e);
-            }
-        }
-    };
-}
diff --git a/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/test/TestingNetconfClient.java b/opendaylight/netconf/netconf-client/src/test/java/org/opendaylight/controller/netconf/client/test/TestingNetconfClient.java
new file mode 100644 (file)
index 0000000..32c6ea8
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013 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.client.test;
+
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.GlobalEventExecutor;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.client.NetconfClientSession;
+import org.opendaylight.controller.netconf.client.NetconfClientSessionListener;
+import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener;
+import org.opendaylight.protocol.framework.NeverReconnectStrategy;
+import org.opendaylight.protocol.framework.ReconnectStrategy;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+
+
+/**
+ * Synchronous netconf client suitable for testing
+ */
+public class TestingNetconfClient implements Closeable {
+
+    public static final int DEFAULT_CONNECT_TIMEOUT = 5000;
+
+    private final String label;
+    private final NetconfClientSession clientSession;
+    private final NetconfClientSessionListener sessionListener;
+    private final long sessionId;
+
+    private TestingNetconfClient(String clientLabel, InetSocketAddress address, ReconnectStrategy strat,
+            NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
+        this.label = clientLabel;
+        sessionListener = new SimpleNetconfClientSessionListener();
+        Future<NetconfClientSession> clientFuture = netconfClientDispatcher.createClient(address, sessionListener, strat);
+        clientSession = get(clientFuture);
+        this.sessionId = clientSession.getSessionId();
+    }
+
+    private NetconfClientSession get(Future<NetconfClientSession> clientFuture) throws InterruptedException {
+        try {
+            return clientFuture.get();
+        } catch (CancellationException e) {
+            throw new RuntimeException("Cancelling " + this, e);
+        } catch (ExecutionException e) {
+            throw new IllegalStateException("Unable to create " + this, e);
+        }
+    }
+
+    public TestingNetconfClient(String clientLabelForLogging, InetSocketAddress address, int connectTimeoutMs,
+                                NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
+        this(clientLabelForLogging, address,
+                new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, connectTimeoutMs), netconfClientDispatcher);
+    }
+
+    public TestingNetconfClient(String clientLabelForLogging, InetSocketAddress address,
+                                NetconfClientDispatcher netconfClientDispatcher) throws InterruptedException {
+        this(clientLabelForLogging, address, new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE,
+                DEFAULT_CONNECT_TIMEOUT), netconfClientDispatcher);
+    }
+
+    public Future<NetconfMessage> sendRequest(NetconfMessage message) {
+        return ((SimpleNetconfClientSessionListener)sessionListener).sendRequest(message);
+    }
+
+    public NetconfMessage sendMessage(NetconfMessage message, int attemptMsDelay) throws ExecutionException,
+            InterruptedException, TimeoutException {
+        return sendRequest(message).get(attemptMsDelay, TimeUnit.MILLISECONDS);
+    }
+
+    public NetconfMessage sendMessage(NetconfMessage message) throws ExecutionException,
+            InterruptedException, TimeoutException {
+        return sendMessage(message, DEFAULT_CONNECT_TIMEOUT);
+    }
+
+    @Override
+    public void close() throws IOException {
+        clientSession.close();
+    }
+
+    @Override
+    public String toString() {
+        final StringBuffer sb = new StringBuffer("TestingNetconfClient{");
+        sb.append("label=").append(label);
+        sb.append(", sessionId=").append(sessionId);
+        sb.append('}');
+        return sb.toString();
+    }
+
+    public long getSessionId() {
+        return sessionId;
+    }
+
+    public Set<String> getCapabilities() {
+        Preconditions.checkState(clientSession != null, "Client was not initialized successfully");
+        return Sets.newHashSet(clientSession.getServerCapabilities());
+    }
+}
\ No newline at end of file
index 76a0bd9908ac571a911f7309c33eb91a42ef87cd..b8b3028708fadb391737481c1ae33ad7f5e06f36 100644 (file)
             <artifactId>netconf-client</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>netconf-client</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>commons.logback_settings</artifactId>
index c1a7b1478b3edde41ea5f13004afc48df540c6bf..82e8caef3a1326f4a2ba6e21177add5abf9158c4 100644 (file)
@@ -21,7 +21,7 @@ import org.junit.Test;
 import org.mockito.Mock;
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.client.NetconfClient;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
 import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
@@ -259,13 +259,13 @@ public class ConcurrentClientsTest {
         @Override
         public void run() {
             try {
-                final NetconfClient netconfClient = new NetconfClient(clientId, netconfAddress, netconfClientDispatcher);
+                final TestingNetconfClient netconfClient = new TestingNetconfClient(clientId, netconfAddress, netconfClientDispatcher);
                 long sessionId = netconfClient.getSessionId();
                 logger.info("Client with sessionid {} hello exchanged", sessionId);
 
                 final NetconfMessage getMessage = XmlFileLoader
                         .xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
-                NetconfMessage result = netconfClient.sendMessage(getMessage);
+                NetconfMessage result = netconfClient.sendRequest(getMessage).get();
                 logger.info("Client with sessionid {} got result {}", sessionId, result);
                 netconfClient.close();
                 logger.info("Client with session id {} ended", sessionId);
index aab939e8d90933dedc0dfb496d6db1ada9e48217..68fd34e13594c8320176fc1d0aa585b4eba959c3 100644 (file)
@@ -1,6 +1,9 @@
 <?xml version="1.0"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
+    <properties>
+        <tinybundles.version>2.0.0</tinybundles.version>
+    </properties>
 
     <parent>
         <artifactId>netconf-subsystem</artifactId>
             <artifactId>netconf-client</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>netconf-client</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>config-netconf-connector</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>netty-config-api</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>config-manager</artifactId>
           <groupId>org.opendaylight.controller</groupId>
           <artifactId>commons.logback_settings</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>${tinybundles.version}</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
index 997cae0f7cf258a8a3074af1f525ea17347b1ce1..78933e4b0bededee3245505cf4f30610a4a1c72e 100644 (file)
@@ -25,8 +25,8 @@ import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification;
 import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
-import org.opendaylight.controller.netconf.client.NetconfClient;
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
 import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
@@ -121,12 +121,12 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
         VerifyingNotificationListener notificationVerifier = createCommitNotificationListener();
         VerifyingPersister mockedAggregator = mockAggregator();
 
-        try (NetconfClient persisterClient = new NetconfClient("persister", tcpAddress, 4000, clientDispatcher)) {
+        try (TestingNetconfClient persisterClient = new TestingNetconfClient("persister", tcpAddress, 4000, clientDispatcher)) {
             try (ConfigPersisterNotificationHandler configPersisterNotificationHandler = new ConfigPersisterNotificationHandler(
                     platformMBeanServer, mockedAggregator)) {
 
 
-                try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, 4000, clientDispatcher)) {
+                try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", tcpAddress, 4000, clientDispatcher)) {
                     NetconfMessage response = netconfClient.sendMessage(loadGetConfigMessage());
                     assertResponse(response, "<modules");
                     assertResponse(response, "<services");
index 6989bf512fb702f2b6a3b32b15f803134b27c654..e45a249ad4e1f901075060451c6865a5fd54b585 100644 (file)
@@ -14,10 +14,10 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
-import org.opendaylight.controller.netconf.client.NetconfClient;
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
 import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
 import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
@@ -91,7 +91,7 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest {
     @Test
     public void testSecure() throws Exception {
         NetconfClientDispatcher dispatch = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup, 5000);
-        try (NetconfClient netconfClient = new NetconfClient("tls-client", tlsAddress, 4000, dispatch))  {
+        try (TestingNetconfClient netconfClient = new TestingNetconfClient("tls-client", tlsAddress, 4000, dispatch))  {
 
         }
     }
index 4ca9690211c87bccd6ee79ddc23985c191024653..c4bcb3b227f8c526362b5927c5b1b9b025448641 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMX
 import org.opendaylight.controller.config.yang.test.impl.TestImplModuleFactory;
 import org.opendaylight.controller.netconf.StubUserManager;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.client.NetconfClient;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
@@ -176,7 +176,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void testNetconfClientDemonstration() throws Exception {
-        try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, 4000, clientDispatcher)) {
+        try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", tcpAddress, 4000, clientDispatcher)) {
 
             Set<String> capabilitiesFromNetconfServer = netconfClient.getCapabilities();
             long sessionId = netconfClient.getSessionId();
@@ -191,8 +191,8 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void testTwoSessions() throws Exception {
-        try (NetconfClient netconfClient = new NetconfClient("1", tcpAddress, 10000, clientDispatcher)) {
-            try (NetconfClient netconfClient2 = new NetconfClient("2", tcpAddress, 10000, clientDispatcher)) {
+        try (TestingNetconfClient netconfClient = new TestingNetconfClient("1", tcpAddress, 10000, clientDispatcher))  {
+            try (TestingNetconfClient netconfClient2 = new TestingNetconfClient("2", tcpAddress, 10000, clientDispatcher)) {
             }
         }
     }
@@ -208,7 +208,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void rpcReplyContainsAllAttributesTest() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
             final String rpc = "<rpc message-id=\"5\" a=\"a\" b=\"44\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
                     + "<get/>" + "</rpc>";
             final Document doc = XmlUtil.readXmlToDocument(rpc);
@@ -236,7 +236,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void rpcReplyErrorContainsAllAttributesTest() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
             final String rpc = "<rpc message-id=\"1\" a=\"adada\" b=\"4\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
                     + "<commit/>" + "</rpc>";
             final Document doc = XmlUtil.readXmlToDocument(rpc);
@@ -260,7 +260,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
         transaction.commit();
 
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
             final String expectedNamespace = "urn:opendaylight:params:xml:ns:yang:controller:test:impl";
 
             final String rpc = "<rpc message-id=\"5\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
@@ -284,7 +284,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
     /*
     @Test
     public void testStartExi() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
 
 
             Document rpcReply = netconfClient.sendMessage(this.startExi)
@@ -311,7 +311,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void testCloseSession() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
 
             // edit config
             Document rpcReply = netconfClient.sendMessage(this.editConfig)
@@ -327,7 +327,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void testEditConfig() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
             // send edit_config.xml
             final Document rpcReply = netconfClient.sendMessage(this.editConfig).getDocument();
             assertIsOK(rpcReply);
@@ -336,7 +336,7 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void testValidate() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
             // begin transaction
             Document rpcReply = netconfClient.sendMessage(getConfigCandidate).getDocument();
             assertEquals("data", XmlElement.fromDomDocument(rpcReply).getOnlyChildElement().getName());
@@ -353,11 +353,11 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
         assertEquals("ok", XmlElement.fromDomDocument(rpcReply).getOnlyChildElement().getName());
     }
 
-    private Document assertGetConfigWorks(final NetconfClient netconfClient) throws InterruptedException, ExecutionException, TimeoutException {
+    private Document assertGetConfigWorks(final TestingNetconfClient netconfClient) throws InterruptedException, ExecutionException, TimeoutException {
         return assertGetConfigWorks(netconfClient, this.getConfig);
     }
 
-    private Document assertGetConfigWorks(final NetconfClient netconfClient, final NetconfMessage getConfigMessage)
+    private Document assertGetConfigWorks(final TestingNetconfClient netconfClient, final NetconfMessage getConfigMessage)
             throws InterruptedException, ExecutionException, TimeoutException {
         final NetconfMessage rpcReply = netconfClient.sendMessage(getConfigMessage);
         assertNotNull(rpcReply);
@@ -367,14 +367,14 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void testGetConfig() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
             assertGetConfigWorks(netconfClient);
         }
     }
 
     @Test
     public void createYangTestBasedOnYuma() throws Exception {
-        try (NetconfClient netconfClient = createSession(tcpAddress, "1")) {
+        try (TestingNetconfClient netconfClient = createSession(tcpAddress, "1")) {
             Document rpcReply = netconfClient.sendMessage(
                     XmlFileLoader.xmlFileToNetconfMessage("netconfMessages/editConfig_merge_yang-test.xml"))
                     .getDocument();
@@ -392,8 +392,8 @@ public class NetconfITTest extends AbstractNetconfConfigTest {
         }
     }
 
-    private NetconfClient createSession(final InetSocketAddress address, final String expected) throws Exception {
-        final NetconfClient netconfClient = new NetconfClient("test " + address.toString(), address, 5000, clientDispatcher);
+    private TestingNetconfClient createSession(final InetSocketAddress address, final String expected) throws Exception {
+        final TestingNetconfClient netconfClient = new TestingNetconfClient("test " + address.toString(), address, 5000, clientDispatcher);
         assertEquals(expected, Long.toString(netconfClient.getSessionId()));
         return netconfClient;
     }
index 4af66532a18ec2d8a8fc067f61a777905f4011a2..01b66ab0cff77732f1e6f5b488de8f1c88d79774 100644 (file)
@@ -33,7 +33,7 @@ import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
-import org.opendaylight.controller.netconf.client.NetconfClient;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
 import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
@@ -120,8 +120,8 @@ public class NetconfMonitoringITTest extends AbstractNetconfConfigTest {
 
     @Test
     public void testGetResponseFromMonitoring() throws Exception {
-        try (NetconfClient netconfClient = new NetconfClient("client-monitoring", tcpAddress, 4000, clientDispatcher)) {
-        try (NetconfClient netconfClient2 = new NetconfClient("client-monitoring2", tcpAddress, 4000, clientDispatcher)) {
+        try (TestingNetconfClient netconfClient = new TestingNetconfClient("client-monitoring", tcpAddress, 4000, clientDispatcher)) {
+        try (TestingNetconfClient netconfClient2 = new TestingNetconfClient("client-monitoring2", tcpAddress, 4000, clientDispatcher)) {
             NetconfMessage response = netconfClient.sendMessage(loadGetMessage());
             assertSessionElementsInResponse(response.getDocument(), 2);
         }
index c75adbba8d775845ef6623dbc9f296cedbe9f88a..18275ad78b0c53081fee38fdbfbffb7f34aa6867 100644 (file)
@@ -7,6 +7,22 @@
  */
 package org.opendaylight.controller.netconf.it.pax;
 
+import static org.junit.Assert.fail;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.streamBundle;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import javax.inject.Inject;
+import javax.xml.parsers.ParserConfigurationException;
+
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import io.netty.channel.nio.NioEventLoopGroup;
@@ -16,8 +32,9 @@ import org.junit.Test;
 import org.junit.matchers.JUnitMatchers;
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.client.NetconfClient;
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
+import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.ops4j.pax.exam.Configuration;
@@ -25,29 +42,15 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.options.DefaultCompositeOption;
 import org.ops4j.pax.exam.util.Filter;
-import org.w3c.dom.Document;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Constants;
 import org.xml.sax.SAXException;
 
-import javax.inject.Inject;
-import javax.xml.parsers.ParserConfigurationException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.InetSocketAddress;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeoutException;
 
-import static org.junit.Assert.fail;
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles;
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles;
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles;
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles;
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles;
-import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.systemPackages;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
 @Ignore
 @RunWith(PaxExam.class)
 public class IdentityRefNetconfTest {
@@ -71,7 +74,24 @@ public class IdentityRefNetconfTest {
                 loggingModules(),
                 mdSalCoreBundles(),
                 bindingAwareSalBundles(), configMinumumBundles(), baseModelBundles(), flowCapableModelBundles(),
-                junitAndMockitoBundles());
+                junitAndMockitoBundles(),
+
+                // Classes from test-jars bundled for pax-exam test
+                streamBundle(TinyBundles.bundle()
+                        .add(TestingNetconfClient.class)
+                        .add(XmlFileLoader.class)
+
+                        .add("/netconfMessages/editConfig_identities.xml",
+                                XmlFileLoader.class.getResource("/netconfMessages/editConfig_identities.xml"))
+                        .add("/netconfMessages/commit.xml",
+                                XmlFileLoader.class.getResource("/netconfMessages/commit.xml"))
+                        .add("/netconfMessages/getConfig.xml",
+                                XmlFileLoader.class.getResource("/netconfMessages/getConfig.xml"))
+
+                        .set(Constants.BUNDLE_SYMBOLICNAME, "TestingClient_bundle")
+                        .set(Constants.EXPORT_PACKAGE, "org.opendaylight.controller.netconf.client.test, " +
+                                "org.opendaylight.controller.netconf.util.test")
+                        .build(TinyBundles.withBnd())));
     }
 
     private Option loggingModules() {
@@ -89,29 +109,26 @@ public class IdentityRefNetconfTest {
 
     private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 18383);
 
-
     @Test
     public void testIdRef() throws Exception {
-        try {
-            Preconditions.checkNotNull(broker, "Controller not initialized");
-
-            NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup();
-            NetconfClientDispatcher clientDispatcher = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup,
-                    CLIENT_CONNECTION_TIMEOUT_MILLIS);
-
-            NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml");
-            NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml");
-            NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
-
-            try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) {
-                sendMessage(edit, netconfClient);
-                sendMessage(commit, netconfClient);
-                sendMessage(getConfig, netconfClient, "id-test",
-                        "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</afi>",
-                        "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</afi>",
-                        "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</safi>",
-                        "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</safi>");
-            }
+        Preconditions.checkNotNull(broker, "Controller not initialized");
+
+        NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup();
+        NetconfClientDispatcher clientDispatcher = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup,
+                CLIENT_CONNECTION_TIMEOUT_MILLIS);
+
+        NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml");
+        NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml");
+        NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml");
+
+        try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) {
+            sendMessage(edit, netconfClient);
+            sendMessage(commit, netconfClient);
+            sendMessage(getConfig, netconfClient, "id-test",
+                    "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</afi>",
+                    "<afi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</afi>",
+                    "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity2</safi>",
+                    "<safi xmlns:prefix=\"urn:opendaylight:params:xml:ns:yang:controller:config:test:types\">prefix:test-identity1</safi>");
 
             clientDispatcher.close();
         } catch (Exception e) {
@@ -119,8 +136,7 @@ public class IdentityRefNetconfTest {
         }
     }
 
-
-    private void sendMessage(NetconfMessage edit, NetconfClient netconfClient, String... containingResponse)
+    private void sendMessage(NetconfMessage edit, TestingNetconfClient netconfClient, String... containingResponse)
             throws ExecutionException, InterruptedException, TimeoutException {
         NetconfMessage response = netconfClient.sendRequest(edit).get();
         if (containingResponse == null) {
@@ -134,16 +150,6 @@ public class IdentityRefNetconfTest {
 
     public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException,
             ParserConfigurationException {
-        return new NetconfMessage(xmlFileToDocument(fileName));
-    }
-
-    public static Document xmlFileToDocument(final String fileName) throws IOException, SAXException,
-            ParserConfigurationException {
-        // TODO xml messages from netconf-util test-jar cannot be loaded here(in OSGi), since test jar is not a bundle
-        try (InputStream resourceAsStream = IdentityRefNetconfTest.class.getClassLoader().getResourceAsStream(fileName)) {
-            Preconditions.checkNotNull(resourceAsStream);
-            final Document doc = XmlUtil.readXmlToDocument(resourceAsStream);
-            return doc;
-        }
+        return XmlFileLoader.xmlFileToNetconfMessage(fileName);
     }
 }