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. <cus...@us...> - 2003-02-21 12:14:18
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql In directory sc8-pr-cvs1:/tmp/cvs-serv5808/src/jdk/1.4/com/mockobjects/sql Modified Files: MockConnection2.java Log Message: Correct my apoling speling und gramma Big up to François Beausoleil Index: MockConnection2.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql/MockConnection2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockConnection2.java 4 Dec 2002 12:39:23 -0000 1.1 +++ MockConnection2.java 21 Feb 2003 12:14:15 -0000 1.2 @@ -5,12 +5,12 @@ /** * MockConnection2 is a tempary replacement for the MockConnection. - * It differs from the MockConnection in the way in which preparedstatements + * It differs from the MockConnection in the way in which PreparedStatements * are handled. The changes are significant enough to break compatiblity with - * exsising testcases so MockConnection2 provides a migration path to the new - * system of handling preparedstatements. - * This calls will eventually be merged back into MockConnection when it is felt - * systems using the classes have been provided with enough time to migrate. + * existing testcases so MockConnection2 provides a migration path to the new + * system of handling PreparedStatements. + * This class will eventually be merged back into MockConnection when it is + * felt systems using the classes have been provided with enough time to migrate. */ public class MockConnection2 extends CommonMockConnection2{ private final MockConnection connection = new MockConnection(); |
From: <fb...@us...> - 2003-02-19 05:36:32
|
Hi, This is a simple patch that implements createStatement(int resultSetType, int resultSetConcurrency). I use IntelliJ's Idea and I reformatted the code too, so there are a few changes that are not a direct result of this implementation. Thanks, Francois Beausoleil Index: src/jdk/common/com/mockobjects/sql/CommonMockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql/CommonMockConnection.java,v retrieving revision 1.6 diff -u -r1.6 CommonMockConnection.java --- src/jdk/common/com/mockobjects/sql/CommonMockConnection.java 9 Dec 2002 18:20:14 -0000 1.6 +++ src/jdk/common/com/mockobjects/sql/CommonMockConnection.java 19 Feb 2003 05:08:44 -0000 @@ -68,7 +68,7 @@ * Exceptions to throw can be registered for calling createStatement, * preparedStatement, or close. * Several less-often-used methods are not implemented. - * If a notImplemented method is are needed for your project, please submit + * If a notImplemented method is needed for your project, please submit * a patch. * @see <a href="http://java.sun.com/j2se/1.3/docs/api/java/sql/Connection.html">javax.sql.Connection</a> * @author @@ -89,6 +89,9 @@ private boolean autoCommit = false; + private final ExpectationValue myResultSetConcurrency; + private final ExpectationValue myResultSetType; + private final ExpectationList myAutoCommit; private final ExpectationCounter myCloseCalls; private final ExpectationCounter myCommitCalls; @@ -132,6 +135,8 @@ myPreparedStatements = new ReturnObjectList(name + ".PreparedStatements"); myPreparedStatementStrings = new ExpectationList(name + ".preparedStatementString"); myRollbackCalls = new ExpectationCounter(name + ".rollback"); + myResultSetType = new ExpectationValue(name + ".resultSetType"); + myResultSetConcurrency = new ExpectationValue(name + ".resultSetConcurrency"); } /** @@ -188,6 +193,30 @@ myRollbackCalls.setExpected(callCount); } + /** + * Sets expectations about the possible value of the + * <code>resultSetConcurrency</code> parameter of + * {@link #createStatement(int, int) createStatement()} calls. + * + * @param resultSetConcurrency One of the constants starting with CONCUR + * in {@link java.sql.ResultSet}. + */ + public void setExpectedResultSetConcurrency(int resultSetConcurrency) { + myResultSetConcurrency.setExpected(resultSetConcurrency); + } + + /** + * Sets expectations about the possible value of the + * <code>resultSetType</code> parameter of + * {@link #createStatement(int, int) createStatement()} calls. + * + * @param resultSetType One of the constants starting with TYPE + * in {@link java.sql.ResultSet}. + */ + public void setExpectedResultSetType(int resultSetType) { + myResultSetType.setExpected(resultSetType); + } + // --------------------------------------------------------------------- setup /** @@ -304,7 +333,7 @@ * Returns the DatabaseMetaData instance passed to setupMetaData. */ public DatabaseMetaData getMetaData() - throws SQLException { + throws SQLException { return myMetaData; } @@ -328,7 +357,7 @@ public PreparedStatement prepareStatement(String sql) throws SQLException { myPreparedStatementStrings.addActual(sql); throwStatementExceptionIfAny(); - return (PreparedStatement) myPreparedStatements.nextReturnObject(); + return (PreparedStatement)myPreparedStatements.nextReturnObject(); } /** @@ -360,11 +389,16 @@ * Calls notImplemented. Returns null. */ public Statement createStatement( - int resultSetType, - int resultSetConcurrency) - throws SQLException { - notImplemented(); - return null; + int resultSetType, + int resultSetConcurrency) + throws SQLException { + myCreateStatementCalls.inc(); + throwStatementExceptionIfAny(); + + myResultSetType.setActual(resultSetType); + myResultSetConcurrency.setActual(resultSetConcurrency); + + return myStatement; } public boolean getAutoCommit() throws SQLException { @@ -423,7 +457,7 @@ * Calls notImplemented. Returns null. */ public CallableStatement prepareCall(String sql) - throws SQLException { + throws SQLException { notImplemented(); return null; } @@ -432,10 +466,10 @@ * Calls notImplemented. Returns null. */ public CallableStatement prepareCall( - String sql, - int resultSetType, - int resultSetConcurrency) - throws SQLException { + String sql, + int resultSetType, + int resultSetConcurrency) + throws SQLException { notImplemented(); return null; } @@ -444,10 +478,10 @@ * Calls notImplemented. Returns null. */ public PreparedStatement prepareStatement( - String sql, - int resultSetType, - int resultSetConcurrency) - throws SQLException { + String sql, + int resultSetType, + int resultSetConcurrency) + throws SQLException { notImplemented(); return null; } @@ -470,7 +504,7 @@ * Calls notImplemented. */ public void setTransactionIsolation(int level) - throws SQLException { + throws SQLException { notImplemented(); } @@ -491,39 +525,39 @@ } public Statement createStatement(int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { + int resultSetHoldability) throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, int resultSetType, - int resultSetConcurrency, int resultSetHoldability) - throws SQLException { + int resultSetConcurrency, int resultSetHoldability) + throws SQLException { notImplemented(); return null; } public CallableStatement prepareCall(String sql, int resultSetType, - int resultSetConcurrency, - int resultSetHoldability) throws SQLException { + int resultSetConcurrency, + int resultSetHoldability) throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) - throws SQLException { + throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, int columnIndexes[]) - throws SQLException { + throws SQLException { notImplemented(); return null; } public PreparedStatement prepareStatement(String sql, String columnNames[]) - throws SQLException { + throws SQLException { notImplemented(); return null; } |
From: <fb...@us...> - 2003-02-19 05:26:15
|
Hello all ! This patch corrects a few grammatical errors. Nothing big. Thanks, Francois Beausoleil Index: src/jdk/1.4/com/mockobjects/sql/MockConnection2.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql/MockConnection2.java,v retrieving revision 1.1 diff -u -r1.1 MockConnection2.java --- src/jdk/1.4/com/mockobjects/sql/MockConnection2.java 4 Dec 2002 12:39:23 -0000 1.1 +++ src/jdk/1.4/com/mockobjects/sql/MockConnection2.java 19 Feb 2003 05:08:44 -0000 @@ -5,12 +5,12 @@ /** * MockConnection2 is a tempary replacement for the MockConnection. - * It differs from the MockConnection in the way in which preparedstatements + * It differs from the MockConnection in the way in which PreparedStatements * are handled. The changes are significant enough to break compatiblity with - * exsising testcases so MockConnection2 provides a migration path to the new - * system of handling preparedstatements. - * This calls will eventually be merged back into MockConnection when it is felt - * systems using the classes have been provided with enough time to migrate. + * existing testcases so MockConnection2 provides a migration path to the new + * system of handling PreparedStatements. + * This class will eventually be merged back into MockConnection when it is + * felt systems using the classes have been provided with enough time to migrate. */ public class MockConnection2 extends CommonMockConnection2{ private final MockConnection connection = new MockConnection(); |
From: Tim M. <tim...@po...> - 2003-02-18 00:24:57
|
I was going to suggest that Vincent could wrap the NamingManager object in some better behaved implementation - as exposing the reset stuff does set a dangerous precedent (we observe mocks getting used for all kinds of wierd stuff)... However I have a second observation that supports his reset's as well. Often you initialize a default state in the setup method used by all test methods in a fixture - and then once in a while there are one or two tests out of the 10-15 that just want a slightly different set of expectations - and you know, its a pain in the ass to redefine all of that share stuff for those two tests - and so I've often just wanted to reset that one expectation and leave the rest of the infrastructure in place... its maybe not totally pure - but readability is actually better and in general its what people expect (you often waste a few minutes trying to refactor that duplication back into setup only to discover that one difference that made you duplicate it in the first place). So I second vincents request (maybe with some caveat that reset has a description where you document why you are doing this?) Tim -----Original Message----- From: moc...@li... [mailto:moc...@li...]On Behalf Of Vincent Massol Sent: 17 February 2003 17:43 To: 'Steve Freeman' Cc: 'MockObjects' Subject: RE: [MO-java-dev] Reusing dynamic mocks? Hi Steve, > -----Original Message----- > From: Steve Freeman [mailto:st...@m3...] > Sent: 17 February 2003 16:27 > To: Vincent Massol > Subject: Re: [MO-java-dev] Reusing dynamic mocks? > > Vincent Massol wrote: > > Hi, > > > > I have a scenario where I have to reuse the same Dynamic Mock for > > several tests. However, it appears that there is no "reset()" methods on > > the Mock class. Am I missing something? If not, can I add the following > > to Mock.java: > > > > public void reset() > > { > > this.methods = new MethodMap(); > > } > > Does it really have to be the same instance each time? Actually yes. The scenario is as follows: I am setting up my own JNDI implementation which, upon call to "new InitialContext()" returns a Mock Context object. However, setting up one's own JNDI implementation (by calling NamingManager.setInitialContextFactoryBuilder) can only be done once during the VM's lifetime. Thus, I am wrapping this in a TestSetup. This means that I have only one chance to define what will be the mock returned upon calls to "new InitialContext()". I believe there are use cases for the reset() stuff. Let me know what you think. Thanks -Vincent > > I'd suggest wrapping up mock object creation in a helper method and > generate a new copy for each test. > > S. > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Mockobjects-java-dev mailing list Moc...@li... https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.455 / Virus Database: 255 - Release Date: 13/02/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.455 / Virus Database: 255 - Release Date: 13/02/2003 |
From: Vincent M. <vm...@oc...> - 2003-02-17 17:43:20
|
Hi Steve, > -----Original Message----- > From: Steve Freeman [mailto:st...@m3...] > Sent: 17 February 2003 16:27 > To: Vincent Massol > Subject: Re: [MO-java-dev] Reusing dynamic mocks? > > Vincent Massol wrote: > > Hi, > > > > I have a scenario where I have to reuse the same Dynamic Mock for > > several tests. However, it appears that there is no "reset()" methods on > > the Mock class. Am I missing something? If not, can I add the following > > to Mock.java: > > > > public void reset() > > { > > this.methods = new MethodMap(); > > } > > Does it really have to be the same instance each time? Actually yes. The scenario is as follows: I am setting up my own JNDI implementation which, upon call to "new InitialContext()" returns a Mock Context object. However, setting up one's own JNDI implementation (by calling NamingManager.setInitialContextFactoryBuilder) can only be done once during the VM's lifetime. Thus, I am wrapping this in a TestSetup. This means that I have only one chance to define what will be the mock returned upon calls to "new InitialContext()". I believe there are use cases for the reset() stuff. Let me know what you think. Thanks -Vincent > > I'd suggest wrapping up mock object creation in a helper method and > generate a new copy for each test. > > S. > |
From: Joe W. <jo...@tr...> - 2003-02-16 22:24:43
|
You can easily set this up by definining your own MockCall implementation. To meet your use case, it's as simple as: final Map lookupData = new HashMap(); lookupData.add(OrderUtil.ORDER_LOCALHOME, orderLocalHome); lookupData.add(JNDINames.QUEUE_ORDER, queue); lookupData.add(JNDINames.QUEUE_CONNECTION_FACTORY, queueConnectionFactory); mockContext.setup("lookup", new MockCall() { public Object call(Object[] args) { return lookupData.get(args[0]); } }); Adding a CallGroup class would be a good idea as this is something I've come across lots although it might be tricky as it seems coupled to the fact that the first argument is a keyed value. cheers -Joe Vincent Massol wrote: >Hi, > >I have the following use case: > >1/ I have a lookup() method >2/ The first time the code under test is executed, the lookup method is >called 3 times >3/ The second time (and all time thereafter) the code under test is >executed, the lookup method is only called twice (because a static flag >has been set) >4/ I can't remove the static flag (because I'm writing a tutorial which >needs this static flag) >5/ I would much much prefer not to have to order my testXXX() methods > >My question is: how can I set this up using Dyna Mocks? > >If I write: > > CallSequence sequence = new CallSequence(); > sequence.expectReturn(OrderUtil.ORDER_LOCALHOME, >orderLocalHome); > sequence.expectReturn(JNDINames.QUEUE_ORDER, queue); > sequence.expectReturn(JNDINames.QUEUE_CONNECTION_FACTORY, > queueConnectionFactory); > mockContext.setup("lookup", sequence); > >Then, it does not work the second time as the first lookup is skipped in >the execution code (because of the flag). > >Does anyone have a "CallGroup" java class that would perform the same as >CallSequence but with no ordering nor expectation on the calls? > >Thanks >-Vincent > > > >------------------------------------------------------- >This sf.net email is sponsored by:ThinkGeek >Welcome to geek heaven. >http://thinkgeek.com/sf >_______________________________________________ >Mockobjects-java-dev mailing list >Moc...@li... >https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > |
From: Vincent M. <vm...@oc...> - 2003-02-16 21:07:34
|
Hi, I have a scenario where I have to reuse the same Dynamic Mock for several tests. However, it appears that there is no "reset()" methods on the Mock class. Am I missing something? If not, can I add the following to Mock.java: public void reset() { this.methods = new MethodMap(); } Thanks -Vincent |
From: Vincent M. <vm...@oc...> - 2003-02-16 21:07:30
|
Hi, I have the following use case: 1/ I have a lookup() method 2/ The first time the code under test is executed, the lookup method is called 3 times 3/ The second time (and all time thereafter) the code under test is executed, the lookup method is only called twice (because a static flag has been set) 4/ I can't remove the static flag (because I'm writing a tutorial which needs this static flag) 5/ I would much much prefer not to have to order my testXXX() methods My question is: how can I set this up using Dyna Mocks? If I write: CallSequence sequence = new CallSequence(); sequence.expectReturn(OrderUtil.ORDER_LOCALHOME, orderLocalHome); sequence.expectReturn(JNDINames.QUEUE_ORDER, queue); sequence.expectReturn(JNDINames.QUEUE_CONNECTION_FACTORY, queueConnectionFactory); mockContext.setup("lookup", sequence); Then, it does not work the second time as the first lookup is skipped in the execution code (because of the flag). Does anyone have a "CallGroup" java class that would perform the same as CallSequence but with no ordering nor expectation on the calls? Thanks -Vincent |
From: Jeff M. <je...@mk...> - 2003-02-06 11:11:18
|
Thanks for this I will get around to adding it soon, just a bit busy at the moment. On Fri, 2003-01-31 at 16:17, Dave Glowacki wrote: > Here are a few patches for both MockHttpServletResponse and > MockHttpServletRequest in src/j2ee/1.3/com/mockobjects/servlet/ > > The first patch adds support for addCookie() to MockHttpServletResponse: > ----------- > Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java,v > retrieving revision 1.2 > diff -u -3 -p -r1.2 MockHttpServletResponse.java > --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java 20 Nov 2002 19:08:58 -0000 1.2 > +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java 31 Jan 2003 16:13:12 -0000 > @@ -14,6 +14,8 @@ public class MockHttpServletResponse ext > > private final ExpectationList myContentTypes = > new ExpectationList("MockHttpServletResponse.setContentType"); > + private ExpectationList myCookies = > + new ExpectationList("MockHttpServletResponse.addCookie"); > private final ExpectationList myHeaders = > new ExpectationList("MockHttpServletResponse.setHeader"); > private final ExpectationCounter mySetStatusCalls = > @@ -32,7 +34,7 @@ public class MockHttpServletResponse ext > * Not Implemented > */ > public void addCookie(Cookie arg1) { > - notImplemented(); > + myCookies.addActual(arg1); > } > > /** > @@ -47,6 +49,10 @@ public class MockHttpServletResponse ext > */ > public void addHeader(String arg1, String arg2) { > notImplemented(); > + } > + > + public void addExpectedCookie(javax.servlet.http.Cookie cookie) { > + myCookies.addExpected(cookie); > } > > /** > ----------- > > I broke up the MockHttpServletRequest patch into 4 parts to make it > easier to see which bits go together. The first patch is a simple typo > fix: > > ----------- > Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v > retrieving revision 1.12 > diff -u -3 -p -r1.12 MockHttpServletRequest.java > --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 > +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 15:55:43 -0000 > @@ -57,7 +57,7 @@ public class MockHttpServletRequest exte > return myAttributesToReturn.nextReturnObject(); > } > > - public void setupGetAttrubuteNames(Vector attributeNames){ > + public void setupGetAttributeNames(Vector attributeNames){ > myAttributesNames = attributeNames; > } > > ----------- > > Second, implementations of getAuthType(), getRemoteHost() and > getRemoteUser(): > > ----------- > Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v > retrieving revision 1.12 > diff -u -3 -p -r1.12 MockHttpServletRequest.java > --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 > +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 15:57:56 -0000 > @@ -27,6 +27,9 @@ public class MockHttpServletRequest exte > private String myContextPath; > private String myPathInfo; > private String myRemoteAddress; > + private final ReturnValue myAuthType = new ReturnValue("authentication type"); > + private final ReturnValue myRemoteHost = new ReturnValue("remote host"); > + private final ReturnValue myRemoteUser = new ReturnValue("remote user"); > private final ReturnValue myRequestURI = new ReturnValue("request URI"); > private final ReturnValue method = new ReturnValue("method"); > private final ReturnValue protocol = new ReturnValue("protocol"); > @@ -65,9 +68,12 @@ public class MockHttpServletRequest exte > return myAttributesNames.elements(); > } > > + public void setupGetAuthType(String authType) { > + myAuthType.setValue(authType); > + } > + > public String getAuthType() { > - notImplemented(); > - return null; > + return (String)myAuthType.getValue(); > } > > public String getCharacterEncoding() { > @@ -212,14 +218,20 @@ public class MockHttpServletRequest exte > return myRemoteAddress; > } > > + public void setupGetRemoteHost(String remoteHost) { > + myRemoteHost.setValue(remoteHost); > + } > + > public String getRemoteHost() { > - notImplemented(); > - return null; > + return (String)myRemoteHost.getValue(); > + } > + > + public void setupGetRemoteUser(String remoteUser) { > + myRemoteUser.setValue(remoteUser); > } > > public String getRemoteUser() { > - notImplemented(); > - return null; > + return (String)myRemoteUser.getValue(); > } > > public RequestDispatcher getRequestDispatcher( > ----------- > > Third is an implementation of getHeaderNames(). I *think* this > is right, but I'm not totally sure: > > ----------- > Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v > retrieving revision 1.12 > diff -u -3 -p -r1.12 MockHttpServletRequest.java > --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 > +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 15:59:26 -0000 > @@ -117,8 +117,7 @@ public class MockHttpServletRequest exte > } > > public Enumeration getHeaderNames() { > - notImplemented(); > - return null; > + return myHeaders.keys(); > } > > public Enumeration getHeaders(String arg1) { > ----------- > > And finally, I know this is the wrong way to implement getCookies(), > but I'm not sure what the right way is: > > ----------- > Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v > retrieving revision 1.12 > diff -u -3 -p -r1.12 MockHttpServletRequest.java > --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 > +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 16:04:46 -0000 > @@ -44,6 +44,8 @@ public class MockHttpServletRequest exte > private ExpectationList myGetAttributeNames = new ExpectationList("get attribute names"); > private final ReturnValue servletPath = new ReturnValue("servlet path"); > > + private Cookie[] myCookies; > + > public void setupGetAttribute(Object anAttributeToReturn) { > myAttributesToReturn.addObjectToReturn(anAttributeToReturn); > } > @@ -103,9 +105,12 @@ public class MockHttpServletRequest exte > myContextPath = contextPath; > } > > + public void setupGetCookies(Cookie[] cookies){ > + myCookies = cookies; > + } > + > public Cookie[] getCookies() { > - notImplemented(); > - return null; > + return myCookies; > } > > public long getDateHeader(String arg1) { > ----------- > > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev -- Jeff Martin <je...@mk...> |
From: Dave G. <dg...@hy...> - 2003-01-31 16:17:47
|
Here are a few patches for both MockHttpServletResponse and MockHttpServletRequest in src/j2ee/1.3/com/mockobjects/servlet/ The first patch adds support for addCookie() to MockHttpServletResponse: ----------- Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java,v retrieving revision 1.2 diff -u -3 -p -r1.2 MockHttpServletResponse.java --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java 20 Nov 2002 19:08:58 -0000 1.2 +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java 31 Jan 2003 16:13:12 -0000 @@ -14,6 +14,8 @@ public class MockHttpServletResponse ext private final ExpectationList myContentTypes = new ExpectationList("MockHttpServletResponse.setContentType"); + private ExpectationList myCookies = + new ExpectationList("MockHttpServletResponse.addCookie"); private final ExpectationList myHeaders = new ExpectationList("MockHttpServletResponse.setHeader"); private final ExpectationCounter mySetStatusCalls = @@ -32,7 +34,7 @@ public class MockHttpServletResponse ext * Not Implemented */ public void addCookie(Cookie arg1) { - notImplemented(); + myCookies.addActual(arg1); } /** @@ -47,6 +49,10 @@ public class MockHttpServletResponse ext */ public void addHeader(String arg1, String arg2) { notImplemented(); + } + + public void addExpectedCookie(javax.servlet.http.Cookie cookie) { + myCookies.addExpected(cookie); } /** ----------- I broke up the MockHttpServletRequest patch into 4 parts to make it easier to see which bits go together. The first patch is a simple typo fix: ----------- Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.12 diff -u -3 -p -r1.12 MockHttpServletRequest.java --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 15:55:43 -0000 @@ -57,7 +57,7 @@ public class MockHttpServletRequest exte return myAttributesToReturn.nextReturnObject(); } - public void setupGetAttrubuteNames(Vector attributeNames){ + public void setupGetAttributeNames(Vector attributeNames){ myAttributesNames = attributeNames; } ----------- Second, implementations of getAuthType(), getRemoteHost() and getRemoteUser(): ----------- Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.12 diff -u -3 -p -r1.12 MockHttpServletRequest.java --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 15:57:56 -0000 @@ -27,6 +27,9 @@ public class MockHttpServletRequest exte private String myContextPath; private String myPathInfo; private String myRemoteAddress; + private final ReturnValue myAuthType = new ReturnValue("authentication type"); + private final ReturnValue myRemoteHost = new ReturnValue("remote host"); + private final ReturnValue myRemoteUser = new ReturnValue("remote user"); private final ReturnValue myRequestURI = new ReturnValue("request URI"); private final ReturnValue method = new ReturnValue("method"); private final ReturnValue protocol = new ReturnValue("protocol"); @@ -65,9 +68,12 @@ public class MockHttpServletRequest exte return myAttributesNames.elements(); } + public void setupGetAuthType(String authType) { + myAuthType.setValue(authType); + } + public String getAuthType() { - notImplemented(); - return null; + return (String)myAuthType.getValue(); } public String getCharacterEncoding() { @@ -212,14 +218,20 @@ public class MockHttpServletRequest exte return myRemoteAddress; } + public void setupGetRemoteHost(String remoteHost) { + myRemoteHost.setValue(remoteHost); + } + public String getRemoteHost() { - notImplemented(); - return null; + return (String)myRemoteHost.getValue(); + } + + public void setupGetRemoteUser(String remoteUser) { + myRemoteUser.setValue(remoteUser); } public String getRemoteUser() { - notImplemented(); - return null; + return (String)myRemoteUser.getValue(); } public RequestDispatcher getRequestDispatcher( ----------- Third is an implementation of getHeaderNames(). I *think* this is right, but I'm not totally sure: ----------- Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.12 diff -u -3 -p -r1.12 MockHttpServletRequest.java --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 15:59:26 -0000 @@ -117,8 +117,7 @@ public class MockHttpServletRequest exte } public Enumeration getHeaderNames() { - notImplemented(); - return null; + return myHeaders.keys(); } public Enumeration getHeaders(String arg1) { ----------- And finally, I know this is the wrong way to implement getCookies(), but I'm not sure what the right way is: ----------- Index: src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.12 diff -u -3 -p -r1.12 MockHttpServletRequest.java --- src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 +++ src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java 31 Jan 2003 16:04:46 -0000 @@ -44,6 +44,8 @@ public class MockHttpServletRequest exte private ExpectationList myGetAttributeNames = new ExpectationList("get attribute names"); private final ReturnValue servletPath = new ReturnValue("servlet path"); + private Cookie[] myCookies; + public void setupGetAttribute(Object anAttributeToReturn) { myAttributesToReturn.addObjectToReturn(anAttributeToReturn); } @@ -103,9 +105,12 @@ public class MockHttpServletRequest exte myContextPath = contextPath; } + public void setupGetCookies(Cookie[] cookies){ + myCookies = cookies; + } + public Cookie[] getCookies() { - notImplemented(); - return null; + return myCookies; } public long getDateHeader(String arg1) { ----------- |
From: Jeff M. <cus...@us...> - 2003-01-23 13:09:16
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv24006/src/core/test/mockobjects Modified Files: TestReturnObjectBag.java Log Message: Allow the use of null as a key Index: TestReturnObjectBag.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestReturnObjectBag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestReturnObjectBag.java 4 Dec 2002 12:36:37 -0000 1.1 +++ TestReturnObjectBag.java 23 Jan 2003 13:09:13 -0000 1.2 @@ -9,6 +9,8 @@ private final ReturnObjectBag bag = new ReturnObjectBag(getName()); private static final String KEY1 = "key1"; private static final String KEY2 = "key2"; + private static final String VALUE_ONE = "one"; + private static final String VALUE_TWO = "two"; public TestReturnObjectBag(String name) { super(name); @@ -19,7 +21,7 @@ } public void testLeftoverObjectFails() { - bag.putObjectToReturn(KEY1, "one"); + bag.putObjectToReturn(KEY1, VALUE_ONE); assertVerifyFails(bag); } @@ -29,11 +31,11 @@ } public void testReturnSucceeds() { - bag.putObjectToReturn(KEY1, "one"); - bag.putObjectToReturn(KEY2, "two"); + bag.putObjectToReturn(KEY1, VALUE_ONE); + bag.putObjectToReturn(KEY2, VALUE_TWO); - assertEquals("Should be first result", "one", bag.getNextReturnObject(KEY1)); - assertEquals("Should be second result", "two", bag.getNextReturnObject(KEY2)); + assertEquals("Should be first result", VALUE_ONE, bag.getNextReturnObject(KEY1)); + assertEquals("Should be second result", VALUE_TWO, bag.getNextReturnObject(KEY2)); bag.verify(); } @@ -46,8 +48,13 @@ } } + public void testNullKey(){ + bag.putObjectToReturn(null, VALUE_ONE); + assertEquals(VALUE_ONE, bag.getNextReturnObject(null)); + } + public void testTooManyReturns() { - bag.putObjectToReturn(KEY1, "one"); + bag.putObjectToReturn(KEY1, VALUE_ONE); bag.getNextReturnObject(KEY1); try { bag.getNextReturnObject(KEY1); |
From: Jeff M. <cus...@us...> - 2003-01-23 13:09:16
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv24006/src/core/com/mockobjects Modified Files: ReturnObjectBag.java Log Message: Allow the use of null as a key Index: ReturnObjectBag.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ReturnObjectBag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ReturnObjectBag.java 4 Dec 2002 12:36:37 -0000 1.1 +++ ReturnObjectBag.java 23 Jan 2003 13:09:13 -0000 1.2 @@ -3,6 +3,7 @@ import com.mockobjects.ReturnObjectList; import com.mockobjects.Verifiable; import com.mockobjects.util.AssertMo; +import com.mockobjects.util.Null; import java.util.HashMap; import java.util.Iterator; @@ -36,9 +37,12 @@ * @see ReturnObjectList#addObjectToReturn */ public void putObjectToReturn(Object key, Object value) { - ReturnObjectList returnObjectList = (ReturnObjectList)returnObjectLists.get(key); - if(returnObjectList==null){ - returnObjectList = new ReturnObjectList(name+"."+key.toString()); + ReturnObjectList returnObjectList = (ReturnObjectList) returnObjectLists.get(key); + if (key == null) { + key = Null.NULL; + } + if (returnObjectList == null) { + returnObjectList = new ReturnObjectList(name + "." + key.toString()); returnObjectLists.put(key, returnObjectList); } @@ -51,8 +55,8 @@ * @see ReturnObjectList#verify */ public void verify() { - for(Iterator it = returnObjectLists.values().iterator();it.hasNext();){ - ((ReturnObjectList)it.next()).verify(); + for (Iterator it = returnObjectLists.values().iterator(); it.hasNext();) { + ((ReturnObjectList) it.next()).verify(); } } @@ -65,7 +69,10 @@ * @see ReturnObjectList#nextReturnObject */ public Object getNextReturnObject(Object key) { - ReturnObjectList returnObjectList = (ReturnObjectList)returnObjectLists.get(key); + if (key == null) { + key = Null.NULL; + } + ReturnObjectList returnObjectList = (ReturnObjectList) returnObjectLists.get(key); AssertMo.assertNotNull(name + " does not contain " + key.toString(), returnObjectList); return returnObjectList.nextReturnObject(); } |
From: Jeff M. <cus...@us...> - 2003-01-23 12:05:30
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv31262/src/j2ee/common/com/mockobjects/servlet Modified Files: MockJspWriter.java Log Message: Truncate data after verify is called Index: MockJspWriter.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet/MockJspWriter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockJspWriter.java 25 Jun 2002 10:13:12 -0000 1.3 +++ MockJspWriter.java 23 Jan 2003 12:05:27 -0000 1.4 @@ -8,7 +8,7 @@ import java.io.StringWriter; public class MockJspWriter extends JspWriter { - private ExpectationValue expectedData = new ExpectationValue("data"); + private final ExpectationValue expectedData = new ExpectationValue("data"); private StringWriter stringWriter = new StringWriter(); private PrintWriter printWriter = new PrintWriter(stringWriter); @@ -80,8 +80,8 @@ notImplemented(); } - public void write(char[] c, int i1, int i2) { - notImplemented(); + public void write(char[] buf, int off, int len) { + printWriter.write(buf, off, len); } public void println(char[] c) { @@ -133,6 +133,9 @@ printWriter.flush(); expectedData.setActual(stringWriter.toString()); expectedData.verify(); + expectedData.setExpected(""); + stringWriter = new StringWriter(); + printWriter = new PrintWriter(stringWriter); } } |
From: Jeff M. <cus...@us...> - 2003-01-23 11:43:03
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv20683/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpServletRequest.java Log Message: Added support for ServletPath Index: MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- MockHttpServletRequest.java 31 Dec 2002 13:43:01 -0000 1.11 +++ MockHttpServletRequest.java 23 Jan 2003 11:43:00 -0000 1.12 @@ -27,7 +27,7 @@ private String myContextPath; private String myPathInfo; private String myRemoteAddress; - private String myRequestURI; + private final ReturnValue myRequestURI = new ReturnValue("request URI"); private final ReturnValue method = new ReturnValue("method"); private final ReturnValue protocol = new ReturnValue("protocol"); private ServletInputStream myInputStream; @@ -42,7 +42,7 @@ private ReturnObjectList myAttributesToReturn = new ReturnObjectList("attributes"); private ExpectationValue myContentType = new ExpectationValue("content type"); private ExpectationList myGetAttributeNames = new ExpectationList("get attribute names"); - + private final ReturnValue servletPath = new ReturnValue("servlet path"); public void setupGetAttribute(Object anAttributeToReturn) { myAttributesToReturn.addObjectToReturn(anAttributeToReturn); @@ -51,7 +51,7 @@ public void addExpectedGetAttributeName(String anAttributeName) { myGetAttributeNames.addExpected(anAttributeName); } - + public Object getAttribute(String anAttributeName) { myGetAttributeNames.addActual(anAttributeName); return myAttributesToReturn.nextReturnObject(); @@ -60,7 +60,7 @@ public void setupGetAttrubuteNames(Vector attributeNames){ myAttributesNames = attributeNames; } - + public Enumeration getAttributeNames() { return myAttributesNames.elements(); } @@ -234,11 +234,11 @@ } public void setupGetRequestURI(String aRequestURI) { - myRequestURI = aRequestURI; + myRequestURI.setValue(aRequestURI); } public String getRequestURI() { - return myRequestURI; + return (String)myRequestURI.getValue(); } public String getScheme() { @@ -253,9 +253,12 @@ return 0; } + public void setupGetServletPath(String path){ + this.servletPath.setValue(path); + } + public String getServletPath() { - notImplemented(); - return null; + return (String)servletPath.getValue(); } public HttpSession getSession() { |
From: Vincent M. <vm...@us...> - 2003-01-21 15:44:29
|
Update of /cvsroot/mockobjects/mockobjects-java In directory sc8-pr-cvs1:/tmp/cvs-serv3740 Added Files: .cvsignore Log Message: Added needed ignore files (i.e. files that must not in CVS) |
From: Vincent M. <vm...@us...> - 2003-01-21 15:43:56
|
Update of /cvsroot/mockobjects/mockobjects-java/lib In directory sc8-pr-cvs1:/tmp/cvs-serv3498/lib Added Files: .cvsignore Log Message: Ignore jar files (they should not be in CVS) --- NEW FILE: .cvsignore --- *.jar |
From: <has...@jp...> - 2003-01-21 10:22:34
|
Jeff In the Sybase/etc JDBC implementations of this code, the number of times you call getColumnType etc, is not significant. I can understand the callls to rs.next() etc being significant, but why must the call-count to the above be important? (For this matter the call-count to getColumnName should not be significant either). Also, at the moment we have to setup our result set with our expected data and column names, then we have to set up our meta data seperately. String[] columnNames = TRADE_DATA.getColumnNames(); singleRowResultSet.addExpectedNamedValues( columnNames, TRADE_DATA.getColumnValues()); // setup result set meta data resultSetMetaData.setupColumns(columnNames, TRADE_DATA.getColumnTypes ()); singleRowResultSet.setupMetaData(mockDbAccess.resultSetMetaData); Would it not be better if these were setup together? i.e create some sort of factory which we supply the column names, types and a set of values and it creates and returns an appropriate result set. We could then have the option to change the data in the result set but the column types and names would be fixed... p.s Im new to mock objects, so If im missing something obvious, please accept my apologies! Haseeb |---------+----------------------------> | | je...@mk... | | | | | | 01/21/2003 10:04 | | | AM | | | | |---------+----------------------------> >----------------------------------------------------------------------------------------------------------------------| | | | To: moc...@li... | | cc: has...@jp... | | Subject: Re: Mock Objects - | >----------------------------------------------------------------------------------------------------------------------| The point of this is so you can know how many times a piece of content is requested. As far as I'm concerned the difference between getColumnType(0); and getColumnType(0); getColumnType(0); getColumnType(0); getColumnType(0); is significant. This is why the ReturnObjectList was used. This means that the exact number of objects to be returned need to be inserted into the ReturnObjectList in the order in which they will be requested. However it maybe more appropriate to use the ReturnObjectBag as this allows the key value to be taken into consideration. The previous example would still be significant but the difference between getColumnType(0); getColumnType(1); and getColumnType(1); getColumnType(0); would not be significant. You would still need to load in the correct number of objects for each key value though. e.g. setupGetColumnType(0, "value"); getColumnType(0); getColumnType(0); would fail setupGetColumnType(0, "value"); setupGetColumnType(0, "value"); getColumnType(0); getColumnType(0); would be successful. If this sounds okay I can make the change. On Mon, 2003-01-20 at 23:22, Steve Freeman wrote: > Sounds like it shouldn't. Jeff, do you want to take this one? > > Steve > > has...@jp... wrote: > > Hi > > > > I encountered a problem with the MockResultSetMetaData code in 0.7. > > I viewed the archive and saw a similar problem reported by Vincent Massoul > > but I coundlt find out if it was fixed or not: > > > > http://sourceforge.net/mailarchive/message.php?msg_id=2702964 > > > > Heres the problem... > > > > The implementation of the method > > > > getColumnType(i); in the CommonMockResultSetMetaData class > > > > does not match that provided by the 3rdy party driver providers e.g Sybase > > - jconnect52. > > > > It removes the column type from the underlying vector, so multiple calls to > > getColumnType(i), > > in effect run down the vector (ReturnObjectList). > > (The code that im writing tests for calls this method more than once for > > the same column, hence the problem!). > > > > This shouldnt happen, should it? > > > > Haseeb Asghar > > > > > > > > > > > > > > > > > > > > > > public abstract class CommonMockResultSetMetaData extends MockObject > > implements ResultSetMetaData { > > /** > > * 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(); > > } > > > > > > > > public class ReturnObjectList implements Verifiable { > > /** > > * Returns the next object from the list. Each object it returned in > > the > > * order in which they where added. > > */ > > public Object nextReturnObject(){ > > AssertMo.assertTrue(myName + " has run out of objects.", > > myObjects.size() > 0); > > return myObjects.remove(0); > > } > > > > > > This communication is for informational purposes only. It is not intended as > > an offer or solicitation for the purchase or sale of any financial instrument > > or as an official confirmation of any transaction. All market prices, data > > and other information are not warranted as to completeness or accuracy and > > are subject to change without notice. Any comments or statements made herein > > do not necessarily reflect those of J.P. Morgan Chase & Co., its > > subsidiaries and affiliates. > > -- Jeff Martin <je...@mk...> This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of J.P. Morgan Chase & Co., its subsidiaries and affiliates. |
From: Jeff M. <je...@mk...> - 2003-01-21 10:04:20
|
The point of this is so you can know how many times a piece of content is requested. As far as I'm concerned the difference between getColumnType(0); and getColumnType(0); getColumnType(0); getColumnType(0); getColumnType(0); is significant. This is why the ReturnObjectList was used. This means that the exact number of objects to be returned need to be inserted into the ReturnObjectList in the order in which they will be requested. However it maybe more appropriate to use the ReturnObjectBag as this allows the key value to be taken into consideration. The previous example would still be significant but the difference between getColumnType(0); getColumnType(1); and getColumnType(1); getColumnType(0); would not be significant. You would still need to load in the correct number of objects for each key value though. e.g. setupGetColumnType(0, "value"); getColumnType(0); getColumnType(0); would fail setupGetColumnType(0, "value"); setupGetColumnType(0, "value"); getColumnType(0); getColumnType(0); would be successful. If this sounds okay I can make the change. On Mon, 2003-01-20 at 23:22, Steve Freeman wrote: > Sounds like it shouldn't. Jeff, do you want to take this one? > > Steve > > has...@jp... wrote: > > Hi > > > > I encountered a problem with the MockResultSetMetaData code in 0.7. > > I viewed the archive and saw a similar problem reported by Vincent Massoul > > but I coundlt find out if it was fixed or not: > > > > http://sourceforge.net/mailarchive/message.php?msg_id=2702964 > > > > Heres the problem... > > > > The implementation of the method > > > > getColumnType(i); in the CommonMockResultSetMetaData class > > > > does not match that provided by the 3rdy party driver providers e.g Sybase > > - jconnect52. > > > > It removes the column type from the underlying vector, so multiple calls to > > getColumnType(i), > > in effect run down the vector (ReturnObjectList). > > (The code that im writing tests for calls this method more than once for > > the same column, hence the problem!). > > > > This shouldnt happen, should it? > > > > Haseeb Asghar > > > > > > > > > > > > > > > > > > > > > > public abstract class CommonMockResultSetMetaData extends MockObject > > implements ResultSetMetaData { > > /** > > * 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(); > > } > > > > > > > > public class ReturnObjectList implements Verifiable { > > /** > > * Returns the next object from the list. Each object it returned in > > the > > * order in which they where added. > > */ > > public Object nextReturnObject(){ > > AssertMo.assertTrue(myName + " has run out of objects.", > > myObjects.size() > 0); > > return myObjects.remove(0); > > } > > > > > > This communication is for informational purposes only. It is not intended as > > an offer or solicitation for the purchase or sale of any financial instrument > > or as an official confirmation of any transaction. All market prices, data > > and other information are not warranted as to completeness or accuracy and > > are subject to change without notice. Any comments or statements made herein > > do not necessarily reflect those of J.P. Morgan Chase & Co., its > > subsidiaries and affiliates. > > -- Jeff Martin <je...@mk...> |
From: Jeff M. <je...@mk...> - 2003-01-17 17:51:23
|
Ta kid that's in. On Fri, 2003-01-17 at 16:27, Griffin Caprio wrote: > I noticed that there was no MockCallableStatement for > testing using Stored Procedures. Attached is a bare > bones implementation. One is the common > CallableStatement across all jdk's, and the other is > the one for JDK 1.4, which we use. Most of the things > are not implemented, but it does work fine for us. > > Thanks, > -Griffin > > ===== > Griffin Caprio > "Your child against mine. The winner > will be hailed, the loser will be booed > until my throat hurts!" - Homer Simpson to Marge > > __________________________________________________ > Do you Yahoo!? > Yahoo! Mail Plus - Powerful. Affordable. Sign up now. > http://mailplus.yahoo.com -- Jeff Martin <je...@mk...> |
From: Jeff M. <cus...@us...> - 2003-01-17 17:11:54
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql In directory sc8-pr-cvs1:/tmp/cvs-serv32519/src/jdk/common/com/mockobjects/sql Added Files: CommonMockCallableStatement.java Log Message: Basic implementation of CallableStatement from Griffin Caprio --- NEW FILE: CommonMockCallableStatement.java --- /* * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ // ------------------------------------------------------------------------ 78 package com.mockobjects.sql; import java.sql.*; import java.util.Calendar; import java.io.Reader; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import com.mockobjects.*; abstract class CommonMockCallableStatement extends CommonMockPreparedStatement implements CallableStatement { public void registerOutParameter(int parameterIndex, int sqlType) { notImplemented(); } public void registerOutParameter(int parameterIndex, int sqlType, int scale) { notImplemented(); } public void registerOutParameter(int parameterIndex, int sqlType, String typeName) { notImplemented(); } public void registerOutParameter(String parameterName, int sqlType) { notImplemented(); } public void registerOutParameter(String parameterName, int sqlType, int scale) { notImplemented(); } public void registerOutParameter(String parameterName, int sqlType, String typeName) { notImplemented(); } public boolean wasNull() { notImplemented(); return false; } public String getString(int parameterIndex) { notImplemented(); return null; } public String getString(String parameterName) { notImplemented(); return null; } public boolean getBoolean(int parameterIndex) { notImplemented(); return false; } public boolean getBoolean(String parameterName) { notImplemented(); return false; } public byte getByte(int parameterIndex) { notImplemented(); return 0; } public byte getByte(String parameterName) { notImplemented(); return 0; } public short getShort(int parameterIndex) { notImplemented(); return 0; } public short getShort(String parameterName) { notImplemented(); return 0; } public int getInt(int parameterIndex) { notImplemented(); return 0; } public int getInt(String parameterName) { notImplemented(); return 0; } public long getLong(int parameterIndex) { notImplemented(); return 0; } public long getLong(String parameterName) { notImplemented(); return 0; } public float getFloat(int parameterIndex) { notImplemented(); return 0; } public float getFloat(String parameterName) { notImplemented(); return 0; } public double getDouble(int parameterIndex) { notImplemented(); return 0; } public double getDouble(String parameterName) { notImplemented(); return 0; } public BigDecimal getBigDecimal(int parameterIndex) { notImplemented(); return null; } public BigDecimal getBigDecimal(String parameterName) { notImplemented(); return null; } public BigDecimal getBigDecimal(int parameterIndex, int scale) { notImplemented(); return null; } public byte[] getBytes(int parameterIndex) { notImplemented(); return null; } public byte[] getBytes(String parameterName) { notImplemented(); return null; } public Date getDate(int parameterIndex) { notImplemented(); return null; } public Date getDate(String parameterName) { notImplemented(); return null; } public Date getDate(int parameterIndex, Calendar cal) { notImplemented(); return null; } public Date getDate(String parameterName, Calendar cal) { notImplemented(); return null; } public Time getTime(int parameterIndex) { notImplemented(); return null; } public Time getTime(String parameterName) { notImplemented(); return null; } public Time getTime(int parameterIndex, Calendar cal) { notImplemented(); return null; } public Time getTime(String parameterName, Calendar cal) { notImplemented(); return null; } public Timestamp getTimestamp(int parameterIndex) { notImplemented(); return null; } public Timestamp getTimestamp(String parameterName) { notImplemented(); return null; } public Timestamp getTimestamp(int parameterIndex, Calendar cal) { notImplemented(); return null; } public Timestamp getTimestamp(String parameterName, Calendar cal) { notImplemented(); return null; } public Object getObject(int parameterIndex) { notImplemented(); return null; } public Object getObject(String parameterName) { notImplemented(); return null; } public Object getObject(int parameterIndex, java.util.Map map) { notImplemented(); return null; } public Object getObject(String parameterName, java.util.Map map) { notImplemented(); return null; } public Ref getRef(int parameterIndex) { notImplemented(); return null; } public Ref getRef(String parameterName) { notImplemented(); return null; } public Blob getBlob(int parameterIndex) { notImplemented(); return null; } public Blob getBlob(String parameterName) { notImplemented(); return null; } public Clob getClob(int parameterIndex) { notImplemented(); return null; } public Clob getClob(String parameterName) { notImplemented(); return null; } public Array getArray(int parameterIndex) { notImplemented(); return null; } public Array getArray(String parameterName) { notImplemented(); return null; } public URL getURL(int parameterIndex) { notImplemented(); return null; } public URL getURL(String parameterName) { notImplemented(); return null; } public void setAsciiStream(String parameterName, InputStream x, int length) { notImplemented(); } public void setBigDecimal(String parameterName, BigDecimal x) { notImplemented(); } public void setBinaryStream(String parameterName, InputStream x, int length) { notImplemented(); } public void setBoolean(String parameterName, boolean x) { notImplemented(); } public void setByte(String parameterName, byte x) { notImplemented(); } public void setBytes(String parameterName, byte[] x) { notImplemented(); } public void setCharacterStream(String parameterName, Reader reader, int length) { notImplemented(); } public void setDate(String parameterName, Date x) { notImplemented(); } public void setDate(String parameterName, Date x, Calendar cal) { notImplemented(); } public void setDouble(String parameterName, double x) { notImplemented(); } public void setFloat(String parameterName, float x) { notImplemented(); } public void setInt(String parameterName, int x) { notImplemented(); } public void setLong(String parameterName, long x) { notImplemented(); } public void setNull(String parameterName, int sqlType) { notImplemented(); } public void setNull(String parameterName, int sqlType, String typeName) { notImplemented(); } public void setObject(String parameterName, Object x) { notImplemented(); } public void setObject(String parameterName, Object x, int targetSqlType) { notImplemented(); } public void setObject(String parameterName, Object x, int targetSqlType, int scale) { notImplemented(); } public void setShort(String parameterName, short x) { notImplemented(); } public void setString(String parameterName, String x) { notImplemented(); } public void setTime(String parameterName, Time x) { notImplemented(); } public void setTime(String parameterName, Time x, Calendar cal) { notImplemented(); } public void setTimestamp(String parameterName, Timestamp x) { notImplemented(); } public void setTimestamp(String parameterName, Timestamp x, Calendar cal) { notImplemented(); } public void setURL(String parameterName, URL val) { notImplemented(); } } |
From: Jeff M. <cus...@us...> - 2003-01-17 17:11:53
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/1.4/com/mockobjects/sql In directory sc8-pr-cvs1:/tmp/cvs-serv32519/src/jdk/1.4/com/mockobjects/sql Added Files: MockCallableStatement.java Log Message: Basic implementation of CallableStatement from Griffin Caprio --- NEW FILE: MockCallableStatement.java --- package com.mockobjects.sql; import java.sql.SQLException; import java.sql.ResultSet; import java.sql.ParameterMetaData; import java.net.URL; public class MockCallableStatement extends CommonMockCallableStatement { public void setURL(int parameterIndex, URL val) { notImplemented(); } public ParameterMetaData getParameterMetaData() throws SQLException { notImplemented(); return null; } public boolean getMoreResults(int current) throws SQLException { notImplemented(); return false; } public ResultSet getGeneratedKeys() throws SQLException { notImplemented(); return null; } public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { notImplemented(); return 0; } public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { notImplemented(); return 0; } public int executeUpdate(String sql, String[] columnNames) throws SQLException { notImplemented(); return 0; } public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { notImplemented(); return false; } public boolean execute(String sql, int[] columnIndexes) throws SQLException { notImplemented(); return false; } public boolean execute(String sql, String[] columnNames) throws SQLException { notImplemented(); return false; } public int getResultSetHoldability() throws SQLException { notImplemented(); return 0; } } |
From: Jeff M. <cus...@us...> - 2003-01-17 17:10:37
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory sc8-pr-cvs1:/tmp/cvs-serv32150/src/jdk/common/com/mockobjects/io Modified Files: MockIOFactory.java Log Message: Change MockIOFactory to use bags for streams Index: MockIOFactory.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockIOFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockIOFactory.java 2 Jan 2003 16:04:31 -0000 1.1 +++ MockIOFactory.java 17 Jan 2003 17:10:33 -0000 1.2 @@ -5,40 +5,33 @@ import com.mockobjects.ExpectationValue; import com.mockobjects.MockObject; import com.mockobjects.ReturnValue; +import com.mockobjects.ReturnObjectBag; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.OutputStream; public class MockIOFactory extends MockObject implements IOFactory { - private final ExpectationValue myFile = new ExpectationValue("file"); - private final ReturnValue inputStream = new ReturnValue("input stream"); - private final ReturnValue outputStream = new ReturnValue("output stream"); + private final ReturnObjectBag inputStream = new ReturnObjectBag("input stream"); + private final ReturnObjectBag outputStream = new ReturnObjectBag("output stream"); private final ReturnValue file = new ReturnValue("file"); private final ExpectationValue fileName = new ExpectationValue("file name"); - public void setExpectedFile(File aFile) { - myFile.setExpected(aFile); - } - - public void setupInputStream(InputStream inputStream) { - this.inputStream.setValue(inputStream); + public void setupInputStream(File expectedFile, InputStream returnStream) { + this.inputStream.putObjectToReturn(expectedFile, returnStream); } public InputStream createInputStream(File aFile) throws FileNotFoundException { - myFile.setActual(aFile); - - return (InputStream)inputStream.getValue(); + return (InputStream)inputStream.getNextReturnObject(aFile); } - public void setupOutputStream(OutputStream outputStream) { - this.outputStream.setValue(outputStream); + public void setupOutputStream(File expectedFile, OutputStream returnStream) { + this.outputStream.putObjectToReturn(expectedFile, outputStream); } public OutputStream createOutputStream(File aFile) throws FileNotFoundException { - myFile.setActual(aFile); - return (OutputStream)outputStream.getValue(); + return (OutputStream)outputStream.getNextReturnObject(aFile); } public void setupCreateFile(File file) { @@ -53,5 +46,4 @@ this.fileName.setActual(fileName); return (File)file.getValue(); } - } |
From: Griffin C. <gri...@ya...> - 2003-01-17 16:27:52
|
I noticed that there was no MockCallableStatement for testing using Stored Procedures. Attached is a bare bones implementation. One is the common CallableStatement across all jdk's, and the other is the one for JDK 1.4, which we use. Most of the things are not implemented, but it does work fine for us. Thanks, -Griffin ===== Griffin Caprio "Your child against mine. The winner will be hailed, the loser will be booed until my throat hurts!" - Homer Simpson to Marge __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com |
From: Griffin C. <gri...@ya...> - 2003-01-13 14:40:00
|
This is to announce that .NET Mock Objects library, version 0.3, has been release. New in this release: - Fully implemented IDataRead Mock Objects, which completes the implementation of the System.Data core classes. - Added a re-write of the MailingList example that comes with the mockobjects-java package - Cleaned up the XML documentation and API docs - Other, minor refactorings Link to release notes and change log here: https://sourceforge.net/project/shownotes.php?group_id=54948&release_id=133345 -Griffin ===== Griffin Caprio "Your child against mine. The winner will be hailed, the loser will be booed until my throat hurts!" - Homer Simpson to Marge __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com |
From: Vincent M. <vm...@us...> - 2003-01-13 13:46:59
|
Update of /cvsroot/mockobjects/mockobjects-java In directory sc8-pr-cvs1:/tmp/cvs-serv6884 Modified Files: build.xml Log Message: Current version is 0.08 dev. 0.07 has already been released. Index: build.xml =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/build.xml,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- build.xml 3 Nov 2002 15:18:06 -0000 1.30 +++ build.xml 13 Jan 2003 13:46:56 -0000 1.31 @@ -18,7 +18,7 @@ <target name="project-properties"> <property name="project.fullname" value="Mock Objects" /> - <property name="project.version" value="0.07" /> + <property name="project.version" value="0.08dev" /> <property name="project.name" value="mockobjects" /> <property name="year" value="2002" /> <property name="debug" value="on" /> |