Sha256: ff1dbd760f5defbf94e7ed9bc12f9b50720c1a46d347d84bc8a514696b101ca3
Contents?: true
Size: 1.92 KB
Versions: 5
Compression:
Stored size: 1.92 KB
Contents
require File.expand_path(File.join(File.dirname(__FILE__),'../spec_helper')) require 'lib/lock_jar/class_loader' describe LockJar::ClassLoader, "#isolate" do if Naether.platform != 'java' pending "need tests for RJB backed classloader" else it "should create a SimpleEmail" do # Generate the IsolateJarfile.lock LockJar.lock( :lockfile => 'tmp/IsolateJarfile.lock' ) do jar 'org.apache.commons:commons-email:1.2' end email = LockJar::ClassLoader.new( 'tmp/IsolateJarfile.lock' ).isolate do email = new_instance( 'org.apache.commons.mail.SimpleEmail' ) email.setSubject( 'test subject' ) email end email.getSubject().should eql 'test subject' unless $CLASSPATH.nil? $CLASSPATH.to_a.join(' ').should_not =~ /commons-email-1\.2\.jar/ end expect { org.apache.commons.mail.SimpleEmail.new }.to raise_error end it "should create a JsonFactory and ObjectMapper" do # Generate the IsolateJarfile.lock LockJar.lock( :lockfile => 'tmp/IsolateJarfile.lock' ) do jar 'com.fasterxml.jackson.core:jackson-core:2.0.6' jar 'com.fasterxml.jackson.core:jackson-databind:2.0.6' end json = '{ "test1": "1test1", "test2": "2test2"}' map = LockJar::ClassLoader.new( 'tmp/IsolateJarfile.lock' ).isolate do factory = new_instance( 'com.fasterxml.jackson.core.JsonFactory' ) mapper = new_instance( 'com.fasterxml.jackson.databind.ObjectMapper', factory) mapper.readValue(json, java.util.Map.java_class) end map.get('test1').should eql "1test1" map.get('test2').should eql "2test2" unless $CLASSPATH.nil? $CLASSPATH.to_a.join(' ').should_not =~ /jackson-databind-2\.0\.6\.jar/ end expect { com.fasterxml.jackson.core.JsonFactory.new }.to raise_error end end end
Version data entries
5 entries across 5 versions & 1 rubygems