Created
August 29, 2008 05:43
-
-
Save nicksieger/7906 to your computer and use it in GitHub Desktop.
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
/* | |
* Copyright 2007-2008 Sun Microsystems, Inc. | |
* This source code is available under the MIT license. | |
* See the file LICENSE.txt for details. | |
*/ | |
package org.jruby.rack; | |
import java.io.IOException; | |
import javax.servlet.ServletConfig; | |
import javax.servlet.ServletException; | |
import javax.servlet.ServletRequest; | |
import javax.servlet.ServletResponse; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
/** | |
* | |
* @author nicksieger | |
*/ | |
public class RackServlet extends HttpServlet { | |
private RackDispatcher dispatcher; | |
/** Default ctor, used by servlet container */ | |
public RackServlet() { | |
} | |
/** dependency injection ctor, used by unit tests */ | |
public RackServlet(RackDispatcher dispatcher) { | |
this.dispatcher = dispatcher; | |
} | |
@Override | |
public void init(ServletConfig config) { | |
this.dispatcher = new DefaultRackDispatcher(config.getServletContext()); | |
} | |
@Override | |
public void service(ServletRequest request, ServletResponse response) | |
throws ServletException, IOException { | |
dispatcher.process((HttpServletRequest) request, (HttpServletResponse) response); | |
} | |
} |
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
#-- | |
# Copyright 2007-2008 Sun Microsystems, Inc. | |
# This source code is available under the MIT license. | |
# See the file LICENSE.txt for details. | |
#++ | |
require File.dirname(__FILE__) + '/../spec_helper' | |
import org.jruby.rack.RackServlet | |
describe RackServlet, "service" do | |
it "should delegate to process" do | |
request = javax.servlet.http.HttpServletRequest.impl {} | |
response = javax.servlet.http.HttpServletResponse.impl {} | |
dispatcher = mock "dispatcher" | |
dispatcher.should_receive(:process).with(request, response) | |
@servlet = RackServlet.new dispatcher | |
@servlet.service request, response | |
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
Java::OrgJrubyRack::RackServlet service | |
- should delegate to process (ERROR - 1) | |
1) | |
TypeError in 'Java::OrgJrubyRack::RackServlet service should delegate to process' | |
for method service expected [javax.servlet.ServletRequest, javax.servlet.ServletResponse]; got: [org.jruby.RubyObject,org.jruby.RubyObject]; error: argument type mismatch | |
/Users/nicksieger/Projects/ruby/jruby-rack/src/spec/ruby/rack/servlet_spec.rb:18: | |
Finished in 0.236357 seconds | |
1 example, 1 failure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment