Search in sources :

Example 1 with TestComponentDefinition

use of org.talend.components.api.testcomponent.TestComponentDefinition in project components by Talend.

the class ComponentDefinitionTest method testAllExecutionEngine.

@Test
public void testAllExecutionEngine() {
    // A component that supports all execution engines.
    TestComponentDefinition cd = new TestComponentDefinition(true);
    for (ExecutionEngine engine : ExecutionEngine.values()) {
        assertThat(cd.getSupportedExecutionEngines(), hasItem(engine));
        assertTrue(cd.isSupportingExecutionEngines(engine));
        // Nothing is returned, but there isn't any exception.
        RuntimeInfo ri = cd.getRuntimeInfo(engine, null, null);
        assertThat(ri, nullValue());
    }
}
Also used : ExecutionEngine(org.talend.components.api.component.runtime.ExecutionEngine) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) TestComponentDefinition(org.talend.components.api.testcomponent.TestComponentDefinition) Test(org.junit.Test)

Example 2 with TestComponentDefinition

use of org.talend.components.api.testcomponent.TestComponentDefinition in project components by Talend.

the class ComponentDefinitionTest method testConnectorTopologyEngine_Error1.

@Test(expected = TalendRuntimeException.class)
public void testConnectorTopologyEngine_Error1() {
    TestComponentDefinition cd = new TestComponentDefinition() {

        @Override
        public Set<ConnectorTopology> getSupportedConnectorTopologies() {
            return EnumSet.of(ConnectorTopology.INCOMING, ConnectorTopology.OUTGOING);
        }
    };
    // The assert will throw an exception on this cases
    cd.assertConnectorTopologyCompatibility(ConnectorTopology.INCOMING_AND_OUTGOING);
}
Also used : TestComponentDefinition(org.talend.components.api.testcomponent.TestComponentDefinition) Test(org.junit.Test)

Example 3 with TestComponentDefinition

use of org.talend.components.api.testcomponent.TestComponentDefinition in project components by Talend.

the class ComponentDefinitionTest method testRuntimeEngine.

@Test
public void testRuntimeEngine() {
    TestComponentDefinition cd = new TestComponentDefinition();
    assertThat(cd.getSupportedExecutionEngines(), containsInAnyOrder(ExecutionEngine.DI));
    assertTrue(cd.isSupportingExecutionEngines(ExecutionEngine.DI));
    // Nothing is returned, but there isn't any exception.
    RuntimeInfo ri = cd.getRuntimeInfo(ExecutionEngine.DI, null, null);
    assertThat(ri, nullValue());
    // Requesting a wrong execution engine causes an exception.
    thrown.expect(TalendRuntimeException.class);
    thrown.expect(hasProperty("code", is(ComponentsErrorCode.WRONG_EXECUTION_ENGINE)));
    thrown.expectMessage("WRONG_EXECUTION_ENGINE:{component=TestComponent, requested=BEAM, available=[DI]}");
    ri = cd.getRuntimeInfo(ExecutionEngine.BEAM, null, null);
    fail("An exception must have been thrown.");
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) TestComponentDefinition(org.talend.components.api.testcomponent.TestComponentDefinition) Test(org.junit.Test)

Example 4 with TestComponentDefinition

use of org.talend.components.api.testcomponent.TestComponentDefinition in project components by Talend.

the class ComponentDefinitionTest method testConnectorTopologyEngine_ok.

@Test
public void testConnectorTopologyEngine_ok() {
    TestComponentDefinition cd = new TestComponentDefinition() {

        @Override
        public Set<ConnectorTopology> getSupportedConnectorTopologies() {
            return EnumSet.of(ConnectorTopology.INCOMING, ConnectorTopology.OUTGOING);
        }
    };
    // The assert will no thorw an exception on these two cases
    cd.assertConnectorTopologyCompatibility(ConnectorTopology.INCOMING);
    cd.assertConnectorTopologyCompatibility(ConnectorTopology.OUTGOING);
}
Also used : TestComponentDefinition(org.talend.components.api.testcomponent.TestComponentDefinition) Test(org.junit.Test)

Example 5 with TestComponentDefinition

use of org.talend.components.api.testcomponent.TestComponentDefinition in project components by Talend.

the class ComponentPropertiesInitializationTest method test.

@Test
@Ignore("This is just an example of how performance tests can be written")
@PerfTest(invocations = 5, threads = 1)
@Required(max = 200, average = 100)
public void test() {
    TestComponentDefinition cd = new TestComponentDefinition();
    TestComponentProperties prop = (TestComponentProperties) cd.createRuntimeProperties();
    prop.init();
}
Also used : TestComponentProperties(org.talend.components.api.testcomponent.TestComponentProperties) TestComponentDefinition(org.talend.components.api.testcomponent.TestComponentDefinition) Ignore(org.junit.Ignore) Required(org.databene.contiperf.Required) PerfTest(org.databene.contiperf.PerfTest) Test(org.junit.Test) PerfTest(org.databene.contiperf.PerfTest)

Aggregations

Test (org.junit.Test)10 TestComponentDefinition (org.talend.components.api.testcomponent.TestComponentDefinition)10 TestComponentProperties (org.talend.components.api.testcomponent.TestComponentProperties)2 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)2 PerfTest (org.databene.contiperf.PerfTest)1 Required (org.databene.contiperf.Required)1 Matchers.hasProperty (org.hamcrest.Matchers.hasProperty)1 Ignore (org.junit.Ignore)1 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)1 Property (org.talend.daikon.properties.property.Property)1