• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

leeonky / test-charm-java / 111

07 Feb 2025 04:38PM UTC coverage: 73.358% (-0.3%) from 73.633%
111

push

circleci

leeonky
First inspector example

0 of 59 new or added lines in 5 files covered. (0.0%)

1 existing line in 1 file now uncovered.

7663 of 10446 relevant lines covered (73.36%)

0.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/DAL-extension-inspector/src/main/java/com/github/leeonky/dal/extensions/inspector/HttpServer.java
1
package com.github.leeonky.dal.extensions.inspector;
2

3
import com.github.leeonky.util.Suppressor;
4
import de.neuland.jade4j.JadeConfiguration;
5
import de.neuland.jade4j.template.ClasspathTemplateLoader;
6
import io.javalin.Javalin;
7
import io.javalin.http.staticfiles.Location;
8
import io.javalin.plugin.rendering.JavalinRenderer;
9

10
import java.util.Collections;
11
import java.util.Objects;
12
import java.util.concurrent.CountDownLatch;
13

14
public class HttpServer {
15
    private final InspectorContext.ApiProvider apiProvider;
16
    private Javalin javalin;
17
    private CountDownLatch serverReadyLatch;
18

NEW
19
    public HttpServer(InspectorContext.ApiProvider apiProvider) {
×
NEW
20
        this.apiProvider = apiProvider;
×
21
        JadeConfiguration jadeConfiguration = new JadeConfiguration();
×
22
        jadeConfiguration.setCaching(false);
×
23
        jadeConfiguration.setTemplateLoader(new ClasspathTemplateLoader());
×
24
        JavalinRenderer.register((filePath, model, context) ->
×
25
                jadeConfiguration.renderTemplate(jadeConfiguration.getTemplate("public" + filePath), model), ".pug", ".PNG", ".Png");
×
26
    }
×
27

28
    public HttpServer start() {
NEW
29
        serverReadyLatch = new CountDownLatch(1);
×
NEW
30
        javalin = Javalin.create(config -> config.addStaticFiles("/public", Location.CLASSPATH))
×
NEW
31
                .events(event -> event.serverStarted(serverReadyLatch::countDown));
×
NEW
32
        Objects.requireNonNull(javalin.jettyServer()).setServerPort(10081);
×
NEW
33
        javalin.get("/", ctx -> ctx.render("/index.pug", Collections.emptyMap()));
×
NEW
34
        javalin.get("/api/fetch-code", ctx -> ctx.status(200).html(apiProvider.fetchCode()));
×
NEW
35
        javalin.post("/api/execute", ctx -> ctx.status(200).html(apiProvider.execute(ctx.body())));
×
NEW
36
        javalin.start();
×
NEW
37
        Suppressor.run(serverReadyLatch::await);
×
NEW
38
        return this;
×
39
    }
40

41
    public void stop() {
NEW
42
        javalin.close();
×
43
    }
×
44
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc