package org.opendaylight.controller.netconf.util;
import com.google.common.base.Preconditions;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
public final class NetconfUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfUtil.class);
private NetconfUtil() {}
if (element.getName().equals(XmlNetconfConstants.OK)) {
return response;
}
- logger.warn("Can not load last configuration. Operation failed.");
+ LOG.warn("Can not load last configuration. Operation failed.");
throw new IllegalStateException("Can not load last configuration. Operation failed: "
+ XmlUtil.toString(response));
}
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class MissingNameSpaceException extends NetconfDocumentedException {
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class UnexpectedElementException extends NetconfDocumentedException {
import java.util.Collections;
import java.util.Map;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
public class UnexpectedNamespaceException extends NetconfDocumentedException {
package org.opendaylight.controller.netconf.util.messages;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
import java.util.Set;
-
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.exception.MissingNameSpaceException;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-
/**
* NetconfMessage that can carry additional header with session metadata. See {@link org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader}
*/
package org.opendaylight.controller.netconf.util.messages;
import com.google.common.base.Preconditions;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package org.opendaylight.controller.netconf.util.messages;
-import java.nio.ByteBuffer;
-
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
+import java.nio.ByteBuffer;
/**
* Netconf message header is used only when chunked framing mechanism is
public final class NetconfMessageUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfMessageUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageUtil.class);
private NetconfMessageUtil() {}
try {
return input.getTextContent().trim();
} catch (NetconfDocumentedException e) {
- logger.trace("Error fetching inpit text content becauese {}",e);
+ LOG.trace("Error fetching input text content",e);
return null;
}
}
package org.opendaylight.controller.netconf.util.messages;
import com.google.common.base.Preconditions;
-
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
-
-import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.slf4j.Logger;
import org.w3c.dom.NamedNodeMap;
public final class SendErrorExceptionUtil {
- private static final Logger logger = LoggerFactory.getLogger(SendErrorExceptionUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SendErrorExceptionUtil.class);
private SendErrorExceptionUtil() {}
public static void sendErrorMessage(final NetconfSession session,
final NetconfDocumentedException sendErrorException) {
- logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture f = session.sendMessage(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
}
public static void sendErrorMessage(Channel channel, NetconfDocumentedException sendErrorException) {
- logger.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
+ LOG.trace("Sending error {}", sendErrorException.getMessage(), sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture f = channel.writeAndFlush(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
public static void sendErrorMessage(NetconfSession session, NetconfDocumentedException sendErrorException,
NetconfMessage incommingMessage) {
final Document errorDocument = createDocument(sendErrorException);
- logger.trace("Sending error {}", XmlUtil.toString(errorDocument));
+ LOG.trace("Sending error {}", XmlUtil.toString(errorDocument));
tryToCopyAttributes(incommingMessage.getDocument(), errorDocument, sendErrorException);
ChannelFuture f = session.sendMessage(new NetconfMessage(errorDocument));
f.addListener(new SendErrorVerifyingListener(sendErrorException));
rpcReply.setAttributeNode((Attr) errorDocument.importNode(attr, true));
}
} catch (final Exception e) {
- logger.warn("Unable to copy incomming attributes to {}, returned rpc-error might be invalid for client",
+ LOG.warn("Unable to copy incomming attributes to {}, returned rpc-error might be invalid for client",
sendErrorException, e);
}
}
import org.slf4j.LoggerFactory;
public final class NetconfConfigUtil {
- private static final Logger logger = LoggerFactory.getLogger(NetconfConfigUtil.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfConfigUtil.class);
private static final String PREFIX_PROP = "netconf.";
try {
return Long.parseLong(timeoutString);
} catch (final NumberFormatException e) {
- logger.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e);
+ LOG.warn("Cannot parse {} property: {}, using defaults", key, timeoutString, e);
return DEFAULT_TIMEOUT_MILLIS;
}
}
try {
return Optional.of(parseAddress(address, port));
} catch (final RuntimeException e) {
- logger.warn("Unable to parse {} netconf address from {}:{}, fallback to default",
+ LOG.warn("Unable to parse {} netconf address from {}:{}, fallback to default",
infixProp, address, port, e);
}
}
package org.opendaylight.controller.netconf.util.xml;
+import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-
import javax.xml.namespace.NamespaceContext;
-import com.google.common.collect.ImmutableMap;
-
// http://www.ibm.com/developerworks/library/x-nmspccontext/
public class HardcodedNamespaceResolver implements NamespaceContext {
private final Map<String/* prefix */, String/* namespace */> prefixesToNamespaces;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
public final class XMLNetconfUtil {
public static final String DEFAULT_NAMESPACE_PREFIX = "";
private final Element element;
- private static final Logger logger = LoggerFactory.getLogger(XmlElement.class);
+ private static final Logger LOG = LoggerFactory.getLogger(XmlElement.class);
private XmlElement(Element element) {
this.element = element;
public void checkNamespace(String expectedNamespace) throws UnexpectedNamespaceException, MissingNameSpaceException {
if (!getNamespace().equals(expectedNamespace))
- {
+ {
throw new UnexpectedNamespaceException(String.format("Unexpected namespace %s should be %s",
getNamespace(),
expectedNamespace),
try {
sb.append(", namespace='").append(getNamespace()).append('\'');
} catch (MissingNameSpaceException e) {
- logger.trace("Missing namespace for element.");
+ LOG.trace("Missing namespace for element.");
}
}
sb.append('}');
package org.opendaylight.controller.netconf.util.xml;
+import com.google.common.base.Preconditions;
import java.io.IOException;
import java.io.InputStream;
-
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
-
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
-import com.google.common.base.Preconditions;
-
public final class XmlNetconfValidator {
private static final Schema SCHEMA;
import com.google.common.base.Charsets;
import com.google.common.base.Optional;
-
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
-
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.validation.SchemaFactory;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
-
import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix,
String namespace, String contentWithoutPrefix) {
- return createTextElementWithNamespacedContent(document, qName, prefix, namespace, contentWithoutPrefix, Optional.<String>absent());
+ return createTextElementWithNamespacedContent(document, qName, prefix, namespace, contentWithoutPrefix, Optional.<String>absent());
}
public static Element createTextElementWithNamespacedContent(Document document, String qName, String prefix,
*/
package org.opendaylight.controller.netconf.util;
-import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
+import static org.hamcrest.CoreMatchers.containsString;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
public class AbstractLastNetconfOperationTest {
class LastNetconfOperationImplTest extends AbstractLastNetconfOperation {
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-
public class AbstractNetconfOperationTest {
class NetconfOperationImpl extends AbstractNetconfOperation {
package org.opendaylight.controller.netconf.util.mapping;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-
public class AbstractSingletonNetconfOperationTest {
class SingletonNCOperationImpl extends AbstractSingletonNetconfOperation {
package org.opendaylight.controller.netconf.util.messages;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
public class NetconfHelloMessageAdditionalHeaderTest {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+
import com.google.common.base.Optional;
import java.util.Set;
import org.junit.Before;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+
import com.google.common.base.Charsets;
import org.junit.Test;
package org.opendaylight.controller.netconf.util.messages;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.Collection;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
public class NetconfMessageUtilTest {
@Test
public void testNetconfMessageUtil() throws Exception {
package org.opendaylight.controller.netconf.util.messages;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.GenericFutureListener;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
import org.w3c.dom.Document;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
public class SendErrorExceptionUtilTest {
NetconfSession netconfSession;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+
import com.google.common.base.Optional;
import io.netty.channel.local.LocalAddress;
import java.net.InetSocketAddress;
package org.opendaylight.controller.netconf.util.test;
+import com.google.common.base.Charsets;
+import com.google.common.base.Preconditions;
+import com.google.common.io.CharStreams;
+import com.google.common.io.InputSupplier;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-
import javax.xml.parsers.ParserConfigurationException;
-
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import com.google.common.base.Charsets;
-import com.google.common.base.Preconditions;
-import com.google.common.io.CharStreams;
-import com.google.common.io.InputSupplier;
-
public class XmlFileLoader {
public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException,
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.common.base.Optional;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import com.google.common.base.Optional;
-
public class XmlElementTest {
private final String elementAsString = "<top xmlns=\"namespace\" xmlns:a=\"attrNamespace\" a:attr1=\"value1\" attr2=\"value2\">" +
<lexical-values/>
</fidelity>
</start-exi>
-</rpc>
+</rpc>
\ No newline at end of file
<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<stop-exi xmlns="urn:ietf:params:xml:ns:netconf:exi:1.0"/>
-</rpc>
+</rpc>
\ No newline at end of file