PageRenderTime 21ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/smpp/src/test/java/org/mobicents/protocols/smpp/encoding/Latin1EncodingTest.java

http://mobicents.googlecode.com/
Java | 71 lines | 34 code | 8 blank | 29 comment | 0 complexity | 2eb8dbb5337a29c480e60864c4c01922 MD5 | raw file
 1/*
 2 * JBoss, Home of Professional Open Source
 3 * Copyright 2011, Red Hat, Inc. and individual contributors
 4 * by the @authors tag. See the copyright.txt in the distribution for a
 5 * full listing of individual contributors.
 6 *
 7 * This is free software; you can redistribute it and/or modify it
 8 * under the terms of the GNU Lesser General Public License as
 9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */
22
23package org.mobicents.protocols.smpp.encoding;
24
25import java.io.UnsupportedEncodingException;
26
27import org.mobicents.protocols.smpp.encoding.Latin1Encoding;
28import org.testng.annotations.Test;
29
30/**
31 * @version $Id:$
32 */
33@Test
34public class Latin1EncodingTest extends BaseAlphabetEncodingTest<Latin1Encoding> {
35    // "Test message" followed by:
36    // Yen symbol
37    // Pound sign (European interpretation, not what I would call a "hash").
38    // Superscript 3
39    // Latin capital letter AE
40    private final static int[] EXPECTED_BYTES = {
41        0x54, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x73,
42        0x73, 0x61, 0x67, 0x65, 0xa5, 0xa3, 0xb3, 0xc6,
43    };
44    private static final String STRING = "Test message\u00a5\u00a3\u00b3\u00c6";
45
46    @Override
47    protected TestData getArrayToDecode() {
48        return new TestData(STRING, EXPECTED_BYTES);
49    }
50
51    @Override
52    protected Latin1Encoding getEncodingToTest() throws UnsupportedEncodingException {
53        return new Latin1Encoding();
54    }
55
56    @Override
57    protected TestData getFullySupportedStringToEncode() {
58        return new TestData(EXPECTED_BYTES, STRING);
59    }
60
61    @Override
62    protected TestData getPartiallySupportedStringToEncode() {
63        String string = "Unsupported character: \u20ac";
64        int[] expectedBytes = new int[] {
65                85, 110, 115, 117, 112, 112, 111, 114,
66                116, 101, 100, 32, 99, 104, 97, 114,
67                97, 99, 116, 101, 114, 58, 32, 63,
68        };
69        return new TestData(expectedBytes, string);
70    }
71}