01: /*
02: *
03: */
04: package org.terracotta.modules.surefire_2_3;
05:
06: import org.osgi.framework.Bundle;
07: import org.osgi.framework.BundleContext;
08: import org.terracotta.modules.configuration.TerracottaConfiguratorModule;
09:
10: import com.tc.object.config.ConfigLockLevel;
11:
12: /**
13: * @author Eugene Kuleshov
14: */
15: public class SurefireTerracottaConfigurator extends
16: TerracottaConfiguratorModule {
17:
18: private static final String CLUSTERED_SUREFIRE_BUNDLE_NAME = "org.terracotta.modules.clustered_surefire_2.3";
19:
20: protected void addInstrumentation(BundleContext context) {
21: configHelper.addCustomAdapter("junit.framework.TestSuite",
22: new JUnitTestSuiteAdapter());
23: configHelper.addCustomAdapter(
24: "org.apache.maven.surefire.booter.IsolatedClassLoader",
25: new IsolatedClassLoaderAdapter());
26:
27: configHelper.addIncludePattern(
28: JUnitTestSuiteAdapter.CLUSTERED_JUNIT_BARRIER_CLASS,
29: true);
30: configHelper.addAutolock("* "
31: + JUnitTestSuiteAdapter.CLUSTERED_JUNIT_BARRIER_CLASS
32: + ".*(..)", ConfigLockLevel.WRITE);
33:
34: // find the bundle that contains the replacement classes
35: Bundle[] bundles = context.getBundles();
36: Bundle bundle = null;
37: for (int i = 0; i < bundles.length; i++) {
38: if (CLUSTERED_SUREFIRE_BUNDLE_NAME.equals(bundles[i]
39: .getSymbolicName())) {
40: bundle = bundles[i];
41: break;
42: }
43: }
44:
45: if (bundle != null) {
46: addExportedBundleClass(bundle,
47: JUnitTestSuiteAdapter.CLUSTERED_JUNIT_BARRIER_CLASS);
48: }
49: }
50:
51: }
|