use of uk.ac.ed.ph.jqtiplus.utils.contentpackaging.QtiContentPackageExtractor in project openolat by klemens.
the class ManifestPackageTest method makeManifest.
@Test
public void makeManifest() throws XmlResourceNotFoundException, ImsManifestException, IOException {
ManifestBuilder manifest = ManifestBuilder.createAssessmentTestBuilder();
String testFilename = manifest.appendAssessmentTest();
String itemFilename = manifest.appendAssessmentItem();
Assert.assertNotNull(testFilename);
Assert.assertNotNull(itemFilename);
File tmpDir = new File(WebappHelper.getTmpDir(), "itembuilder" + UUID.randomUUID());
tmpDir.mkdirs();
File manifestFile = new File(tmpDir, "imsmanifest.xml");
FileOutputStream out = new FileOutputStream(manifestFile);
manifest.write(out);
out.flush();
out.close();
QtiContentPackageExtractor extractor = new QtiContentPackageExtractor(tmpDir);
QtiContentPackageSummary summary = extractor.parse();
List<ContentPackageResource> items = summary.getItemResources();
List<ContentPackageResource> tests = summary.getTestResources();
Assert.assertEquals(1, items.size());
Assert.assertEquals(1, tests.size());
ManifestBuilder reloadManifest = ManifestBuilder.read(manifestFile);
Assert.assertNotNull(reloadManifest);
FileUtils.deleteDirsAndFiles(tmpDir.toPath());
}
Aggregations