01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //limitations under the License.
10: //
11: //The Original Code is "The Columba Project"
12: //
13: //The Initial Developers of the Original Code are Frederik Dietz and Timo
14: // Stich.
15: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16: //
17: //All Rights Reserved.
18: package org.columba.addressbook.parser;
19:
20: import java.io.BufferedInputStream;
21: import java.io.BufferedOutputStream;
22: import java.io.File;
23: import java.io.FileInputStream;
24: import java.io.FileOutputStream;
25:
26: import junit.framework.TestCase;
27:
28: import org.columba.addressbook.model.ContactModel;
29: import org.columba.addressbook.model.IContactModel;
30: import org.columba.core.xml.XmlNewIO;
31: import org.jdom.Document;
32:
33: /**
34: * @author fdietz
35: *
36: */
37: public class VCardParserTest extends TestCase {
38:
39: public void testWrite() throws Exception {
40:
41: File file = new File(
42: "res/org/columba/addressbook/parser/columba.xml");
43:
44: Document doc = XmlNewIO.load(file);
45: assertNotNull(doc);
46:
47: IContactModel c = new ContactModel(new Integer(0).toString());
48:
49: BufferedOutputStream out = new BufferedOutputStream(
50: new FileOutputStream("test.vcf"));
51:
52: VCardParser.write(c, out);
53: }
54:
55: public void testRead() throws Exception {
56: File file = new File(
57: "res/org/columba/addressbook/parser/vcard_evolution1.vcf");
58:
59: BufferedInputStream in = new BufferedInputStream(
60: new FileInputStream(file));
61: IContactModel[] cards = VCardParser.read(in);
62: assertNotNull(cards);
63: }
64:
65: }
|