|
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> |