Switch default stream output to Magnesium
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / test / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / LithiumWriteObjectMappingTest.java
1 /*
2  * Copyright (c) 2015 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.controller.cluster.datastore.node.utils.stream;
9
10 import static org.junit.Assert.assertEquals;
11
12 import org.junit.Test;
13
14 public class LithiumWriteObjectMappingTest {
15     @Test
16     public void testStringType() {
17         assertEquals(LithiumValue.STRING_TYPE, AbstractLithiumDataOutput.getSerializableType("foobar"));
18         final String largeString = largeString(LithiumValue.STRING_BYTES_LENGTH_THRESHOLD);
19         assertEquals(LithiumValue.STRING_BYTES_TYPE, AbstractLithiumDataOutput.getSerializableType(largeString));
20     }
21
22     private static String largeString(final int minSize) {
23         final int pow = (int) (Math.log(minSize * 2) / Math.log(2));
24         StringBuilder sb = new StringBuilder("X");
25         for (int i = 0; i < pow; i++) {
26             sb.append(sb);
27         }
28         return sb.toString();
29     }
30 }