[jboss-svn-commits] JBL Code SVN: r34792 - in labs/jbossrules/branches/DRLv6/src: main/resources and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 19 10:30:35 EDT 2010
Author: dsotty
Date: 2010-08-19 10:30:35 -0400 (Thu, 19 Aug 2010)
New Revision: 34792
Modified:
labs/jbossrules/branches/DRLv6/src/main/java/org/drools/util/ProTreeView.java
labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g
labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java
Log:
Modified: labs/jbossrules/branches/DRLv6/src/main/java/org/drools/util/ProTreeView.java
===================================================================
--- labs/jbossrules/branches/DRLv6/src/main/java/org/drools/util/ProTreeView.java 2010-08-19 13:45:16 UTC (rev 34791)
+++ labs/jbossrules/branches/DRLv6/src/main/java/org/drools/util/ProTreeView.java 2010-08-19 14:30:35 UTC (rev 34792)
@@ -84,9 +84,10 @@
private LabelRenderer m_nodeRenderer;
private EdgeRenderer m_edgeRenderer;
+ private NodeLinkTreeLayout treeLayout;
private String m_label = "label";
- private int m_orientation = Constants.ORIENT_LEFT_RIGHT;
+ private int m_orientation = Constants.ORIENT_TOP_BOTTOM;
public ProTreeView(Tree t, String label) {
super(new Visualization());
@@ -131,9 +132,9 @@
m_vis.putAction("animatePaint", animatePaint);
// create the tree layout action
- NodeLinkTreeLayout treeLayout = new NodeLinkTreeLayout(tree,
+ treeLayout = new NodeLinkTreeLayout(tree,
m_orientation, 50, 0, 8);
- treeLayout.setLayoutAnchor(new Point2D.Double(50,200));
+ treeLayout.setLayoutAnchor(new Point2D.Double(400,50));
m_vis.putAction("treeLayout", treeLayout);
CollapsedSubtreeLayout subLayout =
@@ -228,6 +229,7 @@
m_edgeRenderer.setHorizontalAlignment2(Constants.LEFT);
m_edgeRenderer.setVerticalAlignment1(Constants.CENTER);
m_edgeRenderer.setVerticalAlignment2(Constants.CENTER);
+ treeLayout.setLayoutAnchor(new Point2D.Double(50,200));
break;
case Constants.ORIENT_RIGHT_LEFT:
m_nodeRenderer.setHorizontalAlignment(Constants.RIGHT);
@@ -235,6 +237,7 @@
m_edgeRenderer.setHorizontalAlignment2(Constants.RIGHT);
m_edgeRenderer.setVerticalAlignment1(Constants.CENTER);
m_edgeRenderer.setVerticalAlignment2(Constants.CENTER);
+ treeLayout.setLayoutAnchor(new Point2D.Double(750,200));
break;
case Constants.ORIENT_TOP_BOTTOM:
m_nodeRenderer.setHorizontalAlignment(Constants.CENTER);
@@ -242,6 +245,7 @@
m_edgeRenderer.setHorizontalAlignment2(Constants.CENTER);
m_edgeRenderer.setVerticalAlignment1(Constants.BOTTOM);
m_edgeRenderer.setVerticalAlignment2(Constants.TOP);
+ treeLayout.setLayoutAnchor(new Point2D.Double(400,50));
break;
case Constants.ORIENT_BOTTOM_TOP:
m_nodeRenderer.setHorizontalAlignment(Constants.CENTER);
@@ -249,6 +253,7 @@
m_edgeRenderer.setHorizontalAlignment2(Constants.CENTER);
m_edgeRenderer.setVerticalAlignment1(Constants.TOP);
m_edgeRenderer.setVerticalAlignment2(Constants.BOTTOM);
+ treeLayout.setLayoutAnchor(new Point2D.Double(400,400));
break;
default:
throw new IllegalArgumentException(
@@ -349,7 +354,7 @@
JFrame frame = new JFrame(titleStr);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setContentPane(panel);
frame.pack();
Modified: labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g
===================================================================
--- labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g 2010-08-19 13:45:16 UTC (rev 34791)
+++ labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g 2010-08-19 14:30:35 UTC (rev 34792)
@@ -16,11 +16,14 @@
VT_DATA_TYPE;
VT_DIM_SIZE;
+ VT_IMPORT;
VT_FUNCTION_IMPORT;
- VT_IMPORT_ID;
+ VT_STAR;
+ VT_FUNCTION;
VT_FUNCTION_ID;
VT_PARAM;
VT_PARAM_LIST;
+ VT_NAME;
VT_TEMPLATE;
VT_TEMPLATE_ID;
@@ -29,12 +32,19 @@
VT_TYPE_DECLARE;
VT_TYPE_DECLARE_ID;
+ VT_EXTENDS;
VT_DL_DEFINITION;
VT_DL_TYPE;
+ VT_FIELD;
VT_RULE_ID;
VT_ATTRIBUTES;
VT_DIALECT;
+
+ VT_LHS;
+ VT_ARROW;
+ VT_RHS;
+
VT_RHS_CHUNK;
VT_CURLY_CHUNK;
@@ -44,6 +54,7 @@
VT_NEW_OBJ;
VT_TYPE;
VT_ARGS;
+ VT_MSR;
VT_AND_IMPLICIT;
VT_IMPLIES;
@@ -61,15 +72,19 @@
VT_NEXISTS;
VT_PATTERN;
+ VT_NESTED_PATTERN;
VT_ENABLED;
- VT_QUERY_PATTERN;
+ VT_QUERY_PATTERN;
VT_POSITIONAL_VAR;
VT_POSITIONAL_CONST;
VT_POSITIONAL_INDEX;
VT_BINDING;
- VT_FIELD;
+ VT_ACCESSOR;
+ VT_INDEXER;
+ VT_INDEX_ALL;
+ VT_METHOD;
VT_EXPR;
VT_FILTER;
@@ -115,13 +130,13 @@
;
package_id
- : id+=ID ( id+=DOT id+=ID )*
- -> ^(VT_PACKAGE_ID ID+)
+ : fully_qualified_name
;
+
/**************************** STATEMENTS *******************************************/
statement
@@ -152,8 +167,8 @@
@init{
int dim=0;
}
- : id+=ID ( DOT id+=ID )* (dimension_definition {dim++;})*
- -> ^(VT_DATA_TYPE VT_DIM_SIZE[$start,""+dim] $id+ )
+ : fully_qualified_name (dimension_definition {dim++;})*
+ -> ^(VT_DATA_TYPE VT_DIM_SIZE[$start,""+dim] fully_qualified_name )
;
dimension_definition
: LEFT_SQUARE RIGHT_SQUARE
@@ -163,24 +178,25 @@
/**************************** IMPORT *******************************************/
import_statement
: IMPORT import_name SEMICOLON?
- -> ^(IMPORT import_name)
+ -> ^(VT_IMPORT import_name)
;
function_import_statement
- : imp=IMPORT FUNCTION import_name SEMICOLON?
- -> ^(VT_FUNCTION_IMPORT[$imp] FUNCTION import_name)
+ : IMPORT FUNCTION import_name SEMICOLON?
+ -> ^(VT_FUNCTION_IMPORT import_name)
;
import_name
- : id+=ID ( id+=DOT id+=ID )* id+=DOT_STAR?
- -> ^(VT_IMPORT_ID ID+ DOT_STAR?)
+ : fully_qualified_name star=DOT_STAR?
+ -> {star==null}? fully_qualified_name
+ -> ^(VT_STAR fully_qualified_name)
;
/**************************** FUNCTION *******************************************/
function
: FUNCTION data_type? function_id parameters curly_chunk
- -> ^(FUNCTION data_type? function_id parameters curly_chunk)
+ -> ^(VT_FUNCTION data_type? function_id parameters curly_chunk)
;
function_id
@@ -249,8 +265,8 @@
;
type_declare_id
- : id=ID
- -> VT_TYPE_DECLARE_ID[$id]
+ : fully_qualified_name
+ -> ^(VT_TYPE_DECLARE_ID fully_qualified_name)
;
type_declare_attributes
@@ -301,7 +317,8 @@
extend
- : EXTEND ID
+ : EXTEND fully_qualified_name
+ -> ^(VT_EXTENDS fully_qualified_name)
;
decl_field
@@ -391,11 +408,16 @@
: RULE rule_id (EXTEND rule_id)?
rule_metadata*
rule_attributes?
- deduction?
- implication?
+ rule_arrow?
when_part?
then_part
- -> ^(RULE rule_id ^(EXTEND rule_id)? rule_metadata* rule_attributes? when_part? then_part)
+ -> ^(RULE rule_id
+ ^(VT_EXTENDS rule_id)?
+ rule_metadata*
+ rule_attributes?
+ rule_arrow?
+ when_part?
+ then_part)
;
@@ -411,8 +433,14 @@
: AT! ID^ paren_chunk?
;
+rule_arrow
+ : (
+ (implication deduction?)
+ | (deduction implication?)
+ )
+ -> ^(VT_ARROW implication? deduction?)
+ ;
-
deduction
: A_DEDUCTION^ operator_attributes
;
@@ -503,7 +531,7 @@
;
ra_lock_on_active
- : A_LOCKONACTIVE^ (LEFT_PAREN! BOOL RIGHT_PAREN)!
+ : A_LOCKONACTIVE^ (LEFT_PAREN! BOOL RIGHT_PAREN!)
;
ra_direction
@@ -587,13 +615,15 @@
when_part
- : WHEN^
- lhs_root
+ : WHEN
+ lhs_root?
+ -> ^(VT_LHS lhs_root?)
;
lhs_root
- : lhs_implies*
- -> ^(VT_AND_IMPLICIT lhs_implies*)
+ : lhs_implies more=lhs_implies*
+ -> {more==null}? lhs_implies
+ -> ^(VT_AND_IMPLICIT lhs_implies+)
;
@@ -735,7 +765,10 @@
/* over_clause obsolete, replaced by filters (see far below in lhs_unary)*/
lhs_atom_pattern
: ID LEFT_PAREN constraints? RIGHT_PAREN operator_attributes? from?
- -> ^(VT_AND operator_attributes? VT_ENABLED ^(VT_PATTERN ID) constraints? from? )
+ -> ^(VT_PATTERN
+ ^(VT_AND operator_attributes? VT_ENABLED ^(VT_TYPE ID) constraints? )
+ from?
+ )
;
@@ -792,6 +825,11 @@
/********************************************* ATOMIC DATA DEFINITIONS ************************************************/
+fully_qualified_name
+ : ID ( DOT ID )*
+ -> ^(VT_NAME ID+)
+ ;
+
string_list
@init {
StringBuilder buf = new StringBuilder();
@@ -806,8 +844,12 @@
k=6;
}
: STRING
- | INT msr_unit?
- | FLOAT msr_unit?
+ | INT m=msr_unit?
+ -> {m==null}? INT
+ -> ^(VT_MSR INT $m)
+ | FLOAT m=msr_unit?
+ -> {m==null}? FLOAT
+ -> ^(VT_MSR FLOAT $m)
| BOOL
| NULL
| literal_object
@@ -821,7 +863,9 @@
var_literal
- : VAR msr_unit?
+ : VAR m=msr_unit?
+ -> {m==null}? VAR
+ -> ^(VT_MSR VAR $m)
;
label
@@ -829,7 +873,8 @@
;
msr_unit
- : GATE ID msr_unit?
+ : (GATE! ID)+
+ //-> ^(VT_MSR ID+)
;
@@ -866,21 +911,27 @@
;
method
- : ID LEFT_PAREN args=method_args? RIGHT_PAREN msr_unit?
- -> {args==null}? ^(ID msr_unit? )
- -> ^(ID msr_unit? ^(VT_ARGS method_args?))
+ : core=method_core m=msr_unit?
+ -> {m==null}? $core
+ -> ^(VT_MSR $core $m)
+ ;
+
+method_core
+ : ID LEFT_PAREN args=method_args? RIGHT_PAREN
+ -> {args==null}? ^(VT_METHOD ID )
+ -> ^(VT_METHOD ID ^(VT_ARGS method_args?))
;
expr_root
- : factor ( (PLUS | MINUS) factor )*
+ : factor ( (PLUS | MINUS)^ factor )*
;
factor
- : term ( (TIMES | SLASH) term )*
+ : term ( (TIMES | SLASH)^ term )*
;
term
- : MINUS? expr_unary
+ : (MINUS^)? expr_unary
;
expr_unary
@@ -976,9 +1027,24 @@
;
constr_atom
- : left_expression restriction_root^?
+ : left=left_expression rest=restriction_root?
+ -> {rest==null}? ^(left_expression)
+ -> ^(VT_AND_IMPLICIT left_expression restriction_root)
;
+ /*
+ {
+ if (rest != null) {
+ Tree t = ((Tree) rest.getTree());
+ Tree temp = t.getChild(0);
+ t.setChild(0,(Tree) left.getTree());
+ t.addChild(temp);
+ }
+ }
+ -> {rest==null}? ^($left)
+ -> ^($rest)
+ */
+
restriction_root
@@ -1075,18 +1141,19 @@
: label
(
accessor_path
- -> ^(VT_BINDING label ^(VT_FIELD accessor_path))
+ -> ^(VT_BINDING label accessor_path)
| PIPE expr_root PIPE
-> ^(VT_BINDING label ^(VT_EXPR expr_root))
)
| PIPE expr_root PIPE
-> ^(VT_EXPR expr_root)
| accessor_path
- -> ^(VT_FIELD accessor_path)
+ -> accessor_path
;
right_expression
: expr_root
+ -> ^(VT_EXPR expr_root)
;
@@ -1096,33 +1163,67 @@
accessor_path
- : accessor (DOT! accessor)*
- | var (DOT! accessor)+
+ : accessor (DOT accessor)*
+ -> ^(VT_ACCESSOR accessor+)
+ | var (DOT accessor)+
+ -> ^(VT_ACCESSOR var accessor+)
;
accessor
:
- (ID LEFT_PAREN) => method indexer?
- | ID indexer?
+ (ID LEFT_PAREN) => m=method ix=indexer?
+ {
+ if (ix != null ) {
+ Tree t = ((Tree) ix.getTree());
+ Tree temp = t.getChild(0);
+ t.setChild(0,(Tree) m.getTree());
+ t.addChild(temp);
+ }
+ }
+ -> {ix==null}? ^($m)
+ -> ^($ix)
+ | id=ID ix=indexer?
+ {
+ if (ix != null ) {
+ Tree t = ((Tree) ix.getTree());
+ Tree temp = t.getChild(0);
+ t.setChild(0,new CommonTree(new CommonToken(STRING,$id.text)));
+ t.addChild(temp);
+ }
+ }
+ -> {ix==null}? ^(ID)
+ -> ^($ix)
| nested_obj_pattern
;
nested_obj_pattern
- : GATE! (ID (DOT! ID)*)? LEFT_PAREN! constraints RIGHT_PAREN!
+ : GATE fqn=fully_qualified_name? LEFT_PAREN constraints RIGHT_PAREN
+ -> {fqn==null}? ^(VT_NESTED_PATTERN constraints)
+ -> ^(VT_NESTED_PATTERN
+ ^(VT_AND ^(VT_TYPE fully_qualified_name) constraints)
+ )
;
indexer
- : LEFT_SQUARE!
+ : LEFT_SQUARE
(
INT
+ -> ^(VT_INDEXER INT)
| STRING
+ -> ^(VT_INDEXER STRING)
| method
- | GATE! lhs_label_atom_pattern
- )?
- RIGHT_SQUARE!
+ -> ^(VT_INDEXER method)
+ | GATE lhs_label_atom_pattern
+ -> ^(VT_INDEXER lhs_label_atom_pattern)
+ )
+ RIGHT_SQUARE
+
+ | LEFT_SQUARE RIGHT_SQUARE
+ -> ^(VT_INDEXER VT_INDEX_ALL)
+
;
@@ -1396,7 +1497,10 @@
then_part
:
rhs_structured
- | rhs_chunk
+ -> ^(VT_RHS rhs_structured)
+ | rhs_chunk
+ -> ^(VT_RHS rhs_chunk)
+
;
Modified: labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java
===================================================================
--- labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java 2010-08-19 13:45:16 UTC (rev 34791)
+++ labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java 2010-08-19 14:30:35 UTC (rev 34792)
@@ -2,16 +2,25 @@
import static org.junit.Assert.assertTrue;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
import java.io.ByteArrayInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Collections;
import java.util.Date;
+import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;
@@ -34,7 +43,11 @@
private static FileWriter writer;
private boolean visual = false;
+ public boolean isVisual() { return visual; }
+ public void setVisual(boolean visual) { this.visual = visual; }
+
+
@BeforeClass
public static void setUpBeforeClass() throws Exception {
log = Logger.getAnonymousLogger();
@@ -42,10 +55,6 @@
writer = new FileWriter("out/DRLv6Log.txt");
}
-
-
-
-
@AfterClass
public static void tearDownAfterClass() throws Exception {
@@ -101,7 +110,9 @@
String rule = "global";
String[] testDRL = new String[] {
"global int N ",
+ "global String[][] tab ",
"global org.it.pack.String strix ;"
+
};
check(rule,testDRL);
}
@@ -163,11 +174,22 @@
}
+ @Test
+ public void test_fqn() {
+ String rule = "fully_qualified_name";
+ String[] testDRL = new String[] {
+ "Student",
+ "org.Student",
+ "org.other.Student"
+ };
+ check(rule,testDRL);
+ }
+
@Test
public void test_type_declaration() {
String rule = "type_declaration";
String[] testDRL = new String[] {
- "declare Student extends Person" + "\n" +
+ "declare org.Student extends com.Person" + "\n" +
" @role(entity) " + "\n" +
" @namespace(myNS=\"http:\\\\www.stix.com\\domain\\subd#\") " + "\n" +
" age : int " + "\n" +
@@ -252,6 +274,20 @@
}
+ @Test
+ public void test_rule_arrow() {
+ String rule = "rule";
+ String[] testDRL = new String[] {
+ "rule test deduction @crisp when then end \n",
+ "rule test implication @crisp when then end \n",
+ "rule test deduction @crisp implication @crisp when then end \n",
+ "rule test implication @crisp deduction @crisp when then end \n",
+
+ };
+ check(rule,testDRL);
+ }
+
+
@Test
public void test_rule_attributes() {
String rule = "rule_attributes";
@@ -362,6 +398,10 @@
String[] testDRL = new String[] {
"rule test when " +
"Car() and Taxi() and Bus()" +
+ "then end",
+
+ "rule test when " +
+ "Car() Taxi() Bus()" +
"then end"
};
check(rule,testDRL);
@@ -538,13 +578,23 @@
public void test_literal_object() {
String rule = "literal_object";
String[] testDRL = new String[] {
- "new Thing(13, $var, true)"
+ "new Thing(13, $var, true, new Obj(2))",
};
check(rule,testDRL);
}
+ @Test
+ public void test_method() {
+ String rule = "method";
+ String[] testDRL = new String[] {
+ "method(2.0, 3.0#km, \"xx\")",
+ "method()#km",
+ };
+ check(rule,testDRL);
+ }
+
@Test
public void test_method_args() {
String rule = "literal_object";
@@ -632,7 +682,7 @@
String[] testDRL = new String[] {
"rule test when " + "\n" +
" Person( neg very (name == \"john\" implies age < 18) )" + "\n" +
- "then end"
+ "then end",
};
check(rule,testDRL);
}
@@ -699,7 +749,7 @@
public void test_restriction_root() {
String rule = "restriction_root";
String[] testDRL = new String[] {
- " all == @crisp 18 + 2*$x#km " ,
+ " all == @crisp 18 + 2#ms*$x#km " ,
// TODO
//" all == @crisp 18 + 2*$var "
// again, works only within a rule and not parsed standalone
@@ -708,8 +758,30 @@
check(rule,testDRL);
}
+ @Test
+ public void test_msr_unit() {
+ String rule = "msr_unit";
+ String[] testDRL = new String[] {
+ " #m#km#cm" ,
+ };
+ check(rule,testDRL);
+ }
+ @Test
+ public void test_literal_msr_unit() {
+ String rule = "literal";
+ String[] testDRL = new String[] {
+ " 2#km ",
+ " 2.0#cm#m " ,
+ };
+ check(rule,testDRL);
+ }
+
+
+
+
+
@Test
public void test_expression() {
String rule = "right_expression";
@@ -745,23 +817,11 @@
};
check(rule,testDRL);
}
+
@Test
- public void test_restriction_root_in_rule() {
- String rule = "rule";
- String[] testDRL = new String[] {
- "rule test when " + "\n" +
- " Person( age all == @crisp 18+2*$x )" + "\n" +
- "then end"
- };
- check(rule,testDRL);
- }
-
-
-
- @Test
public void test_left_expression() {
String rule = "left_expression";
String[] testDRL = new String[] {
@@ -864,8 +924,8 @@
public void test_from() {
String rule = "from";
String[] testDRL = new String[] {
- " from entrypoint byId ",
- " from entrypoint \"byStr\" ",
+ " from entry-point byId ",
+ " from entry-point \"byStr\" ",
" from $var.access ",
@@ -903,6 +963,23 @@
@Test
+ public void test_binding() {
+ String rule = "rule";
+ String[] testDRL = new String[] {
+ "rule test when" + "\n" +
+ " Person( $a : age ) " + "\n" +
+ "then end",
+
+ "rule test when" + "\n" +
+ " Person( $a : | age + 4 | ) " + "\n" +
+ "then end",
+ };
+ check(rule,testDRL);
+ }
+
+
+
+ @Test
public void test_inner_quantifier() {
String rule = "inner_quantifier";
String[] testDRL = new String[] {
@@ -974,11 +1051,83 @@
}
+ @Test
+ public void test_dle_nested_objects() {
+ String rule = "lhs_atom_pattern";
+ String[] testDRL = {
+ "Person( name== \"mark\", address.#( city == \"london\", country == \"uk\") )"
+ };
+
+ check(rule,testDRL);
+ }
+ @Test
+ public void test_dle_nested_objects_cast() {
+ String rule = "lhs_atom_pattern";
+ String[] testDRL = {
+ "Person( name== \"mark\", address.#org.domain.LongAddress( city == \"london\", country == \"uk\") )"
+ };
+
+ check(rule,testDRL);
+ }
+ @Test
+ public void test_dle_positional() {
+ String rule = "lhs_atom_pattern";
+ String[] testDRL = {
+ "Person( \"mark\", 34, address.#(\"london\", \"uk\") )"
+ };
+
+ check(rule,testDRL);
+ }
+ @Test
+ public void test_dle_mixed() {
+ String rule = "lhs_atom_pattern";
+ String[] testDRL = {
+ "Person( \"mark\", age == 34, address.#(\"london\", \"uk\") )"
+ };
+
+ check(rule,testDRL);
+ }
+ @Test
+ public void test_dle_methods() {
+ String rule = "lhs_atom_pattern";
+ String[] testDRL = {
+ "Person( m1() == $x, address.m2() == $y, $z : m3() )"
+ };
+
+ check(rule,testDRL);
+ }
+
+ @Test
+ public void test_dle_mapsarrays() {
+ String rule = "lhs_atom_pattern";
+ String[] testDRL = {
+ "Person( pets[0].age == 15 )",
+ "Person( pets[\"rover\"].age == 15 )"
+ };
+
+ check(rule,testDRL);
+ }
+
+ @Test
+ public void test_dle_xpath_filters() {
+ String rule = "lhs_label_atom_pattern";
+ String[] testDRL = {
+ "$per : Person( $pet: pets[ #Dog( age == 15 ) ] )",
+ "$per : Person( $a : mAddr()[ #LongAddress( loc == \"london\") ] )",
+ "$per : Person( $pet : pets[] )",
+ "$per : Person( $pet : pets[ last() ] )"
+ };
+
+ check(rule,testDRL);
+ }
+
+
+
/*
@Test
public void test_ {
@@ -1131,7 +1280,44 @@
log = Logger.getAnonymousLogger();
log.setLevel(Level.INFO);
tester.setVisual(true);
- tester.check("test_rule");
+
+
+ Vector<String> methods = new Vector<String>();
+ Class<?> klass = Rule_Test.class;
+ for (Method m : klass.getMethods())
+ if (m.getAnnotation(Test.class) != null)
+ methods.add(m.getName());
+ Collections.sort(methods);
+
+ JList list = new JList(methods);
+ ListSelectionModel lsm = list.getSelectionModel();
+ lsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ list.addMouseListener(new MouseListener() {
+ public void mouseReleased(MouseEvent e) {}
+ public void mousePressed(MouseEvent e) {}
+ public void mouseExited(MouseEvent e) {}
+ public void mouseEntered(MouseEvent e) {}
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() > 1) {
+ String methodName = ((JList)e.getSource()).getSelectedValue().toString();
+ Rule_Test tester = new Rule_Test();
+ tester.setVisual(true);
+ tester.check(methodName);
+ }
+
+ }
+ });
+ JScrollPane jsp = new JScrollPane(list);
+
+ JFrame frame = new JFrame();
+ frame.setSize(200, 600);
+ frame.setLocation(200, 100);
+ frame.add(jsp);
+ frame.pack();
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+
+ //tester.check("test_package_statement");
} catch (Exception e) {
e.printStackTrace();
}
@@ -1139,15 +1325,9 @@
- public boolean isVisual() {
- return visual;
- }
-
- public void setVisual(boolean visual) {
- this.visual = visual;
- }
+
}
More information about the jboss-svn-commits
mailing list