use of io.quarkus.deployment.dev.testing.TestSupport in project quarkus by quarkusio.
the class TestsProcessor method toggleTestRunner.
@BuildStep(onlyIf = IsDevelopment.class)
void toggleTestRunner(LaunchModeBuildItem launchModeBuildItem, BuildProducer<DevConsoleRouteBuildItem> routeProducer) {
Optional<TestSupport> ts = TestSupport.instance();
if (testsDisabled(launchModeBuildItem, ts)) {
return;
}
routeProducer.produce(new DevConsoleRouteBuildItem("tests/toggle", "POST", new Handler<>() {
@Override
public void handle(RoutingContext event) {
if (ts.get().isStarted()) {
ts.get().stop();
} else {
ts.get().start();
}
Json.JsonObjectBuilder object = Json.object();
object.put("running", ts.get().isRunning());
event.response().putHeader("Content-Type", "application/json; charset=utf-8").end(object.build());
}
}));
routeProducer.produce(new DevConsoleRouteBuildItem("tests/toggle-broken-only", "POST", new Handler<>() {
@Override
public void handle(RoutingContext event) {
boolean brokenOnlyMode = ts.get().toggleBrokenOnlyMode();
Json.JsonObjectBuilder object = Json.object();
object.put("brokenOnlyMode", brokenOnlyMode);
event.response().putHeader("Content-Type", "application/json; charset=utf-8").end(object.build());
}
}));
}
use of io.quarkus.deployment.dev.testing.TestSupport in project quarkus by quarkusio.
the class IsolatedTestModeMain method setupRuntimeCompilation.
private RuntimeUpdatesProcessor setupRuntimeCompilation(DevModeContext context, Path applicationRoot) throws Exception {
System.setProperty("quarkus.test.display-test-output", "true");
if (!context.getAllModules().isEmpty()) {
ServiceLoader<CompilationProvider> serviceLoader = ServiceLoader.load(CompilationProvider.class);
List<CompilationProvider> compilationProviders = new ArrayList<>();
for (CompilationProvider provider : serviceLoader) {
compilationProviders.add(provider);
context.getAllModules().forEach(moduleInfo -> moduleInfo.addSourcePaths(provider.handledSourcePaths()));
}
QuarkusCompiler compiler;
try {
compiler = new QuarkusCompiler(curatedApplication, compilationProviders, context);
} catch (Exception e) {
throw new RuntimeException("Failed to create compiler", e);
}
TestSupport testSupport = new TestSupport(curatedApplication, compilationProviders, context, DevModeType.TEST_ONLY);
RuntimeUpdatesProcessor processor = new RuntimeUpdatesProcessor(applicationRoot, context, compiler, DevModeType.TEST_ONLY, this::regenerateApplication, new BiConsumer<DevModeContext.ModuleInfo, String>() {
@Override
public void accept(DevModeContext.ModuleInfo moduleInfo, String s) {
}
}, new BiFunction<String, byte[], byte[]>() {
@Override
public byte[] apply(String s, byte[] bytes) {
return ClassTransformingBuildStep.transform(s, bytes);
}
}, testSupport);
for (HotReplacementSetup service : ServiceLoader.load(HotReplacementSetup.class, curatedApplication.getBaseRuntimeClassLoader())) {
hotReplacementSetups.add(service);
service.setupHotDeployment(processor);
processor.addHotReplacementSetup(service);
}
return processor;
}
return null;
}
use of io.quarkus.deployment.dev.testing.TestSupport in project quarkus by quarkusio.
the class IsolatedDevModeMain method setupRuntimeCompilation.
private RuntimeUpdatesProcessor setupRuntimeCompilation(DevModeContext context, Path appRoot, DevModeType devModeType) throws Exception {
if (!context.getAllModules().isEmpty()) {
ServiceLoader<CompilationProvider> serviceLoader = ServiceLoader.load(CompilationProvider.class);
List<CompilationProvider> compilationProviders = new ArrayList<>();
for (CompilationProvider provider : serviceLoader) {
compilationProviders.add(provider);
context.getAllModules().forEach(moduleInfo -> moduleInfo.addSourcePaths(provider.handledSourcePaths()));
}
QuarkusCompiler compiler = new QuarkusCompiler(curatedApplication, compilationProviders, context);
TestSupport testSupport = null;
if (devModeType == DevModeType.LOCAL) {
testSupport = new TestSupport(curatedApplication, compilationProviders, context, devModeType);
}
RuntimeUpdatesProcessor processor = new RuntimeUpdatesProcessor(appRoot, context, compiler, devModeType, this::restartCallback, null, new BiFunction<String, byte[], byte[]>() {
@Override
public byte[] apply(String s, byte[] bytes) {
return ClassTransformingBuildStep.transform(s, bytes);
}
}, testSupport);
for (HotReplacementSetup service : ServiceLoader.load(HotReplacementSetup.class, curatedApplication.getBaseRuntimeClassLoader())) {
hotReplacementSetups.add(service);
service.setupHotDeployment(processor);
processor.addHotReplacementSetup(service);
}
for (DeploymentFailedStartHandler service : ServiceLoader.load(DeploymentFailedStartHandler.class, curatedApplication.getAugmentClassLoader())) {
processor.addDeploymentFailedStartHandler(new Runnable() {
@Override
public void run() {
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(curatedApplication.getAugmentClassLoader());
service.handleFailedInitialStart();
} finally {
Thread.currentThread().setContextClassLoader(old);
}
}
});
}
DevConsoleManager.setQuarkusBootstrap(curatedApplication.getQuarkusBootstrap());
DevConsoleManager.setHotReplacementContext(processor);
return processor;
}
return null;
}
Aggregations