From 8a655f77142aa5005bec09916e2e9ff4c39da77b Mon Sep 17 00:00:00 2001 From: arcuri82 Date: Thu, 4 Jul 2019 12:03:36 +0200 Subject: [PATCH] restored previous Base test. --- e2e-tests/spring-rest-postgres/pom.xml | 4 ++ .../foo/spring/rest/postgres/base/BaseApp.kt | 46 +++++++++++++++++++ .../{basic/BasicApp.kt => ind0/Ind0App.kt} | 6 +-- .../resources/schema/base/V1.0__createDB.sql | 4 ++ .../schema/{basic => ind0}/V1.0__createDB.sql | 0 .../rest/postgres/base/BaseController.kt | 12 +++++ .../rest/postgres/basic/BasicController.kt | 11 ----- .../rest/postgres/ind0/Ind0Controller.kt | 11 +++++ .../BasicEMTest.kt => base/BaseEMTest.kt} | 11 +++-- .../spring/rest/postgres/ind0/Ind0EMTest.kt | 39 ++++++++++++++++ 10 files changed, 125 insertions(+), 19 deletions(-) create mode 100644 e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/base/BaseApp.kt rename e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/{basic/BasicApp.kt => ind0/Ind0App.kt} (94%) create mode 100644 e2e-tests/spring-rest-postgres/src/main/resources/schema/base/V1.0__createDB.sql rename e2e-tests/spring-rest-postgres/src/main/resources/schema/{basic => ind0}/V1.0__createDB.sql (100%) create mode 100644 e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/base/BaseController.kt delete mode 100644 e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/basic/BasicController.kt create mode 100644 e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/ind0/Ind0Controller.kt rename e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/{basic/BasicEMTest.kt => base/BaseEMTest.kt} (76%) create mode 100644 e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/ind0/Ind0EMTest.kt diff --git a/e2e-tests/spring-rest-postgres/pom.xml b/e2e-tests/spring-rest-postgres/pom.xml index 2b2ab3e9bc..04483322f1 100644 --- a/e2e-tests/spring-rest-postgres/pom.xml +++ b/e2e-tests/spring-rest-postgres/pom.xml @@ -111,6 +111,10 @@ org.junit.jupiter junit-jupiter-engine + + org.junit.platform + junit-platform-launcher + org.testcontainers testcontainers diff --git a/e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/base/BaseApp.kt b/e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/base/BaseApp.kt new file mode 100644 index 0000000000..8d086141a3 --- /dev/null +++ b/e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/base/BaseApp.kt @@ -0,0 +1,46 @@ +package com.foo.spring.rest.postgres.base + +import com.foo.spring.rest.postgres.SwaggerConfiguration +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.SpringApplication +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import springfox.documentation.swagger2.annotations.EnableSwagger2 +import javax.persistence.EntityManager + + + + +/** + * Created by arcuri82 on 21-Jun-19. + */ +@EnableSwagger2 +@SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) +@RequestMapping(path = ["/api/basic"]) +open class BaseApp : SwaggerConfiguration() { + + companion object { + @JvmStatic + fun main(args: Array) { + SpringApplication.run(BaseApp::class.java, *args) + } + } + + @Autowired + private lateinit var em : EntityManager + + + @GetMapping + open fun get() : ResponseEntity { + + val query = em.createNativeQuery("select * from X where id>0") + val res = query.resultList + + val status = if(res.isEmpty()) 400 else 200 + + return ResponseEntity.status(status).build() + } +} diff --git a/e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/basic/BasicApp.kt b/e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/ind0/Ind0App.kt similarity index 94% rename from e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/basic/BasicApp.kt rename to e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/ind0/Ind0App.kt index ed9f581eeb..280f47ae3d 100644 --- a/e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/basic/BasicApp.kt +++ b/e2e-tests/spring-rest-postgres/src/main/kotlin/com/foo/spring/rest/postgres/ind0/Ind0App.kt @@ -1,4 +1,4 @@ -package com.foo.spring.rest.postgres.basic +package com.foo.spring.rest.postgres.ind0 import com.foo.spring.rest.postgres.SwaggerConfiguration import org.springframework.beans.factory.annotation.Autowired @@ -19,12 +19,12 @@ import javax.persistence.EntityManager @EnableSwagger2 @SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) @RequestMapping(path = ["/api/basic"]) -open class BasicApp : SwaggerConfiguration() { +open class Ind0App : SwaggerConfiguration() { companion object { @JvmStatic fun main(args: Array) { - SpringApplication.run(BasicApp::class.java, *args) + SpringApplication.run(Ind0App::class.java, *args) } } diff --git a/e2e-tests/spring-rest-postgres/src/main/resources/schema/base/V1.0__createDB.sql b/e2e-tests/spring-rest-postgres/src/main/resources/schema/base/V1.0__createDB.sql new file mode 100644 index 0000000000..223b9e8a2a --- /dev/null +++ b/e2e-tests/spring-rest-postgres/src/main/resources/schema/base/V1.0__createDB.sql @@ -0,0 +1,4 @@ +create table X ( + id BIGINT, + constraint pk_x primary key (id) +); \ No newline at end of file diff --git a/e2e-tests/spring-rest-postgres/src/main/resources/schema/basic/V1.0__createDB.sql b/e2e-tests/spring-rest-postgres/src/main/resources/schema/ind0/V1.0__createDB.sql similarity index 100% rename from e2e-tests/spring-rest-postgres/src/main/resources/schema/basic/V1.0__createDB.sql rename to e2e-tests/spring-rest-postgres/src/main/resources/schema/ind0/V1.0__createDB.sql diff --git a/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/base/BaseController.kt b/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/base/BaseController.kt new file mode 100644 index 0000000000..b02a33be0d --- /dev/null +++ b/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/base/BaseController.kt @@ -0,0 +1,12 @@ +package com.foo.spring.rest.postgres.base + + +import com.foo.spring.rest.postgres.SpringRestPostgresController + +/** + * Created by arcuri82 on 21-Jun-19. + */ +class BaseController : SpringRestPostgresController(BaseApp::class.java) { + + override fun pathToFlywayFiles() = "classpath:/schema/base" +} \ No newline at end of file diff --git a/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/basic/BasicController.kt b/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/basic/BasicController.kt deleted file mode 100644 index 1ed60df27e..0000000000 --- a/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/basic/BasicController.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.foo.spring.rest.postgres.basic - -import com.foo.spring.rest.postgres.SpringRestPostgresController - -/** - * Created by arcuri82 on 21-Jun-19. - */ -class BasicController : SpringRestPostgresController(BasicApp::class.java) { - - override fun pathToFlywayFiles() = "classpath:/schema/basic" -} \ No newline at end of file diff --git a/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/ind0/Ind0Controller.kt b/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/ind0/Ind0Controller.kt new file mode 100644 index 0000000000..c08bcd9c03 --- /dev/null +++ b/e2e-tests/spring-rest-postgres/src/test/kotlin/com/foo/spring/rest/postgres/ind0/Ind0Controller.kt @@ -0,0 +1,11 @@ +package com.foo.spring.rest.postgres.ind0 + +import com.foo.spring.rest.postgres.SpringRestPostgresController + +/** + * Created by arcuri82 on 21-Jun-19. + */ +class Ind0Controller : SpringRestPostgresController(Ind0App::class.java) { + + override fun pathToFlywayFiles() = "classpath:/schema/ind0" +} \ No newline at end of file diff --git a/e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/basic/BasicEMTest.kt b/e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/base/BaseEMTest.kt similarity index 76% rename from e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/basic/BasicEMTest.kt rename to e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/base/BaseEMTest.kt index b12b9d4bf5..fe46cb07f1 100644 --- a/e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/basic/BasicEMTest.kt +++ b/e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/base/BaseEMTest.kt @@ -1,6 +1,7 @@ -package org.evomaster.e2etests.spring.rest.postgres.basic +package org.evomaster.e2etests.spring.rest.postgres.base -import com.foo.spring.rest.postgres.basic.BasicController + +import com.foo.spring.rest.postgres.base.BaseController import org.evomaster.core.problem.rest.HttpVerb import org.evomaster.e2etests.spring.rest.postgres.SpringRestPostgresTestBase import org.junit.jupiter.api.Assertions.assertTrue @@ -15,7 +16,7 @@ class BasicEMTest : SpringRestPostgresTestBase(){ companion object { @BeforeAll @JvmStatic fun initClass() { - SpringRestPostgresTestBase.initKlass(BasicController()) + SpringRestPostgresTestBase.initKlass(BaseController()) } } @@ -23,8 +24,8 @@ class BasicEMTest : SpringRestPostgresTestBase(){ fun testRunEM() { runTestHandlingFlakyAndCompilation( - "BasicEM", - "org.bar.BasicEM", + "BaseEM", + "org.bar.BaseEM", 100 ) { args -> diff --git a/e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/ind0/Ind0EMTest.kt b/e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/ind0/Ind0EMTest.kt new file mode 100644 index 0000000000..b45ab5f07d --- /dev/null +++ b/e2e-tests/spring-rest-postgres/src/test/kotlin/org/evomaster/e2etests/spring/rest/postgres/ind0/Ind0EMTest.kt @@ -0,0 +1,39 @@ +package org.evomaster.e2etests.spring.rest.postgres.ind0 + +import com.foo.spring.rest.postgres.ind0.Ind0Controller +import org.evomaster.core.problem.rest.HttpVerb +import org.evomaster.e2etests.spring.rest.postgres.SpringRestPostgresTestBase +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Test + +/** + * Created by arcuri82 on 21-Jun-19. + */ +class Ind0EMTest : SpringRestPostgresTestBase(){ + + companion object { + @BeforeAll @JvmStatic + fun initClass() { + SpringRestPostgresTestBase.initKlass(Ind0Controller()) + } + } + + @Test + fun testRunEM() { + + runTestHandlingFlakyAndCompilation( + "Ind0EM", + "org.bar.Ind0EM", + 100 + ) { args -> + + val solution = initAndRun(args) + + assertTrue(solution.individuals.size >= 1) + + assertHasAtLeastOne(solution, HttpVerb.GET, 400) + assertHasAtLeastOne(solution, HttpVerb.GET, 200) + } + } +} \ No newline at end of file