jdk/test/java/nio/charset/coders/CheckSJISMappingProp.sh
author katleman
Thu, 05 Jan 2012 08:42:37 -0800
changeset 11376 075fe3928b7f
parent 10148 b951831be5f9
child 12047 320a714614e9
permissions -rw-r--r--
Added tag jdk8-b20 for changeset 90e14ec89395
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     1
#!/bin/sh
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     2
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     3
#
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 5506
diff changeset
     4
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     6
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
     9
# published by the Free Software Foundation.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    10
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    15
# accompanied this code).
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    16
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    20
#
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4817
diff changeset
    23
# questions.
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    24
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    25
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    26
# @test
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    27
# @summary Verify that sun.nio.cs.map property interpreted in ja multibyte locales
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    28
# @bug 4879123
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    29
# @build SJISPropTest
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    30
#
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    31
# @run shell/timeout=300 CheckSJISMappingProp.sh
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    32
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    33
# set platform-dependent variables
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    34
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    35
OS=`uname -s`
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    36
case "$OS" in
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    37
  SunOS | Linux ) ;;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    38
  # Skip locale test for Windows
10148
b951831be5f9 7036518: TEST_BUG: add cygwin support to test/java/nio/charset/coders/CheckSJISMappingProp.sh
mchung
parents: 9035
diff changeset
    39
  Windows* | CYGWIN* )
4817
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    40
    echo "Passed"; exit 0 ;;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    41
  * ) echo "Unrecognized system!" ;  exit 1 ;;
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    42
esac
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    43
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    44
expectPass() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    45
  if [ $1 -eq 0 ]
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    46
  then echo "--- passed as expected"
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    47
  else
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    48
    echo "--- failed"
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    49
    exit $1
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    50
  fi
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    51
}
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    52
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    53
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    54
JAVA="${TESTJAVA}/bin/java -cp ${TESTCLASSES}"
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    55
runTest() {
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    56
  echo "Testing:" ${1}
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    57
  LC_ALL="$1" ; export LC_ALL
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    58
  locale
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    59
  # Firstly, test with property set
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    60
  # (shift_jis should map to windows-31J charset) 
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    61
  ${JAVA} -Dsun.nio.cs.map="Windows-31J/Shift_JIS" SJISPropTest MS932
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    62
  expectPass $?
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    63
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    64
  # Next, test without property set - "shift_jis" follows IANA conventions
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    65
  # and should map to the sun.nio.cs.ext.Shift_JIS charset
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    66
  ${JAVA} SJISPropTest Shift_JIS
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    67
  expectPass $?
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    68
}
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    69
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    70
# Run the test in the common Solaris/Linux locales
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    71
# Tests will simply run in current locale if locale isn't supported
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    72
# on the test machine/platform
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    73
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    74
for i in "ja" "ja_JP.PCK" "ja_JP.eucJP"  ; do
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    75
  runTest ${i}
67f425ac409b 6920732: opensource test/java/nio/charset
sherman
parents:
diff changeset
    76
done