|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectpatterntesting.runtime.junit.CloneableTester
public final class CloneableTester
This tester checks class which implements Clonable and has therefore
the clone method implemented. According Object.clone() the
following conditions should be true:
will be true, and that the expression:x.clone() != x
will be true, but these are not absolute requirements. While it is typically the case that:x.clone().getClass() == x.getClass()
will be true, this is not an absolute requirement.x.clone().equals(x)
So the equals method will be only checked if it is overwritten.
NOTE: In the future this class will be perhaps part of the ObjectTester
class.
Before v1.1 the methods are named "checkCloning". Since 1.1 these
methods will have now an "assert" prefix ("assertCloning").
| Method Summary | |
|---|---|
static void |
assertCloning(Class<? extends Cloneable> clazz)
Check cloning. |
static void |
assertCloning(Cloneable orig)
We call the clone method of the given orig paramter.Because the clone method is normally "protected" we use reflection to call it. |
static void |
assertCloning(Collection<Class<Cloneable>> classes)
Check for each class in the given collection if it can be cloned correct. |
static void |
assertCloning(Package pkg)
Check for each class in the given package if it can be cloned correct. |
static void |
assertCloningOfPackage(String packageName)
Check for each class in the given package if it can be cloned correct. |
static void |
assertCloningOfPackage(String packageName,
Class<? extends Cloneable>... excluded)
Check for each class in the given package if the clone method is implemented correct. |
static void |
assertCloningOfPackage(String packageName,
List<Class<Cloneable>> excluded)
Check for each class in the given package if the clone method is implemented correct. |
static Cloneable |
getCloneOf(Cloneable orig)
Gets the clone of the given Cloneable object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void assertCloning(Class<? extends Cloneable> clazz)
clazz - the clazzpublic static void assertCloning(Cloneable orig)
orig - the original object
public static Cloneable getCloneOf(Cloneable orig)
throws AssertionError
orig - the orig
AssertionError - the assertion errorpublic static void assertCloning(Collection<Class<Cloneable>> classes)
classes - a collection of classes to be checkedpublic static void assertCloning(Package pkg)
Package.getPackage(String).
But be sure that you can't get null as result. In this case
use assertCloningOfPackage(String).
pkg - the package e.g. "patterntesting.runtime"assertCloningOfPackage(String)public static void assertCloningOfPackage(String packageName)
packageName - the package name e.g. "patterntesting.runtime"
public static void assertCloningOfPackage(String packageName,
Class<? extends Cloneable>... excluded)
packageName - the package name e.g. "patterntesting.runtime"excluded - classes which should be excluded from the checkassertCloningOfPackage(String)
public static void assertCloningOfPackage(String packageName,
List<Class<Cloneable>> excluded)
packageName - the package name e.g. "patterntesting.runtime"excluded - classes which should be excluded from the checkassertCloningOfPackage(String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||