use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptModuleTest method testInjectionDefault.
@Test
public void testInjectionDefault() throws Exception {
JavaScriptConfig config = makeInjectorWithProperties(new Properties()).getInstance(JavaScriptConfig.class);
Assert.assertFalse(config.isEnabled());
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptWorkerSelectStrategyTest method testDisabled.
@Test
public void testDisabled() throws Exception {
ObjectMapper mapper = new DefaultObjectMapper();
mapper.setInjectableValues(new InjectableValues.Std().addValue(JavaScriptConfig.class, new JavaScriptConfig(false)));
final String strategyString = mapper.writeValueAsString(STRATEGY);
expectedException.expect(JsonMappingException.class);
expectedException.expectCause(CoreMatchers.<Throwable>instanceOf(IllegalStateException.class));
expectedException.expectMessage("JavaScript is disabled");
mapper.readValue(strategyString, JavaScriptWorkerSelectStrategy.class);
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptAggregatorTest method testJavaScriptDisabledFactorizeBuffered.
@Test
public void testJavaScriptDisabledFactorizeBuffered() {
final JavaScriptAggregatorFactory factory = new JavaScriptAggregatorFactory("foo", ImmutableList.of("foo"), scriptDoubleSum.get("fnAggregate"), scriptDoubleSum.get("fnReset"), scriptDoubleSum.get("fnCombine"), new JavaScriptConfig(false));
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("JavaScript is disabled");
factory.factorizeBuffered(DUMMY_COLUMN_SELECTOR_FACTORY);
Assert.assertTrue(false);
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptParseSpecTest method testMakeParser.
@Test
public void testMakeParser() {
final JavaScriptConfig config = JavaScriptConfig.getEnabledInstance();
JavaScriptParseSpec spec = new JavaScriptParseSpec(new TimestampSpec("abc", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("abc")), null, null), "function(str) { var parts = str.split(\"-\"); return { one: parts[0], two: parts[1] } }", config);
final Parser<String, Object> parser = spec.makeParser();
final Map<String, Object> obj = parser.parse("x-y");
Assert.assertEquals(ImmutableMap.of("one", "x", "two", "y"), obj);
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptParseSpecTest method testMakeParserNotAllowed.
@Test
public void testMakeParserNotAllowed() {
final JavaScriptConfig config = new JavaScriptConfig(false);
JavaScriptParseSpec spec = new JavaScriptParseSpec(new TimestampSpec("abc", "iso", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(Arrays.asList("abc")), null, null), "abc", config);
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("JavaScript is disabled");
spec.makeParser();
}
Aggregations