Delete netconf
[controller.git] / opendaylight / netconf / netconf-monitoring / src / test / java / org / opendaylight / controller / netconf / monitoring / GetTest.java
diff --git a/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/GetTest.java b/opendaylight/netconf/netconf-monitoring/src/test/java/org/opendaylight/controller/netconf/monitoring/GetTest.java
deleted file mode 100644 (file)
index 86c9cc6..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.netconf.monitoring;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-
-import java.util.Collections;
-import org.hamcrest.CoreMatchers;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
-import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
-import org.opendaylight.controller.netconf.mapping.api.NetconfOperationChainedExecution;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SessionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
-import org.w3c.dom.Document;
-
-public class GetTest {
-
-    @Mock
-    private NetconfMonitoringService monitor;
-    @Mock
-    private Document request;
-    @Mock
-    private NetconfOperationChainedExecution subsequentOperation;
-    private Document incorrectSubsequentResult;
-    private Document correctSubsequentResult;
-
-    private Get get;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-
-        incorrectSubsequentResult = XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>");
-        correctSubsequentResult = XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><data></data></rpc-reply>");
-
-        doReturn(new SessionsBuilder().setSession(Collections.<Session>emptyList()).build()).when(monitor).getSessions();
-        doReturn(new SchemasBuilder().setSchema(Collections.<Schema>emptyList()).build()).when(monitor).getSchemas();
-        doReturn(false).when(subsequentOperation).isExecutionTermination();
-
-        get = new Get(monitor);
-    }
-
-    @Test
-    public void testHandleNoSubsequent() throws Exception {
-        try {
-            get.handle(null, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
-        } catch (final DocumentedException e) {
-            assertNetconfDocumentedEx(e, DocumentedException.ErrorSeverity.error, DocumentedException.ErrorTag.operation_failed, DocumentedException.ErrorType.application);
-            return;
-        }
-
-        fail("Get should fail without subsequent operation");
-    }
-
-    @Test
-    public void testHandleWrongPlaceholder() throws Exception {
-        doReturn(incorrectSubsequentResult).when(subsequentOperation).execute(request);
-        try {
-            get.handle(request, subsequentOperation);
-        } catch (final DocumentedException e) {
-            assertNetconfDocumentedEx(e, DocumentedException.ErrorSeverity.error, DocumentedException.ErrorTag.invalid_value, DocumentedException.ErrorType.application);
-            return;
-        }
-
-        fail("Get should fail with wrong xml");
-    }
-
-    @Test
-    public void testHandleRuntimeEx() throws Exception {
-        doThrow(RuntimeException.class).when(subsequentOperation).execute(request);
-        try {
-            get.handle(request, subsequentOperation);
-        } catch (final DocumentedException e) {
-            assertNetconfDocumentedEx(e, DocumentedException.ErrorSeverity.error, DocumentedException.ErrorTag.operation_failed, DocumentedException.ErrorType.application);
-            assertEquals(1, e.getErrorInfo().size());
-            return;
-        }
-
-        fail("Get should fail with wrong xml");
-    }
-
-    @Test
-    public void testSuccessHandle() throws Exception {
-        doReturn(correctSubsequentResult).when(subsequentOperation).execute(request);
-        assertTrue(get.getHandlingPriority().getPriority().get() > HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.getPriority().get());
-        final Document result = get.handle(request, subsequentOperation);
-        assertThat(XmlUtil.toString(result), CoreMatchers.containsString("sessions"));
-        assertThat(XmlUtil.toString(result), CoreMatchers.containsString("schemas"));
-
-    }
-
-    @Test(expected = UnsupportedOperationException.class)
-    public void testHandle() throws Exception {
-        get.handle(null, null, null);
-
-    }
-
-    private void assertNetconfDocumentedEx(final DocumentedException e, final DocumentedException.ErrorSeverity severity, final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorType type) {
-        assertEquals(severity, e.getErrorSeverity());
-        assertEquals(errorTag, e.getErrorTag());
-        assertEquals(type, e.getErrorType());
-    }
-}