Search in sources :

Example 1 with JavaScriptConfig

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

Example 2 with JavaScriptConfig

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);
}
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)

Example 3 with JavaScriptConfig

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

Example 4 with JavaScriptConfig

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

Example 5 with JavaScriptConfig

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