Java Code Examples for org.springframework.util.ClassUtils#classPackageAsResourcePath()
The following examples show how to use
org.springframework.util.ClassUtils#classPackageAsResourcePath() .
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: XsltViewResolverTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void resolveView() throws Exception { StaticApplicationContext ctx = new StaticApplicationContext(); String prefix = ClassUtils.classPackageAsResourcePath(getClass()); String suffix = ".xsl"; String viewName = "products"; XsltViewResolver viewResolver = new XsltViewResolver(); viewResolver.setPrefix(prefix); viewResolver.setSuffix(suffix); viewResolver.setApplicationContext(ctx); XsltView view = (XsltView) viewResolver.resolveViewName(viewName, Locale.ENGLISH); assertNotNull("View should not be null", view); assertEquals("Incorrect URL", prefix + viewName + suffix, view.getUrl()); }
Example 2
Source File: PathEditorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testUnqualifiedPathNameFound() throws Exception { PropertyEditor pathEditor = new PathEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; pathEditor.setAsText(fileName); Object value = pathEditor.getValue(); assertTrue(value instanceof Path); Path path = (Path) value; File file = path.toFile(); assertTrue(file.exists()); String absolutePath = file.getAbsolutePath(); if (File.separatorChar == '\\') { absolutePath = absolutePath.replace('\\', '/'); } assertTrue(absolutePath.endsWith(fileName)); }
Example 3
Source File: PathEditorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testUnqualifiedPathNameNotFound() throws Exception { PropertyEditor pathEditor = new PathEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".clazz"; pathEditor.setAsText(fileName); Object value = pathEditor.getValue(); assertTrue(value instanceof Path); Path path = (Path) value; File file = path.toFile(); assertFalse(file.exists()); String absolutePath = file.getAbsolutePath(); if (File.separatorChar == '\\') { absolutePath = absolutePath.replace('\\', '/'); } assertTrue(absolutePath.endsWith(fileName)); }
Example 4
Source File: FileEditorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testUnqualifiedFileNameNotFound() throws Exception { PropertyEditor fileEditor = new FileEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".clazz"; fileEditor.setAsText(fileName); Object value = fileEditor.getValue(); assertTrue(value instanceof File); File file = (File) value; assertFalse(file.exists()); String absolutePath = file.getAbsolutePath(); if (File.separatorChar == '\\') { absolutePath = absolutePath.replace('\\', '/'); } assertTrue(absolutePath.endsWith(fileName)); }
Example 5
Source File: FileEditorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testUnqualifiedFileNameFound() throws Exception { PropertyEditor fileEditor = new FileEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; fileEditor.setAsText(fileName); Object value = fileEditor.getValue(); assertTrue(value instanceof File); File file = (File) value; assertTrue(file.exists()); String absolutePath = file.getAbsolutePath(); if (File.separatorChar == '\\') { absolutePath = absolutePath.replace('\\', '/'); } assertTrue(absolutePath.endsWith(fileName)); }
Example 6
Source File: XsltViewResolverTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void resolveView() throws Exception { StaticApplicationContext ctx = new StaticApplicationContext(); String prefix = ClassUtils.classPackageAsResourcePath(getClass()); String suffix = ".xsl"; String viewName = "products"; XsltViewResolver viewResolver = new XsltViewResolver(); viewResolver.setPrefix(prefix); viewResolver.setSuffix(suffix); viewResolver.setApplicationContext(ctx); XsltView view = (XsltView) viewResolver.resolveViewName(viewName, Locale.ENGLISH); assertNotNull("View should not be null", view); assertEquals("Incorrect URL", prefix + viewName + suffix, view.getUrl()); }
Example 7
Source File: XsltViewResolverTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void resolveView() throws Exception { StaticApplicationContext ctx = new StaticApplicationContext(); String prefix = ClassUtils.classPackageAsResourcePath(getClass()); String suffix = ".xsl"; String viewName = "products"; XsltViewResolver viewResolver = new XsltViewResolver(); viewResolver.setPrefix(prefix); viewResolver.setSuffix(suffix); viewResolver.setApplicationContext(ctx); XsltView view = (XsltView) viewResolver.resolveViewName(viewName, Locale.ENGLISH); assertNotNull("View should not be null", view); assertEquals("Incorrect URL", prefix + viewName + suffix, view.getUrl()); }
Example 8
Source File: PathEditorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testUnqualifiedPathNameFound() throws Exception { PropertyEditor pathEditor = new PathEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; pathEditor.setAsText(fileName); Object value = pathEditor.getValue(); assertTrue(value instanceof Path); Path path = (Path) value; File file = path.toFile(); assertTrue(file.exists()); String absolutePath = file.getAbsolutePath(); if (File.separatorChar == '\\') { absolutePath = absolutePath.replace('\\', '/'); } assertTrue(absolutePath.endsWith(fileName)); }
Example 9
Source File: PathEditorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testUnqualifiedPathNameNotFound() throws Exception { PropertyEditor pathEditor = new PathEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".clazz"; pathEditor.setAsText(fileName); Object value = pathEditor.getValue(); assertTrue(value instanceof Path); Path path = (Path) value; File file = path.toFile(); assertFalse(file.exists()); String absolutePath = file.getAbsolutePath(); if (File.separatorChar == '\\') { absolutePath = absolutePath.replace('\\', '/'); } assertTrue(absolutePath.endsWith(fileName)); }
Example 10
Source File: ReaderEditorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGetAsTextReturnsNullByDefault() throws Exception { assertNull(new ReaderEditor().getAsText()); String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; ReaderEditor editor = new ReaderEditor(); editor.setAsText(resource); assertNull(editor.getAsText()); }
Example 11
Source File: InputStreamEditorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGetAsTextReturnsNullByDefault() throws Exception { assertNull(new InputStreamEditor().getAsText()); String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; InputStreamEditor editor = new InputStreamEditor(); editor.setAsText(resource); assertNull(editor.getAsText()); }
Example 12
Source File: ReaderEditorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testGetAsTextReturnsNullByDefault() throws Exception { assertNull(new ReaderEditor().getAsText()); String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; ReaderEditor editor = new ReaderEditor(); editor.setAsText(resource); assertNull(editor.getAsText()); }
Example 13
Source File: FileEditorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testUnqualifiedFileNameNotFound() throws Exception { PropertyEditor fileEditor = new FileEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".clazz"; fileEditor.setAsText(fileName); Object value = fileEditor.getValue(); assertTrue(value instanceof File); File file = (File) value; assertFalse(file.exists()); String absolutePath = file.getAbsolutePath().replace('\\', '/'); assertTrue(absolutePath.endsWith(fileName)); }
Example 14
Source File: FileEditorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testUnqualifiedFileNameFound() throws Exception { PropertyEditor fileEditor = new FileEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; fileEditor.setAsText(fileName); Object value = fileEditor.getValue(); assertTrue(value instanceof File); File file = (File) value; assertTrue(file.exists()); String absolutePath = file.getAbsolutePath().replace('\\', '/'); assertTrue(absolutePath.endsWith(fileName)); }
Example 15
Source File: InputStreamEditorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testGetAsTextReturnsNullByDefault() throws Exception { assertNull(new InputStreamEditor().getAsText()); String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; InputStreamEditor editor = new InputStreamEditor(); editor.setAsText(resource); assertNull(editor.getAsText()); }
Example 16
Source File: ReaderEditorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testGetAsTextReturnsNullByDefault() throws Exception { assertNull(new ReaderEditor().getAsText()); String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; ReaderEditor editor = new ReaderEditor(); editor.setAsText(resource); assertNull(editor.getAsText()); }
Example 17
Source File: FileEditorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testUnqualifiedFileNameNotFound() throws Exception { PropertyEditor fileEditor = new FileEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".clazz"; fileEditor.setAsText(fileName); Object value = fileEditor.getValue(); assertTrue(value instanceof File); File file = (File) value; assertFalse(file.exists()); String absolutePath = file.getAbsolutePath().replace('\\', '/'); assertTrue(absolutePath.endsWith(fileName)); }
Example 18
Source File: FileEditorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testUnqualifiedFileNameFound() throws Exception { PropertyEditor fileEditor = new FileEditor(); String fileName = ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; fileEditor.setAsText(fileName); Object value = fileEditor.getValue(); assertTrue(value instanceof File); File file = (File) value; assertTrue(file.exists()); String absolutePath = file.getAbsolutePath().replace('\\', '/'); assertTrue(absolutePath.endsWith(fileName)); }
Example 19
Source File: InputStreamEditorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testGetAsTextReturnsNullByDefault() throws Exception { assertNull(new InputStreamEditor().getAsText()); String resource = "classpath:" + ClassUtils.classPackageAsResourcePath(getClass()) + "/" + ClassUtils.getShortName(getClass()) + ".class"; InputStreamEditor editor = new InputStreamEditor(); editor.setAsText(resource); assertNull(editor.getAsText()); }