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

temporalio / sdk-java / #351

04 Aug 2026 11:58PM UTC coverage: 67.781% (-0.5%) from 68.245%
#351

push

github

web-flow
Add dev server downloader & runner to testing package (#2982)

7311 of 12876 branches covered (56.78%)

Branch coverage included in aggregate %.

331 of 703 new or added lines in 12 files covered. (47.08%)

28 existing lines in 13 files now uncovered.

30207 of 42476 relevant lines covered (71.12%)

0.71 hits per line

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

1.82
/temporal-testing/src/main/java/io/temporal/testing/internal/devserver/SdkJavaTestServerProfile.java
1
package io.temporal.testing.internal.devserver;
2

3
import io.temporal.testing.TemporalDevServer;
4
import io.temporal.testing.TemporalDevServerOptions;
5
import java.io.File;
6
import java.nio.file.Path;
7
import java.util.Arrays;
8
import java.util.List;
9
import javax.annotation.Nonnull;
10

11
/** Configuration and lifecycle used only by sdk-java's Gradle test profile. */
12
public final class SdkJavaTestServerProfile {
13
  public static final String ACTIVE_PROPERTY = "io.temporal.testing.internal.devServerProfile";
14

15
  // This is intentionally the sole Temporal CLI version used by sdk-java repository tests.
16
  private static final String TEST_CLI_VERSION = "1.7.4-standalone-nexus-operations";
17
  private static final String TEST_NAMESPACE = "UnitTest";
18
  private static final String DATABASE_FILENAME = "temporal.sqlite";
19

20
  private static TemporalDevServer server;
21
  private static boolean shutdownHookRegistered;
22

23
  private SdkJavaTestServerProfile() {}
24

25
  public static boolean isActive() {
26
    return Boolean.parseBoolean(System.getProperty(ACTIVE_PROPERTY, "false"));
1✔
27
  }
28

29
  public static String getTarget() {
NEW
30
    if (!isActive()) {
×
NEW
31
      return null;
×
32
    }
NEW
33
    return "localhost:7233";
×
34
  }
35

36
  public static synchronized String start() {
NEW
37
    if (server == null) {
×
NEW
38
      File workingDirectory = workingDirectory();
×
NEW
39
      cleanDatabase(workingDirectory);
×
40
      try {
NEW
41
        server = TemporalDevServer.start(TEST_NAMESPACE, serverOptions(workingDirectory));
×
NEW
42
      } catch (RuntimeException | Error failure) {
×
NEW
43
        cleanDatabase(workingDirectory);
×
NEW
44
        throw failure;
×
NEW
45
      }
×
NEW
46
      if (!shutdownHookRegistered) {
×
NEW
47
        Runtime.getRuntime()
×
NEW
48
            .addShutdownHook(
×
49
                new Thread(SdkJavaTestServerProfile::shutdown, "sdk-java-dev-server-shutdown"));
NEW
50
        shutdownHookRegistered = true;
×
51
      }
52
    }
NEW
53
    return server.getTarget();
×
54
  }
55

56
  public static Path prepare() {
NEW
57
    return TemporalDevServerDownloader.prepare(downloadOptions());
×
58
  }
59

60
  public static synchronized void shutdown() {
NEW
61
    if (server != null) {
×
NEW
62
      server.close();
×
NEW
63
      server = null;
×
64
    }
NEW
65
    cleanDatabase(workingDirectory());
×
NEW
66
  }
×
67

68
  private static TemporalDevServerOptions serverOptions(@Nonnull File workingDirectory) {
NEW
69
    return TemporalDevServerOptions.newBuilder(downloadOptions())
×
NEW
70
        .setIp("127.0.0.1")
×
NEW
71
        .setPort(7233)
×
NEW
72
        .setUiEnabled(false)
×
NEW
73
        .setDatabaseFilename(DATABASE_FILENAME)
×
NEW
74
        .setWorkingDirectory(workingDirectory.getAbsolutePath())
×
NEW
75
        .setLogFile(new File(workingDirectory, "server.log").getAbsolutePath())
×
NEW
76
        .setExtraArgs(repositoryServerArguments())
×
NEW
77
        .build();
×
78
  }
79

80
  private static TemporalDevServerOptions downloadOptions() {
NEW
81
    return TemporalDevServerOptions.newBuilder().setDownloadVersion("v" + TEST_CLI_VERSION).build();
×
82
  }
83

84
  private static List<String> repositoryServerArguments() {
NEW
85
    return Arrays.asList(
×
86
        "--http-port",
87
        "7243",
88
        "--sqlite-pragma",
89
        "journal_mode=WAL",
90
        "--sqlite-pragma",
91
        "synchronous=OFF",
92
        "--search-attribute",
93
        "CustomKeywordField=Keyword",
94
        "--search-attribute",
95
        "CustomStringField=Text",
96
        "--search-attribute",
97
        "CustomTextField=Text",
98
        "--search-attribute",
99
        "CustomIntField=Int",
100
        "--search-attribute",
101
        "CustomDatetimeField=Datetime",
102
        "--search-attribute",
103
        "CustomDoubleField=Double",
104
        "--search-attribute",
105
        "CustomBoolField=Bool",
106
        "--dynamic-config-value",
107
        "system.enableActivityEagerExecution=true",
108
        "--dynamic-config-value",
109
        "history.MaxBufferedQueryCount=10000",
110
        "--dynamic-config-value",
111
        "frontend.workerVersioningDataAPIs=true",
112
        "--dynamic-config-value",
113
        "history.enableRequestIdRefLinks=true",
114
        "--dynamic-config-value",
115
        "frontend.WorkerHeartbeatsEnabled=true",
116
        "--dynamic-config-value",
117
        "frontend.ListWorkersEnabled=true",
118
        "--dynamic-config-value",
119
        "frontend.enableCancelWorkerPollsOnShutdown=true",
120
        "--dynamic-config-value",
121
        "component.callbacks.allowedAddresses=[{\"Pattern\":\"localhost:7243\",\"AllowInsecure\":true}]",
122
        "--dynamic-config-value",
123
        "callback.allowedAddresses=[{\"Pattern\":\"localhost:7243\",\"AllowInsecure\":true}]",
124
        "--dynamic-config-value",
125
        "frontend.activityAPIsEnabled=true",
126
        "--dynamic-config-value",
127
        "activity.enableStandalone=true",
128
        "--dynamic-config-value",
129
        "activity.enableCallbacks=true",
130
        "--dynamic-config-value",
131
        "activity.startDelayEnabled=true",
132
        "--dynamic-config-value",
133
        "nexusoperation.enableStandalone=true",
134
        "--dynamic-config-value",
135
        "history.enableChasm=true",
136
        "--dynamic-config-value",
137
        "history.enableCHASMSignalBacklinks=true",
138
        "--dynamic-config-value",
139
        "history.enableUpdateCallbacks=true",
140
        "--dynamic-config-value",
141
        "history.enableCHASMCallbacks=true",
142
        "--dynamic-config-value",
143
        "history.enableTransitionHistory=true",
144
        "--dynamic-config-value",
145
        "frontend.enableCancelWorkerPollsOnShutdown=true",
146
        "--dynamic-config-value",
147
        "frontend.workerCommandsEnabled=true",
148
        "--dynamic-config-value",
149
        "system.enableCancelActivityWorkerCommand=true");
150
  }
151

152
  private static File workingDirectory() {
NEW
153
    return new File("build", "temporal-cli/server");
×
154
  }
155

156
  private static void cleanDatabase(@Nonnull File workingDirectory) {
157
    for (String name :
NEW
158
        Arrays.asList(DATABASE_FILENAME, DATABASE_FILENAME + "-shm", DATABASE_FILENAME + "-wal")) {
×
NEW
159
      File file = new File(workingDirectory, name);
×
NEW
160
      if (file.exists() && !file.delete()) {
×
NEW
161
        System.err.println("Unable to delete Temporal dev-server database file " + file);
×
162
      }
NEW
163
    }
×
NEW
164
  }
×
165
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc