use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptExtractionFnTest method testJavascriptNotAllowed.
@Test
public void testJavascriptNotAllowed() {
String function = "function(str) { return str.substring(0,3); }";
ExtractionFn extractionFn = new JavaScriptExtractionFn(function, false, new JavaScriptConfig(false));
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("JavaScript is disabled");
extractionFn.apply("hey");
Assert.assertTrue(false);
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptDimFilterTest method testToFilterNotAllowed.
@Test
public void testToFilterNotAllowed() {
JavaScriptDimFilter javaScriptDimFilter = new JavaScriptDimFilter("dim", FN1, null, new JavaScriptConfig(false));
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("JavaScript is disabled");
javaScriptDimFilter.toFilter();
Assert.assertTrue(false);
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptAggregatorTest method testJavaScriptDisabledFactorize.
@Test
public void testJavaScriptDisabledFactorize() {
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.factorize(DUMMY_COLUMN_SELECTOR_FACTORY);
Assert.assertTrue(false);
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptPostAggregatorTest method testComputeJavaScriptNotAllowed.
@Test
public void testComputeJavaScriptNotAllowed() {
String absPercentFunction = "function(delta, total) { return 100 * Math.abs(delta) / total; }";
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("JavaScript is disabled");
new JavaScriptPostAggregator("absPercent", Lists.newArrayList("delta", "total"), absPercentFunction, new JavaScriptConfig(false));
}
use of io.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptTieredBrokerSelectorStrategyTest 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, JavaScriptTieredBrokerSelectorStrategy.class);
}
Aggregations