diff options
| author | Andrei Belov <defan@nginx.com> | 2019-05-30 17:44:29 +0300 |
|---|---|---|
| committer | Andrei Belov <defan@nginx.com> | 2019-05-30 17:44:29 +0300 |
| commit | 4921df052be8437d912f3c60faa9a667890e4498 (patch) | |
| tree | 3678c551f148a0d177721597de978c090237f205 /test/unit/applications/lang/java.py | |
| parent | 3b7a7ff2aa5840d4238584410ee1ebc6860fb9c5 (diff) | |
| parent | 7da320a93af07765e79c929287704936c431f3cd (diff) | |
| download | unit-1.9.0-1.tar.gz unit-1.9.0-1.tar.bz2 | |
Merged with the default branch.1.9.0-1
Diffstat (limited to 'test/unit/applications/lang/java.py')
| -rw-r--r-- | test/unit/applications/lang/java.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py new file mode 100644 index 00000000..c4390f15 --- /dev/null +++ b/test/unit/applications/lang/java.py @@ -0,0 +1,74 @@ +import os +import shutil +from subprocess import Popen +from unit.applications.proto import TestApplicationProto + + +class TestApplicationJava(TestApplicationProto): + 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) + + tomcat_jar = self.pardir + '/build/tomcat-servlet-api-9.0.13.jar' + + javac = [ + 'javac', + '-encoding', 'utf-8', + '-d', classes_path, + '-classpath', tomcat_jar, + ] + javac.extend(src) + + process = Popen(javac) + process.communicate() + + self._load_conf( + { + "listeners": {"*:7080": {"pass": "applications/" + script}}, + "applications": { + script: { + "unit_jars": self.pardir + '/build', + "type": "java", + "processes": {"spare": 0}, + "working_directory": script_path, + "webapp": app_path, + } + }, + } + ) |
