Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-14774

Replace SQLRepositoryTestCase with CoreFeature

    XMLWordPrintable

    Details

    • Type: Clean up
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.9.5
    • Component/s: Tests
    • Upgrade notes:
      Hide

      Usually it's just a matter of adding:
      @RunWith(FeaturesRunner.class)
      @Features(

      { TransactionalFeature.class, CoreFeature.class }

      )
      @RepositoryConfig(cleanup = Granularity.METHOD)
      And injecting the session:
      @Inject
      protected CoreSession session;
      And getting rid of the setUp/tearDown if they only do standard stuff.

      If setUp does some deployBundle / deployContrib, you'll have to turn them into @Deploy / @LocalDeploy, like:
      @Deploy(

      { "org.nuxeo.runtime.management", "org.nuxeo.ecm.core.management", "org.nuxeo.ecm.core.management.test" }

      )
      @LocalDeploy(

      { "org.nuxeo.ecm.core.test.tests:test-CoreExtensions.xml", "org.nuxeo.ecm.core.test.tests:test-security-policy-contrib.xml" }

      )

      If you have one test method that needs to do specific deploys, the pattern is:

      @Inject
      protected RuntimeHarness harness;

      @Test
      public void test() throws Exception

      { harness.deployContrib("org.nuxeo.ecm.core.test.tests", "test-PostCommitListeners.xml"); ... harness.undeployContrib("org.nuxeo.ecm.core.test.tests", "test-PostCommitListeners.xml"); }

      Please make sure that you always have TransactionalFeature in your Features, it's how Nuxeo actually runs and non-transactional stuff usually has problems with inter-session visibility.

      Show
      Usually it's just a matter of adding: @RunWith(FeaturesRunner.class) @Features( { TransactionalFeature.class, CoreFeature.class } ) @RepositoryConfig(cleanup = Granularity.METHOD) And injecting the session: @Inject protected CoreSession session; And getting rid of the setUp/tearDown if they only do standard stuff. If setUp does some deployBundle / deployContrib, you'll have to turn them into @Deploy / @LocalDeploy, like: @Deploy( { "org.nuxeo.runtime.management", "org.nuxeo.ecm.core.management", "org.nuxeo.ecm.core.management.test" } ) @LocalDeploy( { "org.nuxeo.ecm.core.test.tests:test-CoreExtensions.xml", "org.nuxeo.ecm.core.test.tests:test-security-policy-contrib.xml" } ) If you have one test method that needs to do specific deploys, the pattern is: @Inject protected RuntimeHarness harness; @Test public void test() throws Exception { harness.deployContrib("org.nuxeo.ecm.core.test.tests", "test-PostCommitListeners.xml"); ... harness.undeployContrib("org.nuxeo.ecm.core.test.tests", "test-PostCommitListeners.xml"); } Please make sure that you always have TransactionalFeature in your Features, it's how Nuxeo actually runs and non-transactional stuff usually has problems with inter-session visibility.

      Description

      Convert use of SQLRepositoryTestCase with a CoreFeature in tests.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: