01: package org.drools.compiler;
02:
03: import java.io.InputStreamReader;
04:
05: import org.drools.DroolsTestCase;
06: import org.drools.rule.builder.dialect.java.JavaDialectConfiguration;
07:
08: public class Java5Test extends DroolsTestCase {
09:
10: public void testJava5Rule() throws Exception {
11: final String javaVersion = System
12: .getProperty("java.specification.version");
13: //do not execute tests under JDK 1.4
14: //otherwise the compiled version cannot be interpreted
15: if (javaVersion.equals("1.4")) {
16: System.out
17: .println("Skipping Java 1.5 tests - current JDK not compatible");
18: return;
19: }
20: final PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
21: JavaDialectConfiguration javaConf = (JavaDialectConfiguration) conf
22: .getDialectConfiguration("java");
23: javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
24: javaConf.setJavaLanguageLevel("1.5");
25:
26: final PackageBuilder builder = new PackageBuilder();
27: builder.addPackageFromDrl(new InputStreamReader(this .getClass()
28: .getResourceAsStream("java5_rule.drl")));
29: assertFalse(builder.hasErrors());
30: }
31:
32: public void testJava14Defaults() throws Exception {
33: final PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
34: JavaDialectConfiguration javaConf = (JavaDialectConfiguration) conf
35: .getDialectConfiguration("java");
36: javaConf.setCompiler(JavaDialectConfiguration.JANINO);
37: final PackageBuilder builder = new PackageBuilder(conf);
38: builder.addPackageFromDrl(new InputStreamReader(this .getClass()
39: .getResourceAsStream("java5_rule.drl")));
40: assertTrue(builder.hasErrors());
41: }
42:
43: }
|