Last active
July 16, 2016 03:04
-
-
Save calimaborges/c768595c04f8c0056928be78177d1df7 to your computer and use it in GitHub Desktop.
workflow-back-end-java-part4-teste-automatizado
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package carlosborges.taskify; | |
import static spark.Spark.*; | |
public class App { | |
public static void main( String[] args ) { | |
App app = new App(); | |
app.start(System.getenv("PORT")); | |
} | |
public void start(String port) { | |
if (port == null) port = "4567"; | |
port(Integer.valueOf(port)); | |
get("/", (req, res) -> "Hello World"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package carlosborges.taskify; | |
import com.mashape.unirest.http.HttpResponse; | |
import com.mashape.unirest.http.Unirest; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import static org.junit.Assert.assertTrue; | |
public class AppTest { | |
@BeforeClass | |
public static void setup() { | |
new App().start("1337"); | |
} | |
@Test | |
public void tDeveExibirHelloWorld() throws Exception { | |
HttpResponse<String> response = Unirest.get("http://localhost:1337").asString(); | |
assertTrue(response.getBody().contains("Hello World")); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>carlosborges.taskify</groupId> | |
<artifactId>taskify-api</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>taskify-api</name> | |
<url>http://maven.apache.org</url> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.12</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>com.mashape.unirest</groupId> | |
<artifactId>unirest-java</artifactId> | |
<version>1.4.8</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.slf4j</groupId> | |
<artifactId>slf4j-simple</artifactId> | |
<version>1.6.4</version> | |
</dependency> | |
<dependency> | |
<groupId>com.sparkjava</groupId> | |
<artifactId>spark-core</artifactId> | |
<version>2.5</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.5.1</version> | |
<configuration> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<configuration> | |
<finalName>taskify-api</finalName> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> | |
</descriptorRefs> | |
<appendAssemblyId>false</appendAssemblyId> | |
<archive> | |
<manifest> | |
<mainClass>carlosborges.taskify.App</mainClass> | |
</manifest> | |
</archive> | |
</configuration> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>single</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package carlosborges.taskify; | |
import org.junit.BeforeClass; | |
public class AppTest { | |
@BeforeClass | |
public static void setup() { | |
new App().start("1337"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package carlosborges.taskify; | |
import com.mashape.unirest.http.HttpResponse; | |
import com.mashape.unirest.http.Unirest; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import static org.junit.Assert.assertTrue; | |
public class AppTest { | |
@BeforeClass | |
public static void setup() { | |
new App().start("1337"); | |
} | |
@Test | |
public void tDeveExibirHelloWorld() throws Exception { | |
HttpResponse<String> response = Unirest.get("http://localhost:1337").asString(); | |
assertTrue(response.getBody().contains("Hello Man")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment