@Test public void testMissingDb() { context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG , () -> ImmutableMap.of(GeoLiteCityDatabase.GEO_HDFS_FILE, "./fakefile.mmdb") ).build(); String stellar = "GEO_GET()"; try { run(stellar, ImmutableMap.of()); } catch (Exception expected) { Assert.assertTrue(expected.getMessage().contains("File fakefile.mmdb does not exist")); } }
@Test public void testMissingDb() { context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> ImmutableMap.of(GeoLiteAsnDatabase.ASN_HDFS_FILE, "./fakefile.mmdb") ).build(); String stellar = "ASN_GET()"; try { run(stellar, ImmutableMap.of()); } catch (Exception expected) { Assert.assertTrue(expected.getMessage().contains("File fakefile.mmdb does not exist")); } }
private Context createContext(Optional<CuratorFramework> zkClient) { Context.Builder builder = new Context.Builder(); if (zkClient.isPresent()) { builder.with(Context.Capabilities.ZOOKEEPER_CLIENT, zkClient::get); } builder.with(Context.Capabilities.GLOBAL_CONFIG, () -> globalConfig); builder.with(Context.Capabilities.STELLAR_CONFIG, () -> globalConfig); return builder.build(); }
@Before public void setup() throws Exception { // create the cache Map<String, Object> cacheConfig = ImmutableMap.of( CachingStellarProcessor.MAX_CACHE_SIZE_PARAM, 2, CachingStellarProcessor.MAX_TIME_RETAIN_PARAM, 10, CachingStellarProcessor.RECORD_STATS, true ); cache = CachingStellarProcessor.createCache(cacheConfig); contextWithCache = new Context.Builder() .with(Context.Capabilities.CACHE, () -> cache) .build(); // create the object to test processor = new CachingStellarProcessor(); }
@BeforeClass public static void setup() { ConcurrencyContext infrastructure = new ConcurrencyContext(); infrastructure.initialize(5, 100, 10, null, null, false); stellarContext = new Context.Builder() .build(); StellarFunctions.initialize(stellarContext); StellarAdapter adapter = new AccessLoggingStellarAdapter().ofType("ENRICHMENT"); adapter.initializeAdapter(new HashMap<>()); EnrichmentAdapter<CacheKey> dummy = new DummyEnrichmentAdapter(); enrichmentsByType = ImmutableMap.of("stellar", adapter, "dummy", dummy); enricher = new ParallelEnricher(enrichmentsByType, infrastructure, false); }
@Test public void testListVarsWithoutVars() { Context context = new Context.Builder() .with(Context.Capabilities.SHELL_VARIABLES, () -> new HashMap<>()) .build(); Object out = run("SHELL_LIST_VARS()", new HashMap<>(), context); Assert.assertEquals(expectedEmptyList, out); } /**
private Context getStellarContext() { Map<String, Object> global = getConfigurations().getGlobalConfig(); return new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> zookeeperClient) .with(Context.Capabilities.GLOBAL_CONFIG, () -> global) .with(Context.Capabilities.STELLAR_CONFIG, () -> global) .build(); }
@Before public void setup() throws Exception { testFolder.create(); context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG , () -> ImmutableMap.of(GeoLiteCityDatabase.GEO_HDFS_FILE, geoHdfsFile.getAbsolutePath()) ) .build(); }
/** * Create the execution context for running Stellar. */ public static Context getContext(Map<String, String> globals) { Context context = new Context.Builder() .with(Context.Capabilities.GLOBAL_CONFIG, () -> globals) .with(Context.Capabilities.STELLAR_CONFIG, () -> globals) .build(); StellarFunctions.initialize(context); return context; } }
protected void initializeStellar() { this.stellarContext = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) .build(); StellarFunctions.initialize(stellarContext); this.functionResolver = StellarFunctions.FUNCTION_RESOLVER(); }
protected void initializeStellar() { stellarContext = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) .build(); StellarFunctions.initialize(stellarContext); }
@Before public void setup() throws Exception { testFolder.create(); context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> ImmutableMap.of(GeoLiteAsnDatabase.ASN_HDFS_FILE, asnHdfsFile.getAbsolutePath()) ).build(); }
@Before public void setup() throws Exception { context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG , () -> ImmutableMap.of(GeoLiteCityDatabase.GEO_HDFS_FILE, geoHdfsFile.getAbsolutePath()) ) .build(); }
@Before public void setup() throws Exception { context = new Context.Builder().with(Context.Capabilities.GLOBAL_CONFIG, () -> ImmutableMap.of(GeoLiteAsnDatabase.ASN_HDFS_FILE, asnHdfsFile.getAbsolutePath()) ).build(); }
protected void initializeStellar() { stellarContext = new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> getConfigurations().getGlobalConfig()) .with(Context.Capabilities.STELLAR_CONFIG, () -> getConfigurations().getGlobalConfig()) .build(); StellarFunctions.initialize(stellarContext); }
public StellarTransformationTest(Cache<CachingStellarProcessor.Key, Object> cache) { if(cache == null) { context = Context.EMPTY_CONTEXT(); } else { context = new Context.Builder().with(Context.Capabilities.CACHE, () -> cache).build(); } }
@Before public void setup() throws Exception { context = new Context.Builder().build(); } @Test
@Test public void testListVarsWithVars() { Map<String, VariableResult> variables = ImmutableMap.of( "foo", VariableResult.withExpression(2.0, "1 + 1")); Context context = new Context.Builder() .with(Context.Capabilities.SHELL_VARIABLES , () -> variables) .build(); Object out = run("SHELL_LIST_VARS()", new HashMap<>(), context); Assert.assertEquals(expectedListWithFoo, out); }
public Context getStellarContext() { Map<String, Object> global = getConfigurations().getGlobalConfig(); return new Context.Builder() .with(Context.Capabilities.ZOOKEEPER_CLIENT, () -> client) .with(Context.Capabilities.GLOBAL_CONFIG, () -> global) .with(Context.Capabilities.STELLAR_CONFIG, () -> global) .build(); }
/** * Create a function resolver to test. * @param config The configuration for Stellar. */ public static ClasspathFunctionResolver create(Properties config) { ClasspathFunctionResolver resolver = new ClasspathFunctionResolver(); Context context = new Context.Builder() .with(Context.Capabilities.STELLAR_CONFIG, () -> config) .build(); resolver.initialize(context); return resolver; }