Package org.geoserver.python

Source Code of org.geoserver.python.PythonTestSupport

package org.geoserver.python;

import static org.junit.Assert.assertEquals;

import java.io.ByteArrayOutputStream;
import java.io.File;

import org.geoserver.platform.GeoServerResourceLoader;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.python.util.PythonInterpreter;
import org.vfny.geoserver.global.GeoserverDataDirectory;

public class PythonTestSupport {

    protected static Python python;
   
    protected PythonInterpreter pi;
    protected ByteArrayOutputStream out;
   
    @BeforeClass
    public static void setUpPython() throws Exception {
        GeoServerResourceLoader loader = new GeoServerResourceLoader(new File("target"));
       
        python = new Python(loader);
        GeoserverDataDirectory.setResourceLoader(loader);
    }
   
    @AfterClass
    public static void tearDownPython() throws Exception {
        GeoserverDataDirectory.setResourceLoader(null);
    }
   
    @Before
    public void setUpPythonInterpreter() throws Exception {
        out = new ByteArrayOutputStream();
        pi = python.interpreter();
        pi.setOut(out);
    }
   
    void print() {
        System.out.println(new String(out.toByteArray()));
    }
   
    void clear() {
        out = new ByteArrayOutputStream();
        pi.setOut(out);
    }
   
    void _assert(String result) {
        assertEquals(result, new String(out.toByteArray()).trim());
    }
}
TOP

Related Classes of org.geoserver.python.PythonTestSupport

TOP
Copyright © 2018 www.massapi.com. 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.