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.yangtools.yang.common;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertSame;
14 import java.io.ByteArrayInputStream;
15 import java.io.ByteArrayOutputStream;
16 import java.io.IOException;
17 import java.io.ObjectInputStream;
18 import java.io.ObjectOutputStream;
19 import org.junit.Test;
21 public class EmptyTest {
24 public void testInstanceNotNull() {
25 assertNotNull(Empty.getInstance());
29 public void testToString() {
30 assertEquals("empty", Empty.getInstance().toString());
34 public void testSerialization() throws IOException, ClassNotFoundException {
35 final ByteArrayOutputStream bos = new ByteArrayOutputStream();
36 try (ObjectOutputStream oos = new ObjectOutputStream(bos)) {
37 oos.writeObject(Empty.getInstance());
41 try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()))) {
42 read = ois.readObject();
45 assertSame(Empty.getInstance(), read);