From acb15f8e492abcef89cfcfe443bb8c39d3871269 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20de=20Talhou=C3=ABt?= Date: Thu, 2 Apr 2015 10:52:39 -0400 Subject: [PATCH] Add JUnit testing for AbstractHandler class. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: If172dff7ad5d98a6cabdb78a6c4067c3327e1f10 Signed-off-by: Alexis de Talhouët --- .../netvirt/AbstractHandlerTest.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/AbstractHandlerTest.java diff --git a/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/AbstractHandlerTest.java b/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/AbstractHandlerTest.java new file mode 100644 index 0000000000..686b781083 --- /dev/null +++ b/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/AbstractHandlerTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015 Inocybe 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.ovsdb.openstack.netvirt; + +import static org.junit.Assert.*; + +import java.net.HttpURLConnection; + +import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.ovsdb.plugin.api.Status; +import org.opendaylight.ovsdb.plugin.api.StatusCode; + +/** + * Unit test for {@link AbstractHandler} + */ +public class AbstractHandlerTest { + + @Test + public void testAbstractHandler() { + Status status = Mockito.mock(Status.class); + + Mockito.when(status.getCode()) + .thenReturn(StatusCode.BADREQUEST) + .thenReturn(StatusCode.CONFLICT) + .thenReturn(StatusCode.NOTACCEPTABLE) + .thenReturn(StatusCode.NOTFOUND) + .thenReturn(StatusCode.GONE); + + assertEquals( + "Error, getException() did not return the correct neutron API service error", + HttpURLConnection.HTTP_BAD_REQUEST, + AbstractHandler.getException(status)); + assertEquals( + "Error, getException() did not return the correct neutron API service error", + HttpURLConnection.HTTP_CONFLICT, + AbstractHandler.getException(status)); + assertEquals( + "Error, getException() did not return the correct neutron API service error", + HttpURLConnection.HTTP_NOT_ACCEPTABLE, + AbstractHandler.getException(status)); + assertEquals( + "Error, getException() did not return the correct neutron API service error", + HttpURLConnection.HTTP_NOT_FOUND, + AbstractHandler.getException(status)); + assertEquals( + "Error, getException() did not return the correct neutron API service error", + HttpURLConnection.HTTP_INTERNAL_ERROR, + AbstractHandler.getException(status)); + } +} -- 2.36.6