?? testxmlstorage.java
字號(hào):
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);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -