From e3bcea78f9802be6c03a10bbce5c4a313592b3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Reitmann?= Date: Tue, 18 Oct 2016 15:27:31 +0200 Subject: [PATCH] #706 rolled back to spring boot 1.3.8 due to validation error message issue --- pom.xml | 29 +++---------------- .../common/config/MetricsConfiguration.java | 19 ++++-------- .../common/config/WebConfigurer.java | 2 +- .../fdz/metadatamanagement/AbstractTest.java | 10 +++---- .../logmanagement/rest/LogsResourceTest.java | 2 +- .../rest/StudyResourceTest.java | 6 ++-- .../rest/AccountResourceTest.java | 2 +- .../usermanagement/rest/UserResourceTest.java | 4 +-- .../rest/VariableResourceTest.java | 5 ++-- 9 files changed, 25 insertions(+), 54 deletions(-) diff --git a/pom.xml b/pom.xml index 6e8cc0c96d..ad8e9a6dd9 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ spring-boot-starter-parent org.springframework.boot - 1.4.1.RELEASE + 1.3.8.RELEASE @@ -40,7 +40,7 @@ 3.1.3 ${project.build.directory}/test-results - 4.1.4 + 3.7.4 false 2.3.1 @@ -69,7 +69,7 @@ - com.querydsl + com.mysema.querydsl querydsl-mongodb ${querydsl.version} @@ -353,7 +353,7 @@ - com.querydsl + com.mysema.querydsl querydsl-apt ${querydsl.version} @@ -568,13 +568,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - build-info - - - true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 @@ -730,13 +723,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - build-info - - - true @@ -847,13 +833,6 @@ org.springframework.boot spring-boot-maven-plugin - - - - build-info - - - true diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MetricsConfiguration.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MetricsConfiguration.java index cde74dffd8..d6da07816f 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MetricsConfiguration.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/MetricsConfiguration.java @@ -2,7 +2,6 @@ import java.lang.management.ManagementFactory; import java.util.EnumSet; -import java.util.List; import javax.inject.Inject; import javax.servlet.DispatcherType; @@ -10,8 +9,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.web.servlet.ServletContextInitializer; +import org.springframework.boot.context.embedded.ServletContextInitializer; import org.springframework.context.annotation.Configuration; import com.codahale.metrics.MetricRegistry; @@ -21,18 +19,16 @@ import com.codahale.metrics.jvm.MemoryUsageGaugeSet; import com.codahale.metrics.jvm.ThreadStatesGaugeSet; import com.codahale.metrics.servlet.InstrumentedFilter; -import com.ryantenney.metrics.spring.config.annotation.DelegatingMetricsConfiguration; -import com.ryantenney.metrics.spring.config.annotation.MetricsConfigurer; +import com.ryantenney.metrics.spring.config.annotation.EnableMetrics; /** * Attach spring-metrics and custom jvm metrics to spring boot actuator metrics endpoint. * * @author René Reitmann - * @author Daniel Katzberg */ @Configuration -public class MetricsConfiguration extends DelegatingMetricsConfiguration - implements ServletContextInitializer { +@EnableMetrics(proxyTargetClass = true) +public class MetricsConfiguration implements ServletContextInitializer { private static final String PROP_METRIC_REG_JVM_MEMORY = "jvm.memory"; private static final String PROP_METRIC_REG_JVM_GARBAGE = "jvm.garbage"; private static final String PROP_METRIC_REG_JVM_THREADS = "jvm.threads"; @@ -41,12 +37,7 @@ public class MetricsConfiguration extends DelegatingMetricsConfiguration @Inject private MetricRegistry metricRegistry; - - @Override - @Autowired(required = false) - public void setMetricsConfigurers(final List configurers) { - } - + @Override public void onStartup(ServletContext servletContext) throws ServletException { metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); diff --git a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java index 05054705b9..9ab91768a4 100644 --- a/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java +++ b/src/main/java/eu/dzhw/fdz/metadatamanagement/common/config/WebConfigurer.java @@ -14,7 +14,7 @@ import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; import org.springframework.boot.context.embedded.MimeMappings; -import org.springframework.boot.web.servlet.ServletContextInitializer; +import org.springframework.boot.context.embedded.ServletContextInitializer; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java index ff8b900b77..4a8040fdc9 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java @@ -1,10 +1,9 @@ package eu.dzhw.fdz.metadatamanagement; import org.junit.runner.RunWith; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import eu.dzhw.fdz.metadatamanagement.common.config.Constants; @@ -15,11 +14,10 @@ * @author Daniel Katzberg * */ -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class) +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = Application.class) @ActiveProfiles(Constants.SPRING_PROFILE_UNITTEST) @WebAppConfiguration -@AutoConfigureMockMvc public abstract class AbstractTest { } diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/logmanagement/rest/LogsResourceTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/logmanagement/rest/LogsResourceTest.java index b0d01acfc9..3bbd2bdc83 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/logmanagement/rest/LogsResourceTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/logmanagement/rest/LogsResourceTest.java @@ -48,7 +48,7 @@ public void testGetList() throws Exception { MvcResult mvcResult = this.restUserMockMvc.perform(get("/api/logs").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); String content = mvcResult.getResponse() diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java index 163ac07c2f..78c5c3f359 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java @@ -1,5 +1,6 @@ package eu.dzhw.fdz.metadatamanagement.studymanagement.rest; +import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.Matchers.is; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -90,7 +91,7 @@ public void testCreateStudyWithTooSurveySeries() throws IOException, Exception { .content(TestUtil.convertObjectToJsonBytes(study))) .andExpect(status().is4xxClientError()); } - + @Test public void testCreateStudyWithWrongId() throws IOException, Exception { DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject(); @@ -102,7 +103,8 @@ public void testCreateStudyWithWrongId() throws IOException, Exception { // create the study with the given id mockMvc.perform(put(API_STUDY_URI + "/" + study.getId()) .content(TestUtil.convertObjectToJsonBytes(study))) - .andExpect(status().is4xxClientError()); + .andExpect(status().is4xxClientError()) + .andExpect(jsonPath("$.errors[0].message", containsString("study-management.error.study.id.not-equal-to-project-id"))); } @Test diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java index 6e9832e978..a0621e4617 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java @@ -129,7 +129,7 @@ public void testGetExistingAccount() throws Exception { restUserMockMvc.perform(get("/api/account").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.login").value("test")) .andExpect(jsonPath("$.firstName").value("john")) .andExpect(jsonPath("$.lastName").value("Doe")) diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResourceTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResourceTest.java index 809f9d25d3..27ab5de093 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResourceTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/UserResourceTest.java @@ -79,7 +79,7 @@ public void testGetExistingUser() throws Exception { // Assert restUserMockMvc.perform(get("/api/users/admin").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.lastName").value("Administrator")); } @@ -115,7 +115,7 @@ public void testGetAllUser() throws Exception { // Act MvcResult mvcResult = restUserMockMvc.perform(get("/api/users")) .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful()) .andReturn(); String content = mvcResult.getResponse() diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java index 1703bec922..1bb77246ca 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java @@ -297,8 +297,9 @@ public void testCreateVariableWithNonNumericValueOnContinouosScaleLevel() throws // create the variable with duplicate value classes mockMvc.perform(put(API_VARIABLES_URI + "/" + variable.getId()) .content(TestUtil.convertObjectToJsonBytes(variable))) - .andExpect(status().is4xxClientError()) - .andReturn(); + .andExpect(status().isBadRequest()) + .andExpect(jsonPath("$.errors[0].message", containsString("variable-management.error.variable.valid-response-value-must-be-a-number-on-numeric-data-type"))); + } @Test