Skip to content

Commit

Permalink
restored previous Base test.
Browse files Browse the repository at this point in the history
  • Loading branch information
arcuri82 committed Jul 4, 2019
1 parent 989a116 commit 8a655f7
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 19 deletions.
4 changes: 4 additions & 0 deletions e2e-tests/spring-rest-postgres/pom.xml
Expand Up @@ -111,6 +111,10 @@
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.testcontainers</groupId> <groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId> <artifactId>testcontainers</artifactId>
Expand Down
@@ -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<String>) {
SpringApplication.run(BaseApp::class.java, *args)
}
}

@Autowired
private lateinit var em : EntityManager


@GetMapping
open fun get() : ResponseEntity<Any> {

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<Any>()
}
}
@@ -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 com.foo.spring.rest.postgres.SwaggerConfiguration
import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -19,12 +19,12 @@ import javax.persistence.EntityManager
@EnableSwagger2 @EnableSwagger2
@SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) @SpringBootApplication(exclude = [SecurityAutoConfiguration::class])
@RequestMapping(path = ["/api/basic"]) @RequestMapping(path = ["/api/basic"])
open class BasicApp : SwaggerConfiguration() { open class Ind0App : SwaggerConfiguration() {


companion object { companion object {
@JvmStatic @JvmStatic
fun main(args: Array<String>) { fun main(args: Array<String>) {
SpringApplication.run(BasicApp::class.java, *args) SpringApplication.run(Ind0App::class.java, *args)
} }
} }


Expand Down
@@ -0,0 +1,4 @@
create table X (
id BIGINT,
constraint pk_x primary key (id)
);
@@ -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"
}

This file was deleted.

@@ -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"
}
@@ -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.core.problem.rest.HttpVerb
import org.evomaster.e2etests.spring.rest.postgres.SpringRestPostgresTestBase import org.evomaster.e2etests.spring.rest.postgres.SpringRestPostgresTestBase
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
Expand All @@ -15,16 +16,16 @@ class BasicEMTest : SpringRestPostgresTestBase(){
companion object { companion object {
@BeforeAll @JvmStatic @BeforeAll @JvmStatic
fun initClass() { fun initClass() {
SpringRestPostgresTestBase.initKlass(BasicController()) SpringRestPostgresTestBase.initKlass(BaseController())
} }
} }


@Test @Test
fun testRunEM() { fun testRunEM() {


runTestHandlingFlakyAndCompilation( runTestHandlingFlakyAndCompilation(
"BasicEM", "BaseEM",
"org.bar.BasicEM", "org.bar.BaseEM",
100 100
) { args -> ) { args ->


Expand Down
@@ -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)
}
}
}

0 comments on commit 8a655f7

Please sign in to comment.