Ejemplo n.º 1
0
  @Test
  public void testParentContextDoesNotSeeModificationsOfStaticFields() throws Throwable {
    Context context = runIsolate(StaticFieldSetter.class);
    context.join();

    assertEquals(StaticFieldSetter.OLD_VALUE, StaticFieldSetter.staticField);
  }
Ejemplo n.º 2
0
 @Test
 public void testClassesDefinedInParentContextAreNotVisibleToChild() throws Throwable {
   try {
     Context context =
         runIsolate(ClassFinder.class, ClassPresentOnlyInParentContext.class.getName());
     context.join();
     throw new AssertionError("Isolate should not be able to find the class");
   } catch (ContextFailedException e) {
     if (e.getCause() instanceof ClassNotFoundException) {
       // expected
     } else {
       throw e;
     }
   }
 }
Ejemplo n.º 3
0
  @Test
  public void testIsolateMayLoadItsOwnVersionOfAClassDefinedInParentContext() throws Throwable {
    String fieldName = "field_existing_only_in_isolate_context";

    try {
      ClassPresentInBothContexts.class.getDeclaredField(fieldName);
      throw new AssertionError("The field should be absent in parent context");
    } catch (NoSuchFieldException e) {
      // expected
    }

    Context context =
        runIsolate(FieldTester.class, ClassPresentInBothContexts.class.getName(), fieldName);
    context.join();
  }
Ejemplo n.º 4
0
  @Test
  public void testStaticDataIsIsolatedBetweenChildContexts() throws Throwable {
    Context context1 = runIsolate(StaticFieldSetter.Party.class, "value1");
    Context context2 = runIsolate(StaticFieldSetter.Party.class, "value2");

    CyclicBarrier barrier = new CyclicBarrier(2);
    context1.send(barrier);
    context2.send(barrier);

    context1.join();
    context2.join();
  }