JET

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

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

public 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.15 $
Author:
Yoonsik Cheon

Field Summary
 
Fields inherited from class edu.utep.cs.jet.rat.gen.ClassValueGenerator
context, factory, mutators, type
 
Constructor Summary
IncrementalClassValueGenerator(ValueFactory factory, ValueGenerator generator)
          Creates a class generator that uses the given value factory and generator.
 
Method Summary
protected  boolean canConstruct(Denotable value)
          Returns true if the given value can actually be built.
protected  Denotable construct(int maxHeight)
          Constructs an instance of the target class.
 Denotable generate(Class<?> type, Context ctx, int maxHeight)
          Generates a value of the given class type under the given testing context.
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.jet.rat.gen.ClassValueGenerator
createNullValue, generateArguments, simpleMutate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IncrementalClassValueGenerator

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

Method Detail

generate

public Denotable generate(Class<?> type,
                          Context ctx,
                          int maxHeight)
Generates a value of the given class type under the given testing context. The height of the returned object, represented as a tree, shouldn't exceed maxHeight to prevent an infinite or excessive recursion. This method is overriden hehre to implement object pooling.

Overrides:
generate in class ClassValueGenerator

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

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

JET

JET is Copyright (C) 2005-2008 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.