Skip to content

Commit

Permalink
make unit tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
baixiac committed Apr 26, 2021
1 parent 75d7b40 commit 42b8c5d
Show file tree
Hide file tree
Showing 50 changed files with 203 additions and 190 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN ./gradlew downloadDependencies :radar-auth:shadowJar
# now we copy our application source code and build it
COPY radar-auth radar-auth
COPY src src
RUN ./gradlew -s bootRepackage
RUN ./gradlew -s bootWar

# Run stage
FROM openjdk:8-jre-alpine
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ will generate few files:
To optimize the ManagementPortal application for production, run:
./gradlew -Pprod clean bootRepackage
./gradlew -Pprod clean bootWar
### Hosting in production
The latest Meta-QR code implementation requires REST resources on `api/meta-token/*` should definitely be rate-limited by upstream servers.
Expand Down Expand Up @@ -319,7 +319,7 @@ To stop it and remove the container, run:
You can also fully dockerize your application and all the services that it depends on.
To achieve this, first build a docker image of your app by running:
./gradlew bootRepackage -Pprod buildDocker
./gradlew bootWar -Pprod buildDocker
Then run:
Expand Down
66 changes: 43 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
import org.gradle.internal.os.OperatingSystem

buildscript {
repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}")
}
}

plugins {
id 'org.springframework.boot' version '1.5.9.RELEASE'
id 'org.springframework.boot' version "${spring_boot_version}"
id "com.moowork.node" version "1.2.0"
id "io.spring.dependency-management" version "1.0.7.RELEASE"
id 'de.undercouch.download' version '4.1.1' apply false
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
}

apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'com.moowork.node'
apply plugin: 'io.spring.dependency-management'

repositories {
mavenCentral()
jcenter()
}

allprojects {
Expand Down Expand Up @@ -43,25 +64,20 @@ allprojects {

description = 'MangementPortal application to manage studies and participants'

apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'com.moowork.node'
apply plugin: 'io.spring.dependency-management'

defaultTasks 'bootRun'

configurations {
compile.exclude module: "spring-boot-starter-tomcat"
}


bootRepackage {
mainClass = 'org.radarbase.management.ManagementPortalApp'
bootWar {
mainClassName = 'org.radarbase.management.ManagementPortalApp'
launchScript()
// buildInfo()
}

springBoot {
mainClass = 'org.radarbase.management.ManagementPortalApp'
executable = true
buildInfo()
}

Expand All @@ -80,15 +96,15 @@ if (OperatingSystem.current().isWindows()) {
}

bootRun {
addResources = false
sourceResources sourceSets.main
dependsOn pathingJar
doFirst {
classpath = files("$buildDir/classes/java/main", "$buildDir/resources/main", pathingJar.archivePath)
}
}
} else {
bootRun {
addResources = false
sourceResources sourceSets.main
}
}

Expand Down Expand Up @@ -124,11 +140,6 @@ if (project.hasProperty('graphite')) {
//ext.moduleDescription = 'Management Portal application'
ext.findbugAnnotationVersion = '3.0.2'

repositories {
mavenCentral()
jcenter()
}

dependencies {
compile "io.github.jhipster:jhipster:${jhipster_server_version}"
compile "io.dropwizard.metrics:metrics-core:${dropwizard_metrics_version}"
Expand Down Expand Up @@ -160,7 +171,7 @@ dependencies {
compile group: 'javax.ws.rs', name: 'jsr311-api', version: '1.1.1'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: findbugAnnotationVersion
compile "org.hibernate:hibernate-envers:${hibernate_version}"
compile "org.hibernate:hibernate-validator"
compile "org.hibernate:hibernate-validator:${hibernate_version}"
compile("org.liquibase:liquibase-core")
compile "com.mattbertolini:liquibase-slf4j:${liquibase_slf4j_version}"
compile "org.springframework.boot:spring-boot-actuator"
Expand All @@ -173,19 +184,28 @@ dependencies {
exclude group: 'org.hibernate', module: 'hibernate-entitymanager'
}
compile "org.springframework.boot:spring-boot-starter-security"
compile "org.springframework.cloud:spring-cloud-starter-zuul:${zuul_proxy_version}"
compile("org.springframework.boot:spring-boot-starter-web") {
compile("org.springframework.cloud:spring-cloud-starter-netflix-zuul:${spring_cloud_version}")
// {
// exclude module: "spring-cloud-starter-netflix-ribbon"
// exclude module: "spring-cloud-starter-netflix-hystrix"
// }
// compile "org.springframework.cloud:spring-cloud-starter-netflix-hystrix:2.2.8.RELEASE"
// compile "org.springframework.cloud:spring-cloud-starter-netflix-ribbon:2.2.8.RELEASE"
compile "org.springframework.cloud:spring-cloud-context:${spring_cloud_version}"
compile "org.springframework.cloud:spring-cloud-commons:${spring_cloud_version}"
compile("org.springframework.boot:spring-boot-starter-web:${spring_boot_version}") {
exclude module: 'spring-boot-starter-tomcat'
}
compile "org.springframework.boot:spring-boot-starter-undertow"
compile "org.springframework.boot:spring-boot-starter-thymeleaf"
compile("org.springframework:spring-context-support")
compile("org.springframework:spring-jdbc")
compile "org.springframework.security:spring-security-config"
compile "org.springframework.security:spring-security-data"
compile ("org.springframework.security:spring-security-web"){
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
}
compile "org.springframework.security:spring-security-jwt"
compile "org.springframework.security:spring-security-jwt:${spring_security_jwt_versions}"
compile "org.springframework.security.oauth:spring-security-oauth2:${spring_security_oauth2_version}"
compile("io.springfox:springfox-swagger2:${springfox_version}") {
exclude module: 'mapstruct'
Expand Down Expand Up @@ -227,7 +247,7 @@ wrapper {
gradleVersion '6.7.1'
}

task stage(dependsOn: 'bootRepackage') {
task stage(dependsOn: 'bootWar') {
}

task ghPagesJavadoc(type: Copy, dependsOn: javadoc) {
Expand Down
14 changes: 8 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ commons_io_version=2.6
# Overridden to get metrics-jcache
dropwizard_metrics_version=3.2.2
logstash_logback_encoder_version=4.9
javax_transaction_version=1.2
javax_transaction_version=3.9.1
json_path_version=0.9.1
jhipster_server_version=1.1.2
hazelcast_hibernate52_version=1.2
hibernate_version=5.2.12.Final
hibernate_version=5.2.1.Final
hikaricp_version=2.7.4
liquibase_slf4j_version=2.0.0
liquibase_hibernate5_version=3.6
Expand All @@ -20,15 +20,17 @@ node_version=6.10.0
npm_version=4.3.0
prometheus_simpleclient_version=0.0.20
postgresql_version=42.2.14
spring_security_jwt_versions=1.1.1.RELEASE
spring_security_oauth2_version=2.3.5.RELEASE
springfox_version=2.6.1
spring_boot_version=1.5.9.RELEASE
gatling_version=2.3.1
spring_boot_version=2.3.10.RELEASE
spring_boot_devtools_version=2.4.5
spring_cloud_version=2.2.8.RELEASE
gatling_version=3.3.1
mapstruct_version=1.1.0.Final
undertow_version=1.4.10.Final
yarn_version=0.21.3
zuul_proxy_version=1.3.5.RELEASE
spring_data_envers_version=1.1.10.RELEASE
spring_data_envers_version=2.3.9.RELEASE
jackson_version=2.9.10
jackson_dataformat_version=2.9.10
javaxXmlBindVersion=2.3.3
Expand Down
2 changes: 1 addition & 1 deletion gradle/docker.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem

task buildDocker(type: Exec, dependsOn: bootRepackage) {
task buildDocker(type: Exec, dependsOn: bootWar) {
doFirst {
copy {
from "src/main/docker/"
Expand Down
2 changes: 1 addition & 1 deletion gradle/profile_dev.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.moowork.node'
ext.logbackLoglevel = 'DEBUG'

dependencies {
compile "org.springframework.boot:spring-boot-devtools"
compile "org.springframework.boot:spring-boot-devtools:${spring_boot_devtools_version}"
}

def profiles = 'dev'
Expand Down
7 changes: 3 additions & 4 deletions src/gatling/scala/ManagementPortalSimulation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ abstract class ManagementPortalSimulation extends Simulation {
// Log failed HTTP requests
//context.getLogger("io.gatling.http").setLevel(Level.valueOf("DEBUG"))

val baseURL: String = Option(System.getProperty("baseURL")) getOrElse """http://127.0.0.1:8080"""
val baseUrl: String = Option(System.getProperty("baseUrl")) getOrElse """http://127.0.0.1:8080"""

val httpConf: HttpProtocolBuilder = http
.baseURL(baseURL)
val httpConf: HttpProtocolBuilder = http.baseUrl(baseUrl)
.inferHtmlResources()
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
Expand Down Expand Up @@ -53,7 +52,7 @@ abstract class ManagementPortalSimulation extends Simulation {
def run(): Unit = {
val users = scenario("Users").exec(scn)
setUp(
users.inject(rampUsers(100) over (1 minutes))
users.inject(rampUsers(100) during (1 minutes))
).protocols(httpConf)
}
}
2 changes: 1 addition & 1 deletion src/gatling/scala/ProjectGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ProjectGatlingTest extends ManagementPortalSimulation {
.exec(http("Create new project")
.post("/api/projects")
.headers(headers_http_authenticated)
.body(StringBody("""{"id":null, "projectName":"PROJECT-${randstring}", "description":"SAMPLE_TEXT", "organization":"SAMPLE_TEXT", "location":"SAMPLE_TEXT", "startDate":"2020-01-01T00:00:00.000Z", "projectStatus":null, "endDate":"2020-01-01T00:00:00.000Z", "projectAdmin":null}""")).asJSON
.body(StringBody("""{"id":null, "projectName":"PROJECT-${randstring}", "description":"SAMPLE_TEXT", "organization":"SAMPLE_TEXT", "location":"SAMPLE_TEXT", "startDate":"2020-01-01T00:00:00.000Z", "projectStatus":null, "endDate":"2020-01-01T00:00:00.000Z", "projectAdmin":null}""")).asJson
.check(status.is(201))
.check(headerRegex("Location", "(.*)").saveAs("new_project_url"))).exitHereIfFailed
.pause(5)
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/SensorDataGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SensorDataGatlingTest extends ManagementPortalSimulation {
.exec(http("Create new sourceData")
.post("/api/source-data")
.headers(headers_http_authenticated)
.body(StringBody("""{"id":null, "sourceDataType":"SAMPLE_TEXT", "sourceDataName":"SOURCEDATA-${randstring}", "processingState":null, "keySchema":"SAMPLE_TEXT", "frequency":"SAMPLE_TEXT"}""")).asJSON
.body(StringBody("""{"id":null, "sourceDataType":"SAMPLE_TEXT", "sourceDataName":"SOURCEDATA-${randstring}", "processingState":null, "keySchema":"SAMPLE_TEXT", "frequency":"SAMPLE_TEXT"}""")).asJson
.check(status.is(201))
.check(headerRegex("Location", "(.*)").saveAs("new_sourceData_url"))).exitHereIfFailed
.pause(5)
Expand Down
4 changes: 2 additions & 2 deletions src/gatling/scala/SourceGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SourceGatlingTest extends ManagementPortalSimulation {
.exec(http("Create new sourceType")
.post("/api/source-types")
.headers(headers_http_authenticated)
.body(StringBody("""{"id":null, "producer":"GATLING", "model":"MODEL-${randstring}", "catalogVersion":"v1", "sourceTypeScope": "ACTIVE"}""")).asJSON
.body(StringBody("""{"id":null, "producer":"GATLING", "model":"MODEL-${randstring}", "catalogVersion":"v1", "sourceTypeScope": "ACTIVE"}""")).asJson
.check(status.is(201))
.check(headerRegex("Location", "(.*)").saveAs("new_sourceType_url"))
.check(jsonPath("$.id").saveAs("sourceTypeId"))).exitHereIfFailed
Expand All @@ -50,7 +50,7 @@ class SourceGatlingTest extends ManagementPortalSimulation {
.exec(http("Create new source")
.post("/api/sources")
.headers(headers_http_authenticated)
.body(StringBody("""{"id":null, "sourceName":"SOURCE-${randstring}", "assigned":false, "sourceType":{"id":"${sourceTypeId}"}}""")).asJSON
.body(StringBody("""{"id":null, "sourceName":"SOURCE-${randstring}", "assigned":false, "sourceType":{"id":"${sourceTypeId}"}}""")).asJson
.check(status.is(201))
.check(headerRegex("Location", "(.*)").saveAs("new_source_url"))).exitHereIfFailed
.pause(5)
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/SourceTypeGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SourceTypeGatlingTest extends ManagementPortalSimulation {
.exec(http("Create new sourceType")
.post("/api/source-types")
.headers(headers_http_authenticated)
.body(StringBody("""{"id":null, "producer":"GATLING", "model":"MODEL-${randstring}", "catalogVersion":"v1", "sourceTypeScope": "ACTIVE"}""")).asJSON
.body(StringBody("""{"id":null, "producer":"GATLING", "model":"MODEL-${randstring}", "catalogVersion":"v1", "sourceTypeScope": "ACTIVE"}""")).asJson
.check(status.is(201))
.check(headerRegex("Location", "(.*)").saveAs("new_sourceType_url"))).exitHereIfFailed
.pause(5)
Expand Down
2 changes: 1 addition & 1 deletion src/gatling/scala/SubjectGatlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SubjectGatlingTest extends ManagementPortalSimulation {
.exec(http("Create new subject")
.post("/api/subjects")
.headers(headers_http_authenticated)
.body(StringBody("""{"id":null, "externalLink":"SAMPLE_TEXT", "enternalId":"${randstring}", "project": {"id": "${project_id}"}}""")).asJSON
.body(StringBody("""{"id":null, "externalLink":"SAMPLE_TEXT", "enternalId":"${randstring}", "project": {"id": "${project_id}"}}""")).asJson
.check(status.is(201))
.check(headerRegex("Location", "(.*)").saveAs("new_subject_url"))).exitHereIfFailed
.pause(5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.radarbase.management.config.DefaultProfileUtil;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

/**
* This is a helper Java class that provides an alternative to creating a web.xml. This will be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -31,8 +29,7 @@
"org.radarbase.management.web"
})
@EnableZuulProxy
@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class,
MetricRepositoryAutoConfiguration.class})
@EnableAutoConfiguration
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class,
ManagementPortalProperties.class})
public class ManagementPortalApp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.MetricRepositoryAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -30,8 +28,7 @@
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,
value = SourceTypeLoader.class))
@EnableZuulProxy
@EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class,
MetricRepositoryAutoConfiguration.class})
@EnableAutoConfiguration
@EnableConfigurationProperties({LiquibaseProperties.class, ApplicationProperties.class,
ManagementPortalProperties.class})
public class ManagementPortalTestApp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
import io.github.jhipster.config.JHipsterProperties;
import java.util.concurrent.Executor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
Expand All @@ -27,7 +26,7 @@ public class AsyncConfiguration implements AsyncConfigurer {

@Override
@Bean(name = "taskExecutor")
public Executor getAsyncExecutor() {
public ExceptionHandlingAsyncTaskExecutor getAsyncExecutor() {
log.debug("Creating Async Task Executor");
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.radarbase.management.config;

import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
import io.github.jhipster.config.JHipsterConstants;
import io.github.jhipster.config.liquibase.AsyncSpringLiquibase;
import java.sql.SQLException;
Expand All @@ -16,7 +17,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.core.task.TaskExecutor;
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
Expand Down Expand Up @@ -47,7 +47,8 @@ public Server h2TCPServer() throws SQLException {
}

@Bean
public SpringLiquibase liquibase(@Qualifier("taskExecutor") TaskExecutor taskExecutor,
public SpringLiquibase liquibase(
@Qualifier("taskExecutor") ExceptionHandlingAsyncTaskExecutor taskExecutor,
DataSource dataSource, LiquibaseProperties liquibaseProperties) {

// Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start
Expand Down
Loading

0 comments on commit 42b8c5d

Please sign in to comment.