Sha256: 401983cf5b1bbdc5dedfec366a715ebbb6931258e3241175a3964eb8f5463dca

Contents?: true

Size: 1.42 KB

Versions: 30

Compression:

Stored size: 1.42 KB

Contents

# test of reload -- PR#101 and related PR#128
#
# javac must be on your $PATH

import sys
import os
from java.lang import Runtime, System
rt = Runtime.getRuntime()

# make sure this directory doesn't appear on your CLASSPATH
tmpdir = '/tmp'                                   # TBD: Un*xism

# assert
cpath = System.getProperty('java.class.path')
for dir in cpath.split(os.pathsep):
    assert os.path.normpath(dir) <> tmpdir

sys.path.insert(0, tmpdir)
javafile = os.path.join(tmpdir, 'pr101j.java')

def makejavaclass(s):
    fp = open(javafile, 'w')
    fp.write('''
// Java side of the PR#101 test -- reload of a Java class
public class pr101j {
    public static String doit() {
        return "%s";
    }
}
''' % s)
    fp.close()
    proc = rt.exec('javac ' + javafile)
    status = proc.waitFor()
    if status <> 0:
        raise RuntimeError, 'javac process failed'

try:
    makejavaclass("first")
    import pr101j
    ret = pr101j.doit()
    if ret <> 'first':
        print 'unexpected first doit() result:', ret

    makejavaclass("second")
    pr101j = reload(pr101j)
    ret = pr101j.doit()
    if ret <> 'second':
        print 'unexpected second doit() result:', ret

    makejavaclass("third")
    pr101j = reload(pr101j)
    ret = pr101j.doit()
    if ret <> 'third':
        print 'unexpected third doit() result:', ret

finally:
    classfile = os.path.splitext(javafile)[0]+'.class'
    os.unlink(javafile)
    os.unlink(classfile)

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rubyfox-server-2.19.2.0 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.17.3.2 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.17.3.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.17.3.0 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.16.3.2 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.16.3.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.16.0.4 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.16.0.3 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.16.0.2 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.16.0.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.16.0.0 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.13.7.3 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.13.6.2 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.13.6.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.13.5.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.13.4.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.13.3.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.12.5.1 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.12.5.0 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py
rubyfox-server-2.12.4.0 lib/rubyfox/server/data/lib/Lib/test/bugs/pr101.py