diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/IdentifierServiceTest.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/IdentifierServiceTest.java index 2705544d..1060a86e 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/IdentifierServiceTest.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests/src/org/eclipse/tracecompass/incubator/trace/server/jersey/rest/core/tests/services/IdentifierServiceTest.java @@ -11,12 +11,14 @@ package org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.services; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.IdentifierService; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.ServerInfoResponseImpl; import org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.utils.RestServerTest; @@ -37,18 +39,20 @@ public void testIdentifier() { WebTarget application = getApplicationEndpoint(); WebTarget identifierEndpoint = application.path("identifier"); - Response response = identifierEndpoint.request(MediaType.APPLICATION_JSON) - .get(); - ServerInfoResponseImpl responseValues = response.readEntity(ServerInfoResponseImpl.class); - - assertNotNull("Server version should not be null", responseValues.getVersion()); - assertNotNull("OS should not be null", responseValues.getOs()); - assertNotNull("OS Architecture should not be null", responseValues.getOsArch()); - assertNotNull("OS Version should not be null", responseValues.getOsVersion()); - assertNotNull("CPU count should not be null", responseValues.getCpuCount()); - assertNotNull("Max memory should not be null", responseValues.getMaxMemory()); - assertNotNull("Product ID should not be null", responseValues.getProductId()); - + try (Response response = identifierEndpoint.request(MediaType.APPLICATION_JSON) + .get()) { + ServerInfoResponseImpl responseValues = response.readEntity(ServerInfoResponseImpl.class); + + assertNotNull("Server version should not be null", responseValues.getVersion()); + assertNotNull("OS should not be null", responseValues.getOs()); + assertNotNull("OS Architecture should not be null", responseValues.getOsArch()); + assertNotNull("OS Version should not be null", responseValues.getOsVersion()); + assertNotNull("CPU count should not be null", responseValues.getCpuCount()); + assertNotNull("Max memory should not be null", responseValues.getMaxMemory()); + assertNotNull("Product ID should not be null", responseValues.getProductId()); + assertNotNull("The TSP version should not be null", responseValues.getProductId()); + assertEquals(EndpointConstants.VERSION, responseValues.getTspVersion()); + } } } diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/ServerInfoResponse.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/ServerInfoResponse.java index 15abdfe6..a03a9d25 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/ServerInfoResponse.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/ServerInfoResponse.java @@ -73,4 +73,11 @@ public interface ServerInfoResponse { */ @Schema(required = true, description = "Product identifier for the trace server") String getProductId(); + + /** + * @return supported TSP version + */ + @Schema(required = true, description = "The TSP version that the trace server supports") + String getTspVersion(); + } diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java index 7915c8fc..43f720e8 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/EndpointConstants.java @@ -83,7 +83,8 @@ public final class EndpointConstants { static final String EMAIL = "tracecompass-dev@eclipse.org"; //$NON-NLS-1$ static final String LICENSE = "Apache 2"; //$NON-NLS-1$ static final String LICENSE_URL = "http://www.apache.org/licenses/"; //$NON-NLS-1$ - static final String VERSION = "0.2.0"; //$NON-NLS-1$ + /** The TSP version */ + public static final String VERSION = "0.2.0"; //$NON-NLS-1$ static final String SERVER = "https://localhost:8080/tsp/api"; //$NON-NLS-1$ /** diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/IdentifierService.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/IdentifierService.java index 1634cc05..c0166457 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/IdentifierService.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/IdentifierService.java @@ -80,7 +80,7 @@ public Response getSystemInfo() { } else { response.setVersion(HARD_CODED_VERSION); } - + response.setTspVersion(EndpointConstants.VERSION); return Response.ok(response).build(); } diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ServerInfoResponseImpl.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ServerInfoResponseImpl.java index 742362fb..52e6e36e 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ServerInfoResponseImpl.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/ServerInfoResponseImpl.java @@ -30,6 +30,7 @@ public class ServerInfoResponseImpl { @JsonInclude(JsonInclude.Include.NON_NULL) // Makes launcher name optional private String launcherName; private String productId; + private String tspVersion; /** * @return Version in the format Major.Minor.Micro @@ -94,6 +95,13 @@ public String getProductId() { return productId; } + /** + * @return Version in the format Major.Minor.Micro + */ + public String getTspVersion() { + return tspVersion; + } + /** * Set Version * @@ -184,4 +192,13 @@ public void setProductId(String productId) { this.productId = productId; } + /** + * Set the TSP version + * + * @param version + * the TSP version to set + */ + public void setTspVersion(String version) { + tspVersion = version; + } }