Example usage for io.netty.util CharsetUtil ISO_8859_1

List of usage examples for io.netty.util CharsetUtil ISO_8859_1

Introduction

In this page you can find the example usage for io.netty.util CharsetUtil ISO_8859_1.

Prototype

Charset ISO_8859_1

To view the source code for io.netty.util CharsetUtil ISO_8859_1.

Click Source Link

Document

ISO Latin Alphabet No.

Usage

From source file:com.tesora.dve.sql.BlobTest.java

License:Open Source License

@Test
public void testBlob() throws Throwable {
    ArrayList<MirrorTest> out = new ArrayList<MirrorTest>();
    out.add(new StatementMirrorProc("set names utf8"));
    Charset charset = CharsetUtil.ISO_8859_1;
    byte[] esc = allBytes(true);
    for (int i = 0; i < types.length; i++) {
        String prefix = "insert into " + tnames[i] + " values (1, '";
        String postfix = "')";
        List<Byte> prebytes = toObject(prefix.getBytes(charset));
        List<Byte> postbytes = toObject(postfix.getBytes(charset));
        ArrayList<Byte> buf = new ArrayList<Byte>();
        buf.addAll(prebytes);//w  w  w .j  a  v a  2s. c  om
        buf.addAll(toObject(esc));
        buf.addAll(postbytes);
        String command = PECharsetUtils.getString(toPrimitive(buf), charset, true);
        if (command == null)
            fail("Not a valid string");
        out.add(new StatementMirrorProc(command));
        String query = "select bt from " + tnames[i] + " where id = 1";
        out.add(new StatementMirrorFun(true, query));
    }

    // Test for returning a null blob
    String nullTest = "insert into LB (id) values (2)";
    out.add(new StatementMirrorProc(nullTest));
    String nullQuery = "select bt from LB where id = 2";
    out.add(new StatementMirrorFun(nullQuery));
    runTest(out, getTestConfig(), false);
}

From source file:com.tesora.dve.sql.InsertMysqlConnTest.java

License:Open Source License

@Test
public void testPE969() throws Throwable {
    final byte[] failingInput = { 75, -108, -84, 9 };

    final List<MirrorTest> tests = new ArrayList<MirrorTest>();
    tests.add(new StatementMirrorProc(
            "CREATE TABLE `bug_repro_969` (`message_id` int(11) unsigned NOT NULL AUTO_INCREMENT,`ip` varbinary(16) DEFAULT NULL,PRIMARY KEY (`message_id`)) ENGINE=InnoDB AUTO_INCREMENT=1262 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"));
    binaryTestHelper("INSERT INTO `bug_repro_969` (`ip`) VALUES (?)",
            Collections.singletonList(new SerialBlob(failingInput)), CharsetUtil.ISO_8859_1, tests);
    tests.add(new StatementMirrorFun("SELECT binary ip FROM `bug_repro_969` order by message_id"));
    runTest(tests);//  www. ja  v a2  s.  c o m
}

From source file:com.tesora.dve.sql.InsertMysqlConnTest.java

License:Open Source License

@Test
public void testPE1149() throws Throwable {
    final byte[] failingInput = { (byte) 255 }; // any value above 127 will fail

    final List<MirrorTest> tests = new ArrayList<MirrorTest>();
    tests.add(new StatementMirrorProc(
            "CREATE TABLE `bug_repro_1149` (`user_session_id` INT NOT NULL AUTO_INCREMENT,`detail` blob, PRIMARY KEY (`user_session_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"));
    binaryTestHelper("INSERT INTO `bug_repro_1149` (`detail`) VALUES (?),('hi')",
            Collections.singletonList(new SerialBlob(failingInput)), CharsetUtil.ISO_8859_1, tests);
    tests.add(new StatementMirrorFun("SELECT * from `bug_repro_1149` ORDER BY `user_session_id`"));
    runTest(tests);//  ww w.  j av  a  2 s.  c o  m
}

From source file:com.tesora.dve.sql.InsertMysqlConnTest.java

License:Open Source License

@Test
public void testPE1327() throws Throwable {
    final byte[] failingInput = { (byte) 0xBE, (byte) 0x0E, (byte) 0x30, (byte) 0x5c, (byte) 0x5c };

    final List<MirrorTest> tests = new ArrayList<MirrorTest>();
    tests.add(new StatementMirrorProc("CREATE TABLE `ecb` (`bip` int(10) unsigned NOT NULL AUTO_INCREMENT, "
            + "`start` varbinary(16) NOT NULL, " + "`stop` varbinary(16) NOT NULL, " + "PRIMARY KEY (`bip`) "
            + ") ENGINE=InnoDB AUTO_INCREMENT=80 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"));
    binaryTestHelper("INSERT INTO `ecb` (`start`, `stop`) VALUES (?, ?)",
            Arrays.asList(new SerialBlob(failingInput), new SerialBlob(failingInput)), CharsetUtil.ISO_8859_1,
            tests);//ww  w.  ja  va2  s .  c  o  m
    tests.add(new StatementMirrorFun("SELECT start FROM `ecb`"));
    runTest(tests);
}

From source file:com.tesora.dve.sql.InsertMysqlConnTest.java

License:Open Source License

@Test
public void testPE1482() throws Throwable {
    final byte[] failingInput = { (byte) 0x80, 0x5c, 0x72, 0x5c, 0x6e, 0x5c, 0x74, 0x5c, 0x62, 0x5c, 0x5a, 0x5c,
            0x27, 0x5c, 0x22 }; // out of range char, \r, \n, \t, \b, \Z, \', \" 

    final List<MirrorTest> tests = new ArrayList<MirrorTest>();
    tests.add(new StatementMirrorProc(
            "CREATE TABLE `dgid` (`id` bigint(20) NOT NULL AUTO_INCREMENT, `p12Key` mediumblob NOT NULL, `email` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"));
    binaryTestHelper("INSERT INTO `dgid` (`p12Key`, `email`) VALUES (?, '')",
            Arrays.asList(new SerialBlob(failingInput)), CharsetUtil.ISO_8859_1, tests);

    tests.add(new StatementMirrorFun("SELECT p12Key FROM `dgid`"));
    runTest(tests);/*  w  w w  .  j  a v a2 s  .c  o  m*/
}

From source file:com.tesora.dve.sql.parser.FileParser.java

License:Open Source License

public void parseOneFileNative(InputStream in, LogLineBuffer buffer, ParserInvoker invoker) throws Throwable {
    parseOneFileNative(in, buffer, invoker, CharsetUtil.ISO_8859_1);
}

From source file:com.tesora.dve.sql.parser.FileParser.java

License:Open Source License

public static void convertNativeLog(InputStream in, OutputStream out, boolean force, LogFileFilter filter)
        throws Throwable {
    ConvertingParserInvoker cpi = new ConvertingParserInvoker(out, force);
    new FileParser().parseOneMysqlLogFile(in, cpi, CharsetUtil.ISO_8859_1, filter);
    cpi.close();//  www . j  a v  a  2s.c  o m
}

From source file:com.tesora.dve.sql.parser.FileParser.java

License:Open Source License

public static void convertPELog(InputStream in, OutputStream out, boolean force) throws Throwable {
    ConvertingParserInvoker cpi = new ConvertingParserInvoker(out, force);
    new FileParser().parseOnePELogFile(in, cpi, CharsetUtil.ISO_8859_1);
    cpi.close();/*ww w  .  j a  v a  2  s . com*/
}

From source file:com.tesora.dve.sql.parser.FileParser.java

License:Open Source License

public static void convertNativeLog(InputStream in, LogFileFilter filter, ConvertingParserInvoker cpi)
        throws Throwable {
    new FileParser().parseOneMysqlLogFile(in, cpi, CharsetUtil.ISO_8859_1, filter);
    cpi.close();/*w ww  .  j  ava2s .  c  o m*/
}

From source file:com.tesora.dve.sql.util.BlobColumnChecker.java

License:Open Source License

@Override
public String asString(Object in) {
    if (in == null) {
        return "null";
    }// w  w  w  .  jav a2 s  .c o m

    // May easily lead to heap exhaustion when handling large result sets.
    if (useFormatedOutput) {
        return asFormattedString(in);
    }

    return new String((byte[]) in, CharsetUtil.ISO_8859_1);
}