├── .editorconfig
├── .gitignore
├── .travis.maven.settings.xml
├── LICENSE.txt
├── README.md
├── pom.xml
├── vertx-lang-ruby-gen
├── pom.xml
└── src
│ ├── main
│ ├── assembly
│ │ └── docs.xml
│ ├── docoverride
│ │ └── docoverride
│ │ │ ├── buffer
│ │ │ └── package-info.java
│ │ │ ├── dependencies
│ │ │ └── package-info.java
│ │ │ ├── dns
│ │ │ └── package-info.java
│ │ │ ├── eventbus
│ │ │ ├── headers
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ │ ├── json
│ │ │ └── package-info.java
│ │ │ └── verticles
│ │ │ ├── configuration
│ │ │ └── package-info.java
│ │ │ └── package-info.java
│ ├── java
│ │ └── io
│ │ │ └── vertx
│ │ │ └── lang
│ │ │ └── ruby
│ │ │ ├── AdaptingMap.java
│ │ │ ├── ContainerHolder.java
│ │ │ ├── Deployment.java
│ │ │ ├── Helper.java
│ │ │ ├── JRubyDocGenerator.java
│ │ │ ├── JRubyVerticle.java
│ │ │ └── JRubyVerticleFactory.java
│ └── resources
│ │ ├── META-INF
│ │ └── services
│ │ │ ├── io.vertx.core.spi.VerticleFactory
│ │ │ └── io.vertx.docgen.DocGenerator
│ │ ├── codegen.json
│ │ ├── vertx-rb
│ │ └── template
│ │ │ └── rb.templ
│ │ └── vertx
│ │ └── util
│ │ ├── utils.rb
│ │ └── vertx_require.rb
│ └── test
│ ├── java
│ └── io
│ │ └── vertx
│ │ └── test
│ │ ├── lang
│ │ └── ruby
│ │ │ ├── ApiTCKTest.java
│ │ │ ├── CollectionTCKTest.java
│ │ │ ├── ConstantTCKTest.java
│ │ │ ├── DataObjectTCKTest.java
│ │ │ ├── FunctionParamTCKTest.java
│ │ │ ├── GenericsTCKTest.java
│ │ │ ├── LangTest.java
│ │ │ └── RubyTestBase.java
│ │ └── support
│ │ ├── ClassWithMixin.java
│ │ ├── ClassWithMixinImpl.java
│ │ ├── Helper.java
│ │ ├── LinearOverloadedMethods.java
│ │ ├── LinearOverloadedMethodsImpl.java
│ │ ├── MethodWithClosure.java
│ │ ├── MethodWithClosureImpl.java
│ │ ├── Mixin.java
│ │ ├── MultiOverloadedMethods.java
│ │ ├── MultiOverloadedMethodsImpl.java
│ │ ├── OverloadWithOptions.java
│ │ ├── OverloadWithOptionsImpl.java
│ │ ├── ReferencedType.java
│ │ ├── ReferencedTypeImpl.java
│ │ ├── ReferencingType.java
│ │ ├── ReferencingTypeImpl.java
│ │ ├── ReservedWordParams.java
│ │ ├── ReservedWordParamsImpl.java
│ │ ├── SuperMixin.java
│ │ └── package-info.java
│ └── resources
│ ├── api_tck_test.rb
│ ├── assert.rb
│ ├── collection_tck_test.rb
│ ├── constant_tck_test.rb
│ ├── data_object_tck_test.rb
│ ├── examples
│ ├── bus_echo.rb
│ └── simple_http_server.rb
│ ├── function_param_tck_test.rb
│ ├── generics_tck_test.rb
│ └── lang_test.rb
└── vertx-lang-ruby
├── pom.xml
└── src
├── main
├── asciidoc
│ ├── dataobjects.adoc
│ └── enums.adoc
├── assembly
│ └── docs.xml
└── docoverride
│ └── vertx-core
│ └── ruby
│ └── override
│ ├── buffer_from_bytes.adoc
│ ├── configuring-eventbus.adoc
│ ├── configuring-native.adoc
│ ├── dependencies.adoc
│ ├── dns.adoc
│ ├── eventbus.adoc
│ ├── eventbus_headers.adoc
│ ├── hostname-resolution.adoc
│ ├── in-the-beginning.adoc
│ ├── json.adoc
│ ├── verticle-configuration.adoc
│ └── verticles.adoc
└── test
├── asciidoc
├── cheatsheet
│ ├── NetServerOptions.adoc
│ └── TestDataObject.adoc
├── dataobjects.adoc
└── enums.adoc
├── external-test-resources
└── foo
│ └── bar.rb
├── gems
└── test_gem
│ ├── lib
│ └── test_gem.rb
│ ├── test_gem-0.0.0.gem
│ └── test_gem.gemspec
├── java
└── io
│ └── vertx
│ └── test
│ ├── it
│ ├── ServiceDiscoveryTest.java
│ ├── VertxUnitTest.java
│ └── service
│ │ ├── HelloService.java
│ │ ├── HelloServiceImpl.java
│ │ ├── HelloServiceVertxEBProxy.java
│ │ ├── HelloServiceVertxProxyHandler.java
│ │ └── package-info.java
│ └── lang
│ └── ruby
│ ├── DeployTest.java
│ ├── EventBusTest.java
│ ├── IntegrationTest.java
│ ├── IsolationTest.java
│ ├── LoadingTest.java
│ ├── RubyTestBase.java
│ └── VerticleTest.java
└── resources
├── async_lifecycle_verticle.rb
├── event_bus_test.rb
├── examples
├── bus_echo.rb
└── simple_http_server.rb
├── integration_test.rb
├── it
├── discovery
│ └── HelloServiceConsumer.rb
└── unit
│ ├── assertions.rb
│ └── failing.rb
├── lifecycle_verticle.rb
├── require
└── simple_verticle.rb
├── simple_verticle.rb
├── verticle_incrementing_cvar.rb
├── verticle_incrementing_global.rb
├── verticle_incrementing_ivar.rb
├── verticle_incrementing_local.rb
├── verticle_raising_error_in_async_start.rb
├── verticle_raising_error_in_async_stop.rb
├── verticle_raising_error_in_run.rb
├── verticle_raising_error_in_start.rb
├── verticle_raising_error_in_stop.rb
├── verticle_requiring_gem.rb
├── verticle_sharing_global_1.rb
└── verticle_sharing_global_2.rb
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | trim_trailing_whitespace = true
8 | end_of_line = lf
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .gradle
3 | .idea
4 | .classpath
5 | .project
6 | .settings
7 | .yardoc
8 | .yardopts
9 | bin
10 | build
11 | target
12 | out
13 | *.iml
14 | *.ipr
15 | *.iws
16 | test-output
17 | test-results
18 | test-tmp
19 | *.class
20 |
--------------------------------------------------------------------------------
/.travis.maven.settings.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 | false
7 |
8 |
9 |
10 | vertx-snapshots-repository
11 | ${env.VERTX_NEXUS_USERNAME}
12 | ${env.VERTX_NEXUS_PASSWORD}
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | vertx-lang-jruby
2 | ========
3 |
4 | [](https://github.com/vert-x3/vertx-lang-ruby/actions?query=workflow%3ACI)
5 |
6 | ## todo list
7 |
8 | - ruby specific documentation
9 | - consider using @option Yard tag
10 | - consider @yieldparam usage
11 | - snake_case for method params
12 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | io.vertx
7 |
8 | vertx-parent
9 |
10 | 19
11 |
12 |
13 |
14 | 4.0.0
15 |
16 | pom
17 |
18 | vertx-lang-ruby-parent
19 |
20 | 3.9.17-SNAPSHOT
21 |
22 |
23 |
24 | ${java.home}/../lib/tools.jar
25 |
26 | 3.9.17-SNAPSHOT
27 |
28 |
29 |
30 |
31 |
32 | vertx-lang-ruby-gen
33 |
34 | vertx-lang-ruby
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | io.vertx
45 |
46 | vertx-dependencies
47 |
48 | ${stack.version}
49 |
50 | pom
51 |
52 | import
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | io.vertx
6 | vertx-lang-ruby-parent
7 | 3.9.17-SNAPSHOT
8 | ../pom.xml
9 |
10 |
11 | 4.0.0
12 |
13 | vertx-lang-ruby-gen
14 | 3.9.17-SNAPSHOT
15 |
16 |
17 |
18 |
19 | io.vertx
20 | vertx-codegen
21 | provided
22 |
23 |
24 | io.vertx
25 | vertx-codegen
26 | sources
27 | provided
28 |
29 |
30 | io.vertx
31 | vertx-docgen
32 | true
33 |
34 |
35 | io.vertx
36 | vertx-codetrans
37 | true
38 |
39 |
40 | io.vertx
41 | vertx-core
42 |
43 |
44 | io.vertx
45 | vertx-core
46 | sources
47 | provided
48 |
49 |
50 | org.jruby
51 | jruby-complete
52 | 9.1.13.0
53 |
54 |
55 | org.mvel
56 | mvel2
57 | 2.3.1.Final
58 | provided
59 |
60 |
61 |
62 |
63 | io.vertx
64 | vertx-codegen
65 | tck-sources
66 | test
67 |
68 |
69 | io.vertx
70 | vertx-codegen
71 | tck
72 | test
73 |
74 |
75 | junit
76 | junit
77 | 4.13.1
78 | test
79 |
80 |
81 | io.vertx
82 | vertx-core
83 | test-jar
84 | test
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | org.apache.maven.plugins
95 | maven-surefire-plugin
96 |
97 |
98 | %4$s: %3$s - %5$s %6$s%n
99 | ${project.build.directory}/gems
100 |
101 |
102 | ${project.build.testSourceDirectory}
103 | ${project.basedir}/src/main/resources
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | maven-dependency-plugin
112 |
113 |
114 |
115 | unpack-codegen
116 | generate-test-sources
117 |
118 | unpack-dependencies
119 |
120 |
121 | io.vertx
122 | vertx-codegen
123 | jar
124 | tck-sources
125 | ${project.build.directory}/sources/codegen
126 |
127 |
128 |
129 |
130 |
131 | org.bsc.maven
132 | maven-processor-plugin
133 | 3.1.0
134 |
135 |
136 | %4$s: %3$s - %5$s %6$s%n
137 | true
138 |
139 |
140 |
141 |
142 |
143 | generate-codegen
144 |
145 | process
146 |
147 | generate-test-sources
148 |
149 |
150 | io.vertx.codegen.CodeGenProcessor
151 |
152 |
153 | ${project.basedir}/src/test
154 | Ruby
155 |
156 | ${project.build.directory}/sources/codegen
157 |
158 | io/vertx/test/lang/ruby/**
159 |
160 |
161 | ${project.basedir}/src/test/java
162 |
163 |
164 |
165 |
166 |
167 |
168 | junit
169 | junit
170 | 4.13.1
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/assembly/docs.xml:
--------------------------------------------------------------------------------
1 |
4 | docs
5 |
6 | zip
7 |
8 | false
9 |
10 |
11 | ${asciidoc.dir}
12 | /
13 |
14 |
15 | ${project.build.directory}/docs/vertx-core/ruby/yardoc
16 | /ruby/yardoc
17 |
18 |
19 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/buffer/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | */
19 | @Document(fileName = "override/buffer_from_bytes.adoc")
20 | package docoverride.buffer;
21 |
22 | import io.vertx.docgen.Document;
23 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/dependencies/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | * If you are using Maven or Gradle, add the following dependency to the _dependencies_ section of your
19 | * project descriptor to access the Vert.x Core API and enable the Ruby support:
20 | *
21 | * * Maven (in your `pom.xml`):
22 | *
23 | * [source,xml,subs="+attributes"]
24 | * ----
25 | *
26 | * io.vertx
27 | * vertx-core
28 | * ${maven.version}
29 | *
30 | *
31 | * ${maven.groupId}
32 | * ${maven.artifactId}
33 | * ${maven.version}
34 | *
35 | * ----
36 | *
37 | * * Gradle (in your `build.gradle` file):
38 | *
39 | * [source,groovy,subs="+attributes"]
40 | * ----
41 | * compile "io.vertx:vertx-core:${maven.version}"
42 | * compile "${maven.groupId}:${maven.artifactId}:${maven.version}"
43 | * ----
44 | */
45 | @Document(fileName = "override/dependencies.adoc")
46 | package docoverride.dependencies;
47 |
48 | import io.vertx.docgen.Document;
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/dns/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | */
19 | @Document(fileName = "override/dns.adoc")
20 | package docoverride.dns;
21 |
22 | import io.vertx.docgen.Document;
23 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/eventbus/headers/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011-2013 The original author or authors
3 | * ------------------------------------------------------
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 | /**
17 | * ==== Setting headers on messages
18 | *
19 | * Messages sent over the event bus can also contain headers. This can be specified by providing a `headers` object
20 | * inside the {@link io.vertx.core.eventbus.DeliveryOptions} object when sending or publishing:
21 | *
22 | * [source,ruby]
23 | * ----
24 | * options = {
25 | * headers: {
26 | * 'some-header' => 'some-value'
27 | * }
28 | * }
29 | * vertx.event_bus().send("news.uk.sport", "Yay! Someone kicked a ball", options)
30 | * ----
31 | *
32 | * On the other side, the consumer can retrieve the message header as follows:
33 | *
34 | * [source, ruby]
35 | * ----
36 | * eb = $vertx.event_bus()
37 | * eb.consumer("news.uk.sport") { |message|
38 | * puts message.headers().get("some-header")
39 | * }
40 | * ----
41 | *
42 | */
43 | @Document(fileName = "override/eventbus_headers.adoc")
44 | package docoverride.eventbus.headers;
45 |
46 | import io.vertx.docgen.Document;
47 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/eventbus/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | * ==== Message Codecs
19 | *
20 | * Message codecs are available exclusively with the Java api.
21 | */
22 | @Document(fileName = "override/eventbus.adoc")
23 | package docoverride.eventbus;
24 |
25 | import io.vertx.docgen.Document;
26 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/json/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | * == JSON
19 | *
20 | * Unlike some other languages, Ruby does not have first class support for http://json.org/[JSON] so we use
21 | * Array and Hash to make handling JSON in your Vert.x applications a bit easier.
22 | *
23 | * === JSON objects
24 | *
25 | * Ruby hashes represents JSON objects.
26 | *
27 | * A JSON object is basically just a map which has string keys and values can be of one of the JSON supported types
28 | * (string, number, boolean).
29 | *
30 | * JSON objects also support nil values.
31 | *
32 | * ==== Creating JSON objects
33 | *
34 | * Empty JSON objects can be created with the default constructor.
35 | *
36 | * You can create a JSON object from a string JSON representation as follows:
37 | *
38 | * [source,ruby]
39 | * ----
40 | * require 'json'
41 | * object = JSON.parse('"foo":"bar"')
42 | * ----
43 | *
44 | * ==== Encoding the JSON object to a String
45 | *
46 | * You use `JSON.generate` to encode the object to a String form.
47 | *
48 | * [source,ruby]
49 | * ----
50 | * require 'json'
51 | * json = JSON.generate(object)
52 | * ----
53 | *
54 | * === JSON arrays
55 | *
56 | * Ruby arrays represents JSON arrays.
57 | *
58 | * A JSON array is a sequence of values (string, number, boolean).
59 | *
60 | * JSON arrays can also contain null values.
61 | *
62 | * ==== Creating JSON arrays
63 | *
64 | * Empty JSON arrays can be created with the default constructor.
65 | *
66 | * You can create a JSON array from a string JSON representation as follows:
67 | *
68 | * [source,ruby]
69 | * ----
70 | * require 'json'
71 | * object = JSON.parse('[1,2,3]')
72 | * ----
73 | *
74 | * ==== Encoding the JSON array to a String
75 | *
76 | * You use `JSON.generate` to encode the array to a String form.
77 | *
78 | * [source,ruby]
79 | * ----
80 | * require 'json'
81 | * json = JSON.generate(array)
82 | * ----
83 | */
84 | @Document(fileName = "override/json.adoc")
85 | package docoverride.json;
86 |
87 | import io.vertx.docgen.Document;
88 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/verticles/configuration/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | * === Passing configuration to a verticle
19 | *
20 | * Configuration in the form of JSON can be passed to a verticle at deployment time:
21 | *
22 | * [source,ruby]
23 | * ----
24 | * config = {
25 | * 'name' => "tim",
26 | * 'directory' => "/blah"
27 | * }
28 | * options = {
29 | * 'config' => config
30 | * }
31 | * vertx.deploy_verticle("MyOrderProcessorVerticle.rb", options)
32 | * ----
33 | *
34 | * This configuration is then available via the {@link io.vertx.core.Context} object. The configuration is returned as a
35 | * _Hash_ object so you can retrieve data as follows:
36 | *
37 | * [source,ruby]
38 | * ----
39 | * puts $vertx.get_or_create_context().config()["name"]
40 | * ----
41 | *
42 | * === Accessing environment variables in a Verticle
43 | *
44 | * Environment variables and system properties are accessible from a verticle using the Java API:
45 | *
46 | * [source,javascript]
47 | * ----
48 | * puts Java::JavaLang::System.getProperty("foo")
49 | * puts Java::JavaLang::System.getenv("HOME")
50 | * ----
51 | *
52 | */
53 | @Document(fileName = "override/verticle-configuration.adoc")
54 | package docoverride.configuration;
55 |
56 | import io.vertx.docgen.Document;
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/docoverride/docoverride/verticles/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | * === Writing Verticles
19 | *
20 | * Ruby verticles are implemented as simple scripts.
21 | *
22 | * Ruby verticles will have the following globals pre-set as a convenience:
23 | *
24 | * * +$vertx+ - A reference to the Vertx object
25 | *
26 | * [source,ruby]
27 | * ----
28 | * # Start a timer
29 | * $vertx.set_periodic(1000) { puts 'Timer has fired' }
30 | * ----
31 | *
32 | * When the verticle is deployed the body of the script will be executed.
33 | *
34 | * Any `vertx_start` function function defined during the body execution will be executed after the
35 | * execution. The `vertx_start` is executed as any other function and does not expect any argument.
36 | *
37 | * Likewise any `vertx_stop` function function defined during the body execution will be executed after the
38 | * execution. The `vertx_stop` is executed as any other function and does not expect any argument.
39 | *
40 | * [source,ruby]
41 | * ----
42 | * def vertx_stop future
43 | * # Cleanup here
44 | * end
45 | * ----
46 | *
47 | * To load a verticle as a Ruby gem, this Ruby gem must deployed
48 | *
49 | * === Asynchronous Verticle start and stop
50 | *
51 | * Sometimes you want to do something in your verticle start-up which takes some time and you don't want the verticle to
52 | * be considered deployed until that happens. For example you might want to deploy other verticles in the start method.
53 | *
54 | * You can't block waiting for the other verticles to deploy in your start method as that would break the Golden Rule.
55 | *
56 | * So how can you do this?
57 | *
58 | * The way to do it is to implement the *asynchronous* start method. This version of the method takes a Future as a parameter.
59 | * When the method returns the verticle will *not* be considered deployed yet. Some time later, after you've done everything
60 | * you need to do (e.g. start other verticles), you can call complete on the Future (or fail) to signal that you're done.
61 | *
62 | * Here's an example:
63 | *
64 | * [source,ruby]
65 | * ----
66 | * def vertx_start_async start_future
67 | * # Now deploy some other verticle:
68 | *
69 | * $vertx.deploy_verticle("other_verticle.rb") do |res|
70 | * if res.succeeded?
71 | * start_future.complete
72 | * else
73 | * start_future.fail
74 | * end
75 | * end
76 | * end
77 | * ----
78 | *
79 | * Similarly, there is an asynchronous version of the stop method too. You use this if you want to do some verticle
80 | * cleanup that takes some time.
81 | *
82 | * [source,ruby]
83 | * ----
84 | * def vertx_stop_async stop_future
85 | * obj.do_something_that_takes_time do |res|
86 | * if res.succeeded?
87 | * stop_future.complete
88 | * else
89 | * stop_future.fail
90 | * end
91 | * end
92 | * end
93 | * ----
94 | *
95 | * INFO: You don't need to manually undeploy child verticles started by a verticle, in the verticle's stop method. Vert.x
96 | * will automatically undeploy any child verticles when the parent is undeployed.
97 | *
98 | * === Verticle deployment options
99 | *
100 | * When deploying a Ruby, verticle it is possible to set a specific _GEM_PATH_ variable for this particular
101 | * verticle:
102 | *
103 | * [source,java]
104 | * ----
105 | * DeploymentOptions options = new DeploymentOptions().
106 | * setConfig(new JsonObject().put("GEM_PATH", "/path/to/gems"));
107 | * vertx.deployVerticle("my_verticle.rb", options);
108 | * ----
109 | *
110 | * This can be done also possible in Ruby:
111 | *
112 | * [source,ruby]
113 | * ----
114 | * options = { :config => { :GEM_PATH => '/path/to/gems' } }
115 | * $vertx.deploy_verticle('my_verticle.rb', options)
116 | * ----
117 | *
118 | * This option can also be specified for the CLI:
119 | *
120 | * ----
121 | * vertx run my_verticle_rb -conf {\"GEM_PATH\":\"/path/to/gems\"}
122 | * ----
123 | *
124 | */
125 | @Document(fileName = "override/verticles.adoc")
126 | package docoverride.verticles;
127 |
128 | import io.vertx.docgen.Document;
129 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/java/io/vertx/lang/ruby/AdaptingMap.java:
--------------------------------------------------------------------------------
1 | package io.vertx.lang.ruby;
2 |
3 | import java.util.AbstractMap;
4 | import java.util.AbstractSet;
5 | import java.util.Iterator;
6 | import java.util.Map;
7 | import java.util.Set;
8 | import java.util.function.Function;
9 |
10 | /**
11 | * A map that wrap/unwrap the entries of a delegate map. The function are provided by Ruby under the form
12 | * of Proc that takes care of the conversion.
13 | *
14 | * @author Julien Viet
15 | */
16 | class AdaptingMap extends AbstractMap {
17 |
18 | final Map delegate;
19 | final Function toRuby;
20 | final Function toJava;
21 |
22 | AdaptingMap(Map delegate, Function toRuby, Function toJava) {
23 | this.delegate = delegate;
24 | this.toRuby = toRuby;
25 | this.toJava = toJava;
26 | }
27 |
28 | @Override
29 | public Object put(Object key, Object value) {
30 | return delegate.put(key, toJava.apply(value));
31 | }
32 |
33 | @Override
34 | public Object get(Object key) {
35 | return toRuby.apply(delegate.get(key));
36 | }
37 |
38 | @Override
39 | public Object remove(Object key) {
40 | return toRuby.apply(delegate.remove(key));
41 | }
42 |
43 | @Override
44 | public void clear() {
45 | delegate.clear();
46 | }
47 |
48 | final Set entrySet = new AbstractSet() {
49 | @Override
50 | public Iterator iterator() {
51 | Iterator extends Entry> it = AdaptingMap.this.delegate.entrySet().iterator();
52 | return new Iterator() {
53 | @Override
54 | public boolean hasNext() {
55 | return it.hasNext();
56 | }
57 | @Override
58 | public Entry next() {
59 | Entry entry = it.next();
60 | return new Entry() {
61 | @Override
62 | public Object getKey() {
63 | return entry.getKey();
64 | }
65 | @Override
66 | public Object getValue() {
67 | return toRuby.apply(entry.getValue());
68 | }
69 | @Override
70 | public Object setValue(Object value) {
71 | return toRuby.apply(entry.setValue(toJava.apply(value)));
72 | }
73 | };
74 | }
75 | };
76 | }
77 |
78 | @Override
79 | public int size() {
80 | return delegate.size();
81 | }
82 | };
83 |
84 | @Override
85 | public Set entrySet() {
86 | return entrySet;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/java/io/vertx/lang/ruby/ContainerHolder.java:
--------------------------------------------------------------------------------
1 | package io.vertx.lang.ruby;
2 |
3 | import io.vertx.core.Future;
4 | import io.vertx.core.Vertx;
5 | import org.jruby.CompatVersion;
6 | import org.jruby.RubyClass;
7 | import org.jruby.RubyInstanceConfig;
8 | import org.jruby.RubyModule;
9 | import org.jruby.embed.LocalContextScope;
10 | import org.jruby.embed.ScriptingContainer;
11 |
12 | import java.io.BufferedReader;
13 | import java.io.File;
14 | import java.io.IOException;
15 | import java.io.InputStreamReader;
16 | import java.io.OutputStream;
17 | import java.io.PrintStream;
18 | import java.io.StringReader;
19 | import java.net.URL;
20 | import java.net.URLClassLoader;
21 | import java.util.Arrays;
22 | import java.util.HashMap;
23 | import java.util.Map;
24 | import java.util.concurrent.atomic.AtomicInteger;
25 | import java.util.stream.Collectors;
26 |
27 | /**
28 | * Wrap a JRuby scripting container to allow the deployment of several verticle instances for
29 | * the same scripting container to remove the per container bottleneck that would prevent to
30 | * scale up the number of verticle instances for the same script.
31 | *
32 | * @author Julien Viet
33 | */
34 | class ContainerHolder {
35 |
36 | private static final AtomicInteger seq = new AtomicInteger();
37 | private final JRubyVerticleFactory factory;
38 | private final String verticleName;
39 | private ScriptingContainer container;
40 | private int refs;
41 |
42 | ContainerHolder(JRubyVerticleFactory factory, String verticleName) {
43 | this.factory = factory;
44 | this.verticleName = verticleName;
45 | }
46 |
47 | String getVerticleName() {
48 | return verticleName;
49 | }
50 |
51 | /**
52 | * Create a deployment of the verticle.
53 | *
54 | * @param gemPath the optional gem path
55 | * @param vertx the current vertx object
56 | * @param classLoader the classloader
57 | * @param startFuture the start callback
58 | * @return the deployment or null if that couldn't be done
59 | */
60 | synchronized Deployment create(String gemPath, Vertx vertx, ClassLoader classLoader, Future> startFuture) {
61 | if (refs++ == 0) {
62 | ScriptingContainer cont = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
63 | RubyInstanceConfig config = cont.getProvider().getRubyInstanceConfig();
64 | if (gemPath != null) {
65 | Map newEnv = new HashMap(config.getEnvironment());
66 | newEnv.put("GEM_PATH", gemPath);
67 | config.setEnvironment(newEnv);
68 | }
69 |
70 | // In jruby 9, it it not able to load classes or rb files from a classloader.
71 | // We need to explode the classloader content in the `LOAD_PATH` building "jar" URIs pointing to the root of the
72 | // jar.
73 | if (classLoader instanceof URLClassLoader) {
74 | config.setLoadPaths(Arrays.stream(((URLClassLoader) classLoader).getURLs())
75 | .map(u -> {
76 | String form = u.toExternalForm();
77 | if (form.endsWith(".jar")) {
78 | return "jar:" + form + "!";
79 | } else {
80 | return form;
81 | }
82 | }).collect(Collectors.toList()));
83 | }
84 | // In addition we need to the set delegating classloader.
85 | cont.setClassLoader(classLoader);
86 |
87 | cont.setError(new PrintStream(new OutputStream() {
88 | @Override
89 | public void write(int b) throws IOException {
90 | // > /dev/null
91 | }
92 | }));
93 | cont.put("$_vertx", vertx);
94 | cont.runScriptlet("require 'vertx/vertx'");
95 | cont.runScriptlet("require 'vertx/future'");
96 | cont.runScriptlet("$vertx=Vertx::Vertx.new($_vertx)");
97 | cont.remove("$_vertx");
98 | container = cont;
99 | }
100 |
101 | try {
102 | // Read the whole file into a string and wrap it in a module to provide a degree of isolation
103 | // - note there is one JRuby runtime per
104 | // verticle _type_ or module _type_ so any verticles/module instances of the same type
105 | // will share a runtime and need to be wrapped so ivars, cvars etc don't collide
106 | // We also require vertx_require which overrides the load and require methods to make them
107 | // synchronized
108 | String modName = "Mod___VertxInternalVert__" + seq.incrementAndGet();
109 | StringBuilder script = new StringBuilder("require 'vertx/util/vertx_require'\n").append("module ").append(modName).append(";extend self;");
110 |
111 | URL url = classLoader.getResource(verticleName);
112 | if (url == null) {
113 | File f = new File(verticleName);
114 | if (!f.isAbsolute()) {
115 | f = new File(System.getProperty("user.dir"), verticleName);
116 | }
117 | if (f.exists() && f.isFile()) {
118 | url = f.toURI().toURL();
119 | }
120 | }
121 | if (url == null) {
122 | throw new IllegalStateException("Cannot find verticle script: " + verticleName + " on classpath");
123 | }
124 | int idx = verticleName.lastIndexOf('/');
125 |
126 | BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
127 | for (String line = br.readLine(); line != null; line = br.readLine()) {
128 | script.append(line).append("\n");
129 | }
130 | br.close();
131 | script.append(";end;").append(modName);
132 |
133 | RubyModule wrappingModule = (RubyModule) container.runScriptlet(new StringReader(script.toString()), verticleName.substring(idx + 1));
134 |
135 | if (wrappingModule.getMethods().containsKey("vertx_start")) {
136 | container.callMethod(wrappingModule, "vertx_start");
137 | startFuture.complete();
138 | } else if (wrappingModule.getMethods().containsKey("vertx_start_async")) {
139 | invokeAsync(wrappingModule, "vertx_start_async", startFuture);
140 | } else {
141 | startFuture.complete();
142 | }
143 | return new Deployment(modName, wrappingModule);
144 | } catch (Throwable t) {
145 | startFuture.fail(t);
146 | return null;
147 | }
148 | }
149 |
150 | /**
151 | * Undeploy the deployment, this possibly destroy this container holder when the number of
152 | * deployment reaches zero.
153 | *
154 | * @param deployment the deployment to destroy
155 | * @param stopFuture the stop callback
156 | */
157 | synchronized void undeploy(Deployment deployment, Future> stopFuture) {
158 | Future fut = Future.future();
159 | fut.setHandler(ar -> {
160 |
161 | // Remove the module const
162 | container.runScriptlet("Object.send(:remove_const, :" + deployment.modName + ")");
163 |
164 | // Destroy for verticle
165 | if (--refs == 0) {
166 | factory.removeVerticle(this);
167 | container.terminate();
168 | }
169 |
170 | //
171 | if (ar.succeeded()) {
172 | stopFuture.complete();
173 | } else {
174 | stopFuture.fail(ar.cause());
175 | }
176 | });
177 | if (deployment.wrappingModule.getMethods().containsKey("vertx_stop")) {
178 | container.callMethod(deployment.wrappingModule, "vertx_stop");
179 | fut.complete();
180 | } else if (deployment.wrappingModule.getMethods().containsKey("vertx_stop_async")) {
181 | invokeAsync(deployment.wrappingModule, "vertx_stop_async", fut);
182 | } else {
183 | fut.complete();
184 | }
185 | }
186 |
187 | private void invokeAsync(RubyModule module, String name, Future future) {
188 | org.jruby.RubyClass rubyClass = (RubyClass) container.runScriptlet("return ::Vertx::Future");
189 | Object wrappedFuture = container.callMethod(rubyClass, "new", future);
190 | container.callMethod(module, name, wrappedFuture);
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/java/io/vertx/lang/ruby/Deployment.java:
--------------------------------------------------------------------------------
1 | package io.vertx.lang.ruby;
2 |
3 | import org.jruby.RubyModule;
4 |
5 | /**
6 | * Contains the JRuby objects resulting of the deployment of the verticle in a scripting container.
7 | * Its purpose is to hold these objects for undeployment.
8 | *
9 | * @author Julien Viet
10 | */
11 | class Deployment {
12 |
13 | final String modName;
14 | final RubyModule wrappingModule;
15 |
16 | public Deployment(String modName, RubyModule wrappingModule) {
17 | this.modName = modName;
18 | this.wrappingModule = wrappingModule;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/java/io/vertx/lang/ruby/Helper.java:
--------------------------------------------------------------------------------
1 | package io.vertx.lang.ruby;
2 |
3 | import io.vertx.core.AsyncResult;
4 |
5 | import java.util.Map;
6 | import java.util.concurrent.Callable;
7 | import java.util.function.Function;
8 |
9 | /**
10 | * @author Julien Viet
11 | */
12 | public class Helper {
13 |
14 | public static Map adaptingMap(Map map, Function toRuby, Function toJava) {
15 | if (map == null) {
16 | return null;
17 | }
18 | return new AdaptingMap(map, toRuby, toJava);
19 | }
20 |
21 | public static AsyncResult succeededResult(T object) {
22 | return new AsyncResult() {
23 | @Override
24 | public T result() {
25 | return object;
26 | }
27 | @Override
28 | public Throwable cause() {
29 | return null;
30 | }
31 | @Override
32 | public boolean succeeded() {
33 | return true;
34 | }
35 | @Override
36 | public boolean failed() {
37 | return false;
38 | }
39 | };
40 | }
41 |
42 | public static AsyncResult failedResult(Object err) {
43 | return new AsyncResult() {
44 | @Override
45 | public T result() {
46 | return null;
47 | }
48 | @Override
49 | public Throwable cause() {
50 | return err instanceof Throwable ? (Throwable) err : new Exception(String.valueOf(err));
51 | }
52 | @Override
53 | public boolean succeeded() {
54 | return false;
55 | }
56 | @Override
57 | public boolean failed() {
58 | return true;
59 | }
60 | };
61 | }
62 |
63 | public static Throwable catchAndReturnThrowable(Callable> c) {
64 | try {
65 | c.call();
66 | } catch (Throwable t) {
67 | return t;
68 | }
69 | throw new AssertionError("Should not happen");
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/java/io/vertx/lang/ruby/JRubyDocGenerator.java:
--------------------------------------------------------------------------------
1 | package io.vertx.lang.ruby;
2 |
3 | import io.vertx.codegen.Case;
4 | import io.vertx.codegen.type.ClassKind;
5 | import io.vertx.codegen.type.ApiTypeInfo;
6 | import io.vertx.codegen.type.EnumTypeInfo;
7 | import io.vertx.codegen.type.TypeInfo;
8 | import io.vertx.codegen.type.TypeMirrorFactory;
9 | import io.vertx.codetrans.CodeTranslator;
10 | import io.vertx.codetrans.lang.ruby.RubyLang;
11 | import io.vertx.docgen.Coordinate;
12 | import io.vertx.docgen.DocGenerator;
13 |
14 | import javax.annotation.processing.ProcessingEnvironment;
15 | import javax.lang.model.element.Element;
16 | import javax.lang.model.element.ElementKind;
17 | import javax.lang.model.element.ExecutableElement;
18 | import javax.lang.model.element.Modifier;
19 | import javax.lang.model.element.TypeElement;
20 | import javax.lang.model.element.VariableElement;
21 |
22 | /**
23 | * @author Julien Viet
24 | */
25 | public class JRubyDocGenerator implements DocGenerator {
26 |
27 | private TypeMirrorFactory factory;
28 | private CodeTranslator translator;
29 |
30 | @Override
31 | public void init(ProcessingEnvironment processingEnv) {
32 | factory = new TypeMirrorFactory(processingEnv.getElementUtils(), processingEnv.getTypeUtils());
33 | translator = new CodeTranslator(processingEnv);
34 | }
35 |
36 | @Override
37 | public String getName() {
38 | return "ruby";
39 | }
40 |
41 | @Override
42 | public String renderSource(ExecutableElement elt, String source) {
43 | RubyLang lang = new RubyLang();
44 | try {
45 | return translator.translate(elt, lang);
46 | } catch (Exception e) {
47 | System.out.println("Cannot generate " + elt.getEnclosingElement().getSimpleName() + "#" + elt.getSimpleName() + " : " + e.getMessage());
48 | return "Code not translatable";
49 | }
50 | }
51 |
52 | @Override
53 | public String resolveTypeLink(TypeElement elt, Coordinate coordinate) {
54 | TypeInfo type = null;
55 | try {
56 | type = factory.create(elt.asType());
57 | } catch (Exception e) {
58 | System.out.println("Could not resolve doc likn for type " + elt.getQualifiedName());
59 | return null;
60 | }
61 | if (type.getKind() == ClassKind.ENUM && ((EnumTypeInfo) type).isGen()) {
62 | String baselink;
63 | if (coordinate == null) {
64 | baselink = "../";
65 | } else {
66 | baselink = "../../" + coordinate.getArtifactId() + "/";
67 | }
68 | return baselink + "enums.html#" + elt.getSimpleName().toString();
69 | }
70 | if (type.getKind() == ClassKind.DATA_OBJECT) {
71 | String baselink;
72 | if (coordinate == null) {
73 | baselink = "../";
74 | } else {
75 | baselink = "../../" + coordinate.getArtifactId() + "/";
76 | }
77 | return baselink + "dataobjects.html#" + elt.getSimpleName().toString();
78 | }
79 | if (type.getKind() == ClassKind.API) {
80 | ApiTypeInfo api = (ApiTypeInfo) type.getRaw();
81 | String module = api.getModuleName();
82 | String dir = Case.CAMEL.format(Case.KEBAB.parse(module));
83 |
84 | return "../../yardoc/" + dir + "/" + api.getSimpleName() + ".html";
85 | }
86 | return "unavailable";
87 | }
88 |
89 | @Override
90 | public String resolveMethodLink(ExecutableElement elt, Coordinate coordinate) {
91 | String baselink = resolveTypeLink((TypeElement) elt.getEnclosingElement(), coordinate);
92 | if (baselink != null) {
93 | if (baselink.contains("cheatsheet")) {
94 | baselink = baselink + '#' + java.beans.Introspector.decapitalize(elt.getSimpleName().toString().substring(3));
95 | } else {
96 | String methodName = Case.SNAKE.format(Case.CAMEL.parse(elt.getSimpleName().toString()));
97 | baselink = baselink + '#' + methodName + "-" + (elt.getModifiers().contains(Modifier.STATIC) ? "class_method" : "instance_method");
98 | }
99 | }
100 | return baselink;
101 | }
102 |
103 | @Override
104 | public String resolveConstructorLink(ExecutableElement elt, Coordinate coordinate) {
105 | return "todo";
106 | }
107 |
108 | @Override
109 | public String resolveFieldLink(VariableElement elt, Coordinate coordinate) {
110 | return "todo";
111 | }
112 |
113 | @Override
114 | public String resolveLabel(Element elt, String defaultLabel) {
115 | if (elt.getKind() == ElementKind.METHOD) {
116 | TypeInfo type = factory.create(elt.getEnclosingElement().asType());
117 | if (type.getKind() == ClassKind.DATA_OBJECT) {
118 | String name = elt.getSimpleName().toString();
119 | if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3))) {
120 | name = java.beans.Introspector.decapitalize(name.substring(3));
121 | }
122 | return name;
123 | }
124 | }
125 | return defaultLabel;
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/java/io/vertx/lang/ruby/JRubyVerticle.java:
--------------------------------------------------------------------------------
1 | package io.vertx.lang.ruby;
2 |
3 | import io.vertx.core.Context;
4 | import io.vertx.core.Future;
5 | import io.vertx.core.Verticle;
6 | import io.vertx.core.Vertx;
7 |
8 | /**
9 | * @author Julien Viet
10 | */
11 | public class JRubyVerticle implements Verticle {
12 |
13 | private final JRubyVerticleFactory factory;
14 | private final ContainerHolder holder;
15 | private final ClassLoader classLoader;
16 | private final String verticleName;
17 | private Vertx vertx;
18 | private Context context;
19 | private Deployment instance;
20 |
21 | public JRubyVerticle(JRubyVerticleFactory factory, ContainerHolder holder, ClassLoader classLoader, String verticleName) {
22 | this.factory = factory;
23 | this.holder = holder;
24 | this.classLoader = classLoader;
25 | this.verticleName = verticleName;
26 | }
27 |
28 | @Override
29 | public Vertx getVertx() {
30 | return vertx;
31 | }
32 |
33 | @Override
34 | public void init(Vertx vertx, Context context) {
35 | this.vertx = vertx;
36 | this.context = context;
37 | }
38 |
39 | @Override
40 | public void start(Future startFuture) throws Exception {
41 | String gemPath = context.config().getString("GEM_PATH");
42 | if (gemPath != null && !gemPath.trim().isEmpty()) {
43 | instance = holder.create(gemPath, vertx, classLoader, startFuture);
44 | } else {
45 | instance = holder.create(null, vertx, classLoader, startFuture);
46 | }
47 | }
48 |
49 | @Override
50 | public void stop(Future stopFuture) throws Exception {
51 | if (instance != null) {
52 | holder.undeploy(instance, stopFuture);
53 | } else {
54 | stopFuture.complete();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/java/io/vertx/lang/ruby/JRubyVerticleFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * Red Hat licenses this file to you under the Apache License, version 2.0
5 | * (the "License"); you may not use this file except in compliance with the
6 | * License. You may obtain a copy of the License at:
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package io.vertx.lang.ruby;
18 |
19 | import io.vertx.core.Verticle;
20 | import io.vertx.core.Vertx;
21 | import io.vertx.core.spi.VerticleFactory;
22 |
23 | import java.util.HashMap;
24 | import java.util.Map;
25 |
26 | /**
27 | * @author Tim Fox
28 | */
29 | public class JRubyVerticleFactory implements VerticleFactory {
30 |
31 | final Map holderMap = new HashMap<>();
32 |
33 | private Vertx vertx;
34 |
35 | @Override
36 | public String prefix() {
37 | return "rb";
38 | }
39 |
40 | @Override
41 | public boolean blockingCreate() {
42 | return true;
43 | }
44 |
45 | @Override
46 | public void init(Vertx vertx) {
47 | this.vertx = vertx;
48 | }
49 |
50 | @Override
51 | public Verticle createVerticle(String verticleName, ClassLoader classLoader) throws Exception {
52 | verticleName = VerticleFactory.removePrefix(verticleName);
53 | ContainerHolder holder;
54 | synchronized (holderMap) {
55 | holder = holderMap.get(verticleName);
56 | if (holder == null) {
57 | holderMap.put(verticleName, holder = new ContainerHolder(this, verticleName));
58 | }
59 | }
60 | return new JRubyVerticle(this, holder, classLoader, verticleName);
61 | }
62 |
63 | void removeVerticle(ContainerHolder holder) {
64 | synchronized (holderMap) {
65 | holderMap.remove(holder.getVerticleName());
66 | }
67 | }
68 |
69 | // This method synchronizes the callback into the JRuby code to make sure we don't have concurrent requires
70 | // or loads occurring in the same JRuby container
71 | public static synchronized void requireCallback(Runnable runnable) {
72 | runnable.run();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/resources/META-INF/services/io.vertx.core.spi.VerticleFactory:
--------------------------------------------------------------------------------
1 | io.vertx.lang.ruby.JRubyVerticleFactory
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/resources/META-INF/services/io.vertx.docgen.DocGenerator:
--------------------------------------------------------------------------------
1 | io.vertx.lang.ruby.JRubyDocGenerator
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/resources/codegen.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Ruby",
3 | "generators": [ {
4 | "kind": "class",
5 | "fileName": "'resources/' + type.raw.moduleName + '/' + type.raw.getSimpleName(CASE_SNAKE) + '.rb'",
6 | "templateFileName": "vertx-rb/template/rb.templ"
7 | } ]
8 | }
9 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/resources/vertx/util/utils.rb:
--------------------------------------------------------------------------------
1 | require 'json'
2 | require 'set'
3 | java_import 'io.vertx.core.json.JsonObject'
4 | java_import 'io.vertx.core.json.JsonArray'
5 | module Vertx
6 | module Util
7 | class Utils
8 | def self.raise_runtime_exception(err)
9 | raise err.getMessage
10 | end
11 | def self.from_throwable(err)
12 | begin
13 | raise_runtime_exception(err)
14 | rescue Exception => e;
15 | return e;
16 | end
17 | end
18 | def self.to_throwable(err)
19 | Java::IoVertxLangRuby::Helper.catchAndReturnThrowable(Proc.new { raise err });
20 | end
21 | def self.safe_create(object, clazz, *args)
22 | if nil != object
23 | return clazz.new(object, *args)
24 | end
25 | return nil
26 | end
27 | def self.to_object(object)
28 | if object.is_a? Hash
29 | JsonObject.new(JSON.generate(object))
30 | elsif object.is_a? Array
31 | JsonArray.new(JSON.generate(object))
32 | elsif object.respond_to?(:j_del)
33 | object.j_del
34 | else
35 | # Best effort, we let jruby handle the conversion
36 | object
37 | end
38 | end
39 | def self.to_string(val)
40 | if val != nil && val.class == String
41 | val
42 | else
43 | raise ArgumentError, 'Only String accepted'
44 | end
45 | end
46 | def self.to_long(val)
47 | if val != nil && val.class == Fixnum
48 | Java::JavaLang::Long.new(val)
49 | else
50 | raise ArgumentError, 'Only Fixnum accepted'
51 | end
52 | end
53 | def self.to_integer(val)
54 | if val != nil && val.class == Fixnum
55 | Java::JavaLang::Integer.new(val)
56 | else
57 | raise ArgumentError, 'Only Fixnum accepted'
58 | end
59 | end
60 | def self.to_short(val)
61 | if val != nil && val.class == Fixnum
62 | Java::JavaLang::Short.new(val)
63 | else
64 | raise ArgumentError, 'Only Fixnum accepted'
65 | end
66 | end
67 | def self.to_byte(val)
68 | if val != nil && val.class == Fixnum
69 | Java::JavaLang::Byte.new(val)
70 | else
71 | raise ArgumentError, 'Only Fixnum accepted'
72 | end
73 | end
74 | def self.to_character(val)
75 | if val != nil && val.class == Fixnum
76 | Java::JavaLang::Character.new(val)
77 | else
78 | raise ArgumentError, 'Only Fixnum accepted'
79 | end
80 | end
81 | def self.to_boolean(val)
82 | if val
83 | true
84 | else
85 | false
86 | end
87 | end
88 | def self.to_float(val)
89 | if val != nil && val.class == Float
90 | Java::JavaLang::Float.new(val)
91 | else
92 | raise ArgumentError, 'Only Float accepted'
93 | end
94 | end
95 | def self.to_double(val)
96 | if val != nil && val.class == Float
97 | Java::JavaLang::Double.new(val)
98 | else
99 | raise ArgumentError, 'Only Float accepted'
100 | end
101 | end
102 | def self.to_json_object(val)
103 | if val != nil && val.is_a?(Hash)
104 | JsonObject.new(JSON.generate(val))
105 | else
106 | raise ArgumentError, 'Only Hash accepted'
107 | end
108 | end
109 | def self.to_json_array(val)
110 | if val.is_a? Array
111 | return to_json_object({:key=>val}).getJsonArray('key')
112 | else
113 | raise ArgumentError, 'Only Array accepted'
114 | end
115 | end
116 | def self.from_object(object)
117 | if object.is_a?(JsonObject) || object.is_a?(JsonArray)
118 | JSON.parse(object.encode)
119 | else
120 | # Best effort, we let jruby handle the conversion
121 | object
122 | end
123 | end
124 | def self.to_set(set)
125 | ret = Set.new
126 | set.each { |elt| ret.add elt }
127 | ret
128 | end
129 | def self.to_handler_proc(handler, &converter)
130 | Proc.new { |val|
131 | val = yield val;
132 | handler.handle(val);
133 | }
134 | end
135 | def self.to_async_result_handler_proc(handler, &converter)
136 | Proc.new { |err,val|
137 | if nil != err
138 | handler.handle(Java::IoVertxLangRuby::Helper.failedResult(err));
139 | else
140 | val = yield val;
141 | handler.handle(Java::IoVertxLangRuby::Helper.succeededResult(val));
142 | end
143 | }
144 | end
145 | def self.v_type_of ruby_type
146 | if ruby_type.respond_to? :j_api_type
147 | ruby_type.j_api_type
148 | elsif ruby_type == Fixnum
149 | ::Vertx::Util.fixnum_type
150 | elsif ruby_type == Float
151 | ::Vertx::Util.float_type
152 | elsif ruby_type == String
153 | ::Vertx::Util.string_type
154 | elsif ruby_type == Hash
155 | ::Vertx::Util.hash_type
156 | elsif ruby_type == Array
157 | ::Vertx::Util.array_type
158 | elsif ruby_type == TrueClass || ruby_type == FalseClass
159 | ::Vertx::Util.boolean_type
160 | else
161 | ::Vertx::Util.unknown_type
162 | end
163 | end
164 | def self.j_class_of ruby_type
165 | if ruby_type.respond_to? :j_class
166 | ruby_type.j_class
167 | else
168 | if ruby_type == Hash
169 | Java::IoVertxCoreJson::JsonObject.java_class
170 | elsif ruby_type == Array
171 | Java::IoVertxCoreJson::JsonArray.java_class
172 | elsif ruby_type == Fixnum
173 | Java::JavaLang::Long.java_class
174 | elsif ruby_type == Float
175 | Java::JavaLang::Float.java_class
176 | elsif ruby_type == String
177 | Java::JavaLang::String.java_class
178 | elsif ruby_type == TrueClass || ruby_type == FalseClass
179 | Java::JavaLang::Boolean.java_class
180 | else
181 | nil
182 | end
183 | end
184 | end
185 | end
186 |
187 | @@unknown_type = Object.new
188 | def @@unknown_type.accept?(obj)
189 | true
190 | end
191 | def @@unknown_type.wrap(obj)
192 | Utils.from_object(obj)
193 | end
194 | def @@unknown_type.unwrap(obj)
195 | Utils.to_object(obj)
196 | end
197 | def self.unknown_type
198 | @@unknown_type
199 | end
200 |
201 | @@fixnum_type = Object.new
202 | def @@fixnum_type.accept?(obj)
203 | obj.class == Fixnum
204 | end
205 | def @@fixnum_type.wrap(obj)
206 | Utils.from_object(obj)
207 | end
208 | def @@fixnum_type.unwrap(obj)
209 | Utils.to_object(obj)
210 | end
211 | def self.fixnum_type
212 | @@fixnum_type
213 | end
214 |
215 | @@float_type = Object.new
216 | def @@float_type.accept?(obj)
217 | obj.class == Float
218 | end
219 | def @@float_type.wrap(obj)
220 | Utils.from_object(obj)
221 | end
222 | def @@float_type.unwrap(obj)
223 | Utils.to_object(obj)
224 | end
225 | def self.float_type
226 | @@float_type
227 | end
228 |
229 | @@string_type = Object.new
230 | def @@string_type.accept?(obj)
231 | obj.class == String
232 | end
233 | def @@string_type.wrap(obj)
234 | Utils.from_object(obj)
235 | end
236 | def @@string_type.unwrap(obj)
237 | Utils.to_object(obj)
238 | end
239 | def self.string_type
240 | @@string_type
241 | end
242 |
243 | @@hash_type = Object.new
244 | def @@hash_type.accept?(obj)
245 | obj.class == Hash
246 | end
247 | def @@hash_type.wrap(obj)
248 | Utils.from_object(obj)
249 | end
250 | def @@hash_type.unwrap(obj)
251 | Utils.to_object(obj)
252 | end
253 | def self.hash_type
254 | @@hash_type
255 | end
256 |
257 | @@array_type = Object.new
258 | def @@array_type.accept?(obj)
259 | obj.class == Array
260 | end
261 | def @@array_type.wrap(obj)
262 | Utils.from_object(obj)
263 | end
264 | def @@array_type.unwrap(obj)
265 | Utils.to_object(obj)
266 | end
267 | def self.array_type
268 | @@array_type
269 | end
270 |
271 | @@boolean_type = Object.new
272 | def @@boolean_type.accept?(obj)
273 | obj.class == TrueClass || obj.class == FalseClass
274 | end
275 | def @@boolean_type.wrap(obj)
276 | Utils.from_object(obj)
277 | end
278 | def @@boolean_type.unwrap(obj)
279 | Utils.to_object(obj)
280 | end
281 | def self.boolean_type
282 | @@boolean_type
283 | end
284 |
285 | class DataObjectType
286 | def initialize(clazz)
287 | @clazz = clazz
288 | end
289 | def accept?(obj)
290 | obj.class == Hash
291 | end
292 | def wrap(obj)
293 | JSON.parse(obj.toJson.encode)
294 | end
295 | def unwrap(obj)
296 | @clazz.new(Utils.to_json_object(obj));
297 | end
298 | end
299 | def self.data_object_type(clazz)
300 | DataObjectType.new clazz
301 | end
302 |
303 | class JavaEnumType
304 | def initialize(clazz)
305 | @clazz = clazz
306 | end
307 | def accept?(obj)
308 | obj.class == String
309 | end
310 | def wrap(obj)
311 | obj != nil ? obj.name : nil
312 | end
313 | def unwrap(obj)
314 | obj != nil ? @clazz.valueOf(obj) : nil
315 | end
316 | end
317 | def self.java_enum_type(clazz)
318 | JavaEnumType.new clazz
319 | end
320 |
321 | class HashProxy < Hash
322 | def initialize
323 | super
324 | end
325 | def [](key)
326 | val = super(key)
327 | puts "getting #{key} = #{val}"
328 | val
329 | end
330 | def []=(key,val)
331 | super(key,val)
332 | puts "putting #{key}=#{val}"
333 | end
334 | end
335 | end
336 | end
337 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/main/resources/vertx/util/vertx_require.rb:
--------------------------------------------------------------------------------
1 | # Redefine the require and load methods so we can make them synchronized
2 |
3 | require 'jruby/synchronized'
4 |
5 | module Kernel
6 | # make an alias of the original require
7 | alias_method :original_require, :require
8 | alias_method :original_load, :load
9 |
10 | def require(*args)
11 | Java::IoVertxLangRuby::JRubyVerticleFactory.requireCallback do
12 | #puts "in require callback"
13 | original_require(*args)
14 | end
15 | end
16 |
17 | def load(*args)
18 | Java::IoVertxLangRuby::JRubyVerticleFactory.requireCallback do
19 | #puts "in require callback"
20 | original_load(*args)
21 | end
22 | end
23 |
24 | end
25 |
26 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/ApiTCKTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import io.vertx.codegen.Case;
4 | import org.junit.Rule;
5 | import org.junit.Test;
6 | import org.junit.rules.TestName;
7 |
8 | /**
9 | * @author Julien Viet
10 | */
11 | public class ApiTCKTest extends RubyTestBase {
12 |
13 | @Test
14 | public void testMethodWithBasicParams() {
15 | runTest();
16 | }
17 |
18 | @Test
19 | public void testMethodWithBasicBoxedParams() {
20 | runTest();
21 | }
22 |
23 | @Test
24 | public void testMethodWithHandlerBasicTypes() {
25 | runTest();
26 | }
27 |
28 | @Test
29 | public void testMethodWithHandlerAsyncResultBasicTypes() {
30 | runTest();
31 | }
32 |
33 | @Test
34 | public void testMethodWithHandlerAsyncResultBasicTypesFails() {
35 | runTest();
36 | }
37 |
38 | @Test
39 | public void testMethodWithUserTypes() {
40 | runTest();
41 | }
42 |
43 | @Test
44 | public void testObjectParam() {
45 | runTest();
46 | }
47 |
48 | @Test
49 | public void testDataObjectParam() {
50 | runTest();
51 | }
52 |
53 | @Test
54 | public void testMethodWithHandlerDataObject() {
55 | runTest();
56 | }
57 |
58 | @Test
59 | public void testMethodWithHandlerAsyncResultDataObject() {
60 | runTest();
61 | }
62 |
63 | @Test
64 | public void testMethodWithHandlerAsyncResultDataObjectFails() {
65 | runTest();
66 | }
67 |
68 | @Test
69 | public void testMethodWithHandlerStringReturn() {
70 | runTest();
71 | }
72 |
73 | @Test
74 | public void testMethodWithHandlerVertxGenReturn() {
75 | runTest();
76 | }
77 |
78 | @Test
79 | public void testMethodWithHandlerGenericReturn() {
80 | runTest();
81 | }
82 |
83 | @Test
84 | public void testMethodWithHandlerAsyncResultStringReturn() {
85 | runTest();
86 | }
87 |
88 | @Test
89 | public void testMethodWithHandlerAsyncResultVertxGenReturn() {
90 | runTest();
91 | }
92 |
93 | @Test
94 | public void testMethodWithHandlerAsyncResultGenericReturn() {
95 | runTest();
96 | }
97 |
98 | @Test
99 | public void testMethodWithHandlerUserTypes() {
100 | runTest();
101 | }
102 |
103 | @Test
104 | public void testMethodWithHandlerAsyncResultUserTypes() {
105 | runTest();
106 | }
107 |
108 | @Test
109 | public void testMethodWithConcreteHandlerUserTypeSubtype() {
110 | runTest();
111 | }
112 |
113 | @Test
114 | public void testMethodWithAbstractHandlerUserTypeSubtype() {
115 | runTest();
116 | }
117 |
118 | @Test
119 | public void testMethodWithConcreteHandlerUserTypeSubtypeExtension() {
120 | runTest();
121 | }
122 |
123 | @Test
124 | public void testMethodWithHandlerVoid() {
125 | runTest();
126 | }
127 |
128 | @Test
129 | public void testMethodWithHandlerAsyncResultVoid() {
130 | runTest();
131 | }
132 |
133 | @Test
134 | public void testMethodWithHandlerAsyncResultVoidFails() {
135 | runTest();
136 | }
137 |
138 | @Test
139 | public void testMethodWithHandlerThrowable() {
140 | runTest();
141 | }
142 |
143 | @Test
144 | public void testMethodWithHandlerGenericUserType() {
145 | runTest();
146 | }
147 |
148 | @Test
149 | public void testMethodWithHandlerAsyncResultGenericUserType() {
150 | runTest();
151 | }
152 |
153 | @Test
154 | public void testMethodWithGenericParam() {
155 | runTest();
156 | }
157 |
158 | @Test
159 | public void testMethodWithGenericHandler() {
160 | runTest();
161 | }
162 |
163 | @Test
164 | public void testMethodWithGenericHandlerAsyncResult() {
165 | runTest();
166 | }
167 |
168 | @Test
169 | public void testBasicReturns() {
170 | runTest();
171 | }
172 |
173 | @Test
174 | public void testVertxGenReturn() {
175 | runTest();
176 | }
177 |
178 | @Test
179 | public void testVertxGenNullReturn() {
180 | runTest();
181 | }
182 |
183 | @Test
184 | public void testAbstractVertxGenReturn() {
185 | runTest();
186 | }
187 |
188 | @Test
189 | public void testDataObjectReturn() {
190 | runTest();
191 | }
192 |
193 | @Test
194 | public void testDataObjectNullReturn() {
195 | runTest();
196 | }
197 |
198 | @Test
199 | public void testOverloadedMethods() {
200 | runTest();
201 | }
202 |
203 | @Test
204 | public void testSuperInterfaces() {
205 | runTest();
206 | }
207 |
208 | @Test
209 | public void testMethodWithGenericReturn() {
210 | runTest();
211 | }
212 |
213 | @Test
214 | public void testFluentMethod() {
215 | runTest();
216 | }
217 |
218 | @Test
219 | public void testStaticFactoryMethod() {
220 | runTest();
221 | }
222 |
223 | @Test
224 | public void testMethodWithCachedReturn() {
225 | runTest();
226 | }
227 |
228 | @Test
229 | public void testMethodWithCachedListReturn() {
230 | runTest();
231 | }
232 |
233 | @Test
234 | public void testJsonReturns() {
235 | runTest();
236 | }
237 |
238 | @Test
239 | public void testNullJsonReturns() {
240 | runTest();
241 | }
242 |
243 | @Test
244 | public void testComplexJsonReturns() {
245 | runTest();
246 | }
247 |
248 | @Test
249 | public void testJsonParams() {
250 | runTest();
251 | }
252 |
253 | @Test
254 | public void testNullJsonParams() {
255 | runTest();
256 | }
257 |
258 | @Test
259 | public void testJsonHandlerParams() {
260 | runTest();
261 | }
262 |
263 | @Test
264 | public void testComplexJsonHandlerParams() {
265 | runTest();
266 | }
267 |
268 | @Test
269 | public void testJsonHandlerAsyncResultParams() {
270 | runTest();
271 | }
272 |
273 | @Test
274 | public void testNullJsonHandlerAsyncResultParams() {
275 | runTest();
276 | }
277 |
278 | @Test
279 | public void testThrowableParam() {
280 | runTest();
281 | }
282 |
283 | @Test
284 | public void testSuperMethodOverloadedBySubclass() {
285 | runTest();
286 | }
287 |
288 | @Test
289 | public void testEnumParam() {
290 | runTest();
291 | }
292 |
293 | @Test
294 | public void testEnumReturn() {
295 | runTest();
296 | }
297 |
298 | @Test
299 | public void testComplexJsonHandlerAsyncResultParams() {
300 | runTest();
301 | }
302 |
303 | @Test
304 | public void testThrowableReturn() {
305 | runTest();
306 | }
307 |
308 | @Test
309 | public void testCustomModule() {
310 | runTest();
311 | }
312 |
313 | private void runTest() {
314 | runTest("api_tck_test", testName.getMethodName());
315 | }
316 | }
317 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/CollectionTCKTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class CollectionTCKTest extends RubyTestBase {
9 |
10 | @Test
11 | public void testMethodWithHandlerListAndSet() {
12 | runTest();
13 | }
14 |
15 | @Test
16 | public void testMethodWithHandlerAsyncResultListAndSet() {
17 | runTest();
18 | }
19 |
20 | @Test
21 | public void testMethodWithHandlerListVertxGen() {
22 | runTest();;
23 | }
24 |
25 | @Test
26 | public void testMethodWithHandlerListAbstractVertxGen() {
27 | runTest();;
28 | }
29 |
30 | @Test
31 | public void testMethodWithHandlerAsyncResultListVertxGen() {
32 | runTest();;
33 | }
34 |
35 | @Test
36 | public void testMethodWithHandlerAsyncResultListAbstractVertxGen() {
37 | runTest();
38 | }
39 |
40 | @Test
41 | public void testMethodWithHandlerSetVertxGen() {
42 | runTest();
43 | }
44 |
45 | @Test
46 | public void testMethodWithHandlerSetAbstractVertxGen() {
47 | runTest();
48 | }
49 |
50 | @Test
51 | public void testMethodWithHandlerAsyncResultSetVertxGen() {
52 | runTest();
53 | }
54 |
55 | @Test
56 | public void testMethodWithHandlerAsyncResultSetAbstractVertxGen() {
57 | runTest();
58 | }
59 |
60 | @Test
61 | public void testMethodWithHandlerListJsonObject() {
62 | runTest();
63 | }
64 |
65 | @Test
66 | public void testMethodWithHandlerListComplexJsonObject() {
67 | runTest();
68 | }
69 |
70 | @Test
71 | public void testMethodWithHandlerAsyncResultListJsonObject() {
72 | runTest();
73 | }
74 |
75 | @Test
76 | public void testMethodWithHandlerAsyncResultListComplexJsonObject() {
77 | runTest();
78 | }
79 |
80 | @Test
81 | public void testMethodWithHandlerSetJsonObject() {
82 | runTest();
83 | }
84 |
85 | @Test
86 | public void testMethodWithHandlerSetComplexJsonObject() {
87 | runTest();
88 | }
89 |
90 | @Test
91 | public void testMethodWithHandlerAsyncResultSetJsonObject() {
92 | runTest();
93 | }
94 |
95 | @Test
96 | public void testMethodWithHandlerAsyncResultSetComplexJsonObject() {
97 | runTest();
98 | }
99 |
100 | @Test
101 | public void testMethodWithHandlerListJsonArray() {
102 | runTest();
103 | }
104 |
105 | @Test
106 | public void testMethodWithHandlerAsyncResultListJsonArray() {
107 | runTest();
108 | }
109 |
110 | @Test
111 | public void testMethodWithHandlerAsyncResultListComplexJsonArray() {
112 | runTest();
113 | }
114 |
115 | @Test
116 | public void testMethodWithHandlerSetJsonArray() {
117 | runTest();
118 | }
119 |
120 | @Test
121 | public void testMethodWithHandlerSetComplexJsonArray() {
122 | runTest();
123 | }
124 |
125 | @Test
126 | public void testMethodWithHandlerAsyncResultSetJsonArray() {
127 | runTest();
128 | }
129 |
130 | @Test
131 | public void testMethodWithHandlerListComplexJsonArray() {
132 | runTest();
133 | }
134 |
135 | @Test
136 | public void testMethodWithHandlerListDataObject() {
137 | runTest();
138 | }
139 |
140 | @Test
141 | public void testMethodWithHandlerSetDataObject() {
142 | runTest();
143 | }
144 |
145 | @Test
146 | public void testMethodWithHandlerAsyncResultSetComplexJsonArray() {
147 | runTest();
148 | }
149 |
150 | @Test
151 | public void testMethodWithHandlerAsyncResultListDataObject() {
152 | runTest();
153 | }
154 |
155 | @Test
156 | public void testMethodWithHandlerAsyncResultSetDataObject() {
157 | runTest();
158 | }
159 |
160 | @Test
161 | public void testMethodWithHandlerListEnum() {
162 | runTest();
163 | }
164 |
165 | @Test
166 | public void testMethodWithHandlerSetEnum() {
167 | runTest();
168 | }
169 |
170 | @Test
171 | public void testMethodWithHandlerAsyncResultListEnum() {
172 | runTest();
173 | }
174 |
175 | @Test
176 | public void testMethodWithHandlerAsyncResultSetEnum() {
177 | runTest();
178 | }
179 |
180 | @Test
181 | public void testMapComplexJsonArrayReturn() {
182 | runTest();
183 | }
184 |
185 | @Test
186 | public void testMapReturn() {
187 | runTest();
188 | }
189 |
190 | @Test
191 | public void testMapStringReturn() {
192 | runTest();
193 | }
194 |
195 | @Test
196 | public void testMapJsonObjectReturn() {
197 | runTest();
198 | }
199 |
200 | @Test
201 | public void testMapComplexJsonObjectReturn() {
202 | runTest();
203 | }
204 |
205 | @Test
206 | public void testMapJsonArrayReturn() {
207 | runTest();
208 | }
209 |
210 | @Test
211 | public void testMapIntegerReturn() {
212 | runTest();
213 | }
214 |
215 | @Test
216 | public void testMapShortReturn() {
217 | runTest();
218 | }
219 |
220 | @Test
221 | public void testMapByteReturn() {
222 | runTest();
223 | }
224 |
225 | @Test
226 | public void testMapCharacterReturn() {
227 | runTest();
228 | }
229 |
230 | @Test
231 | public void testMapBooleanReturn() {
232 | runTest();
233 | }
234 |
235 | @Test
236 | public void testMapFloatReturn() {
237 | runTest();
238 | }
239 |
240 | @Test
241 | public void testMapDoubleReturn() {
242 | runTest();
243 | }
244 |
245 | @Test
246 | public void testMapObjectReturn() {
247 | runTest();
248 | }
249 |
250 | @Test
251 | public void testMapLongReturn() {
252 | runTest();
253 | }
254 |
255 | @Test
256 | public void testListStringReturn() {
257 | runTest();
258 | }
259 |
260 | @Test
261 | public void testListLongReturn() {
262 | runTest();
263 | }
264 |
265 | @Test
266 | public void testListJsonObjectReturn() {
267 | runTest();
268 | }
269 |
270 | @Test
271 | public void testListComplexJsonObjectReturn() {
272 | runTest();
273 | }
274 |
275 | @Test
276 | public void testListJsonArrayReturn() {
277 | runTest();
278 | }
279 |
280 | @Test
281 | public void testListComplexJsonArrayReturn() {
282 | runTest();
283 | }
284 |
285 | @Test
286 | public void testListVertxGenReturn() {
287 | runTest();
288 | }
289 |
290 | @Test
291 | public void testListDataObjectReturn() {
292 | runTest();
293 | }
294 |
295 | @Test
296 | public void testListObjectReturn() {
297 | runTest();
298 | }
299 |
300 | @Test
301 | public void testListEnumReturn() {
302 | runTest();
303 | }
304 |
305 | @Test
306 | public void testSetStringReturn() {
307 | runTest();
308 | }
309 |
310 | @Test
311 | public void testSetLongReturn() {
312 | runTest();
313 | }
314 |
315 | @Test
316 | public void testSetJsonObjectReturn() {
317 | runTest();
318 | }
319 |
320 | @Test
321 | public void testSetComplexJsonObjectReturn() {
322 | runTest();
323 | }
324 |
325 | @Test
326 | public void testSetJsonArrayReturn() {
327 | runTest();
328 | }
329 |
330 | @Test
331 | public void testSetComplexJsonArrayReturn() {
332 | runTest();
333 | }
334 |
335 | @Test
336 | public void testSetVertxGenReturn() {
337 | runTest();
338 | }
339 |
340 | @Test
341 | public void testSetDataObjectReturn() {
342 | runTest();
343 | }
344 |
345 | @Test
346 | public void testSetEnumReturn() {
347 | runTest();
348 | }
349 |
350 | @Test
351 | public void testSetObjectReturn() {
352 | runTest();
353 | }
354 |
355 | @Test
356 | public void testMethodWithListParams() {
357 | runTest();
358 | }
359 |
360 | @Test
361 | public void testMethodWithSetParams() {
362 | runTest();
363 | }
364 |
365 | @Test
366 | public void testMethodWithMapParams() {
367 | runTest();
368 | }
369 |
370 | private void runTest() {
371 | runTest("collection_tck_test", testName.getMethodName());
372 | }
373 | }
374 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/ConstantTCKTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class ConstantTCKTest extends RubyTestBase {
9 |
10 | @Test public void testBasic() { runTest(); }
11 | @Test public void testVertxGen() { runTest(); }
12 | @Test public void testDataObject() { runTest(); }
13 | @Test public void testJson() { runTest(); }
14 | @Test public void testEnum() { runTest(); }
15 | @Test public void testThrowable() { runTest(); }
16 | @Test public void testObject() { runTest(); }
17 | @Test public void testNullable() { runTest(); }
18 | @Test public void testList() { runTest(); }
19 | @Test public void testSet() { runTest(); }
20 | @Test public void testMap() { runTest(); }
21 |
22 | private void runTest() {
23 | runTest("constant_tck_test", testName.getMethodName());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/DataObjectTCKTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class DataObjectTCKTest extends RubyTestBase {
9 |
10 | @Test
11 | public void testMethodWithOnlyJsonObjectConstructorDataObject() {
12 | runTest();
13 | }
14 |
15 | private void runTest() {
16 | runTest("data_object_tck_test", testName.getMethodName());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/FunctionParamTCKTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Rule;
4 | import org.junit.Test;
5 | import org.junit.rules.TestName;
6 |
7 | /**
8 | * @author Julien Viet
9 | */
10 | public class FunctionParamTCKTest extends RubyTestBase {
11 |
12 | @Rule
13 | public final TestName testName = new TestName();
14 |
15 | @Test
16 | public void testBasicParam() {
17 | runTest();
18 | }
19 |
20 | @Test
21 | public void testJsonParam() {
22 | runTest();
23 | }
24 |
25 | @Test
26 | public void testUserTypeParam() {
27 | runTest();
28 | }
29 |
30 | @Test
31 | public void testObjectParam() {
32 | runTest();
33 | }
34 |
35 | @Test
36 | public void testDataObjectParam() {
37 | runTest();
38 | }
39 |
40 | @Test
41 | public void testEnumParam() {
42 | runTest();
43 | }
44 |
45 | @Test
46 | public void testListParam() {
47 | runTest();
48 | }
49 |
50 | @Test
51 | public void testSetParam() {
52 | runTest();
53 | }
54 |
55 | @Test
56 | public void testMapParam() {
57 | runTest();
58 | }
59 |
60 | @Test
61 | public void testGenericParam() {
62 | runTest();
63 | }
64 |
65 | @Test
66 | public void testGenericUserTypeParam() {
67 | runTest();
68 | }
69 |
70 | @Test
71 | public void testNullableListParam() {
72 | runTest();
73 | }
74 |
75 | @Test
76 | public void testBasicReturn() {
77 | runTest();
78 | }
79 |
80 | @Test
81 | public void testJsonReturn() {
82 | runTest();
83 | }
84 |
85 | @Test
86 | public void testObjectReturn() {
87 | runTest();
88 | }
89 |
90 | @Test
91 | public void testDataObjectReturn() {
92 | runTest();
93 | }
94 |
95 | @Test
96 | public void testEnumReturn() {
97 | runTest();
98 | }
99 |
100 | @Test
101 | public void testListReturn() {
102 | runTest();
103 | }
104 |
105 | @Test
106 | public void testSetReturn() {
107 | runTest();
108 | }
109 |
110 | @Test
111 | public void testMapReturn() {
112 | runTest();
113 | }
114 |
115 | @Test
116 | public void testGenericReturn() {
117 | runTest();
118 | }
119 |
120 | @Test
121 | public void testGenericUserTypeReturn() {
122 | runTest();
123 | }
124 |
125 | @Test
126 | public void testNullableListReturn() {
127 | runTest();
128 | }
129 |
130 | private void runTest() {
131 | runTest("function_param_tck_test", testName.getMethodName());
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/GenericsTCKTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class GenericsTCKTest extends RubyTestBase {
9 |
10 | @Test
11 | public void testMethodWithBasicParameterizedReturn() throws Exception {
12 | runTest();
13 | }
14 |
15 | @Test
16 | public void testMethodWithHandlerBasicParameterized() throws Exception {
17 | runTest();
18 | }
19 |
20 | @Test
21 | public void testMethodWithHandlerAsyncResultBasicParameterized() throws Exception {
22 | runTest();
23 | }
24 |
25 | @Test
26 | public void testMethodWithFunctionParamBasicParameterized() throws Exception {
27 | runTest();
28 | }
29 |
30 | @Test
31 | public void testMethodWithJsonParameterizedReturn() throws Exception {
32 | runTest();
33 | }
34 |
35 | @Test
36 | public void testMethodWithHandlerJsonParameterized() throws Exception {
37 | runTest();
38 | }
39 |
40 | @Test
41 | public void testMethodWithHandlerAsyncResultJsonParameterized() throws Exception {
42 | runTest();
43 | }
44 |
45 | @Test
46 | public void testMethodWithFunctionParamJsonParameterized() throws Exception {
47 | runTest();
48 | }
49 |
50 | @Test
51 | public void testMethodWithDataObjectParameterizedReturn() throws Exception {
52 | runTest();
53 | }
54 |
55 | @Test
56 | public void testMethodWithHandlerDataObjectParameterized() throws Exception {
57 | runTest();
58 | }
59 |
60 | @Test
61 | public void testMethodWithHandlerAsyncResultDataObjectParameterized() throws Exception {
62 | runTest();
63 | }
64 |
65 | @Test
66 | public void testMethodWithFunctionParamDataObjectParameterized() throws Exception {
67 | runTest();
68 | }
69 |
70 | @Test
71 | public void testMethodWithEnumParameterizedReturn() throws Exception {
72 | runTest();
73 | }
74 |
75 | @Test
76 | public void testMethodWithHandlerEnumParameterized() throws Exception {
77 | runTest();
78 | }
79 |
80 | @Test
81 | public void testMethodWithHandlerAsyncResultEnumParameterized() throws Exception {
82 | runTest();
83 | }
84 |
85 | @Test
86 | public void testMethodWithFunctionParamEnumParameterized() throws Exception {
87 | runTest();
88 | }
89 |
90 | @Test
91 | public void testMethodWithUserTypeParameterizedReturn() throws Exception {
92 | runTest();
93 | }
94 |
95 | @Test
96 | public void testMethodWithHandlerUserTypeParameterized() throws Exception {
97 | runTest();
98 | }
99 |
100 | @Test
101 | public void testMethodWithHandlerAsyncResultUserTypeParameterized() throws Exception {
102 | runTest();
103 | }
104 |
105 | @Test
106 | public void testMethodWithFunctionParamUserTypeParameterized() throws Exception {
107 | runTest();
108 | }
109 |
110 | @Test
111 | public void testMethodWithClassTypeParameterizedReturn() throws Exception {
112 | runTest();
113 | }
114 |
115 | @Test
116 | public void testMethodWithHandlerClassTypeParameterized() throws Exception {
117 | runTest();
118 | }
119 |
120 | @Test
121 | public void testMethodWithHandlerAsyncResultClassTypeParameterized() throws Exception {
122 | runTest();
123 | }
124 |
125 | @Test
126 | public void testMethodWithFunctionParamClassTypeParameterized() throws Exception {
127 | runTest();
128 | }
129 |
130 | @Test
131 | public void testMethodWithClassTypeParam() throws Exception {
132 | runTest();
133 | }
134 |
135 | @Test
136 | public void testMethodWithClassTypeReturn() throws Exception {
137 | runTest();
138 | }
139 |
140 | @Test
141 | public void testMethodWithClassTypeHandler() throws Exception {
142 | runTest();
143 | }
144 |
145 | @Test
146 | public void testMethodWithClassTypeHandlerAsyncResult() throws Exception {
147 | runTest();
148 | }
149 |
150 | @Test
151 | public void testMethodWithClassTypeFunctionParam() throws Exception {
152 | runTest();
153 | }
154 |
155 | @Test
156 | public void testMethodWithClassTypeFunctionReturn() throws Exception {
157 | runTest();
158 | }
159 |
160 | @Test
161 | public void testInterfaceWithStringArg() throws Exception {
162 | runTest();
163 | }
164 |
165 | @Test
166 | public void testInterfaceWithVariableArg() throws Exception {
167 | runTest();
168 | }
169 |
170 | @Test
171 | public void testInterfaceWithApiArg() throws Exception {
172 | runTest();
173 | }
174 |
175 | private void runTest() {
176 | runTest("generics_tck_test", testName.getMethodName());
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/LangTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class LangTest extends RubyTestBase {
9 |
10 | @Test
11 | public void testLinearOverload() {
12 | runTest("test_linear_overload");
13 | }
14 |
15 | @Test
16 | public void testMultiOverload() {
17 | runTest("test_multi_overload");
18 | }
19 |
20 | @Test
21 | public void testMultiOverloadOptionalHandler() {
22 | runTest("test_multi_overload_optional_handler");
23 | }
24 |
25 | @Test
26 | public void testMultiOverloadOptionalHandlers() {
27 | runTest("test_multi_overload_handlers");
28 | }
29 | @Test
30 | public void testMixinInheritance() {
31 | runTest("test_mixin_inheritance");
32 | }
33 |
34 | @Test
35 | public void testInclude() {
36 | runTest("test_include");
37 | }
38 |
39 | @Test
40 | public void testReservedWords() {
41 | runTest("test_reserved_words");
42 | }
43 |
44 | @Test
45 | public void testClosureCallback() {
46 | runTest("test_closure_callback");
47 | }
48 |
49 | @Test
50 | public void testOverloadWithOptions() {
51 | runTest("test_overload_with_options");
52 | }
53 |
54 | private void runTest(String testName) {
55 | runTest("lang_test", testName);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/lang/ruby/RubyTestBase.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Rule;
4 | import org.junit.rules.TestName;
5 |
6 | import javax.script.ScriptEngine;
7 | import javax.script.ScriptEngineManager;
8 | import javax.script.ScriptException;
9 |
10 | /**
11 | * @author Julien Viet
12 | */
13 | public class RubyTestBase {
14 |
15 | @Rule
16 | public final TestName testName = new TestName();
17 |
18 | protected void runTest(String script, String testName) {
19 | try {
20 | ScriptEngineManager manager = new ScriptEngineManager();
21 | ScriptEngine engine = manager.getEngineByName("jruby");
22 | engine.eval("require '" + script + "'");
23 | engine.eval(testName + "()");
24 | } catch (ScriptException e) {
25 | throw new AssertionError(e.getCause());
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ClassWithMixin.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | @VertxGen
9 | public interface ClassWithMixin extends Mixin {
10 | }
11 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ClassWithMixinImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | /**
4 | * @author Julien Viet
5 | */
6 | public class ClassWithMixinImpl implements ClassWithMixin {
7 |
8 | private String called;
9 |
10 | public String getCalled() {
11 | return called;
12 | }
13 |
14 | @Override
15 | public void mixinMethod() {
16 | called = "mixinMethod()";
17 | }
18 |
19 | @Override
20 | public void superMixinMethod() {
21 | called = "superMixinMethod()";
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/Helper.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 | import io.vertx.core.MultiMap;
5 | import io.vertx.core.http.CaseInsensitiveHeaders;
6 |
7 | /**
8 | * @author Julien Viet
9 | */
10 | @VertxGen
11 | public interface Helper {
12 |
13 | static MultiMap getMultiMap() {
14 | CaseInsensitiveHeaders multiMap = new CaseInsensitiveHeaders();
15 | multiMap.add("foo", "foo_value");
16 | multiMap.add("bar", "bar_value");
17 | return multiMap;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/LinearOverloadedMethods.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | @VertxGen
9 | public interface LinearOverloadedMethods {
10 |
11 | void method();
12 | void method(String foo);
13 | void method(String foo, String bar, String juu);
14 | void method(String foo, String bar, String juu, String daa);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/LinearOverloadedMethodsImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | /**
4 | * @author Julien Viet
5 | */
6 | public class LinearOverloadedMethodsImpl implements LinearOverloadedMethods {
7 |
8 | private String called;
9 |
10 | public String getCalled() {
11 | return called;
12 | }
13 |
14 | @Override
15 | public void method() {
16 | this.called = "method()";
17 | }
18 |
19 | @Override
20 | public void method(String foo) {
21 | this.called = "method(" + foo + ")";
22 | }
23 |
24 | @Override
25 | public void method(String foo, String bar, String juu) {
26 | this.called = "method(" + foo + "," + bar + "," + juu + ")";
27 | }
28 |
29 | @Override
30 | public void method(String foo, String bar, String juu, String daa) {
31 | this.called = "method(" + foo + "," + bar + "," + juu + "," + daa + ")";
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/MethodWithClosure.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 | import io.vertx.core.Handler;
5 |
6 | /**
7 | * @author Julien Viet
8 | */
9 | @VertxGen
10 | public interface MethodWithClosure {
11 |
12 | void doSomething();
13 | void doSomething(String s);
14 | void doSomething(String s, Handler callback);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/MethodWithClosureImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.core.Handler;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class MethodWithClosureImpl implements MethodWithClosure {
9 |
10 | private String called;
11 |
12 | public String getCalled() {
13 | return called;
14 | }
15 |
16 | @Override
17 | public void doSomething() {
18 | called = "doSomething()";
19 | }
20 |
21 | @Override
22 | public void doSomething(String s) {
23 | called = "doSomething(" + s + ")";
24 | }
25 |
26 | @Override
27 | public void doSomething(String s, Handler callback) {
28 | called = "doSomething(" + s + ",callback)";
29 | callback.handle("the_callback_payload");
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/Mixin.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | @VertxGen(concrete = false)
9 | public interface Mixin extends SuperMixin {
10 |
11 | void mixinMethod();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/MultiOverloadedMethods.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 | import io.vertx.core.Handler;
5 |
6 | /**
7 | * @author Julien Viet
8 | */
9 | @VertxGen
10 | public interface MultiOverloadedMethods {
11 |
12 | void method();
13 | void method(String foo);
14 | void method(int bar, boolean juu);
15 |
16 | void optionalHandler(String foo, Handler bar);
17 | void optionalHandler(String foo, int bar);
18 | void optionalHandler(String foo, boolean juu);
19 |
20 | void handlers(Handler foo);
21 | void handlers(Handler foo, Handler bar);
22 | void handlers(Handler foo, Handler bar, Handler juu);
23 | }
24 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/MultiOverloadedMethodsImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.core.Handler;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class MultiOverloadedMethodsImpl implements MultiOverloadedMethods {
9 |
10 | private String called;
11 |
12 | public String getCalled() {
13 | return called;
14 | }
15 |
16 | @Override
17 | public void method() {
18 | called = "method()";
19 | }
20 |
21 | @Override
22 | public void method(String foo) {
23 | called = "method(foo=" + foo + ")";
24 | }
25 |
26 | @Override
27 | public void method(int bar, boolean juu) {
28 | called = "method(bar=" + bar + ",juu=" + juu + ")";
29 | }
30 |
31 | @Override
32 | public void optionalHandler(String foo, Handler bar) {
33 | if (bar != null) {
34 | bar.handle("the_event");
35 | }
36 | called = "optionalHandler(foo=" + foo + ",bar)";
37 | }
38 |
39 | @Override
40 | public void optionalHandler(String foo, int bar) {
41 | called = "optionalHandler(foo=" + foo + ",bar=" + bar+ ")";
42 | }
43 |
44 | @Override
45 | public void optionalHandler(String foo, boolean juu) {
46 | called = "optionalHandler(foo=" + foo + ",juu=" + juu+ ")";
47 | }
48 |
49 | @Override
50 | public void handlers(Handler foo) {
51 | if (foo != null) {
52 | foo.handle("foo_event");
53 | }
54 | called = "handlers(foo)";
55 | }
56 |
57 | @Override
58 | public void handlers(Handler foo, Handler bar) {
59 | if (foo != null) {
60 | foo.handle("foo_event");
61 | }
62 | if (bar != null) {
63 | bar.handle("bar_event");
64 | }
65 | called = "handlers(foo,bar)";
66 | }
67 |
68 | @Override
69 | public void handlers(Handler foo, Handler bar, Handler juu) {
70 | if (foo != null) {
71 | foo.handle("foo_event");
72 | }
73 | if (bar != null) {
74 | bar.handle("bar_event");
75 | }
76 | if (juu != null) {
77 | juu.handle("juu_event");
78 | }
79 | called = "handlers(foo,bar,juu)";
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/OverloadWithOptions.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 | import io.vertx.core.DeploymentOptions;
5 |
6 | /**
7 | * @author Julien Viet
8 | */
9 | @VertxGen
10 | public interface OverloadWithOptions {
11 |
12 | void method();
13 |
14 | void method(DeploymentOptions options);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/OverloadWithOptionsImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.core.DeploymentOptions;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class OverloadWithOptionsImpl implements OverloadWithOptions {
9 |
10 | private String called;
11 |
12 | public String getCalled() {
13 | return called;
14 | }
15 |
16 | @Override
17 | public void method() {
18 | called = "method()";
19 | }
20 |
21 | @Override
22 | public void method(DeploymentOptions options) {
23 | called = "method(" + (options != null ? options.toJson() : "null") + ")";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ReferencedType.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | @VertxGen
9 | public interface ReferencedType {
10 |
11 | String someMethod();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ReferencedTypeImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | /**
4 | * @author Julien Viet
5 | */
6 | public class ReferencedTypeImpl implements ReferencedType {
7 |
8 | @Override
9 | public String someMethod() {
10 | return "someMethodValue";
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ReferencingType.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | @VertxGen
9 | public interface ReferencingType {
10 |
11 | ReferencedType getReferenced();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ReferencingTypeImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | /**
4 | * @author Julien Viet
5 | */
6 | public class ReferencingTypeImpl implements ReferencingType {
7 |
8 | @Override
9 | public ReferencedType getReferenced() {
10 | return new ReferencedTypeImpl();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ReservedWordParams.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | @VertxGen
9 | public interface ReservedWordParams {
10 |
11 | // According to : http://www.zenspider.com/Languages/Ruby/QuickRef.html#reserved-words
12 | String method(
13 | String alias, String and, String BEGIN, String begin, String def, String elsif, String END,
14 | String end, String ensure, String in, String module, String next, String nil, String not,
15 | String or, String redo, String rescue, String retry, String self, String then, String undef,
16 | String unless, String until, String when, String yield
17 | );
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/ReservedWordParamsImpl.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | /**
4 | * @author Julien Viet
5 | */
6 | public class ReservedWordParamsImpl implements ReservedWordParams {
7 |
8 | @Override
9 | public String method(String alias, String and, String BEGIN, String begin, String def, String elsif, String END, String end, String ensure, String in, String module, String next, String nil, String not, String or, String redo, String rescue, String retry, String self, String then, String undef, String unless, String until, String when, String yield) {
10 | return alias + and + BEGIN + begin + def + elsif + END + end + ensure + in + module + next + nil + not + or + redo + rescue + retry + self + then + undef + unless + until + when + yield;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/SuperMixin.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.support;
2 |
3 | import io.vertx.codegen.annotations.VertxGen;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | @VertxGen(concrete = false)
9 | public interface SuperMixin {
10 |
11 | void superMixinMethod();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/java/io/vertx/test/support/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Julien Viet
3 | */
4 | @ModuleGen(name = "ruby-codegen", groupPackage = "io.vertx")
5 | package io.vertx.test.support;
6 |
7 | import io.vertx.codegen.annotations.ModuleGen;
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/resources/assert.rb:
--------------------------------------------------------------------------------
1 | module Assert
2 | def self.fail(msg)
3 | raise 'the error'
4 | end
5 | def self.is_nil(actual)
6 | equals actual, nil
7 | end
8 | def self.is_not_nil(actual)
9 | not_equals actual, nil
10 | end
11 | def self.not_equals(actual, expected)
12 | if _equals actual, expected
13 | raise "Was expecting to have #{actual} != #{expected}"
14 | end
15 | end
16 | def self.equals(actual, expected)
17 | unless _equals actual, expected
18 | raise "Was expecting to have #{actual} == #{expected}"
19 | end
20 | end
21 | def self._equals(actual, expected)
22 | if expected.class == Float
23 | if (expected - actual).abs <= 0.001
24 | return true
25 | end
26 | else
27 | if actual == expected
28 | return true
29 | end
30 | end
31 | end
32 | def self.has_class(actual, expected_class)
33 | unless actual != nil && _equals(actual.class, expected_class)
34 | raise "Was expecting to have #{actual} to have type #{expected_class}"
35 | end
36 | end
37 | def self.is(actual, expected_type)
38 | unless actual != nil && actual.is_a?(expected_type)
39 | raise "Was expecting to have #{actual} to be instance of #{expected_type}"
40 | end
41 | end
42 | def self.argument_error(&callback)
43 | failed = false
44 | begin
45 | callback.call;
46 | rescue ArgumentError
47 | failed = true
48 | end
49 | equals(failed, true)
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/resources/constant_tck_test.rb:
--------------------------------------------------------------------------------
1 | require 'java'
2 | require 'assert'
3 | require 'set'
4 | require 'testmodel/constant_tck'
5 | require 'testmodel/super_interface1'
6 | require 'testmodel/super_interface2'
7 | require 'testmodel/test_interface'
8 | require 'testmodel/data_object_tck'
9 | require 'testmodel/refed_interface1'
10 | require 'testmodel/refed_interface2'
11 | require 'testmodel/generic_refed_interface'
12 | require 'testmodel/factory'
13 | require 'acme/my_interface'
14 |
15 | def testBasic
16 | ret = Testmodel::ConstantTCK.BYTE
17 | Assert.equals(ret.class, Fixnum)
18 | Assert.equals(ret, 123)
19 | ret = Testmodel::ConstantTCK.BOXED_BYTE
20 | Assert.equals(ret.class, Fixnum)
21 | Assert.equals(ret, 123)
22 | ret = Testmodel::ConstantTCK.SHORT
23 | Assert.equals(ret.class, Fixnum)
24 | Assert.equals(ret, 12345)
25 | ret = Testmodel::ConstantTCK.BOXED_SHORT
26 | Assert.equals(ret.class, Fixnum)
27 | Assert.equals(ret, 12345)
28 | ret = Testmodel::ConstantTCK.BOXED_INT
29 | Assert.equals(ret.class, Fixnum)
30 | Assert.equals(ret, 12345464)
31 | ret = Testmodel::ConstantTCK.INT
32 | Assert.equals(ret.class, Fixnum)
33 | Assert.equals(ret, 12345464)
34 | ret = Testmodel::ConstantTCK.LONG
35 | Assert.equals(ret.class, Fixnum)
36 | Assert.equals(ret, 65675123)
37 | ret = Testmodel::ConstantTCK.BOXED_LONG
38 | Assert.equals(ret.class, Fixnum)
39 | Assert.equals(ret, 65675123)
40 | ret = Testmodel::ConstantTCK.FLOAT
41 | Assert.equals(ret.class, Float)
42 | Assert.equals(ret, 1.23)
43 | ret = Testmodel::ConstantTCK.BOXED_FLOAT
44 | Assert.equals(ret.class, Float)
45 | Assert.equals(ret, 1.23)
46 | ret = Testmodel::ConstantTCK.DOUBLE
47 | Assert.equals(ret.class, Float)
48 | Assert.equals(ret, 3.34535)
49 | ret = Testmodel::ConstantTCK.BOXED_DOUBLE
50 | Assert.equals(ret.class, Float)
51 | Assert.equals(ret, 3.34535)
52 | ret = Testmodel::ConstantTCK.BOOLEAN
53 | Assert.equals(ret.class, TrueClass)
54 | Assert.equals(ret, true)
55 | ret = Testmodel::ConstantTCK.BOXED_BOOLEAN
56 | Assert.equals(ret.class, TrueClass)
57 | Assert.equals(ret, true)
58 | ret = Testmodel::ConstantTCK.CHAR
59 | Assert.equals(ret.class, Fixnum)
60 | Assert.equals(ret, 89)
61 | ret = Testmodel::ConstantTCK.BOXED_CHAR
62 | Assert.equals(ret.class, Fixnum)
63 | Assert.equals(ret, 89)
64 | ret = Testmodel::ConstantTCK.STRING
65 | Assert.equals(ret.class, String)
66 | Assert.equals(ret, 'orangutan')
67 | end
68 |
69 | def testVertxGen
70 | ret = Testmodel::ConstantTCK.VERTX_GEN
71 | Assert.equals(ret.class, Testmodel::RefedInterface1)
72 | Assert.equals(ret.get_string, 'chaffinch')
73 | end
74 |
75 | def testDataObject
76 | ret = Testmodel::ConstantTCK.DATA_OBJECT
77 | Assert.equals(ret, {'foo' => 'foo', 'bar' => 123, 'wibble' => 0.0})
78 | end
79 |
80 | def testJson
81 | ret = Testmodel::ConstantTCK.JSON_OBJECT
82 | Assert.equals(ret, {'cheese'=>'stilton'})
83 | ret = Testmodel::ConstantTCK.JSON_ARRAY
84 | Assert.equals(ret, %w(socks shoes))
85 | end
86 |
87 | def testEnum
88 | ret = Testmodel::ConstantTCK.ENUM
89 | Assert.equals(:JULIEN, ret)
90 | end
91 |
92 | def testThrowable
93 | ret = Testmodel::ConstantTCK.THROWABLE
94 | Assert.equals(true, ret.is_a?(Exception))
95 | Assert.equals('test', ret.message)
96 | end
97 |
98 | def testObject
99 | ret = Testmodel::ConstantTCK.OBJECT
100 | Assert.equals(ret.class, Fixnum)
101 | Assert.equals(ret, 4)
102 | end
103 |
104 | def testNullable
105 | ret = Testmodel::ConstantTCK.NULLABLE_NON_NULL
106 | Assert.equals(ret.class, Testmodel::RefedInterface1)
107 | Assert.equals(ret.get_string, 'chaffinch')
108 | ret = Testmodel::ConstantTCK.NULLABLE_NULL
109 | Assert.equals(ret, nil)
110 | end
111 |
112 |
113 | def checkArray(array, clazz)
114 | Assert.equals(array.class, Array)
115 | Assert.equals(array.size, 1)
116 | elt = array[0]
117 | Assert.equals(elt.class, clazz)
118 | elt
119 | end
120 |
121 | def testList
122 | Assert.equals(checkArray(Testmodel::ConstantTCK.BYTE_LIST, Fixnum), 123)
123 | Assert.equals(checkArray(Testmodel::ConstantTCK.SHORT_LIST, Fixnum), 12345)
124 | Assert.equals(checkArray(Testmodel::ConstantTCK.INT_LIST, Fixnum), 12345464)
125 | Assert.equals(checkArray(Testmodel::ConstantTCK.LONG_LIST, Fixnum), 65675123)
126 | Assert.equals(checkArray(Testmodel::ConstantTCK.FLOAT_LIST, Float), 1.23)
127 | Assert.equals(checkArray(Testmodel::ConstantTCK.DOUBLE_LIST, Float), 3.34535)
128 | Assert.equals(checkArray(Testmodel::ConstantTCK.BOOLEAN_LIST, TrueClass), true)
129 | Assert.equals(checkArray(Testmodel::ConstantTCK.CHAR_LIST, Fixnum), 89)
130 | Assert.equals(checkArray(Testmodel::ConstantTCK.STRING_LIST, String), 'orangutan')
131 | Assert.equals(checkArray(Testmodel::ConstantTCK.VERTX_GEN_LIST, Testmodel::RefedInterface1).get_string, 'chaffinch')
132 | Assert.equals(checkArray(Testmodel::ConstantTCK.JSON_OBJECT_LIST, Hash), {'cheese'=>'stilton'})
133 | Assert.equals(checkArray(Testmodel::ConstantTCK.JSON_ARRAY_LIST, Array), %w(socks shoes))
134 | Assert.equals(checkArray(Testmodel::ConstantTCK.DATA_OBJECT_LIST, Hash), {'foo' => 'foo', 'bar' => 123, 'wibble' => 0.0})
135 | Assert.equals(checkArray(Testmodel::ConstantTCK.ENUM_LIST, Symbol), :JULIEN)
136 | end
137 |
138 | def checkSet(set, clazz)
139 | Assert.equals(set.class, Set)
140 | Assert.equals(set.size, 1)
141 | elt = set.to_a[0]
142 | Assert.equals(elt.class, clazz)
143 | elt
144 | end
145 |
146 | def testSet
147 | Assert.equals(checkSet(Testmodel::ConstantTCK.BYTE_SET, Fixnum), 123)
148 | Assert.equals(checkSet(Testmodel::ConstantTCK.SHORT_SET, Fixnum), 12345)
149 | Assert.equals(checkSet(Testmodel::ConstantTCK.INT_SET, Fixnum), 12345464)
150 | Assert.equals(checkSet(Testmodel::ConstantTCK.LONG_SET, Fixnum), 65675123)
151 | Assert.equals(checkSet(Testmodel::ConstantTCK.FLOAT_SET, Float), 1.23)
152 | Assert.equals(checkSet(Testmodel::ConstantTCK.DOUBLE_SET, Float), 3.34535)
153 | Assert.equals(checkSet(Testmodel::ConstantTCK.BOOLEAN_SET, TrueClass), true)
154 | Assert.equals(checkSet(Testmodel::ConstantTCK.CHAR_SET, Fixnum), 89)
155 | Assert.equals(checkSet(Testmodel::ConstantTCK.STRING_SET, String), 'orangutan')
156 | Assert.equals(checkSet(Testmodel::ConstantTCK.VERTX_GEN_SET, Testmodel::RefedInterface1).get_string, 'chaffinch')
157 | Assert.equals(checkSet(Testmodel::ConstantTCK.JSON_OBJECT_SET, Hash), {'cheese'=>'stilton'})
158 | Assert.equals(checkSet(Testmodel::ConstantTCK.JSON_ARRAY_SET, Array), %w(socks shoes))
159 | Assert.equals(checkSet(Testmodel::ConstantTCK.DATA_OBJECT_SET, Hash), {'foo' => 'foo', 'bar' => 123, 'wibble' => 0.0})
160 | Assert.equals(checkSet(Testmodel::ConstantTCK.ENUM_SET, Symbol), :JULIEN)
161 | end
162 |
163 | def checkMap(map, clazz)
164 | Assert.equals(map.size, 1)
165 | elt = map['foo']
166 | Assert.equals(elt.class, clazz)
167 | elt
168 | end
169 |
170 | def testMap
171 | Assert.equals(checkMap(Testmodel::ConstantTCK.BYTE_MAP, Fixnum), 123)
172 | Assert.equals(checkMap(Testmodel::ConstantTCK.SHORT_MAP, Fixnum), 12345)
173 | Assert.equals(checkMap(Testmodel::ConstantTCK.INT_MAP, Fixnum), 12345464)
174 | Assert.equals(checkMap(Testmodel::ConstantTCK.LONG_MAP, Fixnum), 65675123)
175 | Assert.equals(checkMap(Testmodel::ConstantTCK.FLOAT_MAP, Float), 1.23)
176 | Assert.equals(checkMap(Testmodel::ConstantTCK.DOUBLE_MAP, Float), 3.34535)
177 | Assert.equals(checkMap(Testmodel::ConstantTCK.BOOLEAN_MAP, TrueClass), true)
178 | Assert.equals(checkMap(Testmodel::ConstantTCK.CHAR_MAP, Fixnum), 89)
179 | Assert.equals(checkMap(Testmodel::ConstantTCK.STRING_MAP, String), 'orangutan')
180 | Assert.equals(checkMap(Testmodel::ConstantTCK.JSON_OBJECT_MAP, Hash), {'cheese'=>'stilton'})
181 | Assert.equals(checkMap(Testmodel::ConstantTCK.JSON_ARRAY_MAP, Array), %w(socks shoes))
182 | end
183 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/resources/data_object_tck_test.rb:
--------------------------------------------------------------------------------
1 | require 'java'
2 | require 'assert'
3 | require 'set'
4 | require 'testmodel/super_interface1'
5 | require 'testmodel/super_interface2'
6 | require 'testmodel/test_interface'
7 | require 'testmodel/data_object_tck'
8 | require 'testmodel/refed_interface1'
9 | require 'testmodel/refed_interface2'
10 | require 'testmodel/generic_refed_interface'
11 | require 'testmodel/factory'
12 | require 'acme/my_interface'
13 |
14 | java_import 'io.vertx.codegen.testmodel.RefedInterface1Impl'
15 | java_import 'io.vertx.codegen.testmodel.DataObjectTCKImpl'
16 |
17 | # Instantiate obj
18 | @dobj_tck = Testmodel::DataObjectTCK.new(DataObjectTCKImpl.new)
19 |
20 | def testMethodWithOnlyJsonObjectConstructorDataObject
21 | data_object = {:foo => 'bar'}
22 | @dobj_tck.method_with_only_json_object_constructor_data_object(data_object)
23 | end
24 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/resources/examples/bus_echo.rb:
--------------------------------------------------------------------------------
1 | eb = $vertx.event_bus()
2 |
3 | eb.consumer("ping-address") { |message|
4 | message.reply "pong"
5 | }
6 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/resources/examples/simple_http_server.rb:
--------------------------------------------------------------------------------
1 | require 'vertx/http_server'
2 | server = $vertx.create_http_server({:port=>8080,:host=>'localhost'})
3 | server.request_handler do |req|
4 | req.response.end('Hello World')
5 | end
6 | server.listen
7 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/resources/function_param_tck_test.rb:
--------------------------------------------------------------------------------
1 | require 'java'
2 | require 'assert'
3 | require 'set'
4 | require 'testmodel/function_param_tck'
5 | require 'testmodel/refed_interface1'
6 |
7 | java_import 'io.vertx.codegen.testmodel.FunctionParamTCKImpl'
8 | java_import 'io.vertx.codegen.testmodel.RefedInterface1Impl'
9 |
10 | # Instantiate obj
11 | @obj = Testmodel::FunctionParamTCK.new(FunctionParamTCKImpl.new)
12 | @refed_obj = Testmodel::RefedInterface1.new(RefedInterface1Impl.new)
13 |
14 | def testBasicParam
15 | ret = @obj.method_with_basic_param(
16 | Proc.new { |arg| Assert.equals(arg, 100); "ok0" },
17 | Proc.new { |arg| Assert.equals(arg, 1000); "ok1" },
18 | Proc.new { |arg| Assert.equals(arg, 100000); "ok2" },
19 | Proc.new { |arg| Assert.equals(arg, 10000000000); "ok3" },
20 | Proc.new { |arg| Assert.equals(arg, 3.5); "ok4" },
21 | Proc.new { |arg| Assert.equals(arg, 0.01); "ok5" },
22 | Proc.new { |arg| Assert.equals(arg, true); "ok6" },
23 | Proc.new { |arg| Assert.equals(arg, 70); "ok7" }
24 | ) do |arg|
25 | Assert.equals(arg, "wibble"); "ok8"
26 | end
27 | Assert.equals(ret, ["ok0","ok1","ok2","ok3","ok4","ok5","ok6","ok7","ok8"])
28 | end
29 |
30 | def testJsonParam
31 | ret = @obj.method_with_json_param(
32 | Proc.new { |arg| Assert.equals(arg, {"one"=>1,"two"=>2,"three"=>3}); "ok0" }
33 | ) do |arg|
34 | Assert.equals(arg, ["one","two","three"]); "ok1"
35 | end
36 | Assert.equals(ret, ["ok0","ok1"])
37 | end
38 |
39 | def testUserTypeParam
40 | ret = @obj.method_with_user_type_param(@refed_obj) do |arg|
41 | arg.set_string("foobarjuu")
42 | Assert.equals(arg.get_string(), "foobarjuu")
43 | "ok"
44 | end
45 | Assert.equals(ret, "ok")
46 | end
47 |
48 | def testObjectParam
49 | Assert.equals(@obj.method_with_object_param(123) do |arg|
50 | Assert.equals(arg, 123)
51 | "ok"
52 | end, "ok")
53 | Assert.equals(@obj.method_with_object_param("the-string-arg") do |arg|
54 | Assert.equals(arg, "the-string-arg")
55 | "ok"
56 | end, "ok")
57 | end
58 |
59 | def testDataObjectParam
60 | Assert.equals(@obj.method_with_data_object_param() do |arg|
61 | Assert.equals(arg["foo"], "foo_value")
62 | Assert.equals(arg["bar"], 3)
63 | Assert.equals(arg["wibble"], 0.01)
64 | "ok"
65 | end, "ok")
66 | end
67 |
68 | def testEnumParam
69 | Assert.equals(@obj.method_with_enum_param() do |arg|
70 | Assert.equals(arg, :TIM)
71 | "ok"
72 | end, "ok")
73 | end
74 |
75 | def testListParam
76 | Assert.equals(@obj.method_with_list_param() do |arg|
77 | Assert.equals(arg, ["one","two","three"])
78 | "ok"
79 | end, "ok")
80 | end
81 |
82 | def testSetParam
83 | Assert.equals(@obj.method_with_set_param() do |arg|
84 | Assert.equals(arg, Set.new(["one","two","three"]))
85 | "ok"
86 | end, "ok")
87 | end
88 |
89 | def testMapParam
90 | Assert.equals(@obj.method_with_map_param() do |arg|
91 | Assert.equals(arg, {"one"=>"one","two"=>"two","three"=>"three"})
92 | "ok"
93 | end, "ok")
94 | end
95 |
96 | def testGenericParam
97 | Assert.equals(@obj.method_with_generic_param(123) do |arg|
98 | Assert.equals(arg, 123)
99 | "ok"
100 | end, "ok")
101 | Assert.equals(@obj.method_with_generic_param("the-string-arg") do |arg|
102 | Assert.equals(arg, "the-string-arg")
103 | "ok"
104 | end, "ok")
105 | end
106 |
107 | def testGenericUserTypeParam
108 | Assert.equals(@obj.method_with_generic_user_type_param(123) do |arg|
109 | Assert.equals(arg.get_value(), 123)
110 | "ok"
111 | end, "ok")
112 | Assert.equals(@obj.method_with_generic_user_type_param("the-string-arg") do |arg|
113 | Assert.equals(arg.get_value(), "the-string-arg")
114 | "ok"
115 | end, "ok")
116 | end
117 |
118 | def testNullableListParam
119 | # Cannot pass because nullable return is not implemented
120 | end
121 |
122 | def testBasicReturn
123 | ret = @obj.method_with_basic_return(
124 | Proc.new { |arg| 10 },
125 | Proc.new { |arg| 1000 },
126 | Proc.new { |arg| 100000 },
127 | Proc.new { |arg| 10000000000 },
128 | Proc.new { |arg| 0.01 },
129 | Proc.new { |arg| 0.00001 },
130 | Proc.new { |arg| true },
131 | Proc.new { |arg| 67 }
132 | ) do |arg|
133 | "the-return"
134 | end
135 | Assert.equals(ret, "ok")
136 | end
137 |
138 | def testJsonReturn
139 | ret = @obj.method_with_json_return(
140 | Proc.new { |arg| { "foo":"foo_value", "bar":10, "wibble":0.1 } }
141 | ) do |arg|
142 | ["one", "two", "three"]
143 | end
144 | Assert.equals(ret, "ok")
145 | end
146 |
147 | def testObjectReturn
148 | ret = @obj.method_with_object_return() do |arg|
149 | case arg
150 | when 0
151 | "the-string"
152 | when 1
153 | 123
154 | when 2
155 | true
156 | when 3
157 | { "foo"=>"foo_value" }
158 | when 4
159 | ["foo", "bar"]
160 | else
161 | nil
162 | end
163 | end
164 | Assert.equals(ret, "ok")
165 | end
166 |
167 | def testDataObjectReturn
168 | ret = @obj.method_with_data_object_return() do |arg|
169 | { "foo"=>"wasabi","bar"=>6,"wibble"=>0.01 }
170 | end
171 | Assert.equals(ret, "ok")
172 | end
173 |
174 | def testEnumReturn
175 | ret = @obj.method_with_enum_return() do |arg|
176 | "NICK"
177 | end
178 | Assert.equals(ret, "ok")
179 | end
180 |
181 | def testListReturn
182 | ret = @obj.method_with_list_return() do |arg|
183 | ["one", "two", "three"]
184 | end
185 | Assert.equals(ret, "ok")
186 | end
187 |
188 | def testSetReturn
189 | ret = @obj.method_with_set_return() do |arg|
190 | Set.new(["one", "two", "three"])
191 | end
192 | Assert.equals(ret, "ok")
193 | end
194 |
195 | def testMapReturn
196 | ret = @obj.method_with_map_return() do |arg|
197 | {"one"=>"one", "two"=>"two", "three"=>"three"}
198 | end
199 | Assert.equals(ret, "ok")
200 | end
201 |
202 | def testGenericReturn
203 | ret = @obj.method_with_generic_return() do |arg|
204 | case arg
205 | when 0
206 | "the-string"
207 | when 1
208 | 123
209 | when 2
210 | true
211 | when 3
212 | { "foo"=>"foo_value" }
213 | when 4
214 | ["foo", "bar"]
215 | else
216 | nil
217 | end
218 | end
219 | Assert.equals(ret, "ok")
220 | end
221 |
222 | def testGenericUserTypeReturn
223 | ret = @obj.method_with_generic_user_type_return() do |arg|
224 | arg
225 | end
226 | Assert.equals(ret, "ok")
227 | end
228 |
229 | def testNullableListReturn
230 | # Cannot pass because nullable return is not implemented
231 | end
232 |
--------------------------------------------------------------------------------
/vertx-lang-ruby-gen/src/test/resources/lang_test.rb:
--------------------------------------------------------------------------------
1 | require 'java'
2 | require 'assert'
3 | require 'ruby-codegen/linear_overloaded_methods'
4 | require 'ruby-codegen/multi_overloaded_methods'
5 | require 'ruby-codegen/super_mixin'
6 | require 'ruby-codegen/mixin'
7 | require 'ruby-codegen/class_with_mixin'
8 | require 'ruby-codegen/reserved_word_params'
9 | require 'ruby-codegen/method_with_closure'
10 | require 'ruby-codegen/overload_with_options'
11 |
12 | java_import 'io.vertx.test.support.LinearOverloadedMethodsImpl'
13 | java_import 'io.vertx.test.support.MultiOverloadedMethodsImpl'
14 | java_import 'io.vertx.test.support.ClassWithMixinImpl'
15 | java_import 'io.vertx.test.support.ReferencingTypeImpl'
16 | java_import 'io.vertx.test.support.ReferencingTypeImpl'
17 | java_import 'io.vertx.test.support.ReservedWordParamsImpl'
18 | java_import 'io.vertx.test.support.MethodWithClosureImpl'
19 | java_import 'io.vertx.test.support.OverloadWithOptionsImpl'
20 |
21 | def test_linear_overload
22 | def create
23 | impl = LinearOverloadedMethodsImpl.new
24 | RubyCodegen::LinearOverloadedMethods.new impl
25 | end
26 |
27 | obj = create
28 | obj.method
29 | Assert.equals(obj.j_del.getCalled, 'method()')
30 |
31 | obj = create
32 | obj.method 'first_value'
33 | Assert.equals(obj.j_del.getCalled, 'method(first_value)')
34 |
35 | obj = create
36 | Assert.argument_error { obj.method 'first_value', 'second_value' }
37 | Assert.equals(obj.j_del.getCalled, nil)
38 |
39 | obj = create
40 | obj.method 'first_value', 'second_value', 'third_value'
41 | Assert.equals(obj.j_del.getCalled, 'method(first_value,second_value,third_value)')
42 |
43 | obj = create
44 | obj.method 'first_value', 'second_value', "third_value", 'forth_value'
45 | Assert.equals(obj.j_del.getCalled, 'method(first_value,second_value,third_value,forth_value)')
46 |
47 | end
48 |
49 | def create_multi_overload
50 | impl = MultiOverloadedMethodsImpl.new
51 | RubyCodegen::MultiOverloadedMethods.new impl
52 | end
53 |
54 | def test_multi_overload
55 |
56 | obj = create_multi_overload
57 | obj.method
58 | Assert.equals(obj.j_del.getCalled, 'method()')
59 |
60 | obj = create_multi_overload
61 | obj.method 'foo_value'
62 | Assert.equals(obj.j_del.getCalled, 'method(foo=foo_value)')
63 |
64 | obj = create_multi_overload
65 | Assert.argument_error { obj.method 123 }
66 | Assert.equals(obj.j_del.getCalled, nil)
67 |
68 | obj = create_multi_overload
69 | obj.method 123, true
70 | Assert.equals(obj.j_del.getCalled, 'method(bar=123,juu=true)')
71 |
72 | obj = create_multi_overload
73 | Assert.argument_error { obj.method 123, 'some_string' }
74 | Assert.equals(obj.j_del.getCalled, nil)
75 |
76 | end
77 |
78 | def test_multi_overload_optional_handler
79 |
80 | obj = create_multi_overload
81 | list = []
82 | obj.optional_handler('foo_value_with_handler') { |event| list.push event }
83 | Assert.equals(obj.j_del.getCalled, 'optionalHandler(foo=foo_value_with_handler,bar)')
84 | Assert.equals(list, ['the_event'])
85 |
86 | obj = create_multi_overload
87 | list = []
88 | obj.optional_handler 'foo_value_with_int', 4
89 | Assert.equals(obj.j_del.getCalled, 'optionalHandler(foo=foo_value_with_int,bar=4)')
90 | Assert.equals(list, [])
91 |
92 | obj = create_multi_overload
93 | list = []
94 | obj.optional_handler 'foo_value_with_boolean', true
95 | Assert.equals(obj.j_del.getCalled, 'optionalHandler(foo=foo_value_with_boolean,juu=true)')
96 | Assert.equals(list, [])
97 |
98 | Assert.argument_error { obj.optional_handler }
99 | Assert.argument_error { obj.optional_handler('the_string', 3) { |event| } }
100 | Assert.argument_error { obj.optional_handler('the_string', true) { |event| } }
101 |
102 | end
103 |
104 | def test_multi_overload_handlers
105 |
106 | obj = create_multi_overload
107 | list = Hash.new
108 | obj.handlers { |event| list[:foo]=event }
109 | Assert.equals(obj.j_del.getCalled, 'handlers(foo)')
110 | Assert.equals(list, {:foo=>'foo_event'})
111 |
112 | obj = create_multi_overload
113 | list = Hash.new
114 | obj.handlers(Proc.new { |event| list[:foo]=event }) { |event| list[:bar]=event }
115 | Assert.equals(obj.j_del.getCalled, 'handlers(foo,bar)')
116 | Assert.equals(list, {:foo=>'foo_event',:bar=>'bar_event'})
117 |
118 | obj = create_multi_overload
119 | list = Hash.new
120 | obj.handlers(Proc.new { |event| list[:foo]=event }, Proc.new { |event| list[:bar]=event }) { |event| list[:juu]=event }
121 | Assert.equals(obj.j_del.getCalled, 'handlers(foo,bar,juu)')
122 | Assert.equals(list, {:foo=>'foo_event',:bar=>'bar_event',:juu=>'juu_event'})
123 |
124 | Assert.argument_error { obj.handlers }
125 | Assert.argument_error { obj.handlers Proc.new({}), Proc.new({}), Proc.new({}) }
126 | Assert.argument_error { obj.handlers Proc.new({}), Proc.new({}), 'a' }
127 | Assert.argument_error { obj.handlers(Proc.new({}), Proc.new({}), 'a') {} }
128 |
129 | end
130 |
131 | def test_mixin_inheritance
132 | impl = ClassWithMixinImpl.new
133 | obj = RubyCodegen::ClassWithMixin.new impl
134 | Assert.equals(obj.is_a?(RubyCodegen::ClassWithMixin), true)
135 | Assert.equals(obj.is_a?(RubyCodegen::Mixin), true)
136 | Assert.equals(obj.is_a?(RubyCodegen::SuperMixin), true)
137 | end
138 |
139 | def test_include
140 | begin
141 | RubyCodegen::ReferencedType
142 | raise "We should not reference RubyCodegen::ReferencedType"
143 | rescue NameError
144 | # ignore
145 | end
146 | require 'ruby-codegen/referencing_type'
147 | obj = RubyCodegen::ReferencingType.new(ReferencingTypeImpl.new)
148 | referenced = obj.get_referenced
149 | Assert.equals referenced.some_method, 'someMethodValue'
150 | end
151 |
152 | def test_reserved_words
153 | obj = RubyCodegen::ReservedWordParams.new(ReservedWordParamsImpl.new)
154 | ret = obj.method('a', 'b', 'c', 'd', 'e',
155 | 'f', 'g', 'h', 'i', 'j',
156 | 'k', 'l', 'm', 'n', 'o',
157 | 'p', 'q', 'r', 's', 't',
158 | 'u', 'v', 'w', 'x', 'y')
159 | Assert.equals ret, 'abcdefghijklmnopqrstuvwxy'
160 | end
161 |
162 | def test_closure_callback
163 | impl = MethodWithClosureImpl.new
164 | obj = RubyCodegen::MethodWithClosure.new(impl)
165 | obj.do_something
166 | Assert.equals impl.getCalled, 'doSomething()'
167 | obj.do_something 'arg_value'
168 | Assert.equals impl.getCalled, 'doSomething(arg_value)'
169 | val = nil
170 | obj.do_something('arg_value') { |event| val = event }
171 | Assert.equals val, 'the_callback_payload'
172 | Assert.equals impl.getCalled, 'doSomething(arg_value,callback)'
173 | end
174 |
175 | def test_overload_with_options
176 | impl = OverloadWithOptionsImpl.new
177 | obj = RubyCodegen::OverloadWithOptions.new(impl)
178 | obj.method
179 | Assert.equals impl.getCalled, 'method()'
180 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/assembly/docs.xml:
--------------------------------------------------------------------------------
1 |
4 | docs
5 | false
6 |
7 |
8 | ${project.build.directory}/asciidoc
9 | ./
10 |
11 |
12 | ${project.build.directory}/yardoc
13 | ./yardoc/
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/buffer_from_bytes.adoc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vert-x3/vertx-lang-ruby/fc13f0ab2b9f3accc21be47e7f46c0b53568cfbd/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/buffer_from_bytes.adoc
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/configuring-eventbus.adoc:
--------------------------------------------------------------------------------
1 | The event bus can be configured. It is particularly useful when the event bus is clustered.
2 | Under the hood the event bus uses TCP connections to send and receive messages, so the {@link io.vertx.core.eventbus.EventBusOptions} let you configure all aspects of these TCP connections.
3 | As the event bus acts as a server and client, the configuration is close to {@link io.vertx.core.net.NetClientOptions} and {@link io.vertx.core.net.NetServerOptions}.
4 |
5 | [source,json]
6 | ----
7 | {
8 | "eventBusOptions": {
9 | "ssl": true,
10 | "keyStoreOptions": {
11 | "path": "keystore.jks",
12 | "password": "wibble"
13 | },
14 | "trustStoreOptions:" {
15 | "path": "keystore.jks",
16 | "password": "wibble"
17 | },
18 | clientAuth: "REQUIRED"
19 | }
20 | }
21 | ----
22 |
23 | The previous snippet depicts how you can use SSL connections for the event bus, instead of plain TCP connections.
24 |
25 | **WARNING**: to enforce the security in clustered mode, you **must** configure the cluster manager to use encryption or enforce security.
26 | Refer to the documentation of the cluster manager for further details.
27 |
28 | The event bus configuration needs to be consistent in all the cluster nodes.
29 |
30 | The {@link io.vertx.core.eventbus.EventBusOptions} also lets you specify whether or not the event bus is clustered, the port and host.
31 |
32 | When used in containers, you can also configure the public host and port:
33 |
34 | [source,json]
35 | ----
36 | {
37 | "eventBusOptions": {
38 | "clusterPublicHost": "whatever",
39 | "clusterPublicPort": 1234
40 | }
41 | }
42 | ----
43 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/configuring-native.adoc:
--------------------------------------------------------------------------------
1 | [source,json]
2 | ----
3 | {
4 | "preferNativeTransport": true
5 | }
6 | ----
7 |
8 | NOTE: preferring native transport will not prevent the application to execute (for example if a JAR is missing).
9 | If your application requires native transport, you need to check {@link io.vertx.core.Vertx#isNativeTransportEnabled()}.
10 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/dependencies.adoc:
--------------------------------------------------------------------------------
1 | If you are using Maven or Gradle, add the following dependency to the _dependencies_ section of your
2 | project descriptor to access the Vert.x Core API and enable the Ruby support:
3 |
4 | * Maven (in your `pom.xml`):
5 |
6 | [source,xml,subs="+attributes"]
7 | ----
8 |
9 | io.vertx
10 | vertx-core
11 | ${maven.version}
12 |
13 |
14 | io.vertx
15 | vertx-lang-ruby
16 | ${maven.version}
17 |
18 | ----
19 |
20 | * Gradle (in your `build.gradle` file):
21 |
22 | [source,groovy,subs="+attributes"]
23 | ----
24 | compile "io.vertx:vertx-core:${maven.version}"
25 | compile "io.vertx:vertx-lang-ruby:${maven.version}"
26 | ----
27 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/dns.adoc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vert-x3/vertx-lang-ruby/fc13f0ab2b9f3accc21be47e7f46c0b53568cfbd/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/dns.adoc
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/eventbus.adoc:
--------------------------------------------------------------------------------
1 | ==== Message Codecs
2 |
3 | Message codecs are available exclusively with the Java api.
4 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/eventbus_headers.adoc:
--------------------------------------------------------------------------------
1 | ==== Setting headers on messages
2 |
3 | Messages sent over the event bus can also contain headers. This can be specified by providing a `headers` object
4 | inside the {@link io.vertx.core.eventbus.DeliveryOptions} object when sending or publishing:
5 |
6 | [source,ruby]
7 | ----
8 | options = {
9 | headers: {
10 | 'some-header' => 'some-value'
11 | }
12 | }
13 | vertx.event_bus().send("news.uk.sport", "Yay! Someone kicked a ball", options)
14 | ----
15 |
16 | On the other side, the consumer can retrieve the message header as follows:
17 |
18 | [source, ruby]
19 | ----
20 | eb = $vertx.event_bus()
21 | eb.consumer("news.uk.sport") { |message|
22 | puts message.headers().get("some-header")
23 | }
24 | ----
25 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/hostname-resolution.adoc:
--------------------------------------------------------------------------------
1 | == Host name resolution
2 |
3 | Vert.x uses an an address resolver for resolving host name into IP addresses instead of
4 | the JVM built-in blocking resolver.
5 |
6 | An host name resolves to an IP address using:
7 |
8 | - the _hosts_ file of the operating system
9 | - otherwise DNS queries against a list of servers
10 |
11 | By default it will use the list of the system DNS server addresses from the environment, if that list cannot be
12 | retrieved it will use Google's public DNS servers `"8.8.8.8"` and `"8.8.4.4"`.
13 |
14 | DNS servers can be also configured with {@link io.vertx.core.VertxOptions}:
15 |
16 | [source,json]
17 | ----
18 | {
19 | "addressResolverOptions": {
20 | "servers": ["192.168.0.1", "192.168.0.2:40000"]
21 | }
22 | }
23 | ----
24 |
25 | The default port of a DNS server is `53`, when a server uses a different port, this port can be set
26 | using a colon delimiter: `192.168.0.2:40000`.
27 |
28 | NOTE: sometimes it can be desirable to use the JVM built-in resolver, the JVM system property
29 | _-Dvertx.disableDnsResolver=true_ activates this behavior
30 |
31 | === Failover
32 |
33 | When a server does not reply in a timely manner, the resolver will try the next one from the list, the search
34 | is limited by {@link io.vertx.core.dns.AddressResolverOptions#setMaxQueries(int)} (the default value is `4` queries).
35 |
36 | A DNS query is considered as failed when the resolver has not received a correct answer within
37 | {@link io.vertx.core.dns.AddressResolverOptions#getQueryTimeout()} milliseconds (the default value is `5` seconds).
38 |
39 | === Server list rotation
40 |
41 | By default the dns server selection uses the first one, the remaining servers are used for failover.
42 |
43 | You can configure {@link io.vertx.core.dns.AddressResolverOptions#setRotateServers(boolean)} to `true` to let
44 | the resolver perform a round-robin selection instead. It spreads the query load among the servers and avoids
45 | all lookup to hit the first server of the list.
46 |
47 | Failover still applies and will use the next server in the list.
48 |
49 | === Hosts mapping
50 |
51 | The _hosts_ file of the operating system is used to perform an hostname lookup for an ipaddress.
52 |
53 | An alternative _hosts_ file can be used instead:
54 |
55 | [source,json]
56 | ----
57 | {
58 | "addressResolverOptions": {
59 | "hostsPath": "/path/to/hosts"
60 | }
61 | }
62 | ----
63 |
64 | === Search domains
65 |
66 | By default the resolver will use the system DNS search domains from the environment. Alternatively an explicit search domain
67 | list can be provided:
68 |
69 | [source,json]
70 | ----
71 | {
72 | "addressResolverOptions": {
73 | "searchDomains": ["foo.com", "bar.com"]
74 | }
75 | }
76 | ----
77 |
78 | When a search domain list is used, the threshold for the number of dots is `1` or loaded from `/etc/resolv.conf`
79 | on Linux, it can be configured to a specific value with {@link io.vertx.core.dns.AddressResolverOptions#setNdots(int)}.
80 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/in-the-beginning.adoc:
--------------------------------------------------------------------------------
1 | == In the beginning there was Vert.x
2 |
3 | You can't do much in Vert.x-land unless you can communicate with a {@link io.vertx.core.Vertx} object!
4 |
5 | It's the control centre of Vert.x and is how you do pretty much everything, including creating clients and servers,
6 | getting a reference to the event bus, setting timers, as well as many other things.
7 |
8 | So how do you get an instance?
9 |
10 | When you start your application with the CLI, a `vertx` variable will be made available to your code.
11 |
12 | [source,ruby]
13 | ----
14 | server = vertx.create_http_server() # <1>
15 | server.request_handler() { |request|
16 | request.response().end("Hello world")
17 | })
18 | server.listen(8080)
19 | ----
20 | <1> At runtime, `vertx` variable is available
21 |
22 | Then run the applicaton with the CLI:
23 |
24 | [source,bash]
25 | ----
26 | vertx run my-verticle.rb
27 | ----
28 |
29 | NOTE: Most applications will only need a single Vert.x instance, but it's possible to create multiple Vert.x instances if you
30 | require, for example, isolation between the event bus or different groups of servers and clients.
31 |
32 | === Specifying options when creating a Vertx object
33 |
34 | When creating a Vert.x object you can also specify options if the defaults aren't right for you.
35 |
36 | [source,bash]
37 | ----
38 | vertx run my-verticle.rb -options my-options.json
39 | ----
40 |
41 | If you want to increase the worker pool size, your `my-options.json` file may look like:
42 |
43 | [source,json]
44 | ----
45 | {
46 | "workerPoolSize": 40
47 | }
48 | ----
49 |
50 | The {@link io.vertx.core.VertxOptions} object has many settings and allows you to configure things like clustering, high availability, pool sizes and various other settings.
51 |
52 | === Creating a clustered Vert.x object
53 |
54 | If you're creating a *clustered Vert.x* (See the section on the <> for more information on clustering the event bus), add the `-cluster` option:
55 |
56 | [source,bash]
57 | ----
58 | vertx run my-verticle.rb -cluster
59 | ----
60 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/json.adoc:
--------------------------------------------------------------------------------
1 | == JSON
2 |
3 | Unlike some other languages, Ruby does not have first class support for http://json.org/[JSON] so we use
4 | Array and Hash to make handling JSON in your Vert.x applications a bit easier.
5 |
6 | === JSON objects
7 |
8 | Ruby hashes represents JSON objects.
9 |
10 | A JSON object is basically just a map which has string keys and values can be of one of the JSON supported types
11 | (string, number, boolean).
12 |
13 | JSON objects also support nil values.
14 |
15 | ==== Creating JSON objects
16 |
17 | Empty JSON objects can be created with the default constructor.
18 |
19 | You can create a JSON object from a string JSON representation as follows:
20 |
21 | [source,ruby]
22 | ----
23 | require 'json'
24 | object = JSON.parse('"foo":"bar"')
25 | ----
26 |
27 | ==== Encoding the JSON object to a String
28 |
29 | You use `JSON.generate` to encode the object to a String form.
30 |
31 | [source,ruby]
32 | ----
33 | require 'json'
34 | json = JSON.generate(object)
35 | ----
36 |
37 | === JSON arrays
38 |
39 | Ruby arrays represents JSON arrays.
40 |
41 | A JSON array is a sequence of values (string, number, boolean).
42 |
43 | JSON arrays can also contain null values.
44 |
45 | ==== Creating JSON arrays
46 |
47 | Empty JSON arrays can be created with the default constructor.
48 |
49 | You can create a JSON array from a string JSON representation as follows:
50 |
51 | [source,ruby]
52 | ----
53 | require 'json'
54 | object = JSON.parse('[1,2,3]')
55 | ----
56 |
57 | ==== Encoding the JSON array to a String
58 |
59 | You use `JSON.generate` to encode the array to a String form.
60 |
61 | [source,ruby]
62 | ----
63 | require 'json'
64 | json = JSON.generate(array)
65 | ----
66 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/verticle-configuration.adoc:
--------------------------------------------------------------------------------
1 | === Passing configuration to a verticle
2 |
3 | Configuration in the form of JSON can be passed to a verticle at deployment time:
4 |
5 | [source,ruby]
6 | ----
7 | config = {
8 | 'name' => "tim",
9 | 'directory' => "/blah"
10 | }
11 | options = {
12 | 'config' => config
13 | }
14 | vertx.deploy_verticle("MyOrderProcessorVerticle.rb", options)
15 | ----
16 |
17 | This configuration is then available via the {@link io.vertx.core.Context} object. The configuration is returned as a
18 | _Hash_ object so you can retrieve data as follows:
19 |
20 | [source,ruby]
21 | ----
22 | puts $vertx.get_or_create_context().config()["name"]
23 | ----
24 |
25 | === Accessing environment variables in a Verticle
26 |
27 | Environment variables and system properties are accessible from a verticle using the Java API:
28 |
29 | [source,javascript]
30 | ----
31 | puts Java::JavaLang::System.getProperty("foo")
32 | puts Java::JavaLang::System.getenv("HOME")
33 | ----
34 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/main/docoverride/vertx-core/ruby/override/verticles.adoc:
--------------------------------------------------------------------------------
1 | === Writing Verticles
2 |
3 | Ruby verticles are implemented as simple scripts.
4 |
5 | Ruby verticles will have the following globals pre-set as a convenience:
6 |
7 | * +$vertx+ - A reference to the Vertx object
8 |
9 | [source,ruby]
10 | ----
11 | # Start a timer
12 | $vertx.set_periodic(1000) { puts 'Timer has fired' }
13 | ----
14 |
15 | When the verticle is deployed the body of the script will be executed.
16 |
17 | Any `vertx_start` function function defined during the body execution will be executed after the
18 | execution. The `vertx_start` is executed as any other function and does not expect any argument.
19 |
20 | Likewise any `vertx_stop` function function defined during the body execution will be executed after the
21 | execution. The `vertx_stop` is executed as any other function and does not expect any argument.
22 |
23 | [source,ruby]
24 | ----
25 | def vertx_stop future
26 | # Cleanup here
27 | end
28 | ----
29 |
30 | To load a verticle as a Ruby gem, this Ruby gem must deployed
31 |
32 | === Asynchronous Verticle start and stop
33 |
34 | Sometimes you want to do something in your verticle start-up which takes some time and you don't want the verticle to
35 | be considered deployed until that happens. For example you might want to deploy other verticles in the start method.
36 |
37 | You can't block waiting for the other verticles to deploy in your start method as that would break the Golden Rule.
38 |
39 | So how can you do this?
40 |
41 | The way to do it is to implement theasynchronous* start method. This version of the method takes a Future as a parameter.
42 | When the method returns the verticle willnot* be considered deployed yet. Some time later, after you've done everything
43 | you need to do (e.g. start other verticles), you can call complete on the Future (or fail) to signal that you're done.
44 |
45 | Here's an example:
46 |
47 | [source,ruby]
48 | ----
49 | def vertx_start_async start_future
50 | # Now deploy some other verticle:
51 |
52 | $vertx.deploy_verticle("other_verticle.rb") do |res|
53 | if res.succeeded?
54 | start_future.complete
55 | else
56 | start_future.fail
57 | end
58 | end
59 | end
60 | ----
61 |
62 | Similarly, there is an asynchronous version of the stop method too. You use this if you want to do some verticle
63 | cleanup that takes some time.
64 |
65 | [source,ruby]
66 | ----
67 | def vertx_stop_async stop_future
68 | obj.do_something_that_takes_time do |res|
69 | if res.succeeded?
70 | stop_future.complete
71 | else
72 | stop_future.fail
73 | end
74 | end
75 | end
76 | ----
77 |
78 | INFO: You don't need to manually undeploy child verticles started by a verticle, in the verticle's stop method. Vert.x
79 | will automatically undeploy any child verticles when the parent is undeployed.
80 |
81 | === Verticle deployment options
82 |
83 | When deploying a Ruby, verticle it is possible to set a specific _GEM_PATH_ variable for this particular
84 | verticle:
85 |
86 | [source,java]
87 | ----
88 | DeploymentOptions options = new DeploymentOptions().
89 | setConfig(new JsonObject().put("GEM_PATH", "/path/to/gems"));
90 | vertx.deployVerticle("my_verticle.rb", options);
91 | ----
92 |
93 | This can be done also possible in Ruby:
94 |
95 | [source,ruby]
96 | ----
97 | options = { :config => { :GEM_PATH => '/path/to/gems' } }
98 | $vertx.deploy_verticle('my_verticle.rb', options)
99 | ----
100 |
101 | This option can also be specified for the CLI:
102 |
103 | ----
104 | vertx run my_verticle_rb -conf {\"GEM_PATH\":\"/path/to/gems\"}
105 | ----
106 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/asciidoc/cheatsheet/NetServerOptions.adoc:
--------------------------------------------------------------------------------
1 | == NetServerOptions
2 |
3 | ++++
4 | @author Julien Viet
5 | ++++
6 | '''
7 |
8 | [cols=">25%,^25%,50%"]
9 | [frame="topbot"]
10 | |===
11 | ^|Name | Type ^| Description
12 | |===
13 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/asciidoc/cheatsheet/TestDataObject.adoc:
--------------------------------------------------------------------------------
1 | == TestDataObject
2 |
3 | ++++
4 | @author Tim Fox
5 | ++++
6 | '''
7 |
8 | [cols=">25%,^25%,50%"]
9 | [frame="topbot"]
10 | |===
11 | ^|Name | Type ^| Description
12 |
13 | |[[bar]]`bar`
14 | |`Number (int)`
15 | |-
16 | |[[foo]]`foo`
17 | |`String`
18 | |-
19 | |[[wibble]]`wibble`
20 | |`Number (double)`
21 | |-|===
22 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/asciidoc/dataobjects.adoc:
--------------------------------------------------------------------------------
1 | = Cheatsheets
2 |
3 | [[DataObjectWithBuffer]]
4 | == DataObjectWithBuffer
5 |
6 | ++++
7 | ++++
8 | '''
9 |
10 | [cols=">25%,^25%,50%"]
11 | [frame="topbot"]
12 | |===
13 | ^|Name | Type ^| Description
14 | |[[buffer]]`buffer`|`Buffer`|-
15 | |===
16 |
17 | [[DataObjectWithLists]]
18 | == DataObjectWithLists
19 |
20 | ++++
21 | ++++
22 | '''
23 |
24 | [cols=">25%,^25%,50%"]
25 | [frame="topbot"]
26 | |===
27 | ^|Name | Type ^| Description
28 | |[[booleanValues]]`booleanValues`|`Array of Boolean`|-
29 | |[[dataObjectValues]]`dataObjectValues`|`Array of link:dataobjects.html#TestDataObject[TestDataObject]`|-
30 | |[[doubleValues]]`doubleValues`|`Array of Number (Double)`|-
31 | |[[enumValues]]`enumValues`|`Array of link:enums.html#TestEnum[TestEnum]`|-
32 | |[[floatValues]]`floatValues`|`Array of Number (Float)`|-
33 | |[[genEnumValues]]`genEnumValues`|`Array of link:enums.html#TestGenEnum[TestGenEnum]`|-
34 | |[[integerValues]]`integerValues`|`Array of Number (Integer)`|-
35 | |[[jsonArrayValues]]`jsonArrayValues`|`Array of Json array`|-
36 | |[[jsonObjectValues]]`jsonObjectValues`|`Array of Json object`|-
37 | |[[longValues]]`longValues`|`Array of Number (Long)`|-
38 | |[[shortValues]]`shortValues`|`Array of Number (Short)`|-
39 | |[[stringValues]]`stringValues`|`Array of String`|-
40 | |===
41 |
42 | [[DataObjectWithMaps]]
43 | == DataObjectWithMaps
44 |
45 | ++++
46 | ++++
47 | '''
48 |
49 | [cols=">25%,^25%,50%"]
50 | [frame="topbot"]
51 | |===
52 | ^|Name | Type ^| Description
53 | |[[booleanValues]]`booleanValues`|`Boolean`|-
54 | |[[dataObjectValues]]`dataObjectValues`|`link:dataobjects.html#TestDataObject[TestDataObject]`|-
55 | |[[doubleValues]]`doubleValues`|`Number (Double)`|-
56 | |[[enumValues]]`enumValues`|`link:enums.html#TestEnum[TestEnum]`|-
57 | |[[floatValues]]`floatValues`|`Number (Float)`|-
58 | |[[genEnumValues]]`genEnumValues`|`link:enums.html#TestGenEnum[TestGenEnum]`|-
59 | |[[integerValues]]`integerValues`|`Number (Integer)`|-
60 | |[[jsonArrayValues]]`jsonArrayValues`|`Json array`|-
61 | |[[jsonObjectValues]]`jsonObjectValues`|`Json object`|-
62 | |[[longValues]]`longValues`|`Number (Long)`|-
63 | |[[shortValues]]`shortValues`|`Number (Short)`|-
64 | |[[stringValues]]`stringValues`|`String`|-
65 | |===
66 |
67 | [[DataObjectWithNestedBuffer]]
68 | == DataObjectWithNestedBuffer
69 |
70 | ++++
71 | ++++
72 | '''
73 |
74 | [cols=">25%,^25%,50%"]
75 | [frame="topbot"]
76 | |===
77 | ^|Name | Type ^| Description
78 | |[[buffer]]`buffer`|`Buffer`|-
79 | |[[buffers]]`buffers`|`Array of Buffer`|-
80 | |[[nested]]`nested`|`link:dataobjects.html#DataObjectWithBuffer[DataObjectWithBuffer]`|-
81 | |===
82 |
83 | [[DataObjectWithOnlyJsonObjectConstructor]]
84 | == DataObjectWithOnlyJsonObjectConstructor
85 |
86 | ++++
87 | ++++
88 | '''
89 |
90 | [cols=">25%,^25%,50%"]
91 | [frame="topbot"]
92 | |===
93 | ^|Name | Type ^| Description
94 | |[[foo]]`foo`|`String`|-
95 | |===
96 |
97 | [[DataObjectWithValues]]
98 | == DataObjectWithValues
99 |
100 | ++++
101 | ++++
102 | '''
103 |
104 | [cols=">25%,^25%,50%"]
105 | [frame="topbot"]
106 | |===
107 | ^|Name | Type ^| Description
108 | |[[booleanValue]]`booleanValue`|`Boolean`|-
109 | |[[boxedBooleanValue]]`boxedBooleanValue`|`Boolean`|-
110 | |[[boxedDoubleValue]]`boxedDoubleValue`|`Number (Double)`|-
111 | |[[boxedFloatValue]]`boxedFloatValue`|`Number (Float)`|-
112 | |[[boxedIntValue]]`boxedIntValue`|`Number (Integer)`|-
113 | |[[boxedLongValue]]`boxedLongValue`|`Number (Long)`|-
114 | |[[boxedShortValue]]`boxedShortValue`|`Number (Short)`|-
115 | |[[dataObjectValue]]`dataObjectValue`|`link:dataobjects.html#TestDataObject[TestDataObject]`|-
116 | |[[doubleValue]]`doubleValue`|`Number (double)`|-
117 | |[[enumValue]]`enumValue`|`link:enums.html#TestEnum[TestEnum]`|-
118 | |[[floatValue]]`floatValue`|`Number (float)`|-
119 | |[[genEnumValue]]`genEnumValue`|`link:enums.html#TestGenEnum[TestGenEnum]`|-
120 | |[[intValue]]`intValue`|`Number (int)`|-
121 | |[[jsonArrayValue]]`jsonArrayValue`|`Json array`|-
122 | |[[jsonObjectValue]]`jsonObjectValue`|`Json object`|-
123 | |[[longValue]]`longValue`|`Number (long)`|-
124 | |[[shortValue]]`shortValue`|`Number (short)`|-
125 | |[[stringValue]]`stringValue`|`String`|-
126 | |===
127 |
128 | [[TestDataObject]]
129 | == TestDataObject
130 |
131 | ++++
132 | ++++
133 | '''
134 |
135 | [cols=">25%,^25%,50%"]
136 | [frame="topbot"]
137 | |===
138 | ^|Name | Type ^| Description
139 | |[[bar]]`bar`|`Number (int)`|-
140 | |[[foo]]`foo`|`String`|-
141 | |[[wibble]]`wibble`|`Number (double)`|-
142 | |===
143 |
144 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/asciidoc/enums.adoc:
--------------------------------------------------------------------------------
1 | = Enums
2 |
3 | [[TestGenEnum]]
4 | == TestGenEnum
5 |
6 | ++++
7 | ++++
8 | '''
9 |
10 | [cols=">25%,75%"]
11 | [frame="topbot"]
12 | |===
13 | ^|Name | Description
14 | |[[LAURA]]`LAURA`|-
15 | |[[BOB]]`BOB`|-
16 | |[[MIKE]]`MIKE`|-
17 | |[[LELAND]]`LELAND`|-
18 | |===
19 |
20 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/external-test-resources/foo/bar.rb:
--------------------------------------------------------------------------------
1 | puts "Hello";
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/gems/test_gem/lib/test_gem.rb:
--------------------------------------------------------------------------------
1 | require 'vertx/event_bus'
2 | eb = $vertx.event_bus
3 | eb.send 'deployment', 'gem_started', {}
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/gems/test_gem/test_gem-0.0.0.gem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vert-x3/vertx-lang-ruby/fc13f0ab2b9f3accc21be47e7f46c0b53568cfbd/vertx-lang-ruby/src/test/gems/test_gem/test_gem-0.0.0.gem
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/gems/test_gem/test_gem.gemspec:
--------------------------------------------------------------------------------
1 | Gem::Specification.new do |s|
2 | s.name = 'test_gem'
3 | s.version = '0.0.0'
4 | s.date = '2014-01-16'
5 | s.summary = 'the_summary'
6 | s.description = 'the_description'
7 | s.authors = ['Julien Viet']
8 | s.email = 'admin@mydomain.org'
9 | s.files = ['lib/test_gem.rb']
10 | s.homepage = 'http://vertx.io'
11 | s.license = 'MIT'
12 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/it/ServiceDiscoveryTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011-2016 The original author or authors
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | package io.vertx.test.it;
18 |
19 | import io.vertx.core.Vertx;
20 | import io.vertx.core.json.JsonObject;
21 | import io.vertx.ext.unit.junit.VertxUnitRunner;
22 | import io.vertx.servicediscovery.Record;
23 | import io.vertx.servicediscovery.ServiceDiscovery;
24 | import io.vertx.servicediscovery.ServiceDiscoveryOptions;
25 | import io.vertx.servicediscovery.impl.DiscoveryImpl;
26 | import io.vertx.servicediscovery.types.*;
27 | import io.vertx.serviceproxy.ProxyHelper;
28 | import io.vertx.test.it.service.HelloService;
29 | import io.vertx.test.it.service.HelloServiceImpl;
30 | import org.junit.After;
31 | import org.junit.Before;
32 | import org.junit.Test;
33 | import org.junit.runner.RunWith;
34 |
35 | import java.util.concurrent.TimeUnit;
36 | import java.util.concurrent.atomic.AtomicBoolean;
37 | import java.util.concurrent.atomic.AtomicReference;
38 |
39 | import static com.jayway.awaitility.Awaitility.await;
40 | import static org.assertj.core.api.Assertions.assertThat;
41 | import static org.hamcrest.core.Is.is;
42 |
43 | /**
44 | * @author Clement Escoffier
45 | */
46 | @RunWith(VertxUnitRunner.class)
47 | public class ServiceDiscoveryTest {
48 |
49 | public static final ServiceDiscoveryOptions DISCOVERY_OPTIONS = new ServiceDiscoveryOptions()
50 | .setBackendConfiguration(new JsonObject().put("backend-name", "io.vertx.servicediscovery.impl.DefaultServiceDiscoveryBackend"));
51 |
52 | private Vertx vertx;
53 | private ServiceDiscovery discovery;
54 |
55 | @Before
56 | public void setUp() {
57 | vertx = Vertx.vertx();
58 | discovery = new DiscoveryImpl(vertx, DISCOVERY_OPTIONS);
59 | }
60 |
61 | @After
62 | public void tearDown() {
63 | discovery.close();
64 | AtomicBoolean completed = new AtomicBoolean();
65 | vertx.close((v) -> completed.set(true));
66 | await().untilAtomic(completed, is(true));
67 | }
68 |
69 | @Test
70 | public void testWithRubyConsumer() {
71 | // Step 1 - register the service
72 | HelloService svc = new HelloServiceImpl("stuff");
73 | ProxyHelper.registerService(HelloService.class, vertx, svc, "address");
74 | Record record = EventBusService.createRecord("Hello", "address", HelloService.class);
75 |
76 | discovery.publish(record, (r) -> {
77 | });
78 | await().until(() -> record.getRegistration() != null);
79 |
80 | // Step 2 - register a consumer that get the result
81 | AtomicReference result = new AtomicReference<>();
82 | vertx.eventBus().consumer("result", message -> result.set(message.body()));
83 |
84 | // Step 3 - deploy the verticle
85 | vertx.deployVerticle("it/discovery/HelloServiceConsumer.rb", ar -> {
86 | if (ar.failed()) {
87 | // Will fail anyway.
88 | ar.cause().printStackTrace();
89 | }
90 | });
91 |
92 | await().atMost(1, TimeUnit.MINUTES).until(() -> result.get() != null);
93 |
94 | assertThat(result.get().getString("message")).isEqualTo("stuff vert.x");
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/it/VertxUnitTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.it;
2 |
3 | import io.vertx.core.json.JsonObject;
4 | import io.vertx.ext.unit.collect.EventBusCollector;
5 | import io.vertx.test.core.VertxTestBase;
6 |
7 | /**
8 | * @author Julien Viet
9 | */
10 | public class VertxUnitTest extends VertxTestBase {
11 |
12 | @org.junit.Test
13 | public void testAssertionsRuby() throws Exception {
14 | testAssertions("rb:it/unit/assertions.rb");
15 | }
16 |
17 | private void testAssertions(String verticle) throws Exception {
18 | vertx.eventBus().consumer("assert_tests").bodyStream().handler(msg -> {
19 | String type = msg.getString("type");
20 | switch (type) {
21 | case EventBusCollector.EVENT_TEST_CASE_END:
22 | String name = msg.getString("name");
23 | if (name.startsWith("fail_")) {
24 | assertNotNull(msg.getValue("failure"));
25 | } else {
26 | assertEquals(null, msg.getValue("failure"));
27 | }
28 | break;
29 | case EventBusCollector.EVENT_TEST_SUITE_END:
30 | testComplete();
31 | break;
32 | }
33 | });
34 | vertx.deployVerticle(verticle, ar -> {
35 | assertTrue(ar.succeeded());
36 | });
37 | await();
38 | }
39 |
40 | @org.junit.Test
41 | public void testRubyFailure() {
42 | vertx.deployVerticle("it/unit/failing.rb", ar -> {
43 | assertTrue(ar.failed());
44 | assertEquals("(Exception) the_failure", ar.cause().getMessage());
45 | testComplete();
46 | });
47 | await();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/it/service/HelloService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011-2016 The original author or authors
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | package io.vertx.test.it.service;
18 |
19 | import io.vertx.codegen.annotations.ProxyGen;
20 | import io.vertx.codegen.annotations.VertxGen;
21 | import io.vertx.core.AsyncResult;
22 | import io.vertx.core.Handler;
23 | import io.vertx.core.json.JsonObject;
24 |
25 | /**
26 | * @author Clement Escoffier
27 | */
28 | @ProxyGen
29 | @VertxGen
30 | public interface HelloService {
31 |
32 | void hello(JsonObject name, Handler> resultHandler);
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/it/service/HelloServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011-2016 The original author or authors
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | package io.vertx.test.it.service;
18 |
19 | import io.vertx.core.AsyncResult;
20 | import io.vertx.core.Future;
21 | import io.vertx.core.Handler;
22 | import io.vertx.core.Vertx;
23 | import io.vertx.core.eventbus.MessageConsumer;
24 | import io.vertx.core.json.JsonObject;
25 | import io.vertx.serviceproxy.ProxyHelper;
26 |
27 | /**
28 | * @author Clement Escoffier
29 | */
30 | public class HelloServiceImpl implements HelloService {
31 |
32 | private final String msg;
33 | private MessageConsumer service;
34 |
35 | public HelloServiceImpl() {
36 | this("Hello");
37 | }
38 |
39 | public HelloServiceImpl(String message) {
40 | this.msg = message;
41 | }
42 |
43 | public void start(Vertx vertx, String address) {
44 | service = ProxyHelper.registerService(HelloService.class, vertx, this, address);
45 | }
46 |
47 | public void stop() {
48 | ProxyHelper.unregisterService(service);
49 | }
50 |
51 | @Override
52 | public void hello(JsonObject name, Handler> resultHandler) {
53 | resultHandler.handle(Future.succeededFuture(msg + " " + name.getString("name")));
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/it/service/HelloServiceVertxEBProxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * Red Hat licenses this file to you under the Apache License, version 2.0
5 | * (the "License"); you may not use this file except in compliance with the
6 | * License. You may obtain a copy of the License at:
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package io.vertx.test.it.service;
18 |
19 | import io.vertx.core.eventbus.DeliveryOptions;
20 | import io.vertx.core.Vertx;
21 | import io.vertx.core.Future;
22 | import io.vertx.core.json.JsonObject;
23 | import io.vertx.core.json.JsonArray;
24 | import java.util.ArrayList;
25 | import java.util.HashSet;
26 | import java.util.List;
27 | import java.util.Map;
28 | import java.util.Set;
29 | import java.util.stream.Collectors;
30 | import java.util.function.Function;
31 | import io.vertx.serviceproxy.ServiceProxyBuilder;
32 | import io.vertx.serviceproxy.ServiceException;
33 | import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
34 | import io.vertx.serviceproxy.ProxyUtils;
35 |
36 | import io.vertx.core.json.JsonObject;
37 | import io.vertx.core.AsyncResult;
38 | import io.vertx.core.Handler;
39 | /*
40 | Generated Proxy code - DO NOT EDIT
41 | @author Roger the Robot
42 | */
43 |
44 | @SuppressWarnings({"unchecked", "rawtypes"})
45 | public class HelloServiceVertxEBProxy implements HelloService {
46 | private Vertx _vertx;
47 | private String _address;
48 | private DeliveryOptions _options;
49 | private boolean closed;
50 |
51 | public HelloServiceVertxEBProxy(Vertx vertx, String address) {
52 | this(vertx, address, null);
53 | }
54 |
55 | public HelloServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) {
56 | this._vertx = vertx;
57 | this._address = address;
58 | this._options = options;
59 | try{
60 | this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec());
61 | } catch (IllegalStateException ex) {}
62 | }
63 |
64 | @Override
65 | public void hello(JsonObject name, Handler> resultHandler){
66 | if (closed) {
67 | resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
68 | return;
69 | }
70 | JsonObject _json = new JsonObject();
71 | _json.put("name", name);
72 |
73 | DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
74 | _deliveryOptions.addHeader("action", "hello");
75 | _vertx.eventBus().request(_address, _json, _deliveryOptions, res -> {
76 | if (res.failed()) {
77 | resultHandler.handle(Future.failedFuture(res.cause()));
78 | } else {
79 | resultHandler.handle(Future.succeededFuture(res.result().body()));
80 | }
81 | });
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/it/service/HelloServiceVertxProxyHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Red Hat, Inc.
3 | *
4 | * Red Hat licenses this file to you under the Apache License, version 2.0
5 | * (the "License"); you may not use this file except in compliance with the
6 | * License. You may obtain a copy of the License at:
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package io.vertx.test.it.service;
18 |
19 | import io.vertx.test.it.service.HelloService;
20 | import io.vertx.core.Vertx;
21 | import io.vertx.core.Handler;
22 | import io.vertx.core.AsyncResult;
23 | import io.vertx.core.eventbus.EventBus;
24 | import io.vertx.core.eventbus.Message;
25 | import io.vertx.core.eventbus.MessageConsumer;
26 | import io.vertx.core.eventbus.DeliveryOptions;
27 | import io.vertx.core.eventbus.ReplyException;
28 | import io.vertx.core.json.JsonObject;
29 | import io.vertx.core.json.JsonArray;
30 | import java.util.Collection;
31 | import java.util.ArrayList;
32 | import java.util.HashSet;
33 | import java.util.List;
34 | import java.util.Map;
35 | import java.util.Set;
36 | import java.util.UUID;
37 | import java.util.stream.Collectors;
38 | import io.vertx.serviceproxy.ServiceBinder;
39 | import io.vertx.serviceproxy.ProxyHandler;
40 | import io.vertx.serviceproxy.ServiceException;
41 | import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
42 | import io.vertx.serviceproxy.HelperUtils;
43 |
44 | import io.vertx.core.json.JsonObject;
45 | import io.vertx.core.AsyncResult;
46 | import io.vertx.core.Handler;
47 | /*
48 | Generated Proxy code - DO NOT EDIT
49 | @author Roger the Robot
50 | */
51 |
52 | @SuppressWarnings({"unchecked", "rawtypes"})
53 | public class HelloServiceVertxProxyHandler extends ProxyHandler {
54 |
55 | public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes
56 | private final Vertx vertx;
57 | private final HelloService service;
58 | private final long timerID;
59 | private long lastAccessed;
60 | private final long timeoutSeconds;
61 |
62 | public HelloServiceVertxProxyHandler(Vertx vertx, HelloService service){
63 | this(vertx, service, DEFAULT_CONNECTION_TIMEOUT);
64 | }
65 |
66 | public HelloServiceVertxProxyHandler(Vertx vertx, HelloService service, long timeoutInSecond){
67 | this(vertx, service, true, timeoutInSecond);
68 | }
69 |
70 | public HelloServiceVertxProxyHandler(Vertx vertx, HelloService service, boolean topLevel, long timeoutSeconds) {
71 | this.vertx = vertx;
72 | this.service = service;
73 | this.timeoutSeconds = timeoutSeconds;
74 | try {
75 | this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
76 | new ServiceExceptionMessageCodec());
77 | } catch (IllegalStateException ex) {}
78 | if (timeoutSeconds != -1 && !topLevel) {
79 | long period = timeoutSeconds * 1000 / 2;
80 | if (period > 10000) {
81 | period = 10000;
82 | }
83 | this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
84 | } else {
85 | this.timerID = -1;
86 | }
87 | accessed();
88 | }
89 |
90 |
91 | private void checkTimedOut(long id) {
92 | long now = System.nanoTime();
93 | if (now - lastAccessed > timeoutSeconds * 1000000000) {
94 | close();
95 | }
96 | }
97 |
98 | @Override
99 | public void close() {
100 | if (timerID != -1) {
101 | vertx.cancelTimer(timerID);
102 | }
103 | super.close();
104 | }
105 |
106 | private void accessed() {
107 | this.lastAccessed = System.nanoTime();
108 | }
109 |
110 | public void handle(Message msg) {
111 | try{
112 | JsonObject json = msg.body();
113 | String action = msg.headers().get("action");
114 | if (action == null) throw new IllegalStateException("action not specified");
115 | accessed();
116 | switch (action) {
117 | case "hello": {
118 | service.hello((io.vertx.core.json.JsonObject)json.getValue("name"),
119 | HelperUtils.createHandler(msg));
120 | break;
121 | }
122 | default: throw new IllegalStateException("Invalid action: " + action);
123 | }
124 | } catch (Throwable t) {
125 | msg.reply(new ServiceException(500, t.getMessage()));
126 | throw t;
127 | }
128 | }
129 | }
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/it/service/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2011-2016 The original author or authors
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * and Apache License v2.0 which accompanies this distribution.
7 | *
8 | * The Eclipse Public License is available at
9 | * http://www.eclipse.org/legal/epl-v10.html
10 | *
11 | * The Apache License v2.0 is available at
12 | * http://www.opensource.org/licenses/apache2.0.php
13 | *
14 | * You may elect to redistribute this code under either of these licenses.
15 | */
16 |
17 | /**
18 | * @author Clement Escoffier
19 | */
20 | @ModuleGen(name = "test-services", groupPackage = "io.vertx")
21 | package io.vertx.test.it.service;
22 |
23 | import io.vertx.codegen.annotations.ModuleGen;
24 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/lang/ruby/DeployTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import io.vertx.core.DeploymentOptions;
4 | import io.vertx.core.json.JsonObject;
5 | import io.vertx.test.core.VertxTestBase;
6 | import org.jruby.embed.LocalContextScope;
7 | import org.jruby.embed.ScriptingContainer;
8 | import org.junit.Test;
9 |
10 | import java.io.File;
11 |
12 | /**
13 | * @author Julien Viet
14 | */
15 | public class DeployTest extends VertxTestBase {
16 |
17 | private static volatile int deployedCount;
18 | private static volatile int startedCount;
19 | private static volatile int stoppedCount;
20 |
21 | public static void deployed() {
22 | deployedCount++;
23 | }
24 | public static void started() {
25 | startedCount++;
26 | }
27 | public static void stopped() {
28 | stoppedCount++;
29 | }
30 |
31 | @Override
32 | public void setUp() throws Exception {
33 | super.setUp();
34 | deployedCount = 0;
35 | startedCount = 0;
36 | stoppedCount = 0;
37 | }
38 |
39 | @Test
40 | public void testDeployRubyVerticle() {
41 | vertx.deployVerticle("simple_verticle.rb", ar -> {
42 | assertTrue(ar.succeeded());
43 | assertEquals(1, deployedCount);
44 | testComplete();
45 | });
46 | await();
47 | }
48 |
49 | @Test
50 | public void testDeployAbsentVerticle() {
51 | vertx.deployVerticle("doesnotexists.rb", ar -> {
52 | assertTrue(ar.failed());
53 | testComplete();
54 | });
55 | await();
56 | }
57 |
58 | @Test
59 | public void testGemPath() {
60 | waitFor(2);
61 | File gemsDir = new File(System.getProperty("gems.path"));
62 | if (gemsDir.exists()) {
63 | if (!gemsDir.isDirectory()) {
64 | throw new AssertionError("Gems dir is not a dir");
65 | }
66 | } else if (!gemsDir.mkdirs()) {
67 | throw new AssertionError("Could not create gems dir");
68 | }
69 | ScriptingContainer container = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
70 | container.runScriptlet(
71 | "require 'rubygems'\n" +
72 | "require 'rubygems/gem_runner'\n" +
73 | "require 'rubygems/exceptions'\n" +
74 | "Gem::GemRunner.new.run ['install', 'src/test/gems/test_gem/test_gem-0.0.0.gem', '--install-dir', '" +
75 | gemsDir.getAbsolutePath() + "']"
76 | );
77 | vertx.eventBus().consumer("deployment", msg -> {
78 | assertEquals("gem_started", msg.body());
79 | complete();
80 | });
81 | vertx.deployVerticle(
82 | "verticle_requiring_gem.rb",
83 | new DeploymentOptions().setConfig(new JsonObject().put("GEM_PATH", gemsDir.getAbsolutePath())),
84 | onSuccess(id -> {
85 | complete();
86 | }));
87 | await();
88 | }
89 |
90 | @Test
91 | public void testVerticleLifecycle() {
92 | vertx.deployVerticle("lifecycle_verticle.rb", ar -> {
93 | assertTrue(ar.succeeded());
94 | assertEquals(1, deployedCount);
95 | assertEquals(1, startedCount);
96 | assertEquals(0, stoppedCount);
97 | vertx.undeploy(ar.result(), ar2 -> {
98 | assertTrue(ar2.succeeded());
99 | assertEquals(1, deployedCount);
100 | assertEquals(1, startedCount);
101 | assertEquals(1, stoppedCount);
102 | testComplete();
103 | });
104 | });
105 | await();
106 | }
107 |
108 | @Test
109 | public void testAsyncVerticleLifecycle() {
110 | vertx.deployVerticle("async_lifecycle_verticle.rb", ar -> {
111 | assertTrue(ar.succeeded());
112 | assertEquals(1, deployedCount);
113 | assertEquals(1, startedCount);
114 | assertEquals(0, stoppedCount);
115 | vertx.undeploy(ar.result(), ar2 -> {
116 | assertTrue(ar2.succeeded());
117 | assertEquals(1, deployedCount);
118 | assertEquals(1, startedCount);
119 | assertEquals(1, stoppedCount);
120 | testComplete();
121 | });
122 | });
123 | await();
124 | }
125 |
126 | @Test
127 | public void testVerticleRaisingErrorInRun() {
128 | vertx.deployVerticle("verticle_raising_error_in_run.rb", ar -> {
129 | assertFalse(ar.succeeded());
130 | assertEquals(1, deployedCount);
131 | assertEquals(0, startedCount);
132 | assertEquals(0, stoppedCount);
133 | testComplete();
134 | });
135 | await();
136 | }
137 |
138 | @Test
139 | public void testVerticleRaisingErrorInStart() {
140 | vertx.deployVerticle("verticle_raising_error_in_start.rb", ar -> {
141 | assertFalse(ar.succeeded());
142 | assertEquals(1, deployedCount);
143 | assertEquals(1, startedCount);
144 | assertEquals(0, stoppedCount);
145 | testComplete();
146 | });
147 | await();
148 | }
149 |
150 | @Test
151 | public void testVerticleRaisingErrorInStop() {
152 | vertx.deployVerticle("verticle_raising_error_in_stop.rb", ar -> {
153 | assertTrue(ar.succeeded());
154 | assertEquals(1, deployedCount);
155 | assertEquals(1, startedCount);
156 | assertEquals(0, stoppedCount);
157 | vertx.undeploy(ar.result(), ar2 -> {
158 | assertTrue(ar.succeeded());
159 | assertEquals(1, deployedCount);
160 | assertEquals(1, startedCount);
161 | assertEquals(1, stoppedCount);
162 | testComplete();
163 | });
164 | });
165 | await();
166 | }
167 |
168 | @Test
169 | public void testVerticleRaisingErrorInAsyncStart() {
170 | vertx.deployVerticle("verticle_raising_error_in_async_start.rb", ar -> {
171 | assertFalse(ar.succeeded());
172 | assertEquals(1, deployedCount);
173 | assertEquals(1, startedCount);
174 | assertEquals(0, stoppedCount);
175 | testComplete();
176 | });
177 | await();
178 | }
179 |
180 | @Test
181 | public void testVerticleRaisingErrorInAsyncStop() {
182 | vertx.deployVerticle("verticle_raising_error_in_async_stop.rb", ar -> {
183 | assertTrue(ar.succeeded());
184 | assertEquals(1, deployedCount);
185 | assertEquals(1, startedCount);
186 | assertEquals(0, stoppedCount);
187 | vertx.undeploy(ar.result(), ar2 -> {
188 | assertTrue(ar.succeeded());
189 | assertEquals(1, deployedCount);
190 | assertEquals(1, startedCount);
191 | assertEquals(1, stoppedCount);
192 | testComplete();
193 | });
194 | });
195 | await();
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/lang/ruby/EventBusTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Red Hat, Inc.
3 | *
4 | * Red Hat licenses this file to you under the Apache License, version 2.0
5 | * (the "License"); you may not use this file except in compliance with the
6 | * License. You may obtain a copy of the License at:
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations
14 | * under the License.
15 | */
16 |
17 | package io.vertx.test.lang.ruby;
18 |
19 | import org.junit.Test;
20 |
21 | /**
22 | * @author Thomas Segismont
23 | */
24 | public class EventBusTest extends RubyTestBase {
25 |
26 | @Test
27 | public void testSendBuffer() throws Exception {
28 | runTest();
29 | }
30 |
31 | private void runTest() {
32 | runTest("event_bus_test", testName.getMethodName());
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/lang/ruby/IntegrationTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * @author Julien Viet
7 | */
8 | public class IntegrationTest extends RubyTestBase {
9 |
10 | @Test
11 | public void testMultiMapNames() {
12 | runTest("test_multi_map_names");
13 | }
14 |
15 | private void runTest(String testName) {
16 | runTest("integration_test", testName);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/lang/ruby/IsolationTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import io.vertx.test.core.VertxTestBase;
4 | import org.junit.Test;
5 |
6 | import java.util.LinkedList;
7 | import java.util.function.Supplier;
8 |
9 | /**
10 | * @author Julien Viet
11 | */
12 | public class IsolationTest extends VertxTestBase {
13 |
14 | private static final LinkedList> callbacks = new LinkedList<>();
15 |
16 | public static void registerCallback(Supplier callback) {
17 | callbacks.add(callback);
18 | }
19 |
20 | public void before() throws Exception {
21 | callbacks.clear();
22 | super.before();
23 | }
24 |
25 | @Test
26 | public void testDifferentVerticleTypeDontShareTheSameGlobal() {
27 | vertx.deployVerticle("verticle_sharing_global_1.rb", ar1 -> {
28 | assertTrue(ar1.succeeded());
29 | assertEquals(1, callbacks.size());
30 | assertEquals(1, callbacks.get(0).get().intValue());
31 | vertx.deployVerticle("verticle_sharing_global_2.rb", ar2 -> {
32 | assertTrue(ar2.succeeded());
33 | assertEquals(2, callbacks.size());
34 | assertEquals(1, callbacks.get(0).get().intValue());
35 | assertEquals(2, callbacks.get(1).get().intValue());
36 | testComplete();
37 | });
38 | });
39 | await();
40 | }
41 |
42 | @Test
43 | public void testSameVerticleTypeShareTheSameGlobal() {
44 | vertx.deployVerticle("verticle_incrementing_global.rb", ar1 -> {
45 | assertTrue(ar1.succeeded());
46 | assertEquals(1, callbacks.size());
47 | assertEquals(1, callbacks.get(0).get().intValue());
48 | vertx.deployVerticle("verticle_incrementing_global.rb", ar2 -> {
49 | assertTrue(ar2.succeeded());
50 | assertEquals(2, callbacks.size());
51 | assertEquals(2, callbacks.get(0).get().intValue());
52 | assertEquals(2, callbacks.get(1).get().intValue());
53 | testComplete();
54 | });
55 | });
56 | await();
57 | }
58 |
59 | @Test
60 | public void testSameVerticleTypeDontShareTheSameLocal() {
61 | vertx.deployVerticle("verticle_incrementing_local.rb", ar1 -> {
62 | assertTrue(ar1.succeeded());
63 | assertEquals(1, callbacks.size());
64 | assertEquals(1, callbacks.get(0).get().intValue());
65 | vertx.deployVerticle("verticle_incrementing_local.rb", ar2 -> {
66 | assertTrue(ar2.succeeded());
67 | assertEquals(2, callbacks.size());
68 | assertEquals(1, callbacks.get(0).get().intValue());
69 | assertEquals(1, callbacks.get(1).get().intValue());
70 | testComplete();
71 | });
72 | });
73 | await();
74 | }
75 |
76 | @Test
77 | public void testSameVerticleTypeDontShareTheSameIvar() {
78 | vertx.deployVerticle("verticle_incrementing_ivar.rb", ar1 -> {
79 | assertTrue(ar1.succeeded());
80 | assertEquals(1, callbacks.size());
81 | assertEquals(1, callbacks.get(0).get().intValue());
82 | vertx.deployVerticle("verticle_incrementing_ivar.rb", ar2 -> {
83 | assertTrue(ar2.succeeded());
84 | assertEquals(2, callbacks.size());
85 | assertEquals(1, callbacks.get(0).get().intValue());
86 | assertEquals(1, callbacks.get(1).get().intValue());
87 | testComplete();
88 | });
89 | });
90 | await();
91 | }
92 |
93 | @Test
94 | public void testSameVerticleTypeDontShareTheSameCvar() {
95 | vertx.deployVerticle("verticle_incrementing_cvar.rb", ar1 -> {
96 | assertTrue(ar1.succeeded());
97 | assertEquals(1, callbacks.size());
98 | assertEquals(1, callbacks.get(0).get().intValue());
99 | vertx.deployVerticle("verticle_incrementing_cvar.rb", ar2 -> {
100 | assertTrue(ar2.succeeded());
101 | assertEquals(2, callbacks.size());
102 | assertEquals(1, callbacks.get(0).get().intValue());
103 | assertEquals(1, callbacks.get(1).get().intValue());
104 | testComplete();
105 | });
106 | });
107 | await();
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/lang/ruby/LoadingTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import io.vertx.test.core.VertxTestBase;
4 | import org.junit.After;
5 | import org.junit.Test;
6 |
7 | import java.io.File;
8 | import java.io.FileInputStream;
9 | import java.io.FileOutputStream;
10 | import java.io.IOException;
11 | import java.net.MalformedURLException;
12 | import java.net.URL;
13 | import java.net.URLClassLoader;
14 | import java.util.jar.Attributes;
15 | import java.util.jar.JarEntry;
16 | import java.util.jar.JarOutputStream;
17 | import java.util.jar.Manifest;
18 |
19 | /**
20 | * @author Clement Escoffier
21 | */
22 | public class LoadingTest extends VertxTestBase {
23 |
24 | private static boolean deployed;
25 | private ClassLoader orig;
26 |
27 | public synchronized static void deployed() {
28 | deployed = true;
29 | }
30 |
31 | @After
32 | public void restoreTCCL() {
33 | Thread.currentThread().setContextClassLoader(orig);
34 | }
35 |
36 | @Test
37 | public void testLoadingARubyFileFromCustomClassloader() throws MalformedURLException {
38 | File external = new File("src/test/external-test-resources");
39 | orig = Thread.currentThread().getContextClassLoader();
40 | URLClassLoader custom = new URLClassLoader(new URL[]{external.toURI().toURL()});
41 | Thread.currentThread().setContextClassLoader(custom);
42 | deployed = false;
43 | vertx.deployVerticle("require/simple_verticle.rb");
44 | assertWaitUntil(() -> deployed);
45 | }
46 |
47 | @Test
48 | public void testLoadingARubyFileEmbeddedInAJarLoadedFromCustomClassloader() throws IOException {
49 | File jar = createJar();
50 | orig = Thread.currentThread().getContextClassLoader();
51 | URLClassLoader custom = new URLClassLoader(new URL[]{jar.toURI().toURL()});
52 | Thread.currentThread().setContextClassLoader(custom);
53 | deployed = false;
54 | vertx.deployVerticle("require/simple_verticle.rb");
55 | assertWaitUntil(() -> deployed);
56 | }
57 |
58 | private File createJar() throws IOException {
59 | File file = File.createTempFile("ruby-require-test", ".jar");
60 | Manifest manifest = new Manifest();
61 | manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
62 | JarOutputStream target = new JarOutputStream(new FileOutputStream(file), manifest);
63 |
64 | File external = new File("src/test/external-test-resources/foo/bar.rb");
65 | JarEntry bar = new JarEntry("foo/bar.rb");
66 | bar.setTime(external.lastModified());
67 | target.putNextEntry(bar);
68 |
69 | byte buffer[] = new byte[1024];
70 | FileInputStream in = new FileInputStream(external);
71 | while (true) {
72 | int nRead = in.read(buffer, 0, buffer.length);
73 | if (nRead <= 0)
74 | break;
75 | target.write(buffer, 0, nRead);
76 | }
77 | in.close();
78 | target.close();
79 | return file;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/lang/ruby/RubyTestBase.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import org.junit.Rule;
4 | import org.junit.rules.TestName;
5 |
6 | import javax.script.ScriptEngine;
7 | import javax.script.ScriptEngineManager;
8 | import javax.script.ScriptException;
9 |
10 | /**
11 | * @author Julien Viet
12 | */
13 | public class RubyTestBase {
14 |
15 | @Rule
16 | public final TestName testName = new TestName();
17 |
18 | protected void runTest(String script, String testName) {
19 | try {
20 | ScriptEngineManager manager = new ScriptEngineManager();
21 | ScriptEngine engine = manager.getEngineByName("jruby");
22 | engine.eval("require '" + script + "'");
23 | engine.eval(testName + "()");
24 | } catch (ScriptException e) {
25 | throw new AssertionError(e.getCause());
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/java/io/vertx/test/lang/ruby/VerticleTest.java:
--------------------------------------------------------------------------------
1 | package io.vertx.test.lang.ruby;
2 |
3 | import io.vertx.core.http.HttpClient;
4 | import io.vertx.core.http.HttpClientOptions;
5 | import io.vertx.core.http.HttpClientRequest;
6 | import io.vertx.core.http.HttpMethod;
7 | import io.vertx.test.core.VertxTestBase;
8 | import org.junit.Test;
9 |
10 | /**
11 | * @author Julien Viet
12 | */
13 | public class VerticleTest extends VertxTestBase {
14 |
15 | @Test
16 | public void testHttpServer() {
17 | vertx.deployVerticle("examples/simple_http_server.rb", ar -> {
18 | assertTrue(ar.succeeded());
19 | HttpClient client = vertx.createHttpClient(new HttpClientOptions());
20 | HttpClientRequest req = client.request(HttpMethod.GET, 8080, "localhost", "/");
21 | req.exceptionHandler(err -> fail());
22 | req.handler(resp -> {
23 | assertEquals(200, resp.statusCode());
24 | testComplete();
25 | });
26 | req.end();
27 | });
28 | await();
29 | }
30 |
31 | @Test
32 | public void testEventBusPingPong() throws Exception {
33 | vertx.deployVerticle("examples/bus_echo.rb", ar -> {
34 | assertTrue(ar.succeeded());
35 | vertx.eventBus().send("ping-address", "ping", onSuccess(msg -> {
36 | testComplete();
37 | }));
38 | });
39 | await();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/async_lifecycle_verticle.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
2 | def vertx_start_async future
3 | Java::IoVertxTestLangRuby::DeployTest.started
4 | $vertx.set_timer(50) { future.complete }
5 | end
6 | def vertx_stop_async future
7 | Java::IoVertxTestLangRuby::DeployTest.stopped
8 | $vertx.set_timer(50) { future.complete }
9 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/event_bus_test.rb:
--------------------------------------------------------------------------------
1 | require 'java'
2 | require 'assert'
3 | require 'vertx/vertx'
4 | require 'vertx/buffer'
5 |
6 | java_import 'java.util.concurrent.CountDownLatch'
7 | java_import 'java.util.concurrent.TimeUnit'
8 |
9 | def testSendBuffer
10 | vertx = Vertx::Vertx.vertx
11 | latch = CountDownLatch.new(1)
12 |
13 | event_bus = vertx.event_bus
14 | event_bus.consumer('foo') do |msg|
15 | Assert.equals('The quick brown fox jumps over the lazy dog', msg.body.to_string)
16 | latch.countDown
17 | end.completion_handler() do |err, v|
18 | Assert.is_nil(err)
19 | event_bus.send('foo', Vertx::Buffer.buffer('The quick brown fox jumps over the lazy dog'))
20 | end
21 |
22 | Assert.equals(latch.await(2, TimeUnit::MINUTES), true)
23 | end
24 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/examples/bus_echo.rb:
--------------------------------------------------------------------------------
1 | eb = $vertx.event_bus()
2 |
3 | eb.consumer("ping-address") { |message|
4 | message.reply "pong"
5 | }
6 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/examples/simple_http_server.rb:
--------------------------------------------------------------------------------
1 | require 'vertx/http_server'
2 | server = $vertx.create_http_server({:port=>8080,:host=>'localhost'})
3 | server.request_handler do |req|
4 | req.response.end('Hello World')
5 | end
6 | server.listen
7 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/integration_test.rb:
--------------------------------------------------------------------------------
1 | require 'java'
2 | require 'assert'
3 | require 'set'
4 | require 'ruby-codegen/helper'
5 |
6 | def test_multi_map_names
7 | map = RubyCodegen::Helper.get_multi_map
8 | actual = Set.new
9 | map.names.each { |name| actual.add(name) }
10 | Assert.equals actual, Set.new(%w(foo bar))
11 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/it/discovery/HelloServiceConsumer.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright (c) 2011-2016 The original author or authors
3 | #
4 | # All rights reserved. This program and the accompanying materials
5 | # are made available under the terms of the Eclipse Public License v1.0
6 | # and Apache License v2.0 which accompanies this distribution.
7 | #
8 | # The Eclipse Public License is available at
9 | # http://www.eclipse.org/legal/epl-v10.html
10 | #
11 | # The Apache License v2.0 is available at
12 | # http://www.opensource.org/licenses/apache2.0.php
13 | #
14 | # You may elect to redistribute this code under either of these licenses.
15 | #
16 |
17 | require 'vertx/vertx'
18 | require 'vertx-service-discovery/service_discovery'
19 | require 'test-services/hello_service'
20 | require 'vertx-service-discovery/event_bus_service'
21 |
22 | discovery = VertxServiceDiscovery::ServiceDiscovery.create($vertx, {
23 | 'backendConfiguration' => {
24 | 'backend-name' => 'io.vertx.servicediscovery.impl.DefaultServiceDiscoveryBackend'
25 | }
26 | })
27 |
28 | VertxServiceDiscovery::EventBusService.get_service_proxy_with_json_filter(discovery, {
29 | 'service.interface' => "io.vertx.test.it.service.HelloService"
30 | }, TestServices::HelloService) { |ar_err,ar|
31 | service = ar
32 | eb = $vertx.event_bus
33 | service.hello('name' => 'vert.x') { |err, res|
34 | eb.send('result', 'message' => res)
35 | }
36 | VertxServiceDiscovery::ServiceDiscovery.release_service_object(discovery, service)
37 | }
38 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/it/unit/assertions.rb:
--------------------------------------------------------------------------------
1 | require 'vertx-unit/test_suite'
2 | suite = VertxUnit::TestSuite.create 'the_suite'
3 |
4 |
5 | suite.test 'assert_null' do |context| context.assert_null(nil) end
6 | suite.test 'fail_assert_null_1' do |context| context.assert_null(0) end
7 | suite.test 'fail_assert_null_2' do |context| context.assert_null('string') end
8 | suite.test 'fail_assert_null_3' do |context| context.assert_null(0.12) end
9 | suite.test 'fail_assert_null_4' do |context| context.assert_null(true) end
10 | suite.test 'fail_assert_null_5' do |context| context.assert_null(false) end
11 | suite.test 'fail_assert_null_6' do |context| context.assert_null({}) end
12 | suite.test 'fail_assert_null_7' do |context| context.assert_null([]) end
13 |
14 | suite.test 'assert_null_with_message' do |context| context.assert_null(nil, 'the_message') end
15 | suite.test 'fail_assert_null_with_message_1' do |context| context.assert_null(0, 'the_message') end
16 | suite.test 'fail_assert_null_with_message_2' do |context| context.assert_null('string', 'the_message') end
17 | suite.test 'fail_assert_null_with_message_3' do |context| context.assert_null(0.12, 'the_message') end
18 | suite.test 'fail_assert_null_with_message_4' do |context| context.assert_null(true, 'the_message') end
19 | suite.test 'fail_assert_null_with_message_5' do |context| context.assert_null(false, 'the_message') end
20 | suite.test 'fail_assert_null_with_message_6' do |context| context.assert_null({}, 'the_message') end
21 | suite.test 'fail_assert_null_with_message_7' do |context| context.assert_null([], 'the_message') end
22 |
23 | suite.test 'assert_not_null' do |context|
24 | context.assert_not_null(0)
25 | context.assert_not_null('string')
26 | context.assert_not_null(0.12)
27 | context.assert_not_null(true)
28 | context.assert_not_null(false)
29 | context.assert_not_null({})
30 | context.assert_not_null([])
31 | end
32 | suite.test 'fail_assert_null' do |context|
33 | context.assert_not_null(nil)
34 | end
35 |
36 | suite.test 'assert_not_null_with_message' do |context|
37 | context.assert_not_null(0, 'the_message')
38 | context.assert_not_null('string', 'the_message')
39 | context.assert_not_null(0.12, 'the_message')
40 | context.assert_not_null(true, 'the_message')
41 | context.assert_not_null(false, 'the_message')
42 | context.assert_not_null({}, 'the_message')
43 | context.assert_not_null([], 'the_message')
44 | end
45 | suite.test 'fail_assert_null_with_message' do |context|
46 | context.assert_not_null(nil, 'the_message')
47 | end
48 |
49 | suite.test 'assert_equals' do |context|
50 | context.assert_equals(0, 0)
51 | context.assert_equals(10, 10)
52 | context.assert_equals(0.12, 0.12)
53 | context.assert_equals(true, true)
54 | context.assert_equals(false, false)
55 | context.assert_equals('the_string', 'the_' + 'string')
56 | context.assert_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'juu'})
57 | context.assert_equals([], [])
58 | context.assert_equals([123], [123])
59 | end
60 | suite.test 'fail_assert_equals_1' do |context| context.assert_equals(0, 1) end
61 | suite.test 'fail_assert_equals_2' do |context| context.assert_equals(0.12, 0.13) end
62 | suite.test 'fail_assert_equals_3' do |context| context.assert_equals(true, false) end
63 | suite.test 'fail_assert_equals_4' do |context| context.assert_equals(false, true) end
64 | suite.test 'fail_assert_equals_5' do |context| context.assert_equals('foo', 'bar') end
65 | suite.test 'fail_assert_equals_6' do |context| context.assert_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'daa'}) end
66 | suite.test 'fail_assert_equals_7' do |context| context.assert_equals([123], [321]) end
67 |
68 | suite.test 'assert_in_range' do |context|
69 | context.assert_in_range(0.12, 0.13, 0.02)
70 | context.assert_in_range(0.12, 0.11, 0.02)
71 | end
72 | suite.test 'fail_assert_in_range_1' do |context|
73 | context.assert_in_range(0.12, 0.15, 0.02)
74 | end
75 | suite.test 'fail_assert_in_range_2' do |context|
76 | context.assert_in_range(0.12, 0.09, 0.02)
77 | end
78 |
79 | suite.test 'assert_equals_with_message' do |context|
80 | context.assert_equals(0, 0, 'the_message')
81 | context.assert_equals(10, 10, 'the_message')
82 | context.assert_equals(0.12, 0.12, 'the_message')
83 | context.assert_equals(true, true, 'the_message')
84 | context.assert_equals(false, false, 'the_message')
85 | context.assert_equals('the_string', 'the_' + 'string', 'the_message')
86 | context.assert_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'juu'}, 'the_message')
87 | context.assert_equals([], [], 'the_message')
88 | context.assert_equals([123], [123], 'the_message')
89 | end
90 | suite.test 'fail_assert_equals_with_message_1' do |context| context.assert_equals(0, 1, 'the_message') end
91 | suite.test 'fail_assert_equals_with_message_2' do |context| context.assert_equals(0.12, 0.13, 'the_message') end
92 | suite.test 'fail_assert_equals_with_message_3' do |context| context.assert_equals(true, false, 'the_message') end
93 | suite.test 'fail_assert_equals_with_message_4' do |context| context.assert_equals(false, true, 'the_message') end
94 | suite.test 'fail_assert_equals_with_message_5' do |context| context.assert_equals('foo', 'bar', 'the_message') end
95 | suite.test 'fail_assert_equals_with_message_6' do |context| context.assert_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'daa'}, 'the_message') end
96 | suite.test 'fail_assert_equals_with_message_7' do |context| context.assert_equals([123], [321], 'the_message') end
97 |
98 | suite.test 'assert_not_equals' do |context|
99 | context.assert_not_equals(0, 1)
100 | context.assert_not_equals(0.12, 0.13)
101 | context.assert_not_equals(true, false)
102 | context.assert_not_equals(false, true)
103 | context.assert_not_equals('foo', 'bar')
104 | context.assert_not_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'daa'})
105 | context.assert_not_equals([123], [321])
106 | end
107 | suite.test 'fail_assert_equals_1' do |context| context.assert_not_equals(0, 0) end
108 | suite.test 'fail_assert_equals_2' do |context| context.assert_not_equals(0.12, 0.12) end
109 | suite.test 'fail_assert_equals_3' do |context| context.assert_not_equals(true, true) end
110 | suite.test 'fail_assert_equals_4' do |context| context.assert_not_equals(false, false) end
111 | suite.test 'fail_assert_equals_5' do |context| context.assert_not_equals('the_string', 'the_' + 'string') end
112 | suite.test 'fail_assert_equals_6' do |context| context.assert_not_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'juu'}) end
113 | suite.test 'fail_assert_equals_7' do |context| context.assert_not_equals([], []) end
114 | suite.test 'fail_assert_equals_8' do |context| context.assert_not_equals([123], [123]) end
115 |
116 | suite.test 'assert_not_equals_with_message' do |context|
117 | context.assert_not_equals(0, 1, 'the_message')
118 | context.assert_not_equals(0.12, 0.13, 'the_message')
119 | context.assert_not_equals(true, false, 'the_message')
120 | context.assert_not_equals(false, true, 'the_message')
121 | context.assert_not_equals('foo', 'bar', 'the_message')
122 | context.assert_not_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'daa'}, 'the_message')
123 | context.assert_not_equals([123], [321], 'the_message')
124 | end
125 | suite.test 'fail_assert_equals_with_message_1' do |context| context.assert_not_equals(0, 0, 'the_message') end
126 | suite.test 'fail_assert_equals_with_message_2' do |context| context.assert_not_equals(0.12, 0.12, 'the_message') end
127 | suite.test 'fail_assert_equals_with_message_3' do |context| context.assert_not_equals(true, true, 'the_message') end
128 | suite.test 'fail_assert_equals_with_message_4' do |context| context.assert_not_equals(false, false, 'the_message') end
129 | suite.test 'fail_assert_equals_with_message_5' do |context| context.assert_not_equals('the_string', 'the_' + 'string', 'the_message') end
130 | suite.test 'fail_assert_equals_with_message_6' do |context| context.assert_not_equals({:foo=>1,:bar=>'juu'}, {:foo=>1,:bar=>'juu'}, 'the_message') end
131 | suite.test 'fail_assert_equals_with_message_7' do |context| context.assert_not_equals([], [], 'the_message') end
132 | suite.test 'fail_assert_equals_with_message_8' do |context| context.assert_not_equals([123], [123], 'the_message') end
133 |
134 | suite.test 'assert_true' do |context| context.assert_true(true) end
135 | suite.test 'fail_assert_true' do |context| context.assert_true(false) end
136 |
137 | suite.test 'assert_true_with_message' do |context| context.assert_true(true, 'the_message') end
138 | suite.test 'fail_true_with_message' do |context| context.assert_true(false, 'the_message') end
139 |
140 | suite.test 'assert_false' do |context| context.assert_false(false) end
141 | suite.test 'fail_assert_false' do |context| context.assert_false(true) end
142 |
143 | suite.test 'assert_false_with_message' do |context| context.assert_false(false, 'the_message') end
144 | suite.test 'fail_assert_false_with_message' do |context| context.assert_false(true, 'the_message') end
145 |
146 | suite.test 'fail_' do |context|
147 | context.fail
148 | end
149 |
150 | suite.test 'fail_with_message' do |context|
151 | context.fail 'the_message'
152 | end
153 |
154 | suite.run $vertx, { :reporters => [ { :to => 'bus:assert_tests' }] }
155 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/it/unit/failing.rb:
--------------------------------------------------------------------------------
1 | require 'vertx-unit/test_suite'
2 |
3 | def vertx_start_async start_future
4 | suite = VertxUnit::TestSuite.create('my_suite').test 'timer_test' do |context|
5 | async = context.async
6 | $vertx.set_timer 50 do
7 | context.fail Exception.new('the_failure')
8 | end
9 | end
10 | suite.run.resolve start_future
11 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/lifecycle_verticle.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
2 | def vertx_start
3 | Java::IoVertxTestLangRuby::DeployTest.started
4 | end
5 | def vertx_stop
6 | Java::IoVertxTestLangRuby::DeployTest.stopped
7 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/require/simple_verticle.rb:
--------------------------------------------------------------------------------
1 | require 'foo/bar'
2 |
3 | Java::IoVertxTestLangRuby::LoadingTest.deployed
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/simple_verticle.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_incrementing_cvar.rb:
--------------------------------------------------------------------------------
1 | class Whatever
2 | @@test_cvar = 0
3 | def self.value
4 | @@test_cvar
5 | end
6 | def self.inc
7 | @@test_cvar += 1
8 | end
9 | end
10 | Whatever.inc
11 | Java::IoVertxTestLangRuby::IsolationTest.registerCallback { Whatever.value }
12 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_incrementing_global.rb:
--------------------------------------------------------------------------------
1 | if $global_var == nil
2 | $global_var = 1
3 | else
4 | $global_var += 1
5 | end
6 | Java::IoVertxTestLangRuby::IsolationTest.registerCallback { $global_var }
7 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_incrementing_ivar.rb:
--------------------------------------------------------------------------------
1 | if @test_ivar == nil
2 | @test_ivar = 1
3 | else
4 | @test_ivar += 1
5 | end
6 | Java::IoVertxTestLangRuby::IsolationTest.registerCallback { @test_ivar }
7 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_incrementing_local.rb:
--------------------------------------------------------------------------------
1 | if defined?(test_local).nil?
2 | test_local = 1
3 | else
4 | test_local += 1
5 | end
6 | Java::IoVertxTestLangRuby::IsolationTest.registerCallback { test_local }
7 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_raising_error_in_async_start.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
2 | def vertx_start_async future
3 | Java::IoVertxTestLangRuby::DeployTest.started
4 | $vertx.set_timer(50) { future.fail "the_error" }
5 | end
6 | def vertx_stop_async future
7 | Java::IoVertxTestLangRuby::DeployTest.stopped
8 | $vertx.set_timer(50) { future.complete }
9 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_raising_error_in_async_stop.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
2 | def vertx_start_async future
3 | Java::IoVertxTestLangRuby::DeployTest.started
4 | $vertx.set_timer(50) { future.complete }
5 | end
6 | def vertx_stop_async future
7 | Java::IoVertxTestLangRuby::DeployTest.stopped
8 | $vertx.set_timer(50) { future.fail "the_error" }
9 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_raising_error_in_run.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
2 | raise 'the_error'
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_raising_error_in_start.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
2 | def vertx_start
3 | Java::IoVertxTestLangRuby::DeployTest.started
4 | raise 'the_error'
5 | end
6 | def vertx_stop
7 | Java::IoVertxTestLangRuby::DeployTest.stopped
8 | end
9 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_raising_error_in_stop.rb:
--------------------------------------------------------------------------------
1 | Java::IoVertxTestLangRuby::DeployTest.deployed
2 | def vertx_start
3 | Java::IoVertxTestLangRuby::DeployTest.started
4 | end
5 | def vertx_stop
6 | Java::IoVertxTestLangRuby::DeployTest.stopped
7 | raise 'the_error'
8 | end
9 |
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_requiring_gem.rb:
--------------------------------------------------------------------------------
1 | require 'test_gem'
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_sharing_global_1.rb:
--------------------------------------------------------------------------------
1 | if $test_global == nil
2 | $test_global = 1
3 | end
4 |
5 | Java::IoVertxTestLangRuby::IsolationTest.registerCallback do
6 | $test_global
7 | end
--------------------------------------------------------------------------------
/vertx-lang-ruby/src/test/resources/verticle_sharing_global_2.rb:
--------------------------------------------------------------------------------
1 | if $test_global == nil
2 | $test_global = 2
3 | end
4 |
5 | Java::IoVertxTestLangRuby::IsolationTest.registerCallback do
6 | $test_global
7 | end
--------------------------------------------------------------------------------