Skip to content


Browse files Browse the repository at this point in the history
added small test for IsolatedScriptingContainer simulating an OSGi co…
  • Loading branch information
mkristian committed Jan 13, 2015
1 parent 3320b8a commit a042abb
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
@@ -0,0 +1,48 @@
package org.jruby.embed;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static;


import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class IsolatedScriptingContainerTest {

static ClassLoader cl;

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 );

public static void restClassLoader() {
Thread.currentThread().setContextClassLoader( cl );

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();

assertEquals(instance.runScriptlet("JRuby.runtime.jruby_class_loader.parent" ), cl );
assertEquals(ScriptingContainer.class.getClassLoader(), cl);
9 changes: 9 additions & 0 deletions core/src/test/resources/rubygems/defaults/jruby.rb
@@ -0,0 +1,9 @@
# dummy to run IsolatedScriptingContainerTest
module Gem
class Specification
def self.reset
def self.add_dir *args

0 comments on commit a042abb

Please sign in to comment.