-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Committed the 'Request routing' scenario for the 'Host a spring web M…
…VC application'
- Loading branch information
Stuart Blair
committed
Jan 20, 2012
1 parent
b552e63
commit 448ffa8
Showing
33 changed files
with
154 additions
and
86 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,7 @@ | ||
Feature:Host a spring mvc web application | ||
|
||
Scenario: Request routing | ||
Given I have a spring mvc application context location of "mvc-dispatcher-servlet.xml" | ||
Given I host a spring mvc application with context location of "WEB-INF/mvc-dispatcher-servlet.xml" | ||
And the application will respond to get requests for the uri "/hello" | ||
When I host the application | ||
And I GET "/hello" | ||
Then I recieve an HTTPResponse with a 200 code | ||
|
||
#Scenario: Invalid application context | ||
#Given I have a spring mvc application context location of "" | ||
#When I host the application | ||
#Then I receive an error message reporting that "" is an invalid application context | ||
|
||
#Scenario: Missing the supporting spring mvc classes from the runtime environment | ||
#Given I have a spring mvc application context location of "application-servlet.xml" | ||
#And the application will respond to get requests for the uri "/hello" | ||
#But I don't have Spring MVC's supporting classes on my classpath | ||
#When I host the application | ||
#Then I receive an error message reporting the classes that cannot be found |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__)) | ||
$LOAD_PATH.unshift(File.expand_path('../../../reference_apps', __FILE__)) | ||
require 'java' | ||
$CLASSPATH << File.join(File.dirname(__FILE__), 'reference_apps', 'valid_app', 'target', 'valid_app', 'WEB-INF', 'classes') | ||
Dir.glob("**/lib/*.jar") {|jar| $CLASSPATH << jar} | ||
|
||
require 'classpath' | ||
require 'reigns' | ||
java_import 'com._5values.dummy.controller.HelloController' |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module KnowsSpring | ||
def set_context_location(context_location) | ||
@context_location = context_location | ||
def host_application(context_location) | ||
@fake_dispatcher_servlet = ::Reigns::FakeDispatcherServlet.new(context_location) | ||
end | ||
|
||
def host_application | ||
@fake_dispatcher_servlet = FakeDispatcherServlet.new(context_location) | ||
def send_request(method, uri) | ||
@fake_dispatcher_servlet.send(method.downcase, uri) | ||
end | ||
end | ||
|
||
World(KnowsSpring) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,26 @@ | ||
require 'java' | ||
|
||
java_import 'javax.servlet.http.HttpServlet' | ||
java_import 'org.springframework.web.servlet.DispatcherServlet' | ||
java_import 'org.springframework.mock.web.MockServletConfig' | ||
java_import 'org.springframework.mock.web.MockHttpServletRequest' | ||
java_import 'org.springframework.mock.web.MockHttpServletResponse' | ||
|
||
|
||
module Reigns | ||
class FakeDispatcherServlet | ||
def initialize(context_location) | ||
@servlet = DispatcherServlet.new | ||
config = MockServletConfig.new("resources") | ||
config.add_init_parameter("contextConfigLocation", context_location) | ||
@servlet.init(config) | ||
end | ||
|
||
def get(uri) | ||
request = MockHttpServletRequest.new('GET', uri) | ||
response = MockHttpServletResponse.new | ||
@servlet.service(request, response); | ||
return response | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$CLASSPATH << File.join(File.dirname(__FILE__), 'valid_app', 'target', 'valid_app') | ||
$CLASSPATH << File.join(File.dirname(__FILE__), 'valid_app', 'target', 'valid_app', 'WEB-INF', 'classes') | ||
Dir.glob("**/lib/*.jar") {|jar| $CLASSPATH << jar} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com._5values.dummy</groupId> | ||
<artifactId>valid_app</artifactId> | ||
<packaging>war</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<name>Dummy 'valid' website for use in feature testing the Reigns gem</name> | ||
|
||
<properties> | ||
<spring.version>3.0.5.RELEASE</spring.version> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<!-- Spring 3 dependencies --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-webmvc</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-test</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
|
||
<!-- Servlet implementation dependency --> | ||
<dependency> | ||
<groupId>org.apache.tomcat</groupId> | ||
<artifactId>tomcat-servlet-api</artifactId> | ||
<version>7.0.23</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<finalName>valid_app</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
..._app/target/maven-archiver/pom.properties → ..._app/target/maven-archiver/pom.properties
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#Generated by Maven | ||
#Wed Jan 11 03:20:42 PST 2012 | ||
#Thu Jan 19 13:23:42 PST 2012 | ||
version=1.0-SNAPSHOT | ||
groupId=com._5values.dummy | ||
artifactId=valid_app |
Binary file renamed
BIN
+2.64 MB
...rence_apps/valid_app/target/valid_app.war → ...rence_apps/valid_app/target/valid_app.war
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added
BIN
+200 KB
reference_apps/valid_app/target/valid_app/WEB-INF/lib/spring-test-3.0.5.RELEASE.jar
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added
BIN
+173 KB
reference_apps/valid_app/target/valid_app/WEB-INF/lib/tomcat-servlet-api-7.0.23.jar
Binary file not shown.
File renamed without changes.
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
require 'spec_helper' | ||
|
||
module Reigns | ||
describe FakeDispatcherServlet do | ||
describe "#initialize" do | ||
context "when initialized with a valid context configuration location" do | ||
pending it "should do something -erk - back to the cucumber features I think!" do | ||
describe FakeDispatcherServlet do | ||
describe "#get" do | ||
|
||
before (:each) do | ||
@fake_dispatcher_servlet = FakeDispatcherServlet.new("WEB-INF/mvc-dispatcher-servlet.xml") | ||
end | ||
|
||
context "to a resource that exists" do | ||
it "returns an HTTPResponse with a 200 code" do | ||
@fake_dispatcher_servlet.get("/hello").get_status.should eql 200 | ||
end | ||
end | ||
|
||
context "to a resource that doesn't exist" do | ||
it "returns an HTTPResponse with a 404 code" do | ||
@fake_dispatcher_servlet.get("/goodbye").get_status.should eql 404 | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
$:.unshift(File.join(File.dirname(__FILE__), '..', 'reference_apps')) | ||
require 'java' | ||
require 'classpath' | ||
require 'reigns' | ||
|