2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.access.concepts;
10 import java.io.ByteArrayInputStream;
11 import java.io.ByteArrayOutputStream;
12 import java.io.DataInputStream;
13 import java.io.DataOutputStream;
14 import org.junit.Assert;
15 import org.junit.Test;
17 public class FrontendTypeTest extends AbstractIdentifierTest<FrontendType> {
20 FrontendType object() {
21 return FrontendType.forName("type-1");
25 FrontendType differentObject() {
26 return FrontendType.forName("type-2");
30 FrontendType equalObject() {
31 return FrontendType.forName("type-1");
35 public void testWriteToReadFrom() throws Exception {
36 final FrontendType type = FrontendType.forName("type");
37 final ByteArrayOutputStream baos = new ByteArrayOutputStream();
38 final DataOutputStream dos = new DataOutputStream(baos);
40 final FrontendType read =
41 FrontendType.readFrom(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())));
42 Assert.assertEquals(type, read);
46 public void testCompareTo() throws Exception {
47 Assert.assertTrue(object().compareTo(equalObject()) == 0);
48 Assert.assertTrue(object().compareTo(differentObject()) < 0);