Examples of AssertThrows


Examples of org.h2.test.utils.AssertThrows

        Restore.main("-file", fileName, "-dir", getBaseDir(), "-db", "utils", "-quiet");
        conn = DriverManager.getConnection("jdbc:h2:" + getBaseDir() + "/utils", "sa", "abc");
        ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM TEST");
        assertTrue(rs.next());
        assertFalse(rs.next());
        new AssertThrows(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1) {
            public void test() throws SQLException {
                // must fail when the database is in use
                Backup.main("-file", fileName, "-dir", getBaseDir(), "-db", "utils");
            }
        };
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

        args = new String[] { "-dir", dir, "-db", "utils", "-cipher", "AES", "-encrypt", "def", "-quiet" };
        ChangeFileEncryption.main(args);
        conn = DriverManager.getConnection(url + "/utils;CIPHER=AES", "sa", "def 123");
        stat = conn.createStatement();
        stat.execute("SELECT * FROM TEST");
        new AssertThrows(ErrorCode.CANNOT_CHANGE_SETTING_WHEN_OPEN_1) {
            public void test() throws SQLException {
                ChangeFileEncryption.main(new String[] {
                    "-dir", dir, "-db", "utils", "-cipher", "AES", "-decrypt", "def", "-quiet" });
            }
        };
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

        } catch (SQLException e) {
            assertKnownException(e);
        }
        conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
        conn.close();
        new AssertThrows(ErrorCode.WRONG_USER_OR_PASSWORD) {
            public void test() throws SQLException {
                Server.shutdownTcpServer("tcp://localhost:9192", "", true, false);
        }};
        conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test", "sa", "");
        // conn.close();
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

            assertEquals(Integer.reverse(y), s);
        }
    }

    private void testFactorial() {
        new AssertThrows(IllegalArgumentException.class) { public void test() {
            factorial(-1);
        }};
        assertEquals("1", factorial(0).toString());
        assertEquals("1", factorial(1).toString());
        assertEquals("2", factorial(2).toString());
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

    private void testHex() {
        assertEquals("face", StringUtils.convertBytesToHex(new byte[] { (byte) 0xfa, (byte) 0xce }));
        assertEquals(new byte[] { (byte) 0xfa, (byte) 0xce }, StringUtils.convertHexToBytes("face"));
        assertEquals(new byte[] { (byte) 0xfa, (byte) 0xce }, StringUtils.convertHexToBytes("fAcE"));
        assertEquals(new byte[] { (byte) 0xfa, (byte) 0xce }, StringUtils.convertHexToBytes("FaCe"));
        new AssertThrows(DbException.class) { public void test() {
            StringUtils.convertHexToBytes("120");
        }};
        new AssertThrows(DbException.class) { public void test() {
            StringUtils.convertHexToBytes("fast");
        }};
    }
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

        assertEquals(10, v.convertPrecision(10, true).getPrecision());

        final Value vd = ValueDecimal.get(new BigDecimal("1234567890.123456789"));
        assertEquals(19, vd.getPrecision());
        assertEquals("1234567890.1234567", vd.convertPrecision(10, true).getString());
        new AssertThrows(ErrorCode.NUMERIC_VALUE_OUT_OF_RANGE_1) { public void test() {
            vd.convertPrecision(10, false);
        }};

        v = ValueLobDb.createSmallLob(Value.CLOB, spaces.getBytes(), 100);
        assertEquals(100, v.getPrecision());
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

        assertEquals("00000000-0000-4000-8000-000000000000", min.getString());
    }

    private void testModulusDouble() {
        final ValueDouble vd1 = ValueDouble.get(12);
        new AssertThrows(ErrorCode.DIVISION_BY_ZERO_1) { public void test() {
            vd1.modulus(ValueDouble.get(0));
        }};
        ValueDouble vd2 = ValueDouble.get(10);
        ValueDouble vd3 = vd1.modulus(vd2);
        assertEquals(2, vd3.getDouble());
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

        assertEquals(2, vd3.getDouble());
    }

    private void testModulusDecimal() {
        final ValueDecimal vd1 = ValueDecimal.get(new BigDecimal(12));
        new AssertThrows(ErrorCode.DIVISION_BY_ZERO_1) { public void test() {
            vd1.modulus(ValueDecimal.get(new BigDecimal(0)));
        }};
        ValueDecimal vd2 = ValueDecimal.get(new BigDecimal(10));
        ValueDecimal vd3 = vd1.modulus(vd2);
        assertEquals(2, vd3.getDouble());
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

        assertEquals(0, ValueTimestamp.parse("1970-01-01").getNanos());
        assertEquals(0, ValueTimestamp.parse("1970-01-01 00:00:00.000 UTC").getTimestamp().getTime());
        assertEquals(0, ValueTimestamp.parse("+1970-01-01T00:00:00.000Z").getTimestamp().getTime());
        assertEquals(0, ValueTimestamp.parse("1970-01-01T00:00:00.000+00:00").getTimestamp().getTime());
        assertEquals(0, ValueTimestamp.parse("1970-01-01T00:00:00.000-00:00").getTimestamp().getTime());
        new AssertThrows(ErrorCode.INVALID_DATETIME_CONSTANT_2) { public void test() {
            ValueTimestamp.parse("1970-01-01 00:00:00.000 ABC");
        }};
        new AssertThrows(ErrorCode.INVALID_DATETIME_CONSTANT_2) { public void test() {
            ValueTimestamp.parse("1970-01-01T00:00:00.000+ABC");
        }};
    }
View Full Code Here

Examples of org.h2.test.utils.AssertThrows

        testServer();
        testWebApp();
    }

    private void testWrongParameters() throws Exception {
        new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
            public void test() throws SQLException {
                Server.createPgServer("-pgPort 8182");
        }};
        new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
            public void test() throws SQLException {
                Server.createTcpServer("-tcpPort 8182");
        }};
        new AssertThrows(ErrorCode.FEATURE_NOT_SUPPORTED_1) {
            public void test() throws SQLException {
            Server.createWebServer("-webPort=8182");
        }};
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.