Search in sources :

Example 6 with JavaScriptConfig

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);
}
Also used : JavaScriptConfig(io.druid.js.JavaScriptConfig) Test(org.junit.Test)

Example 7 with JavaScriptConfig

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);
}
Also used : JavaScriptConfig(io.druid.js.JavaScriptConfig) Test(org.junit.Test)

Example 8 with JavaScriptConfig

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);
}
Also used : JavaScriptConfig(io.druid.js.JavaScriptConfig) Test(org.junit.Test)

Example 9 with JavaScriptConfig

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));
}
Also used : JavaScriptConfig(io.druid.js.JavaScriptConfig) Test(org.junit.Test)

Example 10 with JavaScriptConfig

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);
}
Also used : JavaScriptConfig(io.druid.js.JavaScriptConfig) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Aggregations

JavaScriptConfig (io.druid.js.JavaScriptConfig)11 Test (org.junit.Test)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)2 Properties (java.util.Properties)2