diff --git a/antlib/extra.xml b/antlib/extra.xml index 0a51146c1d7..2181ba426d5 100644 --- a/antlib/extra.xml +++ b/antlib/extra.xml @@ -25,7 +25,7 @@ build jruby-complete.jar - + @@ -137,7 +137,7 @@ build jruby-complete.jar - + @@ -153,7 +153,7 @@ build jruby-complete.jar - + @@ -169,7 +169,7 @@ build jruby-complete.jar - + @@ -461,7 +461,7 @@ build jruby-complete.jar - + @@ -515,4 +515,4 @@ build jruby-complete.jar - \ No newline at end of file + diff --git a/core/src/main/java/org/jruby/RubyString.java b/core/src/main/java/org/jruby/RubyString.java index 7c27b6b75df..baf8e4c5cc3 100644 --- a/core/src/main/java/org/jruby/RubyString.java +++ b/core/src/main/java/org/jruby/RubyString.java @@ -5804,11 +5804,17 @@ public static ByteList encodeBytelist(CharSequence value, Encoding encoding) { public Object toJava(Class target) { if (target.isAssignableFrom(String.class)) { return decodeString(); - } else if (target.isAssignableFrom(ByteList.class)) { + } + if (target.isAssignableFrom(ByteList.class)) { return value; - } else { - return super.toJava(target); } + if (target == Character.class || target == Character.TYPE) { + if ( strLength() != 1 ) { + throw getRuntime().newArgumentError("could not coerce string of length " + strLength() + " (!= 1) into a char"); + } + return decodeString().charAt(0); + } + return super.toJava(target); } /** diff --git a/core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java b/core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java index 5f06ebbcb2d..87cbda05dfd 100644 --- a/core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java +++ b/core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java @@ -877,7 +877,7 @@ private IRubyObject op_quo19_20(ThreadContext context, IRubyObject other) { int len = value.precision() + preciseOther.value.precision(); int pow = len / 4; int precision = (pow + 1) * 4 * 2; - + return op_div(context, preciseOther, getRuntime().newFixnum(precision)); } @@ -929,9 +929,18 @@ public IRubyObject op_div(ThreadContext context, IRubyObject other, IRubyObject // MRI behavior: "If digits is 0, the result is the same as the / operator." if (scale == 0) return op_quo(context, other); - MathContext mathContext = new MathContext(scale, getRoundingMode(context.runtime)); - return new RubyBigDecimal(context.runtime, - value.divide(val.value, mathContext)).setResult(scale); + if (isZero()) { + return newZero(getRuntime(), zeroSign * val.value.signum()); + } + + if (scale == 0) { + // MRI behavior: "If digits is 0, the result is the same as the / operator." + return op_quo(context, other); + } else { + MathContext mathContext = new MathContext(scale, getRoundingMode(context.runtime)); + return new RubyBigDecimal(getRuntime(), + value.divide(val.value, mathContext)).setResult(scale); + } } @JRubyMethod(name = "div") diff --git a/core/src/test/java/org/jruby/embed/IsolatedScriptingContainerTest.java b/core/src/test/java/org/jruby/embed/IsolatedScriptingContainerTest.java new file mode 100644 index 00000000000..f7a69bcb7b5 --- /dev/null +++ b/core/src/test/java/org/jruby/embed/IsolatedScriptingContainerTest.java @@ -0,0 +1,48 @@ +package org.jruby.embed; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.net.URL; +import java.net.URLClassLoader; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class IsolatedScriptingContainerTest { + + static ClassLoader cl; + + @BeforeClass + public static void setupClassLoader() { + cl = Thread.currentThread().getContextClassLoader(); + // make sure we have classloader which does not find jruby + ClassLoader c = new URLClassLoader( new URL[] {}, null ); + try { + c.loadClass( "org.jruby.embed.ScriptingContainer" ); + fail( "this classloader shall not find jruby" ); + } + catch( ClassNotFoundException expected){} + // set it as context classloader + Thread.currentThread().setContextClassLoader( c ); + } + + @AfterClass + public static void restClassLoader() { + Thread.currentThread().setContextClassLoader( cl ); + } + + @Test + public void testIsolatedScriptingContainer() throws Exception { + // we do have an instance of "jruby" loaded via some other classloader + //System.setProperty("jruby.debug.loadService", "true"); + ScriptingContainer instance = new IsolatedScriptingContainer(); + String result = instance.runScriptlet( "$LOAD_PATH" ).toString(); + assertNotNull(result); + + assertEquals(instance.runScriptlet("JRuby.runtime.jruby_class_loader.parent" ), cl ); + assertEquals(ScriptingContainer.class.getClassLoader(), cl); + } +} \ No newline at end of file diff --git a/core/src/test/resources/rubygems/defaults/jruby.rb b/core/src/test/resources/rubygems/defaults/jruby.rb new file mode 100644 index 00000000000..311394dbb43 --- /dev/null +++ b/core/src/test/resources/rubygems/defaults/jruby.rb @@ -0,0 +1,9 @@ +# dummy to run IsolatedScriptingContainerTest +module Gem + class Specification + def self.reset + end + def self.add_dir *args + end + end +end diff --git a/ext/pom.xml b/ext/pom.xml index aa57edfb5b8..9b7bb25090f 100644 --- a/ext/pom.xml +++ b/ext/pom.xml @@ -5,7 +5,7 @@ org.jruby jruby-parent - 9.0.0.0.pre1 + 9.0.0.0-SNAPSHOT jruby-ext pom diff --git a/ext/ripper/pom.xml b/ext/ripper/pom.xml index 50aba0e98f0..68c00f2a652 100644 --- a/ext/ripper/pom.xml +++ b/ext/ripper/pom.xml @@ -5,7 +5,7 @@ org.jruby jruby-ext - 9.0.0.0.pre1 + 9.0.0.0-SNAPSHOT rubygems jruby-ripper diff --git a/maven/jruby/src/it/j2ee_jetty_rack/.gitignore b/maven/jruby/src/it/j2ee_jetty_rack/.gitignore new file mode 100644 index 00000000000..5fff1d9c188 --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/.gitignore @@ -0,0 +1 @@ +pkg diff --git a/maven/jruby/src/it/j2ee_jetty_rack/.jrubydir b/maven/jruby/src/it/j2ee_jetty_rack/.jrubydir new file mode 100644 index 00000000000..b02dae4d683 --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/.jrubydir @@ -0,0 +1,4 @@ +. +config.ru +gems +specifications \ No newline at end of file diff --git a/maven/jruby/src/it/j2ee_jetty_rack/Mavenfile b/maven/jruby/src/it/j2ee_jetty_rack/Mavenfile new file mode 100644 index 00000000000..f4d6832ccf1 --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/Mavenfile @@ -0,0 +1,80 @@ +#-*- mode: ruby -*- + +# it is war-file +packaging 'war' + +# get jruby dependencies +properties( 'jruby.version' => '@project.version@', + 'jruby.plugins.version' => '1.0.7', + 'project.build.sourceEncoding' => 'utf-8', + 'public.dir' => '${basedir}/public' ) + +pom( 'org.jruby:jruby', '${jruby.version}' ) + +jar( 'org.jruby.rack:jruby-rack', '1.1.18', + :exclusions => [ 'org.jruby:jruby-complete' ] ) + + +# ruby-maven will dump an equivalent pom.xml +properties[ 'tesla.dump.pom' ] = 'pom.xml' + +# a gem to be used +gem 'flickraw', '0.9.7' + +repository( :url => 'http://rubygems-proxy.torquebox.org/releases', + :id => 'rubygems-releases' ) + +jruby_plugin :gem, :includeRubygemsInResources => true, :includeLibDirectoryInResources => true do + execute_goal :initialize +end + +# not really needed but for completeness: +# pack the war with that ruby-like directory layout +plugin( :war, '2.2', + :warSourceDirectory => '${public.dir}' ) + +resource :directory => '${basedir}', :includes => [ 'config.ru', '.jrubydir' ] + +# start jetty for the tests +plugin( 'org.eclipse.jetty:jetty-maven-plugin', '9.1.3.v20140225', + :path => '/', + :webAppSourceDirectory => '${public.dir}', + :stopPort => 9999, + :stopKey => 'foo' ) do + execute_goal( 'start', :id => 'start jetty', :phase => 'pre-integration-test', :daemon => true ) + execute_goal( 'stop', :id => 'stop jetty', :phase => 'post-integration-test' ) +end + +# download files during the tests +result = nil +execute 'download', :phase => 'integration-test' do + require 'open-uri' + result = open( 'http://localhost:8080' ).string + puts result +end + +# verify the downloads +execute 'check download', :phase => :verify do + expected = 'hello world:' + unless result.match( /^#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + expected = 'self: uri:classloader://config.ru' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + expected = 'PWD: uri:classloader://' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + expected = 'Gem.path: ."uri:classloader://",' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + # TODO get rid off this over normalization + expected = 'uri:classloader:/gems/flickraw-0.9.7' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end +end +# vim: syntax=Ruby diff --git a/maven/jruby/src/it/j2ee_jetty_rack/config.ru b/maven/jruby/src/it/j2ee_jetty_rack/config.ru new file mode 100644 index 00000000000..f1732a912f7 --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/config.ru @@ -0,0 +1,19 @@ +#-*- mode: ruby -*- + +use Rack::ShowExceptions + +require 'hello_world' + +run lambda { |env| + require 'flickraw' + [ + 200, + { + 'Content-Type' => 'text/html', + 'Cache-Control' => 'public, max-age=86400' + }, + [ "self: #{__FILE__}\n", "PWD: #{Dir.pwd}\n", "Gem.path: #{Gem.path.inspect}\n", Gem.loaded_specs['flickraw'].gem_dir + "\n", HelloWorld.new + "\n" ] + ] +} + +# vim: syntax=Ruby diff --git a/maven/jruby/src/it/j2ee_jetty_rack/lib/hello_world.rb b/maven/jruby/src/it/j2ee_jetty_rack/lib/hello_world.rb new file mode 100644 index 00000000000..f2c430ad256 --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/lib/hello_world.rb @@ -0,0 +1,7 @@ +require 'openssl' + +class HelloWorld < String + def initialize + super "hello world: #{OpenSSL::Random.random_bytes( 16 ).inspect}" + end +end diff --git a/maven/jruby/src/it/j2ee_jetty_rack/pom.xml b/maven/jruby/src/it/j2ee_jetty_rack/pom.xml new file mode 100644 index 00000000000..0dcfb9eeac8 --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/pom.xml @@ -0,0 +1,151 @@ + + + 4.0.0 + no_group_id_given + j2ee_jetty_rack + 0.0.0 + war + j2ee_jetty_rack + + @project.version@ + 1.0.7 + pom.xml + ${basedir}/public + utf-8 + 0.1.1 + + + + org.jruby + jruby + ${jruby.version} + pom + + + org.jruby.rack + jruby-rack + 1.1.18 + + + jruby-complete + org.jruby + + + + + rubygems + flickraw + 0.9.7 + gem + + + + + rubygems-releases + http://rubygems-proxy.torquebox.org/releases + + + + + + ${basedir} + + config.ru + .jrubydir + + + + + + de.saumya.mojo + gem-maven-plugin + ${jruby.plugins.version} + + + + initialize + + + + + true + true + + + + maven-war-plugin + 2.2 + + ${public.dir} + + + + org.eclipse.jetty + jetty-maven-plugin + 9.1.3.v20140225 + + + start jetty + pre-integration-test + + start + + + true + + + + stop jetty + post-integration-test + + stop + + + + + / + ${public.dir} + 9999 + foo + + + + io.tesla.polyglot + tesla-polyglot-maven-plugin + ${tesla.version} + + + download + integration-test + + execute + + + download + Mavenfile + + + + check download + verify + + execute + + + check download + Mavenfile + + + + + + io.tesla.polyglot + tesla-polyglot-ruby + ${tesla.version} + + + + + + diff --git a/maven/jruby/src/it/j2ee_jetty_rack/public/WEB-INF/.gitignore b/maven/jruby/src/it/j2ee_jetty_rack/public/WEB-INF/.gitignore new file mode 100644 index 00000000000..16d264c7acb --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/public/WEB-INF/.gitignore @@ -0,0 +1,2 @@ +classes +config.ru \ No newline at end of file diff --git a/maven/jruby/src/it/j2ee_jetty_rack/public/WEB-INF/web.xml b/maven/jruby/src/it/j2ee_jetty_rack/public/WEB-INF/web.xml new file mode 100644 index 00000000000..b944d4b3eee --- /dev/null +++ b/maven/jruby/src/it/j2ee_jetty_rack/public/WEB-INF/web.xml @@ -0,0 +1,22 @@ + + + + jruby.rack.layout_class + JRuby::Rack::ClassPathLayout + + + + RackFilter + org.jruby.rack.RackFilter + + + RackFilter + /* + + + + org.jruby.rack.RackServletContextListener + + diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/.gitignore b/maven/jruby/src/it/j2ee_tomcat_rack/.gitignore new file mode 100644 index 00000000000..5fff1d9c188 --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/.gitignore @@ -0,0 +1 @@ +pkg diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/.jrubydir b/maven/jruby/src/it/j2ee_tomcat_rack/.jrubydir new file mode 100644 index 00000000000..b02dae4d683 --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/.jrubydir @@ -0,0 +1,4 @@ +. +config.ru +gems +specifications \ No newline at end of file diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/Mavenfile b/maven/jruby/src/it/j2ee_tomcat_rack/Mavenfile new file mode 100644 index 00000000000..5e4bb7adfd3 --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/Mavenfile @@ -0,0 +1,83 @@ +#-*- mode: ruby -*- + +# it is war-file +packaging 'war' + +# get jruby dependencies +properties( 'jruby.version' => '@project.version@', + 'jruby.home' => '../../../../../', + 'jruby.plugins.version' => '1.0.3', + 'project.build.sourceEncoding' => 'utf-8', + 'public.dir' => '${basedir}/public' ) + +pom( 'org.jruby:jruby', '${jruby.version}' ) + +jar( 'org.jruby.rack:jruby-rack', '1.1.18', + :exclusions => [ 'org.jruby:jruby-complete' ] ) + + +# ruby-maven will dump an equivalent pom.xml +properties[ 'tesla.dump.pom' ] = 'pom.xml' + +# a gem to be used +gem 'flickraw', '0.9.7' + +repository( :url => 'http://rubygems-proxy.torquebox.org/releases', + :id => 'rubygems-releases' ) + +jruby_plugin :gem, :includeRubygemsInResources => true, :includeLibDirectoryInResources => true do + execute_goal :initialize +end + +# not really needed but for completeness: +# pack the war with that ruby-like directory layout +plugin( :war, '2.2', + :warSourceDirectory => '${public.dir}' ) + +resource :directory => '${basedir}', :includes => [ 'config.ru', '.jrubydir' ] + +# start tomcat for the tests +plugin( 'org.codehaus.mojo:tomcat-maven-plugin', '1.1', + :fork => true, :path => '/', + :warSourceDirectory => '${public.dir}' ) do + execute_goals( 'run', + :id => 'run-tomcat', + :phase => 'pre-integration-test' ) +end + +# download files during the tests +execute 'download', :phase => 'integration-test' do + require 'open-uri' + result = open( 'http://localhost:8080' ).string + File.open( 'result', 'w' ) { |f| f.puts result } + puts result +end + +# verify the downloads +execute 'check download', :phase => :verify do + result = File.read( 'result' ) + expected = 'hello world:' + unless result.match( /^#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + expected = 'self: uri:classloader://config.ru' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + expected = 'PWD: uri:classloader://' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + expected = 'Gem.path: ."uri:classloader://",' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end + # TODO get rid off this over normalization + #expected = 'uri:classloader:/gems/flickraw-0.9.7' + # TODO find out why travis find the gem on filesystem + expected = 'target/classes/gems/flickraw-0.9.7' + unless result.match( /#{expected}/ ) + raise "missed expected string in download: #{expected}" + end +end +# vim: syntax=Ruby diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/config.ru b/maven/jruby/src/it/j2ee_tomcat_rack/config.ru new file mode 100644 index 00000000000..e7986182db5 --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/config.ru @@ -0,0 +1,19 @@ +#-*- mode: ruby -*- + +use Rack::ShowExceptions + +require 'hello_world' + +run lambda { |env| + require 'flickraw' + [ + 200, + { + 'Content-Type' => 'text/html', + 'Cache-Control' => 'public, max-age=86400' + }, + [ "self: #{__FILE__}\n", "PWD: #{Dir.pwd}\n", "Gem.path: #{Gem.path.inspect}\n","Gem::Specification.dirs: #{Gem::Specification.dirs.inspect}\n", Gem.loaded_specs['flickraw'].gem_dir + "\n", HelloWorld.new + "\n" ] + ] +} + +# vim: syntax=Ruby diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/lib/hello_world.rb b/maven/jruby/src/it/j2ee_tomcat_rack/lib/hello_world.rb new file mode 100644 index 00000000000..f2c430ad256 --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/lib/hello_world.rb @@ -0,0 +1,7 @@ +require 'openssl' + +class HelloWorld < String + def initialize + super "hello world: #{OpenSSL::Random.random_bytes( 16 ).inspect}" + end +end diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/pom.xml b/maven/jruby/src/it/j2ee_tomcat_rack/pom.xml new file mode 100644 index 00000000000..f3b76c5f939 --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/pom.xml @@ -0,0 +1,141 @@ + + + 4.0.0 + no_group_id_given + j2ee_tomcat_rack + 0.0.0 + war + j2ee_tomcat_rack + + ../../../../../ + @project.version@ + 1.0.3 + pom.xml + ${basedir}/public + utf-8 + 0.1.1 + + + + org.jruby + jruby + ${jruby.version} + pom + + + org.jruby.rack + jruby-rack + 1.1.18 + + + jruby-complete + org.jruby + + + + + rubygems + flickraw + 0.9.7 + gem + + + + + rubygems-releases + http://rubygems-proxy.torquebox.org/releases + + + + + + ${basedir} + + config.ru + .jrubydir + + + + + + de.saumya.mojo + gem-maven-plugin + ${jruby.plugins.version} + + + + initialize + + + + + true + true + + + + maven-war-plugin + 2.2 + + ${public.dir} + + + + org.codehaus.mojo + tomcat-maven-plugin + 1.1 + + + run-tomcat + pre-integration-test + + run + + + + + true + / + ${public.dir} + + + + io.tesla.polyglot + tesla-polyglot-maven-plugin + ${tesla.version} + + + download + integration-test + + execute + + + download + Mavenfile + + + + check download + verify + + execute + + + check download + Mavenfile + + + + + + io.tesla.polyglot + tesla-polyglot-ruby + ${tesla.version} + + + + + + diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/public/WEB-INF/.gitignore b/maven/jruby/src/it/j2ee_tomcat_rack/public/WEB-INF/.gitignore new file mode 100644 index 00000000000..16d264c7acb --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/public/WEB-INF/.gitignore @@ -0,0 +1,2 @@ +classes +config.ru \ No newline at end of file diff --git a/maven/jruby/src/it/j2ee_tomcat_rack/public/WEB-INF/web.xml b/maven/jruby/src/it/j2ee_tomcat_rack/public/WEB-INF/web.xml new file mode 100644 index 00000000000..b944d4b3eee --- /dev/null +++ b/maven/jruby/src/it/j2ee_tomcat_rack/public/WEB-INF/web.xml @@ -0,0 +1,22 @@ + + + + jruby.rack.layout_class + JRuby::Rack::ClassPathLayout + + + + RackFilter + org.jruby.rack.RackFilter + + + RackFilter + /* + + + + org.jruby.rack.RackServletContextListener + + diff --git a/maven/jruby/src/it/runnable/Mavenfile b/maven/jruby/src/it/runnable/Mavenfile index 0d8b5e3a267..ed3212e13e2 100644 --- a/maven/jruby/src/it/runnable/Mavenfile +++ b/maven/jruby/src/it/runnable/Mavenfile @@ -40,7 +40,10 @@ build do directory 'pkg' end -jruby_plugin!( :gem, :includeRubygemsInResources => true ) +jruby_plugin!( :gem, '1.0.8', + # need a jruby-complete from maven central here + :jrubyVersion => '1.7.19', + :includeRubygemsInResources => true ) if File.file?('Jarfile.lock') phase :package do diff --git a/maven/jruby/src/it/runnable/pom.xml b/maven/jruby/src/it/runnable/pom.xml new file mode 100644 index 00000000000..7e297d88399 --- /dev/null +++ b/maven/jruby/src/it/runnable/pom.xml @@ -0,0 +1,335 @@ + + + 4.0.0 + no_group_id_given + runnable + 0.0.0 + runnable + + true + @project.version@ + 1.0.3 + utf-8 + pom.xml + 0.1.1 + + + + rubygems + bundler + 1.7.7 + gem + + + org.jruby + jruby + ${jruby.version} + pom + + + + + rubygems-releases + http://rubygems-proxy.torquebox.org/releases + + + + + + ${basedir} + + config.ru + *file + *file.lock + .jbundler/classpath.rb + lib/** + app/** + config/** + vendor/** + spec/** + + + + META-INF/jruby.home/bin + ${project.build.directory}/rubygems/bin + + * + + + + pkg + + + maven-jar-plugin + 2.4 + + + prepare-package + + jar + + + + + . + runnable + + + + maven-clean-plugin + 2.4 + + + + . + + runnable.jar + */**/*.jar + + + + + + + de.saumya.mojo + gem-maven-plugin + ${jruby.plugins.version} + + + install gems + + initialize + + + + + 1.7.19 + true + + + + maven-dependency-plugin + + + copy jar dependencies + package + + copy + + + + + org.bouncycastle + bcpkix-jdk15on + jar + 1.49 + + ${project.build.outputDirectory}/org/bouncycastle/bcpkix-jdk15on/1.49 + + + org.slf4j + slf4j-simple + jar + 1.6.4 + + ${project.build.outputDirectory}/org/slf4j/slf4j-simple/1.6.4 + + + org.bouncycastle + bcprov-jdk15on + jar + 1.49 + + ${project.build.outputDirectory}/org/bouncycastle/bcprov-jdk15on/1.49 + + + org.slf4j + slf4j-api + jar + 1.6.4 + + ${project.build.outputDirectory}/org/slf4j/slf4j-api/1.6.4 + + + + + + + + maven-shade-plugin + + + pack + + shade + + + + + rubygems:* + + + + + Main + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2 + + + rake -T + package + + exec + + + + -jar + runnable.jar + -S + rake + -T + + + + + rspec + package + + exec + + + + -jar + runnable.jar + -S + rspec + + + + + + java + + ${basedir} + ${basedir} + ${basedir} + ${basedir} + + + + + io.tesla.polyglot + tesla-polyglot-maven-plugin + ${tesla.version} + + + create jrubydir info + process-resources + + execute + + + create jrubydir info + Mavenfile + + + + + + io.tesla.polyglot + tesla-polyglot-ruby + ${tesla.version} + + + + + + + + gemfile + + + Gemfile.lock + + + + + rubygems + rspec + [2.14,2.99999] + gem + + + rubygems + rake + [10.3,10.99999] + gem + + + rubygems + jbundler + 0.7.1 + gem + + + + + gemfile_lock + + + Gemfile.lock + + + + + + de.saumya.mojo + gem-maven-plugin + ${jruby.plugins.version} + + + install gem sets for compile + initialize + + sets + + + compile + + 2.99.0 + 2.99.2 + 2.99.2 + 1.2.5 + 2.99.2 + 10.3.2 + 0.7.1 + 0.1.7 + 1.0.7 + 1.0.3 + 0.1.1 + 0.0.4 + 0.3.4 + 0.11.0 + 1.0.0 + 0.0.9 + 3.1.1.0.8 + 3.1.1 + + + + + + + + + + diff --git a/maven/jruby/src/it/runnable/spec/one_spec.rb b/maven/jruby/src/it/runnable/spec/one_spec.rb index 5134835f374..9776c592e58 100644 --- a/maven/jruby/src/it/runnable/spec/one_spec.rb +++ b/maven/jruby/src/it/runnable/spec/one_spec.rb @@ -3,7 +3,7 @@ describe "something" do it "does something" do $CLASSPATH.size.should == 4 - Jars.home.should == 'uri:classloader://' + Jars.home.should == 'uri:classloader:/' Dir.pwd.should == 'uri:classloader://' $LOAD_PATH.each do |lp| lp.should =~ /^uri:classloader:|runnable.jar!\// diff --git a/maven/jruby/src/it/runnable/src/main/java/Main.java b/maven/jruby/src/it/runnable/src/main/java/Main.java index 12c98156a0a..2eb0606b54f 100644 --- a/maven/jruby/src/it/runnable/src/main/java/Main.java +++ b/maven/jruby/src/it/runnable/src/main/java/Main.java @@ -30,9 +30,9 @@ private Main(org.jruby.RubyInstanceConfig config) { config.setHardExit(true); config.setCurrentDirectory( "uri:classloader://" ); config.setJRubyHome( "uri:classloader://META-INF/jruby.home" ); - config.setLoadPaths( java.util.Arrays.asList("uri:classloader://") ); + config.setLoadPaths( java.util.Arrays.asList("uri:classloader:/") ); java.util.Map env = new java.util.HashMap( System.getenv() ); - env.put( "JARS_HOME", "uri:classloader://" ); + env.put( "JARS_HOME", "uri:classloader:/" ); // needed for jruby version before 1.7.19 env.put( "BUNDLE_DISABLE_SHARED_GEMS", "true" ); config.setEnvironment( env ); diff --git a/rakelib/test.rake b/rakelib/test.rake index 1fbb66d13c5..3812ffb0bd3 100644 --- a/rakelib/test.rake +++ b/rakelib/test.rake @@ -107,7 +107,8 @@ namespace :test do end t.test_files = files t.verbose = true - t.ruby_opts << '-J-ea' + t.test_files = files_in_file 'test/slow.index' + t.ruby_opts << '-J-ea' << '--1.8' t.ruby_opts << '-J-cp target/test-classes' end diff --git a/spec/regression/GH-2182_struct_inspect_has_ascii_encoding_spec.rb b/spec/regression/GH-2182_struct_inspect_has_ascii_encoding_spec.rb new file mode 100644 index 00000000000..efd02ff89c4 --- /dev/null +++ b/spec/regression/GH-2182_struct_inspect_has_ascii_encoding_spec.rb @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- + +# https://github.com/jruby/jruby/issues/2182 +if RUBY_VERSION > '1.9' + describe 'Struct#inspect' do + it 'returns correct value' do + s1 = Struct.new(:aa).new("ΆἅἇἈ") + s1.inspect.should == "#" + s1.inspect.encoding.should == Encoding::UTF_8 + + s2 = Struct.new(:a, :b).new("ΆἅἇἈ", "abc") + s2.inspect.should == "#" + s2.inspect.encoding.should == Encoding::UTF_8 + + s3 = Struct.new(:b).new("abc") + s3.inspect.should == "#" + s3.inspect.encoding.should == Encoding::ASCII_8BIT + + s4 = Struct.new(:"ΆἅἇἈ").new("aa") + s4.inspect.should == "#" + s4.inspect.encoding.should == Encoding::UTF_8 + end + end +end diff --git a/spec/regression/GH-2524_bigdecimal_loss_of_precision_with_different_excution_order_spec.rb b/spec/regression/GH-2524_bigdecimal_loss_of_precision_with_different_excution_order_spec.rb index c948e52a32b..d0f8c48295c 100644 --- a/spec/regression/GH-2524_bigdecimal_loss_of_precision_with_different_excution_order_spec.rb +++ b/spec/regression/GH-2524_bigdecimal_loss_of_precision_with_different_excution_order_spec.rb @@ -9,4 +9,3 @@ expect(r1).to eq(r2) end end - diff --git a/test/jruby/test_primitive_to_java.rb b/test/jruby/test_primitive_to_java.rb index 35a80c9b2cf..b9c82770946 100644 --- a/test/jruby/test_primitive_to_java.rb +++ b/test/jruby/test_primitive_to_java.rb @@ -1,11 +1,35 @@ +# encoding: UTF-8 require 'test/unit' -require 'java' class TestPrimitiveToJava < Test::Unit::TestCase + + def setup; super; require 'java' end + def test_primitive_conversion t = Time.now date = t.to_java(java.util.Date) assert_equal(t.to_i, date.time / 1000, "Ruby time #{t} not converted to java date correctly: #{date}") end + + def test_char_conversion + str = 'a' + char = str.to_java(:char) + assert_instance_of Java::JavaLang::Character, char + + str = ' ' + char = str.to_java(Java::char) + assert_equal 32, char.charValue + + str = '0' + char = str.to_java(java.lang.Character) + assert_equal 48.to_java(:char), char + + assert_equal 228, 'ä'.to_java(:char).charValue unless RUBY_VERSION.index('1.8') == 0 + + assert_raises(ArgumentError) { ''.to_java(:char) } + assert_raises(ArgumentError) { 'už'.to_java('java.lang.Character') } + 'už'[1].to_java('java.lang.Character') unless RUBY_VERSION.index('1.8') == 0 + end + end diff --git a/test/pom.xml b/test/pom.xml index 359e9fb42e2..12f868e46fe 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -240,7 +240,7 @@ - + @@ -269,7 +269,7 @@ - + @@ -510,7 +510,7 @@ - + @@ -628,7 +628,7 @@ - + @@ -673,7 +673,7 @@ - + @@ -716,7 +716,7 @@ - + @@ -761,7 +761,7 @@ - + @@ -806,7 +806,7 @@ - + diff --git a/test/test_adding_pem_to_x509store.rb b/test/test_adding_pem_to_x509store.rb index 1c59ebeb62d..29ffa6a6ea1 100644 --- a/test/test_adding_pem_to_x509store.rb +++ b/test/test_adding_pem_to_x509store.rb @@ -6,7 +6,7 @@ def test_adding_pem OpenSSL.debug = true # mimic what rubygems/request#add_rubygems_trusted_certs does # to find the pem certificates -p base = $LOAD_PATH.detect { |p| p =~ /ruby\/shared/ } + base = $LOAD_PATH.detect { |p| p =~ /ruby\/shared/ } pems = Dir[ File.join(base, 'rubygems/ssl_certs/*pem') ] assert_equal( 9, pems.size ) pems.each do |pem|