Package com._1c.g5.v8.dt.testing
Class TestingPlatformSupport
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- com._1c.g5.v8.dt.testing.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 platformEObject
providers or platform resource factories. By default platform support sets upEObject
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 Summary
Constructors Constructor Description TestingPlatformSupport(Version version, Version... other)
Creates an instance ofTestingPlatformSupport
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFontProvider(IPlatformFontProvider provider)
Adds custom font provider to the font resource factory.void
addMethodProvider(IPlatformMethodProvider provider)
Adds custom method provider to the method resource factory.void
addTypeProvider(IPlatformTypeProvider provider)
Adds custom type provider to the type resource factory.protected void
after()
protected void
before()
void
cleanUpSupport()
Cleans all previously added version support.void
removeFontProvider(IPlatformFontProvider provider)
Removes custom font provider to font resource factory.void
removeMethodProvider(IPlatformMethodProvider provider)
Removes custom method provider to method resource factory.void
removeTypeProvider(IPlatformTypeProvider provider)
Removes custom type provider to type resource factory.void
setUpEObjectProvider(org.eclipse.emf.ecore.EClass eClass, Version version, Class<? extends IEObjectProvider> eObjectProvider)
Adds platformEObject
provider of the providedEClass
and 1C:Enterprise platfrom version for testing purposes.void
setUpEObjectProvider(org.eclipse.emf.ecore.EClass eClass, Version version, Class<? extends IEObjectProvider> eObjectProvider, Class<? extends org.eclipse.core.runtime.IExecutableExtensionFactory> extensionFactory)
Adds platformEObject
provider of the providedEClass
and 1C:Enterprise platfrom version for testing purposes created with the specified extension factory.void
setUpResourceFactory(String fileExtension, org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory)
Adds platform resource factory support for the provided file extension.void
setUpRuntimeSupport(Version version)
Adds platform support for the provided 1C:Enterprise platfrom version for testing purposes.void
setUpTypeResourceFactory(org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory)
Adds platform resource factory support for thetype
file extension.
-
-
-
Constructor Detail
-
TestingPlatformSupport
public TestingPlatformSupport(Version version, Version... other)
Creates an instance ofTestingPlatformSupport
.- Parameters:
version
- the platform version to support in test, cannot benull
other
- others platform version to support in test, cannot benull
-
-
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 benull
- 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 benull
-
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 benull
- 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 benull
-
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 benull
- 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 benull
-
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 benull
- See Also:
IRuntime
-
setUpEObjectProvider
public void setUpEObjectProvider(org.eclipse.emf.ecore.EClass eClass, Version version, Class<? extends IEObjectProvider> eObjectProvider)
Adds platformEObject
provider of the providedEClass
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 benull
version
- the platform version to support in test, cannot benull
eObjectProvider
- the provider class to use, cannot benull
-
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 platformEObject
provider of the providedEClass
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 benull
version
- the platform version to support in test, cannot benull
eObjectProvider
- the provider class to use, cannot benull
extensionFactory
- the Eclipse extension factory class to use, cannot benull
-
setUpTypeResourceFactory
public void setUpTypeResourceFactory(org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory)
Adds platform resource factory support for thetype
file extension.Note that method need to be executed before test projects or sevices usage.
- Parameters:
resourceFactory
- the resource factory, cannot benull
-
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 benull
resourceFactory
- the resource factory, cannot benull
-
cleanUpSupport
public void cleanUpSupport()
Cleans all previously added version support.
-
before
protected void before() throws Throwable
- Overrides:
before
in classorg.junit.rules.ExternalResource
- Throws:
Throwable
-
after
protected void after()
- Overrides:
after
in classorg.junit.rules.ExternalResource
-
-