4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
7 * Shingil Kang <shingil.kang@samsung.com>
8 * Kangho Kim <kh5325.kim@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
26 package org.tizen.common.connection.log;
28 import static org.junit.Assert.assertEquals;
30 import java.io.UnsupportedEncodingException;
32 import org.junit.Test;
33 import org.tizen.common.connection.log.LogTab;
34 import org.tizen.sdblib.SdbHelper;
39 * Testcase for {@link LogTab}
41 * @author Shingil Kang{@literal <shingil.kang@samsung.com>} (S-Core)
43 public class LogTabTest
45 private LogTab logTab = new LogTab();
48 public void test_getDecodedLineManual()
50 final Language[] TEST_CASES = new Language[]
52 new Language(new byte[] {(byte) 0xB0, (byte) 0xA1}, EncodingChar.EUC_KR),
53 new Language(new byte[] {(byte) 0xA4, (byte) 0x40}, EncodingChar.BIG5),
54 new Language(new byte[] {(byte) 0x82, (byte) 0x9F, (byte) 0x92, (byte) 0xA0}, EncodingChar.SHIFT_JIS),
55 new Language(new byte[] {(byte) 0x80, (byte) 0x81, (byte) 0x82}, EncodingChar.IBM852),
56 new Language(new byte[] {(byte) 0xAA, (byte) 0xB5}, EncodingChar.TIS_620),
57 new Language(new byte[] {(byte) 0x65, (byte) 0xAE}, EncodingChar.X_MACROMAN)
60 for (final Language TEST_CASE : TEST_CASES)
62 byte[] byteValue = TEST_CASE.getByteValue();
63 EncodingChar encodingChar = TEST_CASE.getEncoding();
64 String defaultEncodedString = null;
68 defaultEncodedString = new String(byteValue, SdbHelper.DEFAULT_ENCODING);
69 String encodedLine = logTab.getDecodedLineManual(defaultEncodedString, encodingChar);
71 System.out.println("encoded line : " + encodedLine);
73 byte[] encodedLineByte = encodedLine.getBytes(encodingChar.getName());
75 assertEquals(byteValue.length, encodedLineByte.length);
77 for(int i = 0; i < byteValue.length; i++)
79 assertEquals(byteValue[i], encodedLineByte[i]);
82 } catch (UnsupportedEncodingException e)
91 private byte[] byteValue;
92 private EncodingChar encoding;
94 Language(byte[] byteValue, EncodingChar encoding)
96 this.byteValue = byteValue;
97 this.encoding = encoding;
100 public byte[] getByteValue()
105 public EncodingChar getEncoding()