2 * Copyright (c) 2014 Brocade Communications Systems, Inc. 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
9 package org.opendaylight.yangtools.yang.data.impl.test.codecs;
11 import static org.junit.Assert.*;
13 import org.junit.Test;
14 import static org.opendaylight.yangtools.yang.data.impl.test.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
15 import static org.opendaylight.yangtools.yang.data.impl.test.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
16 import org.opendaylight.yangtools.yang.data.api.codec.EmptyCodec;
17 import org.opendaylight.yangtools.yang.model.util.EmptyType;
20 * Unit tests for EmptyCodecString.
22 * @author Thomas Pantelis
24 public class EmptyCodecStringTest {
26 @SuppressWarnings("unchecked")
28 public void testSerialize() {
29 EmptyCodec<String> codec = getCodec( EmptyType.getInstance(), EmptyCodec.class);
31 assertEquals( "serialize", "", codec.serialize( null ) );
34 @SuppressWarnings("unchecked")
36 public void testDeserialize() {
37 EmptyCodec<String> codec = getCodec( EmptyType.getInstance(), EmptyCodec.class);
39 assertEquals( "deserialize", null, codec.deserialize( "" ) );
40 assertEquals( "deserialize", null, codec.deserialize( null ) );
42 deserializeWithExpectedIllegalArgEx( codec, "foo" );