Class TestingPlatformSupport

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class TestingPlatformSupport
    extends org.junit.rules.ExternalResource
    Testing platform support rule allows to add 1C:Enterprise platform version support for testing purposes and provide stubs for platform EObject providers or platform resource factories. By default platform support sets up EObject provider for platform types provision only.

    Example of rule usage:

     public class PlatformAwareExampleTest
     {
         @ClassRule
         public static TestingPlatformSupport testingPlatformSupport = new TestingPlatformSupport(Version.V8_3_12);
    
         @Test
         public void testSomeProjectOrServiceBehavior()
         {
             // we can use project or version related services ...
         }
     }
     
    • Constructor Detail

      • TestingPlatformSupport

        public TestingPlatformSupport​(Version version,
                                      Version... other)
        Creates an instance of TestingPlatformSupport.
        Parameters:
        version - the platform version to support in test, cannot be null
        other - others platform version to support in test, cannot be null
    • Method Detail

      • addTypeProvider

        public void addTypeProvider​(IPlatformTypeProvider provider)
        Adds custom type provider to the type resource factory. All type providers will be iterated during type creation to find appropriate one.
        Parameters:
        provider - the type provider to add, cannot be null
        See Also:
        IPlatformTypeProvider
      • removeTypeProvider

        public void removeTypeProvider​(IPlatformTypeProvider provider)
        Removes custom type provider to type resource factory.
        Parameters:
        provider - the type provider to remove, cannot be null
      • addFontProvider

        public void addFontProvider​(IPlatformFontProvider provider)
        Adds custom font provider to the font resource factory. All font providers will be iterated during font creation to find appropriate one.
        Parameters:
        provider - the font provider to add, cannot be null
        See Also:
        IPlatformFontProvider
      • removeFontProvider

        public void removeFontProvider​(IPlatformFontProvider provider)
        Removes custom font provider to font resource factory.
        Parameters:
        provider - the font provider to remove, cannot be null
      • addMethodProvider

        public void addMethodProvider​(IPlatformMethodProvider provider)
        Adds custom method provider to the method resource factory. All method providers will be iterated during method creation to find appropriate one.
        Parameters:
        provider - the method provider to add, cannot be null
        See Also:
        IPlatformMethodProvider
      • removeMethodProvider

        public void removeMethodProvider​(IPlatformMethodProvider provider)
        Removes custom method provider to method resource factory.
        Parameters:
        provider - the method provider to remove, cannot be null
      • setUpRuntimeSupport

        public void setUpRuntimeSupport​(Version version)
        Adds platform support for the provided 1C:Enterprise platfrom version for testing purposes.

        Note that method need to be executed before test projects or sevices usage.

        Parameters:
        version - the platform version to support in test, cannot be null
        See Also:
        IRuntime
      • setUpEObjectProvider

        public void setUpEObjectProvider​(org.eclipse.emf.ecore.EClass eClass,
                                         Version version,
                                         Class<? extends IEObjectProvider> eObjectProvider)
        Adds platform EObject provider of the provided EClass and 1C:Enterprise platfrom version for testing purposes. EObject provider must have no-args constructor.

        Note that method need to be executed before test projects or sevices usage.

        Parameters:
        eClass - the class of the provider, cannot be null
        version - the platform version to support in test, cannot be null
        eObjectProvider - the provider class to use, cannot be null
      • setUpEObjectProvider

        public void setUpEObjectProvider​(org.eclipse.emf.ecore.EClass eClass,
                                         Version version,
                                         Class<? extends IEObjectProvider> eObjectProvider,
                                         Class<? extends org.eclipse.core.runtime.IExecutableExtensionFactory> extensionFactory)
        Adds platform EObject provider of the provided EClass and 1C:Enterprise platfrom version for testing purposes created with the specified extension factory.

        Note that method need to be executed before test projects or sevices usage.

        Parameters:
        eClass - the class of the provider, cannot be null
        version - the platform version to support in test, cannot be null
        eObjectProvider - the provider class to use, cannot be null
        extensionFactory - the Eclipse extension factory class to use, cannot be null
      • setUpTypeResourceFactory

        public void setUpTypeResourceFactory​(org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory)
        Adds platform resource factory support for the type file extension.

        Note that method need to be executed before test projects or sevices usage.

        Parameters:
        resourceFactory - the resource factory, cannot be null
      • setUpResourceFactory

        public void setUpResourceFactory​(String fileExtension,
                                         org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory)
        Adds platform resource factory support for the provided file extension.

        Note that method need to be executed before test projects or sevices usage.

        Parameters:
        fileExtension - the file extension, cannot be null
        resourceFactory - the resource factory, cannot be null
      • cleanUpSupport

        public void cleanUpSupport()
        Cleans all previously added version support.
      • before

        protected void before()
                       throws Throwable
        Overrides:
        before in class org.junit.rules.ExternalResource
        Throws:
        Throwable
      • after

        protected void after()
        Overrides:
        after in class org.junit.rules.ExternalResource