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

📄 testxmlstorage.java

📁 Gmail API for Java 一个gmail信箱的客户端
💻 JAVA
字号:
package siuying.gm.test;

import siuying.gm.app.gmailer4j.*;
import java.util.*;
import siuying.gm.structure.*;
import java.io.*;
import java.util.logging.*;
import junit.framework.*;

public class TestXMLStorage extends TestCase{
    private static String url = "data\\";
    private XMLStorage store;
    private GMConversationEntry entry1;
    private Logger logger = Logger.getLogger(TestXMLStorage.class.getName());

    protected void setUp() {
        entry1 = new GMConversationEntry();
        entry1.setIndex("2");
        entry1.setId("Q902882753A09");
        entry1.setSender("Mino");
        entry1.setSender_email("abc@bcd.com");
        entry1.setRecv("Siuying");
        entry1.setRecv_email("siu.ying@test.gmail.com");
        entry1.setDt("18 September 2004, 11:24:35 +08:00");
        entry1.setDt_easy("18 Sep 2004");
        entry1.setSubj("unread entry test");
        entry1.setSnippet("");
        entry1.setBody("This is ANOTHER test!<br>Hi!<br>Hihi!");

        ArrayList attachment = new ArrayList();
        attachment.add("DD.html");
        entry1.setAttachment(attachment);

        try{
            store = XMLStorage.getXMLStorage(url);
        }catch (IOException ioe){

        }


        try{
            store.open();
        }catch(Exception e){

        }
	}

    public void testGetXMLStorage(){
        try{
            store = XMLStorage.getXMLStorage(url);
        }catch (IOException ioe){
            fail("I/O error: " + ioe.getMessage());
        }
        assertEquals(store.getUrl(), url);
    }

    public void testOpen(){
        try{
            store.open();
        }catch(Exception e){
            fail("Exception while opening store: " + e);
        }
    }

    public void testContainsThreadId(){
        File file = new File(url + File.separator + "Dummy.xml");
        boolean exist = file.exists();
        logger.info(file + " exist? " + exist);
        assertTrue(exist == store.containsId("Dummy"));
    }

    public void testAdd(){
        try{
            store.put("TestEntry1", entry1);
        }catch (Exception e){
            fail("failed add thread: " + e);
        }

        assertTrue(store.containsId("TestEntry1"));
    }

    public void testGet(){
        GMConversationEntry entry = null;
        try{
            entry = (GMConversationEntry)store.get("TestEntry1");
        }catch (Exception e){
            fail("failed remove thread: " + e);
        }

        assertTrue(entry != null);

        logger.info("Original: " + entry1);
        logger.info("Now: " + entry);

        assertTrue(entry1.equals(entry));
    }

    public void testRemove(){
        try{
            store.remove("TestEntry1");
        }catch (Exception e){
            fail("failed remove thread: " + e);
        }

        assertTrue(!store.containsId("TestEntry1"));
    }


    public static void main (String[] args) {
            junit.swingui.TestRunner.run(TestXMLStorage.class);
    }
}


⌨️ 快捷键说明

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