Add FrontendTypeTest 34/52634/5
authorAndrej Mak <andrej.mak@pantheon.tech>
Thu, 2 Mar 2017 11:38:21 +0000 (12:38 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 9 Mar 2017 12:37:38 +0000 (12:37 +0000)
Change-Id: Ie3129ef8b5147e8f9dfb4be51a6bfa906c5aff65
Signed-off-by: Andrej Mak <andrej.mak@pantheon.tech>
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FrontendTypeTest.java [new file with mode: 0644]

diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FrontendTypeTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FrontendTypeTest.java
new file mode 100644 (file)
index 0000000..43ffa19
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.cluster.access.concepts;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FrontendTypeTest extends AbstractIdentifierTest<FrontendType> {
+
+    @Override
+    FrontendType object() {
+        return FrontendType.forName("type-1");
+    }
+
+    @Override
+    FrontendType differentObject() {
+        return FrontendType.forName("type-2");
+    }
+
+    @Override
+    FrontendType equalObject() {
+        return FrontendType.forName("type-1");
+    }
+
+    @Test
+    public void testWriteToReadFrom() throws Exception {
+        final FrontendType type = FrontendType.forName("type");
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        final DataOutputStream dos = new DataOutputStream(baos);
+        type.writeTo(dos);
+        final FrontendType read =
+                FrontendType.readFrom(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())));
+        Assert.assertEquals(type, read);
+    }
+
+    @Test
+    public void testCompareTo() throws Exception {
+        Assert.assertTrue(object().compareTo(equalObject()) == 0);
+        Assert.assertTrue(object().compareTo(differentObject()) < 0);
+    }
+}
\ No newline at end of file

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.