java.py (1477:b93d1acf81bd) java.py (1596:b7e2d4d92624)
1import glob
2import os
1import glob
2import os
3import pytest
3import shutil
4import subprocess
5
6from unit.applications.proto import TestApplicationProto
4import shutil
5import subprocess
6
7from unit.applications.proto import TestApplicationProto
8from conftest import option
7
8
9class TestApplicationJava(TestApplicationProto):
10 def load(self, script, name='app', **kwargs):
9
10
11class TestApplicationJava(TestApplicationProto):
12 def load(self, script, name='app', **kwargs):
11 app_path = self.testdir + '/java'
13 app_path = self.temp_dir + '/java'
12 web_inf_path = app_path + '/WEB-INF/'
13 classes_path = web_inf_path + 'classes/'
14 web_inf_path = app_path + '/WEB-INF/'
15 classes_path = web_inf_path + 'classes/'
14 script_path = self.current_dir + '/java/' + script + '/'
16 script_path = option.test_dir + '/java/' + script + '/'
15
16 if not os.path.isdir(app_path):
17 os.makedirs(app_path)
18
19 src = []
20
21 for f in os.listdir(script_path):
22 file_path = script_path + f

--- 26 unchanged lines hidden (view full) ---

49
50 classpath = self.pardir + '/build/tomcat-servlet-api-9.0.13.jar'
51
52 ws_jars = glob.glob(
53 self.pardir + '/build/websocket-api-java-*.jar'
54 )
55
56 if not ws_jars:
17
18 if not os.path.isdir(app_path):
19 os.makedirs(app_path)
20
21 src = []
22
23 for f in os.listdir(script_path):
24 file_path = script_path + f

--- 26 unchanged lines hidden (view full) ---

51
52 classpath = self.pardir + '/build/tomcat-servlet-api-9.0.13.jar'
53
54 ws_jars = glob.glob(
55 self.pardir + '/build/websocket-api-java-*.jar'
56 )
57
58 if not ws_jars:
57 self.fail('websocket api jar not found.')
59 pytest.fail('websocket api jar not found.')
58
59 javac = [
60 'javac',
61 '-encoding', 'utf-8',
62 '-d', classes_path,
63 '-classpath', classpath + ':' + ws_jars[0],
64 ]
65 javac.extend(src)
66
67 try:
68 process = subprocess.Popen(javac, stderr=subprocess.STDOUT)
69 process.communicate()
70
71 except:
60
61 javac = [
62 'javac',
63 '-encoding', 'utf-8',
64 '-d', classes_path,
65 '-classpath', classpath + ':' + ws_jars[0],
66 ]
67 javac.extend(src)
68
69 try:
70 process = subprocess.Popen(javac, stderr=subprocess.STDOUT)
71 process.communicate()
72
73 except:
72 self.fail('Cann\'t run javac process.')
74 pytest.fail('Cann\'t run javac process.')
73
74 self._load_conf(
75 {
76 "listeners": {"*:7080": {"pass": "applications/" + script}},
77 "applications": {
78 script: {
79 "unit_jars": self.pardir + '/build',
80 "type": 'java',
81 "processes": {"spare": 0},
82 "working_directory": script_path,
83 "webapp": app_path,
84 }
85 },
86 },
87 **kwargs
88 )
75
76 self._load_conf(
77 {
78 "listeners": {"*:7080": {"pass": "applications/" + script}},
79 "applications": {
80 script: {
81 "unit_jars": self.pardir + '/build',
82 "type": 'java',
83 "processes": {"spare": 0},
84 "working_directory": script_path,
85 "webapp": app_path,
86 }
87 },
88 },
89 **kwargs
90 )