import static groovyx.net.http.Method.GET
import groovyx.net.http.HTTPBuilder
import java.util.Properties
import org.apache.http.conn.HttpHostConnectException

final File ampsFile = new File("${project.build.directory}/amps.properties")

assert ampsFile.exists(), "amps.properties doesn't exists at $ampsFile.absolutePath"

final Properties amps = new Properties()
ampsFile.withInputStream { amps.load(it) }

new HTTPBuilder("http://localhost:${amps['http.port']}${amps['context.path']}/plugins/servlet/database-console/login.do").request(GET) {
    headers.'Authorization' = "Basic YWRtaW46YWRtaW4=" // admin:admin base64 encoded
    response.success = { assert it.statusLine.statusCode == 200, "Expected status 200 on the DB console page" }
    response.failure = { assert false, "The HTTP GET should have succeeded on the DB console page" }
}