Browse Source

Added build info to web test client.

pull/57/head
Kalle Stenflo 10 years ago
parent
commit
29e3f1843c
  1. 1
      build.gradle
  2. 12
      json-path-web-test/build.gradle
  3. 18
      json-path-web-test/src/main/java/com/jayway/jsonpath/web/resource/ApiResource.java
  4. 11
      json-path-web-test/src/main/resources/webapp/index.html

1
build.gradle

@ -24,6 +24,7 @@ ext {
allprojects { allprojects {
ext.displayName = null ext.displayName = null
ext.buildTimestamp = new Date().format('yyyy-MM-dd HH:mm:ss')
group = 'com.jayway.jsonpath' group = 'com.jayway.jsonpath'
version = '1.1.1' + (snapshotVersion ? "-SNAPSHOT" : "") version = '1.1.1' + (snapshotVersion ? "-SNAPSHOT" : "")

12
json-path-web-test/build.gradle

@ -1,13 +1,22 @@
apply plugin: 'shadow' apply plugin: 'shadow'
apply plugin: 'application' apply plugin: 'application'
displayName = "JsonPath Tets Bench" displayName = "JsonPath Test Bench"
description = "Web app that compares different JsonPath implementations." description = "Web app that compares different JsonPath implementations."
mainClassName = 'com.jayway.jsonpath.web.boot.Main' mainClassName = 'com.jayway.jsonpath.web.boot.Main'
task createBuildInfoFile << {
def buildInfoFile = new File("$buildDir/classes/main/build-info.properties")
Properties props = new Properties()
props.setProperty('version', project.version.toString())
props.setProperty('timestamp', project.buildTimestamp)
props.store(buildInfoFile.newWriter(), null)
}
jar { jar {
dependsOn createBuildInfoFile
baseName 'json-path-web-test' baseName 'json-path-web-test'
manifest { manifest {
attributes 'Implementation-Title': 'json-path-web-test', attributes 'Implementation-Title': 'json-path-web-test',
@ -16,6 +25,7 @@ jar {
} }
} }
dependencies { dependencies {
compile project(':json-path') compile project(':json-path')
compile 'commons-io:commons-io:2.4' compile 'commons-io:commons-io:2.4'

18
json-path-web-test/src/main/java/com/jayway/jsonpath/web/resource/ApiResource.java

@ -17,7 +17,9 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle;
@Path("/") @Path("/")
@Produces(MediaType.TEXT_HTML) @Produces(MediaType.TEXT_HTML)
@ -25,6 +27,21 @@ public class ApiResource {
private static final Logger logger = LoggerFactory.getLogger(ApiResource.class); private static final Logger logger = LoggerFactory.getLogger(ApiResource.class);
@GET
@Path("/info")
@Produces(MediaType.APPLICATION_JSON)
public Response info() {
Map<String, String> result = new HashMap<String, String>();
try {
ResourceBundle resource = ResourceBundle.getBundle("build-info");
result.put("version", resource.getString("version"));
result.put("timestamp", resource.getString("timestamp"));
} catch (Exception e){
result.put("version", "LOCAL");
result.put("timestamp", "NOW");
}
return Response.ok(result).build();
}
@GET @GET
@Path("/validate") @Path("/validate")
@ -60,5 +77,4 @@ public class ApiResource {
} }
} }

11
json-path-web-test/src/main/resources/webapp/index.html

@ -16,7 +16,10 @@
</head> </head>
<body role="document"> <body role="document">
<div class="container"> <div class="container">
<h3>Jayway JsonPath evaluator</h3> <h3>Jayway JsonPath Evaluator</h3>
<div style="margin-top: -12px; margin-bottom: 10px;">
<span id="version" style="font-size: xx-small"></span>&nbsp;-&nbsp;<span id="timestamp" style="font-size: xx-small"></span>
</div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
@ -211,6 +214,11 @@
} }
$( document ).ready(function() { $( document ).ready(function() {
$.get('/api/info', function(data) {
$("#version").text(data.version);
$("#timestamp").text(data.timestamp);
});
$('#path-status-tool').tooltip({ $('#path-status-tool').tooltip({
container: 'body', container: 'body',
delay: 0 delay: 0
@ -288,7 +296,6 @@
success: function(data) { success: function(data) {
$('#jayway-time').text(data.jayway.time); $('#jayway-time').text(data.jayway.time);
//$('#jayway-res').hide().text(data.jayway.result).fadeIn();
$('#jayway-res').hide().empty(); $('#jayway-res').hide().empty();
if(data.jayway.error){ if(data.jayway.error){
$('#jayway-error').text(data.jayway.error).show(); $('#jayway-error').text(data.jayway.error).show();

Loading…
Cancel
Save