Search in sources :

Example 21 with EcoTopologyDefinition

use of org.apache.heron.eco.definition.EcoTopologyDefinition in project heron by twitter.

the class EcoTest method testSubmit_StormTopologyType_BehavesAsExpected.

@Test
public void testSubmit_StormTopologyType_BehavesAsExpected() throws Exception {
    FileInputStream mockStream = PowerMockito.mock(FileInputStream.class);
    FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
    final String topologyName = "the name";
    EcoTopologyDefinition topologyDefinition = new EcoTopologyDefinition();
    topologyDefinition.setName(topologyName);
    when(mockEcoParser.parseFromInputStream(eq(mockStream), eq(mockPropsStream), eq(false))).thenReturn(topologyDefinition);
    subject.submit(mockStream, mockPropsStream, false);
    verify(mockEcoParser).parseFromInputStream(same(mockStream), same(mockPropsStream), eq(false));
    verify(mockEcoSubmitter).submitStormTopology(any(String.class), any(Config.class), any(StormTopology.class));
}
Also used : Config(org.apache.heron.api.Config) StormTopology(org.apache.storm.generated.StormTopology) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 22 with EcoTopologyDefinition

use of org.apache.heron.eco.definition.EcoTopologyDefinition in project heron by twitter.

the class EcoTest method testSubmit_HeronTopologyType_BehavesAsExpected.

@Test
public void testSubmit_HeronTopologyType_BehavesAsExpected() throws Exception {
    FileInputStream mockStream = PowerMockito.mock(FileInputStream.class);
    FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
    final String topologyName = "the name";
    EcoTopologyDefinition topologyDefinition = new EcoTopologyDefinition();
    topologyDefinition.setName(topologyName);
    topologyDefinition.setType("heron");
    when(mockEcoParser.parseFromInputStream(eq(mockStream), eq(mockPropsStream), eq(false))).thenReturn(topologyDefinition);
    subject.submit(mockStream, mockPropsStream, false);
    verify(mockEcoParser).parseFromInputStream(same(mockStream), same(mockPropsStream), eq(false));
    verify(mockEcoSubmitter).submitHeronTopology(any(String.class), any(Config.class), any(HeronTopology.class));
}
Also used : Config(org.apache.heron.api.Config) HeronTopology(org.apache.heron.api.HeronTopology) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 23 with EcoTopologyDefinition

use of org.apache.heron.eco.definition.EcoTopologyDefinition in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_MBAllocationTooSmall_ExceptionThrown.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_MBAllocationTooSmall_ExceptionThrown() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_RAM_MEGABYTES.getBytes());
        FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
        EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
        config = subject.buildConfig(ecoTopologyDefinition);
    } finally {
        assertNull(config);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(org.apache.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(org.apache.heron.eco.parser.EcoParser) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 24 with EcoTopologyDefinition

use of org.apache.heron.eco.definition.EcoTopologyDefinition in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_ByteAllocationTooSmall_ExceptionThrown.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_ByteAllocationTooSmall_ExceptionThrown() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_RAM_BYTES.getBytes());
        FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
        EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
        config = subject.buildConfig(ecoTopologyDefinition);
    } finally {
        assertNull(config);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(org.apache.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(org.apache.heron.eco.parser.EcoParser) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 25 with EcoTopologyDefinition

use of org.apache.heron.eco.definition.EcoTopologyDefinition in project heron by twitter.

the class ConfigBuilderTest method testBuildConfig_IncorrectByteResourceFormat_ExceptionThrow.

@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectByteResourceFormat_ExceptionThrow() throws Exception {
    Config config = null;
    try {
        EcoParser ecoParser = new EcoParser();
        InputStream inputStream = new ByteArrayInputStream(INCORRECT_BYTES_FORMAT_YAML.getBytes());
        FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
        EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
        config = subject.buildConfig(ecoTopologyDefinition);
    } finally {
        assertNull(config);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(org.apache.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(org.apache.heron.eco.parser.EcoParser) EcoTopologyDefinition(org.apache.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

EcoTopologyDefinition (org.apache.heron.eco.definition.EcoTopologyDefinition)31 Test (org.junit.Test)21 FileInputStream (java.io.FileInputStream)15 ByteArrayInputStream (java.io.ByteArrayInputStream)13 InputStream (java.io.InputStream)13 Config (org.apache.heron.api.Config)13 EcoParser (org.apache.heron.eco.parser.EcoParser)8 ArrayList (java.util.ArrayList)4 BoltDefinition (org.apache.heron.eco.definition.BoltDefinition)4 StreamDefinition (org.apache.heron.eco.definition.StreamDefinition)4 HashMap (java.util.HashMap)3 GroupingDefinition (org.apache.heron.eco.definition.GroupingDefinition)3 ObjectDefinition (org.apache.heron.eco.definition.ObjectDefinition)3 SpoutDefinition (org.apache.heron.eco.definition.SpoutDefinition)3 BeanDefinition (org.apache.heron.eco.definition.BeanDefinition)2 ComponentStream (org.apache.heron.eco.definition.ComponentStream)2 Before (org.junit.Before)2 Matchers.anyObject (org.mockito.Matchers.anyObject)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Properties (java.util.Properties)1