Search in sources :

Example 1 with VirtualFileClasspath

use of org.webpieces.util.file.VirtualFileClasspath in project webpieces by deanhiller.

the class TestAjaxHibernate method setUp.

@Before
public void setUp() {
    //clear in-memory database
    JdbcApi jdbc = JdbcFactory.create(JdbcConstants.jdbcUrl, JdbcConstants.jdbcUser, JdbcConstants.jdbcPassword);
    jdbc.dropAllTablesFromDatabase();
    VirtualFileClasspath metaFile = new VirtualFileClasspath("plugins/hibernateMeta.txt", WebserverForTest.class.getClassLoader());
    TestConfig config = new TestConfig();
    config.setPlatformOverrides(platformOverrides);
    config.setAppOverrides(new TestModule());
    config.setMetaFile(metaFile);
    WebserverForTest webserver = new WebserverForTest(config);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : TestConfig(org.webpieces.webserver.TestConfig) WebserverForTest(org.webpieces.webserver.WebserverForTest) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) JdbcApi(org.webpieces.ddl.api.JdbcApi) Before(org.junit.Before)

Example 2 with VirtualFileClasspath

use of org.webpieces.util.file.VirtualFileClasspath in project webpieces by deanhiller.

the class TestAsyncHibernate method setUp.

@Before
public void setUp() {
    //clear in-memory database
    JdbcApi jdbc = JdbcFactory.create(JdbcConstants.jdbcUrl, JdbcConstants.jdbcUser, JdbcConstants.jdbcPassword);
    jdbc.dropAllTablesFromDatabase();
    mockExecutor.clear();
    VirtualFileClasspath metaFile = new VirtualFileClasspath("plugins/hibernateMeta.txt", WebserverForTest.class.getClassLoader());
    TestConfig config = new TestConfig();
    config.setPlatformOverrides(platformOverrides);
    config.setAppOverrides(new TestOverrides());
    config.setMetaFile(metaFile);
    WebserverForTest webserver = new WebserverForTest(config);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : TestConfig(org.webpieces.webserver.TestConfig) WebserverForTest(org.webpieces.webserver.WebserverForTest) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) JdbcApi(org.webpieces.ddl.api.JdbcApi) Before(org.junit.Before)

Example 3 with VirtualFileClasspath

use of org.webpieces.util.file.VirtualFileClasspath in project webpieces by deanhiller.

the class TestFlashAndSelect method setUp.

@Before
public void setUp() {
    //clear in-memory database
    JdbcApi jdbc = JdbcFactory.create(JdbcConstants.jdbcUrl, JdbcConstants.jdbcUser, JdbcConstants.jdbcPassword);
    jdbc.dropAllTablesFromDatabase();
    user = loadDataInDb();
    VirtualFileClasspath metaFile = new VirtualFileClasspath("plugins/hibernateMeta.txt", WebserverForTest.class.getClassLoader());
    TestConfig config = new TestConfig();
    config.setPlatformOverrides(platformOverrides);
    config.setMetaFile(metaFile);
    config.setAppOverrides(new TestModule(mock));
    WebserverForTest webserver = new WebserverForTest(config);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : TestConfig(org.webpieces.webserver.TestConfig) WebserverForTest(org.webpieces.webserver.WebserverForTest) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) JdbcApi(org.webpieces.ddl.api.JdbcApi) Before(org.junit.Before)

Example 4 with VirtualFileClasspath

use of org.webpieces.util.file.VirtualFileClasspath in project webpieces by deanhiller.

the class TestUrlHtmlEncoding method setUp.

@Before
public void setUp() {
    VirtualFileClasspath metaFile = new VirtualFileClasspath("beansMeta.txt", WebserverForTest.class.getClassLoader());
    WebserverForTest webserver = new WebserverForTest(platformOverrides, null, false, metaFile);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : WebserverForTest(org.webpieces.webserver.WebserverForTest) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) Before(org.junit.Before)

Example 5 with VirtualFileClasspath

use of org.webpieces.util.file.VirtualFileClasspath in project webpieces by deanhiller.

the class DevTemplateService method loadTemplateImpl.

private Template loadTemplateImpl(OurGroovyClassLoader cl, String fullTemplatePath, String templateFullClassName) throws IOException, ClassNotFoundException {
    if (config.isMustReadClassFromFileSystem()) {
        //shortcut for tests that use PlatformOverridesForTest to ensure we test the production groovy class files AND
        //it ensures we give code coverage numbers on those class files as well.
        Class<?> compiledTemplate = DevTemplateService.class.getClassLoader().loadClass(templateFullClassName);
        return new TemplateImpl(urlLookup, htmlTagLookup, compiledTemplate);
    }
    VirtualFile theResource = null;
    List<VirtualFile> srcPaths = config.getSrcPaths();
    for (VirtualFile f : srcPaths) {
        //take off the leading '/' so it is a relative path
        VirtualFile child = f.child(fullTemplatePath.substring(1));
        if (child.exists()) {
            theResource = child;
            break;
        }
    }
    if (theResource == null)
        theResource = new VirtualFileClasspath(fullTemplatePath, DevTemplateService.class);
    if (!theResource.exists())
        throw new FileNotFoundException("resource=" + fullTemplatePath + " was not found in classpath");
    try (InputStream resource = theResource.openInputStream()) {
        String viewSource = IOUtils.toString(resource, config.getFileEncoding().name());
        Class<?> compiledTemplate = createTemplate(cl, templateFullClassName, viewSource);
        return new TemplateImpl(urlLookup, htmlTagLookup, compiledTemplate);
    }
}
Also used : TemplateImpl(org.webpieces.templating.impl.TemplateImpl) VirtualFile(org.webpieces.util.file.VirtualFile) InputStream(java.io.InputStream) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

VirtualFileClasspath (org.webpieces.util.file.VirtualFileClasspath)30 Before (org.junit.Before)29 WebserverForTest (org.webpieces.webserver.WebserverForTest)29 JdbcApi (org.webpieces.ddl.api.JdbcApi)4 TestConfig (org.webpieces.webserver.TestConfig)4 SeleniumOverridesForTest (org.webpieces.webserver.test.SeleniumOverridesForTest)3 Module (com.google.inject.Module)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 Ignore (org.junit.Ignore)1 TemplateImpl (org.webpieces.templating.impl.TemplateImpl)1 VirtualFile (org.webpieces.util.file.VirtualFile)1 TagOverridesModule (org.webpieces.webserver.api.TagOverridesModule)1