01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/archive/tags/sakai_2-4-1/import-parsers/sakai-archive/src/java/org/sakaiproject/importer/impl/SakaiArchiveTest.java $
03: * $Id: SakaiArchiveTest.java 17726 2006-11-01 15:39:28Z lance@indiana.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.importer.impl;
21:
22: import java.io.File;
23: import java.io.FileInputStream;
24: import java.io.IOException;
25: import java.util.ArrayList;
26: import java.util.Collection;
27: import java.util.Iterator;
28: import java.util.List;
29:
30: import org.sakaiproject.importer.api.ImportDataSource;
31: import org.sakaiproject.importer.api.ImportFileParser;
32: import org.sakaiproject.importer.api.Importable;
33: import org.sakaiproject.importer.impl.importables.FileResource;
34: import org.sakaiproject.importer.impl.importables.Folder;
35:
36: import junit.framework.TestCase;
37:
38: public class SakaiArchiveTest extends TestCase {
39: private static ImportFileParser parser;
40: private byte[] archiveData;
41: private FileInputStream archiveStream;
42:
43: public void setUp() throws IOException {
44: System.out.println("doing setUp()");
45: parser = new SakaiArchiveFileParser();
46: archiveStream = new FileInputStream(new File(
47: "/Users/zach/Downloads/sakai_course_export.zip"));
48: archiveData = new byte[archiveStream.available()];
49: archiveStream.read(archiveData, 0, archiveStream.available());
50: archiveStream.close();
51: }
52:
53: public void testCanGetDataSource() {
54: ImportDataSource dataSource = (ImportDataSource) parser.parse(
55: archiveData, "/Users/zach/Desktop");
56: assertNotNull(dataSource);
57: System.out.println("There are "
58: + dataSource.getItemCategories().size()
59: + " categories in this archive.");
60: ((SakaiArchiveDataSource) dataSource)
61: .buildSourceFolder(dataSource.getItemCategories());
62: }
63:
64: public void testArchiveIsValid() {
65: assertTrue(parser.isValidArchive(archiveData));
66: }
67:
68: }
|