X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fnetconf%2Fnetconf-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fit%2Fpax%2FIdentityRefNetconfTest.java;h=18275ad78b0c53081fee38fdbfbffb7f34aa6867;hb=6932c15f119da55b17ce4ad39236566bfed96ab3;hp=ee971a65ddc882bd11e7c0593f1b3f0168bcce99;hpb=88f3fac27f5dbc4043cdeadacaca34bd6f57c854;p=controller.git
diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java
index ee971a65dd..18275ad78b 100644
--- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java
+++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java
@@ -7,16 +7,34 @@
*/
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;
import org.junit.Assert;
+import org.junit.Ignore;
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;
@@ -24,29 +42,16 @@ 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 {
@@ -69,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() {
@@ -87,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",
- "prefix:test-identity1",
- "prefix:test-identity2",
- "prefix:test-identity2",
- "prefix:test-identity1");
- }
+ 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",
+ "prefix:test-identity1",
+ "prefix:test-identity2",
+ "prefix:test-identity2",
+ "prefix:test-identity1");
clientDispatcher.close();
} catch (Exception e) {
@@ -117,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) {
@@ -132,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);
}
}