Package org.geoserver.script

Examples of org.geoserver.script.ScriptManager


        if (process == null) {
            synchronized(this) {
                process = processes.get(name);
                if (process == null) {
                    try {
                        ScriptManager scriptMgr = scriptMgr();

                        // see if the process is a root level one
                        String localName = name.getLocalPart();
                        String namespace = name.getNamespaceURI();
                        File f = new File(scriptMgr.getWpsRoot(), localName + "." + namespace);
                        if (!f.exists()) {
                            // see if it's nested in a directory then
                            File directory = new File(scriptMgr.getWpsRoot(),
                                    namespace);
                            if (!directory.exists()) {
                                throw new FileNotFoundException("Could not find script file "
                                        + f.getName() + " nor a directory of scripts named "
                                        + directory.getName());
View Full Code Here


        form.submit();

        tester.assertRenderedPage(ScriptPage.class);
        tester.assertNoErrorMessage();

        ScriptManager scriptManager = GeoServerExtensions.bean(ScriptManager.class);
        File file = new File(new File(scriptManager.getAppRoot(), "hello"), "main.js");
        assertTrue(file.exists());

        assertEquals("console.log('Hi');", FileUtils.readFileToString(file));
    }
View Full Code Here

public class ScriptEditPageTest extends GeoServerWicketTestSupport {

    @Before
    public void init() throws IOException {
        // Add a few scripts
        ScriptManager scriptManager = GeoServerExtensions.bean(ScriptManager.class);
        File wpsDir = scriptManager.findOrCreateScriptDir("wps");
        File wpsScript = new File(wpsDir, "buffer.groovy");
        FileUtils.writeStringToFile(wpsScript, "buffer");
        Script script = new Script(wpsScript);
        // Login and load the page
        login();
View Full Code Here

    /**
     * Test method for {@link org.geoserver.geoscript.javascript.JavaScriptModules#require()}.
     * @throws ScriptException
     */
    public void testRequireGeoScript() throws ScriptException {
        ScriptManager scriptMgr = getScriptManager();
        ScriptEngine engine = scriptMgr.createNewEngine("js");
        engine.eval("var gs = require('geoscript')");
        Object exportsObj = engine.get("gs");
        assertTrue(exportsObj instanceof Scriptable);
        Scriptable exports = (Scriptable) exportsObj;
        Object geomObj = exports.get("geom", exports);
View Full Code Here

    /**
     * Test method for {@link org.geoserver.geoscript.javascript.JavaScriptModules#require()}.
     * @throws ScriptException
     */
    public void testRequireGeoServer() throws ScriptException {
        ScriptManager scriptMgr = getScriptManager();
        ScriptEngine engine = scriptMgr.createNewEngine("js");
        engine.eval("var gs = require('geoserver')");
        Object exportsObj = engine.get("gs");
        assertTrue(exportsObj instanceof Scriptable);
        Scriptable exports = (Scriptable) exportsObj;
        Object catalogObj = exports.get("catalog", exports);
View Full Code Here

        form.submit();

        tester.assertRenderedPage(ScriptPage.class);
        tester.assertNoErrorMessage();

        ScriptManager scriptManager = GeoServerExtensions.bean(ScriptManager.class);
        File file = new File(scriptManager.getWpsRoot(), "buffer.groovy");
        assertTrue(file.exists());

        assertEquals("geom.buffer(-1);", FileUtils.readFileToString(file));
    }
View Full Code Here

TOP

Related Classes of org.geoserver.script.ScriptManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.