Skip to content

Commit

Permalink
Show TSP version supported by server in IdentifierService
Browse files Browse the repository at this point in the history
Signed-off-by: Bernd Hufmann <[email protected]>
  • Loading branch information
bhufmann committed Oct 31, 2024
1 parent b2a5517 commit cc052a2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public final class EndpointConstants {
static final String EMAIL = "[email protected]"; //$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$

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Response getSystemInfo() {
} else {
response.setVersion(HARD_CODED_VERSION);
}

response.setTspVersion(EndpointConstants.VERSION);
return Response.ok(response).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,6 +95,13 @@ public String getProductId() {
return productId;
}

/**
* @return Version in the format Major.Minor.Micro
*/
public String getTspVersion() {
return tspVersion;
}

/**
* Set Version
*
Expand Down Expand Up @@ -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;
}
}

0 comments on commit cc052a2

Please sign in to comment.