diff options
author | Max Romanov <max.romanov@gmail.com> | 2019-02-28 18:02:42 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@gmail.com> | 2019-02-28 18:02:42 +0300 |
commit | 5bfdebb9e4161a689113d73775498949a09d7fb5 (patch) | |
tree | fcb69169e3da983db0eb1f48d2dccc2ac2ff867b /test/unit.py | |
parent | ec7319d32c9c41597a99a9422ff324c97a92bb21 (diff) | |
download | unit-5bfdebb9e4161a689113d73775498949a09d7fb5.tar.gz unit-5bfdebb9e4161a689113d73775498949a09d7fb5.tar.bz2 |
Introducing Java Servlet Container beta.
Diffstat (limited to 'test/unit.py')
-rw-r--r-- | test/unit.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/unit.py b/test/unit.py index 7a51eb20..a0de82e7 100644 --- a/test/unit.py +++ b/test/unit.py @@ -600,6 +600,72 @@ class TestUnitApplicationNode(TestUnitApplicationProto): } }) +class TestUnitApplicationJava(TestUnitApplicationProto): + def load(self, script, name='app'): + + app_path = self.testdir + '/java' + web_inf_path = app_path + '/WEB-INF/' + classes_path = web_inf_path + 'classes/' + + script_path = self.current_dir + '/java/' + script + '/' + + if not os.path.isdir(app_path): + os.makedirs(app_path) + + src = [] + + for f in os.listdir(script_path): + if f.endswith('.java'): + src.append(script_path + f) + continue + + if f.startswith('.') or f == 'Makefile': + continue + + if os.path.isdir(script_path + f): + if f == 'WEB-INF': + continue + + shutil.copytree(script_path + f, app_path + '/' + f) + continue + + if f == 'web.xml': + if not os.path.isdir(web_inf_path): + os.makedirs(web_inf_path) + + shutil.copy2(script_path + f, web_inf_path) + else: + shutil.copy2(script_path + f, app_path) + + if src: + if not os.path.isdir(classes_path): + os.makedirs(classes_path) + + javac = ['javac', '-encoding', 'utf-8', '-d', classes_path, + '-classpath', + self.pardir + '/build/tomcat-servlet-api-9.0.13.jar'] + javac.extend(src) + + process = subprocess.Popen(javac) + process.communicate() + + self.conf({ + "listeners": { + "*:7080": { + "application": script + } + }, + "applications": { + script: { + "unit_jars": self.pardir + '/build', + "type": "java", + "processes": { "spare": 0 }, + "working_directory": script_path, + "webapp": app_path + } + } + }) + class TestUnitApplicationPerl(TestUnitApplicationProto): def load(self, script, name='psgi.pl'): self.conf({ |