⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testhomework.java

📁 软件设计课做的一个类似Hibernate的O/R Mapping的框架
💻 JAVA
字号:
package cn.edu.nju.software.sd.torm.test;

import java.util.Calendar;

import cn.edu.nju.software.sd.torm.test.beans.Homework;

public class TestHomework extends SimpleTestCase {
    public void testLoadHomework() {
        try {
            Homework h = (Homework) manager.load(Homework.class, 1);
            assertTrue("Null value 'finished' expeced to be false", h
                    .getFinished() == false);
            System.out.println("You treat the null value as false");
        } catch (Exception e) {
            assertTrue(true);
            System.out.println("We cannot say you are right yet. "
                    + "Did you handle the null value for primitive types? "
                    + "We catch an exception here: " + e);
            e.printStackTrace();
        }

    }

    public void testInsertHomework() {
        Homework work = new Homework();
        // We do not set the dueDate property here!
        // So null is the default.
        work.setDueDate(Calendar.getInstance().getTime());
        work.setFinished(true);
        try {
            System.out.println(manager);
            manager.insert(work);
        } catch (Exception e) {
            assertTrue(true);
            System.out
                    .println("Did you handle the null object values when a not-null contraint "
                            + "exists? We catch an exception here: " + e);
            e.printStackTrace();
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -