summaryrefslogtreecommitdiffstats
path: root/sandbox/ant/container.python/src/test/java/org/apache/tuscany/container/python/PythonImplementationTestCase.java
blob: a2af619795c38f3d60d1b5999754538c05788177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package org.apache.tuscany.container.python;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import junit.framework.TestCase;

public class PythonImplementationTestCase extends TestCase {

    private PythonScript pythonScript;

    public void testGetPythonScript() {
        PythonImplementation impl = new PythonImplementation();
        impl.setPythonScript(pythonScript);
        assertEquals(pythonScript, impl.getJythonScript());
    }

    public void setUp() throws IOException {
        URL scriptURL = getClass().getResource("PythonScriptTestCase.py");
        assert scriptURL != null;
        InputStream is = scriptURL.openStream();
        StringBuilder sb = new StringBuilder();
        int i = 0;
        while ((i = is.read()) != -1) {
            sb.append((char) i);
        }
        is.close();
        String script = sb.toString();
        pythonScript = new PythonScript("PythonScriptTestCase", "hello", script, null);
    }

}