Package org.jpox.enhancer.jdo

Source Code of org.jpox.enhancer.jdo.TestA05_4_3

package org.jpox.enhancer.jdo;

import org.jpox.exceptions.JPOXUserException;
import org.jpox.metadata.InvalidPrimaryKeyException;

/**
* @version $Revision: 1.3 $
*/
public abstract class TestA05_4_3 extends JDOTestBase
{
  public void testObjectidClassMustImplementSerializableOkApp()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_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 testObjectidClassMustHavePublicDefaultConstructorOkApp()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_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 testObjectidClassNoPublicDefaultConstructorApp()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_app_no_public_constructor.jdo");
      Class targetClass = findClass(classes, "org.jpox.enhancer.samples.FullProtectedClass");
      targetClass.newInstance();
      fail();
    }
        catch (JPOXUserException ue)
        {
            Throwable[] nested = ue.getNestedExceptions();
            assertEquals(nested.length, 1);
            assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
            InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
            assertEquals("019004", ipke.getMessageKey());
        }
        catch (Throwable e)
        {
      e.printStackTrace();
      fail(e.getClass().getName() + ": " + e.getMessage());
    }
  }

  public void testObjectidClassMustImplementSerializableFailApp()
    {
    try
        {
      getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_app_no_implement_serializable.jdo");
      fail("must throw InvalidPrimaryKeyException with key 019002");
    }
        catch (JPOXUserException ue)
        {
            Throwable[] nested = ue.getNestedExceptions();
            assertEquals(nested.length, 1);
            assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
            InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
            assertEquals("019002", ipke.getMessageKey());
        }
        catch (Throwable e)
        {
      e.printStackTrace();
      fail(e.getClass().getName() + ": " + e.getMessage());
    }
  }

  public void testObjectidClassMustImplementSerializableOkDataStore()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_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 testObjectidClassMustHavePublicDefaultConstructorOkDataStore()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_ds_ok.jdo");
      Class targetClass = findClass(classes, "org.jpox.enhancer.samples.FullProtectedClass");
      targetClass.newInstance();
    }
        catch (Throwable e)
        {
      e.printStackTrace();
      fail(e.getClass().getName() + ": " + e.getMessage());
    }
  }

  public void testObjectidClassNoPublicDefaultConstructorDataStore()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_ds_no_public_constructor.jdo");
      Class targetClass = findClass(classes, "org.jpox.enhancer.samples.FullProtectedClass");
      targetClass.newInstance();
      fail();
    }
        catch (JPOXUserException ue)
        {
            Throwable[] nested = ue.getNestedExceptions();
            assertEquals(nested.length, 1);
            assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
            InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
            assertEquals("019004", ipke.getMessageKey());
        }
        catch (Throwable e)
        {
      e.printStackTrace();
      fail(e.getClass().getName() + ": " + e.getMessage());
    }
  }

  public void testObjectidClassMustImplementSerializableFailDataStore()
    {
    try
        {
      getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_ds_no_implement_serializable.jdo");
      fail("must throw InvalidPrimaryKeyException with key 019002");
    }
        catch (JPOXUserException ue)
        {
            Throwable[] nested = ue.getNestedExceptions();
            assertEquals(nested.length, 1);
            assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
            InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
            assertEquals("019002", ipke.getMessageKey());
        }
        catch (Throwable e)
        {
      e.printStackTrace();
      fail(e.getClass().getName() + ": " + e.getMessage());
    }
  }

  public void testObjectidClassNoOverrideToStringDataStore()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_ds_no_override_tostring.jdo");
      Class targetClass = findClass(classes, "org.jpox.enhancer.samples.FullProtectedClass");
      targetClass.newInstance();
      fail("must throw InvalidPrimaryKeyException with key 019006");
    }
        catch (JPOXUserException ue)
        {
            Throwable[] nested = ue.getNestedExceptions();
            assertEquals(nested.length, 1);
            assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
            InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
            assertEquals("019006", ipke.getMessageKey());
        }
        catch (Throwable e)
        {
      e.printStackTrace();
      fail(e.getClass().getName() + ": " + e.getMessage());
    }
  }

  public void testObjectidClassNoOverrideToStringDataApp()
    {
    try
        {
      Class classes[] = getEnhancedClassesFromFile("org/jpox/enhancer/samples/A5_4_3_app_no_override_tostring.jdo");
      Class targetClass = findClass(classes, "org.jpox.enhancer.samples.FullProtectedClass");
      targetClass.newInstance();
      fail("must throw InvalidPrimaryKeyException with key 019006");
    }
        catch (JPOXUserException ue)
        {
            Throwable[] nested = ue.getNestedExceptions();
            assertEquals(nested.length, 1);
            assertEquals(nested[0].getClass(), InvalidPrimaryKeyException.class);
            InvalidPrimaryKeyException ipke = (InvalidPrimaryKeyException)nested[0];
            assertEquals("019006", ipke.getMessageKey());
        }
        catch (Throwable e)
        {
      e.printStackTrace();
      fail(e.getClass().getName() + ": " + e.getMessage());
    }
  }
}
TOP

Related Classes of org.jpox.enhancer.jdo.TestA05_4_3

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.