From: Andrej Mak Date: Thu, 2 Mar 2017 11:38:21 +0000 (+0100) Subject: Add FrontendTypeTest X-Git-Tag: release/carbon~179 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=deecbdce1c72c6e57a8275047dcaea3fe4e97731;ds=inline Add FrontendTypeTest Change-Id: Ie3129ef8b5147e8f9dfb4be51a6bfa906c5aff65 Signed-off-by: Andrej Mak --- 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 index 0000000000..43ffa19c49 --- /dev/null +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/FrontendTypeTest.java @@ -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 { + + @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