jubilee 2.0.0-java → 2.1.0.Alpha1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/Rakefile +1 -1
- data/jars/hazelcast-3.2.3.jar +0 -0
- data/jars/{netty-all-4.0.14.Final.jar → netty-all-4.0.20.Final.jar} +0 -0
- data/jars/vertx-core-2.1.1.jar +0 -0
- data/jars/vertx-hazelcast-2.1.1.jar +0 -0
- data/jars/vertx-platform-2.1.1.jar +0 -0
- data/java/src/org/jruby/jubilee/JubileeVerticle.java +68 -45
- data/java/src/org/jruby/jubilee/RackApplication.java +6 -0
- data/java/src/org/jruby/jubilee/RubyPlatformManager.java +5 -5
- data/java/src/org/jruby/jubilee/impl/RubyIORackInput.java +2 -3
- data/lib/jubilee.rb +5 -5
- data/lib/jubilee/cli.rb +4 -4
- data/lib/jubilee/configuration.rb +2 -6
- data/lib/jubilee/jubilee.jar +0 -0
- data/lib/jubilee/server.rb +1 -5
- data/lib/jubilee/version.rb +2 -2
- data/spec/apps/rails4/basic/Gemfile.lock +5 -1
- data/spec/integration/basic_rack_spec.rb +1 -1
- data/spec/integration/basic_rails4_spec.rb +1 -1
- data/spec/integration/basic_sinatra_spec.rb +1 -2
- data/test/apps/checker.ru +38 -0
- data/test/apps/method_override.ru +2 -0
- data/test/apps/overwrite_check.ru +8 -0
- data/test/apps/rack_crasher.ru +8 -0
- data/test/apps/sha1.ru +38 -0
- data/test/apps/simple.ru +1 -0
- data/test/apps/url_scheme.ru +1 -0
- data/test/jubilee/test_configuration.rb +0 -1
- data/test/jubilee/test_rack_server.rb +1 -42
- data/test/jubilee/test_server.rb +5 -21
- data/test/jubilee/test_upload.rb +19 -61
- metadata +16 -9
- data/jars/hazelcast-2.6.3.jar +0 -0
- data/jars/vertx-core-2.1M3.jar +0 -0
- data/jars/vertx-hazelcast-2.1M3.jar +0 -0
- data/jars/vertx-platform-2.1M3.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 683724968b6ea7ae25e8fcb25f3684bc65df6a47
|
4
|
+
data.tar.gz: 92f9f51d3833a0b228bc22f49cdcd07a4d2a02f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9a114e152bc837ab4ce9d8ab2759cf7edcc9f2f79e40871c3e8c8b4d0489d08b29eb8bfcafc74318e13025a4d5d6c60a2350cdc4e3670096f90c96842b84a70
|
7
|
+
data.tar.gz: 9de31bb5904dc1ff30d37bb2f081bb451dd024819f1a758594514839e68d0cf1d47f836d35438ade2993126dd655a00d8f5f8effbc077cb0ee935afde57f09e0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
jruby-1.7.
|
1
|
+
jruby-1.7.13
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -86,7 +86,7 @@ desc "Compile the extension, need jdk7 because vertx relies on it"
|
|
86
86
|
task :compile => [DEST_PATH, "#{DEST_PATH}/META-INF"] do |t|
|
87
87
|
ant.javac :srcdir => "java", :destdir => t.prerequisites.first,
|
88
88
|
:source => "1.7", :target => "1.7", :debug => true, :includeantruntime => false,
|
89
|
-
:classpath => "${java.class.path}:${sun.boot.class.path}:jars/vertx-core-2.
|
89
|
+
:classpath => "${java.class.path}:${sun.boot.class.path}:jars/vertx-core-2.1.1.jar:jars/netty-all-4.0.20.Final.jar:jars/jackson-core-2.2.2.jar:jars/jackson-databind-2.2.2.jar:jars/jackson-annotations-2.2.2.jar:jars/hazelcast-3.2.3.jar:jars/vertx-platform-2.1.1.jar:jars/vertx-hazelcast-2.1.1.jar"
|
90
90
|
end
|
91
91
|
|
92
92
|
desc "Copy META-INF"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,6 +1,7 @@
|
|
1
1
|
package org.jruby.jubilee;
|
2
2
|
|
3
3
|
import org.jruby.Ruby;
|
4
|
+
import org.jruby.RubyInstanceConfig;
|
4
5
|
import org.jruby.runtime.builtin.IRubyObject;
|
5
6
|
import org.vertx.java.core.Handler;
|
6
7
|
import org.vertx.java.core.http.HttpServer;
|
@@ -11,59 +12,81 @@ import org.vertx.java.platform.Verticle;
|
|
11
12
|
import org.vertx.java.platform.impl.WrappedVertx;
|
12
13
|
|
13
14
|
import java.io.IOException;
|
15
|
+
import java.util.Arrays;
|
14
16
|
|
15
17
|
/**
|
16
18
|
* Created by isaiah on 23/01/2014.
|
17
19
|
*/
|
18
20
|
public class JubileeVerticle extends Verticle {
|
19
|
-
|
21
|
+
private Ruby runtime;
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
23
|
+
@Override
|
24
|
+
public void start() {
|
25
|
+
JsonObject config = container.config();
|
26
|
+
HttpServer httpServer = vertx.createHttpServer();
|
27
|
+
String root = config.getString("root", ".");
|
28
|
+
this.runtime = createRuntime(root, config);
|
29
|
+
String expandedRoot = this.runtime.evalScriptlet("File.expand_path(%q(" + root + "))").asJavaString();
|
30
|
+
this.runtime.setCurrentDirectory(expandedRoot);
|
31
|
+
IRubyObject rackApplication = initRackApplication(config);
|
32
|
+
final RackApplication app;
|
33
|
+
boolean ssl = config.getBoolean("ssl");
|
34
|
+
try {
|
35
|
+
app = new RackApplication((WrappedVertx) vertx, runtime.getCurrentContext(), rackApplication, ssl);
|
36
|
+
httpServer.setAcceptBacklog(10000);
|
37
|
+
httpServer.requestHandler(new Handler<HttpServerRequest>() {
|
38
|
+
public void handle(final HttpServerRequest req) {
|
39
|
+
app.call(req);
|
40
|
+
}
|
41
|
+
});
|
42
|
+
if (config.containsField("event_bus")) {
|
43
|
+
JsonArray allowAll = new JsonArray();
|
44
|
+
allowAll.add(new JsonObject());
|
45
|
+
JsonObject ebconf = new JsonObject();
|
46
|
+
ebconf.putString("prefix", config.getString("event_bus"));
|
47
|
+
vertx.createSockJSServer(httpServer).bridge(ebconf, allowAll, allowAll);
|
48
|
+
}
|
49
|
+
if (ssl) httpServer.setSSL(true).setKeyStorePath(config.getString("keystore_path"))
|
50
|
+
.setKeyStorePassword(config.getString("keystore_password"));
|
51
|
+
httpServer.listen(config.getInteger("port"), config.getString("host"));
|
52
|
+
} catch (IOException e) {
|
53
|
+
container.logger().fatal("Failed to create RackApplication");
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
@Override
|
58
|
+
public void stop() {
|
59
|
+
this.runtime.tearDown();
|
41
60
|
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
61
|
+
|
62
|
+
private Ruby createRuntime(String root, JsonObject options) {
|
63
|
+
Ruby runtime;
|
64
|
+
// if (Ruby.isGlobalRuntimeReady()) {
|
65
|
+
// runtime = Ruby.getGlobalRuntime();
|
66
|
+
// } else {
|
67
|
+
RubyInstanceConfig instanceConfig = new RubyInstanceConfig();
|
68
|
+
String jrubyHome = options.getString("jruby-home", "");
|
69
|
+
if (!jrubyHome.isEmpty()) {
|
70
|
+
instanceConfig.setJRubyHome(jrubyHome);
|
48
71
|
}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
vertx.createSockJSServer(httpServer).bridge(ebconf, allowAll, allowAll);
|
56
|
-
}
|
57
|
-
if (ssl) httpServer.setSSL(true).setKeyStorePath(config.getString("keystore_path"))
|
58
|
-
.setKeyStorePassword(config.getString("keystore_password"));
|
59
|
-
httpServer.listen(config.getInteger("port"), config.getString("host"));
|
60
|
-
} catch (IOException e) {
|
61
|
-
container.logger().fatal("Failed to create RackApplication");
|
72
|
+
Object[] argv = options.getArray("argv", new JsonArray(new String[]{})).toArray();
|
73
|
+
instanceConfig.setArgv(Arrays.copyOf(argv, argv.length, String[].class));
|
74
|
+
runtime = Ruby.newInstance(instanceConfig);
|
75
|
+
// }
|
76
|
+
runtime.getLoadService().addPaths(root);
|
77
|
+
return runtime;
|
62
78
|
}
|
63
|
-
}
|
64
79
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
private IRubyObject initRackApplication(JsonObject config) {
|
81
|
+
String rackup = config.getString("rackup");
|
82
|
+
String rackScript = "require 'rack'\n" +
|
83
|
+
"require 'jubilee'\n" +
|
84
|
+
"app, _ = Rack::Builder.parse_file('" + rackup + "')\n";
|
85
|
+
if (!config.getBoolean("quiet") && config.getString("environment").equals("development")) {
|
86
|
+
rackScript += "logger = STDOUT\n" +
|
87
|
+
"app = Rack::CommonLogger.new(app, logger)\n";
|
88
|
+
}
|
89
|
+
rackScript += "Jubilee::Application.new(app)\n";
|
90
|
+
return runtime.evalScriptlet(rackScript);
|
91
|
+
}
|
69
92
|
}
|
@@ -43,12 +43,13 @@ public class RubyPlatformManager extends RubyObject {
|
|
43
43
|
}
|
44
44
|
|
45
45
|
@JRubyMethod
|
46
|
-
public IRubyObject initialize(ThreadContext context, IRubyObject config) {
|
47
|
-
RubyHash options = config.convertToHash();
|
46
|
+
public IRubyObject initialize(final ThreadContext context, IRubyObject config) {
|
47
|
+
final RubyHash options = config.convertToHash();
|
48
48
|
Ruby runtime = context.runtime;
|
49
49
|
RubySymbol clustered_k = runtime.newSymbol("clustered");
|
50
50
|
RubySymbol cluster_host_k = runtime.newSymbol("cluster_host");
|
51
51
|
RubySymbol cluster_port_k = runtime.newSymbol("cluster_port");
|
52
|
+
final RubySymbol port_k = runtime.newSymbol("Port");
|
52
53
|
if (options.containsKey(clustered_k) && options.op_aref(context, clustered_k).isTrue()) {
|
53
54
|
int clusterPort = 0;
|
54
55
|
String clusterHost = null;
|
@@ -68,6 +69,7 @@ public class RubyPlatformManager extends RubyObject {
|
|
68
69
|
@Override
|
69
70
|
public void handle(AsyncResult<String> result) {
|
70
71
|
if (result.succeeded()) {
|
72
|
+
context.runtime.getOutputStream().println("Jubilee is listening on port " + options.op_aref(context, port_k) +", press Ctrl+C to quit");
|
71
73
|
// System.out.println("Deployment ID is " + result.result());
|
72
74
|
} else{
|
73
75
|
result.cause().printStackTrace();
|
@@ -102,8 +104,6 @@ public class RubyPlatformManager extends RubyObject {
|
|
102
104
|
|
103
105
|
if (options.has_key_p(rack_up_k).isTrue())
|
104
106
|
map.put("rackup", options.op_aref(context, rack_up_k).asJavaString());
|
105
|
-
if (options.has_key_p(rack_app_k).isTrue())
|
106
|
-
map.put("rackapp", options.op_aref(context, rack_app_k));
|
107
107
|
map.put("quiet", options.containsKey(quiet_k) && options.op_aref(context, quiet_k).isTrue());
|
108
108
|
|
109
109
|
map.put("environment", options.op_aref(context, environment_k).asJavaString());
|
@@ -118,7 +118,7 @@ public class RubyPlatformManager extends RubyObject {
|
|
118
118
|
if (options.has_key_p(eventbus_prefix_k).isTrue())
|
119
119
|
map.put("event_bus", options.op_aref(context, eventbus_prefix_k).asJavaString());
|
120
120
|
// This is a trick to put an Object into the config object
|
121
|
-
map.put("ruby", runtime);
|
121
|
+
// map.put("ruby", runtime);
|
122
122
|
return map;
|
123
123
|
}
|
124
124
|
/*
|
@@ -73,14 +73,13 @@ public class RubyIORackInput extends RubyObject implements RackInput {
|
|
73
73
|
|
74
74
|
if (isEOF()) return runtime.getNil();
|
75
75
|
|
76
|
-
int lineEnd =
|
76
|
+
int lineEnd = buf.indexOf(buf.readerIndex(), buf.writerIndex(), Const.EOL);
|
77
77
|
while (lineEnd == -1 && !eof.get()) {
|
78
78
|
lineEnd = buf.indexOf(buf.readerIndex(), buf.writerIndex(), Const.EOL);
|
79
79
|
}
|
80
80
|
|
81
81
|
// No line break found, read all
|
82
|
-
if (lineEnd == -1)
|
83
|
-
return readAll(runtime, line);
|
82
|
+
if (lineEnd == -1) return readAll(runtime, line);
|
84
83
|
|
85
84
|
int readLength = lineEnd - buf.readerIndex();
|
86
85
|
byte[] dst = new byte[readLength + 1];
|
data/lib/jubilee.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "../jars/jackson-core-2.2.2.jar")
|
2
2
|
require File.join(File.dirname(__FILE__), "../jars/jackson-databind-2.2.2.jar")
|
3
3
|
require File.join(File.dirname(__FILE__), "../jars/jackson-annotations-2.2.2.jar")
|
4
|
-
require File.join(File.dirname(__FILE__), "../jars/hazelcast-2.
|
5
|
-
require File.join(File.dirname(__FILE__), "../jars/vertx-core-2.
|
6
|
-
require File.join(File.dirname(__FILE__), "../jars/vertx-hazelcast-2.
|
7
|
-
require File.join(File.dirname(__FILE__), "../jars/vertx-platform-2.
|
8
|
-
require File.join(File.dirname(__FILE__), "../jars/netty-all-4.0.
|
4
|
+
require File.join(File.dirname(__FILE__), "../jars/hazelcast-3.2.3.jar")
|
5
|
+
require File.join(File.dirname(__FILE__), "../jars/vertx-core-2.1.1.jar")
|
6
|
+
require File.join(File.dirname(__FILE__), "../jars/vertx-hazelcast-2.1.1.jar")
|
7
|
+
require File.join(File.dirname(__FILE__), "../jars/vertx-platform-2.1.1.jar")
|
8
|
+
require File.join(File.dirname(__FILE__), "../jars/netty-all-4.0.20.Final.jar")
|
9
9
|
|
10
10
|
require 'jubilee/jubilee.jar'
|
11
11
|
require 'rack'
|
data/lib/jubilee/cli.rb
CHANGED
@@ -39,7 +39,7 @@ module Jubilee
|
|
39
39
|
`jubilee_d #{(@argv - ["-d", "--daemon"]).join(" ")}`
|
40
40
|
else
|
41
41
|
@config = Jubilee::Configuration.new(@options)
|
42
|
-
server = Jubilee::Server.new(
|
42
|
+
server = Jubilee::Server.new(@config.options)
|
43
43
|
#server.start
|
44
44
|
thread = Thread.current
|
45
45
|
Signal.trap("INT") do
|
@@ -47,7 +47,7 @@ module Jubilee
|
|
47
47
|
puts "Jubilee is shutting down gracefully..."
|
48
48
|
thread.wakeup
|
49
49
|
end
|
50
|
-
puts "Jubilee is
|
50
|
+
puts "Jubilee is initializing..."
|
51
51
|
sleep
|
52
52
|
end
|
53
53
|
end
|
@@ -96,7 +96,7 @@ module Jubilee
|
|
96
96
|
@options[:ssl_keystore] = arg
|
97
97
|
end
|
98
98
|
o.on "--ssl-password PASS", "SSL keystore password" do |arg|
|
99
|
-
@options[:
|
99
|
+
@options[:ssl_password] = arg
|
100
100
|
end
|
101
101
|
o.separator ""
|
102
102
|
o.separator "Event bus options:"
|
@@ -127,7 +127,7 @@ module Jubilee
|
|
127
127
|
end
|
128
128
|
|
129
129
|
o.on "-v", "--version", "Print the version information" do
|
130
|
-
puts "jubilee version #{Jubilee::Version::STRING} on Vert.x 2.
|
130
|
+
puts "jubilee version #{Jubilee::Version::STRING} on Vert.x 2.1.1"
|
131
131
|
exit 0
|
132
132
|
end
|
133
133
|
end
|
@@ -10,17 +10,16 @@ module Jubilee
|
|
10
10
|
attr_accessor :config_file
|
11
11
|
attr_reader :options
|
12
12
|
|
13
|
-
def initialize(options
|
13
|
+
def initialize(options)
|
14
14
|
@config_file = options.delete(:config_file)
|
15
15
|
@options = options.dup
|
16
|
-
@block = block
|
17
16
|
|
18
17
|
reload
|
19
18
|
end
|
20
19
|
|
21
20
|
def reload
|
22
21
|
instance_eval(File.read(config_file), config_file) if config_file
|
23
|
-
load_rack_adapter
|
22
|
+
load_rack_adapter
|
24
23
|
end
|
25
24
|
|
26
25
|
# sets the host and port jubilee listens to +address+ may be an Integer port
|
@@ -106,9 +105,6 @@ module Jubilee
|
|
106
105
|
|
107
106
|
private
|
108
107
|
def load_rack_adapter(&block)
|
109
|
-
if block
|
110
|
-
@options[:rackapp] = Rack::Builder.new(&block).to_app
|
111
|
-
end
|
112
108
|
Dir.chdir(@options[:chdir]) if @options[:chdir]
|
113
109
|
@options[:rackup] = rackup
|
114
110
|
end
|
data/lib/jubilee/jubilee.jar
CHANGED
Binary file
|
data/lib/jubilee/server.rb
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
module Jubilee
|
2
2
|
class Server < PlatformManager
|
3
|
-
def initialize(
|
3
|
+
def initialize(opts = {})
|
4
4
|
options = {Host: "0.0.0.0", Port: 8080, ssl: false, instances: 1, environment: "development", quiet: true}.merge(opts)
|
5
5
|
if (options[:ssl]) && options[:ssl_keystore].nil?
|
6
6
|
raise ArgumentError, "Please provide a keystore for ssl"
|
7
7
|
end
|
8
8
|
# Rackup passes a string value
|
9
9
|
options[:Port] = options[:Port].to_i
|
10
|
-
# back compatible
|
11
|
-
if app
|
12
|
-
options[:rackapp] = Application.new(app)
|
13
|
-
end
|
14
10
|
super(options)
|
15
11
|
end
|
16
12
|
|
data/lib/jubilee/version.rb
CHANGED
@@ -28,6 +28,7 @@ GEM
|
|
28
28
|
thread_safe (~> 0.1)
|
29
29
|
tzinfo (~> 0.3.37)
|
30
30
|
arel (4.0.1)
|
31
|
+
atomic (1.1.14)
|
31
32
|
atomic (1.1.14-java)
|
32
33
|
builder (3.1.4)
|
33
34
|
coffee-rails (4.0.1)
|
@@ -49,8 +50,9 @@ GEM
|
|
49
50
|
jquery-rails (3.0.4)
|
50
51
|
railties (>= 3.0, < 5.0)
|
51
52
|
thor (>= 0.14, < 2.0)
|
53
|
+
json (1.8.1)
|
52
54
|
json (1.8.1-java)
|
53
|
-
jubilee (
|
55
|
+
jubilee (2.0.0-java)
|
54
56
|
rack (>= 1.4.1)
|
55
57
|
spoon (~> 0.0.4)
|
56
58
|
mail (2.5.4)
|
@@ -97,6 +99,8 @@ GEM
|
|
97
99
|
therubyrhino_jar (>= 1.7.3)
|
98
100
|
therubyrhino_jar (1.7.4)
|
99
101
|
thor (0.18.1)
|
102
|
+
thread_safe (0.1.3)
|
103
|
+
atomic
|
100
104
|
thread_safe (0.1.3-java)
|
101
105
|
atomic
|
102
106
|
tilt (1.4.1)
|
@@ -4,7 +4,7 @@ feature "basic rack at non-root context" do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
configurator = Jubilee::Configuration.new(chdir: "#{apps_dir}/rack/basic")
|
7
|
-
@server = Jubilee::Server.new(
|
7
|
+
@server = Jubilee::Server.new(configurator.options)
|
8
8
|
@server.start
|
9
9
|
sleep 0.1
|
10
10
|
end
|
@@ -4,7 +4,7 @@ feature 'basic rails4 test' do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
configurator = Jubilee::Configuration.new(chdir: "#{apps_dir}/rails4/basic")
|
7
|
-
@server = Jubilee::Server.new(
|
7
|
+
@server = Jubilee::Server.new(configurator.options)
|
8
8
|
@server.start
|
9
9
|
sleep 11
|
10
10
|
end
|
@@ -4,7 +4,7 @@ feature "basic sinatra test" do
|
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
configurator = Jubilee::Configuration.new(chdir: "#{apps_dir}/sinatra/basic")
|
7
|
-
@server = Jubilee::Server.new(
|
7
|
+
@server = Jubilee::Server.new(configurator.options)
|
8
8
|
@server.start
|
9
9
|
sleep 1
|
10
10
|
end
|
@@ -79,5 +79,4 @@ feature "basic sinatra test" do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
82
|
-
|
83
82
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rack'
|
2
|
+
class ErrorChecker
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
@exception = nil
|
6
|
+
@env = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :exception, :env
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
begin
|
13
|
+
@env = env
|
14
|
+
return @app.call(env)
|
15
|
+
rescue Exception => e
|
16
|
+
@exception = e
|
17
|
+
|
18
|
+
[
|
19
|
+
500,
|
20
|
+
{ "X-Exception" => e.message, "X-Exception-Class" => e.class.to_s },
|
21
|
+
["Error detected"]
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class ServerLint < Rack::Lint
|
28
|
+
def call(env)
|
29
|
+
assert("No env given") { env }
|
30
|
+
check_env env
|
31
|
+
|
32
|
+
@app.call(env)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
use ServerLint
|
37
|
+
use ErrorChecker
|
38
|
+
run lambda { |env| [200, { "X-Header" => "Works" }, ["Hello"]] }
|
data/test/apps/sha1.ru
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
bs = 4096
|
2
|
+
hdr = {'Content-Type' => 'text/plain', 'Content-Length' => '0'}
|
3
|
+
sha1_app = lambda do |env|
|
4
|
+
sha1 = Digest::SHA1.new
|
5
|
+
input = env['rack.input']
|
6
|
+
resp = {}
|
7
|
+
|
8
|
+
i = 0
|
9
|
+
while buf = input.read(bs)
|
10
|
+
sha1.update(buf)
|
11
|
+
i += buf.size
|
12
|
+
end
|
13
|
+
resp[:sha1] = sha1.hexdigest
|
14
|
+
|
15
|
+
# rewind and read again
|
16
|
+
input.rewind
|
17
|
+
sha1.reset
|
18
|
+
|
19
|
+
while buf = input.read(bs)
|
20
|
+
sha1.update(buf)
|
21
|
+
end
|
22
|
+
|
23
|
+
if resp[:sha1] == sha1.hexdigest
|
24
|
+
resp[:sysread_read_byte_match] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
if expect_size = env['HTTP_X_EXPECT_SIZE']
|
28
|
+
if expect_size.to_i == i
|
29
|
+
resp[:expect_size_match] = true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
resp[:size] = i
|
33
|
+
resp[:expect_size] = expect_size
|
34
|
+
|
35
|
+
[ 200, hdr.merge({'X-Resp' => resp.inspect}), [] ]
|
36
|
+
end
|
37
|
+
|
38
|
+
run sha1_app
|
data/test/apps/simple.ru
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
run lambda { |env| [200, { "X-Header" => "Works" }, ["Hello"]] }
|
@@ -0,0 +1 @@
|
|
1
|
+
run lambda { |env| [200, {}, [env['rack.url_scheme']]] }
|
@@ -5,50 +5,9 @@ require 'rack/commonlogger'
|
|
5
5
|
class TestRackServer < MiniTest::Unit::TestCase
|
6
6
|
include Helpers
|
7
7
|
|
8
|
-
class ErrorChecker
|
9
|
-
def initialize(app)
|
10
|
-
@app = app
|
11
|
-
@exception = nil
|
12
|
-
@env = nil
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_reader :exception, :env
|
16
|
-
|
17
|
-
def call(env)
|
18
|
-
begin
|
19
|
-
@env = env
|
20
|
-
return @app.call(env)
|
21
|
-
rescue Exception => e
|
22
|
-
@exception = e
|
23
|
-
|
24
|
-
[
|
25
|
-
500,
|
26
|
-
{ "X-Exception" => e.message, "X-Exception-Class" => e.class.to_s },
|
27
|
-
["Error detected"]
|
28
|
-
]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class ServerLint < Rack::Lint
|
34
|
-
def call(env)
|
35
|
-
assert("No env given") { env }
|
36
|
-
check_env env
|
37
|
-
|
38
|
-
@app.call(env)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class RackCrasher < Rack::Lint
|
43
|
-
def call(env)
|
44
|
-
raise "Oops"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
8
|
def setup
|
49
9
|
@valid_request = "GET / HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\n\r\n"
|
50
|
-
@
|
51
|
-
@checker = ErrorChecker.new ServerLint.new(@simple)
|
10
|
+
@checker = "checker.ru"
|
52
11
|
@host = "localhost"
|
53
12
|
@port = 8080
|
54
13
|
end
|
data/test/jubilee/test_server.rb
CHANGED
@@ -12,25 +12,9 @@ class TestJubileeServer < MiniTest::Unit::TestCase
|
|
12
12
|
sleep 0.1
|
13
13
|
end
|
14
14
|
|
15
|
-
def test_server_lambda
|
16
|
-
app = lambda {|env| [200, {"Content-Type" => "text/plain"}, ["http"]] }
|
17
|
-
@server = Jubilee::Server.new(app)
|
18
|
-
@server.start
|
19
|
-
sleep 0.5
|
20
|
-
|
21
|
-
http, body = Net::HTTP.new(@host, @port), nil
|
22
|
-
http.start do
|
23
|
-
req = Net::HTTP::Get.new "/", {}
|
24
|
-
http.request(req) do |resp|
|
25
|
-
body = resp.body
|
26
|
-
end
|
27
|
-
end
|
28
|
-
assert_equal "http", body
|
29
|
-
end
|
30
|
-
|
31
15
|
def test_server_embedded
|
32
16
|
config = Jubilee::Configuration.new(rackup: File.expand_path("../../config/config.ru", __FILE__))
|
33
|
-
@server = Jubilee::Server.new(
|
17
|
+
@server = Jubilee::Server.new(config.options)
|
34
18
|
@server.start
|
35
19
|
sleep 0.5
|
36
20
|
http, body = Net::HTTP.new(@host, @port), nil
|
@@ -44,10 +28,10 @@ class TestJubileeServer < MiniTest::Unit::TestCase
|
|
44
28
|
end
|
45
29
|
|
46
30
|
def test_url_scheme_for_https
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
config = Jubilee::Configuration.new(rackup: File.expand_path("../../apps/url_scheme.ru", __FILE__), port: @port, ssl: true,
|
32
|
+
ssl_keystore: File.join(File.dirname(__FILE__), "../../examples/keystore.jks"),
|
33
|
+
ssl_password: "hellojubilee")
|
34
|
+
@server = Jubilee::Server.new(config.options)
|
51
35
|
@server.start
|
52
36
|
sleep 0.5
|
53
37
|
http = Net::HTTP.new @host, @port
|
data/test/jubilee/test_upload.rb
CHANGED
@@ -6,50 +6,16 @@ require 'digest/md5'
|
|
6
6
|
class TestUpload < MiniTest::Unit::TestCase
|
7
7
|
|
8
8
|
def setup
|
9
|
-
@addr
|
10
|
-
@port
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@count = 256
|
9
|
+
@addr = ENV['UNICORN_TEST_ADDR'] || '127.0.0.1'
|
10
|
+
@port = 8080
|
11
|
+
@bs = 4096
|
12
|
+
@count = 256
|
14
13
|
@server = nil
|
15
|
-
@sha1
|
14
|
+
@sha1 = Digest::SHA1.new
|
16
15
|
|
17
16
|
# we want random binary data to test 1.9 encoding-aware IO craziness
|
18
17
|
@random = File.open('/dev/urandom','rb')
|
19
|
-
|
20
|
-
sha1 = Digest::SHA1.new
|
21
|
-
input = env['rack.input']
|
22
|
-
resp = {}
|
23
|
-
|
24
|
-
i = 0
|
25
|
-
while buf = input.read(@bs)
|
26
|
-
sha1.update(buf)
|
27
|
-
i += buf.size
|
28
|
-
end
|
29
|
-
resp[:sha1] = sha1.hexdigest
|
30
|
-
|
31
|
-
# rewind and read again
|
32
|
-
input.rewind
|
33
|
-
sha1.reset
|
34
|
-
|
35
|
-
while buf = input.read(@bs)
|
36
|
-
sha1.update(buf)
|
37
|
-
end
|
38
|
-
|
39
|
-
if resp[:sha1] == sha1.hexdigest
|
40
|
-
resp[:sysread_read_byte_match] = true
|
41
|
-
end
|
42
|
-
|
43
|
-
if expect_size = env['HTTP_X_EXPECT_SIZE']
|
44
|
-
if expect_size.to_i == i
|
45
|
-
resp[:expect_size_match] = true
|
46
|
-
end
|
47
|
-
end
|
48
|
-
resp[:size] = i
|
49
|
-
resp[:expect_size] = expect_size
|
50
|
-
|
51
|
-
[ 200, @hdr.merge({'X-Resp' => resp.inspect}), [] ]
|
52
|
-
end
|
18
|
+
sleep 1
|
53
19
|
end
|
54
20
|
|
55
21
|
def teardown
|
@@ -58,7 +24,7 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
58
24
|
end
|
59
25
|
|
60
26
|
def test_put
|
61
|
-
start_server
|
27
|
+
start_server
|
62
28
|
sock = TCPSocket.new(@addr, @port)
|
63
29
|
sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{length}\r\n\r\n")
|
64
30
|
@count.times do |i|
|
@@ -74,7 +40,7 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
74
40
|
end
|
75
41
|
|
76
42
|
def test_put_content_md5
|
77
|
-
start_server
|
43
|
+
start_server
|
78
44
|
skip "Vert.x doesn't hendle trailing headers"
|
79
45
|
md5 = Digest::MD5.new
|
80
46
|
sock = TCPSocket.new(@addr, @port)
|
@@ -99,7 +65,7 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
99
65
|
end
|
100
66
|
|
101
67
|
def test_put_trickle_small
|
102
|
-
start_server
|
68
|
+
start_server
|
103
69
|
@count, @bs = 2, 128
|
104
70
|
assert_equal 256, length
|
105
71
|
sock = TCPSocket.new(@addr, @port)
|
@@ -120,7 +86,7 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
120
86
|
end
|
121
87
|
|
122
88
|
def test_put_keepalive_truncates_small_overwrite
|
123
|
-
start_server
|
89
|
+
start_server
|
124
90
|
sock = TCPSocket.new(@addr, @port)
|
125
91
|
to_upload = length + 1
|
126
92
|
sock.syswrite("PUT / HTTP/1.0\r\nContent-Length: #{to_upload}\r\n\r\n")
|
@@ -145,16 +111,9 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
145
111
|
end
|
146
112
|
|
147
113
|
def test_put_excessive_overwrite_closed
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
nr = 0
|
152
|
-
while buf = env['rack.input'].read(65536)
|
153
|
-
nr += buf.size
|
154
|
-
end
|
155
|
-
tmp.write(nr.to_s)
|
156
|
-
[ 200, @hdr, [] ]
|
157
|
-
})
|
114
|
+
config = Jubilee::Configuration.new(rackup: File.expand_path("../../apps/overwrite_check.ru", __FILE__))
|
115
|
+
@server = Jubilee::Server.new(config.options)
|
116
|
+
|
158
117
|
sock = TCPSocket.new(@addr, @port)
|
159
118
|
# buf = ' ' * @bs # Something is wrong with the vertx http compression
|
160
119
|
buf = 'a' * @bs
|
@@ -165,8 +124,6 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
165
124
|
16384.times { sock.syswrite(buf) }
|
166
125
|
end
|
167
126
|
sock.gets
|
168
|
-
tmp.rewind
|
169
|
-
assert_equal length, tmp.read.to_i
|
170
127
|
sock.close
|
171
128
|
end
|
172
129
|
|
@@ -176,7 +133,7 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
176
133
|
which('sha1sum') or return
|
177
134
|
which('dd') or return
|
178
135
|
|
179
|
-
start_server
|
136
|
+
start_server
|
180
137
|
|
181
138
|
tmp = Tempfile.new('dd_dest')
|
182
139
|
assert(system("dd", "if=#{@random.path}", "of=#{tmp.path}",
|
@@ -218,7 +175,7 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
218
175
|
which('sha1sum') or return
|
219
176
|
which('dd') or return
|
220
177
|
|
221
|
-
start_server
|
178
|
+
start_server
|
222
179
|
|
223
180
|
tmp = Tempfile.new('dd_dest')
|
224
181
|
assert(system("dd", "if=#{@random.path}", "of=#{tmp.path}",
|
@@ -270,7 +227,7 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
270
227
|
which('sha1sum') or return
|
271
228
|
which('dd') or return
|
272
229
|
|
273
|
-
start_server
|
230
|
+
start_server
|
274
231
|
|
275
232
|
tmp = Tempfile.new('dd_dest')
|
276
233
|
# small StringIO path
|
@@ -297,8 +254,9 @@ class TestUpload < MiniTest::Unit::TestCase
|
|
297
254
|
@bs * @count
|
298
255
|
end
|
299
256
|
|
300
|
-
def start_server
|
301
|
-
|
257
|
+
def start_server
|
258
|
+
config = Jubilee::Configuration.new(rackup: File.expand_path("../../apps/sha1.ru", __FILE__))
|
259
|
+
@server = Jubilee::Server.new(config.options)
|
302
260
|
@server.start
|
303
261
|
sleep 0.1
|
304
262
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jubilee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.Alpha1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Isaiah Peng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -89,14 +89,14 @@ files:
|
|
89
89
|
- examples/client/vertxbus.js
|
90
90
|
- examples/jubilee.conf.rb
|
91
91
|
- examples/keystore.jks
|
92
|
-
- jars/hazelcast-2.
|
92
|
+
- jars/hazelcast-3.2.3.jar
|
93
93
|
- jars/jackson-annotations-2.2.2.jar
|
94
94
|
- jars/jackson-core-2.2.2.jar
|
95
95
|
- jars/jackson-databind-2.2.2.jar
|
96
|
-
- jars/netty-all-4.0.
|
97
|
-
- jars/vertx-core-2.
|
98
|
-
- jars/vertx-hazelcast-2.
|
99
|
-
- jars/vertx-platform-2.
|
96
|
+
- jars/netty-all-4.0.20.Final.jar
|
97
|
+
- jars/vertx-core-2.1.1.jar
|
98
|
+
- jars/vertx-hazelcast-2.1.1.jar
|
99
|
+
- jars/vertx-platform-2.1.1.jar
|
100
100
|
- java/resources/META-INF/services/org.vertx.java.core.spi.cluster.ClusterManagerFactory
|
101
101
|
- java/resources/default-cluster.xml
|
102
102
|
- java/src/jubilee/JubileeService.java
|
@@ -211,6 +211,13 @@ files:
|
|
211
211
|
- spec/integration/basic_sinatra_spec.rb
|
212
212
|
- spec/spec_helper.rb
|
213
213
|
- test/.ruby-version
|
214
|
+
- test/apps/checker.ru
|
215
|
+
- test/apps/method_override.ru
|
216
|
+
- test/apps/overwrite_check.ru
|
217
|
+
- test/apps/rack_crasher.ru
|
218
|
+
- test/apps/sha1.ru
|
219
|
+
- test/apps/simple.ru
|
220
|
+
- test/apps/url_scheme.ru
|
214
221
|
- test/config/app.rb
|
215
222
|
- test/config/app.ru
|
216
223
|
- test/config/config.ru
|
@@ -236,9 +243,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
236
243
|
version: '0'
|
237
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
245
|
requirements:
|
239
|
-
- - '
|
246
|
+
- - '>'
|
240
247
|
- !ruby/object:Gem::Version
|
241
|
-
version:
|
248
|
+
version: 1.3.1
|
242
249
|
requirements: []
|
243
250
|
rubyforge_project:
|
244
251
|
rubygems_version: 2.1.9
|
data/jars/hazelcast-2.6.3.jar
DELETED
Binary file
|
data/jars/vertx-core-2.1M3.jar
DELETED
Binary file
|
Binary file
|
Binary file
|