Java Code Examples for org.springframework.expression.spel.support.StandardTypeLocator#registerImport()
The following examples show how to use
org.springframework.expression.spel.support.StandardTypeLocator#registerImport() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardTypeLocatorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testImports() throws EvaluationException { StandardTypeLocator locator = new StandardTypeLocator(); assertEquals(Integer.class,locator.findType("java.lang.Integer")); assertEquals(String.class,locator.findType("java.lang.String")); List<String> prefixes = locator.getImportPrefixes(); assertEquals(1,prefixes.size()); assertTrue(prefixes.contains("java.lang")); assertFalse(prefixes.contains("java.util")); assertEquals(Boolean.class,locator.findType("Boolean")); // currently does not know about java.util by default // assertEquals(java.util.List.class,locator.findType("List")); try { locator.findType("URL"); fail("Should have failed"); } catch (EvaluationException ee) { SpelEvaluationException sEx = (SpelEvaluationException)ee; assertEquals(SpelMessage.TYPE_NOT_FOUND,sEx.getMessageCode()); } locator.registerImport("java.net"); assertEquals(java.net.URL.class,locator.findType("URL")); }
Example 2
Source File: StandardTypeLocatorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testImports() throws EvaluationException { StandardTypeLocator locator = new StandardTypeLocator(); assertEquals(Integer.class,locator.findType("java.lang.Integer")); assertEquals(String.class,locator.findType("java.lang.String")); List<String> prefixes = locator.getImportPrefixes(); assertEquals(1,prefixes.size()); assertTrue(prefixes.contains("java.lang")); assertFalse(prefixes.contains("java.util")); assertEquals(Boolean.class,locator.findType("Boolean")); // currently does not know about java.util by default // assertEquals(java.util.List.class,locator.findType("List")); try { locator.findType("URL"); fail("Should have failed"); } catch (EvaluationException ee) { SpelEvaluationException sEx = (SpelEvaluationException)ee; assertEquals(SpelMessage.TYPE_NOT_FOUND,sEx.getMessageCode()); } locator.registerImport("java.net"); assertEquals(java.net.URL.class,locator.findType("URL")); }
Example 3
Source File: StandardTypeLocatorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testImports() throws EvaluationException { StandardTypeLocator locator = new StandardTypeLocator(); assertEquals(Integer.class,locator.findType("java.lang.Integer")); assertEquals(String.class,locator.findType("java.lang.String")); List<String> prefixes = locator.getImportPrefixes(); assertEquals(1,prefixes.size()); assertTrue(prefixes.contains("java.lang")); assertFalse(prefixes.contains("java.util")); assertEquals(Boolean.class,locator.findType("Boolean")); // currently does not know about java.util by default // assertEquals(java.util.List.class,locator.findType("List")); try { locator.findType("URL"); fail("Should have failed"); } catch (EvaluationException ee) { SpelEvaluationException sEx = (SpelEvaluationException)ee; assertEquals(SpelMessage.TYPE_NOT_FOUND,sEx.getMessageCode()); } locator.registerImport("java.net"); assertEquals(java.net.URL.class,locator.findType("URL")); }
Example 4
Source File: CommonTypeLocator.java From syncer with BSD 3-Clause "New" or "Revised" License | 4 votes |
public CommonTypeLocator() { locator = new StandardTypeLocator(); locator.registerImport("java.util"); locator.registerImport("com.github.zzt93.syncer.data.util"); }