Permalink
Show file tree
Hide file tree
4 changes: 3 additions & 1 deletion
4
src/main/java/org/olat/fileresource/types/ImsCPFileResource.java
4 changes: 3 additions & 1 deletion
4
src/main/java/org/olat/fileresource/types/ImsQTI21Resource.java
4 changes: 3 additions & 1 deletion
4
src/main/java/org/olat/fileresource/types/ScormCPFileResource.java
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
OO-5549: fix the wiki import and add some unit tests
- Loading branch information
Showing
13 changed files
with
164 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/test/java/org/olat/modules/ims/cp/ImsCPHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package org.olat.modules.ims.cp; | ||
|
|
||
| import java.io.File; | ||
| import java.net.URISyntaxException; | ||
| import java.net.URL; | ||
| import java.util.Locale; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
| import org.olat.core.id.Identity; | ||
| import org.olat.core.logging.OLATRuntimeException; | ||
| import org.olat.fileresource.FileResourceManager; | ||
| import org.olat.fileresource.types.ImsCPFileResource; | ||
| import org.olat.repository.RepositoryEntry; | ||
| import org.olat.repository.handlers.RepositoryHandler; | ||
| import org.olat.repository.handlers.RepositoryHandlerFactory; | ||
| import org.olat.test.JunitTestHelper; | ||
| import org.olat.test.OlatTestCase; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
|
|
||
| /** | ||
| * | ||
| * Initial date: 22 juin 2021<br> | ||
| * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com | ||
| * | ||
| */ | ||
| public class ImsCPHandlerTest extends OlatTestCase { | ||
|
|
||
| @Autowired | ||
| private RepositoryHandlerFactory handlerFactory; | ||
|
|
||
| @Test | ||
| public void importImsCP() throws URISyntaxException { | ||
| Identity author = JunitTestHelper.createAndPersistIdentityAsRndAuthor("ims-cp-1"); | ||
| URL imsCpUrl = ImsCPHandlerTest.class.getResource("imscp.zip"); | ||
| File imsCpFile = new File(imsCpUrl.toURI()); | ||
|
|
||
| RepositoryHandler cpHandler = handlerFactory.getRepositoryHandler(ImsCPFileResource.TYPE_NAME); | ||
| RepositoryEntry entry = cpHandler.importResource(author, null, "IMS CP", null, false, null, Locale.ENGLISH, imsCpFile, imsCpFile.getName()); | ||
| Assert.assertNotNull(entry); | ||
|
|
||
| File cpRoot = FileResourceManager.getInstance().unzipFileResource(entry.getOlatResource()); | ||
| File image = new File(cpRoot, "IMG_1482.jpg"); | ||
| Assert.assertTrue(image.exists()); | ||
| File manifestXml = new File(cpRoot, "imsmanifest.xml"); | ||
| Assert.assertTrue(manifestXml.exists()); | ||
| File page = new File(cpRoot, "new.html"); | ||
| Assert.assertTrue(page.exists()); | ||
| } | ||
|
|
||
| @Test(expected=OLATRuntimeException.class) | ||
| public void importImsCPSlide() throws URISyntaxException { | ||
| Identity author = JunitTestHelper.createAndPersistIdentityAsRndAuthor("ims-cp-1"); | ||
| URL imsCpUrl = ImsCPHandlerTest.class.getResource("imscp_alt.zip"); | ||
| File imsCpFile = new File(imsCpUrl.toURI()); | ||
|
|
||
| RepositoryHandler cpHandler = handlerFactory.getRepositoryHandler(ImsCPFileResource.TYPE_NAME); | ||
| cpHandler.importResource(author, null, "IMS CP", null, false, null, Locale.ENGLISH, imsCpFile, imsCpFile.getName()); | ||
| } | ||
|
|
||
| } |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package org.olat.modules.wiki; | ||
|
|
||
| import java.io.File; | ||
| import java.net.URISyntaxException; | ||
| import java.net.URL; | ||
|
|
||
| import org.junit.After; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.olat.core.logging.OLATRuntimeException; | ||
| import org.olat.core.util.CodeHelper; | ||
| import org.olat.core.util.FileUtils; | ||
| import org.olat.core.util.WebappHelper; | ||
| import org.olat.test.OlatTestCase; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.wildfly.common.Assert; | ||
|
|
||
| /** | ||
| * | ||
| * Initial date: 22 juin 2021<br> | ||
| * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com | ||
| * | ||
| */ | ||
| public class WikiManagerTest extends OlatTestCase { | ||
|
|
||
| @Autowired | ||
| private WikiManager wikiManager; | ||
|
|
||
| private File tmpWikiDir; | ||
|
|
||
| @Before | ||
| public void createTmpDir() { | ||
| tmpWikiDir = new File(WebappHelper.getTmpDir(), "wiki" + CodeHelper.getForeverUniqueID()); | ||
| } | ||
|
|
||
| @After | ||
| public void deleteTmpDir() { | ||
| FileUtils.deleteDirsAndFiles(tmpWikiDir, true, true); | ||
| } | ||
|
|
||
| @Test | ||
| public void importWiki() throws URISyntaxException { | ||
| URL wikiUrl = WikiManagerTest.class.getResource("wiki.zip"); | ||
| File wikiFile = new File(wikiUrl.toURI()); | ||
| wikiManager.importWiki(wikiFile, null, tmpWikiDir); | ||
|
|
||
| File image = new File(tmpWikiDir, "media/IMG_1482.jpg"); | ||
| Assert.assertTrue(image.exists()); | ||
| File imageMetadata = new File(tmpWikiDir, "media/IMG_1482.jpg.metadata"); | ||
| Assert.assertTrue(imageMetadata.exists()); | ||
| File indexPage = new File(tmpWikiDir, "wiki/SW5kZXg=.wp"); | ||
| Assert.assertTrue(indexPage.exists()); | ||
| } | ||
|
|
||
| @Test(expected=OLATRuntimeException.class) | ||
| public void importWikiSlide() throws URISyntaxException { | ||
| URL wikiUrl = WikiManagerTest.class.getResource("wiki_alt.zip"); | ||
| File wikiFile = new File(wikiUrl.toURI()); | ||
| wikiManager.importWiki(wikiFile, null, tmpWikiDir); | ||
| } | ||
|
|
||
| } |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters