warbler 1.3.8 → 1.4.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +3 -0
  3. data/Gemfile +1 -1
  4. data/History.txt +14 -0
  5. data/README.rdoc +13 -0
  6. data/ext/WarMain.java +34 -17
  7. data/ext/WarblerJar.java +3 -2
  8. data/integration/gem-initializer/pom.xml +39 -0
  9. data/integration/pom.xml +134 -0
  10. data/integration/rails4_test/pom.xml +57 -0
  11. data/integration/rails4_test/src/main/ruby/Gemfile +44 -0
  12. data/integration/rails4_test/src/main/ruby/README.rdoc +28 -0
  13. data/integration/rails4_test/src/main/ruby/Rakefile +6 -0
  14. data/integration/rails4_test/src/main/ruby/app/assets/javascripts/application.js +16 -0
  15. data/integration/rails4_test/src/main/ruby/app/assets/javascripts/posts.js.coffee +3 -0
  16. data/integration/rails4_test/src/main/ruby/app/assets/stylesheets/application.css +13 -0
  17. data/integration/rails4_test/src/main/ruby/app/assets/stylesheets/posts.css.scss +3 -0
  18. data/integration/rails4_test/src/main/ruby/app/assets/stylesheets/scaffolds.css.scss +69 -0
  19. data/integration/rails4_test/src/main/ruby/app/controllers/application_controller.rb +5 -0
  20. data/integration/rails4_test/src/main/ruby/app/controllers/concerns/.keep +0 -0
  21. data/integration/rails4_test/src/main/ruby/app/controllers/posts_controller.rb +74 -0
  22. data/integration/rails4_test/src/main/ruby/app/helpers/application_helper.rb +2 -0
  23. data/integration/rails4_test/src/main/ruby/app/helpers/posts_helper.rb +2 -0
  24. data/integration/rails4_test/src/main/ruby/app/mailers/.keep +0 -0
  25. data/integration/rails4_test/src/main/ruby/app/models/.keep +0 -0
  26. data/integration/rails4_test/src/main/ruby/app/models/concerns/.keep +0 -0
  27. data/integration/rails4_test/src/main/ruby/app/models/post.rb +2 -0
  28. data/integration/rails4_test/src/main/ruby/app/views/layouts/application.html.erb +14 -0
  29. data/integration/rails4_test/src/main/ruby/app/views/posts/_form.html.erb +29 -0
  30. data/integration/rails4_test/src/main/ruby/app/views/posts/edit.html.erb +6 -0
  31. data/integration/rails4_test/src/main/ruby/app/views/posts/index.html.erb +31 -0
  32. data/integration/rails4_test/src/main/ruby/app/views/posts/index.json.jbuilder +4 -0
  33. data/integration/rails4_test/src/main/ruby/app/views/posts/new.html.erb +5 -0
  34. data/integration/rails4_test/src/main/ruby/app/views/posts/show.html.erb +19 -0
  35. data/integration/rails4_test/src/main/ruby/app/views/posts/show.json.jbuilder +1 -0
  36. data/integration/rails4_test/src/main/ruby/config.ru +4 -0
  37. data/integration/rails4_test/src/main/ruby/config/application.rb +23 -0
  38. data/integration/rails4_test/src/main/ruby/config/boot.rb +4 -0
  39. data/integration/rails4_test/src/main/ruby/config/database.yml +20 -0
  40. data/integration/rails4_test/src/main/ruby/config/environment.rb +5 -0
  41. data/integration/rails4_test/src/main/ruby/config/environments/development.rb +29 -0
  42. data/integration/rails4_test/src/main/ruby/config/environments/production.rb +80 -0
  43. data/integration/rails4_test/src/main/ruby/config/environments/test.rb +36 -0
  44. data/integration/rails4_test/src/main/ruby/config/initializers/backtrace_silencers.rb +7 -0
  45. data/integration/rails4_test/src/main/ruby/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/integration/rails4_test/src/main/ruby/config/initializers/inflections.rb +16 -0
  47. data/integration/rails4_test/src/main/ruby/config/initializers/mime_types.rb +5 -0
  48. data/integration/rails4_test/src/main/ruby/config/initializers/secret_token.rb +12 -0
  49. data/integration/rails4_test/src/main/ruby/config/initializers/session_store.rb +3 -0
  50. data/integration/rails4_test/src/main/ruby/config/initializers/wrap_parameters.rb +14 -0
  51. data/integration/rails4_test/src/main/ruby/config/locales/en.yml +23 -0
  52. data/integration/rails4_test/src/main/ruby/config/routes.rb +51 -0
  53. data/integration/rails4_test/src/main/ruby/config/warble.rb +4 -0
  54. data/integration/rails4_test/src/main/ruby/db/development.sqlite3 +0 -0
  55. data/integration/rails4_test/src/main/ruby/db/migrate/20130502003552_create_posts.rb +11 -0
  56. data/integration/rails4_test/src/main/ruby/db/production.sqlite3 +0 -0
  57. data/integration/rails4_test/src/main/ruby/db/schema.rb +24 -0
  58. data/integration/rails4_test/src/main/ruby/db/seeds.rb +7 -0
  59. data/integration/rails4_test/src/main/ruby/lib/assets/.keep +0 -0
  60. data/integration/rails4_test/src/main/ruby/lib/tasks/.keep +0 -0
  61. data/integration/rails4_test/src/main/ruby/public/404.html +58 -0
  62. data/integration/rails4_test/src/main/ruby/public/422.html +58 -0
  63. data/integration/rails4_test/src/main/ruby/public/500.html +57 -0
  64. data/integration/rails4_test/src/main/ruby/public/favicon.ico +0 -0
  65. data/integration/rails4_test/src/main/ruby/public/robots.txt +5 -0
  66. data/integration/rails4_test/src/main/ruby/test/controllers/.keep +0 -0
  67. data/integration/rails4_test/src/main/ruby/test/controllers/posts_controller_test.rb +49 -0
  68. data/integration/rails4_test/src/main/ruby/test/fixtures/.keep +0 -0
  69. data/integration/rails4_test/src/main/ruby/test/fixtures/posts.yml +11 -0
  70. data/integration/rails4_test/src/main/ruby/test/helpers/.keep +0 -0
  71. data/integration/rails4_test/src/main/ruby/test/helpers/posts_helper_test.rb +4 -0
  72. data/integration/rails4_test/src/main/ruby/test/integration/.keep +0 -0
  73. data/integration/rails4_test/src/main/ruby/test/mailers/.keep +0 -0
  74. data/integration/rails4_test/src/main/ruby/test/models/.keep +0 -0
  75. data/integration/rails4_test/src/main/ruby/test/models/post_test.rb +7 -0
  76. data/integration/rails4_test/src/main/ruby/test/test_helper.rb +15 -0
  77. data/integration/rails4_test/src/main/ruby/vendor/assets/javascripts/.keep +0 -0
  78. data/integration/rails4_test/src/main/ruby/vendor/assets/stylesheets/.keep +0 -0
  79. data/integration/rails4_test/src/test/java/org/jruby/warbler/Rails4AppTestIT.java +37 -0
  80. data/integration/runnable_test/pom.xml +105 -0
  81. data/integration/runnable_test/src/main/ruby/Rakefile +4 -0
  82. data/integration/runnable_test/src/main/ruby/config.ru +1 -0
  83. data/integration/runnable_test/src/main/ruby/config/warble.rb +9 -0
  84. data/integration/runnable_test/src/test/java/org/jruby/warbler/RunnableWarTestIT.java +22 -0
  85. data/integration/simple_rack_test/pom.xml +56 -0
  86. data/integration/simple_rack_test/src/main/ruby/config.ru +1 -0
  87. data/integration/simple_rack_test/src/main/ruby/config/warble.rb +4 -0
  88. data/integration/simple_rack_test/src/test/java/org/jruby/warbler/AppTestIT.java +36 -0
  89. data/lib/warbler.rb +2 -1
  90. data/lib/warbler/application.rb +5 -1
  91. data/lib/warbler/config.rb +15 -2
  92. data/lib/warbler/executable_helper.rb +25 -0
  93. data/lib/warbler/gems.rb +39 -0
  94. data/lib/warbler/jar.rb +11 -25
  95. data/lib/warbler/scripts/rails.rb +11 -0
  96. data/lib/warbler/templates/war.erb +10 -2
  97. data/lib/warbler/traits.rb +5 -2
  98. data/lib/warbler/traits/gemspec.rb +13 -4
  99. data/lib/warbler/traits/nogemspec.rb +2 -1
  100. data/lib/warbler/traits/rails.rb +25 -7
  101. data/lib/warbler/version.rb +1 -1
  102. data/lib/warbler_jar.jar +0 -0
  103. data/spec/sample_jar/bin/another_jar +5 -0
  104. data/spec/spec_helper.rb +2 -2
  105. data/spec/warbler/bundler_spec.rb +18 -33
  106. data/spec/warbler/config_spec.rb +2 -2
  107. data/spec/warbler/jar_spec.rb +176 -40
  108. data/warble.rb +9 -2
  109. data/warbler.gemspec +2 -2
  110. metadata +175 -9
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,49 @@
1
+ require 'test_helper'
2
+
3
+ class PostsControllerTest < ActionController::TestCase
4
+ setup do
5
+ @post = posts(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:posts)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create post" do
20
+ assert_difference('Post.count') do
21
+ post :create, post: { content: @post.content, name: @post.name, title: @post.title }
22
+ end
23
+
24
+ assert_redirected_to post_path(assigns(:post))
25
+ end
26
+
27
+ test "should show post" do
28
+ get :show, id: @post
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, id: @post
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update post" do
38
+ patch :update, id: @post, post: { content: @post.content, name: @post.name, title: @post.title }
39
+ assert_redirected_to post_path(assigns(:post))
40
+ end
41
+
42
+ test "should destroy post" do
43
+ assert_difference('Post.count', -1) do
44
+ delete :destroy, id: @post
45
+ end
46
+
47
+ assert_redirected_to posts_path
48
+ end
49
+ end
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ name: MyString
5
+ title: MyString
6
+ content: MyText
7
+
8
+ two:
9
+ name: MyString
10
+ title: MyString
11
+ content: MyText
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class PostsHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class PostTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,15 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ ActiveRecord::Migration.check_pending!
7
+
8
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
9
+ #
10
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
11
+ # -- they do not yet inherit this setting
12
+ fixtures :all
13
+
14
+ # Add more helper methods to be used by all tests here...
15
+ end
@@ -0,0 +1,37 @@
1
+ package org.jruby.warbler;
2
+
3
+ import java.net.*;
4
+ import java.io.*;
5
+ import org.junit.Assert;
6
+ import org.junit.Test;
7
+ import org.hamcrest.Matcher;
8
+ import org.hamcrest.Matchers;
9
+
10
+ /**
11
+ * Unit test for simple App.
12
+ */
13
+ public class Rails4AppTestIT
14
+ {
15
+ private static String appName = "rails4_test";
16
+
17
+ /**
18
+ * Hit the web app and test the response
19
+ */
20
+ @Test
21
+ public void testApp() throws Exception
22
+ {
23
+ URL route = new URL("http://localhost:8080/" + appName + "/posts");
24
+ URLConnection routeConn = route.openConnection();
25
+ BufferedReader in = new BufferedReader( new InputStreamReader( routeConn.getInputStream()));
26
+
27
+ String inputLine;
28
+ String content = "";
29
+
30
+ while ((inputLine = in.readLine()) != null)
31
+ content += inputLine;
32
+ in.close();
33
+
34
+ Assert.assertThat(content, Matchers.containsString("Rails4App"));
35
+ Assert.assertThat(content, Matchers.containsString("Listing posts"));
36
+ }
37
+ }
@@ -0,0 +1,105 @@
1
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+ <modelVersion>4.0.0</modelVersion>
4
+
5
+ <parent>
6
+ <groupId>org.jruby.warbler</groupId>
7
+ <artifactId>integration-tests</artifactId>
8
+ <version>1.0-SNAPSHOT</version>
9
+ </parent>
10
+
11
+ <artifactId>runnable_test</artifactId>
12
+ <packaging>jar</packaging>
13
+
14
+ <name>runnable_test</name>
15
+ <url>http://maven.apache.org</url>
16
+
17
+ <properties>
18
+ <test-file>test-file.tmp</test-file>
19
+ </properties>
20
+
21
+ <dependencies>
22
+ <dependency>
23
+ <groupId>${project.groupId}</groupId>
24
+ <artifactId>gem-initializer</artifactId>
25
+ <version>${project.version}</version>
26
+ <type>pom</type>
27
+ </dependency>
28
+ </dependencies>
29
+
30
+ <build>
31
+ <plugins>
32
+ <plugin>
33
+ <artifactId>maven-clean-plugin</artifactId>
34
+ <version>2.5</version>
35
+ <executions>
36
+ <execution>
37
+ <id>auto-clean</id>
38
+ <phase>pre-integration-test</phase>
39
+ <goals>
40
+ <goal>clean</goal>
41
+ </goals>
42
+ <configuration>
43
+ <excludeDefaultDirectories>true</excludeDefaultDirectories>
44
+ <filesets>
45
+ <fileset>
46
+ <directory>target</directory>
47
+ <includes>
48
+ <include>${test-file}</include>
49
+ </includes>
50
+ </fileset>
51
+ </filesets>
52
+ </configuration>
53
+ </execution>
54
+ </executions>
55
+ </plugin>
56
+ <plugin>
57
+ <groupId>org.jruby.plugins</groupId>
58
+ <artifactId>jruby-rake-plugin</artifactId>
59
+ <executions>
60
+ <execution>
61
+ <id>create-war</id>
62
+ <phase>pre-integration-test</phase>
63
+ <goals><goal>jruby</goal></goals>
64
+ <configuration>
65
+ <args>-Csrc/main/ruby -S warble</args>
66
+ </configuration>
67
+ </execution>
68
+ </executions>
69
+ </plugin>
70
+ <plugin>
71
+ <groupId>org.codehaus.mojo</groupId>
72
+ <artifactId>exec-maven-plugin</artifactId>
73
+ <executions>
74
+ <execution>
75
+ <id>test-rake-task</id>
76
+ <phase>pre-integration-test</phase>
77
+ <goals>
78
+ <goal>exec</goal>
79
+ </goals>
80
+ </execution>
81
+ </executions>
82
+ <configuration>
83
+ <executable>java</executable>
84
+ <workingDirectory>${project.basedir}/target</workingDirectory>
85
+ <arguments>
86
+ <argument>-jar</argument>
87
+ <argument>test.war</argument>
88
+ <argument>-S</argument>
89
+ <argument>rake</argument>
90
+ <argument>create_test_file[${project.basedir}/target/${test-file}]</argument>
91
+ </arguments>
92
+ </configuration>
93
+ </plugin>
94
+ <plugin>
95
+ <groupId>org.apache.maven.plugins</groupId>
96
+ <artifactId>maven-failsafe-plugin</artifactId>
97
+ <configuration>
98
+ <systemPropertyVariables>
99
+ <testFilename>${project.basedir}/target/${test-file}</testFilename>
100
+ </systemPropertyVariables>
101
+ </configuration>
102
+ </plugin>
103
+ </plugins>
104
+ </build>
105
+ </project>
@@ -0,0 +1,4 @@
1
+ task :create_test_file, :test_filename do |t, args|
2
+ puts "Creating test file '#{args.test_filename}'"
3
+ File.open(args.test_filename, 'w') {|f| f.write("hello world") }
4
+ end
@@ -0,0 +1 @@
1
+ run lambda {|env| [200, {'Content-Type' => 'text/html'}, 'Hello, World']}
@@ -0,0 +1,9 @@
1
+ Warbler::Config.new do |config|
2
+ config.features = %w(executable)
3
+ config.autodeploy_dir = "../../../target"
4
+ config.jar_name = "test"
5
+
6
+ config.includes = FileList["Rakefile"]
7
+
8
+ config.gems << "rake"
9
+ end
@@ -0,0 +1,22 @@
1
+ package org.jruby.warbler;
2
+
3
+ import java.net.*;
4
+ import java.io.*;
5
+ import org.junit.Assert;
6
+ import org.junit.Test;
7
+ import org.hamcrest.Matcher;
8
+ import org.hamcrest.Matchers;
9
+
10
+ /**
11
+ * Unit test for simple runnable war.
12
+ */
13
+ public class RunnableWarTestIT
14
+ {
15
+ @Test
16
+ public void testApp() throws Exception
17
+ {
18
+ String testFilename = System.getProperty("testFilename");
19
+ File f = new File(testFilename);
20
+ Assert.assertTrue(testFilename + "should exist", f.exists());
21
+ }
22
+ }
@@ -0,0 +1,56 @@
1
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
+ <modelVersion>4.0.0</modelVersion>
4
+
5
+ <parent>
6
+ <groupId>org.jruby.warbler</groupId>
7
+ <artifactId>integration-tests</artifactId>
8
+ <version>1.0-SNAPSHOT</version>
9
+ </parent>
10
+
11
+ <artifactId>simple_rack_test</artifactId>
12
+ <packaging>jar</packaging>
13
+
14
+ <name>simple_rack_test</name>
15
+ <url>http://maven.apache.org</url>
16
+
17
+ <dependencies>
18
+ <dependency>
19
+ <groupId>${groupId}</groupId>
20
+ <artifactId>gem-initializer</artifactId>
21
+ <version>${version}</version>
22
+ <type>pom</type>
23
+ </dependency>
24
+ </dependencies>
25
+
26
+ <build>
27
+ <plugins>
28
+ <plugin>
29
+ <groupId>org.jruby.plugins</groupId>
30
+ <artifactId>jruby-rake-plugin</artifactId>
31
+ <executions>
32
+ <execution>
33
+ <id>create-war</id>
34
+ <phase>pre-integration-test</phase>
35
+ <goals><goal>jruby</goal></goals>
36
+ <configuration>
37
+ <args>-Csrc/main/ruby -S warble</args>
38
+ </configuration>
39
+ </execution>
40
+ </executions>
41
+ </plugin>
42
+ <plugin>
43
+ <groupId>org.mortbay.jetty</groupId>
44
+ <artifactId>maven-jetty-plugin</artifactId>
45
+ <executions>
46
+ <execution>
47
+ <id>start-jetty</id>
48
+ </execution>
49
+ <execution>
50
+ <id>stop-jetty</id>
51
+ </execution>
52
+ </executions>
53
+ </plugin>
54
+ </plugins>
55
+ </build>
56
+ </project>
@@ -0,0 +1 @@
1
+ run lambda {|env| [200, {'Content-Type' => 'text/html'}, 'Hello, World']}
@@ -0,0 +1,4 @@
1
+ Warbler::Config.new do |config|
2
+ config.autodeploy_dir = "../../../target"
3
+ config.jar_name = "test"
4
+ end
@@ -0,0 +1,36 @@
1
+ package org.jruby.warbler;
2
+
3
+ import java.net.*;
4
+ import java.io.*;
5
+ import org.junit.Assert;
6
+ import org.junit.Test;
7
+ import org.hamcrest.Matcher;
8
+ import org.hamcrest.Matchers;
9
+
10
+ /**
11
+ * Unit test for simple App.
12
+ */
13
+ public class AppTestIT
14
+ {
15
+ private static String appName = "simple_rack_test";
16
+
17
+ /**
18
+ * Hit the web app and test the response
19
+ */
20
+ @Test
21
+ public void testApp() throws Exception
22
+ {
23
+ URL url = new URL("http://localhost:8080/" + appName);
24
+ URLConnection conn = url.openConnection();
25
+ BufferedReader in = new BufferedReader( new InputStreamReader( conn.getInputStream()));
26
+
27
+ String inputLine;
28
+ String content = "";
29
+
30
+ while ((inputLine = in.readLine()) != null)
31
+ content = inputLine;
32
+ in.close();
33
+
34
+ Assert.assertEquals("Hello, World", content);
35
+ }
36
+ }