JET

edu.utep.cs.et.rat.gen
Class IncrementalClassValueGenerator

java.lang.Object
  extended by edu.utep.cs.et.rat.gen.ClassValueGenerator
      extended by edu.utep.cs.et.rat.gen.IncrementalClassValueGenerator

 class IncrementalClassValueGenerator
extends ClassValueGenerator

A class to generate class values incrementally. This class uses an incremental random approach in that every method or constructor, selected randomly, is checked on-the-fly to ensure a successful invocation of the method or constructor, i.e., no exception and no assertion violation.

Version:
$Revision: 1.9 $
Author:
Yoonsik Cheon

Field Summary
private static Map<Class,List<Denotable>> pool
          Object pool, a map from classes to lists of denotables.
 
Fields inherited from class edu.utep.cs.et.rat.gen.ClassValueGenerator
context, type
 
Constructor Summary
IncrementalClassValueGenerator(ValueFactory factory, ValueGenerator generator)
          Creates a class generator that uses the given value factory and generator.
 
Method Summary
private  void addPooled(Class clazz, Denotable value)
          Adds the given object of the given type to the pool.
private  boolean canConstruct(Denotable value)
          Returns true if the given value can actually be built.
private  Denotable choosePooled(Class clazz)
          Chooses from the pooled objects an arbitrary object of the given type.
protected  Denotable construct(int maxHeight)
          Constructs an instance of the target class.
private  boolean hasPooled(Class clazz)
          Returns true if at least one object of the given type is pooled.
protected  Denotable mutate(Denotable value, double rate, boolean mutated, int maxHeight)
          Mutates the given value by calling a sequence of mutators.
protected  void reset(Class type, Context ctx)
          Reconfigures this object to be able to create an object of the given type in the given testing context.
 
Methods inherited from class edu.utep.cs.et.rat.gen.ClassValueGenerator
createNullValue, generate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pool

private static final Map<Class,List<Denotable>> pool
Object pool, a map from classes to lists of denotables.

Constructor Detail

IncrementalClassValueGenerator

public IncrementalClassValueGenerator(ValueFactory factory,
                                      ValueGenerator generator)
Creates a class generator that uses the given value factory and generator.

Method Detail

construct

protected Denotable construct(int maxHeight)
Constructs an instance of the target class. The constructed value may be a null value. This method is overridden here to ensure that the returned value can actually be built; i.e., it satisfies class invariants and pre and postconditions.

Overrides:
construct in class ClassValueGenerator
Parameters:
maxHeight - Maximum height of the constructed object

canConstruct

private boolean canConstruct(Denotable value)
Returns true if the given value can actually be built.


mutate

protected Denotable mutate(Denotable value,
                           double rate,
                           boolean mutated,
                           int maxHeight)
Mutates the given value by calling a sequence of mutators. This method is overridden here to make sure that the mutated value can actually be built; i.e., it satisfies class invariants and pre and postconditions. If mutation attempts fails for a predefined times, the original value is returned.

Overrides:
mutate in class ClassValueGenerator
Parameters:
value - Object to be mutated
rate - Mutation rate
mutate - True if the object has already been mutated
maxHeight - Maximum height of the mutated object (viewed as a tree)

reset

protected void reset(Class type,
                     Context ctx)
Reconfigures this object to be able to create an object of the given type in the given testing context. This method is overridden here, if needed, to clear the object pool.

Overrides:
reset in class ClassValueGenerator

hasPooled

private boolean hasPooled(Class clazz)
Returns true if at least one object of the given type is pooled.


choosePooled

private Denotable choosePooled(Class clazz)
Chooses from the pooled objects an arbitrary object of the given type.


addPooled

private void addPooled(Class clazz,
                       Denotable value)
Adds the given object of the given type to the pool.


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.