TestIBMDB.java revision 2362
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * This code is free software; you can redistribute it and/or modify it
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * under the terms of the GNU General Public License version 2 only, as
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * published by the Free Software Foundation.
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * This code is distributed in the hope that it will be useful, but WITHOUT
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * version 2 for more details (a copy is included in the LICENSE file that
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * accompanied this code).
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * You should have received a copy of the GNU General Public License version
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * 2 along with this work; if not, write to the Free Software Foundation,
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * or visit www.oracle.com if you need additional information or have any
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * @bug 6843578
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * @summary Test IBM DB charsets
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi * @build IBM930_OLD IBM933_OLD IBM935_OLD IBM937_OLD IBM939_OLD IBM942_OLD IBM943_OLD IBM948_OLD IBM949_OLD IBM950_OLD IBM970_OLD IBM942C_OLD IBM943C_OLD IBM949C_OLD IBM1381_OLD IBM1383_OLD EUC_CN_OLD EUC_KR_OLD GBK_OLD Johab_OLD MS932_OLD MS936_OLD MS949_OLD MS950_OLD
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi static class Time {
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi static char[] decode(byte[] bb, Charset cs, boolean testDirect, Time t)
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi bbf = ByteBuffer.allocateDirect(bb.length);
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi cbf = ByteBuffer.allocateDirect(bb.length*2).asCharBuffer();
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi System.out.println("DEC-----------------");
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi System.out.printf(" cr=%s, bbf.pos=%d, bb[pos]=%x,%x,%x,%x%n",
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi bb[pos++]&0xff, bb[pos++]&0xff,bb[pos++]&0xff, bb[pos++]&0xff);
76ca3cb000306bc4052fe820a7e4a6998dbcf932Robert Mustacchi throw new RuntimeException("Decoding err: " + csn);
return cc;
throws Exception {
if (testDirect) {
return cr;
throws Exception {
if (testDirect) {
return bb;
throws Exception {
if (testDirect) {
return cr;
for (byte b:bb)
// check and compare canEncoding/Encoding
throws Exception {
if (canNew) {
if (is970) {
} else if (canNew) {
// check and compare canEncoding/Encoding
throws Exception
if (!isEBCDIC) {
if (isEBCDIC) {
throws Exception
boolean failed = false;
for (boolean direct: new boolean[] {false, true}) {
System.out.printf(" FAIL(direct=%b): [%s] not malformed. -->cr=%s\n", direct, ashex, cr.toString());
failed = true;
failed = true;
if (failed)
if (direct) {
boolean failed = false;
int[][] Flows = {
for (boolean direct: new boolean[] {false, true}) {
failed = true;
if (failed)