Search in sources :

Example 6 with ResourceConfig

use of com.hazelcast.jet.config.ResourceConfig in project hazelcast-jet by hazelcast.

the class ResourceConfigTest method testAddResource_with_Url_and_ResourceName.

@Test
public void testAddResource_with_Url_and_ResourceName() throws Exception {
    JobConfig config = new JobConfig();
    String resourceName = "resourceFileName";
    String urlString = "file://path/to/resourceFile";
    config.addResource(new URL(urlString), resourceName);
    ResourceConfig resourceConfig = config.getResourceConfigs().iterator().next();
    assertEquals(resourceName, resourceConfig.getId());
    assertFalse(resourceConfig.isArchive());
    assertEquals(urlString, resourceConfig.getUrl().toString());
}
Also used : ResourceConfig(com.hazelcast.jet.config.ResourceConfig) JobConfig(com.hazelcast.jet.config.JobConfig) URL(java.net.URL) Test(org.junit.Test)

Example 7 with ResourceConfig

use of com.hazelcast.jet.config.ResourceConfig in project hazelcast-jet by hazelcast.

the class ResourceConfigTest method testAddResource_with_Url.

@Test
public void testAddResource_with_Url() throws Exception {
    JobConfig config = new JobConfig();
    String urlString = "file://path/to/resourceFile";
    config.addResource(new URL(urlString));
    ResourceConfig resourceConfig = config.getResourceConfigs().iterator().next();
    assertEquals("resourceFile", resourceConfig.getId());
    assertFalse(resourceConfig.isArchive());
    assertEquals(urlString, resourceConfig.getUrl().toString());
}
Also used : ResourceConfig(com.hazelcast.jet.config.ResourceConfig) JobConfig(com.hazelcast.jet.config.JobConfig) URL(java.net.URL) Test(org.junit.Test)

Example 8 with ResourceConfig

use of com.hazelcast.jet.config.ResourceConfig in project hazelcast-jet by hazelcast.

the class ResourceConfigTest method testAddResource_with_Path.

@Test
public void testAddResource_with_Path() throws Exception {
    JobConfig config = new JobConfig();
    String path = "/path/to/resource";
    config.addResource(path);
    ResourceConfig resourceConfig = config.getResourceConfigs().iterator().next();
    assertEquals("resource", resourceConfig.getId());
    assertFalse(resourceConfig.isArchive());
    assertEquals(new File(path).toURI().toURL(), resourceConfig.getUrl());
}
Also used : ResourceConfig(com.hazelcast.jet.config.ResourceConfig) File(java.io.File) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Example 9 with ResourceConfig

use of com.hazelcast.jet.config.ResourceConfig in project hazelcast-jet by hazelcast.

the class ResourceConfigTest method testAddClass_with_Class.

@Test
public void testAddClass_with_Class() throws Exception {
    JobConfig config = new JobConfig();
    config.addClass(this.getClass());
    ResourceConfig resourceConfig = config.getResourceConfigs().iterator().next();
    assertEquals(this.getClass().getName().replace('.', '/') + ".class", resourceConfig.getId());
    assertFalse(resourceConfig.isArchive());
}
Also used : ResourceConfig(com.hazelcast.jet.config.ResourceConfig) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Example 10 with ResourceConfig

use of com.hazelcast.jet.config.ResourceConfig in project hazelcast-jet by hazelcast.

the class ResourceConfigTest method testAddJar_with_File.

@Test
public void testAddJar_with_File() throws Exception {
    JobConfig config = new JobConfig();
    File file = new File("/path/to/jarfile");
    config.addJar(file);
    ResourceConfig resourceConfig = config.getResourceConfigs().iterator().next();
    assertNull(resourceConfig.getId());
    assertTrue(resourceConfig.isArchive());
    assertEquals(file.toURI().toURL(), resourceConfig.getUrl());
}
Also used : ResourceConfig(com.hazelcast.jet.config.ResourceConfig) File(java.io.File) JobConfig(com.hazelcast.jet.config.JobConfig) Test(org.junit.Test)

Aggregations

ResourceConfig (com.hazelcast.jet.config.ResourceConfig)11 JobConfig (com.hazelcast.jet.config.JobConfig)10 Test (org.junit.Test)10 File (java.io.File)6 URL (java.net.URL)3 JetException (com.hazelcast.jet.JetException)1 Util.idToString (com.hazelcast.jet.impl.util.Util.idToString)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 JarInputStream (java.util.jar.JarInputStream)1