package org.jpox.enhancer.jdo;
import org.jpox.exceptions.JPOXUserException;
import org.jpox.metadata.InvalidPrimaryKeyException;
/**
* @version $Revision: 1.3 $
*/
public abstract class TestA05_4_1 extends JDOTestBase
{
public void testObjectidClassMustBePublicOkApp()
{
try
{
Class[] classes = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_1_app_ok.jdo");
Class targetClass = findClass(classes, "org.jpox.enhancer.samples.FullProtectedClass");
targetClass.newInstance();
assertEquals(true, true);
}
catch (Throwable e)
{
e.printStackTrace();
fail(e.getClass().getName() + ": " + e.getMessage());
}
}
public void testObjectidClassMustBePublicFailApp()
{
try
{
getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_1_app_fail.jdo");
fail("must throw InvalidPrimaryKeyException with key 019001");
}
catch (JPOXUserException ue)
{
Throwable[] nested = ue.getNestedExceptions();
assertEquals(nested.length, 1);
assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
assertEquals("019001", ipke.getMessageKey());
}
catch (Throwable e)
{
e.printStackTrace();
fail(e.getClass().getName() + ": " + e.getMessage());
}
}
public void testObjectidClassMustBePublicOkDataStore()
{
try
{
Class[] classes = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_1_ds_ok.jdo");
Class targetClass = findClass(classes, "org.jpox.enhancer.samples.FullProtectedClass");
targetClass.newInstance();
assertEquals(true, true);
}
catch (Throwable e)
{
e.printStackTrace();
fail(e.getClass().getName() + ": " + e.getMessage());
}
}
public void testObjectidClassMustBePublicFailDataStore()
{
try
{
getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_1_ds_fail.jdo");
fail("must throw InvalidPrimaryKeyException with key 019001");
}
catch (JPOXUserException ue)
{
Throwable[] nested = ue.getNestedExceptions();
assertEquals(nested.length, 1);
assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
assertEquals("019001", ipke.getMessageKey());
}
catch (Throwable e)
{
e.printStackTrace();
fail(e.getClass().getName() + ": " + e.getMessage());
}
}
}