You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(13) |
Aug
(151) |
Sep
(21) |
Oct
(6) |
Nov
(70) |
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(47) |
Feb
(66) |
Mar
(23) |
Apr
(115) |
May
(24) |
Jun
(53) |
Jul
(10) |
Aug
(279) |
Sep
(84) |
Oct
(149) |
Nov
(138) |
Dec
(52) |
2003 |
Jan
(22) |
Feb
(20) |
Mar
(29) |
Apr
(106) |
May
(170) |
Jun
(122) |
Jul
(70) |
Aug
(64) |
Sep
(27) |
Oct
(71) |
Nov
(49) |
Dec
(9) |
2004 |
Jan
(7) |
Feb
(38) |
Mar
(3) |
Apr
(9) |
May
(22) |
Jun
(4) |
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(15) |
Dec
(2) |
2005 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(28) |
Jun
(3) |
Jul
(11) |
Aug
(5) |
Sep
(1) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2006 |
Jan
(8) |
Feb
(3) |
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jeff M. <je...@mk...> - 2002-09-02 08:40:16
|
Err, would you believe me if I told you it was a preemptive strike against j2ee1.4 I'll kill the 1.4 stuff in a bit. On Sat, 2002-08-31 at 23:57, Steve Freeman wrote: > Been looking around the new libraries. Can someone tell me about the > relationship between javax.sql in Java 1.4 and J2EE 1.3? > > At present, it looks like we have two identical MockDataSource's. I don't > understand how they fit into the versioning scheme. > > Ta > Steve > > > - - - - - - - - - - - - - - - > Steve Freeman st...@m3... > Programme chair OT2003. http://www.ot2003.org > > "Nonsense is just nonsense, but the study of nonsense is science." > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev -- jeff martin information technologist mkodo limited mobile: 44 (0) 78 5547 8331 phone: 44 (0) 20 2226 4545 email: je...@mk... www.mkodo.com |
From: Steve F. <sm...@us...> - 2002-09-01 00:30:13
|
Update of /cvsroot/mockobjects/no-stone-unturned/doc/xdocs In directory usw-pr-cvs1:/tmp/cvs-serv10906/doc/xdocs Modified Files: how_mocks_happened.xml Log Message: bit more on design issues Index: how_mocks_happened.xml =================================================================== RCS file: /cvsroot/mockobjects/no-stone-unturned/doc/xdocs/how_mocks_happened.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- how_mocks_happened.xml 22 Aug 2002 11:28:31 -0000 1.14 +++ how_mocks_happened.xml 1 Sep 2002 00:30:11 -0000 1.15 @@ -21,7 +21,7 @@ <para> This chapter is unusual in that it's focussed on the tests, it ignores the production code almost completely. I'll be covering the whole cycle in later chapters but, for now, I want to concentrate - on the thought processes behind a particular approach to test-driven development. This chapter is not about + on the thought processes behind a particular approach to &TDD;. This chapter is not about how to develop routing software for a robot, but how to structure your code so that you can tell if such a module works. </para> @@ -159,14 +159,14 @@ We don't have any other immediate need for <methodname>getRecentMovesRequests()</methodname> and, what's worse, we've made an implicit promise to other people who work with the <classname>Robot</classname> code that we will store routes, thus shrinking (ever so slightly) our room to manouver. We can mark the method as - test infrastructure, but this sort of notation is clumsy and tends to be ignored in the heat of development. + test infrastructure, but this sort of notation is clumsy and is often ignored in the heat of development. </para> <para> Third, although it's not the case here, test suites based on extracting history from objects tend to need lots of utilities for constructing and comparing collections of values. The need to write external code to manipulate an object is often a warning that its class is getting too busy and - that some behaviour should be moved from the utility to a real production class. + that some behaviour should be moved there from the utility. </para> <para> @@ -734,25 +734,53 @@ program, writing tests with Mock Objects makes us think about the objects it depends on, its environment. Sometimes those objects don't yet exist, which means that we've found a conceptual <quote>fault line</quote> in the system that we can turn into - a new object interface. In our tests, we describe what the objects should say to each other, + a new object interface. In our tests, the expectations describe what the objects should say to each other, their <emphasis>protocol</emphasis>, without having to figure out how the new objects actually - work. Applied consistently, this pushes us towards a codebase made up of components with - clear interfaces which (so I've been led to believe) makes good things like reusability + work. We fake them up for now and move on to implementing them when we're ready. + Applied consistently, this pushes us towards a codebase made up of components with + clear interfaces which (at least in my experience) makes good things like reusability happen almost as a byproduct. What makes &TDD; so powerful is that we can do - all this incrementally, evolving the code from the requirements in hand rather than - having to place bets on the what we think we're going to need. + this incrementally, evolving the code from the requirements in hand rather than + trying to place bets on the what we think we're going to need. + </para> + <para> + One more design issue is our unusually heavy use of the <quote>Tell, don't ask</quote> pattern. + We prefer to pass behaviour into an object, rather than pulling values out, which is why we wrote + a <quote>route following object</quote> rather than returning a collection of + <classname>MoveRequest</classname>. + Our experience is that the common use of getters, particularly for collections, makes a class and + the code that uses it that little bit harder to change. Across a whole code base, the increased + <quote>refactoring drag</quote> can be significant. </para> + <note> + <para> + If it's not clear why getting collections can slow things down, think of all the times + you write iterator loops such as: + </para> + <programlisting> +Iterator moveRequests = robot.getMoveRequests(); +while (moveRequests.hasNext()) { + MoveRequest moveRequest = (MoveRequest)moveRequests.next(); + <lineannotation>// process moveRequest</lineannotation> +}</programlisting> + <para> + If we change to passing a <classname>Motor</classname> to a <classname>Robot</classname> which, in turn, + passes each step on the route to the <classname>Motor</classname>, then we've refactored the loop navigation. + At the very least, we've made the tests more accurate. If we need to iterate over this collection in more + than one place, then we've also removed some duplication. Some of us think that this style is also more + expressive because it leaves decisions about route management with the <classname>Robot</classname>, rather + than the caller. + </para> + </note> <para> - We want to unit test but don't want to expose more of the internals of the object than is necessary, - because that makes the class, and the code that uses it, that little bit harder to change; across a - whole code base, the increased <quote>refactoring drag</quote> can be significant. Our solution - (<quote>Tell, don't ask</quote>) forces us into passing around computation rather than data, which is - why we used the <quote>route following object</quote>, rather than returning a collection - of <classname>MoveRequest</classname>. + Speculating wildly, the next requirements might push us to extract a <classname>Navigator</classname> + object that works out the route, and the <classname>Robot</classname> becomes just a frame that + holds together the objects that do the real work. This is how the process often works: we start with a + top level object, fill in some implementation, and hollow it out as we understand more about what's + inside. We then do the same to the new objects we've created, and so on. </para> - <sidebar> <title>Top-Down Decomposition</title> <para> @@ -769,9 +797,9 @@ and to drive the design of interfaces from their use rather than their implementation. It also had a couple of critical failings: it turned out to be hard to change early design decisions because, of course, they're embedded in the top-level structure, and it's not good at - encouraging reuse between lower-level components. It looks like &TDD; avoids those failures because - object-orientation makes it easier to share and replace components throughout the application and - because its emphasis on refactoring means we can adjust as the codebase grows. + encouraging reuse between lower-level components. It looks like &TDD; avoids these problems because + object-orientation makes it easier to share components throughout the application and + the emphasis on refactoring means we can remove duplication as the codebase grows. </para> </sidebar> </section> <!-- What about design? --> @@ -788,19 +816,19 @@ <para>My code moved in this direction because I was committed to unit testing but didn't want to record and expose unnecessary details about the -state of my Robot +state of my Robot (the <function>getRecentMoveRequests()</function> method). As a result, I have better unit tests and a cleaner interface to the Robot class. But even better than that, by following the needs of my tests I have actually ended up improving the object model of the Robot by separating the Robot from its Motor and defining the an abstract interface between the two. -I now have the flexibility to subtitute a different Motor implementation, -perhaps one that accelerates. Similarly, if I want to track the total -distance a Robot travels, I can do so without changing the implementation +I now have the flexibility to subtitute a different Motor implementation, +perhaps one that accelerates. Similarly, if I want to track the total +distance a Robot travels, I can do so without changing the implementation of either the robot or its motor:</para> <programlisting> -/** A decorator that accumulates distances, then passes the request +/** A decorator that accumulates distances, then passes the request * on to a real Motor. */ public class MotorTracker implements Motor { @@ -816,10 +844,10 @@ } public long getTotalDistance() { return totalDistance; - } + } } -// When constructing the Robot, wrap the implementation of a +// When constructing the Robot, wrap the implementation of a // Motor that does the work in a MotorTracker. OneSpeedMotor realMotor = new OneSpeedMotor(); MotorTracker motorTracker = new MotorTracker(realMotor); |
From: Steve F. <sm...@us...> - 2002-09-01 00:29:09
|
Update of /cvsroot/mockobjects/no-stone-unturned/doc/xdocs In directory usw-pr-cvs1:/tmp/cvs-serv10582/doc/xdocs Modified Files: htmlbook.xsl htmlbook.css Log Message: fixed emphasis within programlisting style Index: htmlbook.xsl =================================================================== RCS file: /cvsroot/mockobjects/no-stone-unturned/doc/xdocs/htmlbook.xsl,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- htmlbook.xsl 21 Aug 2002 19:16:43 -0000 1.10 +++ htmlbook.xsl 1 Sep 2002 00:29:07 -0000 1.11 @@ -49,6 +49,12 @@ </xsl:call-template> </xsl:template> + <xsl:template match="programlisting/emphasis"> + <xsl:call-template name="inline.span"> + <xsl:with-param name="spanclass" select="'emphasis'" /> + </xsl:call-template> + </xsl:template> + <xsl:template match="comment|remark"> <xsl:if test="$show.comments != 0"> <xsl:call-template name="inline.span"> Index: htmlbook.css =================================================================== RCS file: /cvsroot/mockobjects/no-stone-unturned/doc/xdocs/htmlbook.css,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- htmlbook.css 21 Aug 2002 21:32:16 -0000 1.13 +++ htmlbook.css 1 Sep 2002 00:29:07 -0000 1.14 @@ -31,7 +31,7 @@ DIV.sidebar P { margin-top: 10px; margin-bottom: 10px; } DIV.sidebar P.title { margin-top: 0%; font-style: italic; font-size: 130%; } -PRE SPAN.emphasis { font-weight: bold; } +PRE SPAN.emphasis { font-style: italic; } .lineannotation { font-style: italic; font-family: "Century Schoolbook", Times, serif; } .footnote { margin-left: 5%; text-indent: -3% } |
From: Steve F. <sm...@us...> - 2002-09-01 00:28:35
|
Update of /cvsroot/mockobjects/no-stone-unturned/rubysrc In directory usw-pr-cvs1:/tmp/cvs-serv10404/rubysrc Removed Files: test_addrservlet.rb tasks.txt addrservlet.rb server.rb Log Message: moved to src/ruby --- test_addrservlet.rb DELETED --- --- tasks.txt DELETED --- --- addrservlet.rb DELETED --- --- server.rb DELETED --- |
From: Steve F. <st...@m3...> - 2002-08-31 22:58:14
|
Been looking around the new libraries. Can someone tell me about the relationship between javax.sql in Java 1.4 and J2EE 1.3? At present, it looks like we have two identical MockDataSource's. I don't understand how they fit into the versioning scheme. Ta Steve - - - - - - - - - - - - - - - Steve Freeman st...@m3... Programme chair OT2003. http://www.ot2003.org "Nonsense is just nonsense, but the study of nonsense is science." |
From: Steve F. <sm...@us...> - 2002-08-31 10:55:27
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/nostone/random In directory usw-pr-cvs1:/tmp/cvs-serv26200/src/nostone/random Removed Files: WeatherTest.java WeatherRandomTest.java MockRandom.java Weather.java WeatherRandom.java DefaultWeatherRandom.java MockWeatherRandom.java Log Message: Restructured source code under single src directory --- WeatherTest.java DELETED --- --- WeatherRandomTest.java DELETED --- --- MockRandom.java DELETED --- --- Weather.java DELETED --- --- WeatherRandom.java DELETED --- --- DefaultWeatherRandom.java DELETED --- --- MockWeatherRandom.java DELETED --- |
Update of /cvsroot/mockobjects/no-stone-unturned/src/nostone/addressbook In directory usw-pr-cvs1:/tmp/cvs-serv26200/src/nostone/addressbook Removed Files: NullHttpServletRequest.java AddressBookServletTest.java NullHttpServletResponse.java AddressBookServlet.java Log Message: Restructured source code under single src directory --- NullHttpServletRequest.java DELETED --- --- AddressBookServletTest.java DELETED --- --- NullHttpServletResponse.java DELETED --- --- AddressBookServlet.java DELETED --- |
From: Steve F. <sm...@us...> - 2002-08-31 10:55:27
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/gui In directory usw-pr-cvs1:/tmp/cvs-serv26200/src/java/nostone/gui Added Files: TestHelper.java SearcherTest.java Searcher.java Directory.java Log Message: Restructured source code under single src directory --- NEW FILE: TestHelper.java --- package nostone.gui; import java.awt.*; public class TestHelper { public Component depthFirst(Container container, ComponentVisitor visitor) { Component[] components = container.getComponents(); for (int i = 0; i < components.length; i++) { Component component = components[i]; Component applied = visitor.apply(component); if (null != applied) { return applied; } if (component instanceof Container) { applied = depthFirst((Container) component, visitor); if (null != applied) { return applied; } } } return null; } public interface ComponentVisitor { public Component apply(Component aComponent); } } --- NEW FILE: SearcherTest.java --- package nostone.gui; import junit.framework.TestCase; import javax.swing.*; import java.awt.*; import com.mockobjects.ExpectationValue; public class SearcherTest extends TestCase { public SearcherTest(String name) { super(name); } public void testNoMatchesFound() { Searcher searcher = new Searcher(new Directory() { public String searchFor(String searchString) { return null; } }); assertEquals("Should be status", "", ((JLabel)findNamedComponent(searcher, "status")).getText().trim()); ((JButton)findNamedComponent(searcher, "search button")).doClick(); assertEquals("Should be status", "No entries found", ((JLabel)findNamedComponent(searcher, "status")).getText()); } public void testOneMatchFound() { final ExpectationValue searchString = new ExpectationValue("search string"); Searcher searcher = new Searcher(new Directory() { public String searchFor(String aSearchString) { searchString.setActual(aSearchString); return "One Result"; } }); ((JTextField)findNamedComponent(searcher, "search criterion")).setText("Search String"); searchString.setExpected("Search String"); ((JButton)findNamedComponent(searcher, "search button")).doClick(); assertEquals("Should be result", "One Result", ((JTextArea)findNamedComponent(searcher, "results")).getText()); assertEquals("Should be status", "", ((JLabel)findNamedComponent(searcher, "status")).getText().trim()); } private Component findNamedComponent(final Container container, final String name) { return new TestHelper().depthFirst(container, new TestHelper.ComponentVisitor() { public Component apply(Component aComponent) { return name.equals(aComponent.getName()) ? aComponent : null; } }); } } --- NEW FILE: Searcher.java --- /* */ package nostone.gui; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Searcher extends JFrame { public Searcher(final Directory directory) throws HeadlessException { super("Searcher"); JButton searchButton = new JButton("Search"); searchButton.setName("search button"); JTextField searchString = new JTextField(); searchString.setName("search criterion"); searchString.setColumns(15); final JLabel statusBar = new JLabel(" "); statusBar.setName("status"); final JTextArea results = new JTextArea(); results.setName("results"); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String result = directory.searchFor(""); if (null == result) { statusBar.setText("No entries found"); } else { results.setText(result); } } }); Box searchBar = Box.createHorizontalBox(); searchBar.add(searchString); searchBar.add(searchButton); getContentPane().add(searchBar, BorderLayout.NORTH); getContentPane().add(results, BorderLayout.CENTER); getContentPane().add(statusBar, BorderLayout.SOUTH); pack(); } static public void main(String[] args) { Searcher searcher = new Searcher(new Directory() { public String searchFor(String searchString) { return "One Result"; } }); searcher.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Window w = e.getWindow(); w.setVisible(false); w.dispose(); System.exit(0); } }); searcher.setVisible(true); } } --- NEW FILE: Directory.java --- package nostone.gui; public interface Directory { String searchFor(String searchString); } |
Update of /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/addressbook In directory usw-pr-cvs1:/tmp/cvs-serv26200/src/java/nostone/addressbook Added Files: NullHttpServletRequest.java AddressBookServletTest.java NullHttpServletResponse.java AddressBookServlet.java Log Message: Restructured source code under single src directory --- NEW FILE: NullHttpServletRequest.java --- package nostone.addressbook; import javax.servlet.http.*; import javax.servlet.ServletInputStream; import javax.servlet.RequestDispatcher; import java.util.*; import java.security.Principal; import java.io.*; public class NullHttpServletRequest implements HttpServletRequest { public String getAuthType() { return null; } public Cookie[] getCookies() { return new Cookie[0]; } public long getDateHeader(String s) { return 0; } public String getHeader(String s) { return null; } public Enumeration getHeaders(String s) { return null; } public Enumeration getHeaderNames() { return null; } public int getIntHeader(String s) { return 0; } public String getMethod() { return null; } public String getPathInfo() { return null; } public String getPathTranslated() { return null; } public String getContextPath() { return null; } public String getQueryString() { return null; } public String getRemoteUser() { return null; } public boolean isUserInRole(String s) { return false; } public Principal getUserPrincipal() { return null; } public String getRequestedSessionId() { return null; } public String getRequestURI() { return null; } public StringBuffer getRequestURL() { return null; } public String getServletPath() { return null; } public HttpSession getSession(boolean b) { return null; } public HttpSession getSession() { return null; } public boolean isRequestedSessionIdValid() { return false; } public boolean isRequestedSessionIdFromCookie() { return false; } public boolean isRequestedSessionIdFromURL() { return false; } public boolean isRequestedSessionIdFromUrl() { return false; } public Object getAttribute(String s) { return null; } public Enumeration getAttributeNames() { return null; } public String getCharacterEncoding() { return null; } public void setCharacterEncoding(String s) throws UnsupportedEncodingException { } public int getContentLength() { return 0; } public String getContentType() { return null; } public ServletInputStream getInputStream() throws IOException { return null; } public String getParameter(String s) { return null; } public Enumeration getParameterNames() { return null; } public String[] getParameterValues(String s) { return new String[0]; } public Map getParameterMap() { return null; } public String getProtocol() { return null; } public String getScheme() { return null; } public String getServerName() { return null; } public int getServerPort() { return 0; } public BufferedReader getReader() throws IOException { return null; } public String getRemoteAddr() { return null; } public String getRemoteHost() { return null; } public void setAttribute(String s, Object o) { } public void removeAttribute(String s) { } public Locale getLocale() { return null; } public Enumeration getLocales() { return null; } public boolean isSecure() { return false; } public RequestDispatcher getRequestDispatcher(String s) { return null; } public String getRealPath(String s) { return null; } } --- NEW FILE: AddressBookServletTest.java --- package nostone.addressbook; import junit.framework.TestCase; import javax.servlet.http.*; import javax.servlet.ServletException; import java.io.*; public class AddressBookServletTest extends TestCase { public AddressBookServletTest(String name) { super(name); } public void testNoEntries() throws ServletException, IOException { final StringWriter page = new StringWriter(); HttpServletRequest mockRequest = new NullHttpServletRequest() { public String getMethod() { return "PUT"; } public String getProtocol() { return "HTTP/1.1"; } }; HttpServletResponse mockResponse = new NullHttpServletResponse() /*{ public void setContentType(String contentType) { assertEquals("Should be content type", "text/plain", contentType); } public PrintWriter getWriter() throws IOException { return new PrintWriter(page); } }*/; AddressBookServlet servlet = new AddressBookServlet(); servlet.service(mockRequest, mockResponse); // assertEquals("Response page", "No address found", page.toString()); } } --- NEW FILE: NullHttpServletResponse.java --- package nostone.addressbook; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.Cookie; import javax.servlet.ServletOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Locale; public class NullHttpServletResponse implements HttpServletResponse { public void addCookie(Cookie cookie) { } public boolean containsHeader(String s) { return false; } public String encodeURL(String s) { return null; } public String encodeRedirectURL(String s) { return null; } public String encodeUrl(String s) { return null; } public String encodeRedirectUrl(String s) { return null; } public void sendError(int i, String s) throws IOException { } public void sendError(int i) throws IOException { } public void sendRedirect(String s) throws IOException { } public void setDateHeader(String s, long l) { } public void addDateHeader(String s, long l) { } public void setHeader(String s, String s1) { } public void addHeader(String s, String s1) { } public void setIntHeader(String s, int i) { } public void addIntHeader(String s, int i) { } public void setStatus(int i) { } public void setStatus(int i, String s) { } public String getCharacterEncoding() { return null; } public ServletOutputStream getOutputStream() throws IOException { return null; } public PrintWriter getWriter() throws IOException { return null; } public void setContentLength(int i) { } public void setContentType(String s) { } public void setBufferSize(int i) { } public int getBufferSize() { return 0; } public void flushBuffer() throws IOException { } public void resetBuffer() { } public boolean isCommitted() { return false; } public void reset() { } public void setLocale(Locale locale) { } public Locale getLocale() { return null; } } --- NEW FILE: AddressBookServlet.java --- package nostone.addressbook; import javax.servlet.http.HttpServlet; public class AddressBookServlet extends HttpServlet { public AddressBookServlet() { } } |
From: Steve F. <sm...@us...> - 2002-08-31 10:55:25
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/nostone/gui In directory usw-pr-cvs1:/tmp/cvs-serv26200/src/nostone/gui Removed Files: Searcher.java TestHelper.java SearcherTest.java Directory.java Log Message: Restructured source code under single src directory --- Searcher.java DELETED --- --- TestHelper.java DELETED --- --- SearcherTest.java DELETED --- --- Directory.java DELETED --- |
From: Steve F. <sm...@us...> - 2002-08-31 10:55:25
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/ruby In directory usw-pr-cvs1:/tmp/cvs-serv26200/src/ruby Added Files: tasks.txt server.rb test_addrservlet.rb addrservlet.rb Log Message: Restructured source code under single src directory --- NEW FILE: tasks.txt --- Stories 1) anyone can search the entries in the book. 2) anyone can add their name and email address to the book. 3) anyone can remove an entry from the book. Tasks 1a) accept a name and find no result DONE Points of Interest: - no need to implement any interfaces when defining mocks 1b) accept a name and return a result from a hard-coded collection. 1b.1) what about the servlet receiving no name? DONE Points of Interest: - using blocks to handle expectations REFACTORING 1c) Retrieve the entries from a file, specified as a servlet property. Values are held in memory. --- NEW FILE: server.rb --- #!/usr/bin/ruby require 'webrick' require 'addrservlet' server = WEBrick::HTTPServer.new( :Port => 2000 ) server.mount( "/address", AddressBookServlet, "Nat Pryce" => "nat...@so...", "Steve Freeman" => "st...@so...", "Jeff Martin" => "cus...@so..." ) trap("INT") { server.shutdown } server.start --- NEW FILE: test_addrservlet.rb --- require 'test/unit' require 'webrick' require 'addrservlet' class MockRequest def _setup_query_string( query ) @query_string = WEBrick::HTTPUtils::escape_form(query) end attr_reader :query_string end class MockResponse include Test::Unit::Assertions def initialize @content_type_set = false @body_set = false @body_expectation = nil end def []=( header, value ) assert_equal( "content-type", header ) assert_match( /^text\/.*/, value ) @content_type_set = true end def _expect_body( &proc ) @body_expectation = proc end def body=( value ) @body_expectation.call(value) if @body_expectation @body_set = true end def _verify assert( "content-type", @content_type_set ) assert( "body", @body_expectation && @body_set ) end end class AddressBookServletTest < Test::Unit::TestCase NAME1 = "First Last" ADDR1 = "ADDRESS" def set_up @request = MockRequest.new @response = MockResponse.new @servlet = AddressBookServlet.new( {}, NAME1 => ADDR1 ) end def test_no_address_found @request._setup_query_string( "UNKNOWN NAME" ) @response._expect_body { |text| assert_match( /no address found/, text ) } @servlet.do_GET( @request, @response ) @response._verify end def test_no_address_found_when_no_name @response._expect_body { |text| assert_match( /no address found/, text ) } @servlet.do_GET( @request, @response ) @response._verify end def test_address_found @request._setup_query_string( NAME1 ) @response._expect_body { |text| assert_match( /#{ADDR1}/, text ) } @servlet.do_GET( @request, @response ) @response._verify end end --- NEW FILE: addrservlet.rb --- require 'webrick' class AddressBookServlet < WEBrick::HTTPServlet::AbstractServlet def initialize( config, address_book ) super @address_book = address_book end def do_GET( request, response ) response['content-type'] = 'text/plain' query = request.query_string if query == nil respond_no_match( response ) else name = WEBrick::HTTPUtils::unescape_form( query ) find_address( name, response ) end end def find_address( name, response ) if @address_book.has_key?(name) respond_address( response, @address_book[name] ) else respond_no_match( response ) end end def respond_address( response, address ) response.body = address end def respond_no_match( response ) response.body = "no address found" end end |
From: Steve F. <sm...@us...> - 2002-08-31 10:55:25
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/random In directory usw-pr-cvs1:/tmp/cvs-serv26200/src/java/nostone/random Added Files: WeatherTest.java WeatherRandomTest.java Weather.java MockRandom.java WeatherRandom.java DefaultWeatherRandom.java MockWeatherRandom.java Log Message: Restructured source code under single src directory --- NEW FILE: WeatherTest.java --- package nostone.random; import junit.framework.TestCase; public class WeatherTest extends TestCase { public WeatherTest( String test ) { super(test); } public void testRandomRaining() { MockWeatherRandom random; Weather weather; random = new MockWeatherRandom(); random.setupNextIsRaining(true); weather = new Weather( random ); weather.randomize(); assertTrue( "is raining", weather.isRaining() ); random = new MockWeatherRandom(); random.setupNextIsRaining(false); weather = new Weather( random ); weather.randomize(); assertTrue( "is not raining", !weather.isRaining() ); } public void testRandomTemperatureSunny() { final double TEMPERATURE = 20; MockWeatherRandom random = new MockWeatherRandom(); random.setupNextIsRaining( false ); random.setupNextTemperature( TEMPERATURE ); Weather weather = new Weather( random ); weather.randomize(); assertEquals( "temperature", TEMPERATURE, weather.getTemperature(), 0.0 ); } public void testRandomTemperatureRaining() { final double TEMPERATURE = 20; MockWeatherRandom random = new MockWeatherRandom(); random.setupNextIsRaining( true ); random.setupNextTemperature( TEMPERATURE ); Weather weather = new Weather( random ); weather.randomize(); assertEquals( "temperature", TEMPERATURE/2.0, weather.getTemperature(), 0.0 ); } } --- NEW FILE: WeatherRandomTest.java --- package nostone.random; import junit.framework.TestCase; public class WeatherRandomTest extends TestCase { public WeatherRandomTest(String test) { super(test); } public void testNextIsRaining() { MockRandom random = new MockRandom(); WeatherRandom weather_random = new DefaultWeatherRandom(random); random.setNextDouble( 0.0 ); assertTrue( "is raining", weather_random.nextIsRaining() ); random.setNextDouble( DefaultWeatherRandom.CHANCE_OF_RAIN ); assertTrue( "is not raining", !weather_random.nextIsRaining() ); random.setNextDouble( 1.0 ); assertTrue( "is not raining", !weather_random.nextIsRaining() ); } public void testNextTemperature() { MockRandom random = new MockRandom(); WeatherRandom weather_random = new DefaultWeatherRandom(random); random.setNextDouble( 0.0 ); assertEquals( "should be min temperature", DefaultWeatherRandom.MIN_TEMPERATURE, weather_random.nextTemperature(), 0.0 ); random.setNextDouble( 0.5 ); assertEquals( "should be average temperature", 0.5*(DefaultWeatherRandom.MIN_TEMPERATURE + DefaultWeatherRandom.MAX_TEMPERATURE), weather_random.nextTemperature(), 0.0 ); random.setNextDouble( 1.0 ); assertEquals( "should be max temperature", DefaultWeatherRandom.MAX_TEMPERATURE, weather_random.nextTemperature(), 0.0 ); } } --- NEW FILE: Weather.java --- package nostone.random; import java.util.Random; public class Weather { private WeatherRandom random; private boolean isRaining = false; private double temperature = 0.0; public Weather( WeatherRandom random ) { this.random= random; } public boolean isRaining() { return isRaining; } public double getTemperature() { return temperature; } public void randomize() { temperature = random.nextTemperature(); isRaining = random.nextIsRaining(); if( isRaining ) temperature *= 0.5; } } --- NEW FILE: MockRandom.java --- package nostone.random; import java.util.Random; public class MockRandom extends Random { private double nextDouble = 0.0; public void setNextDouble( double d ) { nextDouble = d; } public double nextDouble() { return nextDouble; } } --- NEW FILE: WeatherRandom.java --- package nostone.random; public interface WeatherRandom { boolean nextIsRaining(); double nextTemperature(); } --- NEW FILE: DefaultWeatherRandom.java --- package nostone.random; import java.util.Random; public class DefaultWeatherRandom implements WeatherRandom { static final double CHANCE_OF_RAIN = 0.2; static final double MIN_TEMPERATURE = 20; static final double MAX_TEMPERATURE = 30; static final double TEMPERATURE_RANGE = (MAX_TEMPERATURE-MIN_TEMPERATURE); private Random _rng; public DefaultWeatherRandom( Random rng ) { _rng = rng; } public boolean nextIsRaining() { return _rng.nextDouble() < CHANCE_OF_RAIN; } public double nextTemperature() { return MIN_TEMPERATURE + _rng.nextDouble() * TEMPERATURE_RANGE; } } --- NEW FILE: MockWeatherRandom.java --- package nostone.random; import com.mockobjects.ExpectationCounter; public class MockWeatherRandom implements WeatherRandom { private ExpectationCounter nextIsRainingCounter = new ExpectationCounter("nextIsRaining"); private boolean nextIsRainingResult = false; private ExpectationCounter nextTemperatureCounter = new ExpectationCounter("nextTemperature"); private double nextTemperatureResult = 0.0; public void setupNextIsRaining( boolean result ) { nextIsRainingCounter.setExpected(1); nextIsRainingResult = result; } public boolean nextIsRaining() { nextIsRainingCounter.inc(); return nextIsRainingResult; } public void setupNextTemperature( double result ) { nextTemperatureCounter.setExpected(1); nextTemperatureResult = result; } public double nextTemperature() { nextTemperatureCounter.inc(); return nextTemperatureResult; } } |
From: Steve F. <sm...@us...> - 2002-08-31 10:54:34
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/java In directory usw-pr-cvs1:/tmp/cvs-serv25981/src/java Log Message: Directory /cvsroot/mockobjects/no-stone-unturned/src/java added to the repository |
From: Steve F. <sm...@us...> - 2002-08-31 10:54:34
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/ruby In directory usw-pr-cvs1:/tmp/cvs-serv25981/src/ruby Log Message: Directory /cvsroot/mockobjects/no-stone-unturned/src/ruby added to the repository |
From: Steve F. <sm...@us...> - 2002-08-31 10:54:34
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/gui In directory usw-pr-cvs1:/tmp/cvs-serv25981/src/java/nostone/gui Log Message: Directory /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/gui added to the repository |
From: Steve F. <sm...@us...> - 2002-08-31 10:54:34
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/addressbook In directory usw-pr-cvs1:/tmp/cvs-serv25981/src/java/nostone/addressbook Log Message: Directory /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/addressbook added to the repository |
From: Steve F. <sm...@us...> - 2002-08-31 10:54:34
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/random In directory usw-pr-cvs1:/tmp/cvs-serv25981/src/java/nostone/random Log Message: Directory /cvsroot/mockobjects/no-stone-unturned/src/java/nostone/random added to the repository |
From: Steve F. <sm...@us...> - 2002-08-31 10:54:34
|
Update of /cvsroot/mockobjects/no-stone-unturned/src/java/nostone In directory usw-pr-cvs1:/tmp/cvs-serv25981/src/java/nostone Log Message: Directory /cvsroot/mockobjects/no-stone-unturned/src/java/nostone added to the repository |
From: Vincent M. <vm...@oc...> - 2002-08-31 08:21:31
|
Cool! Welcome aboard Ted! :-) -Vincent > -----Original Message----- > From: moc...@li... > [mailto:moc...@li...] On Behalf Of > Steve Freeman > Sent: 31 August 2002 01:10 > To: MockObjects > Subject: [MO-java-dev] added Ted Husted > > OK, OK, I give in with all these changes... > > Added Ted to the project. > > S. > > - - - - - - - - - - - - - - - > Steve Freeman st...@m3... > Programme chair OT2003. http://www.ot2003.org > > "Nonsense is just nonsense, but the study of nonsense is science." > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |
From: Steve F. <st...@m3...> - 2002-08-31 00:12:24
|
OK, OK, I give in with all these changes... Added Ted to the project. S. - - - - - - - - - - - - - - - Steve Freeman st...@m3... Programme chair OT2003. http://www.ot2003.org "Nonsense is just nonsense, but the study of nonsense is science." |
From: Jeff M. <cus...@us...> - 2002-08-30 14:50:35
|
Update of /cvsroot/mockobjects/mockobjects-java/doc/html In directory usw-pr-cvs1:/tmp/cvs-serv31543/doc/html Modified Files: changes.html todo.html Log Message: Tidy up web site docs Index: changes.html =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/doc/html/changes.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- changes.html 29 Aug 2002 12:17:21 -0000 1.1 +++ changes.html 30 Aug 2002 14:50:32 -0000 1.2 @@ -1,43 +1,26 @@ - +<h1>Changes</h1> +<h2> 0.4 (release on 24 July 2002</h2> +<h2> 0.01 (release on 12 August 2001</h2> - <div class="c9"> - <table cellpadding="2" cellspacing="0" border="0" - width="100%"> - <tr> - <td bgcolor="#525D76"><span class= - "c7"><b>0.01 (release on August 12 - 2001</b></span> </td> - </tr> +<ul> + <li><img align="absmiddle" border="0" + alt="update" src="images/update.jpg"> The + distribution zip now includes a zip of + the sources. (SMGF)</li> - <tr> - <td> - <span class="c8"><br> - </span> + <li><img align="absmiddle" border="0" + alt="update" src="images/update.jpg"> + Improved the build process and generate + the user web site from XML files using + stylebook. (VMA)</li> - <ul> - <li><img align="absmiddle" border="0" - alt="update" src="images/update.jpg"> The - distribution zip now includes a zip of - the sources. (SMGF)</li> - - <li><img align="absmiddle" border="0" - alt="update" src="images/update.jpg"> - Improved the build process and generate - the user web site from XML files using - stylebook. (VMA)</li> - - <li><img align="absmiddle" border="0" - alt="add" src="images/add.jpg"> Added a - user web site (in addition to the <a - href= - "http://sf.net/projects/mockobjects">developer's - web site</a> provided by SourceForge). - Added a project description, todo and - changes pages. (VMA)</li> - </ul> - </td> - </tr> - </table> - </div> - <br> + <li><img align="absmiddle" border="0" + alt="add" src="images/add.jpg"> Added a + user web site (in addition to the <a + href= + "http://sf.net/projects/mockobjects">developer's + web site</a> provided by SourceForge). + Added a project description, todo and + changes pages. (VMA)</li> +</ul> Index: todo.html =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/doc/html/todo.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- todo.html 29 Aug 2002 12:17:21 -0000 1.1 +++ todo.html 30 Aug 2002 14:50:32 -0000 1.2 @@ -1,256 +1,164 @@ - - - <div class="c10"> - <table cellpadding="2" cellspacing="0" border="0" - width="100%"> - <tr> - <td bgcolor="#525D76" class="c7"> - <b>Introduction</b></td> - </tr> - - <tr> - <td> - <span class="c8"><br> - </span> - - <p class="c9">The items below are all the - tasks that need to be done before we will - deliver a new version of the Mock Objects - project. We need your help !</p> - - <p class="c9">If you are interested in - participating, send an email on the <a - href= - "http://sourceforge.net/mail/?group_id=18189"> - Mock Objects mailing list</a> stating your - interest and you'll be enrolled right away - ... We're always looking for help ! Don't - be put off if in the "Volunteer" column - there is already a person listed. On the - contrary, the more persons that participate - in a given task, the better (like in pair - programming, several sets of eyes are - always better than one!). However you'll - need to sync. with these others persons but - this is easily done by posting to the - mailing-list.</p> - - <p class="c9">The fun has just begun ... - !</p> - </td> - </tr> - </table> - </div> - <br> - - - <div class="c10"> - <table cellpadding="2" cellspacing="0" border="0" - width="100%"> - <tr> - <td bgcolor="#525D76" class="c7"><b>Version - 0.02</b></td> - </tr> - - <tr> - <td> - <span class="c8"><br> - </span> - - <div class="c10"> - <table cellpadding="2" cellspacing="0" - border="0" width="99%"> - <tr> - <td bgcolor="#525D76" class="c11"> - <b>Documentation</b></td> - </tr> - - <tr> - <td> - <span class="c8"><br> - </span> - - <table cellpadding="2" cellspacing= - "2" border="0" width="100%"> - <tr> - <td align="center" valign= - "center" rowspan="" colspan="" - bgcolor="#039acc"><span class= - "c12"><b>Description</b> </span> - </td> - - <td align="center" valign= - "center" rowspan="" colspan="" - bgcolor="#039acc"><span class= - "c12"><b>Volunteers</b> </span> - </td> - </tr> - - <tr> - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13">Write a page explaining - the differences between Mock - Objects and Stubs as it is - largely misunderstood. - </span> </td> - - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13">Vincent Massol, Steve - Freeman </span> </td> - </tr> - - <tr> - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13">Explain the code - organisation in the src/ - directory as wall as package - organisation. </span> - </td> - - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13"> </span> </td> - </tr> - - <tr> - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class="c13">Add - a features page explaining - current features of Mock - Objects. </span> </td> - - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13"> </span> </td> - </tr> - </table> - </td> - </tr> - </table> - </div> - <span class="c8"><br> - </span> - - <div class="c10"> - <table cellpadding="2" cellspacing="0" - border="0" width="99%"> - <tr> - <td bgcolor="#525D76" class="c11"> - <b>Code</b></td> - </tr> - - <tr> - <td> - <span class="c8"><br> - </span> - - <table cellpadding="2" cellspacing= - "2" border="0" width="100%"> - <tr> - <td align="center" valign= - "center" rowspan="" colspan="" - bgcolor="#039acc"><span class= - "c12"><b>Description</b> </span> - </td> - - <td align="center" valign= - "center" rowspan="" colspan="" - bgcolor="#039acc"><span class= - "c12"><b>Volunteers</b> </span> - </td> - </tr> - - <tr> - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13">Reformat all source code - : Add javadoc to all code where - needed + add license + add - version number + create - packages.html and overview.html - + reformat according to coding - conventions. We need to do that - ASAP. </span> </td> - - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13">everyone </span> - </td> - </tr> - </table> - </td> - </tr> - </table> - </div> - <span class="c8"><br> - </span> - - <div class="c10"> - <table cellpadding="2" cellspacing="0" - border="0" width="99%"> - <tr> - <td bgcolor="#525D76" class="c11"> - <b>Build</b></td> - </tr> - - <tr> - <td> - <span class="c8"><br> - </span> - - <table cellpadding="2" cellspacing= - "2" border="0" width="100%"> - <tr> - <td align="center" valign= - "center" rowspan="" colspan="" - bgcolor="#039acc"><span class= - "c12"><b>Description</b> </span> - </td> - - <td align="center" valign= - "center" rowspan="" colspan="" - bgcolor="#039acc"><span class= - "c12"><b>Volunteers</b> </span> - </td> - </tr> - - <tr> - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13">Finalise the build - process (still need to finalise - directory structure + manage - examples + manage extensions). - </span> </td> - - <td align="left" valign="top" - rowspan="" colspan="" bgcolor= - "#a0ddf0"><span class= - "c13">Vincent - Massol </span> </td> - </tr> - </table> - </td> - </tr> - </table> - </div> - <span class="c8"><br> - </span> - </td> - </tr> - </table> - </div> - <br> - + <h1>Introduction</h1> + <p>The items below are all the + tasks that need to be done before we will + deliver a new version of the Mock Objects + project. We need your help !</p> + + <p>If you are interested in + participating, send an email on the <a + href= + "http://sourceforge.net/mail/?group_id=18189"> + Mock Objects mailing list</a> stating your + interest and you'll be enrolled right away + ... We're always looking for help ! Don't + be put off if in the "Volunteer" column + there is already a person listed. On the + contrary, the more persons that participate + in a given task, the better (like in pair + programming, several sets of eyes are + always better than one!). However you'll + need to sync. with these others persons but + this is easily done by posting to the + mailing-list.</p> + + <p>The fun has just begun ... !</p> + + <h2>Version 0.02</h2> + <h3>Documentation</h3> + <table cellpadding="2" cellspacing= + "2" border="0" width="100%"> + <tr> + <td align="center" valign= + "center" rowspan="" colspan="" + bgcolor="#039acc"><span class= + "c12"><b>Description</b> </span> + </td> + + <td align="center" valign= + "center" rowspan="" colspan="" + bgcolor="#039acc"><span class= + "c12"><b>Volunteers</b> </span> + </td> + </tr> + + <tr> + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13">Write a page explaining + the differences between Mock + Objects and Stubs as it is + largely misunderstood. + </span> </td> + + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13">Vincent Massol, Steve + Freeman </span> </td> + </tr> + + <tr> + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13">Explain the code + organisation in the src/ + directory as wall as package + organisation. </span> + </td> + + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13"> </span> </td> + </tr> + + <tr> + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class="c13">Add + a features page explaining + current features of Mock + Objects. </span> </td> + + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13"> </span> </td> + </tr> + </table> + + <h3>Code</h3> + + <table cellpadding="2" cellspacing= + "2" border="0" width="100%"> + <tr> + <td align="center" valign= + "center" rowspan="" colspan="" + bgcolor="#039acc"><span class= + "c12"><b>Description</b> </span> + </td> + + <td align="center" valign= + "center" rowspan="" colspan="" + bgcolor="#039acc"><span class= + "c12"><b>Volunteers</b> </span> + </td> + </tr> + + <tr> + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13">Reformat all source code + : Add javadoc to all code where + needed + add license + add + version number + create + packages.html and overview.html + + reformat according to coding + conventions. We need to do that + ASAP. </span> </td> + + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13">everyone </span> + </td> + </tr> + </table> + + <h3>Build</h3> + <table cellpadding="2" cellspacing= + "2" border="0" width="100%"> + <tr> + <td align="center" valign= + "center" rowspan="" colspan="" + bgcolor="#039acc"><span class= + "c12"><b>Description</b> </span> + </td> + + <td align="center" valign= + "center" rowspan="" colspan="" + bgcolor="#039acc"><span class= + "c12"><b>Volunteers</b> </span> + </td> + </tr> + + <tr> + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13">Finalise the build + process (still need to finalise + directory structure + manage + examples + manage extensions). + </span> </td> + + <td align="left" valign="top" + rowspan="" colspan="" bgcolor= + "#a0ddf0"><span class= + "c13">Vincent + Massol </span> </td> + </tr> + </table> |
From: Jeff M. <cus...@us...> - 2002-08-30 14:50:01
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv31012/src/jdk/common/com/mockobjects/sql Added Files: CommonMockResultSetMetaData.java Log Message: Added support for column types to MockResultSetMetaData and create a common base class for both 1.3 and 1.4 jdk --- NEW FILE: CommonMockResultSetMetaData.java --- package com.mockobjects.sql; import com.mockobjects.MockObject; import com.mockobjects.ReturnObjectList; import com.mockobjects.ExpectationList; import java.sql.ResultSetMetaData; import java.sql.SQLException; /** * $Revision: 1.1 $ */ public abstract class CommonMockResultSetMetaData extends MockObject implements ResultSetMetaData { private final ReturnObjectList myNames = new ReturnObjectList("MockResultSetMetaData.columnNames"); private final ReturnObjectList myTypes = new ReturnObjectList("MockResultSetMetaData.columnTypes"); private int myColumnCount; private final ExpectationList myColumnTypeIndexes = new ExpectationList("Column Type Indexes"); private final ExpectationList myColumnNameIndexes = new ExpectationList("Column Name Indexes"); /** * Value to return from getColumnCount. */ public void setupGetColumnCount(int aColumnCount) { myColumnCount = aColumnCount; } /** * An array of column names in the order they appear in the * resultSet. */ public void setupAddColumnNames(String[] allNames) { if (allNames != null) { for (int i = 0; i < allNames.length; i++) { setupAddColumnName(allNames[i]); } } } /** * The next column name in the resultSet. */ public void setupAddColumnName(String aName) { this.myNames.addObjectToReturn(aName); } /** * An array of column SQL types in the order they appear in the * resultSet. */ public void setupAddColumnTypes(int[] allTypes) { if (allTypes != null) { for (int i = 0; i < allTypes.length; i++) { setupAddColumnType(allTypes[i]); } } } /** * The next column's SQL type in the resultSet as an int. */ public void setupAddColumnType(int aType) { this.myTypes.addObjectToReturn(aType); } /** * Returns value passed to setupGetColumnCount. * @see ResultSetMetaData#getColumnCount() */ public int getColumnCount() throws SQLException { return myColumnCount; } /** * Returns the column name. * DOES NOT SUPPORT THE aColumnIndex PARAMETER. * You must call getColumnName in order, first to last. * Column names may be added with setupAddColumnName. * or setupAddColumnNames. * @see ResultSetMetaData#getColumnName(int) */ public String getColumnName(int aColumnIndex) throws SQLException { myColumnNameIndexes.addActual(aColumnIndex); return (String) myNames.nextReturnObject(); } /** * Adds an expectation for a column index to be passed to getColumnName * @see MockResultSetMetaData#getColumnName(int) */ public void addExpectedColumnNameIndex(int aColumnIndex){ myColumnNameIndexes.addExpected(aColumnIndex); } /** * Returns the column SQL type. * DOES NOT SUPPORT THE aColumnIndex PARAMETER. * You must call getColumnType in order, first to last. * Column SQL types may be added with setupAddColumnType. * @see ResultSetMetaData#getColumnType(int) */ public int getColumnType(int aColumnIndex) throws SQLException { myColumnTypeIndexes.addActual(aColumnIndex); return ((Integer) myTypes.nextReturnObject()).intValue(); } /** * Adds an expectation for a column index to be passed to getColumnType * @see MockResultSetMetaData#getColumnType(int) */ public void addExpectedColumnTypeIndex(int aColumnIndex){ myColumnTypeIndexes.addExpected(aColumnIndex); } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isAutoIncrement(int) */ public boolean isAutoIncrement(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isCaseSensitive(int) */ public boolean isCaseSensitive(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isSearchable(int) */ public boolean isSearchable(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isCurrency(int) */ public boolean isCurrency(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isNullable(int) */ public int isNullable(int arg0) throws SQLException { notImplemented(); return 0; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isSigned(int) */ public boolean isSigned(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns 0. * @see ResultSetMetaData#getColumnDisplaySize(int) */ public int getColumnDisplaySize(int arg0) throws SQLException { notImplemented(); return 0; } /** * Calls notImplemented. Returns null. * @see ResultSetMetaData#getColumnLabel(int) */ public String getColumnLabel(int arg0) throws SQLException { notImplemented(); return null; } /** * Calls notImplemented. Returns null. * @see ResultSetMetaData#getColumnTypeName(int) */ public String getColumnTypeName(int arg0) throws SQLException { notImplemented(); return null; } /** * Calls notImplemented. Returns null. * @see ResultSetMetaData#getSchemaName(int) */ public String getSchemaName(int arg0) throws SQLException { notImplemented(); return null; } /** * Calls notImplemented. Returns 0. * @see ResultSetMetaData#getPrecision(int) */ public int getPrecision(int arg0) throws SQLException { notImplemented(); return 0; } /** * Calls notImplemented. Returns 0. * @see ResultSetMetaData#getScale(int) */ public int getScale(int arg0) throws SQLException { notImplemented(); return 0; } /** * Calls notImplemented. Returns null. * @see ResultSetMetaData#getTableName(int) */ public String getTableName(int arg0) throws SQLException { notImplemented(); return null; } /** * Calls notImplemented. Returns null. * @see ResultSetMetaData#getCatalogName(int) */ public String getCatalogName(int arg0) throws SQLException { notImplemented(); return null; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isReadOnly(int) */ public boolean isReadOnly(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isWritable(int) */ public boolean isWritable(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns false. * @see ResultSetMetaData#isDefinitelyWritable(int) */ public boolean isDefinitelyWritable(int arg0) throws SQLException { notImplemented(); return false; } /** * Calls notImplemented. Returns null. * @see ResultSetMetaData#getColumnClassName(int) */ public String getColumnClassName(int arg0) throws SQLException { notImplemented(); return null; } } |
From: Jeff M. <cus...@us...> - 2002-08-30 14:50:01
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.3/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv31012/src/jdk/1.3/com/mockobjects/sql Modified Files: MockResultSetMetaData.java Log Message: Added support for column types to MockResultSetMetaData and create a common base class for both 1.3 and 1.4 jdk Index: MockResultSetMetaData.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.3/com/mockobjects/sql/MockResultSetMetaData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockResultSetMetaData.java 28 Jun 2002 17:35:39 -0000 1.1 +++ MockResultSetMetaData.java 30 Aug 2002 14:49:58 -0000 1.2 @@ -1,195 +1,19 @@ package com.mockobjects.sql; -import com.mockobjects.*; -import java.sql.*; -import java.sql.SQLException; -import java.util.Vector; - -public class MockResultSetMetaData extends MockObject -implements ResultSetMetaData { - - private ReturnObjectList myNames = new ReturnObjectList("column names"); - private int myColumnCount; - - public void setupGetColumnCount(int aColumnCount){ - myColumnCount = aColumnCount; - } - - /** - * @see ResultSetMetaData#getColumnCount() - */ - public int getColumnCount() throws SQLException { - return myColumnCount; - } - - /** - * @see ResultSetMetaData#isAutoIncrement(int) - */ - public boolean isAutoIncrement(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isCaseSensitive(int) - */ - public boolean isCaseSensitive(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isSearchable(int) - */ - public boolean isSearchable(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isCurrency(int) - */ - public boolean isCurrency(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isNullable(int) - */ - public int isNullable(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#isSigned(int) - */ - public boolean isSigned(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#getColumnDisplaySize(int) - */ - public int getColumnDisplaySize(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getColumnLabel(int) - */ - public String getColumnLabel(int arg0) throws SQLException { - notImplemented(); - return null; - } +import com.mockobjects.ExpectationList; +import com.mockobjects.MockObject; +import com.mockobjects.ReturnObjectList; - public void setupAddColumnNames(String[] allNames) { - if (allNames != null) { - for (int i = 0; i < allNames.length; i++) { - setupAddColumnName(allNames[i]); - } - } - } - - public void setupAddColumnName(String aName){ - this.myNames.addObjectToReturn(aName); - } - - /** - * @see ResultSetMetaData#getColumnName(int) - */ - public String getColumnName(int aColumnIndex) throws SQLException { - return (String)myNames.nextReturnObject(); - } - - /** - * @see ResultSetMetaData#getSchemaName(int) - */ - public String getSchemaName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#getPrecision(int) - */ - public int getPrecision(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getScale(int) - */ - public int getScale(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getTableName(int) - */ - public String getTableName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#getCatalogName(int) - */ - public String getCatalogName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#getColumnType(int) - */ - public int getColumnType(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getColumnTypeName(int) - */ - public String getColumnTypeName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#isReadOnly(int) - */ - public boolean isReadOnly(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isWritable(int) - */ - public boolean isWritable(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isDefinitelyWritable(int) - */ - public boolean isDefinitelyWritable(int arg0) throws SQLException { - notImplemented(); - return false; - } +import java.sql.ResultSetMetaData; +import java.sql.SQLException; - /** - * @see ResultSetMetaData#getColumnClassName(int) - */ - public String getColumnClassName(int arg0) throws SQLException { - notImplemented(); - return null; - } +/** + * Minimal implementation of ResultSetMetaData for testing. + * Supports column count, column names, and column sql types. + * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/sql/ResultSetMetaData.html">javax.sql.ResultSetMetaData</a>. + * @author Jeff Martin + * @author Ted Husted + * @version $Revision$ + */ +public class MockResultSetMetaData extends CommonMockResultSetMetaData { } |
From: Jeff M. <cus...@us...> - 2002-08-30 14:50:01
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql In directory usw-pr-cvs1:/tmp/cvs-serv31012/src/jdk/1.4/com/mockobjects/sql Modified Files: MockResultSetMetaData.java Log Message: Added support for column types to MockResultSetMetaData and create a common base class for both 1.3 and 1.4 jdk Index: MockResultSetMetaData.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql/MockResultSetMetaData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockResultSetMetaData.java 28 Jun 2002 17:35:39 -0000 1.1 +++ MockResultSetMetaData.java 30 Aug 2002 14:49:58 -0000 1.2 @@ -1,195 +1,19 @@ package com.mockobjects.sql; -import com.mockobjects.*; -import java.sql.*; -import java.sql.SQLException; -import java.util.Vector; - -public class MockResultSetMetaData extends MockObject -implements ResultSetMetaData { - - private ReturnObjectList myNames = new ReturnObjectList("column names"); - private int myColumnCount; - - public void setupGetColumnCount(int aColumnCount){ - myColumnCount = aColumnCount; - } - - /** - * @see ResultSetMetaData#getColumnCount() - */ - public int getColumnCount() throws SQLException { - return myColumnCount; - } - - /** - * @see ResultSetMetaData#isAutoIncrement(int) - */ - public boolean isAutoIncrement(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isCaseSensitive(int) - */ - public boolean isCaseSensitive(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isSearchable(int) - */ - public boolean isSearchable(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isCurrency(int) - */ - public boolean isCurrency(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isNullable(int) - */ - public int isNullable(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#isSigned(int) - */ - public boolean isSigned(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#getColumnDisplaySize(int) - */ - public int getColumnDisplaySize(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getColumnLabel(int) - */ - public String getColumnLabel(int arg0) throws SQLException { - notImplemented(); - return null; - } +import com.mockobjects.ExpectationList; +import com.mockobjects.MockObject; +import com.mockobjects.ReturnObjectList; - public void setupAddColumnNames(String[] allNames) { - if (allNames != null) { - for (int i = 0; i < allNames.length; i++) { - setupAddColumnName(allNames[i]); - } - } - } - - public void setupAddColumnName(String aName){ - this.myNames.addObjectToReturn(aName); - } - - /** - * @see ResultSetMetaData#getColumnName(int) - */ - public String getColumnName(int aColumnIndex) throws SQLException { - return (String)myNames.nextReturnObject(); - } - - /** - * @see ResultSetMetaData#getSchemaName(int) - */ - public String getSchemaName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#getPrecision(int) - */ - public int getPrecision(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getScale(int) - */ - public int getScale(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getTableName(int) - */ - public String getTableName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#getCatalogName(int) - */ - public String getCatalogName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#getColumnType(int) - */ - public int getColumnType(int arg0) throws SQLException { - notImplemented(); - return 0; - } - - /** - * @see ResultSetMetaData#getColumnTypeName(int) - */ - public String getColumnTypeName(int arg0) throws SQLException { - notImplemented(); - return null; - } - - /** - * @see ResultSetMetaData#isReadOnly(int) - */ - public boolean isReadOnly(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isWritable(int) - */ - public boolean isWritable(int arg0) throws SQLException { - notImplemented(); - return false; - } - - /** - * @see ResultSetMetaData#isDefinitelyWritable(int) - */ - public boolean isDefinitelyWritable(int arg0) throws SQLException { - notImplemented(); - return false; - } +import java.sql.ResultSetMetaData; +import java.sql.SQLException; - /** - * @see ResultSetMetaData#getColumnClassName(int) - */ - public String getColumnClassName(int arg0) throws SQLException { - notImplemented(); - return null; - } +/** + * Minimal implementation of ResultSetMetaData for testing. + * Supports column count, column names, and column sql types. + * @see <a href=" http://java.sun.com/j2se/1.3/docs/api/java/sql/ResultSetMetaData.html">javax.sql.ResultSetMetaData</a>. + * @author Jeff Martin + * @author Ted Husted + * @version $Revision$ + */ +public class MockResultSetMetaData extends CommonMockResultSetMetaData { } |
From: Jeff M. <cus...@us...> - 2002-08-30 14:50:01
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory usw-pr-cvs1:/tmp/cvs-serv31012/src/core/com/mockobjects Modified Files: AbstractExpectationCollection.java ExpectationSet.java ReturnObjectList.java Log Message: Added support for column types to MockResultSetMetaData and create a common base class for both 1.3 and 1.4 jdk Index: AbstractExpectationCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/AbstractExpectationCollection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AbstractExpectationCollection.java 29 Jan 2002 14:56:01 -0000 1.3 +++ AbstractExpectationCollection.java 30 Aug 2002 14:49:57 -0000 1.4 @@ -1,9 +1,10 @@ package com.mockobjects; -import java.util.*; -import junit.framework.Assert; +import java.util.Collection; +import java.util.Enumeration; +import java.util.Iterator; -abstract public class AbstractExpectationCollection extends AbstractExpectation implements ExpectationCollection { +abstract public class AbstractExpectationCollection extends AbstractExpectation implements ExpectationCollection { public AbstractExpectationCollection(String name) { super(name); @@ -16,6 +17,15 @@ } } + public void addActual(int actualItem) { + Integer actualItemWrapper = new Integer(actualItem); + + getActualCollection().add(actualItemWrapper); + if (shouldCheckImmediately()) { + checkImmediateValues(actualItemWrapper); + } + } + public void addActualMany(Object[] items) { for (int i = 0; i < items.length; ++i) { addActual(items[i]); @@ -32,6 +42,12 @@ while (items.hasNext()) { addActual(items.next()); } + } + + public void addExpected(int expectedItem) { + Integer expectedItemWrapper = new Integer(expectedItem); + getExpectedCollection().add(expectedItemWrapper); + setHasExpectations(); } public void addExpected(Object expectedItem) { Index: ExpectationSet.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ExpectationSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ExpectationSet.java 29 Jul 2001 19:50:24 -0000 1.1 +++ ExpectationSet.java 30 Aug 2002 14:49:57 -0000 1.2 @@ -1,8 +1,9 @@ package com.mockobjects; -import java.util.*; -import junit.framework.Assert; import com.mockobjects.util.AssertMo; + +import java.util.Collection; +import java.util.HashSet; public class ExpectationSet extends AbstractExpectationCollection { private HashSet myExpectedItems = new HashSet(); Index: ReturnObjectList.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ReturnObjectList.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ReturnObjectList.java 19 Jun 2002 15:11:00 -0000 1.3 +++ ReturnObjectList.java 30 Aug 2002 14:49:57 -0000 1.4 @@ -46,6 +46,14 @@ } /** + * Add a next integer to the end of the list. + * @param anIntegerToReturn integer to be added to the list + */ + public void addObjectToReturn(int anIntegerToReturn){ + myObjects.add(new Integer(anIntegerToReturn)); + } + + /** * Returns the next object from the list. Each object it returned in the * order in which they where added. */ |