child.run(notifier);
}
@Override
public void run(final RunNotifier notifier) {
final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();
if (SIMULATED) {
QualifierUtil.initFromFactoryProvider(new QualifierEqualityFactoryProvider() {
@Override
public QualifierEqualityFactory provide() {
return new QualifierEqualityFactory() {
@Override
public boolean isEqual(final Annotation a1, final Annotation a2) {
return a1.equals(a2);
}
@Override
public int hashCodeOf(final Annotation a1) {
return a1.hashCode();
}
};
}
});
TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() {
ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
@Override
public TaskManager get() {
return new TaskManager() {
@Override
public void execute(final Runnable task) {
service.execute(task);
}
@Override
public AsyncTask scheduleRepeating(final TimeUnit unit, final int interval, final Runnable task) {
final ScheduledFuture<?> future =
service.scheduleAtFixedRate(task, unit.toMillis(interval), 0,
java.util.concurrent.TimeUnit.MILLISECONDS);
return new AsyncTask() {
@Override
public void cancel(final boolean interrupt) {
future.cancel(true);
}
@Override
public void setExitHandler(final Runnable runnable) {
}
@Override
public boolean isCancelled() {
return future.isCancelled();
}
@Override
public boolean isFinished() {
return future.isDone();
}
};
}
@Override
public AsyncTask schedule(final TimeUnit unit, final int interval, final Runnable task) {
final ScheduledFuture<?> future =
service.schedule(task, unit.toMillis(interval), java.util.concurrent.TimeUnit.MILLISECONDS);
return new AsyncTask() {
@Override
public void cancel(final boolean interrupt) {
future.cancel(true);
}
@Override
public void setExitHandler(final Runnable runnable) {
}
@Override
public boolean isCancelled() {
return future.isCancelled();
}
@Override
public boolean isFinished() {
return future.isDone();
}
};
}
@Override
public void requestStop() {
}
};
}
});
if (instance instanceof IOCClientTestCase) {
iocClientTestCase.setInitializer(new IOCClientTestCase.ContainerBootstrapper() {
@Override
public void bootstrap() {
try {
final String rootPackage = iocClientTestCase.getModulePackage();
final Set<String> packages = new HashSet<String>();
for (final Package p : Package.getPackages()) {
final String packageName = p.getName();
if (packageName.startsWith(rootPackage)) {
packages.add(packageName);
}
}
packages.add("org.jboss.errai.ioc.client.api.builtin");
final MockIOCGenerator mockIOCGenerator = new MockIOCGenerator(packages);
final Class<? extends Bootstrapper> cls = mockIOCGenerator.generate();
final Bootstrapper bs = cls.newInstance();
final long tm = System.currentTimeMillis();
new IOCBeanManagerLifecycle().resetBeanManager();
final BootstrapInjectionContext ctx = bs.bootstrapContainer();
((SimpleCreationalContext)ctx.getRootContext()).finish();
System.out.println("bootstrapped simulated container in " + (System.currentTimeMillis() - tm) + "ms");
}
catch (GenerationException e) {
throw e;
}
catch (Exception e) {
throw new RuntimeException("failed to run in emulated mode", e);
}
}
});
iocClientTestCase.setForcePureJava(true);
}
super.run(notifier);
}
else {