[New] added version info metadata to agent
This commit is contained in:
parent
74525d9e77
commit
3056d5eb95
4
pom.xml
4
pom.xml
|
@ -92,6 +92,10 @@
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-eclipse-plugin</artifactId>
|
<artifactId>maven-eclipse-plugin</artifactId>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package li.strolch.rest.inspector;
|
package li.strolch.rest;
|
||||||
|
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
import li.strolch.agent.api.StrolchAgent;
|
import li.strolch.agent.api.StrolchAgent;
|
|
@ -13,12 +13,15 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package li.strolch.rest.inspector;
|
package li.strolch.rest;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import li.strolch.rest.endpoint.Inspector;
|
||||||
|
import li.strolch.rest.endpoint.VersionQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
|
@ -30,6 +33,7 @@ public class StrolchRestfulClasses {
|
||||||
static {
|
static {
|
||||||
Set<Class<?>> restfulClasses = new HashSet<>();
|
Set<Class<?>> restfulClasses = new HashSet<>();
|
||||||
restfulClasses.add(Inspector.class);
|
restfulClasses.add(Inspector.class);
|
||||||
|
restfulClasses.add(VersionQuery.class);
|
||||||
|
|
||||||
Set<Class<?>> providerClasses = new HashSet<>();
|
Set<Class<?>> providerClasses = new HashSet<>();
|
||||||
providerClasses.add(StrolchRestfulExceptionMapper.class);
|
providerClasses.add(StrolchRestfulExceptionMapper.class);
|
|
@ -1,4 +1,4 @@
|
||||||
package li.strolch.rest.inspector;
|
package li.strolch.rest;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package li.strolch.rest.inspector;
|
package li.strolch.rest.endpoint;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -35,6 +35,7 @@ import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.model.Order;
|
import li.strolch.model.Order;
|
||||||
import li.strolch.model.Resource;
|
import li.strolch.model.Resource;
|
||||||
import li.strolch.persistence.api.StrolchTransaction;
|
import li.strolch.persistence.api.StrolchTransaction;
|
||||||
|
import li.strolch.rest.AgentRef;
|
||||||
import li.strolch.rest.model.AgentOverview;
|
import li.strolch.rest.model.AgentOverview;
|
||||||
import li.strolch.rest.model.ElementMapOverview;
|
import li.strolch.rest.model.ElementMapOverview;
|
||||||
import li.strolch.rest.model.ElementMapType;
|
import li.strolch.rest.model.ElementMapType;
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package li.strolch.rest.endpoint;
|
||||||
|
|
||||||
|
import javax.ws.rs.GET;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.GenericEntity;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.VersionQueryResult;
|
||||||
|
import li.strolch.rest.AgentRef;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
|
*/
|
||||||
|
@Path("strolch/version")
|
||||||
|
public class VersionQuery {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public Response getVersions() {
|
||||||
|
VersionQueryResult versionQueryResult = AgentRef.getInstance().getAgent().getVersion();
|
||||||
|
GenericEntity<VersionQueryResult> entity = new GenericEntity<VersionQueryResult>(versionQueryResult,
|
||||||
|
VersionQueryResult.class) {
|
||||||
|
};
|
||||||
|
return Response.ok().entity(entity).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
groupId=${project.groupId}
|
||||||
|
artifactId=${project.artifactId}
|
||||||
|
artifactVersion=${project.version}
|
||||||
|
scmRevision=r${buildNumber}
|
||||||
|
scmBranch=${scmBranch}
|
||||||
|
buildTimestamp=${buildTimestamp}
|
|
@ -20,9 +20,9 @@ import java.net.URI;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import li.strolch.rest.inspector.AgentRef;
|
import li.strolch.rest.AgentRef;
|
||||||
import li.strolch.rest.inspector.StrolchRestfulClasses;
|
import li.strolch.rest.StrolchRestfulClasses;
|
||||||
import li.strolch.rest.inspector.StrolchRestfulExceptionMapper;
|
import li.strolch.rest.StrolchRestfulExceptionMapper;
|
||||||
import li.strolch.testbase.runtime.RuntimeMock;
|
import li.strolch.testbase.runtime.RuntimeMock;
|
||||||
|
|
||||||
import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider;
|
import org.eclipse.persistence.jaxb.rs.MOXyJsonProvider;
|
||||||
|
|
|
@ -23,14 +23,15 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import li.strolch.agent.api.AgentVersion;
|
||||||
|
import li.strolch.agent.api.ComponentVersion;
|
||||||
|
import li.strolch.agent.api.VersionQueryResult;
|
||||||
import li.strolch.rest.model.AgentOverview;
|
import li.strolch.rest.model.AgentOverview;
|
||||||
import li.strolch.rest.model.ElementMapOverview;
|
import li.strolch.rest.model.ElementMapOverview;
|
||||||
import li.strolch.rest.model.ElementMapType;
|
import li.strolch.rest.model.ElementMapType;
|
||||||
import li.strolch.rest.model.ElementMapsOverview;
|
import li.strolch.rest.model.ElementMapsOverview;
|
||||||
import li.strolch.rest.model.OrderDetail;
|
|
||||||
import li.strolch.rest.model.RealmDetail;
|
import li.strolch.rest.model.RealmDetail;
|
||||||
import li.strolch.rest.model.RealmOverview;
|
import li.strolch.rest.model.RealmOverview;
|
||||||
import li.strolch.rest.model.ResourceDetail;
|
|
||||||
import li.strolch.rest.model.TypeOverview;
|
import li.strolch.rest.model.TypeOverview;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -41,7 +42,7 @@ import com.sun.jersey.api.client.GenericType;
|
||||||
/**
|
/**
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
public class InspectorTest extends AbstractRestfulTest {
|
public class RestfulServicesTest extends AbstractRestfulTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldGetAgent() {
|
public void shouldGetAgent() {
|
||||||
|
@ -162,4 +163,32 @@ public class InspectorTest extends AbstractRestfulTest {
|
||||||
assertTrue(entity
|
assertTrue(entity
|
||||||
.contains("\"date\":\"2012-11-30T18:12:05.628+01:00\",\"state\":\"CREATED\",\"parameterBags\""));
|
.contains("\"date\":\"2012-11-30T18:12:05.628+01:00\",\"state\":\"CREATED\",\"parameterBags\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldQueryVersion() {
|
||||||
|
|
||||||
|
// query
|
||||||
|
ClientResponse response = getClientResponse("/strolch/version");
|
||||||
|
VersionQueryResult versionQueryResult = response.getEntity(new GenericType<VersionQueryResult>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
if (versionQueryResult.hasErrors()) {
|
||||||
|
for (String error : versionQueryResult.getErrors()) {
|
||||||
|
logger.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AgentVersion agentVersion = versionQueryResult.getAgentVersion();
|
||||||
|
logger.info(agentVersion.toString());
|
||||||
|
List<ComponentVersion> componentVersions = versionQueryResult.getComponentVersions();
|
||||||
|
assertEquals(4, componentVersions.size());
|
||||||
|
for (ComponentVersion version : componentVersions) {
|
||||||
|
logger.info(version.toString());
|
||||||
|
assertEquals("li.strolch", agentVersion.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("StrolchPersistenceTest", agentVersion.getAgentName());
|
||||||
|
assertEquals("li.strolch", agentVersion.getGroupId());
|
||||||
|
assertEquals("li.strolch.agent", agentVersion.getArtifactId());
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue