Skip to content

Commit

Permalink
Restructured project into two sub-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Sep 22, 2014
1 parent 0e280f1 commit f6ff731
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 144 deletions.
84 changes: 84 additions & 0 deletions acceptance-tests/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import net.thucydides.core.reports.ResultChecker
import net.thucydides.core.reports.html.HtmlAggregateStoryReporter

buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
maven { url "https://oss.sonatype.org/content/repositories/releases"}
maven { url "https://oss.sonatype.org/content/repositories/snapshots"}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.6.RELEASE")
classpath("net.thucydides:thucydides-core:0.9.270-SNAPSHOT")
}
}


apply plugin: ThucydidesPlugin

thucydides.projectKey = 'flying-high-acceptance-tests'

dependencies {
compile("org.codehaus.groovy:groovy-all:2.3.6")
compile("com.google.guava:guava:18.0")

compile("org.springframework.data:spring-data-mongodb")
compile("org.springframework.data:spring-data-rest-webmvc")

compile("com.wakaleo.flying-high:flights-service:0.1.0")
testCompile("org.spockframework:spock-core:0.7-groovy-2.0")
testCompile("junit:junit")
testCompile "org.codehaus.groovy.modules.http-builder:http-builder:0.7"
testCompile 'org.easytesting:fest-assert-core:2.0M10'
testCompile 'net.thucydides:thucydides-core:0.9.270-SNAPSHOT'
testCompile 'net.thucydides:thucydides-jbehave-plugin:0.9.270-SNAPSHOT'

}

// Common test configuration
test {
systemProperty 'thucydides.capability.types', 'capability,feature'
systemProperty 'thucydides.test.root', 'flyinghigh.services'
useJUnit()
}

aggregate.mustRunAfter test

clean{
delete "target"
}

class ThucydidesPlugin implements Plugin<Project> {
void apply(Project project) {
project.extensions.create("thucydides", ThucydidesPluginExtension)
project.task('aggregate') << {
logger.lifecycle("Generating Thucydides Reports for ${project.thucydides.projectKey} to directory $project.thucydides.outputDirectory")
System.properties['thucydides.project.key'] = project.thucydides.projectKey
def reporter = new HtmlAggregateStoryReporter(project.thucydides.projectKey)
reporter.outputDirectory = new File(project.thucydides.outputDirectory)
reporter.issueTrackerUrl = project.thucydides.issueTrackerUrl
reporter.jiraUrl = project.thucydides.jiraUrl
reporter.jiraProject = project.thucydides.jiraProject
reporter.generateReportsForTestResultsFrom(new File(project.projectDir, project.thucydides.sourceDirectory))
}

project.task('checkOutcomes') << {
def reportDir = new File(project.projectDir, project.thucydides.outputDirectory)
logger.lifecycle("Checking Thucydides results for ${project.thucydides.projectKey} in directory $reportDir")
def checker = new ResultChecker(reportDir)
checker.checkTestResults()
}

}
}

class ThucydidesPluginExtension {
def String outputDirectory = 'target/site/thucydides'
def String projectKey
def String issueTrackerUrl
def String jiraUrl
def String jiraProject
def String sourceDirectory = outputDirectory
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package flyinghigh.services.acceptancetests;

import net.thucydides.jbehave.ThucydidesJUnitStory;
import org.springframework.boot.test.IntegrationTest;

/**
* Created by john on 18/09/2014.
*/
@IntegrationTest
public class ListingAirports extends ThucydidesJUnitStory {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import java.util.List;

import static org.fest.assertions.Assertions.assertThat;

/**
* Created by john on 17/09/2014.
*/
Expand All @@ -29,8 +31,10 @@ public void whenIAskForAListOfAirports() {
retrievedAirports = airportClientSteps.listAllAirports("/airports");
}



@Then("I should obtain at least the following: $expectedAirports")
public void thenIShouldObtainAtLeastTheFollowing(ExamplesTable expectedAirports) {
// PENDING
assertThat(retrievedAirports).isNotEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import flyinghigh.services.flights.domain.Airport;
import net.thucydides.core.annotations.Step;
import net.thucydides.core.util.EnvironmentVariables;
import net.thucydides.core.util.SystemEnvironmentVariables;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;

Expand All @@ -18,11 +20,25 @@ public class AirportClientSteps {
APPLICATION_JSON_HEADER.setContentType(MediaType.APPLICATION_JSON);
}


EnvironmentVariables environmentVariables;

public AirportClientSteps() {
environmentVariables = new SystemEnvironmentVariables();
}

public String getBaseFlightUrl() {
String environment = environmentVariables.getProperty("webservice.environment","local");
if (environment.equals("local")) {
return "http://localhost:8090/";
} else {
return "http://" + environment + "-" + "flights.cfapps.io";
}
}

@Step
public List<Airport> listAllAirports(String path) {
String baseUrl = "http://localhost:8090/";

String response = restTemplate.getForObject(baseUrl + path, String.class);
String response = restTemplate.getForObject(getBaseFlightUrl() + path, String.class);
// ResponseEntity<Resource<List<Airport>>> responseEntity
// = restTemplate.exchange(baseUrl + path,
// HttpMethod.GET, null,
Expand Down
2 changes: 2 additions & 0 deletions acceptance-tests/src/test/resources/thucydides.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Use 'local', 'dev' or 'prod'
webservice.environment = local
2 changes: 2 additions & 0 deletions acceptance-tests/thucydides.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Use 'local', 'dev' or 'prod'
webservice.environment = local
152 changes: 14 additions & 138 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import net.thucydides.core.reports.html.HtmlAggregateStoryReporter

buildscript {
repositories {
mavenLocal()
Expand All @@ -11,154 +9,32 @@ buildscript {
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.6.RELEASE")
classpath group: 'org.cloudfoundry', name: 'cf-gradle-plugin', version: '1.0.4'
classpath("net.thucydides:thucydides-core:0.9.269")
classpath("net.thucydides:thucydides-core:0.9.270-SNAPSHOT")
}
}

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

apply plugin: ThucydidesPlugin
apply plugin: 'cloudfoundry'
//apply plugin: 'spring-boot'

allprojects {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven'

sourceCompatibility = 1.8
targetCompatibility = 1.8
}

thucydides.projectKey = 'flying-high'

jar {
baseName = 'flights-service'
version = '0.1.0'
}

repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
}

dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.data:spring-data-mongodb")
compile("org.springframework.data:spring-data-rest-webmvc")
compile("org.springframework.boot:spring-boot-starter-actuator")
// compile('org.springframework.cloud:spring-cloud-cloudfoundry-connector:1.1.0.RELEASE')
// compile('org.springframework.cloud:spring-cloud-spring-service-connector:1.1.0.RELEASE')
compile("org.codehaus.groovy:groovy-all:2.3.6")
compile("com.google.guava:guava:18.0")

testCompile("org.spockframework:spock-core:0.7-groovy-2.0")
testCompile("junit:junit")
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile "org.codehaus.groovy.modules.http-builder:http-builder:0.7"
testCompile 'org.easytesting:fest-assert-core:2.0M10'
testCompile 'net.thucydides:thucydides-core:0.9.269'
testCompile 'net.thucydides:thucydides-jbehave-plugin:0.9.268'

}

task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}


// Common test configuration
test {

systemProperty 'thucydides.capability.types', 'capability,feature'
systemProperty 'thucydides.test.root', 'flyinghigh.services'

maxParallelForks 4
useJUnit()

include '**/When*.class'
exclude '**/*IT.class'
exclude 'flyinghigh/services/acceptancetests/**'

testLogging {
events "passed","skipped","failed"
}
}

task integrationTests(type: Test) {
include '**/*IT.class'
testLogging {
events "passed", "skipped", "failed"
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
}
}

task acceptanceTests(type: Test) {
useJUnit()
include 'flyinghigh/services/acceptancetests/**/*.class'
}

integrationTests.mustRunAfter test
acceptanceTests.mustRunAfter integrationTests
aggregate.mustRunAfter acceptanceTests

check.dependsOn integrationTests
check.dependsOn acceptanceTests
check.dependsOn aggregate

clean{
delete "target"
}

if (project.hasProperty('production')) {
cloudfoundry {
space = 'production'
uri = 'http://prod-flights.cfapps.io'
}
} else {
cloudfoundry {
space = 'development'
uri = 'http://dev-flights.cfapps.io'
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
}


cloudfoundry {
target = 'https://api.run.pivotal.io'
application = 'flights'
username = 'john.smart@wakaleo.com'
password = 'nos-bak-yac-yu-i'
file = file("${jar.archivePath}")
buildpack = 'https://github.com/cloudfoundry/java-buildpack'
services {
'mongodb' {
label = 'mongolab'
plan = 'sandbox'
bind = true
}
}
}

class ThucydidesPlugin implements Plugin<Project> {
void apply(Project project) {
project.extensions.create("thucydides", ThucydidesPluginExtension)
project.task('aggregate') << {
logger.lifecycle("Generating Thucydides Reports for ${project.thucydides.projectKey} to directory $project.thucydides.outputDirectory")
System.properties['thucydides.project.key'] = project.thucydides.projectKey
def reporter = new HtmlAggregateStoryReporter(project.thucydides.projectKey)
reporter.outputDirectory = new File(project.thucydides.outputDirectory)
reporter.issueTrackerUrl = project.thucydides.issueTrackerUrl
reporter.jiraUrl = project.thucydides.jiraUrl
reporter.jiraProject = project.thucydides.jiraProject
reporter.generateReportsForTestResultsFrom(new File(project.thucydides.sourceDirectory))
}
}
}

class ThucydidesPluginExtension {
def String outputDirectory = 'target/site/thucydides'
def String projectKey
def String issueTrackerUrl
def String jiraUrl
def String jiraProject
def String sourceDirectory = outputDirectory
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include 'web-service','acceptance-tests'
Loading

0 comments on commit f6ff731

Please sign in to comment.