Skip to content

Commit 7bb257e

Browse files
committed
Merge pull request playframework#229 from shelajev/lighthouse-419-patch
[playframework#419] Fix autotest http protocol & port configuration
1 parent 895bf48 commit 7bb257e

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

framework/pym/play/commands/base.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ def autotest(app, args):
178178
print "~"
179179

180180
# Kill if exists
181-
http_port = app.readConf('http.port')
181+
http_port = 9000
182+
protocol = 'http'
183+
if app.readConf('https.port'):
184+
http_port = app.readConf('https.port')
185+
protocol = 'https'
186+
else:
187+
http_port = app.readConf('http.port')
182188
try:
183189
proxy_handler = urllib2.ProxyHandler({})
184190
opener = urllib2.build_opener(proxy_handler)
@@ -222,7 +228,7 @@ def autotest(app, args):
222228
cp_args = ':'.join(fpcp)
223229
if os.name == 'nt':
224230
cp_args = ';'.join(fpcp)
225-
java_cmd = [app.java_path(), '-classpath', cp_args, '-Dapplication.url=http://localhost:%s' % http_port, 'play.modules.testrunner.FirePhoque']
231+
java_cmd = [app.java_path(), '-classpath', cp_args, '-Dapplication.url=%s://localhost:%s' % (protocol, http_port), 'play.modules.testrunner.FirePhoque']
226232
try:
227233
subprocess.call(java_cmd, env=os.environ)
228234
except OSError:
@@ -243,7 +249,7 @@ def autotest(app, args):
243249
try:
244250
proxy_handler = urllib2.ProxyHandler({})
245251
opener = urllib2.build_opener(proxy_handler)
246-
opener.open('http://localhost:%s/@kill' % http_port)
252+
opener.open('%s://localhost:%s/@kill' % (protocol, http_port))
247253
except Exception, e:
248254
pass
249255

modules/testrunner/app/views/TestRunner/index.html

+22-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,17 @@
371371
});
372372
}
373373
if(/.test.html/.test(testId)) {
374-
$('#selenium-runner').attr('src', '@{'/public/test-runner/selenium/TestRunner.html'}?baseUrl=http://localhost:${play.configuration['http.port'] ?: '9000'}&test=/@tests/'+testId+'.suite&auto=true&close=true&resultsUrl=/@tests/'+testId);
374+
%{
375+
protocol = "http";
376+
port = 9000;
377+
if(play.configuration['https.port'] != null) {
378+
port = play.configuration['https.port'];
379+
protocol = "https";
380+
} else if (play.configuration['http.port'] != null) {
381+
port = play.configuration['http.port'];
382+
}
383+
}%
384+
$('#selenium-runner').attr('src', '@{'/public/test-runner/selenium/TestRunner.html'}?baseUrl=${protocol}://localhost:${port}&test=/@tests/'+testId+'.suite&auto=true&close=true&resultsUrl=/@tests/'+testId);
375385
$('#selenium-mask, #selenium').show();
376386
window.checkResult = setInterval(function() {
377387
var req = $.ajax({url: '@{TestRunner.run("XXX.result")}'.replace('XXX', testId), async: false});
@@ -607,10 +617,20 @@ <h2><span>${tis ? '' : 'There '+functionalTests.size().pluralize('is', 'are')} $
607617
#{if seleniumTests}
608618
<h2><span>${tis ? '' : 'There '+seleniumTests.size().pluralize('is', 'are')} ${tis ? 'and' : ''} ${seleniumTests.size()} selenium test${seleniumTests.size().pluralize()},</span></h2>
609619
<ul>
620+
%{
621+
protocol = "http";
622+
port = 9000;
623+
if(play.configuration['https.port'] != null) {
624+
port = play.configuration['https.port'];
625+
protocol = "https";
626+
} else if (play.configuration['http.port'] != null) {
627+
port = play.configuration['http.port'];
628+
}
629+
}%
610630
#{list items:seleniumTests, as:'test'}
611631
<li>
612632
<div class="test" id="${test}">
613-
<span class="touch">+</span><a href="@{'/public/test-runner/selenium/TestRunner.html'}?baseUrl=http://localhost:${play.configuration['http.port'] ?: '9000'}&test=/@tests/${test}.suite">${test.replace('.test.html','')}</a>
633+
<span class="touch">+</span><a href="@{'/public/test-runner/selenium/TestRunner.html'}?baseUrl=${protocol}://localhost:${port}&test=/@tests/${test}.suite">${test.replace('.test.html','')}</a>
614634
<div class="testResult"></div>
615635
</div>
616636
</li>

modules/testrunner/src/play/modules/testrunner/FirePhoque.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void main(String[] args) throws Exception {
4747
}
4848
in.close();
4949
} catch(Exception e) {
50-
System.out.println("~ The application does not start. There are compilation errors.");
50+
System.out.println("~ The application does not start. There are errors: " + e);
5151
System.exit(-1);
5252
}
5353

modules/testrunner/src/play/modules/testrunner/TestRunnerPlugin.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@ public void onRoutesLoaded() {
3333

3434
@Override
3535
public void onApplicationReady() {
36+
String protocol = "http";
37+
String port = "9000";
38+
if(Play.configuration.getProperty("https.port") != null) {
39+
port = Play.configuration.getProperty("https.port");
40+
protocol = "https";
41+
} else if(Play.configuration.getProperty("http.port") != null) {
42+
port = Play.configuration.getProperty("http.port");
43+
}
3644
System.out.println("~");
37-
System.out.println("~ Go to http://localhost:" + Play.configuration.getProperty("http.port", "9000") + "/@tests to run the tests");
45+
System.out.println("~ Go to "+protocol+"://localhost:" + port + "/@tests to run the tests");
3846
System.out.println("~");
3947
}
4048

0 commit comments

Comments
 (0)