Last active
August 29, 2015 14:10
-
-
Save deffence1776/54ca2b245c9a474abc53 to your computer and use it in GitHub Desktop.
SidenでHello Worldとテスト ref: http://qiita.com/masatsugumatsus/items/c07e13f81fea12fa590e
This file contains 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
import ninja.siden.App; | |
public class Application { | |
public static void main(String[] args) { | |
App app = new App(); | |
new HelloResource(app).defineRoute(); | |
app.listen(); | |
} | |
} |
This file contains 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
apply plugin: 'java' | |
apply plugin: 'groovy' | |
sourceCompatibility = 1.8 | |
version = '1.0' | |
repositories { | |
mavenCentral() | |
jcenter() | |
} | |
dependencies { | |
compile 'ninja.siden:siden-core:0.2.0' | |
testCompile 'org.codehaus.groovy:groovy-all:2.3.8' | |
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0' | |
testCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7+' | |
} | |
This file contains 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
import ninja.siden.App; | |
public class HelloResource { | |
private App app; | |
public HelloResource(App app){ | |
this.app = app; | |
} | |
public void defineRoute(){ | |
app.get("/hello", (req,res)->"Hello World"); | |
} | |
} |
This file contains 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
import groovyx.net.http.RESTClient | |
import ninja.siden.App | |
import ninja.siden.App.Stoppable | |
import spock.lang.Shared; | |
import spock.lang.Specification | |
class HelloResourceSpec extends Specification { | |
@Shared stop | |
def setupSpec(){ | |
def app = new App() | |
new HelloResource(app).defineRoute() | |
stop = app.listen() | |
} | |
def "簡単な起動のテスト"(){ | |
setup: | |
def endpoint = new RESTClient( 'http://localhost:8080/' ) | |
when: | |
def resp = endpoint.get([ path: 'hello']) | |
then: | |
with(resp) { | |
status == 200 | |
data.text == "Hello World" | |
} | |
} | |
def cleanupSpec(){ | |
stop.stop() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment