Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.factorymethod
Class Main

java.lang.Object
  extended by dk.rode.thesis.factorymethod.Main
All Implemented Interfaces:
Testable

public class Main
extends Object
implements Testable

Factory Method tests.

Author:
Gunni Rode / rode.dk

Constructor Summary
Main()
          No-arg constructor.
 
Method Summary
static void main(String[] args)
          Executes the Factory Method tests.
 boolean test(Log out, Arguments arguments)
          Performs the specific tests and report the outcome to the log supplied as log.
private static
<E,T> boolean
testCreator(Log out, CommandCreator<E,T> creator, Sequence<E> sequence, int index, List<T> tokens)
          Tests the creator supplied as creator using sequence for each token in tokens
private static
<E> boolean
testFactory(Log out, Sequence<E> sequence, int index, List<Factory<? extends Command<E>>> factories)
          Tests the factories supplied in factories that creates commands based on sequence as the single argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Main

public Main()
No-arg constructor.

Method Detail

main

public static void main(String[] args)
                 throws Exception
Executes the Factory Method tests.

Parameters:
args - The arguments to supply to test(Log, Arguments), if any; can be null.
Throws:
Exception - If the test failed unexpectedly.

test

public boolean test(Log out,
                    Arguments arguments)
             throws Exception
Description copied from interface: Testable
Performs the specific tests and report the outcome to the log supplied as log.

Arguments to control log-level:

Specified by:
test in interface Testable
Parameters:
out - The log to report the test outcome to; cannot be null.
arguments - Additional arguments, if any.
Returns:
True if the tests succeeded, false if not.
Throws:
NullPointerException - If out is null.
Exception - In case an unexpected error occurs.

testCreator

private static final <E,T> boolean testCreator(Log out,
                                               CommandCreator<E,T> creator,
                                               Sequence<E> sequence,
                                               int index,
                                               List<T> tokens)
Tests the creator supplied as creator using sequence for each token in tokens

Type Parameters:
E - The type of sequence and command values.
T - The type of tokens used to identify the type of command to create.
Parameters:
out - Log to use; never null.
creator - The creator to test; never null.
sequence - The sequence to use; never null.
index - The index of the sequence among all sequences tested.
tokens - The tokens to identify the types of commands to create.
Returns:
True if the test succeeded, false if it did not.

testFactory

private static final <E> boolean testFactory(Log out,
                                             Sequence<E> sequence,
                                             int index,
                                             List<Factory<? extends Command<E>>> factories)
Tests the factories supplied in factories that creates commands based on sequence as the single argument.

Type Parameters:
E - The type of sequence and command values.
Parameters:
out - Log to use; never null.
sequence - The sequence to use; never null.
index - The index of the sequence among all sequences tested.
factories - The factories to create the commands using sequence as the argument.
Returns:
True if the test succeeded, false if it did not.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.