Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.Date


     * @throws Exception if failed
     */
    @Test
    public void date_values_direct() throws Exception {
        dateFormat = "yyyyMMdd";
        assertRestorable(new DateOption(new Date(2011, 3, 31)));
        assertRestorable(new DateOption(new Date(1971, 4, 1)));
        assertRestorable(new DateOption());
    }
View Full Code Here


    @Test
    public void stress_date() throws Exception {
        int count = 5000000;
        CsvEmitter emitter = new CsvEmitter(new VoidOutputStream(), "testing", createConfiguration());
        try {
            DateOption value = new DateOption(new Date(1999, 12, 31));
            for (int i = 0; i < count; i++) {
                emitter.emit(value);
                emitter.endRecord();
            }
        } finally {
View Full Code Here

        assertThat(object.get("type_decimal"), eq(new BigDecimal("1234.567")));

        object.set("type_text", new Text("Hello, world!"));
        assertThat(object.get("type_text"), eq(new Text("Hello, world!")));

        object.set("type_date", new Date(2011, 3, 31));
        assertThat(object.get("type_date"), eq(new Date(2011, 3, 31)));

        object.set("type_datetime", new DateTime(2011, 3, 31, 23, 30, 1));
        assertThat(object.get("type_datetime"), eq(new DateTime(2011, 3, 31, 23, 30, 1)));
    }
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void placeholder_date() throws Exception {
        Mock mock = new Mock(spec(DATE, "yyyy/MM/dd"));
        mock.setMock(new DateOption(new Date(2012, 2, 3)));
        assertThat(mock.apply(), is("2012/02/03"));
    }
View Full Code Here

     */
    @Test
    public void serialize() throws Exception {
        Mock mock = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy/MM/dd"));

        mock.setMock("", "0", "", new DateOption(new Date(2012, 1, 2)));
        byte[] s0 = ser(mock);
        Mock r0 = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy/MM/dd"));
        des(r0, s0);

        assertThat(r0.apply(), is("left0right2012/01/02"));
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void compare() throws Exception {
        Mock a = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy"));
        a.setMock("", "0", "", new DateOption(new Date(2012, 1, 2)));

        Mock b = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy"));
        b.setMock("", "1", "", new DateOption(new Date(2012, 1, 2)));

        Mock c = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy"));
        c.setMock("", "1", "", new DateOption(new Date(2013, 1, 2)));

        Mock d = new Mock(plain("left"), spec(NATURAL), plain("right"), spec(DATE, "yyyy"));
        d.setMock("LLLLLLLLLLLLLL", "0", "RRRRRRRRRRRRRR", new DateOption(new Date(2012, 2, 3)));

        assertThat(cmp(a, b), is(not(0)));
        assertThat(cmp(b, c), is(not(0)));
        assertThat(cmp(a, d), is(equalTo(0)));
    }
View Full Code Here

            case DATE:
                DateOption dateOption = (DateOption) vo;
                if (dateOption.isNull()) {
                    ps.setNull(parameterIndex, Types.DATE);
                } else {
                    Date date = dateOption.get();
                    Calendar cal = Calendar.getInstance();
                    int y = date.getYear();
                    int m = date.getMonth();
                    int d = date.getDay();
                    cal.clear();
                    cal.set(y, m - 1, d, 0, 0, 0);
                    java.sql.Date sqlDate = new java.sql.Date(cal.getTimeInMillis());
                    ps.setDate(parameterIndex, sqlDate);
                }
View Full Code Here

        object.set("type_long", 200L);
        object.set("type_float", 300.f);
        object.set("type_double", 400.d);
        object.set("type_decimal", new BigDecimal("1234.567"));
        object.set("type_text", new Text("Hello, world!"));
        object.set("type_date", new Date(2011, 3, 31));
        object.set("type_datetime", new DateTime(2011, 3, 31, 23, 30, 1));

        DataOutputBuffer output = new DataOutputBuffer();
        ModelOutput<Object> modelOut = (ModelOutput<Object>) type.getAnnotation(ModelOutputLocation.class)
            .value()
View Full Code Here

            if (actualVal.isNull()) {
                fail(Type.NOT_IN_TEST_DAY, expect, actual, expectVal, actualVal, columnInfo);
                return;
            }
            DateOption dateOption = (DateOption) actualVal;
            Date date = dateOption.get();
            cal.clear();
            cal.set(date.getYear(), date.getMonth() - 1, date.getDay());
        } else if (actualVal instanceof DateTimeOption) {
            if (actualVal.isNull()) {
                fail(Type.NOT_IN_TEST_DAY, expect, actual, expectVal, actualVal, columnInfo);
                return;
            }
View Full Code Here

            int secs = DateUtil.getSecondFromTime(h, min, s);
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400 + secs);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
            //            System.out.println(cause.getMessage());
            if (cause.getType().equals(Type.NOT_IN_TESTING_TIME)) {
                System.out.println(cause.getMessage());
            }
            assertEquals("エラー原因のチェック", Type.CONDITION_NOW_ON_INVALID_COLUMN, cause.getType());
        }
        assertEquals("エラー原因のリストの要素数", 36, inspector.getCauses().size()); // 4件成功するのでNG件数が40-4=36(件)となる。
        assertFalse("検査失敗", inspector.isSuccess());

        // NGとなるケース(実値に未来時刻を指定して、inspect()を実行)
        for (AllTypesWNoerr model : getActualList()) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            int y = cal.get(Calendar.YEAR);
            int m = cal.get(Calendar.MONTH);
            int d = cal.get(Calendar.DAY_OF_MONTH);
            int h = cal.get(Calendar.HOUR_OF_DAY);
            int min = cal.get(Calendar.MINUTE);
            int s = cal.get(Calendar.SECOND);
            int days = DateUtil.getDayFromDate(y + 1, m + 1, d); // 1年後を指定
            int secs = DateUtil.getSecondFromTime(h, min, s);
            DateTime dt = new DateTime();
            dt.setElapsedSeconds((long) days * 86400 + secs);
            model.getCDatetimeOption().modify(dt);

            Date date = new Date();
            date.setElapsedDays(days);
            model.getCDateOption().modify(date);
        }
        inspector.clear();
        inspector.inspect(dataHolder);
        for (Cause cause : inspector.getCauses()) {
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.Date

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.