20. Overloaded methods
public class C {
public static String method(String s) {
return "String";
}
public static String method(long l) {
return "long";
}
}
Wednesday, October 26, 11
22. Overloaded methods
public class C {
public String method(int i) {
return "int";
}
public String method(long l) {
return "long";
}
}
Wednesday, October 26, 11
31. Cucumber
• http://cukes.info
• Testing framework for describing software
behavior in plain English
Wednesday, October 26, 11
32. Cucumber
Feature: Pets
Scenario: Edit Pet
Given I am on the owners search page
And I press "Find Owners"
And I follow "George Franklin"
And I follow "Edit Pet"
When I fill in "Name" with "Leoni"
And press "Update Pet"
Then I should see "Leoni"
Wednesday, October 26, 11
33. Cucumber test
Stand by while Tomcat finishes booting...
Using the default profile...
............................................................F-.............
(::) failed steps (::)
expected: /xml/,
got: "text/html;charset=utf-8" (using =~)
Diff:
@@ -1,2 +1,2 @@
-/xml/
+text/html;charset=utf-8
(RSpec::Expectations::ExpectationNotMetError)
org/jruby/RubyProc.java:268:in `call'
./features/step_definitions/xml_json_steps.rb:12:in `(root)':in `/^I should see
an XML document$/'
features/vets.feature:6:in `Then I should see an XML document'
Failing Scenarios:
cucumber features/vets.feature:3 # Scenario: View vets as XML
13 scenarios (1 failed, 12 passed)
75 steps (1 failed, 1 skipped, 73 passed)
0m7.709s
rake aborted!
Cucumber failed
Wednesday, October 26, 11
36. diff --git a/src/main/webapp/WEB-INF/lib/app.rb b/src/main/webapp/WEB-INF/lib/
app.rb
index 6ab5b3c..4398fb4 100644
--- a/src/main/webapp/WEB-INF/lib/app.rb
+++ b/src/main/webapp/WEB-INF/lib/app.rb
@@ -1,6 +1,33 @@
require 'builder'
require 'erb'
+require 'spring_helpers'
+
+helpers do
+ include Spring
+end
get '/rack/' do
'<h1>Sinatra</h1>'
end
+
+get '/rack/vets.xml' do
+ content_type 'application/vnd.petclinic+xml'
+ builder do |xml|
+ xml.instruct!
+ xml.vets do
+ clinic.vets.each do |vet|
+ xml.vetList do
+ xml.id vet.id
+ xml.firstName vet.firstName
+ xml.lastName vet.lastName
+ vet.specialties.each do |spec|
+ xml.specialties do
+ xml.id spec.id
+ xml.name spec.name
+ end
+ end
+ end
+ end
+ end
+ end
+end
Wednesday, October 26, 11
37. Requests
/ /vets JRuby
/owners Java/
/ /vets /owners /1/pets Spring
App
Wednesday, October 26, 11