Commit 46cb7a4b authored by Sreenidhi Iyangar's avatar Sreenidhi Iyangar
Browse files

Experimental code: SpringBoot2+SpringFox3 with some test failure

parent cb0dcc0f
......@@ -19,14 +19,16 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<!-- <version>1.5.10.RELEASE</version>-->
<version>2.0.0.RELEASE</version>
<!-- <version>2.1.4.RELEASE</version>-->
</parent>
<dependencies>
<dependency>
<!-- <dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......@@ -72,7 +74,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
......@@ -82,31 +84,81 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
<!-- <scope>provided</scope>-->
</dependency>
<!-- documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
<!-- <version>2.8.0</version>-->
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
<!-- <version>2.8.0</version>-->
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>2.8.0</version>
<!-- <version>2.8.0</version>-->
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>2.8.0</version>
<!-- <version>2.8.0</version>-->
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-properties-migrator</artifactId>
<!-- <scope>runtime</scope>-->
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<!-- <version>2.0.1.RELEASE</version>-->
<version>2.1.4.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<!-- <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.1-jre</version>
</dependency>-->
<!-- <version>23.6.1-jre</version>-->
<!-- https://mvnrepository.com/artifact/com.fasterxml/classmate -->
<!-- <dependency>
<groupId>com.fasterxml</groupId>
<artifactId>classmate</artifactId>
<version>1.3.4</version>
</dependency>-->
</dependencies>
<repositories>
<repository>
<id>jcenter-snapshots</id>
<name>jcenter</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
</repository>
</repositories>
<build>
<directory>${buildDirectory}</directory>
<plugins>
......
......@@ -20,17 +20,22 @@ package uk.ac.ebi.ampt2d.registry;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
//import org.springframework.boot.web.support.SpringBootServletInitializer;
//import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 2.x
import org.springframework.core.SpringVersion;
@SpringBootApplication
public class PropertyRegistryServiceApplication extends SpringBootServletInitializer {
public class PropertyRegistryServiceApplication {//} extends SpringBootServletInitializer {
public static void main(String[] args) throws Exception {
System.out.println("version===: " + SpringVersion.getVersion());
SpringApplication.run(PropertyRegistryServiceApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(PropertyRegistryServiceApplication.class);
}
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
// return application.sources(PropertyRegistryServiceApplication.class);
// }
}
......@@ -18,8 +18,8 @@
package uk.ac.ebi.ampt2d.registry.config;
import com.fasterxml.classmate.TypeResolver;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
//import com.google.common.base.Predicate;
//import com.google.common.base.Predicates;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -43,7 +43,9 @@ import springfox.documentation.spring.data.rest.configuration.SpringDataRestConf
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger.web.UiConfiguration;
import springfox.documentation.swagger.web.UiConfigurationBuilder;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
//import springfox.documentation.swagger2.annotations.EnableSwagger2;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux;
import java.lang.reflect.WildcardType;
import java.util.Arrays;
......@@ -51,12 +53,13 @@ import java.util.Arrays;
import static springfox.documentation.schema.AlternateTypeRules.newRule;
@Configuration
@EnableSwagger2
@Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class})
//@EnableSwagger2
@EnableSwagger2WebFlux
@Import({/*SpringDataRestConfiguration.class, */BeanValidatorPluginsConfiguration.class})
public class SwaggerConfiguration {
@Autowired
private TypeResolver typeResolver;
// @Autowired
// private TypeResolver typeResolver;
private SecurityReference securityReference = SecurityReference.builder()
.reference("Authorization").scopes(new AuthorizationScope[0]).build();
......@@ -69,8 +72,10 @@ public class SwaggerConfiguration {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(getScanRestServicesPathPredicate())
.paths(PathSelectors.any()) //getScanRestServicesPathPredicate())
// .paths(getScanRestServicesPathPredicate())
.build()
/*
.apiInfo(getApiInfo())
.pathMapping("/")
.tags(
......@@ -81,17 +86,18 @@ public class SwaggerConfiguration {
.securitySchemes(Arrays.asList(new ApiKey("Authorization", "Authorization", "header")))
.securityContexts(Arrays.asList(securityContext))
.alternateTypeRules(getSubstitutionRules());
*/
;
}
private Predicate<String> getScanRestServicesPathPredicate() {
/* private Predicate<String> getScanRestServicesPathPredicate() {
return Predicates.and(
Predicates.not(PathSelectors.regex("/actuator.*")), // Hide spring-actuator
Predicates.not(PathSelectors.regex("/error.*")), // Hide spring-data error
Predicates.not(PathSelectors.regex("/profile.*")),// Hide spring-data profile
Predicates.not(PathSelectors.regex("/users.*")) // Hide user-profile
);
}
}*/
private ApiInfo getApiInfo() {
return new ApiInfoBuilder()
......@@ -105,11 +111,11 @@ public class SwaggerConfiguration {
.build();
}
private AlternateTypeRule getSubstitutionRules() {
return newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class));
}
// private AlternateTypeRule getSubstitutionRules() {
// return newRule(typeResolver.resolve(DeferredResult.class,
// typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
// typeResolver.resolve(WildcardType.class));
// }
@Bean
UiConfiguration uiConfig() {
......
spring.application.name=ampt2d-property-registry
# Bean jmx domain for actuator when using multiple applications with tomcat.
endpoints.jmx.domain=ampt2d-property-registry
#endpoints.jmx.domain=ampt2d-property-registry
management.endpoints.jmx.domain=ampt2d-property-registry
spring.jmx.default-domain=ampt2d-property-registry
management.security.enabled=false
#management.security.enabled=false
management.context-path=/actuator
#management.context-path=/actuator
management.server.servlet.context-path=/actuator
management.endpoint.health.show-details=always
endpoints.health.sensitive=false
#endpoints.health.sensitive=false
spring.datasource.url=@ampt2d-property-registry-db.url@
spring.datasource.username=@ampt2d-property-registry-db.username@
spring.datasource.password=@ampt2d-property-registry-db.password@
spring.jpa.hibernate.ddl-auto=none
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
spring.jpa.generate-ddl=true
#spring.datasource.url=@ampt2d-property-registry-db.url@
#spring.datasource.username=@ampt2d-property-registry-db.username@
#spring.datasource.password=@ampt2d-property-registry-db.password@
#spring.jpa.hibernate.ddl-auto=none
#spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
#spring.jpa.generate-ddl=true
security.enabled=true
security.oauth2.resource.userInfoUri=https://www.googleapis.com/userinfo/v2/me
security.oauth2.resource.filter-order=3
#security.oauth2.resource.filter-order=3
spring.mail.host=@smtp-host@
spring.mail.port=587
......@@ -31,4 +33,6 @@ mail.from=@amp-t2d-email-id@
mail.to=@amp-t2d-email-id@
mail.subject=AMP-T2D Registry Update
registry.protocols=https
\ No newline at end of file
registry.protocols=https
server.port = 8082
\ No newline at end of file
......@@ -17,6 +17,7 @@
*/
package uk.ac.ebi.ampt2d.registry;
import com.fasterxml.classmate.TypeResolver;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -41,6 +42,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@DirtiesContext(classMode = BEFORE_CLASS)
public class RegistryUpdateNotificationFailure {
@Autowired
private TypeResolver typeResolver;
@Autowired
private MockMvc mockMvc;
......
spring.application.name=ampt2d-property-registry
# Bean jmx domain for actuator when using multiple applications with tomcat.
endpoints.jmx.domain=ampt2d-property-registry
#endpoints.jmx.domain=ampt2d-property-registry
management.endpoints.jmx.domain=ampt2d-property-registry
spring.jmx.default-domain=ampt2d-property-registry
management.security.enabled=false
#management.security.enabled=false
management.context-path=/actuator
#management.context-path=/actuator
management.server.servlet.context-path=/actuator
management.endpoint.health.show-details=always
endpoints.health.sensitive=false
#endpoints.health.sensitive=false
registry.protocols=http
spring.jpa.hibernate.ddl-auto=create
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment