Package nexj.core.meta

Examples of nexj.core.meta.Metaclass$ClassPointcutHelper


    */
   public void testUncachedCalculatedValueWithInitializer()
   {
      final Symbol INITIALIZED = Symbol.define("INITIALIZED");
      final Symbol CALCULATED = Symbol.define("CALCULATED");
      final Metaclass userClass = Repository.getMetadata().getMetaclass("User");
      final int attribute = userClass.findAttribute("regionUncached").getOrdinal();
      UnitOfWork oldUOW;
      Instance instance;

      // Get value while new --> run initializer
      // Get value once committed --> run calculated value script
      oldUOW = m_context.beginTransaction();
      instance = (Instance)userClass.invoke("new");
      assertEquals(Undefined.VALUE, instance.getValueDirect(attribute));
      assertEquals(INITIALIZED, instance.getValue(attribute));
      instance.setValue("name", "jack.test");
      instance.setValue("contact", m_context.getUser().getValue("contact"));
      m_context.commitAndResume(oldUOW);
      assertEquals(INITIALIZED, instance.getValueDirect(attribute));
      assertEquals(CALCULATED, instance.getValue(attribute));

      // Ensure that initializer is run by validation
      oldUOW = m_context.beginTransaction();
      instance = (Instance)userClass.invoke("new");
      instance.setValue("name", "jill.test");
      instance.setValue("contact", m_context.getUser().getValue("contact"));
      m_context.commitAndResume(oldUOW);
      assertEquals(INITIALIZED, instance.getValueDirect(attribute));
      assertEquals(CALCULATED, instance.getValue(attribute));
View Full Code Here


    */
   public void testCachedCalculatedValueWithInitializer()
   {
      final Symbol INITIALIZED = Symbol.define("INITIALIZED");
      final Symbol CALCULATED = Symbol.define("CALCULATED");
      final Metaclass userClass = Repository.getMetadata().getMetaclass("User");
      final int attribute = userClass.findAttribute("regionCached").getOrdinal();
      UnitOfWork oldUOW;
      Instance instance;

      // Get value while new --> run initializer
      // Get value once committed --> return cached value
      oldUOW = m_context.beginTransaction();
      instance = (Instance)userClass.invoke("new");
      assertEquals(Undefined.VALUE, instance.getValueDirect(attribute));
      assertEquals(INITIALIZED, instance.getValue(attribute));
      instance.setValue("name", "jack.test");
      instance.setValue("contact", m_context.getUser().getValue("contact"));
      m_context.commitAndResume(oldUOW);
View Full Code Here

   /**
    * Tests that lazy loads don't cause heterogeneous joins.
    */
   public void testLazyRelationalJoiningRelational()
   {
      Metaclass clazz = getMetadata().getMetaclass("ExternalVisit");
      ReadCountHook readHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("DefaultRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      ReadCountHook extHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("ExternalRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      InstanceArrayList list;
      Instance inst;
      int nStartReadCount = readHook.getReadCount();
View Full Code Here

   /**
    * This test is a pre-condition of other tests in this file.
    */
   public void testCanUnitTestsDetectImproperCommitOfATransaction()
   {
      Metaclass metaclass = m_context.getMetadata().getMetaclass("InvocationContextTest");
      UnitOfWork initialUOW = m_context.getUnitOfWork();

      assertFalse(initialUOW.isTransient());
      assertNull(initialUOW.getTransaction());
      metaclass.invoke("new");

      initialUOW.setTransient(true)// force error if initialUOW is committed

      try
      {
         metaclass.invoke("testCommitTransaction");
         fail("Expected exception");
      }
      catch (WorkStateException ex)
      {
         assertEquals("err.runtime.transientCommit", ex.getErrorCode());
View Full Code Here

    * Precondition:
    *    testCanUnitTestsDetectImproperCommitOfATransaction must PASS for this test result to be valid.
    */
   public void testSuspendTransactionDoesNotCommitOtherTransaction()
   {
      Metaclass metaclass = m_context.getMetadata().getMetaclass("InvocationContextTest");
      UnitOfWork initialUOW = m_context.getUnitOfWork();

      assertEquals(0, initialUOW.getInstanceCount());
      assertFalse(initialUOW.isTransient());
      assertNull(initialUOW.getTransaction());
      metaclass.invoke("new");

      initialUOW.setTransient(true)// force error if initialUOW is committed
      metaclass.invoke("testSuspendTransaction");

      UnitOfWork finalUOW = m_context.getUnitOfWork();

      assertSame(initialUOW, finalUOW);
   }
View Full Code Here

    * Precondition:
    *    testCanUnitTestsDetectImproperCommitOfATransaction must PASS for this test result to be valid.
    */
   public void testNoneTransactionModeDoesNotCommitOtherTransaction()
   {
      Metaclass metaclass = m_context.getMetadata().getMetaclass("InvocationContextTest");
      UnitOfWork initialUOW = m_context.getUnitOfWork();

      assertEquals(0, initialUOW.getInstanceCount());
      assertFalse(initialUOW.isTransient());
      assertNull(initialUOW.getTransaction());
      metaclass.invoke("new");

      initialUOW.setTransient(true)// force error if initialUOW is committed
      metaclass.invoke("testTransactionModeNONE");

      UnitOfWork finalUOW = m_context.getUnitOfWork();

      assertSame(initialUOW, finalUOW);
   }
View Full Code Here

    * Additionally, tests transformation arguments.
    * Tests using the service TestTransform.
    */
   public void testTransformFormatPrimitive()
   {
      Metaclass serviceClass = m_metadata.getMetaclass(Metadata.SERVICE_CLASS_NAME);
      Message csvMessage = m_metadata.getMessage("CSVTestSuiteResult");
      MessageFormatter formatter = (MessageFormatter)csvMessage.getFormat().getFormatter().getInstance(m_context);
      TransferObject root, test, testData, result;
      List testList;
      StringWriter writer;
      WriterOutput out;

      root = new TransferObject("XMLTestSuiteResult");
      testList = new ArrayList(2);
      root.setValue("tests", testList);
      test = new TransferObject();
      testList.add(test);
      test.setValue("date", Primitive.toTimestamp("2009-12-07T08:00:00"));
      test.setValue("status", "ERROR");
      testData = new TransferObject("XMLTestResult", 3);
      test.setValue("data", testData);
      testData.setValue("seed", "12345");
      testData.setValue("a", "aValue");
      testData.setValue("b", "bValue");

      test = new TransferObject();
      testList.add(test);
      test.setValue("date", Primitive.toTimestamp("2009-08-17T00:00:00"));
      test.setValue("status", "PASS");
      testData = new TransferObject("XMLTestResult", 3);
      test.setValue("data", testData);
      testData.setValue("b", "bValue2");

      Instance instance = (Instance)serviceClass.invoke("invoke", new Object[]{"TestTransform", root, null, "PRE-", Boolean.TRUE});

      assertEquals(Boolean.TRUE, instance.invoke("done"));
      result = (TransferObject)instance.invoke("result");

      assertEquals("CSVTestSuiteResult", result.getClassName());
View Full Code Here

      );
   }

   public void testReadAssocRelationalFKToVirtualNone() throws Exception
   {
      Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");
      InstanceArrayList list;
      Instance inst, inst2;

      list = (InstanceArrayList)Query.createRead(relationalClass,
         parse("(firstName lastName (relFKToVirtNone commonName))"),
View Full Code Here

      assertEquals("Spider", inst2.getValue("commonName"));
   }

   public void testLazyRelationalJoiningVirtual() throws Exception
   {
      Metaclass relationalClass = getMetadata().getMetaclass("PetOwner");
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      InstanceArrayList list;
      Instance inst;
      int nStartCallCount;

      nStartCallCount = ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue();
      list = (InstanceArrayList)Query.createRead(relationalClass,
         null,
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(2, list.getCount());
      assertEquals(nStartCallCount, ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue());
      inst = list.getInstance(0);
      assertEquals(nStartCallCount, ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue());
      s_logger.info("***** Start lazy load *****");
      assertEquals("Joe", inst.getValue("firstName"));
      s_logger.info("***** End lazy load *****");

      // Ensure no joins on lazy load:
      assertEquals(nStartCallCount, ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue());
   }
View Full Code Here

      assertEquals(nStartCallCount, ((Integer)virtualClass.getValue("objectKeyReadCount")).intValue());
   }

   public void testLazyVirtualJoiningRelational() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      ReadCountHook readCountHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("DefaultRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      InstanceArrayList list;
      Instance inst;
      int nStartReadCount;
View Full Code Here

TOP

Related Classes of nexj.core.meta.Metaclass$ClassPointcutHelper

Copyright © 2018 www.massapicom. 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.