<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>2.6.0-SNAPSHOT</version>
+ <version>3.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<properties>
<commons.opendaylight.version>1.12.0-SNAPSHOT</commons.opendaylight.version>
<controller.mdsal.version>1.9.0-SNAPSHOT</controller.mdsal.version>
- <config.version>0.10.0-SNAPSHOT</config.version>
- <mdsal.version>2.6.0-SNAPSHOT</mdsal.version>
- <mdsal.model.version>0.14.0-SNAPSHOT</mdsal.model.version>
+ <mdsal.version>3.0.1</mdsal.version>
<netconf.version>1.6.0-SNAPSHOT</netconf.version>
<netconf.connector.version>1.9.0-SNAPSHOT</netconf.connector.version>
</properties>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>2.0.10</version>
+ <version>2.1.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<type>xml</type>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>features-mdsal-model</artifactId>
- <version>${mdsal.model.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>features-netconf</artifactId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>2.0.10</version>
+ <version>2.1.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>2.6.0-SNAPSHOT</version>
+ <version>3.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-netconf-api" version="${project.version}">
- <feature version="[2.0.10,3)">odl-yangtools-parser-api</feature>
+ <feature version="[2.1,3)">odl-yangtools-parser-api</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-netconf-netty-util" version="${project.version}">
- <feature version="${karaf.version}">ssh</feature>
- <feature version="[3.1.0,4)">odl-netty-4</feature>
+ <feature version="[4,5)">odl-apache-sshd</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>2.6.0-SNAPSHOT</version>
+ <version>3.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<packaging>feature</packaging>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>odl-apache-sshd</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>odl-netconf-mapping-api</artifactId>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>odl-yangtools-codec</artifactId>
- <version>2.0.10</version>
+ <version>2.1.2</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<configfile finalname="etc/netconf.cfg">
mvn:org.opendaylight.netconf/netconf-util/${project.version}/cfg/config
</configfile>
- <feature version="[2.0.10,3)">odl-yangtools-codec</feature>
+ <feature version="[2.1,3)">odl-yangtools-codec</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odl-guava-23</artifactId>
+ <artifactId>odl-guava</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odl-jackson-2.8</artifactId>
- <version>3.1.3</version>
+ <artifactId>odl-jackson-2.9</artifactId>
+ <version>4.0.2</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-mdsal-apidocs" version="${project.version}">
- <feature version="[3.1.0,4)">odl-jackson-2.8</feature>
+ <feature version="[4,5)">odl-jackson-2.9</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>2.6.0-SNAPSHOT</version>
+ <version>3.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>2.0.10</version>
+ <version>2.1.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>2.6.0-SNAPSHOT</version>
+ <version>3.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>ietf-restconf</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>rfc7895</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>ietf-restconf-monitoring</artifactId>
<!-- TODO: Remove this when RESTCONF is converted to GSON -->
<dependency>
<groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odl-jackson-2.8</artifactId>
- <version>3.1.3</version>
+ <artifactId>odl-jackson-2.9</artifactId>
+ <version>4.0.2</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-restconf-common" version="${project.version}">
- <feature version="[3.1.0,4)">odl-karaf-feat-jetty</feature>
- <feature version="[3.1.0,4)">odl-jackson-2.8</feature>
- <feature version="[2.0.10,3)">odl-yangtools-export</feature>
+ <feature version="[4,5)">odl-karaf-feat-jetty</feature>
+ <feature version="[4,5)">odl-jackson-2.9</feature>
+ <feature version="[2.1,3)">odl-yangtools-export</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-restconf" version="${project.version}">
- <feature version="[3.1.0,4)">odl-jackson-2.8</feature>
+ <feature version="[4,5)">odl-jackson-2.9</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<artifactId>features-restconf-aggregator</artifactId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-netconf-${project.version}">
<feature name="odl-yanglib" version="${project.version}">
- <feature version="[3.1.0,4)">odl-karaf-feat-jetty</feature>
+ <feature version="[4,5)">odl-karaf-feat-jetty</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>karaf4-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.netconf</groupId>
* 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.netconf.callhome.protocol;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.annotations.VisibleForTesting;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoAcceptor;
import org.apache.sshd.common.io.IoServiceFactory;
-import org.apache.sshd.common.io.mina.MinaServiceFactory;
-import org.apache.sshd.common.io.nio2.Nio2ServiceFactory;
import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
+import org.apache.sshd.netty.NettyIoServiceFactory;
import org.opendaylight.netconf.callhome.protocol.CallHomeSessionContext.Factory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOG = LoggerFactory.getLogger(NetconfCallHomeServer.class);
- private final IoAcceptor acceptor;
- private final SshClient client;
private final CallHomeAuthorizationProvider authProvider;
- private final CallHomeSessionContext.Factory sessionFactory;
+ private final IoServiceFactory serviceFactory;
private final InetSocketAddress bindAddress;
private final StatusRecorder recorder;
+ private final Factory sessionFactory;
+ private final IoAcceptor acceptor;
+ private final SshClient client;
NetconfCallHomeServer(final SshClient sshClient, final CallHomeAuthorizationProvider authProvider,
final Factory factory, final InetSocketAddress socketAddress, final StatusRecorder recorder) {
- this.client = Preconditions.checkNotNull(sshClient);
- this.authProvider = Preconditions.checkNotNull(authProvider);
- this.sessionFactory = Preconditions.checkNotNull(factory);
+ this(sshClient, authProvider, factory, socketAddress, recorder,
+ new NettyIoServiceFactory(factory.getNettyGroup()));
+ }
+
+ @VisibleForTesting
+ NetconfCallHomeServer(final SshClient sshClient, final CallHomeAuthorizationProvider authProvider,
+ final Factory factory, final InetSocketAddress socketAddress, final StatusRecorder recorder,
+ final IoServiceFactory serviceFactory) {
+ this.client = requireNonNull(sshClient);
+ this.authProvider = requireNonNull(authProvider);
+ this.sessionFactory = requireNonNull(factory);
this.bindAddress = socketAddress;
this.recorder = recorder;
+ this.serviceFactory = requireNonNull(serviceFactory);
sshClient.setServerKeyVerifier(this);
sshClient.addSessionListener(createSessionListener());
- this.acceptor = createServiceFactory(sshClient).createAcceptor(new SessionFactory(sshClient));
- }
-
- private IoServiceFactory createServiceFactory(final SshClient sshClient) {
- try {
- return createMinaServiceFactory(sshClient);
- } catch (NoClassDefFoundError e) {
- LOG.warn("Mina is not available, defaulting to NIO.");
- return new Nio2ServiceFactory(sshClient, sshClient.getScheduledExecutorService(), false);
- }
+ acceptor = serviceFactory.createAcceptor(new SessionFactory(sshClient));
}
- protected IoServiceFactory createMinaServiceFactory(final SshClient sshClient) {
- return new MinaServiceFactory(sshClient, sshClient.getScheduledExecutorService(), false);
+ @VisibleForTesting
+ SshClient getClient() {
+ return client;
}
SessionListener createSessionListener() {
@Override
public void close() {
acceptor.close(true);
+ serviceFactory.close(true);
}
}
* 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.netconf.callhome.protocol;
import com.google.common.base.Optional;
+import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
-import io.netty.channel.local.LocalEventLoopGroup;
import io.netty.util.HashedWheelTimer;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
}
private static EventLoopGroup defaultNettyGroup() {
- return new LocalEventLoopGroup();
+ return new DefaultEventLoopGroup();
}
private static InetSocketAddress defaultBindAddress() {
* 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.netconf.callhome.protocol;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
+import java.io.IOException;
import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.io.IoInputStream;
private MinaSshNettyChannel instance;
@Before
- public void setup() {
+ public void setup() throws IOException {
IoReadFuture mockFuture = mock(IoReadFuture.class);
IoInputStream mockIn = mock(IoInputStream.class);
Mockito.doReturn(mockFuture).when(mockIn).read(any(Buffer.class));
IoWriteFuture mockWrFuture = mock(IoWriteFuture.class);
Mockito.doReturn(false).when(mockOut).isClosed();
Mockito.doReturn(false).when(mockOut).isClosing();
- Mockito.doReturn(mockWrFuture).when(mockOut).write(any(Buffer.class));
+ Mockito.doReturn(mockWrFuture).when(mockOut).writePacket(any(Buffer.class));
Mockito.doReturn(null).when(mockWrFuture).addListener(any());
Mockito.doReturn(mockFuture).when(mockFuture).addListener(Mockito.any());
package org.opendaylight.netconf.callhome.protocol;
import static org.junit.Assert.assertFalse;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.apache.sshd.common.io.IoServiceFactory;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.session.SessionListener;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+@RunWith(MockitoJUnitRunner.class)
public class NetconfCallHomeServerTest {
+ private static EventLoopGroup EVENT_LOOP_GROUP;
+ private static InetSocketAddress MOCK_ADDRESS;
+
private SshClient mockSshClient;
+ @Mock
private CallHomeAuthorizationProvider mockCallHomeAuthProv;
+ @Mock
private CallHomeAuthorization mockAuth;
+ @Mock
private CallHomeSessionContext.Factory mockFactory;
- private InetSocketAddress mockAddress;
+ @Mock
private ClientSession mockSession;
+ @Mock
private StatusRecorder mockStatusRecorder;
private NetconfCallHomeServer instance;
+ @BeforeClass
+ public static void beforeClass() {
+ EVENT_LOOP_GROUP = new NioEventLoopGroup();
+ MOCK_ADDRESS = InetSocketAddress.createUnresolved("127.0.0.1", 123);
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ EVENT_LOOP_GROUP.shutdownGracefully();
+ EVENT_LOOP_GROUP = null;
+ MOCK_ADDRESS = null;
+ }
+
@Before
public void setup() {
- mockSshClient = Mockito.spy(SshClient.setUpDefaultClient());
+ mockSshClient = spy(SshClient.setUpDefaultClient());
mockCallHomeAuthProv = mock(CallHomeAuthorizationProvider.class);
mockAuth = mock(CallHomeAuthorization.class);
mockFactory = mock(CallHomeSessionContext.Factory.class);
- mockAddress = InetSocketAddress.createUnresolved("1.2.3.4", 123);
mockSession = mock(ClientSession.class);
mockStatusRecorder = mock(StatusRecorder.class);
Map<String, String> props = new HashMap<>();
props.put("nio-workers", "1");
- Mockito.doReturn(props).when(mockSshClient).getProperties();
- Mockito.doReturn("test").when(mockSession).toString();
+ doReturn(props).when(mockSshClient).getProperties();
+ doReturn(EVENT_LOOP_GROUP).when(mockFactory).getNettyGroup();
instance = new NetconfCallHomeServer(
- mockSshClient, mockCallHomeAuthProv, mockFactory, mockAddress, mockStatusRecorder);
+ mockSshClient, mockCallHomeAuthProv, mockFactory, MOCK_ADDRESS, mockStatusRecorder);
}
@Test
for (int pass = 0; pass < evt.length; pass++) {
// given
AuthFuture mockAuthFuture = mock(AuthFuture.class);
- Mockito.doReturn(null).when(mockAuthFuture).addListener(any(SshFutureListener.class));
+ doReturn(null).when(mockAuthFuture).addListener(any(SshFutureListener.class));
CallHomeSessionContext mockContext = mock(CallHomeSessionContext.class);
- Mockito.doNothing().when(mockContext).openNetconfChannel();
- Mockito.doReturn(mockContext).when(mockSession).getAttribute(any(Session.AttributeKey.class));
+ doNothing().when(mockContext).openNetconfChannel();
+ doReturn(mockContext).when(mockSession).getAttribute(any(Session.AttributeKey.class));
SessionListener listener = instance.createSessionListener();
- Mockito.doReturn(mockAuthFuture).when(mockContext).authorize();
+ doReturn(mockAuthFuture).when(mockContext).authorize();
// when
listener.sessionEvent(mockSession, evt[pass]);
// then
ClientSessionImpl mockClientSession = mock(ClientSessionImpl.class);
Mockito.doReturn("test").when(mockClientSession).toString();
SocketAddress mockSocketAddr = mock(SocketAddress.class);
- Mockito.doReturn("testAddr").when(mockSocketAddr).toString();
PublicKey mockPublicKey = mock(PublicKey.class);
- Mockito.doReturn("test").when(mockAuth).toString();
Mockito.doReturn(true).when(mockAuth).isServerAllowed();
Mockito.doReturn("some-session-name").when(mockAuth).getSessionName();
assertFalse(instance.verifyServerKey(mockClientSession, mockSocketAddr, mockPublicKey));
}
- static class TestableCallHomeServer extends NetconfCallHomeServer {
- static IoServiceFactory minaServiceFactory;
-
- static SshClient factoryHook(final SshClient client, final IoServiceFactory minaFactory) {
- minaServiceFactory = minaFactory;
- return client;
- }
-
- SshClient client;
-
- TestableCallHomeServer(final SshClient sshClient, final CallHomeAuthorizationProvider authProvider,
- final CallHomeSessionContext.Factory factory, final InetSocketAddress socketAddress,
- final IoServiceFactory minaFactory, final StatusRecorder recorder) {
- super(factoryHook(sshClient, minaFactory), authProvider, factory, socketAddress, recorder);
- client = sshClient;
- }
-
- @Override
- protected IoServiceFactory createMinaServiceFactory(final SshClient sshClient) {
- return minaServiceFactory;
- }
- }
-
@Test
public void bindShouldStartTheClientAndBindTheAddress() throws IOException {
// given
IoServiceFactory mockMinaFactory = mock(IoServiceFactory.class);
Mockito.doReturn(mockAcceptor).when(mockMinaFactory).createAcceptor(any(IoHandler.class));
- Mockito.doReturn(mockAcceptor).when(mockMinaFactory).createAcceptor(any(IoHandler.class));
- Mockito.doNothing().when(mockAcceptor).bind(mockAddress);
- instance = new TestableCallHomeServer(
- mockSshClient, mockCallHomeAuthProv, mockFactory, mockAddress, mockMinaFactory, mockStatusRecorder);
+ Mockito.doNothing().when(mockAcceptor).bind(any(SocketAddress.class));
+ instance = new NetconfCallHomeServer(
+ mockSshClient, mockCallHomeAuthProv, mockFactory, MOCK_ADDRESS, mockStatusRecorder, mockMinaFactory);
// when
instance.bind();
// then
verify(mockSshClient, times(1)).start();
- verify(mockAcceptor, times(1)).bind(mockAddress);
+ verify(mockAcceptor, times(1)).bind(MOCK_ADDRESS);
}
}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
+import io.netty.channel.nio.NioEventLoopGroup;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Collection;
if (port > 0) {
builder.setBindAddress(new InetSocketAddress(port));
}
+ builder.setNettyGroup(new NioEventLoopGroup());
server = builder.build();
server.bind();
mountDispacher.createTopology();
<scope>test</scope>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
-->
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" a="64" id="a" message-id="101" xmlnx="a:b:c:d">
- <data>
- <top xmlns="urn:opendaylight:mdsal:mapping:test"/>
- </data>
-</rpc-reply>
\ No newline at end of file
+ <data/>
+</rpc-reply>
<argument ref="sessionIdProvider"/>
<argument value="${connection-timeout-millis}"/>
<argument ref="netconfMonitoringService"/>
- <argument><null/></argument><!--Base capabilities-->
</bean>
<bean id="serverChannelInitializer"
<artifactId>mockito-configuration</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-inet-types</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>sal-binding-api</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-inet-types</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc7895</artifactId>
</dependency>
<dependency>
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.addModuleInfos(Collections.singletonList(org.opendaylight.yang.gen.v1.urn.ietf.params
.xml.ns.netmod.notification.rev080714.$YangModuleInfoImpl.getInstance()));
- final Optional<SchemaContext> schemaContextOptional = moduleInfoBackedContext.tryToCreateSchemaContext();
- Preconditions.checkState(schemaContextOptional.isPresent());
- SchemaContext notificationsSchemaCtx = schemaContextOptional.get();
+ SchemaContext notificationsSchemaCtx = moduleInfoBackedContext.tryToCreateSchemaContext().get();
final JavassistUtils javassist = JavassistUtils.forClassPool(ClassPool.getDefault());
CODEC_REGISTRY = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(javassist));
this.dataBroker = getService(mountPoint, DOMDataBroker.class);
}
- private static <T extends DOMService> T getService(DOMMountPoint mountPoint, Class<T> service) {
+ private static <T extends DOMService> T getService(final DOMMountPoint mountPoint, final Class<T> service) {
final Optional<T> optional = mountPoint.getService(service);
Preconditions.checkState(optional.isPresent(), "Service not present on mount point: %s", service.getName());
return optional.get();
* @return ListenerRegistration
* @see DOMNotificationService#registerNotificationListener(DOMNotificationListener, SchemaPath...)
*/
- ListenerRegistration<DOMNotificationListener> registerNotificationListener(DOMNotificationListener listener,
- SchemaPath notificationPath) {
+ ListenerRegistration<DOMNotificationListener> registerNotificationListener(final DOMNotificationListener listener,
+ final SchemaPath notificationPath) {
return notificationService.registerNotificationListener(listener, notificationPath);
}
<dependencies>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
</dependency>
</dependencies>
</project>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
</dependency>
</dependencies>
</project>
<dependencies>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-inet-types</artifactId>
</dependency>
</dependencies>
</project>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<artifactId>protocol-framework</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
package org.opendaylight.netconf.client;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import io.netty.channel.Channel;
ChannelPromise promise = Mockito.mock(ChannelPromise.class);
doReturn(promise).when(chf).addListener(any(GenericFutureListener.class));
doReturn(thr).when(chf).cause();
+ doReturn(true).when(chf).isDone();
+ doReturn(false).when(chf).isSuccess();
Long timeout = 200L;
NetconfHelloMessageAdditionalHeader header =
package org.opendaylight.netconf.client;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import io.netty.channel.ChannelProgressivePromise;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop;
+import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.ssl.SslHandler;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
import org.opendaylight.netconf.api.xml.XmlUtil;
import org.opendaylight.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
+import org.opendaylight.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
doReturn("").when(ret).toString();
doReturn(future).when(ret).newPromise();
doReturn(future).when(ret).close();
- doReturn(future).when(ret).writeAndFlush(anyObject());
- doReturn(future).when(ret).writeAndFlush(anyObject(), anyObject());
+ doReturn(future).when(ret).writeAndFlush(any());
+ doReturn(future).when(ret).writeAndFlush(any(), any());
doReturn(true).when(ret).isOpen();
doReturn(pipeline).when(ret).pipeline();
doReturn("").when(pipeline).toString();
doReturn(handler).when(pipeline).replace(anyString(), anyString(), any(ChunkedFramingMechanismEncoder.class));
NetconfXMLToHelloMessageDecoder messageDecoder = new NetconfXMLToHelloMessageDecoder();
- doReturn(messageDecoder).when(pipeline).replace(anyString(), anyString(), any(NetconfXMLToMessageDecoder
- .class));
- doReturn(pipeline).when(pipeline).replace(any(ChannelHandler.class), anyString(), any(NetconfClientSession
- .class));
+ doReturn(messageDecoder).when(pipeline).replace(anyString(), anyString(),
+ any(NetconfXMLToMessageDecoder.class));
+ doReturn(pipeline).when(pipeline).replace(any(ChannelHandler.class), anyString(),
+ any(NetconfClientSession.class));
+ doReturn(null).when(pipeline).replace(anyString(), anyString(),
+ any(MessageToByteEncoder.class));
+ doReturn(null).when(pipeline).replace(anyString(), anyString(),
+ any(NetconfEXIToMessageDecoder.class));
return pipeline;
}
final EventLoop eventLoop = mock(EventLoop.class);
doReturn(eventLoop).when(channel).eventLoop();
doAnswer(invocation -> {
- invocation.getArgumentAt(0, Runnable.class).run();
+ invocation.<Runnable>getArgument(0).run();
return null;
}).when(eventLoop).execute(any(Runnable.class));
}
@Test
public void testNetconfClientSessionNegotiator() throws NetconfDocumentedException {
Promise<NetconfClientSession> promise = mock(Promise.class);
- doReturn(promise).when(promise).setSuccess(anyObject());
+ doReturn(promise).when(promise).setSuccess(any());
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
negotiator.channelActive(null);
Set<String> caps = Sets.newSet("a", "b");
NetconfHelloMessage helloServerMessage = NetconfHelloMessage.createServerHello(caps, 10);
negotiator.handleMessage(helloServerMessage);
- verify(promise).setSuccess(anyObject());
+ verify(promise).setSuccess(any());
}
@Test
public void testNegotiatorWhenChannelActiveHappenAfterHandleMessage() throws Exception {
Promise promise = mock(Promise.class);
doReturn(false).when(promise).isDone();
- doReturn(promise).when(promise).setSuccess(anyObject());
+ doReturn(promise).when(promise).setSuccess(any());
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
Set<String> caps = Sets.newSet("a", "b");
NetconfHelloMessage helloServerMessage = NetconfHelloMessage.createServerHello(caps, 10);
negotiator.handleMessage(helloServerMessage);
negotiator.channelActive(null);
- verify(promise).setSuccess(anyObject());
+ verify(promise).setSuccess(any());
}
public void testNetconfClientSessionNegotiatorWithEXI() throws Exception {
Promise<NetconfClientSession> promise = mock(Promise.class);
NetconfStartExiMessage exiMessage = NetconfStartExiMessage.create(EXIParameters.empty(), "msg-id");
- doReturn(promise).when(promise).setSuccess(anyObject());
+ doReturn(promise).when(promise).setSuccess(any());
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, exiMessage);
negotiator.channelActive(null);
NetconfHelloMessage message = NetconfHelloMessage.createServerHello(caps, 10);
doAnswer(invocationOnMock -> {
- channelInboundHandlerAdapter = (ChannelInboundHandlerAdapter) invocationOnMock.getArguments()[2];
+ channelInboundHandlerAdapter = invocationOnMock.getArgument(2);
return null;
}).when(pipeline).addAfter(anyString(), anyString(), any(ChannelHandler.class));
Document expectedResult = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc-reply_ok.xml");
channelInboundHandlerAdapter.channelRead(handlerContext, new NetconfMessage(expectedResult));
- verify(promise).setSuccess(anyObject());
+ verify(promise).setSuccess(any());
// two calls for exiMessage, 2 for hello message
verify(pipeline, times(4)).replace(anyString(), anyString(), any(ChannelHandler.class));
@Test
public void testNetconfClientSessionNegotiatorGetCached() throws Exception {
Promise promise = mock(Promise.class);
- doReturn(promise).when(promise).setSuccess(anyObject());
+ doReturn(promise).when(promise).setSuccess(any());
NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
final EventLoop eventLoop = mock(EventLoop.class);
doReturn(eventLoop).when(channel).eventLoop();
doAnswer(invocation -> {
- invocation.getArgumentAt(0, Runnable.class).run();
+ invocation.<Runnable>getArgument(0).run();
return null;
}).when(eventLoop).execute(any(Runnable.class));
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
netconfUpdateDeviceCommand.execute();
- verify(netconfCommands, times(1)).updateDevice(anyString(), anyString(), anyString(),
+ verify(netconfCommands, times(1)).updateDevice(isNull(), isNull(), isNull(),
hashMapArgumentCaptor.capture());
assertTrue(hashMapArgumentCaptor.getValue().containsKey(NetconfConsoleConstants.NETCONF_IP));
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class NetconfServerSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfHelloMessage,
NetconfServerSession, NetconfServerSessionListener> {
private final NetconfOperationServiceFactory aggregatedOpService;
private final long connectionTimeoutMillis;
private final NetconfMonitoringService monitoringService;
- private static final Logger LOG = LoggerFactory.getLogger(NetconfServerSessionNegotiatorFactory.class);
private final Set<String> baseCapabilities;
+ public NetconfServerSessionNegotiatorFactory(final Timer timer,
+ final NetconfOperationServiceFactory netconfOperationProvider,
+ final SessionIdProvider idProvider, final long connectionTimeoutMillis,
+ final NetconfMonitoringService monitoringService) {
+ this(timer, netconfOperationProvider, idProvider, connectionTimeoutMillis, monitoringService, null);
+ }
+
public NetconfServerSessionNegotiatorFactory(final Timer timer,
final NetconfOperationServiceFactory netconfOperationProvider,
final SessionIdProvider idProvider, final long connectionTimeoutMillis,
baseCapabilities);
}
-
private static ImmutableSet<String> validateBaseCapabilities(final Set<String> baseCapabilities) {
// Check base capabilities to be supported by the server
final Sets.SetView<String> unknownBaseCaps = Sets.difference(baseCapabilities, DEFAULT_BASE_CAPABILITIES);
final NetconfOperationRouter operationRouter =
new NetconfOperationRouterImpl(service, monitoringService, netconfSessionIdForReporting);
return new NetconfServerSessionListener(operationRouter, monitoringService, service);
-
}
protected NetconfOperationService getOperationServiceForAddress(final String netconfSessionIdForReporting,
public static Set<String> transformCapabilities(final Capabilities capabilities) {
return Sets.newHashSet(Collections2.transform(capabilities.getCapability(), Uri::getValue));
}
-
}
package org.opendaylight.netconf.impl;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import io.netty.channel.embedded.EmbeddedChannel;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
-import org.hamcrest.CustomMatcher;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.netconf.api.NetconfMessage;
verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.NOTIFICATION)));
}
- private CustomMatcher<SessionEvent> sessionEventIs(final SessionEvent.Type type) {
- return new CustomMatcher<SessionEvent>(type.name()) {
- @Override
- public boolean matches(final Object item) {
- if (!(item instanceof SessionEvent)) {
- return false;
- }
- final SessionEvent e = (SessionEvent) item;
- return e.getType().equals(type) && e.getSession().equals(session);
- }
- };
+ private ArgumentMatcher<SessionEvent> sessionEventIs(final SessionEvent.Type type) {
+ return event -> event.getType().equals(type) && event.getSession().equals(session);
}
-
}
package org.opendaylight.netconf.impl.mapping.operations;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
final EventLoop eventLoop = mock(EventLoop.class);
doReturn(eventLoop).when(channel).eventLoop();
doAnswer(invocation -> {
- invocation.getArgumentAt(0, Runnable.class).run();
+ invocation.<Runnable>getArgument(0).run();
return null;
}).when(eventLoop).execute(any(Runnable.class));
doReturn(true).when(eventLoop).inEventLoop();
final ChannelPromise sendFuture = mock(ChannelPromise.class);
doAnswer(invocation -> {
- invocation.getArgumentAt(0, GenericFutureListener.class).operationComplete(sendFuture);
+ invocation.<GenericFutureListener>getArgument(0).operationComplete(sendFuture);
return null;
}).when(sendFuture).addListener(any(GenericFutureListener.class));
doReturn(sendFuture).when(channel).newPromise();
package org.opendaylight.netconf.impl.osgi;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
private ServiceReference<?> reference;
@Mock
private ServiceRegistration<?> registration;
+ @Mock
+ private ServiceRegistration<?> monRegistration;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doReturn(filter).when(bundle).createFilter(anyString());
- doNothing().when(bundle).addServiceListener(any(ServiceListener.class), anyString());
+ doNothing().when(bundle).addServiceListener(any(ServiceListener.class), any());
ServiceReference<?>[] refs = {};
- doReturn(refs).when(bundle).getServiceReferences(anyString(), anyString());
- doReturn(Arrays.asList(refs)).when(bundle).getServiceReferences(any(Class.class), anyString());
+ doReturn(refs).when(bundle).getServiceReferences(anyString(), any());
+ doReturn(Arrays.asList(refs)).when(bundle).getServiceReferences(any(Class.class), any());
doReturn("").when(bundle).getProperty(anyString());
+ doReturn(monRegistration).when(bundle).registerService(any(Class.class),
+ any(NetconfMonitoringServiceImpl.class), any(Dictionary.class));
+ doNothing().when(monRegistration).unregister();
doReturn(registration).when(bundle).registerService(any(Class.class),
any(AggregatedNetconfOperationServiceFactory.class), any(Dictionary.class));
doNothing().when(registration).unregister();
public void testStart() throws Exception {
NetconfImplActivator activator = new NetconfImplActivator();
activator.start(bundle);
- verify(bundle).registerService(any(Class.class), any(AggregatedNetconfOperationServiceFactory.class),
+ verify(bundle).registerService(any(Class.class), any(NetconfMonitoringServiceImpl.class),
any(Dictionary.class));
activator.stop(bundle);
}
<artifactId>mockito-configuration</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-inet-types</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
package org.opendaylight.netconf.monitoring.osgi;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
doNothing().when(context).addServiceListener(any(ServiceListener.class), anyString());
ServiceReference<?>[] refs = new ServiceReference[2];
doReturn(Arrays.asList(refs)).when(context).getServiceReferences(any(Class.class), anyString());
- doReturn(refs).when(context).getServiceReferences(anyString(), anyString());
+ doReturn(refs).when(context).getServiceReferences(anyString(), any());
doNothing().when(context).removeServiceListener(any(ServiceListener.class));
}
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
- <version>1.6.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-netty</artifactId>
</dependency>
<dependency>
<groupId>com.siemens.ct.exi</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
+import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Deque;
import java.util.LinkedList;
if (LOG.isTraceEnabled()) {
LOG.trace("Writing request on channel: {}, message: {}", ctx.channel(), byteBufToString(byteBufMsg));
}
- asyncIn.write(toBuffer(byteBufMsg)).addListener(future -> {
+ asyncIn.writePacket(toBuffer(byteBufMsg)).addListener(future -> {
// synchronized block due to deadlock that happens on ssh window resize
// writes and pending writes would lock the underlyinch channel session
// window resize write would try to write the message on an already locked channelSession,
writePendingIfAny();
});
- } catch (final WritePendingException e) {
-
+ } catch (final IOException | WritePendingException e) {
if (!wasPending) {
queueRequest(ctx, byteBufMsg, promise);
}
package org.opendaylight.netconf.nettyutil;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
doReturn(eventLoop).when(channel).eventLoop();
doAnswer(invocation -> {
- invocation.getArgumentAt(0, Runnable.class).run();
+ invocation.<Runnable>getArgument(0).run();
return null;
}).when(eventLoop).execute(any(Runnable.class));
* 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.netconf.nettyutil.handler.ssh.client;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.AuthenticationHandler;
@Override
public void onSuccess(final SshFutureListener<IoReadFuture> result) {
doReturn(new IllegalStateException()).when(mockedReadFuture).getException();
- doReturn(mockedReadFuture).when(mockedReadFuture)
- .removeListener(Matchers.any());
+ doReturn(mockedReadFuture).when(mockedReadFuture).removeListener(any());
doReturn(true).when(asyncOut).isClosing();
doReturn(true).when(asyncOut).isClosed();
result.operationComplete(mockedReadFuture);
@Override
public void onSuccess(final SshFutureListener<IoReadFuture> result) {
doReturn(new IllegalStateException()).when(mockedReadFuture).getException();
- doReturn(mockedReadFuture).when(mockedReadFuture)
- .removeListener(Matchers.any());
+ doReturn(mockedReadFuture).when(mockedReadFuture).removeListener(any());
result.operationComplete(mockedReadFuture);
}
}, MoreExecutors.directExecutor());
final IoInputStream asyncOut = getMockedIoInputStream();
final IoOutputStream asyncIn = getMockedIoOutputStream();
- final IoWriteFuture ioWriteFuture = asyncIn.write(null);
+ final IoWriteFuture ioWriteFuture = asyncIn.writePacket(new ByteArrayBuffer());
Futures.addCallback(stubAddListener(ioWriteFuture), new SuccessFutureListener<IoWriteFuture>() {
@Override
final IoInputStream asyncOut = getMockedIoInputStream();
final IoOutputStream asyncIn = getMockedIoOutputStream();
- final IoWriteFuture ioWriteFuture = asyncIn.write(null);
+ final IoWriteFuture ioWriteFuture = asyncIn.writePacket(new ByteArrayBuffer());
final ChannelSubsystem subsystemChannel = getMockedSubsystemChannel(asyncOut, asyncIn);
final ClientSession sshSession = getMockedSshSession(subsystemChannel);
final ChannelPromise secondWritePromise = getMockedPromise();
// now make write throw pending exception
- doThrow(org.apache.sshd.common.io.WritePendingException.class).when(asyncIn).write(any(Buffer.class));
+ doThrow(org.apache.sshd.common.io.WritePendingException.class).when(asyncIn).writePacket(any(Buffer.class));
asyncSshHandler.write(ctx, Unpooled.copiedBuffer(new byte[]{0, 1, 2, 3, 4, 5}), secondWritePromise);
- doReturn(ioWriteFuture).when(asyncIn).write(any(Buffer.class));
+ doReturn(ioWriteFuture).when(asyncIn).writePacket(any(Buffer.class));
verifyZeroInteractions(firstWritePromise, secondWritePromise);
final IoInputStream asyncOut = getMockedIoInputStream();
final IoOutputStream asyncIn = getMockedIoOutputStream();
- final IoWriteFuture ioWriteFuture = asyncIn.write(null);
+ final IoWriteFuture ioWriteFuture = asyncIn.writePacket(new ByteArrayBuffer());
final ChannelSubsystem subsystemChannel = getMockedSubsystemChannel(asyncOut, asyncIn);
final ClientSession sshSession = getMockedSshSession(subsystemChannel);
final ChannelPromise secondWritePromise = getMockedPromise();
// now make write throw pending exception
- doThrow(org.apache.sshd.common.io.WritePendingException.class).when(asyncIn).write(any(Buffer.class));
+ doThrow(org.apache.sshd.common.io.WritePendingException.class).when(asyncIn).writePacket(any(Buffer.class));
for (int i = 0; i < 1001; i++) {
asyncSshHandler.write(ctx, Unpooled.copiedBuffer(new byte[]{0, 1, 2, 3, 4, 5}), secondWritePromise);
}
return subsystemChannel;
}
- private static IoOutputStream getMockedIoOutputStream() {
+ private static IoOutputStream getMockedIoOutputStream() throws IOException {
final IoOutputStream mock = mock(IoOutputStream.class);
final IoWriteFuture ioWriteFuture = mock(IoWriteFuture.class);
- doReturn(ioWriteFuture).when(ioWriteFuture).addListener(Matchers.any());
+ doReturn(ioWriteFuture).when(ioWriteFuture).addListener(any());
doReturn(true).when(ioWriteFuture).isWritten();
Futures.addCallback(stubAddListener(ioWriteFuture), new SuccessFutureListener<IoWriteFuture>() {
}
}, MoreExecutors.directExecutor());
- doReturn(ioWriteFuture).when(mock).write(any(Buffer.class));
+ doReturn(ioWriteFuture).when(mock).writePacket(any(Buffer.class));
doReturn(false).when(mock).isClosed();
doReturn(false).when(mock).isClosing();
return mock;
final IoInputStream mock = mock(IoInputStream.class);
final IoReadFuture ioReadFuture = mock(IoReadFuture.class);
doReturn(null).when(ioReadFuture).getException();
- doReturn(ioReadFuture).when(ioReadFuture).removeListener(Matchers.any());
+ doReturn(ioReadFuture).when(ioReadFuture).removeListener(any());
+ doReturn(ioReadFuture).when(mock).read(any());
doReturn(5).when(ioReadFuture).getRead();
doReturn(new ByteArrayBuffer(new byte[]{0, 1, 2, 3, 4})).when(ioReadFuture).getBuffer();
- doReturn(ioReadFuture).when(ioReadFuture).addListener(Matchers.any());
+ doReturn(ioReadFuture).when(ioReadFuture).addListener(any());
// Always success for read
Futures.addCallback(stubAddListener(ioReadFuture), new SuccessFutureListener<IoReadFuture>() {
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
* 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.netconf.notifications.impl.ops;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import java.io.IOException;
import java.util.Collections;
import java.util.Date;
+import java.util.Optional;
import javassist.ClassPool;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMResult;
import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
public final class NotificationsTransformUtil {
-
- private static final Logger LOG = LoggerFactory.getLogger(NotificationsTransformUtil.class);
-
- private NotificationsTransformUtil() {}
-
static final SchemaContext NOTIFICATIONS_SCHEMA_CTX;
static final BindingNormalizedNodeCodecRegistry CODEC_REGISTRY;
static final RpcDefinition CREATE_SUBSCRIPTION_RPC;
static {
-
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.addModuleInfos(Collections.singletonList($YangModuleInfoImpl.getInstance()));
moduleInfoBackedContext.addModuleInfos(Collections.singletonList(org.opendaylight.yang.gen.v1.urn.ietf.params
NOTIFICATIONS_SCHEMA_CTX));
}
+ private NotificationsTransformUtil() {
+
+ }
+
@SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Unrecognised NullableDecl")
private static RpcDefinition findCreateSubscriptionRpc() {
return Iterables.getFirst(Collections2.filter(NOTIFICATIONS_SCHEMA_CTX.getOperations(),
/**
* Transform base notification for capabilities into NetconfNotification.
*/
- public static NetconfNotification transform(final Notification notification, SchemaPath path) {
- return transform(notification, Optional.absent(), path);
+ public static NetconfNotification transform(final Notification notification, final SchemaPath path) {
+ return transform(notification, Optional.empty(), path);
}
- public static NetconfNotification transform(final Notification notification,
- final Date eventTime, SchemaPath path) {
- return transform(notification, Optional.fromNullable(eventTime), path);
+ public static NetconfNotification transform(final Notification notification, final Date eventTime,
+ final SchemaPath path) {
+ return transform(notification, Optional.ofNullable(eventTime), path);
}
- private static NetconfNotification transform(final Notification notification,
- final Optional<Date> eventTime, SchemaPath path) {
+ private static NetconfNotification transform(final Notification notification, final Optional<Date> eventTime,
+ final SchemaPath path) {
final ContainerNode containerNode = CODEC_REGISTRY.toNormalizedNodeNotification(notification);
final DOMResult result = new DOMResult(XmlUtil.newDocument());
try {
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>0.14.0-SNAPSHOT</version>
+ <version>3.0.1</version>
<relativePath/>
</parent>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-inet-types</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
* 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.netconf.ssh;
import com.google.common.base.Preconditions;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.io.IoInputStream;
import org.apache.sshd.common.io.IoOutputStream;
-import org.apache.sshd.server.AsyncCommand;
-import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
import org.apache.sshd.server.SessionAware;
+import org.apache.sshd.server.command.AsyncCommand;
+import org.apache.sshd.server.command.Command;
import org.apache.sshd.server.session.ServerSession;
import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
import org.slf4j.Logger;
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.util.Timeout;
+import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.SettableFuture;
private final ExceptionMapper<DOMRpcException> domRpcExceptionMapper =
new ExceptionMapper<DOMRpcException>("invokeRpc", DOMRpcException.class) {
@Override
- protected DOMRpcException newWithCause(String message, Throwable cause) {
+ protected DOMRpcException newWithCause(final String message, final Throwable cause) {
return new ClusteringRpcException(id + ": Exception during remote rpc invocation.", cause);
}
};
return;
}
- final Collection<RpcError> errors = ((InvokeRpcMessageReply) response).getRpcErrors();
+ final Collection<? extends RpcError> errors = ((InvokeRpcMessageReply) response).getRpcErrors();
final NormalizedNodeMessage normalizedNodeMessageResult =
((InvokeRpcMessageReply) response).getNormalizedNodeMessage();
final DOMRpcResult result;
if (normalizedNodeMessageResult == null) {
- result = new DefaultDOMRpcResult(errors);
+ result = new DefaultDOMRpcResult(ImmutableList.copyOf(errors));
} else {
result = new DefaultDOMRpcResult(normalizedNodeMessageResult.getNode(), errors);
}
private static final long serialVersionUID = 1L;
@SuppressFBWarnings("SE_BAD_FIELD")
- private final Collection<RpcError> rpcErrors;
+ private final Collection<? extends RpcError> rpcErrors;
private final NormalizedNodeMessage normalizedNodeMessage;
public InvokeRpcMessageReply(@Nullable final NormalizedNodeMessage normalizedNodeMessage,
- @Nonnull final Collection<RpcError> rpcErrors) {
+ @Nonnull final Collection<? extends RpcError> rpcErrors) {
this.normalizedNodeMessage = normalizedNodeMessage;
this.rpcErrors = Objects.requireNonNull(rpcErrors);
}
}
@Nonnull
- public Collection<RpcError> getRpcErrors() {
+ public Collection<? extends RpcError> getRpcErrors() {
return rpcErrors;
}
}
@Override
- public void writeExternal(ObjectOutput out) throws IOException {
+ public void writeExternal(final ObjectOutput out) throws IOException {
out.writeInt(invokeRpcMessageReply.getRpcErrors().size());
for (final RpcError rpcError : invokeRpcMessageReply.getRpcErrors()) {
out.writeObject(rpcError);
}
@Override
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
final int size = in.readInt();
final Collection<RpcError> rpcErrors = new LinkedList<>();
for (int i = 0; i < size; i++) {
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
assertEquals(result.getResult(), actual.getResult());
assertEquals(result.getErrors().size(), actual.getErrors().size());
- Iterator<RpcError> iter1 = result.getErrors().iterator();
- Iterator<RpcError> iter2 = actual.getErrors().iterator();
+ Iterator<? extends RpcError> iter1 = result.getErrors().iterator();
+ Iterator<? extends RpcError> iter2 = actual.getErrors().iterator();
while (iter1.hasNext() && iter2.hasNext()) {
RpcError err1 = iter1.next();
RpcError err2 = iter2.next();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.ArgumentCaptor;
-import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
return slaveRef;
}
- private void initializeMaster(List<SourceIdentifier> sourceIdentifiers) {
+ private void initializeMaster(final List<SourceIdentifier> sourceIdentifiers) {
masterRef.tell(new CreateInitialMasterActorData(mockDOMDataBroker, sourceIdentifiers,
mockDOMRpcService), testKit.getRef());
}
private static PotentialSchemaSource<?> withSourceId(final SourceIdentifier identifier) {
- return argThat(new ArgumentMatcher<PotentialSchemaSource<?>>() {
- @Override
- public boolean matches(final Object argument) {
- final PotentialSchemaSource<?> potentialSchemaSource = (PotentialSchemaSource<?>) argument;
- return identifier.equals(potentialSchemaSource.getSourceIdentifier());
- }
- });
+ return argThat(argument -> identifier.equals(argument.getSourceIdentifier()));
}
private static String convertStreamToString(final InputStream is) {
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
final DataObjectModification<Node> dataObjectModification1 = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification1).getModificationType();
doReturn(node1).when(dataObjectModification1).getDataAfter();
- doReturn(new InstanceIdentifier.IdentifiableItem<>(Node.class, new NodeKey(nodeId1)))
+ doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId1)))
.when(dataObjectModification1).getIdentifier();
final NetconfNode netconfNode2 = new NetconfNodeBuilder()
final DataObjectModification<Node> dataObjectModification2 = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification2).getModificationType();
doReturn(node2).when(dataObjectModification2).getDataAfter();
- doReturn(new InstanceIdentifier.IdentifiableItem<>(Node.class, new NodeKey(nodeId2)))
+ doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId2)))
.when(dataObjectModification2).getIdentifier();
final NetconfTopologyContext mockContext1 = mock(NetconfTopologyContext.class);
final DataObjectModification<Node> dataObjectModification = mock(DataObjectModification.class);
doReturn(WRITE).when(dataObjectModification).getModificationType();
doReturn(node).when(dataObjectModification).getDataAfter();
- doReturn(new InstanceIdentifier.IdentifiableItem<>(Node.class, new NodeKey(nodeId)))
+ doReturn(InstanceIdentifier.IdentifiableItem.of(Node.class, new NodeKey(nodeId)))
.when(dataObjectModification).getIdentifier();
final NetconfTopologyContext mockContext = mock(NetconfTopologyContext.class);
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<artifactId>ietf-netconf-notifications</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc7895</artifactId>
</dependency>
<dependency>
<artifactId>yang-data-codec-xml</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-inet-types</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-legacy</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.NoOpListenerRegistration;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
listener.onRpcAvailable(Collections2.transform(schemaContext.getOperations(),
input -> DOMRpcIdentifier.create(input.getPath())));
- return new NoOpListenerRegistration<>(listener);
- }
-
- private static final class NoOpListenerRegistration<T extends DOMRpcAvailabilityListener>
- implements ListenerRegistration<T> {
- private final T listener;
-
- NoOpListenerRegistration(final T listener) {
- this.listener = requireNonNull(listener);
- }
-
- @Override
- public T getInstance() {
- return listener;
- }
-
- @Override
- public void close() {
- // NOOP, no rpcs appear and disappear in this implementation
- }
+ // NOOP, no rpcs appear and disappear in this implementation
+ return NoOpListenerRegistration.of(listener);
}
}
package org.opendaylight.netconf.sal.connect.netconf;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyCollectionOf;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyCollectionOf;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
device.onRemoteSessionUp(sessionCaps, listener);
Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(
- any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class),
- any(DOMActionService.class));
+ any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class), isNull());
Mockito.verify(schemaFactory, times(2)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
}
device.onRemoteSessionUp(sessionCaps, listener);
Mockito.verify(facade, Mockito.timeout(5000)).onDeviceConnected(
- any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class),
- any(DOMActionService.class));
+ any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class), isNull());
Mockito.verify(schemaFactory, times(1)).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
}
verify(schemaContextProviderFactory, timeout(5000)).createSchemaContext(any(Collection.class));
verify(facade, timeout(5000)).onDeviceConnected(
any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class),
- any(DOMActionService.class));
+ isNull());
device.onRemoteSessionDown();
verify(facade, timeout(5000)).onDeviceDisconnected();
verify(schemaContextProviderFactory, timeout(5000).times(2)).createSchemaContext(any(Collection.class));
verify(facade, timeout(5000).times(2)).onDeviceConnected(
any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class),
- any(DOMActionService.class));
+ isNull());
}
@Test
final ArgumentCaptor<NetconfSessionPreferences> argument =
ArgumentCaptor.forClass(NetconfSessionPreferences.class);
verify(facade, timeout(5000))
- .onDeviceConnected(any(SchemaContext.class), argument.capture(), any(DOMRpcService.class),
- any(DOMActionService.class));
+ .onDeviceConnected(any(SchemaContext.class), argument.capture(), any(DOMRpcService.class), isNull());
final NetconfDeviceCapabilities netconfDeviceCaps = argument.getValue().getNetconfDeviceCapabilities();
netconfDeviceCaps.getResolvedCapabilities()
package org.opendaylight.netconf.sal.connect.netconf;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
device.onNotification(netconfMessage);
- verify(facade).onNotification(any(DOMNotification.class));
+ verify(facade).onNotification(isNull());
device.onRemoteSessionDown();
verify(facade).onDeviceDisconnected();
*/
package org.opendaylight.netconf.sal.connect.netconf.sal;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
final DOMRpcResult result = new DefaultDOMRpcResult(Builders.containerBuilder().withNodeIdentifier(
new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME)).build());
+ doReturn(Futures.immediateCheckedFuture(result))
+ .when(deviceRpc).invokeRpc(any(SchemaPath.class), isNull());
+
doReturn(Futures.immediateCheckedFuture(result))
.when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
verify(underlyingSalFacade).onDeviceConnected(
- any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class), any());
+ isNull(), isNull(), any(DOMRpcService.class), isNull());
verify(deviceRpc, timeout(15000).times(5)).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
}
keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
- verify(underlyingSalFacade).onDeviceConnected(
- any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class), any());
+ verify(underlyingSalFacade).onDeviceConnected(isNull(), isNull(), any(DOMRpcService.class), isNull());
// Should disconnect the session
verify(listener, timeout(15000).times(1)).disconnect();
keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
- verify(underlyingSalFacade).onDeviceConnected(
- any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class), any());
+ verify(underlyingSalFacade).onDeviceConnected(isNull(), isNull(), any(DOMRpcService.class), isNull());
+
// Shouldn't disconnect the session
verify(listener, times(0)).disconnect();
invocationOnMock -> {
proxyRpc = (DOMRpcService) invocationOnMock.getArguments()[2];
return null;
- }).when(underlyingSalFacade).onDeviceConnected(
- any(SchemaContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class), any());
+ }).when(underlyingSalFacade).onDeviceConnected(isNull(), isNull(), any(DOMRpcService.class), isNull());
doReturn(Futures.immediateFailedCheckedFuture(new IllegalStateException("illegal-state")))
.when(deviceRpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
package org.opendaylight.netconf.sal.connect.netconf.sal;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
verify(mountInstance, times(1)).onTopologyDeviceConnected(eq(schemaContext),
any(DOMDataBroker.class), eq(deviceRpc), any(NetconfDeviceNotificationService.class),
- any(DOMActionService.class));
+ isNull());
verify(netconfDeviceTopologyAdapter,
times(1)).updateDeviceData(true, netconfSessionPreferences.getNetconfDeviceCapabilities());
}
package org.opendaylight.netconf.sal.connect.netconf.sal;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
verify(txChain, times(2)).newWriteOnlyTransaction();
verify(writeTx, times(1))
- .put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(NetconfNode.class));
+ .put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class));
adapter.close();
adapter = new NetconfDeviceTopologyAdapter(id, transactionChain); //not a mock
verify(txChain, times(2)).newWriteOnlyTransaction();
verify(writeTx, times(1))
- .put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(NetconfNode.class));
+ .put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class));
verify(writeTx, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class));
}
package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.inOrder;
@Test
public void testDiscardChanges() throws InterruptedException {
+ doReturn(Futures.immediateCheckedFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null)))
+ .when(rpc).invokeRpc(any(SchemaPath.class), isNull());
+
final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(SchemaContext.class)),
false);
try {
inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME),
NetconfMessageTransformUtil.COMMIT_RPC_CONTENT);
inOrder.verify(rpc).invokeRpc(eq(toPath(NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_QNAME)),
- any(NormalizedNode.class));
+ isNull());
inOrder.verify(rpc).invokeRpc(toPath(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME),
NetconfBaseOps.getUnLockContent(NETCONF_CANDIDATE_QNAME));
return;
@Test
public void testListenerCancellation() throws Exception {
doReturn(Futures.immediateCheckedFuture(new DefaultDOMRpcResult((NormalizedNode<?, ?>) null)))
- .when(rpc).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ .when(rpc).invokeRpc(any(SchemaPath.class), isNull());
final WriteCandidateTx tx = new WriteCandidateTx(
id, new NetconfBaseOps(rpc, BaseSchema.BASE_NETCONF_CTX.getSchemaContext()), false);
final TxListener listener = mock(TxListener.class);
package org.opendaylight.netconf.sal.connect.netconf.util;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.List;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
}
}
- private static class NetconfMessageMatcher extends BaseMatcher<NetconfMessage> {
+ private static class NetconfMessageMatcher implements ArgumentMatcher<NetconfMessage> {
private final Document expected;
}
@Override
- public boolean matches(final Object item) {
- if (!(item instanceof NetconfMessage)) {
- return false;
- }
- final NetconfMessage message = (NetconfMessage) item;
+ public boolean matches(final NetconfMessage message) {
final Document actualDoc = removeAttrs(message.getDocument());
actualDoc.normalizeDocument();
expected.normalizeDocument();
return diff.similar();
}
- @Override
- public void describeTo(final Description description) {
- description.appendText(XmlUtil.toString(expected));
- }
-
private static Document removeAttrs(final Document input) {
final Document copy = XmlUtil.newDocument();
copy.appendChild(copy.importNode(input.getDocumentElement(), true));
<artifactId>netconf-client</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc7895</artifactId>
</dependency>
<dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
- <version>2.0.10</version>
+ <version>2.1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
* Constructs an instance with the given RpcErrors.
*/
public RestconfDocumentedException(final String message, final Throwable cause,
- final Collection<RpcError> rpcErrors) {
+ final Collection<? extends RpcError> rpcErrors) {
this(message, cause, convertToRestconfErrors(rpcErrors));
}
status = null;
}
- private static List<RestconfError> convertToRestconfErrors(final Collection<RpcError> rpcErrors) {
+ private static List<RestconfError> convertToRestconfErrors(final Collection<? extends RpcError> rpcErrors) {
final List<RestconfError> errorList = Lists.newArrayList();
if (rpcErrors != null) {
for (RpcError rpcError : rpcErrors) {
<dependencies>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
</dependency>
</dependencies>
</project>
<dependencies>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
</dependency>
</dependencies>
</project>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.glassfish.jersey.bundles.repackaged</groupId>
<artifactId>jersey-guava</artifactId>
- <version>2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>ietf-restconf</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types-2013-07-15</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>yang-model-export</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc7895</artifactId>
</dependency>
<dependency>
package org.opendaylight.controller.md.sal.rest.common;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
}
public static ControllerContext newControllerContext(SchemaContext schemaContext, DOMMountPoint mountInstance) {
+ final DOMMountPointService mockMountService = mock(DOMMountPointService.class);
+
if (mountInstance != null) {
doReturn(schemaContext).when(mountInstance).getSchemaContext();
+ doReturn(Optional.fromNullable(mountInstance)).when(mockMountService)
+ .getMountPoint(any(YangInstanceIdentifier.class));
}
- final DOMMountPointService mockMountService = mock(DOMMountPointService.class);
- doReturn(Optional.fromNullable(mountInstance)).when(mockMountService)
- .getMountPoint(any(YangInstanceIdentifier.class));
-
DOMSchemaService mockSchemaService = mock(DOMSchemaService.class);
doReturn(schemaContext).when(mockSchemaService).getGlobalContext();
- doReturn(ImmutableClassToInstanceMap.of()).when(mockSchemaService).getExtensions();
DOMSchemaService mockDomSchemaService = mock(DOMSchemaService.class);
doReturn(ImmutableClassToInstanceMap.of()).when(mockDomSchemaService).getExtensions();
import static org.junit.Assert.assertSame;
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.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast");
final SchemaPath type = SchemaPath.create(true, qname);
- when(brokerFacade.invokeRpc(eq(type), any(NormalizedNode.class))).thenReturn(future);
+ when(brokerFacade.invokeRpc(eq(type), isNull())).thenReturn(future);
try {
this.restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo);
final SchemaPath path = SchemaPath.create(true,
QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast"));
- when(brokerFacade.invokeRpc(eq(path), any(NormalizedNode.class))).thenReturn(future);
+ when(brokerFacade.invokeRpc(eq(path), isNull())).thenReturn(future);
try {
this.restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo);
final QName qname = QName.create("(http://netconfcentral.org/ns/toaster?revision=2009-11-20)cancel-toast");
final SchemaPath path = SchemaPath.create(true, qname);
- when(brokerFacade.invokeRpc(eq(path), any(NormalizedNode.class))).thenReturn(future);
+ when(brokerFacade.invokeRpc(eq(path), isNull())).thenReturn(future);
final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:cancel-toast", "", uriInfo);
assertNotNull(output);
final DOMRpcResult result = new DefaultDOMRpcResult(container);
final CheckedFuture<DOMRpcResult, DOMRpcException> future = Futures.immediateCheckedFuture(result);
- when(brokerFacade.invokeRpc(eq(rpcDef.getPath()), any(NormalizedNode.class))).thenReturn(future);
+ when(brokerFacade.invokeRpc(eq(rpcDef.getPath()), isNull())).thenReturn(future);
final NormalizedNodeContext output = this.restconfImpl.invokeRpc("toaster:testOutput", "", uriInfo);
assertNotNull(output);
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
-import static org.mockito.Matchers.notNull;
-import static org.mockito.Matchers.same;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.ArgumentMatchers.notNull;
+import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
public void testPut() throws Exception {
final PutResult result = mock(PutResult.class);
when(brokerFacade.commitConfigurationDataPut(notNull(SchemaContext.class),
- notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), Mockito.anyString(),
- Mockito.anyString())).thenReturn(result);
+ notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), isNull(), isNull()))
+ .thenReturn(result);
when(result.getFutureOfPutData())
.thenReturn(Futures.immediateCheckedFuture(null));
when(result.getStatus()).thenReturn(Status.OK);
ArgumentCaptor.forClass(YangInstanceIdentifier.class);
final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
verify(brokerFacade).commitConfigurationDataPut(notNull(SchemaContext.class), capturedPath.capture(),
- capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
+ capturedNode.capture(), isNull(), isNull());
verifyPath(capturedPath.getValue(), INTERFACES_QNAME, INTERFACE_QNAME,
new Object[]{INTERFACE_QNAME, NAME_QNAME, "eth0"});
public void testPutBehindMountPoint() throws Exception {
final PutResult result = mock(PutResult.class);
when(brokerFacade.commitMountPointDataPut(notNull(DOMMountPoint.class),
- notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), Mockito.anyString(),
- Mockito.anyString())).thenReturn(result);
+ notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), isNull(), isNull()))
+ .thenReturn(result);
when(result.getFutureOfPutData()).thenReturn(Futures.immediateCheckedFuture(null));
when(result.getStatus()).thenReturn(Status.OK);
final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1";
ArgumentCaptor.forClass(YangInstanceIdentifier.class);
final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
verify(brokerFacade).commitMountPointDataPut(same(mockMountPoint), capturedPath.capture(),
- capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
+ capturedNode.capture(), isNull(), isNull());
verifyPath(capturedPath.getValue(), TEST_CONT_QNAME, TEST_CONT1_QNAME);
public void testPost() throws Exception {
doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade).commitConfigurationDataPost(
any(SchemaContext.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class),
- Mockito.anyString(), Mockito.anyString());
+ isNull(), isNull());
final String uriPath = null;
final String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
ArgumentCaptor.forClass(YangInstanceIdentifier.class);
final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
verify(brokerFacade).commitConfigurationDataPost(notNull(SchemaContext.class), capturedPath.capture(),
- capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
+ capturedNode.capture(), isNull(), isNull());
verifyPath(capturedPath.getValue(), INTERFACES_QNAME);
public void testPostBehindMountPoint() throws Exception {
doReturn(Futures.immediateCheckedFuture(null)).when(brokerFacade).commitConfigurationDataPost(
notNull(DOMMountPoint.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class),
- Mockito.anyString(), Mockito.anyString());
+ isNull(), isNull());
final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont";
final String payload = loadData("/full-versions/testCont1Data.json");
ArgumentCaptor.forClass(YangInstanceIdentifier.class);
final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
verify(brokerFacade).commitConfigurationDataPost(same(mockMountPoint), capturedPath.capture(),
- capturedNode.capture(), Mockito.anyString(), Mockito.anyString());
+ capturedNode.capture(), isNull(), isNull());
verifyPath(capturedPath.getValue(), TEST_CONT_QNAME, TEST_CONT1_QNAME);
public void testPostFailure() throws Throwable {
doReturn(Futures.immediateFailedCheckedFuture(new TransactionCommitFailedException("mock"))).when(brokerFacade)
.commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class),
- any(NormalizedNode.class), Mockito.anyString(), Mockito.anyString());
+ any(NormalizedNode.class), isNull(), isNull());
final String uriPath = null;
final String payload = loadData("/parts/ietf-interfaces_interfaces_absolute_path.json");
final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
doReturn(Futures.immediateCheckedFuture(expResult)).when(brokerFacade).invokeRpc(any(SchemaPath.class),
- any(NormalizedNode.class));
+ isNull());
final String uriPath = "toaster:cancel-toast";
assertEquals("Output present", false, output.isPresent());
- verify(brokerFacade).invokeRpc(eq(path), isNull(NormalizedNode.class));
+ verify(brokerFacade).invokeRpc(eq(path), isNull());
}
@Test
.withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build();
final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode);
doReturn(Futures.immediateCheckedFuture(expResult)).when(brokerFacade).invokeRpc(any(SchemaPath.class),
- any(NormalizedNode.class));
+ isNull());
final String uriPath = "toaster:testOutput";
assertNotNull("Returned null response", output.get());
assertThat("Missing \"textOut\"", output.get(), containsString("\"textOut\":\"foo\""));
- verify(brokerFacade).invokeRpc(eq(path), isNull(NormalizedNode.class));
+ verify(brokerFacade).invokeRpc(eq(path), isNull());
}
@Test(expected = OperationFailedException.class)
if (datastoreType == LogicalDatastoreType.CONFIGURATION) {
doReturn(entryNode).when(brokerFacade).readConfigurationData(notNull(YangInstanceIdentifier.class),
- Mockito.anyString());
+ isNull());
} else {
doReturn(entryNode).when(brokerFacade).readOperationalData(notNull(YangInstanceIdentifier.class));
}
final ArgumentCaptor<YangInstanceIdentifier> capturedPath =
ArgumentCaptor.forClass(YangInstanceIdentifier.class);
if (datastoreType == LogicalDatastoreType.CONFIGURATION) {
- verify(brokerFacade).readConfigurationData(capturedPath.capture(), Mockito.anyString());
+ verify(brokerFacade).readConfigurationData(capturedPath.capture(), isNull());
} else {
verify(brokerFacade).readOperationalData(capturedPath.capture());
}
import static org.junit.Assert.assertNull;
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.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.netconf.sal.rest.impl.JsonNormalizedNodeBodyReader;
@Test
public void getDataWithUrlMountPoint() throws Exception {
when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), any(YangInstanceIdentifier.class),
- Mockito.anyString())).thenReturn(
- prepareCnDataForMountPointTest(false));
+ isNull())).thenReturn(prepareCnDataForMountPointTest(false));
when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule);
String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/cont1";
public void getDataWithSlashesBehindMountPoint() throws Exception {
final YangInstanceIdentifier awaitedInstanceIdentifier = prepareInstanceIdentifierForList();
when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), eq(awaitedInstanceIdentifier),
- Mockito.anyString())).thenReturn(prepareCnDataForSlashesBehindMountPointTest());
+ isNull())).thenReturn(prepareCnDataForSlashesBehindMountPointTest());
when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule);
@Test
public void getDataMountPointIntoHighestElement() throws Exception {
when(brokerFacade.readConfigurationData(any(DOMMountPoint.class), any(YangInstanceIdentifier.class),
- Mockito.anyString())).thenReturn(
- prepareCnDataForMountPointTest(true));
+ isNull())).thenReturn(prepareCnDataForMountPointTest(true));
when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule);
@SuppressWarnings("unchecked")
private void mockReadConfigurationDataMethod() {
- when(brokerFacade.readConfigurationData(any(YangInstanceIdentifier.class), Mockito.anyString()))
+ when(brokerFacade.readConfigurationData(any(YangInstanceIdentifier.class), isNull()))
.thenReturn(answerFromGet);
}
package org.opendaylight.controller.sal.restconf.impl.test;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.netconf.sal.rest.api.Draft02;
@Test
public void createConfigurationDataNullTest() throws UnsupportedEncodingException {
when(brokerFacade.commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class),
- any(NormalizedNode.class), Mockito.anyString(), Mockito.anyString()))
+ any(NormalizedNode.class), isNull(), isNull()))
.thenReturn(Futures.immediateCheckedFuture(null));
//FIXME : find who is set schemaContext
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
public void testExample() throws FileNotFoundException, ParseException {
@SuppressWarnings("rawtypes")
final NormalizedNode normalizedNodeData = TestUtils.prepareNormalizedNodeWithIetfInterfacesInterfacesData();
- when(brokerFacade.readOperationalData(any(YangInstanceIdentifier.class))).thenReturn(normalizedNodeData);
+ when(brokerFacade.readOperationalData(isNull())).thenReturn(normalizedNodeData);
assertEquals(normalizedNodeData,
brokerFacade.readOperationalData(null));
}
.invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
this.restconfImpl.invokeRpc("randomId", ctx, uriInfo);
this.restconfImpl.invokeRpc("ietf-netconf", ctx, uriInfo);
- verify(rpcService, times(2)).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
+ verify(rpcService, times(2)).invokeRpc(any(SchemaPath.class), isNull());
}
/**
"data-changed-notification": {
"data-change-event": [
{
- "data": {
- "patch-cont": {
- "xmlns": "instance:identifier:patch:module"
- }
- },
- "operation": "updated",
+ "operation": "deleted",
"path": "/instance-identifier-patch-module:patch-cont"
},
{
<artifactId>restconf-common</artifactId>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
<artifactId>rfc7895</artifactId>
</dependency>
<dependency>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991-ietf-yang-types</artifactId>
</dependency>
<dependency>
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isNull;
-import static org.mockito.Matchers.notNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
final SchemaPath path = SchemaPath.create(true, CANCEL_TOAST_QNAME);
final DOMRpcResult expResult = new DefaultDOMRpcResult((NormalizedNode<?, ?>)null);
- doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path),
- any(NormalizedNode.class));
+ doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), isNull());
final String uriPath = "toaster:cancel-toast";
assertEquals("Output present", false, output.isPresent());
- verify(mockRpcService).invokeRpc(eq(path), isNull(NormalizedNode.class));
+ verify(mockRpcService).invokeRpc(eq(path), isNull());
}
@Test
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_OUTPUT_QNAME))
.withChild(ImmutableNodes.leafNode(TEXT_OUT_QNAME, "foo")).build();
final DOMRpcResult expResult = new DefaultDOMRpcResult(outputNode);
- doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path),
- any(NormalizedNode.class));
+ doReturn(Futures.immediateCheckedFuture(expResult)).when(mockRpcService).invokeRpc(eq(path), isNull());
final String uriPath = "toaster:testOutput";
assertNotNull("Returned null response", output.get());
assertThat("Missing \"textOut\"", output.get(), containsString("\"textOut\":\"foo\""));
- verify(mockRpcService).invokeRpc(eq(path), isNull(NormalizedNode.class));
+ verify(mockRpcService).invokeRpc(eq(path), isNull());
}
@Test(expected = OperationFailedException.class)
final DOMRpcResult rpcResult =
RestconfInvokeOperationsUtil.invokeRpc(DATA.input, DATA.errorRpc, serviceHandler);
assertNull(rpcResult.getResult());
- final Collection<RpcError> errorList = rpcResult.getErrors();
+ final Collection<? extends RpcError> errorList = rpcResult.getErrors();
assertEquals(1, errorList.size());
final RpcError actual = errorList.iterator().next();
assertEquals("No implementation of RPC " + DATA.errorRpc.toString() + " available.", actual.getMessage());
"data-changed-notification": {
"data-change-event": [
{
- "data": {
- "patch-cont": {
- "xmlns": "instance:identifier:patch:module"
- }
- },
- "operation": "updated",
+ "operation": "deleted",
"path": "/instance-identifier-patch-module:patch-cont"
},
{
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>0.14.0-SNAPSHOT</version>
+ <version>3.0.1</version>
<relativePath/>
</parent>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.glassfish.jersey.test-framework.providers</groupId>
- <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
- <version>2.6</version>
- </dependency>
</dependencies>
</dependencyManagement>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>3.1.3</version>
+ <version>4.0.2</version>
<relativePath/>
</parent>
*/
package org.opendaylight.netconf.sal.rest.doc.jaxrs;
-import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
public JaxbContextResolver() {
ctx = new ObjectMapper();
- ctx.getSerializationConfig().withSerializationInclusion(JsonInclude.Include.ALWAYS);
}
@Override