-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored code, fixed UpdateKnowledgeBase and FauxPropertiesUpdater.…
… Added tests.
- Loading branch information
Showing
6 changed files
with
94 additions
and
55 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
50 changes: 50 additions & 0 deletions
50
api/src/test/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectoryTest.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,50 @@ | ||
package edu.cornell.mannlib.vitro.webapp.application; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
import stubs.javax.servlet.ServletContextStub; | ||
|
||
public class VitroHomeDirectoryTest { | ||
|
||
private static final String FILE = "file"; | ||
private static final String CONFIG = "config"; | ||
private static final String RDF = "rdf"; | ||
@Rule | ||
public TemporaryFolder src = new TemporaryFolder(); | ||
@Rule | ||
public TemporaryFolder dst = new TemporaryFolder(); | ||
|
||
@Test | ||
public void testGetHomeSrcPath() { | ||
ServletContextStub sc = new ServletContextStub(); | ||
String expectedPath = "/opt/tomcat/webapp/app/WEB-INF/resources/home-files"; | ||
sc.setRealPath("/WEB-INF/resources/home-files", expectedPath); | ||
VitroHomeDirectory vhd = new VitroHomeDirectory(sc, dst.getRoot().toPath(), ""); | ||
String realPath = vhd.getSourcePath(); | ||
assertEquals(expectedPath, realPath); | ||
} | ||
|
||
@Test | ||
public void testPopulate() throws Exception { | ||
ServletContextStub sc = new ServletContextStub(); | ||
src.newFolder(RDF); | ||
src.newFile(FILE); | ||
src.newFolder(CONFIG); | ||
sc.setRealPath("/WEB-INF/resources/home-files", src.getRoot().getAbsolutePath()); | ||
VitroHomeDirectory vhd = new VitroHomeDirectory(sc, dst.getRoot().toPath(), ""); | ||
vhd.populate(); | ||
Set<String> files = new HashSet<String>(Arrays.asList(dst.getRoot().list())); | ||
assertTrue(files.contains(CONFIG)); | ||
assertTrue(files.contains(FILE)); | ||
assertFalse(files.contains(RDF)); | ||
} | ||
} |