JET

edu.utep.cs.et.gui.tester
Class EtMethod

java.lang.Object
  extended by edu.utep.cs.et.gui.tester.EtMethod
All Implemented Interfaces:
Constants, MethodWrapper

 class EtMethod
extends Object
implements MethodWrapper, Constants

A wrapper for the Method and Constructor classes to add test-related data such as test cases.

Version:
$Revision: 1.21 $
Author:
Yoonsik Cheon

Field Summary
private  Class cut
          The class under test.
private  boolean isTested
          True if the wrapped method has already been tested.
private  int kind
          The kind of wrapped method.
private  Member meth
          The wrapped method or constructor that is being tested.
private  EtTestCase selectedTestcase
          The currently selected test case.
private  List<EtTestCase> testcases
          The generated test cases of the wrapped member, meth.
 
Fields inherited from interface edu.utep.cs.et.rat.MethodWrapper
BASIC_CONSTRUCTOR, EXTENDED_CONSTRUCTOR, MUTATOR, OBSERVER
 
Fields inherited from interface edu.utep.cs.et.gui.Constants
CLASS_EXTENSION, COLOR_EXPLORER, COLOR_OUTPUT, COPYRIGHT, DEBUG, DIVIDER_SIZE, EDIT_MENU_NAME, EXPLORER_DIR, EXPLORER_ROOT, FILE_MENU_NAME, HELP_MENU_NAME, ICON_ABOUT, ICON_ABSTRACT_CLASS, ICON_BROWSER, ICON_CLASS, ICON_CLASS_DISABLED, ICON_DELETE, ICON_ERROR, ICON_FILE, ICON_FOLDER, ICON_GEN_APP, ICON_HOME, ICON_INFORM, ICON_INTERFACE, ICON_JAVA_FILE, ICON_JML_LOGO, ICON_METHOD, ICON_METHOD_GREEN, ICON_METHOD_ORANGE, ICON_METHOD_RED, ICON_MINER, ICON_NEW, ICON_NEWTESTSUITE, ICON_NOTE, ICON_OPEN, ICON_OUTPUT, ICON_PREFERENCES, ICON_QUESTION, ICON_REDO, ICON_SAVE_AS, ICON_TEST_FILE, ICON_UNDO, ICON_UNKOWN, ICON_WARN, JAVA, JAVA_EXTENSION, JAVAC, JUNIT_SWINGGUI_TESTRUNNER, NEWLINE, OPTION_MENU_NAME, TEST_MENU_NAME, TITLE, TOOL_MENU_NAME, VERSION, WEB_PAGE_LOCATION, WEB_PAGE_NAME, WINDOW_HEIGHT, WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH, WINDOW_WIDTH
 
Constructor Summary
EtMethod(Member meth)
          Creates a new wrapper for the given method or constructor.
 
Method Summary
 void addTestCase(EtTestCase tc)
          Adds the given test case to the set of the generated test cases for the wrapped method.
(package private)  boolean canBeBasicConstructor()
          Returns true if the wrapped method can be user-selected as a basic constrcutor.
(package private)  boolean canBeExtendedConstructor()
          Returns true if the wrapped method can be user-selected as an extended constructor.
(package private)  boolean canBeMutator()
          Returns true if the wrapped method can be user-selected as a mutator.
(package private)  boolean canBeObserver()
          Returns true if the wrapped method can be user-selected as an observer.
 Class cut()
          Returns the class under test.
 boolean equals(Object other)
          Returns true if the argument is equal to this object.
 int getKind()
          Returns the kind of the wrapped method.
 int getModifiers()
          Returns the modifiers of the wrapped method.
 String getName()
          Returns the name of the wrapped method.
 Class[] getParameterTypes()
          Returns the parameter types of the wrapped method.
 Class getReturnType()
          Returns the return type of the wrapped method.
 Member getWrapped()
          Returns the wrapped method or constructor.
 int hashCode()
          Returns the hash code.
 boolean hasNegativeTestcase()
          Returns true if any negative test cases are generated for the wrapped method.
 boolean hasPositiveTestcase()
          Returns true if any postive test cases are generated for the wrapped method.
 boolean hasTestcases()
          Returns true if any test cases are generated for the wrapped method.
(package private)  boolean isBasicConstructor()
          Returns true if this wraps a basic constructor.
 boolean isConstructor()
          Returns true if the wrapped method is a constructor.
(package private)  boolean isExtendedConstructor()
          Returns true if this wraps an extended constructor.
 boolean isInstance()
          Returns true if wrapped method is an instance method; it is not a static nor a constructor.
(package private)  boolean isMutator()
          Returns true if this wraps a mutator method.
 boolean isStatic()
          Returns true if the wrapped method is a static method.
 boolean isTested()
          Returns true if the wrapped method has been tested.
 Member method()
          Returns the wrapped method or constructor.
 String name()
          Returns the name of the wrapped method or constructor.
 void prepareForTest()
          Prepares for a new test case generation by removing old test cases and resetting internal variables.
 EtTestCase selectedTestcase()
          Returns the currently selected test case.
 void setCut(Class cut)
          Set the class under test.
(package private)  void setKind()
          Sets the kind of the wrapped method based on its signature.
(package private)  void setKind(int kind)
          Sets the kind of the wrapped method.
 void setSelectedTestcase(EtTestCase tc)
          Makes the given testcase the currently slected testcase.
 String spec()
          Returns the specification of the wrapped method.
 Iterable<EtTestCase> testcases()
          Returns an iterator to iterate over the generated test cases of the wrapped method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cut

private Class cut
The class under test. The CUT and the declaring class of the method under test (i.e., meth) are different for inherited methods.


meth

private Member meth
The wrapped method or constructor that is being tested.


selectedTestcase

private EtTestCase selectedTestcase
The currently selected test case. If not null, this is the test case that is currently selected in the test cases pane among the generated test cases of the method under test, meth.


testcases

private List<EtTestCase> testcases
The generated test cases of the wrapped member, meth.


isTested

private boolean isTested
True if the wrapped method has already been tested. Note that testcases.size() == 0 doesn't mean that the method has not been tested because it it is possible to fail generating any test cases.


kind

private int kind
The kind of wrapped method. The possible values are BASIC_CONSTRUCTOR, EXTENDED_CONSTRUCTOR, MUTATOR, and OBSERVER.

Constructor Detail

EtMethod

public EtMethod(Member meth)
Creates a new wrapper for the given method or constructor. The CUT is assumed to be the declaring class of the argument, and the argument should be either a method or a constructor.

Method Detail

method

public Member method()
Returns the wrapped method or constructor. The returned object is either a constructor or a method.


getWrapped

public Member getWrapped()
Returns the wrapped method or constructor. The returned object is either a constructor or a method.

Specified by:
getWrapped in interface MethodWrapper

setCut

public void setCut(Class cut)
Set the class under test. The wrapped method is either declared by the given class or inherited by it.


cut

public Class cut()
Returns the class under test. Note that the returned class and the declaring class of the method under test are different for inherited methods.


name

public String name()
Returns the name of the wrapped method or constructor.


addTestCase

public void addTestCase(EtTestCase tc)
Adds the given test case to the set of the generated test cases for the wrapped method.


testcases

public Iterable<EtTestCase> testcases()
Returns an iterator to iterate over the generated test cases of the wrapped method.


isTested

public boolean isTested()
Returns true if the wrapped method has been tested.


prepareForTest

public void prepareForTest()
Prepares for a new test case generation by removing old test cases and resetting internal variables.


hasTestcases

public boolean hasTestcases()
Returns true if any test cases are generated for the wrapped method.


hasPositiveTestcase

public boolean hasPositiveTestcase()
Returns true if any postive test cases are generated for the wrapped method.


hasNegativeTestcase

public boolean hasNegativeTestcase()
Returns true if any negative test cases are generated for the wrapped method.


setSelectedTestcase

public void setSelectedTestcase(EtTestCase tc)
Makes the given testcase the currently slected testcase.


selectedTestcase

public EtTestCase selectedTestcase()
Returns the currently selected test case. If no testcase is selected, null is returned.


spec

public String spec()
Returns the specification of the wrapped method.


isStatic

public boolean isStatic()
Returns true if the wrapped method is a static method.


isConstructor

public boolean isConstructor()
Returns true if the wrapped method is a constructor.

Specified by:
isConstructor in interface MethodWrapper

isInstance

public boolean isInstance()
Returns true if wrapped method is an instance method; it is not a static nor a constructor.


getReturnType

public Class getReturnType()
Returns the return type of the wrapped method. If the wrapped method is a constructor, null is returned.


getParameterTypes

public Class[] getParameterTypes()
Returns the parameter types of the wrapped method. If it has no parameter, an empty array is returned.


getName

public String getName()
Returns the name of the wrapped method. If the wrapped method is a constructor, this method returns the base name of the declaring class.


getModifiers

public int getModifiers()
Returns the modifiers of the wrapped method.


getKind

public int getKind()
Returns the kind of the wrapped method. The return value is one of BASIC_CONSTRUCTOR, EXTENDED_CONSTRUCTOR, MUTATOR, and OBSERVER.

Specified by:
getKind in interface MethodWrapper

setKind

void setKind()
Sets the kind of the wrapped method based on its signature.


setKind

void setKind(int kind)
Sets the kind of the wrapped method. The argument should be one of BASIC_CONSTRUCTOR, EXTENDED_CONSTRUCTOR, MUTATOR, and OBSERVER.


isBasicConstructor

boolean isBasicConstructor()
Returns true if this wraps a basic constructor.


isExtendedConstructor

boolean isExtendedConstructor()
Returns true if this wraps an extended constructor.


isMutator

boolean isMutator()
Returns true if this wraps a mutator method.


canBeBasicConstructor

boolean canBeBasicConstructor()
Returns true if the wrapped method can be user-selected as a basic constrcutor.


canBeExtendedConstructor

boolean canBeExtendedConstructor()
Returns true if the wrapped method can be user-selected as an extended constructor.


canBeMutator

boolean canBeMutator()
Returns true if the wrapped method can be user-selected as a mutator.


canBeObserver

boolean canBeObserver()
Returns true if the wrapped method can be user-selected as an observer.


equals

public boolean equals(Object other)
Returns true if the argument is equal to this object. The equality is defined in terms of the wrapped method, and an overridden method is equal to its overriding methods.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns the hash code. This method is redefined here to reflect the new notion of equality on the wrapped method, as defined by the equals method; i.e., an overriding method and its overridden methods are equal to each other.

Overrides:
hashCode in class Object

JET

JET is Copyright (C) 2005-2007 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.