forked from jakartaee/expression-language
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 #14 from TomasHofman/JBEE-258-3.0.x-new
[JBEE-258] FactoryFinderCache does not properly handle comments in service
- Loading branch information
Showing
7 changed files
with
83 additions
and
1 deletion.
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
39 changes: 39 additions & 0 deletions
39
api/src/test/java/org/jboss/el/cache/FactoryFinderCacheTestCase.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,39 @@ | ||
package org.jboss.el.cache; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class FactoryFinderCacheTestCase { | ||
|
||
@Test | ||
public void testServiceFileWithComment() { | ||
String className = FactoryFinderCache.loadImplementationClassName("org.jboss.el.cache.TestService-comment", | ||
this.getClass().getClassLoader()); | ||
Assert.assertEquals("org.jboss.el.cache.TestServiceImpl", className); | ||
} | ||
|
||
@Test | ||
public void testEmptyServiceFile() { | ||
String className = FactoryFinderCache.loadImplementationClassName("org.jboss.el.cache.TestService-empty", | ||
this.getClass().getClassLoader()); | ||
Assert.assertNull(className); | ||
} | ||
|
||
@Test | ||
public void testServiceFile() { | ||
String className = FactoryFinderCache.loadImplementationClassName("org.jboss.el.cache.TestService", | ||
this.getClass().getClassLoader()); | ||
Assert.assertEquals("org.jboss.el.cache.TestServiceImpl", className); | ||
} | ||
|
||
@Test | ||
public void testSanitizeMethod() { | ||
Assert.assertEquals("ClassName", FactoryFinderCache.sanitize("ClassName")); | ||
Assert.assertEquals("ClassName", FactoryFinderCache.sanitize(" ClassName ")); | ||
Assert.assertEquals("ClassName", FactoryFinderCache.sanitize("\tClassName\t")); | ||
Assert.assertEquals("ClassName", FactoryFinderCache.sanitize(" \tClassName\t # comment...")); | ||
Assert.assertEquals("", FactoryFinderCache.sanitize("# only comment...")); | ||
Assert.assertEquals("", FactoryFinderCache.sanitize("")); | ||
Assert.assertNull(FactoryFinderCache.sanitize(null)); | ||
} | ||
} |
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,5 @@ | ||
package org.jboss.el.cache; | ||
|
||
public interface TestService { | ||
void execute(); | ||
} |
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,9 @@ | ||
package org.jboss.el.cache; | ||
|
||
public class TestServiceImpl implements TestService { | ||
|
||
@Override | ||
public void execute() { | ||
// pass | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
api/src/test/resources/META-INF/services/org.jboss.el.cache.TestService
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 @@ | ||
org.jboss.el.cache.TestServiceImpl |
2 changes: 2 additions & 0 deletions
2
api/src/test/resources/META-INF/services/org.jboss.el.cache.TestService-comment
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,2 @@ | ||
# Comment | ||
org.jboss.el.cache.TestServiceImpl |
Empty file.