From 8716ff4feb2ee7fd630e48650fc9203149d87b18 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 13 Mar 2012 15:57:30 -0300 Subject: [PATCH] - Add site report generation. mvn site:stage - Add more tests. --- pom.xml | 90 ++++++++++++++++++- wise-webapp/pom.xml | 83 ++++++++++++----- .../wisemapping/rest/MindmapController.java | 25 +++++- .../test/rest/RestMindmapTCase.java | 81 +++++++++++++++++ 4 files changed, 257 insertions(+), 22 deletions(-) create mode 100644 wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java diff --git a/pom.xml b/pom.xml index a76bbcfa..e63c3216 100644 --- a/pom.xml +++ b/pom.xml @@ -49,13 +49,41 @@ maven-surefire-plugin 2.12 + + maven-site-plugin + 3.0 + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + org.apache.maven.plugins + maven-site-plugin + 3.0 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.4 + + + org.apache.maven.plugins + maven-dependency-plugin + 2.4 + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.8.1 + org.apache.maven.plugins maven-resources-plugin - 2.5 UTF-8 @@ -80,9 +108,69 @@ + + org.apache.maven.plugins + maven-site-plugin + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.1 + + true + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.6 + + + org.apache.maven.plugins + maven-dependency-plugin + + analyze-report + + + + org.apache.maven.plugins + maven-pmd-plugin + 2.7.1 + + true + utf-8 + 100 + 1.6 + + target/ + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + index + summary + dependency-management + license + modules + + + + + + + + www.wisemapping.org + scp://www.wisemapping.org/docs/project/ + + + web2d diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml index 0963db3a..ae3a712a 100644 --- a/wise-webapp/pom.xml +++ b/wise-webapp/pom.xml @@ -77,6 +77,24 @@ ${org.springframework.version} compile + + org.springframework + spring-beans + ${org.springframework.version} + compile + + + org.springframework + spring-tx + ${org.springframework.version} + compile + + + org.springframework + spring-context + ${org.springframework.version} + compile + org.springframework spring-web @@ -94,10 +112,32 @@ jaxb-api 2.0 + + commons-logging + commons-logging + 1.0.4 + + + javax.xml.bind + jsr173_api + 1.0 + + + org.apache.xmlgraphics + fop + 0.94 + org.springframework spring-oxm ${org.springframework.version} + runtime + + + org.springframework + spring-context-support + ${org.springframework.version} + compile antlr @@ -133,19 +173,25 @@ org.springframework.security spring-security-web ${org.springframework.version} + runtime + + + org.springframework.security + spring-security-core + ${org.springframework.version} compile org.springframework.security spring-security-config ${org.springframework.version} - compile + runtime javax.transaction jta 1.0.1B - compile + runtime com.octo.captcha @@ -157,31 +203,25 @@ org.springframework spring-jdbc ${org.springframework.version} - compile + runtime org.hibernate hibernate-entitymanager 3.6.0.Final - compile - - - org.apache.xmlgraphics - batik-codec - 1.7 runtime - org.apache.xmlgraphics - batik-svg-dom - 1.7 + org.hibernate + hibernate-core + 3.6.0.Final + compile + + + aopalliance + aopalliance + 1.0 compile - - - xalan - xalan - - org.apache.xmlgraphics @@ -205,7 +245,7 @@ javax.servlet jstl 1.2 - runtime + provided javax.mail @@ -254,16 +294,19 @@ org.codehaus.jackson jackson-mapper-asl 1.9.4 + compile org.slf4j slf4j-api 1.6.4 + runtime xerces xercesImpl 2.10.0 + compile @@ -315,6 +358,7 @@ + create-schema test @@ -455,7 +499,6 @@ org.jvnet.jaxb2.maven2 maven-jaxb2-plugin - 0.8.1 mindmap-generate diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index d68556ef..b6acfd4a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -22,7 +22,7 @@ import java.util.Date; import java.util.List; @Controller -public class MindmapController extends BaseController{ +public class MindmapController extends BaseController { @Autowired private MindmapService mindmapService; @@ -71,4 +71,27 @@ public class MindmapController extends BaseController{ mindmapService.updateMindmap(mindMap, minor); } + @RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"}) + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void createMap(@RequestBody RestMindmap restMindmap, @PathVariable int id, @RequestParam(required = false) boolean minor) throws IOException, WiseMappingException { + + final MindMap mindMap = mindmapService.getMindmapById(id); + final User user = Utils.getUser(); + + final String properties = restMindmap.getProperties(); + mindMap.setProperties(properties); + + final Calendar now = Calendar.getInstance(); + mindMap.setLastModificationTime(now); + mindMap.setLastModifierUser(user.getUsername()); + + final Calendar lastModification = Calendar.getInstance(); + lastModification.setTime(new Date()); + mindMap.setLastModificationTime(lastModification); + + final String xml = restMindmap.getXml(); + mindMap.setXmlStr(xml); + mindmapService.updateMindmap(mindMap, minor); + } + } diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java new file mode 100644 index 00000000..fd46529e --- /dev/null +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java @@ -0,0 +1,81 @@ +package com.wisemapping.test.rest; + + +import com.wisemapping.rest.model.RestUser; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.springframework.http.*; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.security.crypto.codec.Base64; +import org.springframework.web.client.RestTemplate; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + + +@Test +public class RestMindmapTCase { + + @NonNls + private static final String HOST_PORT = "http://localhost:8080/"; + private static final String BASE_REST_URL = HOST_PORT + "service"; + + private URI createUser(@NotNull HttpHeaders requestHeaders, @NotNull RestTemplate templateRest) { + final RestUser restUser = new RestUser(); + final String email = "foo-to-delete" + System.nanoTime() + "@example.org"; + restUser.setEmail(email); + restUser.setUsername("foo"); + restUser.setFirstname("foo first name"); + restUser.setLastname("foo last name"); + restUser.setPassword("foo password"); + + HttpEntity createUserEntity = new HttpEntity(restUser, requestHeaders); + return templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity); + } + + + @Test(dataProvider = "ContentType-Provider-Function") + public void createMap(final @NotNull MediaType mediaType) { // Configure media types ... + final HttpHeaders requestHeaders = createHeaders(mediaType); + final RestTemplate templateRest = createTemplate(); + + } + + private HttpHeaders createHeaders(MediaType mediaType) { + List acceptableMediaTypes = new ArrayList(); + acceptableMediaTypes.add(mediaType); + final HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.setAccept(acceptableMediaTypes); + requestHeaders.setContentType(mediaType); + return requestHeaders; + } + + private RestTemplate createTemplate() { + SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() { + @Override + protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException { + super.prepareConnection(connection, httpMethod); + + //Basic Authentication for Police API + String authorisation = "admin@wisemapping.org" + ":" + "admin"; + byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes()); + connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation)); + } + + }; + return new RestTemplate(s); + } + + @DataProvider(name = "ContentType-Provider-Function") + public Object[][] contentTypes() { + return new Object[][]{{MediaType.APPLICATION_XML}, {MediaType.APPLICATION_JSON}}; + } +}