예제 #1
0
  Class<?> loadClass(String className) throws ClassNotFoundException {

    if (testClasses.contains(className) == false)
      throw new ClassNotFoundException("Class '" + className + "' not found in: " + testClasses);

    Module module = depUnit.getAttachment(Attachments.MODULE);
    BundleAssociation.setBundle(getAssociatedBundle(module));

    Class<?> testClass = module.getClassLoader().loadClass(className);

    ServiceTargetAssociation.setServiceTarget(serviceTarget);
    return testClass;
  }
예제 #2
0
  Class<?> loadClass(String className) throws ClassNotFoundException {

    if (testClasses.contains(className) == false)
      throw new ClassNotFoundException("Class '" + className + "' not found in: " + testClasses);

    XBundle bundle = depUnit.getAttachment(OSGiConstants.INSTALLED_BUNDLE_KEY);
    Module module = depUnit.getAttachment(Attachments.MODULE);
    if (bundle == null && module == null)
      throw new IllegalStateException("Cannot determine deployment type: " + depUnit);

    Class<?> testClass;
    if (bundle != null) {
      testClass = bundle.loadClass(className);
      BundleAssociation.setBundle(bundle);
    } else {
      testClass = module.getClassLoader().loadClass(className);
    }

    return testClass;
  }