File: StandaloneVerifierTest.java

package info (click to toggle)
jython 2.7.2%2Brepack1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 62,676 kB
  • sloc: python: 640,908; java: 306,458; xml: 1,984; sh: 522; ansic: 126; makefile: 76
file content (72 lines) | stat: -rw-r--r-- 2,603 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.python.util.install.driver;

import java.io.File;

import org.python.util.install.Installation;
import org.python.util.install.JarInstaller;

import junit.framework.TestCase;

public class StandaloneVerifierTest extends TestCase {

    private StandaloneVerifier _verifier;

    protected void setUp() throws Exception {
        super.setUp();
        _verifier = new StandaloneVerifier();
        File targetDir = null;
        // have to install jython first in order to activate this test
        // targetDir = new File("C:/Temp/jython.autoinstall.root_54159_dir/006
        // consoleTest_54165_dir");
        _verifier.setTargetDir(targetDir);
    }

    protected void tearDown() throws Exception {
        super.tearDown();
        if (_verifier.getTargetDir() != null) {
            File autotestFile = new File(_verifier.getTargetDir().getCanonicalPath(),
                                         StandaloneVerifier.AUTOTEST_PY);
            if (autotestFile.exists()) {
                assertTrue(autotestFile.delete());
            }
        }
    }

    public void testVerify() throws Exception {
        if (_verifier.getTargetDir() != null) {
            _verifier.verify();
        }
    }

    public void testGetSimpleCommand() throws Exception {
        File javaHome = new File(System.getProperty("java.home"));
        assertNotNull(javaHome);
        assertTrue(javaHome.exists());
        File targetDir = new File(System.getProperty(("user.dir"))); // any existing dir
        assertNotNull(targetDir);
        assertTrue(targetDir.exists());
        String prefix = targetDir.getCanonicalPath().concat(File.separator);
        String expectedCommand = javaHome.getCanonicalPath()
                .concat(File.separator)
                .concat("bin")
                .concat(File.separator)
                .concat("java");
        if (Installation.isWindows()) {
            expectedCommand = expectedCommand.concat(".exe");
        }
        String expectedArgument = prefix.concat("autotest.py");
        _verifier.setTargetDir(targetDir);
        String[] command = _verifier.getSimpleCommand();
        assertNotNull(command);
        assertEquals(4, command.length);
        assertEquals(expectedCommand, command[0]);
        assertEquals("-jar", command[1]);
        assertEquals(prefix.concat(JarInstaller.JYTHON_JAR), command[2]);
        assertEquals(expectedArgument, command[3]);
    }

    public void testDoShellScriptTests() {
        // we cannot do shell script tests in standalone mode
        assertFalse(_verifier.doShellScriptTests());
    }
}