use of org.apache.druid.js.JavaScriptConfig in project druid by druid-io.
the class JavaScriptModuleTest method testInjectionEnabled.
@Test
public void testInjectionEnabled() {
final Properties props = new Properties();
props.setProperty("druid.javascript.enabled", "true");
JavaScriptConfig config = makeInjectorWithProperties(props).getInstance(JavaScriptConfig.class);
Assert.assertTrue(config.isEnabled());
}
use of org.apache.druid.js.JavaScriptConfig in project druid by druid-io.
the class ProtobufInputRowParserTest method testDisableJavaScript.
@Test
public void testDisableJavaScript() {
final JavaScriptParseSpec parseSpec = new JavaScriptParseSpec(new TimestampSpec("timestamp", "auto", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("dim1", "dim2"))), "func", new JavaScriptConfig(false));
final ProtobufInputRowParser parser = new ProtobufInputRowParser(parseSpec, decoder, null, null);
expectedException.expect(CoreMatchers.instanceOf(IllegalStateException.class));
expectedException.expectMessage("JavaScript is disabled");
// noinspection ResultOfMethodCallIgnored (this method call will trigger the expected exception)
parser.parseBatch(ByteBuffer.allocate(1)).get(0);
}
use of org.apache.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.instanceOf(IllegalStateException.class));
expectedException.expectMessage("JavaScript is disabled");
mapper.readValue(strategyString, WorkerSelectStrategy.class);
}
use of org.apache.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(Collections.singletonList("abc"))), "abc", config);
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("JavaScript is disabled");
spec.makeParser();
}
use of org.apache.druid.js.JavaScriptConfig in project druid by druid-io.
the class StringInputRowParserTest method testDisableJavaScript2.
@Test
public void testDisableJavaScript2() {
final JavaScriptParseSpec parseSpec = new JavaScriptParseSpec(new TimestampSpec("timestamp", "auto", null), new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of("dim1", "dim2"))), "func", new JavaScriptConfig(false));
final StringInputRowParser parser = new StringInputRowParser(parseSpec, "UTF-8");
expectedException.expect(CoreMatchers.instanceOf(IllegalStateException.class));
expectedException.expectMessage("JavaScript is disabled");
parser.parse("");
}
Aggregations