/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. package org.mobicents.protocols.smpp.encoding;
  23. import java.io.UnsupportedEncodingException;
  24. import org.mobicents.protocols.smpp.encoding.Latin1Encoding;
  25. import org.testng.annotations.Test;
  26. /**
  27. * @version $Id:$
  28. */
  29. @Test
  30. public class Latin1EncodingTest extends BaseAlphabetEncodingTest<Latin1Encoding> {
  31. // "Test message" followed by:
  32. // Yen symbol
  33. // Pound sign (European interpretation, not what I would call a "hash").
  34. // Superscript 3
  35. // Latin capital letter AE
  36. private final static int[] EXPECTED_BYTES = {
  37. 0x54, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65, 0x73,
  38. 0x73, 0x61, 0x67, 0x65, 0xa5, 0xa3, 0xb3, 0xc6,
  39. };
  40. private static final String STRING = "Test message\u00a5\u00a3\u00b3\u00c6";
  41. @Override
  42. protected TestData getArrayToDecode() {
  43. return new TestData(STRING, EXPECTED_BYTES);
  44. }
  45. @Override
  46. protected Latin1Encoding getEncodingToTest() throws UnsupportedEncodingException {
  47. return new Latin1Encoding();
  48. }
  49. @Override
  50. protected TestData getFullySupportedStringToEncode() {
  51. return new TestData(EXPECTED_BYTES, STRING);
  52. }
  53. @Override
  54. protected TestData getPartiallySupportedStringToEncode() {
  55. String string = "Unsupported character: \u20ac";
  56. int[] expectedBytes = new int[] {
  57. 85, 110, 115, 117, 112, 112, 111, 114,
  58. 116, 101, 100, 32, 99, 104, 97, 114,
  59. 97, 99, 116, 101, 114, 58, 32, 63,
  60. };
  61. return new TestData(expectedBytes, string);
  62. }
  63. }