Permalink
Browse files

chore(spring-boot): cleanup after version change

* ignore camunda persistence
* simplify restTestTemplate
* fix javadoc
* replace deprecated Mockito runner
* remove TODO
* switch from deprecated WebMvcConfigurerAdapter
* avoid unsafe cast

Related to #295, CAM-8292
  • Loading branch information...
jangalinski authored and yanavasileva committed Mar 22, 2018
1 parent e3c7a96 commit 8be681c75d81ae116b8765a9dcff48f07b1a8f1b
View
11 mvnw
@@ -57,27 +57,27 @@ case "`uname`" in
#
# Look for the Apple JDKs first to preserve the existing behaviour, and then look
# for the new JDKs provided by Oracle.
#
#
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
fi
if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
#
# Apple JDKs
#
export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi
if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
#
# Oracle JDKs
#
export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
fi
fi
if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
#
@@ -136,7 +136,6 @@ if $mingw ; then
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
@@ -219,7 +218,7 @@ concat_lines() {
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# Provide a "standardized" way to retrieve the CLI args that will
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="org.springframework " level="info" />
<logger name="org.hibernate" level="info" />
<logger name="org.camunda" level="info" />
</configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework" level="info"/>
<logger name="org.hibernate" level="info"/>
<logger name="org.camunda" level="info"/>
<logger name="org.camunda.bpm.engine.persistence" level="warn" />
</configuration>
@@ -6,21 +6,19 @@
import org.camunda.bpm.spring.boot.starter.webapp.filter.LazyInitRegistration;
import org.camunda.bpm.spring.boot.starter.webapp.filter.ResourceLoaderDependingFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.Assert;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@ConditionalOnWebApplication
@AutoConfigureAfter(CamundaBpmAutoConfiguration.class)
public class CamundaBpmWebappAutoConfiguration extends WebMvcConfigurerAdapter {
public class CamundaBpmWebappAutoConfiguration implements WebMvcConfigurer {
@Autowired
private ResourceLoader resourceLoader;
@@ -30,7 +28,7 @@
@Bean
public CamundaBpmWebappInitializer camundaBpmWebappInitializer(CamundaBpmProperties properties) {
public CamundaBpmWebappInitializer camundaBpmWebappInitializer() {
return new CamundaBpmWebappInitializer(properties);
}
@@ -53,15 +51,13 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/lib/**").addResourceLocations(classpath + "/lib/");
registry.addResourceHandler("/api/**").addResourceLocations("classpath:/api/");
registry.addResourceHandler("/app/**").addResourceLocations(classpath + "/app/");
super.addResourceHandlers(registry);
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
if (properties.getWebapp().isIndexRedirectEnabled()) {
registry.addRedirectViewController("/", "/app/");
}
super.addViewControllers(registry);
}
}
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="org.springframework " level="info" />
<logger name="org.hibernate" level="info" />
<logger name="org.camunda" level="info" />
</configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework" level="info"/>
<logger name="org.hibernate" level="info"/>
<logger name="org.camunda" level="info"/>
<logger name="org.camunda.bpm.engine.persistence" level="warn" />
</configuration>
@@ -5,39 +5,38 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/**
* @author Svetlana Dorokhova.
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebappExampleApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@SpringBootTest(
classes = WebappExampleApplication.class,
webEnvironment = RANDOM_PORT)
public class WebappEeTest {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate testRestTemplate;
@Test
public void testLicenseEndpointAvailable() throws Exception {
public void testLicenseEndpointAvailable() {
final ResponseEntity<String> response = testRestTemplate
.getForEntity("http://localhost:" + this.port + "/api/admin/plugin/license/default/key", String.class);
.getForEntity("/api/admin/plugin/license/default/key", String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@Test
public void testAdminEndpointAvailable() throws Exception {
final ResponseEntity<String> response = testRestTemplate
.getForEntity("http://localhost:" + this.port + "/app/admin", String.class);
public void testAdminEndpointAvailable() {
final ResponseEntity<String> response = testRestTemplate.getForEntity("/app/admin", String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
}
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="org.springframework " level="info" />
<logger name="org.hibernate" level="info" />
<logger name="org.camunda" level="info" />
</configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework" level="info"/>
<logger name="org.hibernate" level="info"/>
<logger name="org.camunda" level="info"/>
<logger name="org.camunda.bpm.engine.persistence" level="warn"/>
</configuration>
@@ -5,39 +5,37 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Svetlana Dorokhova.
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebappExampleApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@SpringBootTest(
classes = WebappExampleApplication.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
)
public class WebappTest {
@LocalServerPort
private int port;
@Autowired
private TestRestTemplate testRestTemplate;
@Test
public void testLicenseEndpointNotAvailable() throws Exception {
final ResponseEntity<String> response = testRestTemplate
.getForEntity("http://localhost:" + this.port + "/api/admin/plugin/license/default/key", String.class);
public void testLicenseEndpointNotAvailable() {
final ResponseEntity<String> response = testRestTemplate.getForEntity("/api/admin/plugin/license/default/key", String.class);
assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
@Test
public void testAdminEndpointAvailable() throws Exception {
final ResponseEntity<String> response = testRestTemplate
.getForEntity("http://localhost:" + this.port + "/app/admin", String.class);
public void testAdminEndpointAvailable() {
final ResponseEntity<String> response = testRestTemplate.getForEntity("/app/admin", String.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
}
}
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="org.springframework " level="info" />
<logger name="org.hibernate" level="info" />
<logger name="org.camunda" level="info" />
</configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework" level="info"/>
<logger name="org.hibernate" level="info"/>
<logger name="org.camunda" level="info"/>
<logger name="org.camunda.bpm.engine.persistence" level="warn" />
</configuration>
@@ -5,6 +5,7 @@
import static org.camunda.bpm.spring.boot.starter.util.GetProcessApplicationNameFromAnnotation.processApplicationNameFromAnnotation;
import static org.camunda.bpm.spring.boot.starter.util.SpringBootProcessEngineLogger.LOG;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
@@ -36,7 +37,7 @@ public static CamundaDeploymentConfiguration deploymentConfiguration() {
return new CamundaDeploymentConfiguration() {
@Override
public Set<Resource> getDeploymentResources() {
return EMPTY_SET;
return Collections.emptySet();
}
@Override
@@ -5,12 +5,12 @@
public class AuthorizationProperty {
/**
* enables authorization
* Enables authorization.
*/
private boolean enabled = Defaults.INSTANCE.isAuthorizationEnabled();
/**
* enables authorization for custom code
* Enables authorization for custom code.
*/
private boolean enabledForCustomCode = Defaults.INSTANCE.isAuthorizationEnabledForCustomCode();
@@ -12,7 +12,7 @@
/**
* Return the full version string of the present Camunda codebase, or
* {@code null} if it cannot be determined.
* <p>
* <p/>
* return the version of Camunda or {@code null}
*
* @see Package#getImplementationVersion()
@@ -41,7 +41,7 @@ public CamundaBpmVersion() {
.map(String::trim)
.orElse("");
this.isEnterprise = version.endsWith("-ee");
this.formattedVersion = String.format(String.format(VERSION_FORMAT, version));
this.formattedVersion = String.format(VERSION_FORMAT, version);
}
@Override
@@ -4,6 +4,7 @@
import static org.junit.Assert.assertNull;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin;
import org.camunda.bpm.spring.boot.starter.configuration.Ordering;
@@ -25,7 +26,7 @@ public ProcessEnginePlugin afterStandardConfiguration() {
}
@Order(Ordering.DEFAULT_ORDER - 1)
public static class BeforeStandardConfiguration implements ProcessEnginePlugin {
public static class BeforeStandardConfiguration extends AbstractProcessEnginePlugin {
static boolean PROCESSED = false;
@@ -34,23 +35,10 @@ public void preInit(ProcessEngineConfigurationImpl configuration) {
assertNull(configuration.getDataSource());
PROCESSED = true;
}
@Override
public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
// TODO Auto-generated method stub
}
@Override
public void postProcessEngineBuild(ProcessEngine processEngine) {
// TODO Auto-generated method stub
}
}
@Order(Ordering.DEFAULT_ORDER + 1)
public static class AfterStandardConfiguration implements ProcessEnginePlugin {
public static class AfterStandardConfiguration extends AbstractProcessEnginePlugin {
static boolean PROCESSED = false;
@@ -59,18 +47,5 @@ public void preInit(ProcessEngineConfigurationImpl configuration) {
assertNotNull(configuration.getDataSource());
PROCESSED = true;
}
@Override
public void postInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
// TODO Auto-generated method stub
}
@Override
public void postProcessEngineBuild(ProcessEngine processEngine) {
// TODO Auto-generated method stub
}
}
}
@@ -14,7 +14,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
@@ -7,7 +7,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
Oops, something went wrong.

0 comments on commit 8be681c

Please sign in to comment.