org.springframework.util.ClassUtils#classPackageAsResourcePath ( )源码实例Demo

下面列出了org.springframework.util.ClassUtils#classPackageAsResourcePath ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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());
}
 
源代码2 项目: spring-analysis-note   文件: PathEditorTests.java
@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));
}
 
源代码3 项目: spring-analysis-note   文件: PathEditorTests.java
@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));
}
 
@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());
}
 
源代码5 项目: java-technology-stack   文件: PathEditorTests.java
@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));
}
 
源代码6 项目: java-technology-stack   文件: PathEditorTests.java
@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));
}
 
@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());
}
 
源代码8 项目: spring4-understanding   文件: FileEditorTests.java
@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));
}
 
源代码9 项目: spring4-understanding   文件: FileEditorTests.java
@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));
}
 
@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());
}
 
源代码11 项目: spring-analysis-note   文件: FileEditorTests.java
@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));
}
 
源代码12 项目: spring-analysis-note   文件: FileEditorTests.java
@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));
}
 
源代码13 项目: spring-analysis-note   文件: ReaderEditorTests.java
@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());
}
 
@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());
}
 
源代码15 项目: java-technology-stack   文件: FileEditorTests.java
@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));
}
 
源代码16 项目: java-technology-stack   文件: FileEditorTests.java
@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));
}
 
源代码17 项目: java-technology-stack   文件: ReaderEditorTests.java
@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());
}
 
@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());
}
 
源代码19 项目: spring4-understanding   文件: ReaderEditorTests.java
@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());
}