Do not pretty-print body class
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / codec / BinaryCodecStringTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.data.impl.codec;
9
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodecTestHelper.getCodec;
13
14 import java.util.Base64;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.data.api.codec.BinaryCodec;
17 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
18
19 /**
20  * Unit tests for BinaryCodecString.
21  *
22  * @author Thomas Pantelis
23  */
24 public class BinaryCodecStringTest {
25     private static final byte[] FOUR_ELEMENTS = { 1, 2, 3, 4 };
26
27     @SuppressWarnings("unchecked")
28     @Test
29     public void testSerialize() {
30         BinaryCodec<String> codec = getCodec(BaseTypes.binaryType(), BinaryCodec.class);
31         assertEquals(Base64.getEncoder().encodeToString(FOUR_ELEMENTS), codec.serialize(FOUR_ELEMENTS));
32     }
33
34     @SuppressWarnings("unchecked")
35     @Test
36     public void testDererialize() {
37         BinaryCodec<String> codec = getCodec(BaseTypes.binaryType(), BinaryCodec.class);
38         assertArrayEquals(FOUR_ELEMENTS, codec.deserialize(Base64.getEncoder().encodeToString(FOUR_ELEMENTS)));
39     }
40 }