use of org.apache.wicket.util.file.Path in project wicket by apache.
the class PathTest method loadFromRootUsingSubpathInFilename.
@Test
public void loadFromRootUsingSubpathInFilename() throws Exception {
final String contents = PathTest.class.getName() + ": loaded from root";
final File file = createTempFile(contents);
final File root = findRoot(file);
final Path path = new Path(root.getCanonicalPath());
String relative = root.toURI().relativize(file.toURI()).getPath();
IResourceStream rs = path.find(PathTest.class, relative);
assertNotNull(rs);
assertContents(contents, rs);
}
use of org.apache.wicket.util.file.Path in project wicket by apache.
the class WebApplication method internalInit.
/**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
*
* Internal initialization. First determine the deployment mode. First check the system property
* -Dwicket.configuration. If it does not exist check the servlet init parameter (
* <code><init-param><param-name>configuration</param-name></code>). If not
* found check the servlet context init parameter
* <code><context-param><param-name6gt;configuration</param-name></code>). If the
* parameter is "development" (which is default), settings appropriate for development are set.
* If it's "deployment" , deployment settings are used. If development is specified and a
* "sourceFolder" init parameter is also set, then resources in that folder will be polled for
* changes.
*/
@Override
protected void internalInit() {
super.internalInit();
getResourceSettings().getResourceFinders().add(new WebApplicationPath(getServletContext(), ""));
getResourceSettings().getResourceFinders().add(new ClassPathResourceFinder(META_INF_RESOURCES));
// Set default error pages for HTML markup
getApplicationSettings().setPageExpiredErrorPage(PageExpiredErrorPage.class);
getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
getApplicationSettings().setAccessDeniedPage(AccessDeniedPage.class);
// Add resolver for automatically resolving HTML links
getPageSettings().addComponentResolver(new AutoLinkResolver());
getPageSettings().addComponentResolver(new AutoLabelResolver());
getPageSettings().addComponentResolver(new AutoLabelTextResolver());
getResourceSettings().setFileCleaner(new FileCleaner());
if (getConfigurationType() == RuntimeConfigurationType.DEVELOPMENT) {
// Add optional sourceFolder for resources.
String resourceFolder = getInitParameter("sourceFolder");
if (resourceFolder != null) {
getResourceSettings().getResourceFinders().add(new Path(resourceFolder));
}
}
setPageRendererProvider(WebPageRenderer::new);
setSessionStoreProvider(HttpSessionStore::new);
setAjaxRequestTargetProvider(AjaxRequestHandler::new);
getAjaxRequestTargetListeners().add(new AjaxEnclosureListener());
// Configure the app.
configure();
}
use of org.apache.wicket.util.file.Path in project wicket by apache.
the class PathTest method loadFilenameFromPath.
@Test
public void loadFilenameFromPath() throws Exception {
final String contents = PathTest.class.getName() + ": loaded from prefix";
final File file = createTempFile(contents);
final File parent = file.getParentFile();
final Path path = new Path(parent.getCanonicalPath());
IResourceStream rs = path.find(PathTest.class, file.getName());
assertNotNull(rs);
assertContents(contents, rs);
}
Aggregations