KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > addressbook > parser > VCardParserTest


1 // The contents of this file are subject to the Mozilla Public License Version
2
// 1.1
3
//(the "License"); you may not use this file except in compliance with the
4
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
5
//
6
//Software distributed under the License is distributed on an "AS IS" basis,
7
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8
//for the specific language governing rights and
9
//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 JavaDoc;
21 import java.io.BufferedOutputStream JavaDoc;
22 import java.io.File JavaDoc;
23 import java.io.FileInputStream JavaDoc;
24 import java.io.FileOutputStream JavaDoc;
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 JavaDoc {
40
41         File JavaDoc file = new File JavaDoc("res/org/columba/addressbook/parser/columba.xml");
42
43         Document doc = XmlNewIO.load(file);
44         assertNotNull(doc);
45         
46         IContactModel c = new ContactModel(new Integer JavaDoc(0).toString());
47
48         BufferedOutputStream JavaDoc out = new BufferedOutputStream JavaDoc(
49                 new FileOutputStream JavaDoc("test.vcf"));
50
51         VCardParser.write(c, out);
52     }
53
54     public void testRead() throws Exception JavaDoc {
55         File JavaDoc file = new File JavaDoc(
56                 "res/org/columba/addressbook/parser/vcard_evolution1.vcf");
57
58         BufferedInputStream JavaDoc in = new BufferedInputStream JavaDoc(new FileInputStream JavaDoc(
59                 file));
60         IContactModel[] cards = VCardParser.read(in);
61         assertNotNull(cards);
62     }
63
64 }
Popular Tags