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: denis k. <den...@ma...> - 2002-09-19 05:34:38
|
Hi - is there a way to get a method to raise an exception in a mockobject? But then, should I be doing this? should I be trying to test the exception handling code I've written? regards, dk- |
From: Tim M. <tim...@po...> - 2002-09-17 23:12:22
|
A deferred exception class sounds like an excellent generic Mock thing on par with expectation lists etc. A nice simple idea - make sure it has a name and error message that clearly indicate the failure (and that its a mock) and bobs your uncle! There are probably other things like this that we have missed and should be spotting. Tim -----Original Message----- From: moc...@li... [mailto:moc...@li...]On Behalf Of Simon Levitt Sent: 16 September 2002 17:24 To: moc...@li... Subject: [MO-java-dev] com.mockobjects.sql review. As part of my role to evaluate/develop the MockObjects SQL functionality I've re-worked some of the classes in order to satisfy the testing requirements we'd like to meet. I've also been looking at them in order to implement a MockCallableStatement (Not yet done). I'd like to present my current set of changes back to the group for comments and/or inclusion into the codebase. They are as follows: - ExpectationMap & ReturnObjectList - methods to enable and perform the verify()cation of objects contained therein. Default to original functionality. - ReturnObjectList keeps its list of objects to allow above. - CommonMockConnection - method to allow the automated checking of associated PreparedStatements. - Automatically associates Statements with Connection on return. - CommonMockStatement: - INTERFACE CHANGE: setExpectedQueryString now makes given query the only one on the object. addExpectedQueryString allows more to be added. Did this for constancy more than anything. - setupResultSet/setupAddResultSet used to set/add ResultSets to the connection. - addResultSet deprecated (in favour to setupAddResultSet(). - An update count is treated the same as a normal ResultSet - more closely follows the java.jdbc specification (eg. a Statement result is either a ResultSet or an update count). The query counts are queued with the ResultSets for retrieval after execute calls. - Automatically associates ResultSets with the Statement on return. - method to allow the automated checking of associated ResultSets. ResultSets (in general) - CommonMockResult created in jdk/common that defines single a ResultSet interface that supports single & multi row result sets. - Allows the verification/expectation checking of row data retrieval from all rows (not just the first). - Each jdk/<version>/com/mockobjects/sql now defines a single MockResultSet that allows the definition of JDK specific additional methods/interfaces that may be required. MockResultSet removed from jdk/common. Now uses a similar model to Connection and Statement. - MockSingleRowResultSet & MockMultiRowResultSet objects/interfaces retained for backwards compatibility (moved into jdk/common - extends MockResultSet defined in jdk/<version>)). Both removed from jdk/<version> trees. MockMultiRowResultSet basically just defines a single deprecated method from its original interface (MockResultSet defines the rest). - MockUpdateResultSet added for update count support (extends MockSingleRowResultSet). - POTENTIAL issue: These changes add a requirement that jdk/common/com/mockobjects/sql needs a jdk/<version> derived MockResultSet in order to compile. (Doesn't break ant build though). - Can now set/add to the row name mappings and rows returned. MockSingleRowResultSet allows setting/adding of individual elements within the row. - If name mapping supplied, can use name and/or index to access row data. (Name mapping currently needs to be supplied before data to work correctly). - Automatically associates ResultSet with Statement on return. - method to allow the automated checking of Row expectations. Given that there is a fair bit of class movement in these changes how should supply these (a cvs diff -u doesn't cope with new/deleted files). Perhaps a CVS branch where I could commit these to? Other things I'd like to do: - Develop a DeferredException class that causes an exception to be thrown after a certain number of events has occured (eg. throws an SQLException on the third call to next() on a ResultSet) - Add mechanism for specifying a particular value on a row shouldn't be retrieved (code may be retrieving different columns depending on data it find in others). - Add support for Statements that return Multiple resultSets on one execution. (Not that high a priority). Cheers, Simon., -- -------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 ------------------------- http://www.worldpay.com/ ----------------------- ------------------------------------------------------- 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.384 / Virus Database: 216 - Release Date: 21/08/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.389 / Virus Database: 220 - Release Date: 16/09/2002 |
From: Jeff M. <je...@mk...> - 2002-09-17 15:09:44
|
One at a time would be my preferred method. If you can chuck us patches for some of the simpler atomic changes we'll work up to the bigger moving files around stuff. What everyone needs to remember is that I've only got a really small head and I can't cope with more than one or two changes at a time. On Mon, 2002-09-16 at 17:23, Simon Levitt wrote: > As part of my role to evaluate/develop the MockObjects SQL functionality > I've re-worked some of the classes in order to satisfy the testing > requirements we'd like to meet. > > I've also been looking at them in order to implement a > MockCallableStatement (Not yet done). > > I'd like to present my current set of changes back to the group for > comments and/or inclusion into the codebase. > > They are as follows: > > - ExpectationMap & ReturnObjectList > - methods to enable and perform the verify()cation of objects > contained therein. Default to original functionality. > - ReturnObjectList keeps its list of objects to allow above. > > - CommonMockConnection > - method to allow the automated checking of associated > PreparedStatements. > - Automatically associates Statements with Connection on return. > > - CommonMockStatement: > - INTERFACE CHANGE: setExpectedQueryString now makes given query the > only one on the object. addExpectedQueryString allows more to be > added. Did this for constancy more than anything. > - setupResultSet/setupAddResultSet used to set/add ResultSets to the > connection. > - addResultSet deprecated (in favour to setupAddResultSet(). > - An update count is treated the same as a normal ResultSet - more > closely follows the java.jdbc specification (eg. a Statement result > is either a ResultSet or an update count). > The query counts are queued with the ResultSets for retrieval after > execute calls. > - Automatically associates ResultSets with the Statement on return. > - method to allow the automated checking of associated ResultSets. > > ResultSets (in general) > - CommonMockResult created in jdk/common that defines single a > ResultSet interface that supports single & multi row result sets. > - Allows the verification/expectation checking of row data retrieval > from all rows (not just the first). > - Each jdk/<version>/com/mockobjects/sql now defines a single > MockResultSet that allows the definition of JDK specific additional > methods/interfaces that may be required. MockResultSet removed from > jdk/common. Now uses a similar model to Connection and Statement. > - MockSingleRowResultSet & MockMultiRowResultSet objects/interfaces > retained for backwards compatibility (moved into jdk/common - > extends MockResultSet defined in jdk/<version>)). Both removed > from jdk/<version> trees. > MockMultiRowResultSet basically just defines a single deprecated > method from its original interface (MockResultSet defines the rest). > - MockUpdateResultSet added for update count support (extends > MockSingleRowResultSet). > - POTENTIAL issue: These changes add a requirement that > jdk/common/com/mockobjects/sql needs a jdk/<version> derived > MockResultSet in order to compile. (Doesn't break ant build though). > - Can now set/add to the row name mappings and rows returned. > MockSingleRowResultSet allows setting/adding of individual elements > within the row. > - If name mapping supplied, can use name and/or index to access row > data. (Name mapping currently needs to be supplied before data to > work correctly). > - Automatically associates ResultSet with Statement on return. > - method to allow the automated checking of Row expectations. > > Given that there is a fair bit of class movement in these changes how > should supply these (a cvs diff -u doesn't cope with new/deleted files). > > Perhaps a CVS branch where I could commit these to? > > Other things I'd like to do: > > - Develop a DeferredException class that causes an exception to be > thrown after a certain number of events has occured (eg. throws an > SQLException on the third call to next() on a ResultSet) > - Add mechanism for specifying a particular value on a row shouldn't be > retrieved (code may be retrieving different columns depending on data > it find in others). > - Add support for Statements that return Multiple resultSets on one > execution. (Not that high a priority). > > Cheers, > > Simon., > -- > -------------------------------------------------------------------------- > Simon Levitt, Senior Development Engineer @ WorldPay plc, > WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND > Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 > ------------------------- http://www.worldpay.com/ ----------------------- > > > > ------------------------------------------------------- > 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 -- 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: Jeff M. <je...@mk...> - 2002-09-17 15:06:19
|
Looks like today's your lucky day. Can't get my head around proper work to day so please enjoy your new found functionality. It hope it brings you many hours of joy in the years to come. On Tue, 2002-09-17 at 07:23, denis krizanovic wrote: > > So, I'm playing with MockContext, and I get a "NotImplementedException" > when I call the createSubContext(string name) method. Low and behold, > this method has not been implemented. > > Who implements this? When can I expect an implementation? > > regards, > dk- > > > > > > > ------------------------------------------------------- > Sponsored by: AMD - Your access to the experts on Hammer Technology! > Open Source & Linux Developers, register now for the AMD Developer > Symposium. Code: EX8664 http://www.developwithamd.com/developerlab > _______________________________________________ > 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: Jeff M. <cus...@us...> - 2002-09-17 15:04:40
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/naming In directory usw-pr-cvs1:/tmp/cvs-serv16812/src/j2ee/common/com/mockobjects/naming Modified Files: MockContext.java Log Message: Added support for createSubContext(string name) Index: MockContext.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/naming/MockContext.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockContext.java 22 Apr 2002 16:43:32 -0000 1.2 +++ MockContext.java 17 Sep 2002 15:04:36 -0000 1.3 @@ -1,12 +1,19 @@ package com.mockobjects.naming; -import com.mockobjects.*; -import java.util.Vector; +import com.mockobjects.ExpectationList; +import com.mockobjects.ExpectationValue; +import com.mockobjects.MockObject; +import com.mockobjects.ReturnObjectList; + import javax.naming.*; -public class MockContext extends MockObject implements Context{ +public class MockContext extends MockObject implements Context { private final ReturnObjectList myLookupObjects = new ReturnObjectList("lookups"); + private final ReturnObjectList mySubContexts = + new ReturnObjectList("sub contexts"); + private ExpectationList mySubContextNames = new ExpectationList( + MockContext.class.getName() + "sub context name"); private ExpectationValue myBindName = new ExpectationValue( MockContext.class.getName() + "myBindName"); private ExpectationValue myBindObject = new ExpectationValue( @@ -16,158 +23,166 @@ private ExpectationValue myLookupName = new ExpectationValue( MockContext.class.getName() + "myLookupName"); - public void setupAddLookup(Object aObjectToReturn){ + public void setupAddLookup(Object aObjectToReturn) { this.myLookupObjects.addObjectToReturn(aObjectToReturn); } - public void setExpectedLookupName(String aLookupName){ + public void setExpectedLookupName(String aLookupName) { this.myLookupName.setExpected(aLookupName); } - public Object lookup(Name name) throws NamingException{ + public Object lookup(Name name) throws NamingException { this.myLookupName.setActual(name); return myLookupObjects.nextReturnObject(); } - public Object lookup(String name) throws NamingException{ + public Object lookup(String name) throws NamingException { this.myLookupName.setActual(name); return myLookupObjects.nextReturnObject(); } - public void bind(Name aBindName, Object aBindObject) throws NamingException{ + public void bind(Name aBindName, Object aBindObject) throws NamingException { this.myBindName.setExpected(aBindName); this.myBindObject.setExpected(aBindObject); } - public void setExpectedBind(String aBindName, Object aBindObject){ + public void setExpectedBind(String aBindName, Object aBindObject) { this.myBindName.setExpected(aBindName); this.myBindObject.setExpected(aBindObject); } - public void setExpectedReBind(String aBindName, Object aBindObject){ + public void setExpectedReBind(String aBindName, Object aBindObject) { this.myRebindName.setExpected(aBindName); this.myRebindName.setExpected(aBindObject); } - public void bind(String aBindName, Object aBindObject) throws NamingException{ + public void bind(String aBindName, Object aBindObject) throws NamingException { this.myBindName.setActual(aBindName); this.myBindObject.setActual(aBindObject); } - public void rebind(Name aBindName, Object aBindObject) throws NamingException{ + public void rebind(Name aBindName, Object aBindObject) throws NamingException { this.myRebindName.setActual(aBindName); this.myRebindName.setActual(aBindObject); } - public void rebind(String aBindName, Object aBindObject) throws NamingException{ + public void rebind(String aBindName, Object aBindObject) throws NamingException { this.myRebindName.setActual(aBindName); this.myRebindName.setActual(aBindObject); } - public void unbind(Name name) throws NamingException{ + public void unbind(Name name) throws NamingException { notImplemented(); } - public void unbind(String name) throws NamingException{ + public void unbind(String name) throws NamingException { notImplemented(); } - public void rename(Name name, Name name2) throws NamingException{ + public void rename(Name name, Name name2) throws NamingException { notImplemented(); } - public void rename(String name, String name2) throws NamingException{ + public void rename(String name, String name2) throws NamingException { notImplemented(); } - public NamingEnumeration list(Name name) throws NamingException{ + public NamingEnumeration list(Name name) throws NamingException { notImplemented(); return null; } - public NamingEnumeration list(String name) throws NamingException{ + public NamingEnumeration list(String name) throws NamingException { notImplemented(); return null; } - public NamingEnumeration listBindings(Name name) throws NamingException{ + public NamingEnumeration listBindings(Name name) throws NamingException { notImplemented(); return null; } - public NamingEnumeration listBindings(String name) throws NamingException{ + public NamingEnumeration listBindings(String name) throws NamingException { notImplemented(); return null; } - public void destroySubcontext(Name name) throws NamingException{ + public void destroySubcontext(Name name) throws NamingException { notImplemented(); } - public void destroySubcontext(String name) throws NamingException{ + public void destroySubcontext(String name) throws NamingException { notImplemented(); } - public Context createSubcontext(Name name) throws NamingException{ + public Context createSubcontext(Name name) throws NamingException { notImplemented(); return null; } - public Context createSubcontext(String name) throws NamingException{ - notImplemented(); - return null; + public void setupAddCreateSubContext(Context aContext){ + mySubContexts.addObjectToReturn(aContext); + } + + public void setExpectedCreateSubContext(String name){ + this.mySubContextNames.addExpected(name); + } + + public Context createSubcontext(String name) throws NamingException { + mySubContextNames.addActual(name); + return (Context) mySubContexts.nextReturnObject(); } - public Object lookupLink(Name name) throws NamingException{ + public Object lookupLink(Name name) throws NamingException { notImplemented(); return null; } - public Object lookupLink(String name) throws NamingException{ + public Object lookupLink(String name) throws NamingException { notImplemented(); return null; } - public NameParser getNameParser(Name name) throws NamingException{ + public NameParser getNameParser(Name name) throws NamingException { notImplemented(); return null; } - public NameParser getNameParser(String name) throws NamingException{ + public NameParser getNameParser(String name) throws NamingException { notImplemented(); return null; } - public Name composeName(Name name, Name name2) throws NamingException{ + public Name composeName(Name name, Name name2) throws NamingException { notImplemented(); return null; } - public String composeName(String name, String name2) throws NamingException{ + public String composeName(String name, String name2) throws NamingException { notImplemented(); return null; } - public Object addToEnvironment(String name, Object object) throws NamingException{ + public Object addToEnvironment(String name, Object object) throws NamingException { notImplemented(); return null; } - public Object removeFromEnvironment(String name) throws NamingException{ + public Object removeFromEnvironment(String name) throws NamingException { notImplemented(); return null; } - public java.util.Hashtable getEnvironment() throws NamingException{ + public java.util.Hashtable getEnvironment() throws NamingException { notImplemented(); return null; } - public void close() throws NamingException{ + public void close() throws NamingException { notImplemented(); } - public String getNameInNamespace() throws NamingException{ + public String getNameInNamespace() throws NamingException { notImplemented(); return null; } |
From: Jeff M. <cus...@us...> - 2002-09-17 14:51:14
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test In directory usw-pr-cvs1:/tmp/cvs-serv3720/src/core/com/mockobjects/test Modified Files: TestVerifier.java Log Message: Added code from Simon Levitt <sim...@uk...> to stop verify going into to a recursive loop Index: TestVerifier.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test/TestVerifier.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestVerifier.java 29 Jul 2001 19:50:24 -0000 1.1 +++ TestVerifier.java 17 Sep 2002 14:51:11 -0000 1.2 @@ -1,11 +1,16 @@ package com.mockobjects.test; -import java.io.*; -import java.util.*; -import junit.framework.*; -import com.mockobjects.*; -import com.mockobjects.util.*;public class TestVerifier extends TestCaseMo { - private static final Class THIS = TestVerifier.class;class OneVerifiable extends MockObject { +import com.mockobjects.ExpectationValue; +import com.mockobjects.MockObject; +import com.mockobjects.util.TestCaseMo; +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestSuite; + +public class TestVerifier extends TestCaseMo { + private static final Class THIS = TestVerifier.class; + + class OneVerifiable extends MockObject { private ExpectationValue myValue = new ExpectationValue("should fail"); private int anotherField; @@ -13,12 +18,14 @@ myValue.setFailOnVerify(); myValue.setExpected("good"); } + public void setValue(String aValue) { myValue.setActual(aValue); } - }class InheritVerifiable extends OneVerifiable { } + class InheritVerifiable extends OneVerifiable { + } public TestVerifier(String name) { @@ -26,19 +33,16 @@ } - public static void main(String[] args) { - start(new String[] { THIS.getName()}); + start(new String[]{THIS.getName()}); } - public static Test suite() { return new TestSuite(THIS); } - public void testInheritVerifiableFails() { InheritVerifiable inheritVerifiable = new InheritVerifiable(); inheritVerifiable.setValue("bad"); @@ -53,7 +57,6 @@ } - public void testInheritVerifiablePasses() { InheritVerifiable inheritVerifiable = new InheritVerifiable(); inheritVerifiable.setValue("good"); @@ -62,7 +65,6 @@ } - public void testNoVerifiables() { class NoVerifiables extends MockObject { } @@ -71,7 +73,6 @@ } - public void testOneVerifiableFails() { OneVerifiable oneVerifiable = new OneVerifiable(); oneVerifiable.setValue("bad"); @@ -86,11 +87,46 @@ } - public void testOneVerifiablePasses() { OneVerifiable oneVerifiable = new OneVerifiable(); oneVerifiable.setValue("good"); oneVerifiable.verify(); } -} \ No newline at end of file + + + class LoopingVerifiable extends MockObject { + LoopingVerifiable myRef; + boolean inVerify = false; + + LoopingVerifiable(LoopingVerifiable aRef) { + setRef(aRef); + } + + + public void setRef(LoopingVerifiable aRef) { + myRef = (aRef == null) ? this : aRef; + } + + public void verify() { + assertTrue("Looping verification detected", !inVerify); + inVerify = true; + super.verify(); + inVerify = false; + } + } + + public void testNoLoopVerifySingleLevel() { + new LoopingVerifiable(null).verify(); + } + + + public void testNoLoopVerifyMultiLevel() { + LoopingVerifiable a = new LoopingVerifiable(null); + LoopingVerifiable b = new LoopingVerifiable(a); + + a.setRef(b); + a.verify(); + } + +} |
From: Jeff M. <cus...@us...> - 2002-09-17 14:51:14
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util In directory usw-pr-cvs1:/tmp/cvs-serv3720/src/core/com/mockobjects/util Modified Files: Verifier.java Log Message: Added code from Simon Levitt <sim...@uk...> to stop verify going into to a recursive loop Index: Verifier.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Verifier.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Verifier.java 28 Mar 2002 18:16:54 -0000 1.3 +++ Verifier.java 17 Sep 2002 14:51:11 -0000 1.4 @@ -3,6 +3,7 @@ import com.mockobjects.Verifiable; import java.lang.reflect.Field; +import java.util.Vector; /** * Helper class to verify all {@link com.mockobjects.Expectation Expectation}s @@ -35,6 +36,8 @@ * @version $Id$ */ public class Verifier { + + private static Vector myProcessingObjects = new Vector(); /** * Public, no-op constructor. * You should not need to instantiate this object, since all methods @@ -58,7 +61,9 @@ Object fieldObject = aField.get(anObject); if (isVerifiable(fieldObject)) { - ((Verifiable)fieldObject).verify(); + if (!myProcessingObjects.contains(fieldObject)) { + ((Verifiable)fieldObject).verify(); + } } } catch (IllegalAccessException e) { junit.framework.Assert.fail("Could not access field " @@ -70,7 +75,7 @@ * Recursively verifies all fields of the passed object. * @param anObject The object to be verified. */ - static public void verifyObject(Object anObject) { + static synchronized public void verifyObject(Object anObject) { verifyObjectFromClass(anObject, anObject.getClass()); } @@ -85,15 +90,24 @@ * @param aClass The apparent class of <code>anObject</code> */ static private void verifyObjectFromClass(Object anObject, Class aClass) { + if (myProcessingObjects.contains(anObject)) { + return; + } if (isRootClass(aClass)) { return; } verifyObjectFromClass(anObject, aClass.getSuperclass()); - - Field[] fields = aClass.getDeclaredFields(); - for (int i = 0; i < fields.length; ++i) { - verifyField(fields[i], anObject); + try { + myProcessingObjects.addElement(anObject); + + Field[] fields = aClass.getDeclaredFields(); + for (int i = 0; i < fields.length; ++i) { + verifyField(fields[i], anObject); + } + } + finally { + myProcessingObjects.removeElement(anObject); } } |
From: Jeff M. <cus...@us...> - 2002-09-17 14:31:18
|
Update of /cvsroot/mockobjects/mockobjects-java/doc In directory usw-pr-cvs1:/tmp/cvs-serv826/doc Modified Files: site.xml Log Message: Simplified site deployment Index: site.xml =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/doc/site.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- site.xml 9 Sep 2002 21:25:41 -0000 1.5 +++ site.xml 17 Sep 2002 14:31:15 -0000 1.6 @@ -1,81 +1,69 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="site" default="site" basedir="."> - <target name="project-properties"> - <property name="project.name" value="mockobjects" /> - <property name="site.name" value="${project.name}-website" /> - <property name="out.dir" value="out" /> - <property name="site.tar" value="${site.name}.tar" /> - </target> - - <target name="copy-stylesheet"> - <copy file="html/stylesheet.css" todir="out"/> - </target> - - <target name="clean" - depends="project-properties"> - <delete quiet="true"> - <fileset dir="${out.dir}"/> - <fileset includes="**/*.class"/> - </delete> - </target> - - <target name="add-task"> - <javac srcdir="."/> - <taskdef name="template" - classname="com.mockobjects.doc.SiteTemplate" - classpath="."/> - </target> - - <target name="site" - depends="project-properties, add-task, copy-stylesheet" - description="Create the output directory and copy templated files over."> - <mkdir dir="${out.dir}"/> - <template - templatefile="html/template.txt" - todir="${out.dir}" - dir="html" - includes="*.html"/> - </target> - - <target name="archive.site" - depends="site"> - <tar tarfile="${site.tar}" - basedir="${out.dir}" /> - - <gzip zipfile="${site.tar}.gz" - src="${site.tar}" /> - - <delete file="${site.tar}" /> - </target> - - <!-- - ======================================================================== - Deploy the web site to SourceForge, using the 'scp' - and 'ssh' commands. The variable "username" need to be passed to Ant - when calling this target and represent your username on SourceForge. - - Ex: ant -Dusername=vmassol deploy-site - - ======================================================================== - --> - <target name="deploy-site" - depends="project-properties" - if="username" - description="Deploy the web site to SourceForge (see target for details)"> - - <property name="deploy.homepage" value="/home/groups/m/mo/mockobjects/htdocs"/> - <property name="deploy.host" value="mockobjects.sourceforge.net"/> - - <exec dir="." executable="scp"> - <arg value="${site.tar}.gz"/> - <arg value="${username}@${deploy.host}:${deploy.homepage}"/> - </exec> - - <exec dir="." executable="ssh"> - <arg - line="-l ${username} ${deploy.host} 'cd ${deploy.homepage};gunzip ${site.tar}.gz;tar xvf ${site.tar};rm ${site.tar}'"/> - </exec> - </target> + <target name="project-properties"> + <property name="project.name" value="mockobjects" /> + <property name="site.name" value="${project.name}-website" /> + <property name="out.dir" value="out" /> + <property name="site.tar" value="${site.name}.tar" /> + </target> + + <target name="copy-stylesheet"> + <copy file="html/stylesheet.css" todir="out"/> + </target> + + <target name="clean" + depends="project-properties"> + <delete quiet="true"> + <fileset dir="${out.dir}"/> + <fileset includes="**/*.class"/> + </delete> + </target> + + <target name="add-task"> + <javac srcdir="."/> + <taskdef name="template" + classname="com.mockobjects.doc.SiteTemplate" + classpath="."/> + </target> + + <target name="site" + depends="project-properties, add-task, copy-stylesheet" + description="Create the output directory and copy templated files over."> + <mkdir dir="${out.dir}"/> + <template + templatefile="html/template.txt" + todir="${out.dir}" + dir="html" + includes="*.html"/> + </target> + + <!-- + ======================================================================== + Deploy the web site to SourceForge, using the 'scp' + command. The variable "username" need to be passed to Ant + when calling this target and represent your username on SourceForge. + + Ex: ant -Dusername=vmassol deploy-site + + ======================================================================== + --> + <target name="deploy-site" + depends="project-properties" + if="username" + description="Deploy the web site to SourceForge (see target for details)"> + + <property name="deploy.homepage" + value="/home/groups/m/mo/mockobjects/htdocs"/> + <property name="deploy.host" + value="mockobjects.sourceforge.net"/> + + <apply dir="." executable="scp" parallel="true" relative="true"> + <srcfile/> + <arg value="${username}@${deploy.host}:${deploy.homepage}"/> + <fileset dir="${out.dir}"/> + </apply> + + </target> </project> |
From: Jeff M. <je...@mk...> - 2002-09-17 14:29:31
|
Feel free to have a go yourself. Otherwise I'll get round to it in a week or two. On Tue, 2002-09-17 at 07:23, denis krizanovic wrote: > > So, I'm playing with MockContext, and I get a "NotImplementedException" > when I call the createSubContext(string name) method. Low and behold, > this method has not been implemented. > > Who implements this? When can I expect an implementation? > > regards, > dk- > > > > > > > ------------------------------------------------------- > Sponsored by: AMD - Your access to the experts on Hammer Technology! > Open Source & Linux Developers, register now for the AMD Developer > Symposium. Code: EX8664 http://www.developwithamd.com/developerlab > _______________________________________________ > 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: denis k. <den...@ma...> - 2002-09-17 06:24:47
|
So, I'm playing with MockContext, and I get a "NotImplementedException" when I call the createSubContext(string name) method. Low and behold, this method has not been implemented. Who implements this? When can I expect an implementation? regards, dk- |
From: Simon L. <sim...@uk...> - 2002-09-16 16:23:31
|
As part of my role to evaluate/develop the MockObjects SQL functionality=20 I've re-worked some of the classes in order to satisfy the testing=20 requirements we'd like to meet. I've also been looking at them in order to implement a=20 MockCallableStatement (Not yet done). I'd like to present my current set of changes back to the group for=20 comments and/or inclusion into the codebase. They are as follows: =2D ExpectationMap & ReturnObjectList - methods to enable and perform the verify()cation of objects contained therein. Default to original functionality. - ReturnObjectList keeps its list of objects to allow above. =2D CommonMockConnection=20 - method to allow the automated checking of associated PreparedStatements. - Automatically associates Statements with Connection on return. =2D CommonMockStatement: - INTERFACE CHANGE: setExpectedQueryString now makes given query the only one on the object. addExpectedQueryString allows more to be=20 added. Did this for constancy more than anything. - setupResultSet/setupAddResultSet used to set/add ResultSets to the=20 connection. - addResultSet deprecated (in favour to setupAddResultSet(). - An update count is treated the same as a normal ResultSet - more=20 closely follows the java.jdbc specification (eg. a Statement result=20 is either a ResultSet or an update count). The query counts are queued with the ResultSets for retrieval after execute calls. - Automatically associates ResultSets with the Statement on return.=20 - method to allow the automated checking of associated ResultSets. ResultSets (in general) - CommonMockResult created in jdk/common that defines single a ResultSet interface that supports single & multi row result sets. - Allows the verification/expectation checking of row data retrieval from all rows (not just the first). - Each jdk/<version>/com/mockobjects/sql now defines a single=20 MockResultSet that allows the definition of JDK specific additional=20 methods/interfaces that may be required. MockResultSet removed from jdk/common. Now uses a similar model to Connection and Statement. - MockSingleRowResultSet & MockMultiRowResultSet objects/interfaces=20 retained for backwards compatibility (moved into jdk/common -=20 extends MockResultSet defined in jdk/<version>)). Both removed from jdk/<version> trees. MockMultiRowResultSet basically just defines a single deprecated method from its original interface (MockResultSet defines the rest). - MockUpdateResultSet added for update count support (extends=20 MockSingleRowResultSet). - POTENTIAL issue: These changes add a requirement that=20 jdk/common/com/mockobjects/sql needs a jdk/<version> derived MockResultSet in order to compile. (Doesn't break ant build though). - Can now set/add to the row name mappings and rows returned. MockSingleRowResultSet allows setting/adding of individual elements=20 within the row. - If name mapping supplied, can use name and/or index to access row=20 data. (Name mapping currently needs to be supplied before data to=20 work correctly). - Automatically associates ResultSet with Statement on return. - method to allow the automated checking of Row expectations. Given that there is a fair bit of class movement in these changes how=20 should supply these (a cvs diff -u doesn't cope with new/deleted files). Perhaps a CVS branch where I could commit these to? Other things I'd like to do: =2D Develop a DeferredException class that causes an exception to be thrown after a certain number of events has occured (eg. throws an=20 SQLException on the third call to next() on a ResultSet) =2D Add mechanism for specifying a particular value on a row shouldn't be retrieved (code may be retrieving different columns depending on data it find in others). =2D Add support for Statements that return Multiple resultSets on one=20 execution. (Not that high a priority). Cheers, Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |
From: Simon L. <sim...@uk...> - 2002-09-16 14:36:46
|
On Monday 16 September 2002 15:31, Simon Levitt wrote: > New diff -u attached > Sorry, Shoud of attempted to compile after copy and paste... diff below to be=20 applied after diff: =2D-- Verifier-damn.java Mon Sep 16 15:34:38 2002 +++ Verifier.java Mon Sep 16 15:32:55 2002 @@ -90,7 +90,7 @@ * @param aClass The apparent class of <code>anObject</code> */ static private void verifyObjectFromClass(Object anObject, Class=20 aClass) { =2D if (myProcessingObjects.contains(fieldObject)) { + if (myProcessingObjects.contains(anObject)) { return; } if (isRootClass(aClass)) { =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |
From: Simon L. <sim...@uk...> - 2002-09-16 14:31:15
|
On Monday 16 September 2002 11:56, Jeff Martin wrote: > Looks reasonable, but could we have a test case for it. It's the sort > of thing that could get broken. > Ok.. I've implemented tests for an object referencing itself, and the=20 classic two objects referencing each other. In writing the test cases it became easier to (ie. may test examples would= =20 only work if this was done) initially check whether we've processed the=20 item before calling verify(). I left the original processing check in as it could catch a manually=20 called verify() for objects previously automatically checked. (A coding style, and supporting methods for verify() could be suggested=20 that would reduce the possibility of loops occuring in test specific=20 verify methods). New diff -u attached Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |
From: Jeff M. <je...@mk...> - 2002-09-16 10:59:40
|
Looks reasonable, but could we have a test case for it. It's the sort of thing that could get broken. On Fri, 2002-09-13 at 15:23, Simon Levitt wrote: > On Friday 13 September 2002 11:55, Jeff Martin wrote: > > It's a general policy to not have mocks manage the relationships with > > other mocks. The idea is to keep the mocks as simple as possible. > > > > This is the reason I've started work on the test helper classes which > > setup the tree of mocks for you. Though I've not produced any for the > > JDBC classes as it's more complex than the servlet api. > > > I can see this being helpful when there is a collection of objects that > need to be associated to sets of each other that have no real defined > (single) parent object, but the association of ResultSet to Statement to > Connection is a very simple child to single parent relationship. Or am I > missing something? > > My changes do the association at usage time (I didn't say that before > TBF), in that when a Statement or ResultSet gets returned, it is > automatically associated with the Object that you called to get it (I > can't see a situation, for JDBC at least, where you would want this any > different - or infact has any advantage). > > The set<Parent> interface is still required, as you may have methods to > test that take a ResultSet, or Statement, for which the parent object > needs manually setting. > > > Don't think this helps if the dependency is more than one level deep. > [...] > > Tempted to say forget thread safety (That's not to say it's okay to > > have static variables.). > > > I've got a change (cvs diff -u attached) to Verifier that now at least > works for me. > It has a static Vector (simplest why I could think of) of in verify() > objects, and ignores any object already being verified. It also doesn't > require any interface change. > > This solves my problem, and unless specific object implementations of > verify cause a loop (which was a potential problem anyway), I can't see > how this is any worse. > > Simon., > -- > -------------------------------------------------------------------------- > Simon Levitt, Senior Development Engineer @ WorldPay plc, > WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND > Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 > ------------------------- http://www.worldpay.com/ ----------------------- > ---- > > Index: Verifier.java > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Verifier.java,v > retrieving revision 1.3 > diff -u -r1.3 Verifier.java > --- Verifier.java 28 Mar 2002 18:16:54 -0000 1.3 > +++ Verifier.java 13 Sep 2002 13:46:34 -0000 > @@ -3,6 +3,7 @@ > import com.mockobjects.Verifiable; > > import java.lang.reflect.Field; > +import java.util.Vector; > > /** > * Helper class to verify all {@link com.mockobjects.Expectation Expectation}s > @@ -35,6 +36,8 @@ > * @version $Id: Verifier.java,v 1.3 2002/03/28 18:16:54 custommonkey Exp $ > */ > public class Verifier { > + > + private static Vector myProcessingObjects = new Vector(); > /** > * Public, no-op constructor. > * You should not need to instantiate this object, since all methods > @@ -70,7 +73,7 @@ > * Recursively verifies all fields of the passed object. > * @param anObject The object to be verified. > */ > - static public void verifyObject(Object anObject) { > + static synchronized public void verifyObject(Object anObject) { > verifyObjectFromClass(anObject, anObject.getClass()); > } > > @@ -85,15 +88,24 @@ > * @param aClass The apparent class of <code>anObject</code> > */ > static private void verifyObjectFromClass(Object anObject, Class aClass) { > + if (myProcessingObjects.contains(anObject)) { > + return; > + } > if (isRootClass(aClass)) { > return; > } > > verifyObjectFromClass(anObject, aClass.getSuperclass()); > - > - Field[] fields = aClass.getDeclaredFields(); > - for (int i = 0; i < fields.length; ++i) { > - verifyField(fields[i], anObject); > + try { > + myProcessingObjects.addElement(anObject); > + > + Field[] fields = aClass.getDeclaredFields(); > + for (int i = 0; i < fields.length; ++i) { > + verifyField(fields[i], anObject); > + } > + } > + finally { > + myProcessingObjects.removeElement(anObject); > } > } > -- 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: Simon L. <sim...@uk...> - 2002-09-13 14:23:15
|
On Friday 13 September 2002 11:55, Jeff Martin wrote: > It's a general policy to not have mocks manage the relationships with > other mocks. The idea is to keep the mocks as simple as possible. > > This is the reason I've started work on the test helper classes which > setup the tree of mocks for you. Though I've not produced any for the > JDBC classes as it's more complex than the servlet api. > I can see this being helpful when there is a collection of objects that=20 need to be associated to sets of each other that have no real defined=20 (single) parent object, but the association of ResultSet to Statement to=20 Connection is a very simple child to single parent relationship. Or am I=20 missing something? My changes do the association at usage time (I didn't say that before=20 TBF), in that when a Statement or ResultSet gets returned, it is=20 automatically associated with the Object that you called to get it (I=20 can't see a situation, for JDBC at least, where you would want this any=20 different - or infact has any advantage). The set<Parent> interface is still required, as you may have methods to=20 test that take a ResultSet, or Statement, for which the parent object=20 needs manually setting. > Don't think this helps if the dependency is more than one level deep. [...] > Tempted to say forget thread safety (That's not to say it's okay to > have static variables.). > I've got a change (cvs diff -u attached) to Verifier that now at least=20 works for me. It has a static Vector (simplest why I could think of) of in verify()=20 objects, and ignores any object already being verified. It also doesn't=20 require any interface change. This solves my problem, and unless specific object implementations of=20 verify cause a loop (which was a potential problem anyway), I can't see=20 how this is any worse. Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |
From: Jeff M. <je...@mk...> - 2002-09-13 10:58:35
|
On Fri, 2002-09-13 at 11:28, Simon Levitt wrote: > On Friday 13 September 2002 10:36, Jeff Martin wrote: > > One problem you might come across is circular verifications. It's a > > problem we had here where you can add a statement to a connection and > > then the connection to the statement. When you call verify the whole > > thing goes into a loop. > > > About 30 seconds before this arrived I was sitting here trying to work out > why that exact problem had occurred! - Thanks a lot - Thats saved me > ages! > ;-) Did I mention I'm a clairvoyant in my spare time. > Is that the reason a MockStatement wasn't automatically associated with > the Connection its added to? One of the changes I've made locally is to > do this (for ResultSets and their Statement as well). It's a general policy to not have mocks manage the relationships with other mocks. The idea is to keep the mocks as simple as possible. This is the reason I've started work on the test helper classes which setup the tree of mocks for you. Though I've not produced any for the JDBC classes as it's more complex than the servlet api. > > > The way to get around it is probably to change verify to build up a > > verification set by adding it's children to it and then verifying > > everything in the set. > > > Wouldn't it be easier for the Verifier to keep a list of objects its in > the process of verifying and not allow the same one twice (silently > doesn't bother)? Don't think this helps if the dependency is more than one level deep. > > Making Verifier.verifyObject synchronized would stop problems with > multiple threads verifying at the same time (why you'd do that I don't > know though). Tempted to say forget thread safety (That's not to say it's okay to have static variables.). > > > You may not hit this problem but it's possible that these sort of > > changes would increase the chances of it happening. > > > Thanks again for the quick spot!. > > Cheers, > > Simon., > -- > -------------------------------------------------------------------------- > Simon Levitt, Senior Development Engineer @ WorldPay plc, > WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND > Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 > ------------------------- http://www.worldpay.com/ ----------------------- > > > > ------------------------------------------------------- > 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 -- 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: Simon L. <sim...@uk...> - 2002-09-13 10:28:19
|
On Friday 13 September 2002 10:36, Jeff Martin wrote: > One problem you might come across is circular verifications. It's a > problem we had here where you can add a statement to a connection and > then the connection to the statement. When you call verify the whole > thing goes into a loop. > About 30 seconds before this arrived I was sitting here trying to work out= =20 why that exact problem had occurred! - Thanks a lot - Thats saved me=20 ages! Is that the reason a MockStatement wasn't automatically associated with=20 the Connection its added to? One of the changes I've made locally is to=20 do this (for ResultSets and their Statement as well). > The way to get around it is probably to change verify to build up a > verification set by adding it's children to it and then verifying > everything in the set. > Wouldn't it be easier for the Verifier to keep a list of objects its in=20 the process of verifying and not allow the same one twice (silently=20 doesn't bother)?=20 Making Verifier.verifyObject synchronized would stop problems with=20 multiple threads verifying at the same time (why you'd do that I don't=20 know though). > You may not hit this problem but it's possible that these sort of > changes would increase the chances of it happening. > Thanks again for the quick spot!. Cheers, Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |
From: Jeff M. <je...@mk...> - 2002-09-13 09:39:21
|
One problem you might come across is circular verifications. It's a problem we had here where you can add a statement to a connection and then the connection to the statement. When you call verify the whole thing goes into a loop. The way to get around it is probably to change verify to build up a verification set by adding it's children to it and then verifying everything in the set. You may not hit this problem but it's possible that these sort of changes would increase the chances of it happening. On Fri, 2002-09-13 at 10:01, Simon Levitt wrote: > On Friday 13 September 2002 00:07, Steve Freeman wrote: > > I'd like to see some concrete examples, especially for ExpectationMap > > which is, itself a verifiable. It's sounds like some of your tests may > > be going too deep. You can overspecify, as well as underspecify. > > > Concrete example: > > We've got our own JDBC Connection Pool implementation which like most has > a finite set of actual JDBC Connections that it can allocate to threads. > > Each piece of code wanting to use JDBC talks directly to the Pool asking > for a connection to a particular named databaase (through a symbolic > name). > > Thus the call to the Connection Pooling classes is performed within the > method we want to test. > > e.g: > > public Person getPerson(String name) { > // PooledConnection is a wrapper round Connection > PooledConnection conn = ConnectionPool.getPooledConnection("persondb"); > > try { > conn.enable(); // Actually gets JDBC Connection from pool > stmt = conn.prepareStatement(...); > > results = stmt.exeuteQuery(); > person = new Person(results): > } > catch (SQLException e) { > conn.disable(); > } > reutrn person; > } > > I've developed a Mocked version of the Connection Pooling system to allow > these methods to be tested. > > What happens is the setup calls on MockConnectionPool populate an > ExpectationMap from pool name to MockPooledConnection - so you can test > the expectation that certain database connections will be/are being used. > verify() is checking expected keys vs actual keys. > > What I'd like to automate is the verification of the expectations set on > the MockPooledConnection objects contained in the ExpectationMap (ie. its > values). > > I think it would also be useful to check the MockStatements contained > therein, and their MockResultSets as well. > > You can obviously manually do this at the moment however verifying the > expectations means keeping a lot of object references locally to the test > method for the duration of the whole test. > > Simon., > -- > -------------------------------------------------------------------------- > Simon Levitt, Senior Development Engineer @ WorldPay plc, > WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND > Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 > ------------------------- http://www.worldpay.com/ ----------------------- > > > > ------------------------------------------------------- > 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 -- 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: Simon L. <sim...@uk...> - 2002-09-13 09:01:33
|
On Friday 13 September 2002 00:07, Steve Freeman wrote: > I'd like to see some concrete examples, especially for ExpectationMap > which is, itself a verifiable. It's sounds like some of your tests may > be going too deep. You can overspecify, as well as underspecify. > Concrete example: We've got our own JDBC Connection Pool implementation which like most has=20 a finite set of actual JDBC Connections that it can allocate to threads.=20 Each piece of code wanting to use JDBC talks directly to the Pool asking=20 for a connection to a particular named databaase (through a symbolic=20 name).=20 Thus the call to the Connection Pooling classes is performed within the=20 method we want to test. e.g: public Person getPerson(String name) { // PooledConnection is a wrapper round Connection PooledConnection conn =3D ConnectionPool.getPooledConnection("persondb"); try { conn.enable(); // Actually gets JDBC Connection from pool stmt =3D conn.prepareStatement(...); results =3D stmt.exeuteQuery(); person =3D new Person(results): } catch (SQLException e) { conn.disable(); } reutrn person; } I've developed a Mocked version of the Connection Pooling system to allow=20 these methods to be tested.=20 What happens is the setup calls on MockConnectionPool populate an=20 ExpectationMap from pool name to MockPooledConnection - so you can test=20 the expectation that certain database connections will be/are being used.=20 verify() is checking expected keys vs actual keys. What I'd like to automate is the verification of the expectations set on=20 the MockPooledConnection objects contained in the ExpectationMap (ie. its=20 values).=20 I think it would also be useful to check the MockStatements contained=20 therein, and their MockResultSets as well.=20 You can obviously manually do this at the moment however verifying the=20 expectations means keeping a lot of object references locally to the test=20 method for the duration of the whole test. Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |
From: Steve F. <st...@m3...> - 2002-09-13 03:57:43
|
From: "Simon Levitt" <sim...@uk...> > I've been looking into the sql Mock objects, and now in particular how to > verify the Expectations that have been set up. > > >From what I understand the only way to do this currently is to manually > code a call to verify on every MockConnection, MockStatement derived, and > MockResultSet derived, object from the test code. > > It strikes me it would be must nicer to be able to call verify on the > MockConnection and it ripple through the heirachy of objects. That's an interesting idea. Jeff has been working on "mock kits" to set up clusters of related objects, so that might be relevant. Don't forget the Verifier object that will verify all the appropriate instance variables of an object. > I've started looking into this, alongside other changes I'd like to > present in the near future, and a way of doing it would be to change > ExpectationMap and ReturnObjectList to allow the verifying their > contained objects by adding a flag to enable/disable the functionality > (with disable being the default). ReturnObjectList would have to keep > hold of returned objects in order to do this successfully. I'd like to see some concrete examples, especially for ExpectationMap which is, itself a verifiable. It's sounds like some of your tests may be going too deep. You can overspecify, as well as underspecify. Steve |
From: Simon L. <sim...@uk...> - 2002-09-12 11:18:18
|
Hi, I've been looking into the sql Mock objects, and now in particular how to=20 verify the Expectations that have been set up. =46rom what I understand the only way to do this currently is to manually=20 code a call to verify on every MockConnection, MockStatement derived, and=20 MockResultSet derived, object from the test code. It strikes me it would be must nicer to be able to call verify on the=20 MockConnection and it ripple through the heirachy of objects. I've started looking into this, alongside other changes I'd like to=20 present in the near future, and a way of doing it would be to change=20 ExpectationMap and ReturnObjectList to allow the verifying their=20 contained objects by adding a flag to enable/disable the functionality=20 (with disable being the default). ReturnObjectList would have to keep=20 hold of returned objects in order to do this successfully. What do you think? Sensible? Simon., =2D-=20 =2D------------------------------------------------------------------------- Simon Levitt, Senior Development Engineer @ WorldPay plc, WorldPay Centre, The Science Park, Milton Rd., Cambridge, CB4 0WE, ENGLAND = =20 Sim...@uk... Ph:+44(0)1223 715151 F:+44(0)1223 715157 =2D------------------------ http://www.worldpay.com/ ----------------------- |
From: Steve F. <st...@m3...> - 2002-09-10 20:14:29
|
I'm not proud, implement something better... S. ----- Original Message ----- From: "Jeff Martin" <je...@mk...> To: "MockObjects" <moc...@li...> Sent: Tuesday, September 10, 2002 10:20 AM Subject: Re: [MO-java-dev] CVS: mockobjects-java/doc site.xml,1.4,1.5 > Rather than having the tar scp untar stuff, wouldn't it be simpler just > to scp the contents of the output dir to htdocs? |
From: Jeff M. <cus...@us...> - 2002-09-10 10:40:36
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv18187 Modified Files: MockHttpServletRequest.java Log Message: Added patch for getContextPath provided by Chris Nokleberg <ch...@si...> Index: MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- MockHttpServletRequest.java 27 Aug 2002 16:38:17 -0000 1.8 +++ MockHttpServletRequest.java 10 Sep 2002 10:40:32 -0000 1.9 @@ -21,6 +21,7 @@ private Dictionary myHeaders = new Hashtable(); private HttpSession myHttpSession; private String myContentTypeToReturn; + private String myContextPath; private String myPathInfo; private String myRemoteAddress; private String myRequestURI; @@ -91,8 +92,11 @@ } public String getContextPath() { - notImplemented(); - return null; + return myContextPath; + } + + public void setupGetContextPath(String contextPath) { + myContextPath = contextPath; } public Cookie[] getCookies() { @@ -352,4 +356,4 @@ public Map getParameterMap() { return null; } -} \ No newline at end of file +} |
From: Jeff M. <je...@mk...> - 2002-09-10 09:23:37
|
Rather than having the tar scp untar stuff, wouldn't it be simpler just to scp the contents of the output dir to htdocs? This is how I've been releasing stuff to the site so far. On Mon, 2002-09-09 at 22:25, Steve Freeman wrote: > Update of /cvsroot/mockobjects/mockobjects-java/doc > In directory usw-pr-cvs1:/tmp/cvs-serv10538/doc > > Modified Files: > site.xml > Log Message: > reworked site build script > removed old implementation > added gzip and (untested) upload target from original build.xml > > Index: site.xml > =================================================================== > RCS file: /cvsroot/mockobjects/mockobjects-java/doc/site.xml,v > retrieving revision 1.4 > retrieving revision 1.5 > diff -u -r1.4 -r1.5 > --- site.xml 9 Sep 2002 00:44:50 -0000 1.4 > +++ site.xml 9 Sep 2002 21:25:41 -0000 1.5 > @@ -1,60 +1,81 @@ > <?xml version="1.0" encoding="UTF-8"?> > <project name="site" default="site" basedir="."> > > - <target name="copy-stylesheet"> > - <copy file="html/stylesheet.css" todir="out"/> > - </target> > - > - <target name="site" depends="copy-stylesheet"> > - <javac srcdir="."> > - <include name="SiteHack.java"/> > - </javac> > - <java classname="SiteHack"> > - <classpath path="."/> > - <arg value="html/template.txt"/> > - <arg value="html/alt.html"/> > - <arg value="html/changes.html"/> > - <arg value="html/coding_conventions.html"/> > - <arg value="html/downloads.html"/> > - <arg value="html/endotesting.html"/> > - <arg value="html/index.html"/> > - <arg value="html/license.html"/> > - <arg value="html/naming_conventions.html"/> > - <arg value="html/papers.html"/> > - <arg value="html/release_process.html"/> > - <arg value="html/todo.html"/> > - <arg value="html/index.html"/> > - <arg value="html/faq.html"/> > - </java> > - </target> > - > - > - <target name="clean"> > - <delete quiet="true"> > - <fileset dir="out" /> > - <fileset includes="**/*.class" /> > - </delete> > - </target> > - > - <target name="add-task"> > - <javac srcdir="." /> > - <taskdef name="template" > - classname="com.mockobjects.doc.SiteTemplate" > - classpath="."/> > - </target> > - > - <target name="create-out-dir"> > - <mkdir dir="out" /> > - </target> > - > - <target name="format" > - depends="add-task, create-out-dir, copy-stylesheet" > - description="Create the output directory and copy templated files over."> > - <template > - templatefile="html/template.txt" > - todir="out" > - dir="html" > - includes="*.html"/> > - </target> > + <target name="project-properties"> > + <property name="project.name" value="mockobjects" /> > + <property name="site.name" value="${project.name}-website" /> > + <property name="out.dir" value="out" /> > + <property name="site.tar" value="${site.name}.tar" /> > + </target> > + > + <target name="copy-stylesheet"> > + <copy file="html/stylesheet.css" todir="out"/> > + </target> > + > + <target name="clean" > + depends="project-properties"> > + <delete quiet="true"> > + <fileset dir="${out.dir}"/> > + <fileset includes="**/*.class"/> > + </delete> > + </target> > + > + <target name="add-task"> > + <javac srcdir="."/> > + <taskdef name="template" > + classname="com.mockobjects.doc.SiteTemplate" > + classpath="."/> > + </target> > + > + <target name="site" > + depends="project-properties, add-task, copy-stylesheet" > + description="Create the output directory and copy templated files over."> > + <mkdir dir="${out.dir}"/> > + <template > + templatefile="html/template.txt" > + todir="${out.dir}" > + dir="html" > + includes="*.html"/> > + </target> > + > + <target name="archive.site" > + depends="site"> > + <tar tarfile="${site.tar}" > + basedir="${out.dir}" /> > + > + <gzip zipfile="${site.tar}.gz" > + src="${site.tar}" /> > + > + <delete file="${site.tar}" /> > + </target> > + > + <!-- > + ======================================================================== > + Deploy the web site to SourceForge, using the 'scp' > + and 'ssh' commands. The variable "username" need to be passed to Ant > + when calling this target and represent your username on SourceForge. > + > + Ex: ant -Dusername=vmassol deploy-site > + > + ======================================================================== > + --> > + <target name="deploy-site" > + depends="project-properties" > + if="username" > + description="Deploy the web site to SourceForge (see target for details)"> > + > + <property name="deploy.homepage" value="/home/groups/m/mo/mockobjects/htdocs"/> > + <property name="deploy.host" value="mockobjects.sourceforge.net"/> > + > + <exec dir="." executable="scp"> > + <arg value="${site.tar}.gz"/> > + <arg value="${username}@${deploy.host}:${deploy.homepage}"/> > + </exec> > + > + <exec dir="." executable="ssh"> > + <arg > + line="-l ${username} ${deploy.host} 'cd ${deploy.homepage};gunzip ${site.tar}.gz;tar xvf ${site.tar};rm ${site.tar}'"/> > + </exec> > + </target> > > </project> > > > > ------------------------------------------------------- > 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-09 21:25:44
|
Update of /cvsroot/mockobjects/mockobjects-java/doc In directory usw-pr-cvs1:/tmp/cvs-serv10538/doc Modified Files: site.xml Log Message: reworked site build script removed old implementation added gzip and (untested) upload target from original build.xml Index: site.xml =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/doc/site.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- site.xml 9 Sep 2002 00:44:50 -0000 1.4 +++ site.xml 9 Sep 2002 21:25:41 -0000 1.5 @@ -1,60 +1,81 @@ <?xml version="1.0" encoding="UTF-8"?> <project name="site" default="site" basedir="."> - <target name="copy-stylesheet"> - <copy file="html/stylesheet.css" todir="out"/> - </target> - - <target name="site" depends="copy-stylesheet"> - <javac srcdir="."> - <include name="SiteHack.java"/> - </javac> - <java classname="SiteHack"> - <classpath path="."/> - <arg value="html/template.txt"/> - <arg value="html/alt.html"/> - <arg value="html/changes.html"/> - <arg value="html/coding_conventions.html"/> - <arg value="html/downloads.html"/> - <arg value="html/endotesting.html"/> - <arg value="html/index.html"/> - <arg value="html/license.html"/> - <arg value="html/naming_conventions.html"/> - <arg value="html/papers.html"/> - <arg value="html/release_process.html"/> - <arg value="html/todo.html"/> - <arg value="html/index.html"/> - <arg value="html/faq.html"/> - </java> - </target> - - - <target name="clean"> - <delete quiet="true"> - <fileset dir="out" /> - <fileset includes="**/*.class" /> - </delete> - </target> - - <target name="add-task"> - <javac srcdir="." /> - <taskdef name="template" - classname="com.mockobjects.doc.SiteTemplate" - classpath="."/> - </target> - - <target name="create-out-dir"> - <mkdir dir="out" /> - </target> - - <target name="format" - depends="add-task, create-out-dir, copy-stylesheet" - description="Create the output directory and copy templated files over."> - <template - templatefile="html/template.txt" - todir="out" - dir="html" - includes="*.html"/> - </target> + <target name="project-properties"> + <property name="project.name" value="mockobjects" /> + <property name="site.name" value="${project.name}-website" /> + <property name="out.dir" value="out" /> + <property name="site.tar" value="${site.name}.tar" /> + </target> + + <target name="copy-stylesheet"> + <copy file="html/stylesheet.css" todir="out"/> + </target> + + <target name="clean" + depends="project-properties"> + <delete quiet="true"> + <fileset dir="${out.dir}"/> + <fileset includes="**/*.class"/> + </delete> + </target> + + <target name="add-task"> + <javac srcdir="."/> + <taskdef name="template" + classname="com.mockobjects.doc.SiteTemplate" + classpath="."/> + </target> + + <target name="site" + depends="project-properties, add-task, copy-stylesheet" + description="Create the output directory and copy templated files over."> + <mkdir dir="${out.dir}"/> + <template + templatefile="html/template.txt" + todir="${out.dir}" + dir="html" + includes="*.html"/> + </target> + + <target name="archive.site" + depends="site"> + <tar tarfile="${site.tar}" + basedir="${out.dir}" /> + + <gzip zipfile="${site.tar}.gz" + src="${site.tar}" /> + + <delete file="${site.tar}" /> + </target> + + <!-- + ======================================================================== + Deploy the web site to SourceForge, using the 'scp' + and 'ssh' commands. The variable "username" need to be passed to Ant + when calling this target and represent your username on SourceForge. + + Ex: ant -Dusername=vmassol deploy-site + + ======================================================================== + --> + <target name="deploy-site" + depends="project-properties" + if="username" + description="Deploy the web site to SourceForge (see target for details)"> + + <property name="deploy.homepage" value="/home/groups/m/mo/mockobjects/htdocs"/> + <property name="deploy.host" value="mockobjects.sourceforge.net"/> + + <exec dir="." executable="scp"> + <arg value="${site.tar}.gz"/> + <arg value="${username}@${deploy.host}:${deploy.homepage}"/> + </exec> + + <exec dir="." executable="ssh"> + <arg + line="-l ${username} ${deploy.host} 'cd ${deploy.homepage};gunzip ${site.tar}.gz;tar xvf ${site.tar};rm ${site.tar}'"/> + </exec> + </target> </project> |