use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.
the class GoogleDriveTestBase method getDefinitionRegistry.
@Override
public DefinitionRegistryService getDefinitionRegistry() {
if (definitionRegistry == null) {
definitionRegistry = new DefinitionRegistry();
definitionRegistry.registerComponentFamilyDefinition(new GoogleDriveFamilyDefinition());
}
return definitionRegistry;
}
use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.
the class TestFixedConnectorComponentProperties method getComponentService.
// default implementation for pure java test. Shall be overriden of Spring or OSGI tests
public ComponentService getComponentService() {
DefinitionRegistry testComponentRegistry = new DefinitionRegistry();
SimpleComponentDefinition componentDef = new SimpleComponentDefinition("foo", ExecutionEngine.DI);
componentDef.setPropertyClass(TestProperties.class);
testComponentRegistry.registerDefinition(Arrays.asList(componentDef));
return new ComponentServiceImpl(testComponentRegistry);
}
use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.
the class FormatPropertiesProviderTest method testProperties.
@Test
public void testProperties() throws Throwable {
FormatPropertiesProvider<AbstractTestFormatProperties> propertiesProvider = new FormatPropertiesProvider<AbstractTestFormatProperties>("propertiesProvider", AbstractTestFormatDefinition.class) {
};
DefinitionRegistry reg = new DefinitionRegistry();
TestFormatDefinition1Impl def1 = new TestFormatDefinition1Impl();
TestFormatDefinition2Impl def2 = new TestFormatDefinition2Impl();
reg.registerDefinition(Arrays.asList(def1, def2));
reg.injectDefinitionRegistry(propertiesProvider);
propertiesProvider.init();
// Check that possible format values include both of registered definitions
Assert.assertEquals(propertiesProvider.format.getPossibleValues().size(), 2);
// Set the format value to first registered definition
propertiesProvider.format.setValue(def1.getName());
PropertiesDynamicMethodHelper.afterProperty(propertiesProvider, propertiesProvider.format.getName());
AbstractTestFormatProperties formatProperties = propertiesProvider.getFormatProperties();
Assert.assertNotEquals(def2.getName(), propertiesProvider.format.getValue());
Assert.assertEquals(def1.getName(), propertiesProvider.format.getValue());
// Format properties class in PropertiesProvider should be the same as properties class for definition
Assert.assertEquals(def1.getPropertiesClass(), formatProperties.getClass());
propertiesProvider.format.setValue(def2.getName());
PropertiesDynamicMethodHelper.afterProperty(propertiesProvider, propertiesProvider.format.getName());
formatProperties = propertiesProvider.getFormatProperties();
Assert.assertNotEquals(def1.getName(), propertiesProvider.format.getValue());
Assert.assertEquals(def2.getName(), propertiesProvider.format.getValue());
Assert.assertEquals(TestFormatProperties2Impl.class, formatProperties.getClass());
}
use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.
the class FullExamplePropertiesTest method getComponentService.
@Override
public ComponentService getComponentService() {
if (simpleComponentService == null) {
DefinitionRegistry componentRegistry = new DefinitionRegistry();
componentRegistry.registerComponentFamilyDefinition(new FullExampleFamilyDefinition());
simpleComponentService = new ComponentServiceImpl(componentRegistry);
}
return simpleComponentService;
}
use of org.talend.components.api.service.common.DefinitionRegistry in project components by Talend.
the class ServiceSpiFactoryTest method testUpdateClassLoaderService.
@Test
public void testUpdateClassLoaderService() throws MalformedURLException {
// this will check that create an update registry with the new url
// given
DefinitionRegistry definitionRegistry = ServiceSpiFactory.createDefinitionRegistry(new URL[] { new URL("mvn:org.talend.components/multiple-runtime-comp/0.18.0") });
assertThat(definitionRegistry.getComponentFamilies(), hasKey(is("MultiRuntimeExample")));
assertThat(definitionRegistry.getComponentFamilies(), not(hasKey(is("Jdbc"))));
// when
DefinitionRegistry definitionRegistry2 = ServiceSpiFactory.createUpdatedDefinitionRegistry(new URL[] { new URL("mvn:org.talend.components/components-jdbc-definition/0.18.0") });
// then
assertThat(definitionRegistry2.getComponentFamilies(), hasKey(is("MultiRuntimeExample")));
assertThat(definitionRegistry2.getComponentFamilies(), hasKey(is("Jdbc")));
// this will check that same registry is returned if no classpath is passed
assertThat(definitionRegistry2, equalTo(ServiceSpiFactory.createDefinitionRegistry(null)));
assertThat(definitionRegistry2, equalTo(ServiceSpiFactory.createDefinitionRegistry(new URL[0])));
}
Aggregations