Search in sources :

Example 6 with JavaScriptConfig

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

Example 7 with JavaScriptConfig

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);
}
Also used : JavaScriptConfig(org.apache.druid.js.JavaScriptConfig) TimestampSpec(org.apache.druid.data.input.impl.TimestampSpec) DimensionsSpec(org.apache.druid.data.input.impl.DimensionsSpec) JavaScriptParseSpec(org.apache.druid.data.input.impl.JavaScriptParseSpec) Test(org.junit.Test)

Example 8 with JavaScriptConfig

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

Example 9 with JavaScriptConfig

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

Example 10 with JavaScriptConfig

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

Aggregations

JavaScriptConfig (org.apache.druid.js.JavaScriptConfig)17 Test (org.junit.Test)17 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Properties (java.util.Properties)2 DimensionsSpec (org.apache.druid.data.input.impl.DimensionsSpec)2 JavaScriptParseSpec (org.apache.druid.data.input.impl.JavaScriptParseSpec)2 TimestampSpec (org.apache.druid.data.input.impl.TimestampSpec)2 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)2 DoubleAnyAggregatorFactory (org.apache.druid.query.aggregation.any.DoubleAnyAggregatorFactory)1 FloatAnyAggregatorFactory (org.apache.druid.query.aggregation.any.FloatAnyAggregatorFactory)1 LongAnyAggregatorFactory (org.apache.druid.query.aggregation.any.LongAnyAggregatorFactory)1 StringAnyAggregatorFactory (org.apache.druid.query.aggregation.any.StringAnyAggregatorFactory)1 CardinalityAggregatorFactory (org.apache.druid.query.aggregation.cardinality.CardinalityAggregatorFactory)1 DoubleFirstAggregatorFactory (org.apache.druid.query.aggregation.first.DoubleFirstAggregatorFactory)1 FloatFirstAggregatorFactory (org.apache.druid.query.aggregation.first.FloatFirstAggregatorFactory)1 LongFirstAggregatorFactory (org.apache.druid.query.aggregation.first.LongFirstAggregatorFactory)1 StringFirstAggregatorFactory (org.apache.druid.query.aggregation.first.StringFirstAggregatorFactory)1 HyperUniquesAggregatorFactory (org.apache.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory)1 DoubleLastAggregatorFactory (org.apache.druid.query.aggregation.last.DoubleLastAggregatorFactory)1 FloatLastAggregatorFactory (org.apache.druid.query.aggregation.last.FloatLastAggregatorFactory)1