From bcb9048c4663a34d9b29a6b5b8e3da14a4321a96 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Tue, 2 Jul 2019 16:44:08 +0300 Subject: Tests: adjusted inactive interval in Java app for slow hosts. --- test/test_java_application.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'test/test_java_application.py') diff --git a/test/test_java_application.py b/test/test_java_application.py index 5d0350fa..54ae3366 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -99,12 +99,16 @@ class TestJavaApplication(TestApplicationJava): def test_java_application_session_active(self): self.load('session_inactive') - resp = self.get() + resp = self.get(headers={ + 'X-Interval': '4', + 'Host': 'localhost', + 'Connection': 'close', + }) session_id = resp['headers']['X-Session-Id'] self.assertEqual(resp['status'], 200, 'session init') self.assertEqual( - resp['headers']['X-Session-Interval'], '2', 'session interval' + resp['headers']['X-Session-Interval'], '4', 'session interval' ) self.assertLess( abs( @@ -147,7 +151,7 @@ class TestJavaApplication(TestApplicationJava): resp['headers']['X-Session-Id'], session_id, 'session active 2' ) - time.sleep(1) + time.sleep(2) resp = self.get( headers={ @@ -164,7 +168,11 @@ class TestJavaApplication(TestApplicationJava): def test_java_application_session_inactive(self): self.load('session_inactive') - resp = self.get() + resp = self.get(headers={ + 'X-Interval': '1', + 'Host': 'localhost', + 'Connection': 'close', + }) session_id = resp['headers']['X-Session-Id'] time.sleep(3) -- cgit From a920215a5cec785e8e3f4bb675b18b5c8916f4dd Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Wed, 17 Jul 2019 17:48:35 +0300 Subject: Tests: more Java tests. Added test with war file and error configuration test. --- test/test_java_application.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test/test_java_application.py') diff --git a/test/test_java_application.py b/test/test_java_application.py index 54ae3366..e62720d1 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -5,6 +5,46 @@ from unit.applications.lang.java import TestApplicationJava class TestJavaApplication(TestApplicationJava): prerequisites = ['java'] + def test_java_conf_error(self): + self.skip_alerts.extend( + [ + r'realpath.*failed', + r'failed to apply new conf', + ] + ) + self.assertIn( + 'error', + self.conf( + { + "listeners": {"*:7080": {"pass": "applications/app"}}, + "applications": { + "app": { + "type": "java", + "processes": 1, + "working_directory": self.current_dir + + "/java/empty", + "webapp": self.testdir + "/java", + } + }, + } + ), + 'conf error', + ) + + def test_java_war(self): + self.load('empty_war') + + self.assertIn( + 'success', + self.conf( + '"' + self.testdir + '/java/empty.war"', + '/config/applications/empty_war/webapp', + ), + 'configure war', + ) + + self.assertEqual(self.get()['status'], 200, 'war') + def test_java_application_cookies(self): self.load('cookies') -- cgit From b1165d2edc99daf8eef0e092e4ed6dcee9bce252 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Tue, 23 Jul 2019 14:58:27 +0300 Subject: Tests: fixed test_java_conf_error to pass with "--modules=" option. --- test/test_java_application.py | 1 + 1 file changed, 1 insertion(+) (limited to 'test/test_java_application.py') diff --git a/test/test_java_application.py b/test/test_java_application.py index e62720d1..f604368c 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -24,6 +24,7 @@ class TestJavaApplication(TestApplicationJava): "working_directory": self.current_dir + "/java/empty", "webapp": self.testdir + "/java", + "unit_jars": self.testdir + "/no_such_dir", } }, } -- cgit From e8d1c760d6c8134c809d2bb60c212743fdbb9b16 Mon Sep 17 00:00:00 2001 From: Andrey Zelenkov Date: Wed, 7 Aug 2019 14:43:38 +0300 Subject: Tests: Java multipart test. --- test/test_java_application.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'test/test_java_application.py') diff --git a/test/test_java_application.py b/test/test_java_application.py index f604368c..2e22e545 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -1,4 +1,5 @@ import time +import unittest from unit.applications.lang.java import TestApplicationJava @@ -1213,6 +1214,44 @@ class TestJavaApplication(TestApplicationJava): ) self.assertEqual(headers['X-Get-Date'], date, 'get date header') + @unittest.skip('not yet') + def test_java_application_multipart(self): + self.load('multipart') + + body = """Preamble. Should be ignored.\r +\r +--12345\r +Content-Disposition: form-data; name="file"; filename="sample.txt"\r +Content-Type: text/plain\r +\r +Data from sample file\r +--12345\r +Content-Disposition: form-data; name="destination"\r +\r +%s\r +--12345\r +Content-Disposition: form-data; name="upload"\r +\r +Upload\r +--12345--\r +\r +Epilogue. Should be ignored.""" % self.testdir + + resp = self.post( + headers={ + 'Content-Type': 'multipart/form-data; boundary=12345', + 'Host': 'localhost', + 'Connection': 'close', + }, + body=body, + ) + + self.assertEqual(resp['status'], 200, 'multipart status') + self.assertRegex(resp['body'], r'sample\.txt created', 'multipart body') + self.assertIsNotNone( + self.search_in_log(r'^Data from sample file$', name='sample.txt'), + 'file created', + ) if __name__ == '__main__': TestJavaApplication.main() -- cgit From 4bef4256c05c3f905e3d65e40585bba5ce0f3327 Mon Sep 17 00:00:00 2001 From: Max Romanov Date: Wed, 14 Aug 2019 15:24:41 +0300 Subject: Java: implementing multipart message support. This closes #265 issue on GitHub. --- test/test_java_application.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/test_java_application.py') diff --git a/test/test_java_application.py b/test/test_java_application.py index 2e22e545..526be565 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -1214,7 +1214,6 @@ class TestJavaApplication(TestApplicationJava): ) self.assertEqual(headers['X-Get-Date'], date, 'get date header') - @unittest.skip('not yet') def test_java_application_multipart(self): self.load('multipart') -- cgit