use of org.drools.mvel.java.JavaForMvelDialectConfiguration in project drools by kiegroup.
the class KnowledgeBuilderTest method testCompilerConfiguration.
@Test
public void testCompilerConfiguration() throws Exception {
// test default is eclipse jdt core
KnowledgeBuilderImpl builder = new KnowledgeBuilderImpl();
PackageDescr pkgDescr = new PackageDescr("org.drools.mvel.compiler.test");
builder.addPackage(pkgDescr);
DialectCompiletimeRegistry reg = builder.getPackageRegistry(pkgDescr.getName()).getDialectCompiletimeRegistry();
final Field dialectField = builder.getClass().getDeclaredField("defaultDialect");
dialectField.setAccessible(true);
String dialectName = (String) dialectField.get(builder);
reg = builder.getPackageRegistry(pkgDescr.getName()).getDialectCompiletimeRegistry();
Dialect dialect = reg.getDialect(dialectName);
final Field compilerField = dialect.getClass().getDeclaredField("compiler");
compilerField.setAccessible(true);
JavaCompiler compiler = (JavaCompiler) compilerField.get(dialect);
KnowledgeBuilderConfigurationImpl conf = new KnowledgeBuilderConfigurationImpl();
JavaForMvelDialectConfiguration javaConf = (JavaForMvelDialectConfiguration) conf.getDialectConfiguration("java");
switch(javaConf.getCompiler()) {
case NATIVE:
assertSame(NativeJavaCompiler.class, compiler.getClass());
break;
case ECLIPSE:
assertSame(EclipseJavaCompiler.class, compiler.getClass());
break;
default:
fail("Unrecognized java compiler");
}
// test eclipse jdt core with property settings and default source level
conf = new KnowledgeBuilderConfigurationImpl();
javaConf = (JavaForMvelDialectConfiguration) conf.getDialectConfiguration("java");
javaConf.setCompiler(JavaForMvelDialectConfiguration.CompilerType.ECLIPSE);
builder = new KnowledgeBuilderImpl(conf);
builder.addPackage(pkgDescr);
dialectName = (String) dialectField.get(builder);
reg = builder.getPackageRegistry(pkgDescr.getName()).getDialectCompiletimeRegistry();
dialect = reg.getDialect(dialectName);
compiler = (JavaCompiler) compilerField.get(dialect);
assertSame(EclipseJavaCompiler.class, compiler.getClass());
}
use of org.drools.mvel.java.JavaForMvelDialectConfiguration in project drools by kiegroup.
the class JavaForMvelDialectConfigurationTest method checkVersion.
@Test
public void checkVersion() {
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("1.5");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("1.6");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("1.7");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("9");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("10");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("11");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("12");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("13");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("14");
new JavaForMvelDialectConfiguration().setJavaLanguageLevel("15");
}
use of org.drools.mvel.java.JavaForMvelDialectConfiguration in project drools by kiegroup.
the class PackageBuilderConfigurationTest method testProgramaticProperties2.
@Test
public void testProgramaticProperties2() {
JavaForMvelDialectConfiguration javaConf = new JavaForMvelDialectConfiguration();
javaConf.init(new KnowledgeBuilderConfigurationImpl());
javaConf.setCompiler(JavaForMvelDialectConfiguration.CompilerType.ECLIPSE);
KnowledgeBuilderConfigurationImpl cfg = new KnowledgeBuilderConfigurationImpl();
cfg.setDialectConfiguration("java", javaConf);
JavaForMvelDialectConfiguration javaConf2 = (JavaForMvelDialectConfiguration) cfg.getDialectConfiguration("java");
assertSame(javaConf, javaConf2);
assertEquals(JavaForMvelDialectConfiguration.CompilerType.ECLIPSE, javaConf2.getCompiler());
}
Aggregations