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
| curl -v -H "Accept: text/plain" http://localhost:6666/time | |
| HTTP/1.1 200 OK | |
| Content-Type: text/plain | |
| Content-Length: 21 | |
| Server: Jetty(9.0.5.v20130815) | |
| It's currently 20:59 |
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
| @Test | |
| public void saysTheCurrentTime() { | |
| givenTheCurrentTimeIs("20:15"); | |
| whenAUserChecksTheTime(); | |
| thenTheUserSees("It's currently 20:15!"); | |
| } |
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
| public class FixedClock implements Clock { | |
| private Date fixedNow; | |
| @Override | |
| public Date now() { | |
| return fixedNow; | |
| } | |
| public void setNow(Date fixedNow) { | |
| this.fixedNow = fixedNow; |
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
| @Before | |
| public void startApplication() { | |
| clock = new FixedClock(); | |
| timeExpert = new TimeExpertServer(clock); | |
| timeExpert.start(); | |
| } |
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
| @Test | |
| public void saysTheCurrentTime() throws Exception { | |
| givenTheCurrentTimeIs("20:15"); | |
| whenAUserChecksTheTime(); | |
| thenTheUserSees("It's currently 20:15!"); | |
| } | |
| private void givenTheCurrentTimeIs(String currentTime) throws ParseException { | |
| Date currentTimeAsDate = new SimpleDateFormat("HH:mm").parse(currentTime); | |
| clock.setNow(currentTimeAsDate); |
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
| @Path("time") | |
| public class TimeResource { | |
| private final Clock clock; | |
| public TimeResource(Clock clock) { | |
| this.clock = clock; | |
| } | |
| @GET |
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
| public void start() { | |
| server = new Server(6666); | |
| ServletContextHandler handler = new ServletContextHandler(); | |
| handler.setContextPath(""); | |
| // adds Jersey Servlet with a customized ResourceConfig | |
| handler.addServlet(new ServletHolder(new ServletContainer(resourceConfig())), "/*"); | |
| server.setHandler(handler); | |
| try { | |
| server.start(); | |
| } catch (Exception e) { |
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
| public class Main { | |
| public static void main(String[] args) { | |
| new Main().startTimeExpert(); | |
| } | |
| private void startTimeExpert() { | |
| final TimeExpertServer timeExpert = new TimeExpertServer(new RealClock()); | |
| try { | |
| timeExpert.start(); |
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
| require_relative 'music' | |
| describe "music kata" do | |
| it "models octaves" do | |
| Notes.c(:simple, 1).pitch.should == 4 | |
| Notes.c(:simple, 2).pitch.should == 16 | |
| Notes.c(:simple, 8).pitch.should == 88 | |
| Notes.e(:simple, 1).pitch.should == 8 | |
| end |
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
| module Roots | |
| def self.rootn(x,n) | |
| Math.exp(Math.log(x)/n) | |
| end | |
| end | |
| module Notes | |
| def self.c accidental, octave | |
| Note.new(4, octave, accidental) | |
| end |
OlderNewer