Package org.voltdb.types

Examples of org.voltdb.types.TimestampType


        // Now we repeat the same thing, but adding a valid order-line.
        // long ol_o_id, long ol_d_id, long ol_w_id, long ol_number, long
        // ol_i_id, long ol_supply_w_id, Date ol_delivery_d, long ol_quantity,
        // double ol_amount, String ol_dist_info
        TimestampType timestamp = new TimestampType();
        VoltTable[] olresults = client.callProcedure("InsertOrderLine", 4L, 7L,
                3L, 1L, 4L, 3L, timestamp, 45L, 152.15, "blah blah blah").getResults();
        assertEquals(1L, olresults[0].asScalarLong());

        try {
            // We expect this to fail because the stock table is empty.
            results = client.callProcedure(TPCCConstants.STOCK_LEVEL, (byte)3, (byte)7, 1).getResults();

            //
            // If this is true SLEV procedure, then we want to check that we got nothing
            //
            if (TPCCConstants.STOCK_LEVEL.equals(slev.class.getSimpleName())) {
                // check one table was returned
                assertEquals(1, results.length);
                // check one tuple was modified
                result = results[0];
                assertNotNull(result);
                stockCount = result.asScalarLong();
                // check count was 0 (should be, for we have an empty stock table.
                assertEquals(0L, stockCount);
            //
            // Otherwise it's the "hand-crafted" SLEV, which should return an error
            //
            } else {
                fail("expected exception");
            }
        } catch (ProcCallException e) {}

        // Now we repeat the same thing, but adding a valid stock.
        // long pkey, long s_i_id, long s_w_id, long s_quantity, String
        // s_dist_01, String s_dist_02, String s_dist_03, String s_dist_04,
        // String s_dist_05, String s_dist_06, String s_dist_07, String
        // s_dist_08, String s_dist_09, String s_dist_10, long s_ytd, double
        // s_order_cnt, double s_remote_cnt, String s_data
        timestamp = new TimestampType();
        VoltTable[] isresults = client.callProcedure("InsertStock", 4L, 3L, 45L,
                "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO", "INFO",
                "INFO", "INFO", 5582L, 152L, 32L, "DATA").getResults();
        assertEquals(1L, isresults[0].asScalarLong());
View Full Code Here


        // c_credit, double c_credit_lim, double c_discount, double c_balance,
        // double c_ytd_payment, double c_payment_cnt, double c_delivery_cnt,
        // String c_data
        VoltTable customer = client.callProcedure("InsertCustomer", C_ID, D_ID,
                W_ID, "I", "Is", "Name", "Place", "Place2", "BiggerPlace",
                "AL", "91083", "(913) 909 - 0928", new TimestampType(), "GC",
                19298943.12, C_DISCOUNT, 15.75, 18832.45, 45L, 15L,
                "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer.asScalarLong());

        final int[] s_quantities = { 45, 85, 15 };
        final long INITIAL_S_YTD = 5582L;
        final long INITIAL_S_ORDER_CNT = 152L;
        // long pkey, long s_i_id, long s_w_id, long s_quantity, String
        // s_dist_01, String s_dist_02, String s_dist_03, String s_dist_04,
        // String s_dist_05, String s_dist_06, String s_dist_07, String
        // s_dist_08, String s_dist_09, String s_dist_10, long s_ytd, long
        // s_order_cnt, long s_remote_cnt, String s_data
        VoltTable stock1 = client.callProcedure("InsertStock", 4L, W_ID,
                s_quantities[0], "INFO", "INFO", "INFO", "INFO", "INFO",
                "INFO", "INFO", "INFO", "INFO", "INFO", INITIAL_S_YTD, INITIAL_S_ORDER_CNT, 32L,
                "DATA").getResults()[0];
        VoltTable stock2 = client.callProcedure("InsertStock", 5L, W_ID,
                s_quantities[1], "INFO", "INFO", "INFO", "INFO", "INFO",
                "INFO", "INFO", "INFO", "INFO", "INFO", INITIAL_S_YTD+10, INITIAL_S_ORDER_CNT+10,
                32L, "foo" + TPCCConstants.ORIGINAL_STRING + "bar").getResults()[0];
        VoltTable stock3 = client.callProcedure("InsertStock", 6L, W_ID,
                s_quantities[2], "INFO", "INFO", "INFO", "INFO", "INFO",
                "INFO", "INFO", "INFO", "INFO", "INFO", INITIAL_S_YTD+20, INITIAL_S_ORDER_CNT+20,
                32L, "DATA").getResults()[0];

        final double PRICE = 2341.23;
        // long i_id, long i_im_id, String i_name, double i_price, String i_data
        ClientResponse cr =
        client.callProcedure("InsertItem", 4L, 4L, "ITEM1",
                PRICE, TPCCConstants.ORIGINAL_STRING);
        VoltTable item1 = cr.getResults()[0];
       
        VoltTable item2 = client.callProcedure("InsertItem", 5L, 5L, "ITEM2",
                PRICE, TPCCConstants.ORIGINAL_STRING).getResults()[0];
        VoltTable item3 = client.callProcedure("InsertItem", 6L, 6L, "ITEM3",
                PRICE, TPCCConstants.ORIGINAL_STRING).getResults()[0];
        // check the inserts went through.
        assertEquals(1L, stock1.asScalarLong());
        assertEquals(1L, stock2.asScalarLong());
        assertEquals(1L, stock3.asScalarLong());
        assertEquals(1L, item1.asScalarLong());
        assertEquals(1L, item2.asScalarLong());
        assertEquals(1L, item3.asScalarLong());

        // call the neworder transaction:
        // if(ol_supply_w_id != w_id) all_local = 0;
        // test all_local behavior, first, then remote warehouse situation.

        // long w_id, long d_id, long c_id, long ol_cnt, long all_local, long[]
        // item_id, long[] supware, long[] quantity
        int[] items = { 4, 5, 6 };
        short[] warehouses = { W_ID, W_ID, W_ID };
        int[] quantities = { 3, 5, 1 };

        TPCDataPrinter.printAllData(client);
        TimestampType timestamp = new TimestampType();
        VoltTable[] neworder = client.callProcedure(TPCCConstants.NEWORDER, W_ID, D_ID, C_ID,
                timestamp, items, warehouses, quantities).getResults();

        // Now to check returns are correct. We assume that inserts and such
        // within the actual transaction went through since it didn't rollback
View Full Code Here

        // double c_ytd_payment, double c_payment_cnt, double c_delivery_cnt,
        // String c_data
        final double initialBalance = 15.75;
        VoltTable customer1 = client.callProcedure("InsertCustomer", C_ID, D_ID,
                W_ID, "I", "Be", "lastname", "Place", "Place2", "BiggerPlace",
                "AL", "91083", "(193) 099 - 9082", new TimestampType(), "BC",
                19298943.12, .13, initialBalance, initialYTD, 0L, 15L,
                "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer1.asScalarLong());

        VoltTable customer2 = client.callProcedure("InsertCustomer", C_ID + 1,
                D_ID, W_ID, "We", "R", "Customer", "Random Department",
                "Place2", "BiggerPlace", "AL", "13908", "(913) 909 - 0928",
                new TimestampType(), "GC", 19298943.12, .13, initialBalance, initialYTD,
                1L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer2.asScalarLong());

        VoltTable customer3 = client.callProcedure("InsertCustomer", C_ID + 2,
                D_ID, W_ID, "Who", "Is", "Customer", "Receiving",
                "450 Mass F.X.", "BiggerPlace", "CI", "91083",
                "(541) 931 - 0928", new TimestampType(), "GC", 19899324.21, .13,
                initialBalance, initialYTD, 2L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer3.asScalarLong());

        VoltTable customer4 = client.callProcedure("InsertCustomer", C_ID + 3,
                D_ID, W_ID, "ICanBe", "", "Customer", "street", "place",
                "BiggerPlace", "MA", "91083", "(913) 909 - 0928", new TimestampType(),
                "GC", 19298943.12, .13, initialBalance, initialYTD, 3L, 15L,
                "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer4.asScalarLong());

        // long d_id, long w_id, double h_amount, String c_last, long c_w_id,
        // long c_d_id
        final double paymentAmount = 500.25;
        VoltTable[] results = client.callProcedure(TPCCConstants.PAYMENT_BY_NAME, W_ID,
                D_ID, paymentAmount, W_ID, D_ID, "Customer", new TimestampType()).getResults();
        assertEquals(3, results.length);
        // check that the middle "Customer" was returned
        assertEquals(C_ID + 1, results[2].fetchRow(0).getLong("c_id"));
        assertEquals("", results[2].fetchRow(0).getString("c_data"));

        // Verify that both warehouse, district and customer were updated
        // correctly
        VoltTable[] allTables = client.callProcedure("SelectAll").getResults();
        warehouse = allTables[TPCDataPrinter.nameMap.get("WAREHOUSE")];
        assertEquals(1, warehouse.getRowCount());
        assertEquals(initialYTD + paymentAmount, warehouse.fetchRow(0)
                .getDouble("W_YTD"));
        district = allTables[TPCDataPrinter.nameMap.get("DISTRICT")];
        assertEquals(1, district.getRowCount());
        assertEquals(initialYTD + paymentAmount, district.fetchRow(0)
                .getDouble("D_YTD"));
        customer1 = allTables[TPCDataPrinter.nameMap.get("CUSTOMER")];
        assertEquals(4, customer1.getRowCount());
        assertEquals(C_ID + 1, customer1.fetchRow(1).getLong("C_ID"));
        assertEquals(initialBalance - paymentAmount, customer1.fetchRow(1)
                .getDouble("C_BALANCE"));
        assertEquals(initialYTD + paymentAmount, customer1.fetchRow(1)
                .getDouble("C_YTD_PAYMENT"));
        assertEquals(2, customer1.fetchRow(1).getLong("C_PAYMENT_CNT"));

        // long d_id, long w_id, double h_amount, String c_last, long c_w_id,
        // long c_d_id
        results = client.callProcedure("paymentByCustomerId", W_ID, D_ID,
                paymentAmount, W_ID, D_ID, C_ID, new TimestampType()).getResults();
        // Also tests badcredit case.
        assertEquals(3, results.length);
        assertEquals(C_ID, results[2].fetchRow(0).getLong("c_id"));
        // bad credit: insert history into c_data
        String data = results[2].fetchRow(0).getString("c_data");
View Full Code Here

        // double c_ytd_payment, double c_payment_cnt, double c_delivery_cnt,
        // String c_data
        final double initialBalance = 15.75;
        VoltTable customer1 = client.callProcedure("InsertCustomer", C_ID, D_ID,
                W_ID, "I", "Be", "lastname", "Place", "Place2", "BiggerPlace",
                "AL", "91083", "(193) 099 - 9082", new TimestampType(), "BC",
                19298943.12, .13, initialBalance, initialYTD, 0L, 15L,
                "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer1.asScalarLong());

        VoltTable customer2 = client.callProcedure("InsertCustomer", C_ID + 1,
                D_ID, W_ID, "We", "R", "Customer", "Random Department",
                "Place2", "BiggerPlace", "AL", "13908", "(913) 909 - 0928",
                new TimestampType(), "GC", 19298943.12, .13, initialBalance, initialYTD,
                1L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer2.asScalarLong());

        VoltTable customer3 = client.callProcedure("InsertCustomer", C_ID + 2,
                D2_ID, W2_ID, "Who", "Is", "Customer", "Receiving",
                "450 Mass F.X.", "BiggerPlace", "CI", "91083",
                "(541) 931 - 0928", new TimestampType(), "GC", 19899324.21, .13,
                initialBalance, initialYTD, 2L, 15L, "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer3.asScalarLong());

        VoltTable customer4 = client.callProcedure("InsertCustomer", C_ID + 3,
                D2_ID, W2_ID, "ICanBe", "", "Customer", "street", "place",
                "BiggerPlace", "MA", "91083", "(913) 909 - 0928", new TimestampType(),
                "GC", 19298943.12, .13, initialBalance, initialYTD, 3L, 15L,
                "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer4.asScalarLong());

        final double paymentAmount = 500.25;
        // long d_id, long w_id, double h_amount, String c_last, long c_w_id,
        // long c_d_id
        // w_id =Warehouse2 but c_w_id=warehouse1 !
        VoltTable[] results = client.callProcedure(TPCCConstants.PAYMENT_BY_NAME, W2_ID,
                D2_ID, paymentAmount, W_ID, D_ID, "Customer", new TimestampType()).getResults();
        assertEquals(3, results.length);
        assertTrue(results[0].getRowCount() > 0);
        // only customer2 should be returned as this is a query on warehouse1
        assertEquals(C_ID + 1, results[2].fetchRow(0).getLong("c_id"));
        assertEquals("", results[2].fetchRow(0).getString("c_data"));

/* TODO : SelectAll doesn't work for multi-partition. how to check results?
        // Verify that both warehouse, district and customer were updated
        // correctly
        VoltTable[] allTables = client.callProcedure("SelectAll");
        warehouse = allTables[TPCDataPrinter.nameMap.get("WAREHOUSE")];
        assertEquals(1, warehouse.getRowCount());
        assertEquals(initialYTD + paymentAmount, warehouse.fetchRow(0)
                .getDouble("W_YTD"));
        district = allTables[TPCDataPrinter.nameMap.get("DISTRICT")];
        assertEquals(1, district.getRowCount());
        assertEquals(initialYTD + paymentAmount, district.fetchRow(0)
                .getDouble("D_YTD"));
        customer1 = allTables[TPCDataPrinter.nameMap.get("CUSTOMER")];
        assertEquals(4, customer1.getRowCount());
        assertEquals(C_ID + 1, customer1.fetchRow(1).getLong("C_ID"));
        assertEquals(initialBalance - paymentAmount, customer1.fetchRow(1)
                .getDouble("C_BALANCE"));
        assertEquals(initialYTD + paymentAmount, customer1.fetchRow(1)
                .getDouble("C_YTD_PAYMENT"));
        assertEquals(2, customer1.fetchRow(1).getLong("C_PAYMENT_CNT"));
        */

        // long d_id, long w_id, double h_amount, String c_last, long c_w_id,
        // long c_d_id
        // w_id =Warehouse2 but c_w_id=warehouse1 !
        results = client.callProcedure("paymentByCustomerId", W2_ID, D2_ID,
                paymentAmount, W_ID, D_ID, C_ID, new TimestampType()).getResults();
        // Also tests badcredit case.
        assertEquals(3, results.length);
        assertEquals(C_ID, results[2].fetchRow(0).getLong("c_id"));
        // bad credit: insert history into c_data
        String data = results[2].fetchRow(0).getString("c_data");
View Full Code Here

        // check for successful insertion.
        assertEquals(1L, warehouse.asScalarLong());

        VoltTable customer = client.callProcedure("InsertCustomer", 5L, 7L, 3L,
                "We", "R", "Customer", "Random Department", "Place2",
                "BiggerPlace", "AL", "13908", "(913) 909 - 0928", new TimestampType(),
                "GC", 19298943.12, .13, 15.75, 18832.45, 45L, 15L,
                "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer.asScalarLong());

        VoltTable orders = client.callProcedure("InsertOrders", 9L, 7L, 3L, 5L,
                new TimestampType(), 10L, 5L, 6L).getResults()[0];
        // check for successful insertion.
        assertEquals(1L, orders.asScalarLong());

        TPCDataPrinter.printAllData(client);
View Full Code Here

        assertEquals(1L, warehouse.asScalarLong());

        VoltTable customer = client.callProcedure("InsertCustomer", 5L, D_ID,
                W_ID, "We", "R", "Customer", "Random Department",
                "Place2", "BiggerPlace", "AL", "13908", "(913) 909 - 0928",
                new TimestampType(), "GC", 19298943.12, .13, 15.75, 18832.45, 45L, 15L,
                "Some History").getResults()[0];
        // check for successful insertion.
        assertEquals(1L, customer.asScalarLong());

        final long O_OL_CNT = 1;
        VoltTable orders = client.callProcedure("InsertOrders", O_ID, D_ID, W_ID,
                5L, new TimestampType(), 10L, O_OL_CNT, 1L).getResults()[0];
        // check for successful insertion.
        assertEquals(1L, orders.asScalarLong());

        // Insert an order line for this order
        VoltTable line = client.callProcedure("InsertOrderLine",
                O_ID, D_ID, W_ID, 1L, I_ID, W_ID, new TimestampType(), 1L,
                1.0, "ol_dist_info").getResults()[0];
        assertEquals(1L, line.asScalarLong());

        VoltTable newOrder = client.callProcedure("InsertNewOrder", O_ID, D_ID,
                W_ID).getResults()[0];
        // check for successful insertion.
        assertEquals(1L, newOrder.asScalarLong());

        System.out.println("DATA before DELIVERY transaction");
        TPCDataPrinter.printAllData(client);

        VoltTable[] results = client.callProcedure(TPCCConstants.DELIVERY, W_ID, 10,
                new TimestampType()).getResults();

        System.out.println("DATA after DELIVERY transaction");
        TPCDataPrinter.printAllData(client);

        assertEquals(1, results.length);
View Full Code Here

        final double EPSILON = 0.00001;
        final BigDecimal moneyOne = new BigDecimal(BigInteger.valueOf(7700000000000L), 12);
        final BigDecimal moneyTwo = new BigDecimal(BigInteger.valueOf(1100000000000L), 12);

        try {
            client.callProcedure("InsertAllTypes", 1, 2, 3, 4, new TimestampType(5),
                                 0.6, moneyOne, "inlined", "uninlined");
            client.callProcedure("InsertAllTypes", 7, 6, 5, 4, new TimestampType(3),
                                 0.2, moneyTwo, "INLINED", "UNINLINED");
        } catch (ProcCallException e1) {
            System.err.printf(">>> %s UNEXPECTED[0] %s\n", procName, e1);
            e1.printStackTrace();
            fail();
        }

        try {
            if (procName.contains("MultiOps"))
                client.callProcedure("AllTypesMultiOpsJavaError", order, id);
            else if (procName.contains("Update"))
                client.callProcedure(procName, 7);
            else
                client.callProcedure(procName);
            System.err.printf(">>> %s DID NOT FAIL!\n", procName);
            fail();
        }
        catch (ProcCallException e) {}
        catch (IOException e) {
            System.err.printf(">>> %s UNEXPECTED[1] %s\n", procName, e);
            e.printStackTrace();
            fail();
        }

        try {
            VoltTable[] results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES ORDER BY ID ASC;").getResults();

            // get the table
            VoltTable table = results[0];
            assertTrue(table.getRowCount() == 2);

            table.advanceRow();
            assertEquals(1, table.getLong(0));
            assertEquals(2, table.getLong(1));
            assertEquals(3, table.getLong(2));
            assertEquals(4, table.getLong(3));
            assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
            assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
            assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
            assertTrue(table.getString(7).equals("inlined"));
            assertTrue(table.getString(8).equals("uninlined"));

            table.advanceRow();
            assertEquals(7, table.getLong(0));
            assertEquals(6, table.getLong(1));
            assertEquals(5, table.getLong(2));
            assertEquals(4, table.getLong(3));
            assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
            assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
            assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
            assertTrue(table.getString(7).equals("INLINED"));
            assertTrue(table.getString(8).equals("UNINLINED"));

            // Check by using the indexes
            results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE ID > 3;").getResults();

            // get the table
            table = results[0];
            assertTrue(table.getRowCount() == 1);

            table.advanceRow();
            assertEquals(7, table.getLong(0));
            assertEquals(6, table.getLong(1));
            assertEquals(5, table.getLong(2));
            assertEquals(4, table.getLong(3));
            assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
            assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
            assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
            assertTrue(table.getString(7).equals("INLINED"));
            assertTrue(table.getString(8).equals("UNINLINED"));

            // unique hash index
            results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE ID = 1;").getResults();

            // get the table
            table = results[0];
            assertTrue(table.getRowCount() == 1);

            table.advanceRow();
            assertEquals(1, table.getLong(0));
            assertEquals(2, table.getLong(1));
            assertEquals(3, table.getLong(2));
            assertEquals(4, table.getLong(3));
            assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
            assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
            assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
            assertTrue(table.getString(7).equals("inlined"));
            assertTrue(table.getString(8).equals("uninlined"));

            // multimap tree index
            results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES ORDER BY TINY, SMALL, BIG, T, RATIO, MONEY, INLINED DESC;").getResults();

            // get the table
            table = results[0];
            assertTrue(table.getRowCount() == 2);

            table.advanceRow();
            assertEquals(1, table.getLong(0));
            assertEquals(2, table.getLong(1));
            assertEquals(3, table.getLong(2));
            assertEquals(4, table.getLong(3));
            assertEquals(new TimestampType(5), table.getTimestampAsTimestamp(4));
            assertTrue(Math.abs(0.6 - table.getDouble(5)) < EPSILON);
            assertEquals(moneyOne, table.getDecimalAsBigDecimal(6));
            assertTrue(table.getString(7).equals("inlined"));
            assertTrue(table.getString(8).equals("uninlined"));

            table.advanceRow();
            assertEquals(7, table.getLong(0));
            assertEquals(6, table.getLong(1));
            assertEquals(5, table.getLong(2));
            assertEquals(4, table.getLong(3));
            assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
            assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
            assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
            assertTrue(table.getString(7).equals("INLINED"));
            assertTrue(table.getString(8).equals("UNINLINED"));

            // multimap hash index
            results = client.callProcedure("@AdHoc", "SELECT * FROM ALL_TYPES WHERE TINY = 6 AND SMALL = 5 AND BIG = 4;").getResults();

            // get the table
            table = results[0];
            assertTrue(table.getRowCount() == 1);

            table.advanceRow();
            assertEquals(7, table.getLong(0));
            assertEquals(6, table.getLong(1));
            assertEquals(5, table.getLong(2));
            assertEquals(4, table.getLong(3));
            assertEquals(new TimestampType(3), table.getTimestampAsTimestamp(4));
            assertTrue(Math.abs(0.2 - table.getDouble(5)) < EPSILON);
            assertEquals(moneyTwo, table.getDecimalAsBigDecimal(6));
            assertTrue(table.getString(7).equals("INLINED"));
            assertTrue(table.getString(8).equals("UNINLINED"));

View Full Code Here

    }

    /* round trip the constructors */
    public void testTimestampCreation() {
        long usec = 999999999;
        TimestampType ts1 = new TimestampType(usec);
        assertEquals(usec, ts1.getTime());

        usec = 999999000;
        ts1 = new TimestampType(usec);
        assertEquals(usec, ts1.getTime());
    }
View Full Code Here

        assertEquals(usec, ts1.getTime());
    }

    /* Compare some values that differ by microseconds and by full millis */
    public void testTimestampEquality() {
        TimestampType ts1 = new TimestampType(150000);
        TimestampType ts2 = new TimestampType(150000);
        TimestampType ts3 = new TimestampType(150001);
        TimestampType ts4 = new TimestampType(160000);

        assertTrue(ts1.equals(ts2));
        assertTrue(ts2.equals(ts1));
        assertFalse(ts1.equals(ts3));
        assertFalse(ts3.equals(ts1));
        assertFalse(ts1.equals(ts4));
        assertFalse(ts4.equals(ts1));

        assertTrue(ts1.compareTo(ts2) == 0);
        assertTrue(ts2.compareTo(ts1) == 0);
        assertTrue(ts1.compareTo(ts3) < 0);
        assertTrue(ts3.compareTo(ts1) > 0);
        assertTrue(ts1.compareTo(ts4) < 0);
        assertTrue(ts4.compareTo(ts1) > 0);
    }
View Full Code Here

        // I suppose these could fall across minute boundaries and fail the
        // test.. but that would seem exceedingly unlikely? Do this a few times
        // to try to avoid the false negative.
        for (int ii=0; ii < 5; ++ii) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            TimestampType now = new TimestampType();
            Date date = new Date();
            if (now.toString().startsWith(sdf.format(date))) {
                assertTrue(now.toString().startsWith(sdf.format(date)));
                return;
            }
        }
        fail();
    }
View Full Code Here

TOP

Related Classes of org.voltdb.types.TimestampType

Copyright © 2018 www.massapicom. 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.