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: <rin...@me...> - 2002-04-10 15:17:50
|
Hello Jeff, > -----Original Message----- > From: Jeff Martin [mailto:je...@mk...] > > I much prefer to keep tests in the same place as the java files. As an > example, I've never really looked at the mock objects test package. I > probably should but unless I know that there is a test I need > to update > I'm not going to look in there just to see if the change I make should > be tested. If the test in the the same package as the class it's much > harder for me to miss the test. I'm using Eclipse as IDE, and although I have split up the production code and test code into separate directory structures (with the *same* package name) for my projects, I see errors in my unit test code if I change the AP= I of my production code. The placement of the code is not an issue for me. Ringo |
From: Jeff M. <je...@mk...> - 2002-04-10 14:57:59
|
I much prefer to keep tests in the same place as the java files. As an example, I've never really looked at the mock objects test package. I probably should but unless I know that there is a test I need to update I'm not going to look in there just to see if the change I make should be tested. If the test in the the same package as the class it's much harder for me to miss the test. On Wed, 2002-04-10 at 11:55, rin...@me... wrote: > Hello Jeff, > > > I'm currently seperating out the jdk classes from the core mockobject > > classes hopefully we'll end up with something like this. > > > > src/core/ > > src/jdk/common/ > > /1.1/ > > /1.2/ > > /1.3/ > > /1.4/ > > src/j2ee/common > > /1.2/ > > /1.3/ > > > > What about appending each of this folders with java and test, like they do > in a number of Apache projects? e.g: > > src/core/java > src/core/test > src/jdk/common/java > src/jdk/common/test > ... > > In Apache style, configuration files are placed in a third subdirectory > named conf, e.g. > > src/core/conf > src/jdk/common/conf > ... > > Within each of these subdirectories you can take the same package structure. > Then you don't have to filter on the source files to distinguish between > production and test code. > > Ringg > > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev -- |
From: <rin...@me...> - 2002-04-10 10:56:50
|
Hello Jeff, > I'm currently seperating out the jdk classes from the core mockobject > classes hopefully we'll end up with something like this. > > src/core/ > src/jdk/common/ > /1.1/ > /1.2/ > /1.3/ > /1.4/ > src/j2ee/common > /1.2/ > /1.3/ > What about appending each of this folders with java and test, like they do in a number of Apache projects? e.g: src/core/java src/core/test src/jdk/common/java src/jdk/common/test ... In Apache style, configuration files are placed in a third subdirectory named conf, e.g. src/core/conf src/jdk/common/conf ... Within each of these subdirectories you can take the same package structure= . Then you don't have to filter on the source files to distinguish between production and test code. Ringg |
From: Jeff M. <je...@cu...> - 2002-04-10 10:46:17
|
I'm currently seperating out the jdk classes from the core mockobject classes hopefully we'll end up with something like this. src/core/ src/jdk/common/ /1.1/ /1.2/ /1.3/ /1.4/ src/j2ee/common /1.2/ /1.3/ and a build process which builds mock-core.jar, mock-jdk.x.x.jar mock-j2ee.x.x.jar or something similar. The thing I've just come up against is the test package with currently sites in core. This contains the TestExpectationSqlRow which needs to be moved to src/jdk/common but I don't think we should have a test package in each area. I'd much rather see the tests sit in the same package as the class it's testing, as it makes it obvious there is a test for a class. Tests can then be striped out of the final dist by excluding **/Test*.class. Any comments? -- Jeff Martin Memetic Engineer http://www.custommonkey.org/ |
From: Benjamin R. <ben...@co...> - 2002-04-08 11:57:02
|
Hi Steve I am doing the test on some code that is supposed to take a result set and "do the right thing" with it. As it happens, it always uses getString, but that might change; and the database will actually return a result set with a boolean in it, not a string, in the case being tested. It seems unfortunate to build into the test an unnecessary dependency on the way the code I'm testing happens to work; especially when the fix is so simple. In other words, putting "false" (or better, "new Boolean(false).toString()") in the MockResultSet rather than "new Boolean(false)" feels like a hack to me. I'm not being modest so much as cautious: the Javadoc for java 1.2.2 (which I'm using, alas) defines getString as "Gets the value of a column in the current row as a Java String." Which is a little ambiguous -- maybe implementations even differ! But the setup we use -- jdk1.2.2, Oracle thin drivers -- works the way I describe. cheers Ben > Thanks for the prompt. We'll take a look (unless you're being > modest and know that this fix should really be made). > > One thought, though, is it likely that you would write code > that gets both the string and the other type? If not, you > could always set 'aBoolean" to be "false" yourself. Has this > actually been a problem for you, or are you concerned about > conforming to the spec? > > Steve > > > ----- Original Message ----- > From: "Benjamin Rosenbaum" <ben...@co...> > To: <moc...@li...> > Sent: Tuesday, April 02, 2002 3:26 PM > Subject: [MO-java-dev] Question about MockResultSet.getString > > > > > > Hi all > > > > My impression is that java.sql.ResultSet.getString(...) gives you a > > String representation even if the datatype is not a String (that is, > it > > tries to do a conversion for you). > > > > Currently if you do: > > > > String columns[] = { "aString", "anInt", "aBoolean", > "aDouble" }; > > Object values[] = { "FOO", new Integer(123), new > Boolean(false), > > new Double(0.02) }; > > > > ResultSet rset = new MockSingleRowResultSet(columns, values); > > > > return rset.getString("aBoolean"); > > > > You get an exception. Is this the correct behavior? |
From: Jeff M. <cus...@us...> - 2002-04-05 10:49:52
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv12932/src/j2ee/common/com/mockobjects/servlet Added Files: MockServletInputStream.java Log Message: Added MockServletInputStream --- NEW FILE: MockServletInputStream.java --- package com.mockobjects.servlet; import com.mockobjects.Verifiable; import com.mockobjects.util.Verifier; import javax.servlet.ServletInputStream; public class MockServletInputStream extends ServletInputStream implements Verifiable{ public void verify(){ Verifier.verifyObject(this); } public int read(){ return -1; } } |
From: Jeff M. <cus...@us...> - 2002-04-05 10:49:52
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv12932/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpServletRequest.java Log Message: Added MockServletInputStream Index: MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockHttpServletRequest.java 15 Mar 2002 17:37:06 -0000 1.2 +++ MockHttpServletRequest.java 5 Apr 2002 10:49:49 -0000 1.3 @@ -21,6 +21,7 @@ private String remoteAddress; private String myRequestURI; private String myMethod; + private ServletInputStream myInputStream; private java.security.Principal userPrincipal; private ExpectationSet mySetAttributes = new ExpectationSet(MockHttpServletRequest.class.getName() + @@ -93,10 +94,13 @@ return null; } + public void setupGetInputStream(ServletInputStream anInputStream){ + this.myInputStream = anInputStream; + } + public javax.servlet.ServletInputStream getInputStream() throws java.io.IOException { - notYetImplemented(); - return null; + return myInputStream; } public int getIntHeader(String arg1) { |
From: Jeff M. <cus...@us...> - 2002-04-05 10:45:48
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms In directory usw-pr-cvs1:/tmp/cvs-serv11905/src/j2ee/common/com/mockobjects/jms Modified Files: MockMessage.java Log Message: Implemented ackknowledgement count Index: MockMessage.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockMessage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockMessage.java 22 Feb 2002 16:25:05 -0000 1.1 +++ MockMessage.java 5 Apr 2002 10:45:43 -0000 1.2 @@ -5,238 +5,244 @@ public abstract class MockMessage extends MockObject implements Message { - protected ExpectationValue myJMSReplyTo = new ExpectationValue("MockMessage.setJMSReplyTo"); - protected ExpectationCounter mySetJMSCorrelationIDCalls = new ExpectationCounter("MockMessage.setJMSCorrelationID"); + protected ExpectationCounter myAcknowledgeCount = + new ExpectationCounter("MockMessage.acknowledge"); + protected ExpectationValue myJMSReplyTo = + new ExpectationValue("MockMessage.setJMSReplyTo"); + protected ExpectationCounter mySetJMSCorrelationIDCalls = + new ExpectationCounter("MockMessage.setJMSCorrelationID"); + + private JMSException myException; + /** + * Used for both messageID and correlationID + */ + private String myJMSMessageID; - private JMSException myException; - /** - * Used for both messageID and correlationID - */ - private String myJMSMessageID; - - public MockMessage() { - } - - public void acknowledge() throws JMSException { - notImplemented(); - } - - public void clearBody() { - notImplemented(); - } - - public void clearProperties() { - notImplemented(); - } - - public boolean getBooleanProperty(String name) { - notImplemented(); - return false; - } - - public byte getByteProperty(String name) { - notImplemented(); - return 0; - } - - public double getDoubleProperty(String name) { - notImplemented(); - return 0; - } - - public float getFloatProperty(String name) { - notImplemented(); - return 0; - } - - public int getIntProperty(String name) { - notImplemented(); - return 0; - } - - public String getJMSCorrelationID() { - return myJMSMessageID; - } - - public byte[] getJMSCorrelationIDAsBytes() { - notImplemented(); - return null; - } - - public int getJMSDeliveryMode() { - notImplemented(); - return 0; - } - - public Destination getJMSDestination() { - notImplemented(); - return null; - } - - public long getJMSExpiration() { - notImplemented(); - return 0; - } - - public String getJMSMessageID() { - return myJMSMessageID; - } - - public int getJMSPriority() { - notImplemented(); - return 0; - } - - public boolean getJMSRedelivered() { - notImplemented(); - return false; - } - - public Destination getJMSReplyTo() { - notImplemented(); - return null; - } - - public long getJMSTimestamp() { - notImplemented(); - return 0; - } - - public String getJMSType() { - notImplemented(); - return null; - } - - public long getLongProperty(String name) { - notImplemented(); - return 0; - } - - public Object getObjectProperty(String name) { - notImplemented(); - return null; - } - - public java.util.Enumeration getPropertyNames() { - notImplemented(); - return null; - } - - public short getShortProperty(String name) { - notImplemented(); - return 0; - } - - public String getStringProperty(String name) { - notImplemented(); - return null; - } - - public boolean propertyExists(String name) { - notImplemented(); - return false; - } - - public void setBooleanProperty(String name, boolean value) { - notImplemented(); - } - - public void setByteProperty(String name, byte value) { - notImplemented(); - } - - public void setDoubleProperty(String name, double value) { - notImplemented(); - } - - public void setFloatProperty(String name, float value) { - notImplemented(); - } - - public void setIntProperty(String name, int value) { - notImplemented(); - } + public void acknowledge() throws JMSException { + myAcknowledgeCount.inc(); + } + + public void setExpectedAcknowledgeCalls(int calls) { + myAcknowledgeCount.setExpected(calls); + } + + public void clearBody() { + notImplemented(); + } + + public void clearProperties() { + notImplemented(); + } + + public boolean getBooleanProperty(String name) { + notImplemented(); + return false; + } + + public byte getByteProperty(String name) { + notImplemented(); + return 0; + } + + public double getDoubleProperty(String name) { + notImplemented(); + return 0; + } + + public float getFloatProperty(String name) { + notImplemented(); + return 0; + } + + public int getIntProperty(String name) { + notImplemented(); + return 0; + } + + public String getJMSCorrelationID() { + return myJMSMessageID; + } + + public byte[] getJMSCorrelationIDAsBytes() { + notImplemented(); + return null; + } + + public int getJMSDeliveryMode() { + notImplemented(); + return 0; + } - public void setJMSCorrelationID(String jmsCorrelationID) { + public Destination getJMSDestination() { + notImplemented(); + return null; + } + + public long getJMSExpiration() { + notImplemented(); + return 0; + } + + public String getJMSMessageID() { + return myJMSMessageID; + } + + public int getJMSPriority() { + notImplemented(); + return 0; + } + + public boolean getJMSRedelivered() { + notImplemented(); + return false; + } + + public Destination getJMSReplyTo() { + notImplemented(); + return null; + } + + public long getJMSTimestamp() { + notImplemented(); + return 0; + } + + public String getJMSType() { + notImplemented(); + return null; + } + + public long getLongProperty(String name) { + notImplemented(); + return 0; + } + + public Object getObjectProperty(String name) { + notImplemented(); + return null; + } + + public java.util.Enumeration getPropertyNames() { + notImplemented(); + return null; + } + + public short getShortProperty(String name) { + notImplemented(); + return 0; + } + + public String getStringProperty(String name) { + notImplemented(); + return null; + } + + public boolean propertyExists(String name) { + notImplemented(); + return false; + } + + public void setBooleanProperty(String name, boolean value) { + notImplemented(); + } + + public void setByteProperty(String name, byte value) { + notImplemented(); + } + + public void setDoubleProperty(String name, double value) { + notImplemented(); + } + + public void setFloatProperty(String name, float value) { + notImplemented(); + } + + public void setIntProperty(String name, int value) { + notImplemented(); + } + + public void setJMSCorrelationID(String jmsCorrelationID) { mySetJMSCorrelationIDCalls.inc(); - } + } - public void setJMSCorrelationIDAsBytes(byte[] correlationID) { - notImplemented(); - } + public void setJMSCorrelationIDAsBytes(byte[] correlationID) { + notImplemented(); + } - public void setJMSDeliveryMode(int deliveryMode) { - notImplemented(); - } + public void setJMSDeliveryMode(int deliveryMode) { + notImplemented(); + } - public void setJMSDestination(Destination destination) { - notImplemented(); - } + public void setJMSDestination(Destination destination) { + notImplemented(); + } - public void setJMSExpiration(long expiration) { - notImplemented(); - } + public void setJMSExpiration(long expiration) { + notImplemented(); + } - public void setJMSMessageID(String id) { - notImplemented(); - } + public void setJMSMessageID(String id) { + notImplemented(); + } - public void setJMSPriority(int priority) { - notImplemented(); - } + public void setJMSPriority(int priority) { + notImplemented(); + } - public void setJMSRedelivered(boolean redelivered) { - notImplemented(); - } + public void setJMSRedelivered(boolean redelivered) { + notImplemented(); + } - public void setJMSReplyTo(Destination replyTo) throws JMSException { + public void setJMSReplyTo(Destination replyTo) throws JMSException { throwExceptionIfAny(); myJMSReplyTo.setActual(replyTo); - } + } + + public void setJMSTimestamp(long timestamp) { + notImplemented(); + } + + public void setJMSType(String type) { + notImplemented(); + } + + public void setLongProperty(String name, long value) { + notImplemented(); + } + + public void setObjectProperty(String name, Object value) { + notImplemented(); + } + + public void setShortProperty(String name, short value) { + notImplemented(); + } - public void setJMSTimestamp(long timestamp) { - notImplemented(); - } - - public void setJMSType(String type) { - notImplemented(); - } - - public void setLongProperty(String name, long value) { - notImplemented(); - } - - public void setObjectProperty(String name, Object value) { - notImplemented(); - } - - public void setShortProperty(String name, short value) { - notImplemented(); - } - - public void setStringProperty(String name, String value) { - notImplemented(); - } - - public void setExpectedJMSReplyTo(Destination expectedJMSReplyTo) { - myJMSReplyTo.setExpected(expectedJMSReplyTo); - } - - public void setExpectedSetJMSCorrelationIDCalls(int callCount) { - mySetJMSCorrelationIDCalls.setExpected(callCount); - } - - public void setupJMSMessageID(String jmsMessageID) { - myJMSMessageID = jmsMessageID; - } - - public void setupThrowException(JMSException e) { - myException = e; - } - - protected void throwExceptionIfAny() throws JMSException { - if (null != myException) { - throw myException; + public void setStringProperty(String name, String value) { + notImplemented(); } - } -} \ No newline at end of file + + public void setExpectedJMSReplyTo(Destination expectedJMSReplyTo) { + myJMSReplyTo.setExpected(expectedJMSReplyTo); + } + + public void setExpectedSetJMSCorrelationIDCalls(int callCount) { + mySetJMSCorrelationIDCalls.setExpected(callCount); + } + + public void setupJMSMessageID(String jmsMessageID) { + myJMSMessageID = jmsMessageID; + } + + public void setupThrowException(JMSException e) { + myException = e; + } + + protected void throwExceptionIfAny() throws JMSException { + if (null != myException) { + throw myException; + } + } +} + |
From: Steve F. <st...@m3...> - 2002-04-02 23:45:47
|
Thanks for the prompt. We'll take a look (unless you're being modest and know that this fix should really be made). One thought, though, is it likely that you would write code that gets both the string and the other type? If not, you could always set 'aBoolean" to be "false" yourself. Has this actually been a problem for you, or are you concerned about conforming to the spec? Steve ----- Original Message ----- From: "Benjamin Rosenbaum" <ben...@co...> To: <moc...@li...> Sent: Tuesday, April 02, 2002 3:26 PM Subject: [MO-java-dev] Question about MockResultSet.getString > > Hi all > > My impression is that java.sql.ResultSet.getString(...) gives you a > String representation even if the datatype is not a String (that is, it > tries to do a conversion for you). > > Currently if you do: > > String columns[] = { "aString", "anInt", "aBoolean", "aDouble" }; > Object values[] = { "FOO", new Integer(123), new Boolean(false), > new Double(0.02) }; > > ResultSet rset = new MockSingleRowResultSet(columns, values); > > return rset.getString("aBoolean"); > > You get an exception. Is this the correct behavior? > > My impression is that the proper behavior is what I get when I do > > String columns[] = { "aString", "anInt", "aBoolean", "aDouble" > }; > Object values[] = { "FOO", new Integer(123), new Boolean(false), > new Double(0.02) }; > > ResultSet rset = new MockSingleRowResultSet(columns, values) > { > public String getString(String columnName) throws > SQLException > { > return super.getObject(columnName).toString(); > } > }; > > return rset.getString("aBoolean"); > > > Should MockResultSet be changed accordingly? > > cheers > > Ben Rosenbaum > COMIT AG > > > > > > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > |
From: Benjamin R. <ben...@co...> - 2002-04-02 14:27:08
|
Hi all My impression is that java.sql.ResultSet.getString(...) gives you a String representation even if the datatype is not a String (that is, it tries to do a conversion for you). Currently if you do: String columns[] = { "aString", "anInt", "aBoolean", "aDouble" }; Object values[] = { "FOO", new Integer(123), new Boolean(false), new Double(0.02) }; ResultSet rset = new MockSingleRowResultSet(columns, values); return rset.getString("aBoolean"); You get an exception. Is this the correct behavior? My impression is that the proper behavior is what I get when I do String columns[] = { "aString", "anInt", "aBoolean", "aDouble" }; Object values[] = { "FOO", new Integer(123), new Boolean(false), new Double(0.02) }; ResultSet rset = new MockSingleRowResultSet(columns, values) { public String getString(String columnName) throws SQLException { return super.getObject(columnName).toString(); } }; return rset.getString("aBoolean"); Should MockResultSet be changed accordingly? cheers Ben Rosenbaum COMIT AG |
From: Jeff M. <je...@mk...> - 2002-03-28 18:22:41
|
I've stripped the license stuff out of this as I think it detracts from the javadoc. Although at some point we need to insert a corrected license into the source which won't be shown on every javadoc page. On Thu, 2002-03-28 at 16:30, Francois Beausoleil wrote: > Hello again ! >=20 > Here's my submission for the Null class. >=20 > Index: Null.java > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: > /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Null.= java,v > retrieving revision 1.2 > diff -u -r1.2 Null.java > --- Null.java 22 Feb 2002 10:28:44 -0000 1.2 > +++ Null.java 28 Mar 2002 16:26:39 -0000 > @@ -1,25 +1,159 @@ > package com.mockobjects.util; > =20 > +/** > + * A class that represents the <code>null</code> value. > + * The {@link com.mockobjects.util.Null Null} class is used when an > + * {@link com.mockobjects.Expectation Expectation} is set to expect noth= ing. > + * <p> > + * <b>Example usage:</b> > + * <pre> > + * public class MockX { > + * private Expectation... anExpectation =3D new Expectation...(...); > + * > + * public MockX() { > + * anExpectation.setExpectNothing(); > + * } > + * > + * public void setAnExpectation(Object value) { > + * anExpectation.setExpected(value); > + * } > + * > + * public void setActual(Object value) { > + * anExpectation.setActual(value); > + * } > + * } > + * </pre> > + * The act of calling {@link com.mockobjects.Expectation#setExpectNothin= g() > Expectation.setExpectNothing()} > + * tells the expectation that it should expect no values to change. Sin= ce > + * all {@link com.mockobjects.util.Null Null} objects are equal to thems= elves, > + * most expectations set their expected value to an instance of > + * {@link com.mockobjects.util.Null Null}, and at the same time, set the= ir > actual > + * value to another instance of {@link com.mockobjects.util.Null Null}. > + * This way, when {@link com.mockobjects.Verifiable#verify() verify()} c= hecks > + * expectations, they will compare two {@link com.mockobjects.util.Null = Null} > + * objects together, which is guaranteed to succeed. > + * <pre> > + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + * The Apache Software License, Version 1.1 > + * > + * Copyright (c) 2001 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 acknowledgment: > + * "This product includes software developed by the > + * Apache Software Foundation (http://www.apache.org/)." > + * Alternately, this acknowledgment may appear in the software itself= , > + * if and wherever such third-party acknowledgments normally appear. > + * > + * 4. The names "Apache" 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 name, without prior written > + * permission of the Apache Software Foundation. > + * > + * 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. > + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + * > + * 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/>. > + * </pre> > + * @author <a href=3D"mailto:fb...@us...">Francois Beauso= leil > (fb...@us...)</a> > + * @version $Id$ > + */ > public class Null { > + /** > + * The default description for all {@link com.mockobjects.util.Null = Null} > + * objects. > + * This String is equal to "<code>Null</code>". > + */ > + public static final String DEFAULT_DESCRIPTION =3D "Null"; > + > + /** > + * A default {@link com.mockobjects.util.Null Null} object. > + * Instead of always instantiating new {@link com.mockobjects.util.N= ull > Null} > + * objects, consider using a reference to this object instead. This = way, > + * the virtual machine will not be taking the time required to insta= ntiate > + * an object everytime it is required. > + */ > + public static final Null NULL =3D new Null(); > + > + /** > + * The description of this {@link com.mockobjects.util.Null Null} ob= ject. > + */ > final private String myDescription; > =20 > + /** > + * Instantiates a new {@link com.mockobjects.util.Null Null} object = with > + * the default description. > + * @see com.mockobjects.util.Null#DEFAULT_DESCRIPTION > + */ > public Null() { > - this("Null"); > + this(DEFAULT_DESCRIPTION); > } > =20 > + /** > + * Instantiates a new {@link com.mockobjects.util.Null Null} object = and > + * sets it's description. > + * @param description > + */ > public Null(String description) { > super(); > myDescription =3D description; > } > =20 > + /** > + * Determines equality between two objects. > + * {@link com.mockobjects.util.Null Null} objects are only equal to > + * another instance of themselves. > + * @param other > + */ > public boolean equals(Object other) { > return other instanceof Null; > } > =20 > + /** > + * Returns this {@link com.mockobjects.util.Null Null} object's hash= Code. > + * All {@link com.mockobjects.util.Null Null} return the same > + * hashCode value. > + */ > public int hashCode() { > - return "Null".hashCode(); > + return 0; > } > =20 > + /** > + * Returns a string representation of this {@link > com.mockobjects.util.Null Null} > + * object. > + * This merely returns the string passed to the constructor initiall= y. > + */ > public String toString() { > return myDescription; > } >=20 >=20 > __________________________________________________________ > L=E8che-vitrine ou l=E8che-=E9cran ? > magasinage.yahoo.ca >=20 > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev --=20 |
From: Jeff M. <je...@mk...> - 2002-03-28 18:20:38
|
Didn't actual apply this one as the problem is the class name the @see points to, not the text. I've fixed the problem anyways. On Thu, 2002-03-28 at 16:33, Francois Beausoleil wrote: > Hello ! >=20 > Well, a final one for today. The @see tag contained an error which was > generating a warning during generation of the JavaDocs. Problem gone ! >=20 > Bye ! > Francois Beausoleil >=20 > Index: Verifiable.java > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: > /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/Verifiable= .java,v > retrieving revision 1.2 > diff -u -r1.2 Verifiable.java > --- Verifiable.java 27 Aug 2001 01:14:31 -0000 1.2 > +++ Verifiable.java 28 Mar 2002 16:32:52 -0000 > @@ -4,7 +4,7 @@ > * A <em>Verifiable</em> is an object that can confirm at the end of a u= nit > test that > * the correct behvaiour has occurred. > * > - * @see com.mockobjects.util.Verifiable to check all the Verifiables in = an > object. > + * @see com.mockobjects.util.Verifiable > */ > public interface Verifiable { > =20 >=20 >=20 > __________________________________________________________ > L=E8che-vitrine ou l=E8che-=E9cran ? > magasinage.yahoo.ca >=20 > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev --=20 |
From: Jeff M. <cus...@us...> - 2002-03-28 18:16:58
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test In directory usw-pr-cvs1:/tmp/cvs-serv6890/core/com/mockobjects/test Modified Files: TestNull.java Log Message: More documentaion changes from Francois Beausoleil Index: TestNull.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test/TestNull.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestNull.java 22 Feb 2002 10:28:44 -0000 1.1 +++ TestNull.java 28 Mar 2002 18:16:54 -0000 1.2 @@ -29,6 +29,10 @@ assertEquals("Should be same value", new Null("one"), new Null("two")); assertEquals("Should be same hashCode", new Null("one").hashCode(), new Null("two").hashCode()); + + // Compare with other objects to assert that they are not equal + assertEquals("Not equal to something else", false, new Null("one").equals("one")); + assertEquals("Not equal to something else", false, new Null().equals(new Integer(2))); } public void testDescription() { |
From: Jeff M. <cus...@us...> - 2002-03-28 18:16:58
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv6890/j2ee/common/com/mockobjects/servlet Modified Files: MockServletContext.java Log Message: More documentaion changes from Francois Beausoleil Index: MockServletContext.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet/MockServletContext.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockServletContext.java 23 Feb 2002 18:50:35 -0000 1.1 +++ MockServletContext.java 28 Mar 2002 18:16:54 -0000 1.2 @@ -62,6 +62,7 @@ log(string); expectedLogThrowable.setActual(t); } + public void setExpectedLogThrowable(Throwable throwable){ expectedLogThrowable.setExpected(throwable); } |
From: Jeff M. <cus...@us...> - 2002-03-28 18:16:58
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util In directory usw-pr-cvs1:/tmp/cvs-serv6890/core/com/mockobjects/util Modified Files: Null.java Verifier.java Added Files: package.html Log Message: More documentaion changes from Francois Beausoleil --- NEW FILE: package.html --- <body> A collection of utilities for the <a href="http://www.mockobjects.com/">MockObjects</a> framework. </body> Index: Null.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Null.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Null.java 22 Feb 2002 10:28:44 -0000 1.2 +++ Null.java 28 Mar 2002 18:16:54 -0000 1.3 @@ -1,25 +1,105 @@ package com.mockobjects.util; +/** + * A class that represents the <code>null</code> value. + * The {@link com.mockobjects.util.Null Null} class is used when an + * {@link com.mockobjects.Expectation Expectation} is set to expect nothing. + * <p> + * <b>Example usage:</b> + * <pre> + * public class MockX { + * private Expectation... anExpectation = new Expectation...(...); + * + * public MockX() { + * anExpectation.setExpectNothing(); + * } + * + * public void setAnExpectation(Object value) { + * anExpectation.setExpected(value); + * } + * + * public void setActual(Object value) { + * anExpectation.setActual(value); + * } + * } + * </pre> + * The act of calling {@link com.mockobjects.Expectation#setExpectNothing() Expectation.setExpectNothing()} + * tells the expectation that it should expect no values to change. Since + * all {@link com.mockobjects.util.Null Null} objects are equal to themselves, + * most expectations set their expected value to an instance of + * {@link com.mockobjects.util.Null Null}, and at the same time, set their actual + * value to another instance of {@link com.mockobjects.util.Null Null}. + * This way, when {@link com.mockobjects.Verifiable#verify() verify()} checks + * expectations, they will compare two {@link com.mockobjects.util.Null Null} + * objects together, which is guaranteed to succeed. + * @author <a href="mailto:fb...@us...">Francois Beausoleil (fb...@us...)</a> + * @version $Id$ + */ public class Null { + /** + * The default description for all {@link com.mockobjects.util.Null Null} + * objects. + * This String is equal to "<code>Null</code>". + */ + public static final String DEFAULT_DESCRIPTION = "Null"; + + /** + * A default {@link com.mockobjects.util.Null Null} object. + * Instead of always instantiating new {@link com.mockobjects.util.Null Null} + * objects, consider using a reference to this object instead. This way, + * the virtual machine will not be taking the time required to instantiate + * an object everytime it is required. + */ + public static final Null NULL = new Null(); + + /** + * The description of this {@link com.mockobjects.util.Null Null} object. + */ final private String myDescription; + /** + * Instantiates a new {@link com.mockobjects.util.Null Null} object with + * the default description. + * @see com.mockobjects.util.Null#DEFAULT_DESCRIPTION + */ public Null() { - this("Null"); + this(DEFAULT_DESCRIPTION); } + /** + * Instantiates a new {@link com.mockobjects.util.Null Null} object and + * sets it's description. + * @param description + */ public Null(String description) { super(); myDescription = description; } + /** + * Determines equality between two objects. + * {@link com.mockobjects.util.Null Null} objects are only equal to + * another instance of themselves. + * @param other + */ public boolean equals(Object other) { return other instanceof Null; } + /** + * Returns this {@link com.mockobjects.util.Null Null} object's hashCode. + * All {@link com.mockobjects.util.Null Null} return the same + * hashCode value. + */ public int hashCode() { - return "Null".hashCode(); + return 0; } + /** + * Returns a string representation of this {@link com.mockobjects.util.Null Null} + * object. + * This merely returns the string passed to the constructor initially. + */ public String toString() { return myDescription; } Index: Verifier.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Verifier.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Verifier.java 28 Mar 2002 09:57:37 -0000 1.2 +++ Verifier.java 28 Mar 2002 18:16:54 -0000 1.3 @@ -29,60 +29,6 @@ * </pre> * This example shows how most mocks implement * {@link com.mockobjects.Verifiable Verifiable}, i.e.: by delegation. - * <pre> - * ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 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 acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" 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 name, without prior written - * permission of the Apache Software Foundation. - * - * 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/>. - * </pre> * @see com.mockobjects.Expectation * @see com.mockobjects.Verifiable * @author <a href="mailto:fb...@us...">Francois Beausoleil (fb...@us...)</a> |
From: Jeff M. <cus...@us...> - 2002-03-28 18:16:58
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory usw-pr-cvs1:/tmp/cvs-serv6890/core/com/mockobjects Modified Files: Verifiable.java Log Message: More documentaion changes from Francois Beausoleil Index: Verifiable.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/Verifiable.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Verifiable.java 27 Aug 2001 01:14:31 -0000 1.2 +++ Verifiable.java 28 Mar 2002 18:16:54 -0000 1.3 @@ -4,7 +4,7 @@ * A <em>Verifiable</em> is an object that can confirm at the end of a unit test that * the correct behvaiour has occurred. * - * @see com.mockobjects.util.Verifiable to check all the Verifiables in an object. + * @see com.mockobjects.util.Verifier Verifier to check all the Verifiables in an object. */ public interface Verifiable { |
From: <fra...@ya...> - 2002-03-28 16:33:41
|
Hello ! Well, a final one for today. The @see tag contained an error which was generating a warning during generation of the JavaDocs. Problem gone ! Bye ! Francois Beausoleil Index: Verifiable.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/Verifiable.java,v retrieving revision 1.2 diff -u -r1.2 Verifiable.java --- Verifiable.java 27 Aug 2001 01:14:31 -0000 1.2 +++ Verifiable.java 28 Mar 2002 16:32:52 -0000 @@ -4,7 +4,7 @@ * A <em>Verifiable</em> is an object that can confirm at the end of a unit test that * the correct behvaiour has occurred. * - * @see com.mockobjects.util.Verifiable to check all the Verifiables in an object. + * @see com.mockobjects.util.Verifiable */ public interface Verifiable { __________________________________________________________ Lèche-vitrine ou lèche-écran ? magasinage.yahoo.ca |
From: <fra...@ya...> - 2002-03-28 16:32:31
|
Hello again ! I added tests in equality to assert that null objects are not equal to other classes of objects. I tested against a string with the same value as the null's description, and against java.lang.Integer. I guess that at least tests the simple cases. A question: If Null is subclassed, should the subclass still be equal to Null ? If I get directions on how you would want to process that, I'll write the proper test case. Thanks ! Francois Beausoleil Index: TestNull.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/test/TestNull.java,v retrieving revision 1.1 diff -u -r1.1 TestNull.java --- TestNull.java 22 Feb 2002 10:28:44 -0000 1.1 +++ TestNull.java 28 Mar 2002 16:26:54 -0000 @@ -29,6 +29,10 @@ assertEquals("Should be same value", new Null("one"), new Null("two")); assertEquals("Should be same hashCode", new Null("one").hashCode(), new Null("two").hashCode()); + + // Compare with other objects to assert that they are not equal + assertEquals("Not equal to something else", false, new Null("one").equals("one")); + assertEquals("Not equal to something else", false, new Null().equals(new Integer(2))); } public void testDescription() { __________________________________________________________ Lèche-vitrine ou lèche-écran ? magasinage.yahoo.ca |
From: <fra...@ya...> - 2002-03-28 16:30:18
|
Hello again ! Here's my submission for the Null class. Index: Null.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Null.java,v retrieving revision 1.2 diff -u -r1.2 Null.java --- Null.java 22 Feb 2002 10:28:44 -0000 1.2 +++ Null.java 28 Mar 2002 16:26:39 -0000 @@ -1,25 +1,159 @@ package com.mockobjects.util; +/** + * A class that represents the <code>null</code> value. + * The {@link com.mockobjects.util.Null Null} class is used when an + * {@link com.mockobjects.Expectation Expectation} is set to expect nothing. + * <p> + * <b>Example usage:</b> + * <pre> + * public class MockX { + * private Expectation... anExpectation = new Expectation...(...); + * + * public MockX() { + * anExpectation.setExpectNothing(); + * } + * + * public void setAnExpectation(Object value) { + * anExpectation.setExpected(value); + * } + * + * public void setActual(Object value) { + * anExpectation.setActual(value); + * } + * } + * </pre> + * The act of calling {@link com.mockobjects.Expectation#setExpectNothing() Expectation.setExpectNothing()} + * tells the expectation that it should expect no values to change. Since + * all {@link com.mockobjects.util.Null Null} objects are equal to themselves, + * most expectations set their expected value to an instance of + * {@link com.mockobjects.util.Null Null}, and at the same time, set their actual + * value to another instance of {@link com.mockobjects.util.Null Null}. + * This way, when {@link com.mockobjects.Verifiable#verify() verify()} checks + * expectations, they will compare two {@link com.mockobjects.util.Null Null} + * objects together, which is guaranteed to succeed. + * <pre> + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 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 acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" 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 name, without prior written + * permission of the Apache Software Foundation. + * + * 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/>. + * </pre> + * @author <a href="mailto:fb...@us...">Francois Beausoleil (fb...@us...)</a> + * @version $Id$ + */ public class Null { + /** + * The default description for all {@link com.mockobjects.util.Null Null} + * objects. + * This String is equal to "<code>Null</code>". + */ + public static final String DEFAULT_DESCRIPTION = "Null"; + + /** + * A default {@link com.mockobjects.util.Null Null} object. + * Instead of always instantiating new {@link com.mockobjects.util.Null Null} + * objects, consider using a reference to this object instead. This way, + * the virtual machine will not be taking the time required to instantiate + * an object everytime it is required. + */ + public static final Null NULL = new Null(); + + /** + * The description of this {@link com.mockobjects.util.Null Null} object. + */ final private String myDescription; + /** + * Instantiates a new {@link com.mockobjects.util.Null Null} object with + * the default description. + * @see com.mockobjects.util.Null#DEFAULT_DESCRIPTION + */ public Null() { - this("Null"); + this(DEFAULT_DESCRIPTION); } + /** + * Instantiates a new {@link com.mockobjects.util.Null Null} object and + * sets it's description. + * @param description + */ public Null(String description) { super(); myDescription = description; } + /** + * Determines equality between two objects. + * {@link com.mockobjects.util.Null Null} objects are only equal to + * another instance of themselves. + * @param other + */ public boolean equals(Object other) { return other instanceof Null; } + /** + * Returns this {@link com.mockobjects.util.Null Null} object's hashCode. + * All {@link com.mockobjects.util.Null Null} return the same + * hashCode value. + */ public int hashCode() { - return "Null".hashCode(); + return 0; } + /** + * Returns a string representation of this {@link com.mockobjects.util.Null Null} + * object. + * This merely returns the string passed to the constructor initially. + */ public String toString() { return myDescription; } __________________________________________________________ Lèche-vitrine ou lèche-écran ? magasinage.yahoo.ca |
From: <fra...@ya...> - 2002-03-28 16:29:33
|
Hi ! A simple description for the package. Sometimes, simple descriptions are the best... I can't think of anything else to say about the util package. Anybody wants to add some more ? ============= package.html <body> A collection of utilities for the <a href="http://www.mockobjects.com/"> MockObjects</a> framework. </body> __________________________________________________________ Lèche-vitrine ou lèche-écran ? magasinage.yahoo.ca |
From: Jeff M. <je...@mk...> - 2002-03-28 10:05:07
|
If I move all the jdk stuff out of the core dir. Should it be moved to src/jdk/common? Then we can think about src/jdk/1.1 src/jdk/1.2 src/jdk/1.3 src/jdk/1.4 -- |
From: Jeff M. <cus...@us...> - 2002-03-28 09:57:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util In directory usw-pr-cvs1:/tmp/cvs-serv31742/src/core/com/mockobjects/util Modified Files: Verifier.java Log Message: Applied patch from Francois Beausoleil (fb...@us...) Index: Verifier.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Verifier.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Verifier.java 29 Jul 2001 19:50:24 -0000 1.1 +++ Verifier.java 28 Mar 2002 09:57:37 -0000 1.2 @@ -1,41 +1,176 @@ package com.mockobjects.util; -import junit.framework.AssertionFailedError; +import com.mockobjects.Verifiable; + import java.lang.reflect.Field; -import com.mockobjects.*; +/** + * Helper class to verify all {@link com.mockobjects.Expectation Expectation}s + * of an object. + * The {@link com.mockobjects.util.Verifier Verifier} class provides two static + * methods to verify objects: + * <ul> + * <li>{@link com.mockobjects.util.Verifier#verifyObject(java.lang.Object) verifyObject(Object)}</li> + * <li>{@link com.mockobjects.util.Verifier#verifyField(java.lang.reflect.Field, java.lang.Object) verifyField(Field, Object)}</li> + * </ul> + * These two methods can be used to verify any expectation to assert that + * they still hold.<p> + * <b>Example usage:</b><p> + * Verifying all expectations on one object at a time:<p> + * <pre> + * public class MockX implements Verifiable { + * private Expectation... anExpectation = new Expectation...(...); + * private Expectation... aSecondExpectation = new Expectation...(...); + * + * public void verify() { + * Verifier.verifyObject(this); + * } + * } + * </pre> + * This example shows how most mocks implement + * {@link com.mockobjects.Verifiable Verifiable}, i.e.: by delegation. + * <pre> + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 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 acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" 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 name, without prior written + * permission of the Apache Software Foundation. + * + * 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/>. + * </pre> + * @see com.mockobjects.Expectation + * @see com.mockobjects.Verifiable + * @author <a href="mailto:fb...@us...">Francois Beausoleil (fb...@us...)</a> + * @version $Id$ + */ public class Verifier { - + /** + * Public, no-op constructor. + * You should not need to instantiate this object, since all methods + * are <code>static</code>. + */ public Verifier() { super(); } - static public void verifyField(Field field, Object anObject) { + /** + * Calls {@link com.mockobjects.Verifiable#verify() Verifiable.verify()} + * on <code>aField</code>. + * This method will result in a no-op if <code>aField</code> does not + * implement {@link com.mockobjects.Verifiable Verifiable}. + * @param aField The field which needs to be checked. + * @param anObject The object in which <code>aField</code> is instantiated. + */ + static public void verifyField(Field aField, Object anObject) { try { - field.setAccessible(true); - Object fieldObject = field.get(anObject); - if (fieldObject instanceof Verifiable) { - ((Verifiable) fieldObject).verify(); + aField.setAccessible(true); + Object fieldObject = aField.get(anObject); + + if (isVerifiable(fieldObject)) { + ((Verifiable)fieldObject).verify(); } - } catch (IllegalAccessException ex) { - throw new AssertionFailedError( - "Could not access field: " + field.getName()); + } catch (IllegalAccessException e) { + junit.framework.Assert.fail("Could not access field " + + aField.getName()); } } + /** + * Recursively verifies all fields of the passed object. + * @param anObject The object to be verified. + */ static public void verifyObject(Object anObject) { verifyObjectFromClass(anObject, anObject.getClass()); } + /** + * Verifies all fields of the passed object, as if it were of the + * passed class. + * This method will be called recursively for each superclass of + * <code>anObject</code>, until the + * {@link com.mockobjects.util.Verifier#isRootClass(java.lang.Class) isRootClass(Class)} + * returns <code>true</code>, at which point the recursion will stop. + * @param anObject The object on which to verify fields. + * @param aClass The apparent class of <code>anObject</code> + */ static private void verifyObjectFromClass(Object anObject, Class aClass) { - if (aClass.equals(Object.class)) { + if (isRootClass(aClass)) { return; } + verifyObjectFromClass(anObject, aClass.getSuperclass()); Field[] fields = aClass.getDeclaredFields(); for (int i = 0; i < fields.length; ++i) { verifyField(fields[i], anObject); } + } + + /** + * Returns a <code>boolean</code> indicating whether or not the passed + * object is {@link com.mockobjects.Verifiable Verifiable}. + * @returns <code>true</code> if <code>anObject</code> implements + * {@link com.mockobjects.Verifiable Verifiable}, <code>false</code> + * otherwise. + */ + private static boolean isVerifiable(Object anObject) { + return anObject instanceof Verifiable; + } + + /** + * Returns a <code>boolean</code> indicating whether or not the passed + * class is the root class. + * The root class is where recursive searching for fields should stop. + * Usually, this would be {@link java.lang.Object}. + * @returns <code>true</code> if <code>aClass</code> is the root class, + * <code>false</code> otherwise. + */ + private static boolean isRootClass(Class aClass) { + return aClass.equals(Object.class); } } |
From: Jeff M. <je...@mk...> - 2002-03-27 17:01:58
|
Thanks, I'll try and get this in asap. No need to send diffs for new files just send the file and I'll stick it in. Not sure about the license think that's an outstanding issue. On Wed, 2002-03-27 at 05:50, Francois Beausoleil wrote: > Hi all ! >=20 > Here is some documentation for the above mentionned class. I also refact= ored a > bit. The tests still run, so no problem there :) I created two query me= thods: > isRootClass(Class) and isVerifiable(Object). The methods are > self-explanatory, but they are documented anyway, as requested in the Cod= e > section of the ToDo page. >=20 > You will notice that most lines have been touched. This is because I use > IntelliJ's IdeaJ, and I have reformatted the source code according to the > coding conventions. >=20 > Would someone create a blank "package.html" in com.mockobjects.util and > com.mockobjects ? This would allow me to diff against them to send my > submissions. >=20 > I do have one question though: Should the license be copied verbatim fro= m the > license page, or should a reference to it be made ? I copied the license= , as I > thought that this would be the best way to show the information. Please = advise > on how to proceed for this. >=20 > Thanks ! > Francois Beausoleil >=20 > Index: Verifier.java > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: > /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Verif= ier.java,v > retrieving revision 1.1 > diff -u -r1.1 Verifier.java > --- Verifier.java 29 Jul 2001 19:50:24 -0000 1.1 > +++ Verifier.java 27 Mar 2002 05:47:32 -0000 > @@ -1,41 +1,176 @@ > package com.mockobjects.util; > =20 > -import junit.framework.AssertionFailedError; > +import com.mockobjects.Verifiable; > + > import java.lang.reflect.Field; > -import com.mockobjects.*; > =20 > +/** > + * Helper class to verify all {@link com.mockobjects.Expectation Expecta= tion}s > + * of an object. > + * The {@link com.mockobjects.util.Verifier Verifier} class provides two > static > + * methods to verify objects: > + * <ul> > + * <li>{@link com.mockobjects.util.Verifier#verifyObject(java.lang.Objec= t) > verifyObject(Object)}</li> > + * <li>{@link > com.mockobjects.util.Verifier#verifyField(java.lang.reflect.Field, > java.lang.Object) verifyField(Field, Object)}</li> > + * </ul> > + * These two methods can be used to verify any expectation to assert tha= t > + * they still hold.<p> > + * <b>Example usage:</b><p> > + * Verifying all expectations on one object at a time:<p> > + * <pre> > + * public class MockX implements Verifiable { > + * private Expectation... anExpectation =3D new Expectation...(...); > + * private Expectation... aSecondExpectation =3D new Expectation...(.= ..); > + * > + * public void verify() { > + * Verifier.verifyObject(this); > + * } > + * } > + * </pre> > + * This example shows how most mocks implement > + * {@link com.mockobjects.Verifiable Verifiable}, i.e.: by delegation. > + * <pre> > + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + * The Apache Software License, Version 1.1 > + * > + * Copyright (c) 2001 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 acknowledgment: > + * "This product includes software developed by the > + * Apache Software Foundation (http://www.apache.org/)." > + * Alternately, this acknowledgment may appear in the software itself= , > + * if and wherever such third-party acknowledgments normally appear. > + * > + * 4. The names "Apache" and "Apache Software Foundation" must not be=20 > + * used to endorse or promote products derived from this software=20 > + * without prior written permission. For written permission, please=20 > + * contact ap...@ap.... > + * > + * 5. Products derived from this software may not be called "Apache", > + * nor may "Apache" appear in their name, without prior written=20 > + * permission of the Apache Software Foundation. > + * > + * 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. > + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + * > + * 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/>. > + * </pre> > + * @see com.mockobjects.Expectation > + * @see com.mockobjects.Verifiable > + * @author <a href=3D"mailto:fb...@us...">Francois Beauso= leil > (fb...@us...)</a> > + * @version $Id$ > + */ > public class Verifier { > - > + /** > + * Public, no-op constructor. > + * You should not need to instantiate this object, since all methods > + * are <code>static</code>. > + */ > public Verifier() { > super(); > } > =20 > - static public void verifyField(Field field, Object anObject) { > + /** > + * Calls {@link com.mockobjects.Verifiable#verify() Verifiable.verif= y()} > + * on <code>aField</code>. > + * This method will result in a no-op if <code>aField</code> does no= t > + * implement {@link com.mockobjects.Verifiable Verifiable}. > + * @param aField The field which needs to be checked. > + * @param anObject The object in which <code>aField</code> is > instantiated. > + */ > + static public void verifyField(Field aField, Object anObject) { > try { > - field.setAccessible(true); > - Object fieldObject =3D field.get(anObject); > - if (fieldObject instanceof Verifiable) { > - ((Verifiable) fieldObject).verify(); > + aField.setAccessible(true); > + Object fieldObject =3D aField.get(anObject); > + > + if (isVerifiable(fieldObject)) { > + ((Verifiable)fieldObject).verify(); > } > - } catch (IllegalAccessException ex) { > - throw new AssertionFailedError( > - "Could not access field: " + field.getName()); > + } catch (IllegalAccessException e) { > + junit.framework.Assert.fail("Could not access field " > + + aField.getName()); > } > } > =20 > + /** > + * Recursively verifies all fields of the passed object. > + * @param anObject The object to be verified. > + */ > static public void verifyObject(Object anObject) { > verifyObjectFromClass(anObject, anObject.getClass()); > } > =20 > + /** > + * Verifies all fields of the passed object, as if it were of the > + * passed class. > + * This method will be called recursively for each superclass of > + * <code>anObject</code>, until the > + * {@link com.mockobjects.util.Verifier#isRootClass(java.lang.Class) > isRootClass(Class)} > + * returns <code>true</code>, at which point the recursion will stop= . > + * @param anObject The object on which to verify fields. > + * @param aClass The apparent class of <code>anObject</code> > + */ > static private void verifyObjectFromClass(Object anObject, Class aCl= ass) { > - if (aClass.equals(Object.class)) { > + if (isRootClass(aClass)) { > return; > } > + > verifyObjectFromClass(anObject, aClass.getSuperclass()); > =20 > Field[] fields =3D aClass.getDeclaredFields(); > for (int i =3D 0; i < fields.length; ++i) { > verifyField(fields[i], anObject); > } > + } > + > + /** > + * Returns a <code>boolean</code> indicating whether or not the pass= ed > + * object is {@link com.mockobjects.Verifiable Verifiable}. > + * @returns <code>true</code> if <code>anObject</code> implements > + * {@link com.mockobjects.Verifiable Verifiable}, <code>false</code> > + * otherwise. > + */ > + private static boolean isVerifiable(Object anObject) { > + return anObject instanceof Verifiable; > + } > + > + /** > + * Returns a <code>boolean</code> indicating whether or not the pass= ed > + * class is the root class. > + * The root class is where recursive searching for fields should sto= p. > + * Usually, this would be {@link java.lang.Object}. > + * @returns <code>true</code> if <code>aClass</code> is the root cla= ss, > + * <code>false</code> otherwise. > + */ > + private static boolean isRootClass(Class aClass) { > + return aClass.equals(Object.class); > } > } >=20 >=20 > __________________________________________________________ > L=E8che-vitrine ou l=E8che-=E9cran ? > magasinage.yahoo.ca >=20 > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev --=20 |
From: <fra...@ya...> - 2002-03-27 05:50:10
|
Hi all ! Here is some documentation for the above mentionned class. I also refactored a bit. The tests still run, so no problem there :) I created two query methods: isRootClass(Class) and isVerifiable(Object). The methods are self-explanatory, but they are documented anyway, as requested in the Code section of the ToDo page. You will notice that most lines have been touched. This is because I use IntelliJ's IdeaJ, and I have reformatted the source code according to the coding conventions. Would someone create a blank "package.html" in com.mockobjects.util and com.mockobjects ? This would allow me to diff against them to send my submissions. I do have one question though: Should the license be copied verbatim from the license page, or should a reference to it be made ? I copied the license, as I thought that this would be the best way to show the information. Please advise on how to proceed for this. Thanks ! Francois Beausoleil Index: Verifier.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/util/Verifier.java,v retrieving revision 1.1 diff -u -r1.1 Verifier.java --- Verifier.java 29 Jul 2001 19:50:24 -0000 1.1 +++ Verifier.java 27 Mar 2002 05:47:32 -0000 @@ -1,41 +1,176 @@ package com.mockobjects.util; -import junit.framework.AssertionFailedError; +import com.mockobjects.Verifiable; + import java.lang.reflect.Field; -import com.mockobjects.*; +/** + * Helper class to verify all {@link com.mockobjects.Expectation Expectation}s + * of an object. + * The {@link com.mockobjects.util.Verifier Verifier} class provides two static + * methods to verify objects: + * <ul> + * <li>{@link com.mockobjects.util.Verifier#verifyObject(java.lang.Object) verifyObject(Object)}</li> + * <li>{@link com.mockobjects.util.Verifier#verifyField(java.lang.reflect.Field, java.lang.Object) verifyField(Field, Object)}</li> + * </ul> + * These two methods can be used to verify any expectation to assert that + * they still hold.<p> + * <b>Example usage:</b><p> + * Verifying all expectations on one object at a time:<p> + * <pre> + * public class MockX implements Verifiable { + * private Expectation... anExpectation = new Expectation...(...); + * private Expectation... aSecondExpectation = new Expectation...(...); + * + * public void verify() { + * Verifier.verifyObject(this); + * } + * } + * </pre> + * This example shows how most mocks implement + * {@link com.mockobjects.Verifiable Verifiable}, i.e.: by delegation. + * <pre> + * ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 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 acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" 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 name, without prior written + * permission of the Apache Software Foundation. + * + * 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/>. + * </pre> + * @see com.mockobjects.Expectation + * @see com.mockobjects.Verifiable + * @author <a href="mailto:fb...@us...">Francois Beausoleil (fb...@us...)</a> + * @version $Id$ + */ public class Verifier { - + /** + * Public, no-op constructor. + * You should not need to instantiate this object, since all methods + * are <code>static</code>. + */ public Verifier() { super(); } - static public void verifyField(Field field, Object anObject) { + /** + * Calls {@link com.mockobjects.Verifiable#verify() Verifiable.verify()} + * on <code>aField</code>. + * This method will result in a no-op if <code>aField</code> does not + * implement {@link com.mockobjects.Verifiable Verifiable}. + * @param aField The field which needs to be checked. + * @param anObject The object in which <code>aField</code> is instantiated. + */ + static public void verifyField(Field aField, Object anObject) { try { - field.setAccessible(true); - Object fieldObject = field.get(anObject); - if (fieldObject instanceof Verifiable) { - ((Verifiable) fieldObject).verify(); + aField.setAccessible(true); + Object fieldObject = aField.get(anObject); + + if (isVerifiable(fieldObject)) { + ((Verifiable)fieldObject).verify(); } - } catch (IllegalAccessException ex) { - throw new AssertionFailedError( - "Could not access field: " + field.getName()); + } catch (IllegalAccessException e) { + junit.framework.Assert.fail("Could not access field " + + aField.getName()); } } + /** + * Recursively verifies all fields of the passed object. + * @param anObject The object to be verified. + */ static public void verifyObject(Object anObject) { verifyObjectFromClass(anObject, anObject.getClass()); } + /** + * Verifies all fields of the passed object, as if it were of the + * passed class. + * This method will be called recursively for each superclass of + * <code>anObject</code>, until the + * {@link com.mockobjects.util.Verifier#isRootClass(java.lang.Class) isRootClass(Class)} + * returns <code>true</code>, at which point the recursion will stop. + * @param anObject The object on which to verify fields. + * @param aClass The apparent class of <code>anObject</code> + */ static private void verifyObjectFromClass(Object anObject, Class aClass) { - if (aClass.equals(Object.class)) { + if (isRootClass(aClass)) { return; } + verifyObjectFromClass(anObject, aClass.getSuperclass()); Field[] fields = aClass.getDeclaredFields(); for (int i = 0; i < fields.length; ++i) { verifyField(fields[i], anObject); } + } + + /** + * Returns a <code>boolean</code> indicating whether or not the passed + * object is {@link com.mockobjects.Verifiable Verifiable}. + * @returns <code>true</code> if <code>anObject</code> implements + * {@link com.mockobjects.Verifiable Verifiable}, <code>false</code> + * otherwise. + */ + private static boolean isVerifiable(Object anObject) { + return anObject instanceof Verifiable; + } + + /** + * Returns a <code>boolean</code> indicating whether or not the passed + * class is the root class. + * The root class is where recursive searching for fields should stop. + * Usually, this would be {@link java.lang.Object}. + * @returns <code>true</code> if <code>aClass</code> is the root class, + * <code>false</code> otherwise. + */ + private static boolean isRootClass(Class aClass) { + return aClass.equals(Object.class); } } __________________________________________________________ Lèche-vitrine ou lèche-écran ? magasinage.yahoo.ca |
From: Jeff M. <je...@mk...> - 2002-03-21 13:28:38
|
Sorry about this, we're all pretty busy people, but that's not much of an excuse. Generally we try to follow the Apache Software Foundations process for patches etc. If you can submit patch files created using "diff -u" (unified diff format) against the latest cvs source code, we'll try to get them applied asap. On Thu, 2002-03-21 at 13:12, Oskar Hannesson wrote: > Hi. > I had the same problem some months ago and I was told to post my code to > this group. > I did so but it was a waste of effort. > I havent seen any of my changes and utils finding its way in to the released > code. > So now I'm stuck with my version of the mock stuff since the original one > can't handle my needs. > I hope you have a better luck. > Regards > Oskar Hgannesson > deCode Genetics. > > > -----Original Message----- > From: moc...@li... > [mailto:moc...@li...]On Behalf Of > Benjamin Rosenbaum > Sent: 21. mars 2002 12:52 > To: moc...@li... > Subject: [MO-java-dev] submitting new mock objects? > > > > Hi all, > > this is undoubtedly a dumb newbie question, so feel free to point me to > the appropriate FAQ. I couldn't find one. > > I am using the latest mockobjects release and enjoying it (even in its > infant state). I find myself implementing lots of mock objects that are > possibly of general utility -- MockServlet, MockServetConfig, versions > of MockPreparedStatement and MockConnection that support batching of SQL > updates (and verification thereof). > > What is the protocol for donating such classes? Would anyone be > interested? Time constraints of my job, alas, do not allow me to take on > general "we need this done next" tasks, but I would be happy to donate > the mock objects that fall naturally out of our development, in the > hopes that they would be incorporated into the mockobjects library. > > I'm happy to twiddle the brackets and add "my" in front of member vars > in order to follow the coding conventions, but I won't be able to do a > whole lot of work on them other than what we need here... > > Do I need to email them to an official code submitter? Post them as > suggestions? Check them in myself? Or is this kind of random submission > of objects more trouble than it's worth? > > Let me know. > > Thanks, > > Benjamin Rosenbaum > COMIT Financial Systems > > > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev > > > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev -- |