forked from javaee/jsftemplating
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from kenpaulsen/pr-49-suggestions
Added a few simple test cases.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ting/src/test/java/com/sun/jsftemplating/util/fileStreamer/ResourceContentSourceTest.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,38 @@ | ||
/** | ||
* | ||
*/ | ||
package com.sun.jsftemplating.util.fileStreamer; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* TestCase for <code>ResourceContentSource</code>. | ||
*/ | ||
public class ResourceContentSourceTest { | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void normalizeDoesNotAccessContextRootParent() { | ||
final String testPath = "../bad/path"; | ||
ResourceContentSource.normalize(testPath); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void normalizeDoesNotAccessContextRootParentWithLeadingSlash() { | ||
final String testPath = "/../bad/path"; | ||
ResourceContentSource.normalize(testPath); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void doesNotGoBackTooFar() { | ||
final String testPath = "/path/../../../../too/many/backward"; | ||
ResourceContentSource.normalize(testPath); | ||
} | ||
|
||
@Test | ||
public void removesExtraSlashesAndBackwardPaths() { | ||
final String testPath = "//OK/path//with/extra/slashes/and/..//in/the/middle/"; | ||
final String result = ResourceContentSource.normalize(testPath); | ||
Assert.assertEquals("Wrong result", "OK/path/with/extra/slashes/in/the/middle", result); | ||
} | ||
} |