96dddbaa8684435e5bfcb43bea26d63bfbd52a86
[yangtools.git] / common / yang-common / src / test / java / org / opendaylight / yangtools / yang / common / ErrorTagTest.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.common;
9
10 import static org.junit.Assert.assertEquals;
11
12 import java.io.ByteArrayInputStream;
13 import java.io.ByteArrayOutputStream;
14 import java.io.ObjectInputStream;
15 import java.io.ObjectOutputStream;
16 import org.junit.Test;
17
18 public class ErrorTagTest {
19     @Test
20     public void testSerialization() throws Exception {
21         final ErrorTag expected = new ErrorTag("test");
22
23         final byte[] bytes;
24         try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
25             try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
26                 oos.writeObject(expected);
27             }
28             bytes = bos.toByteArray();
29         }
30
31         try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes))) {
32             assertEquals(expected, ois.readObject());
33         }
34     }
35 }