private void mockTranslateHandler(HttpExchange httpExchange) throws IOException {
		try {
			translateRequestCount.incrementAndGet();

			assertContentType(httpExchange, CONTENT_TYPE_JSON);

			String requestBody =
				new String(httpExchange.getRequestBody().readAllBytes(), StandardCharsets.UTF_8);

			JsonObject request = JsonParser.parseString(requestBody).getAsJsonObject();
			JsonArray queryStrs = request.get("q").getAsJsonArray();
			String sourceLang = request.get("source").getAsString();

			translateSourceLangs.add(sourceLang);

			log(httpExchange,
				"request src=%s, strs=%s".formatted(sourceLang, queryStrs.toString()));

			JsonObject xlateResultObj = new JsonObject();
			JsonArray xlatedResults = new JsonArray();
			xlateResultObj.add("translatedText", xlatedResults);
			for (int i = 0; i < queryStrs.size(); i++) {
				xlatedResults.add("result" + translateStringCount.getAndIncrement());
			}
			log(httpExchange, "response: " + xlateResultObj);
			byte[] response = xlateResultObj.toString().getBytes();

			httpExchange.getResponseHeaders().set(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON);
			httpExchange.sendResponseHeaders(HTTP_OK, response.length);
			httpExchange.getResponseBody().write(response);
		}
		catch (Throwable th) {
			log(httpExchange, "Error during mockTranslateHandler: " + th.getMessage());
			throw th;
		}
		finally {
			httpExchange.close();
		}
	}
Tests the LibreTranslateStringTranslationService by creating a mock HTTP server that responds
to the minimal requests the service needs.
Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/translate/libretranslate/LibreTranslateStringTranslationServiceTest.java