Package org.drools.runtime.rule

Examples of org.drools.runtime.rule.FactHandle.toExternalForm()


                              inXml,
                              String.class );

        inXml = "";
        inXml += "<batch-execution>";
        inXml += "  <get-object out-identifier='outCheddar' fact-handle='" + factHandle.toExternalForm() + "' />";
        inXml += "</batch-execution>";
        setExec( ksession );

        outXml = template.requestBody( "direct:exec",
                                       inXml,
View Full Code Here


        //now test for code injection:
        ModifyCommand.ALLOW_MODIFY_EXPRESSIONS = false;
        inXml = "";
        inXml += "<batch-execution>";
        inXml += "  <modify fact-handle='" + factHandle.toExternalForm() + "'> <set accessor='type' value='44\"; System.exit(1);' /><set accessor='price' value='50' /></modify>";
        inXml += "  <fire-all-rules />";
        inXml += "</batch-execution>";

        outXml = template.requestBody( "direct:exec",
                                       inXml,
View Full Code Here

                                              inXml,
                                              String.class );

        System.err.println( outXml );
        String expectedXml = "";
        expectedXml += "<execution-results>\n" + "  <result identifier=\"out-list\">\n" + "    <list>\n" + "      <fact-handle external-form=\"" + fh.toExternalForm() + "\"/>\n" + "    </list>\n" + "  </result>\n" + "</execution-results>";

        assertXMLEqual( expectedXml,
                        outXml );

    }
View Full Code Here

        expectedXml += "      <type>brie</type>\n";
        expectedXml += "      <price>10</price>\n";
        expectedXml += "      <oldPrice>5</oldPrice>\n";
        expectedXml += "    </org.drools.camel.testdomain.Cheese>\n";
        expectedXml += "  </result>\n";
        expectedXml += "  <fact-handle identifier=\"outBrie\" external-form=\"" + factHandle.toExternalForm() + "\" /> \n";
        expectedXml += "</execution-results>\n";
        assertXMLEqual( expectedXml,
                        outXml );

        ExecutionResults result = (ExecutionResults) BatchExecutionHelper.newXStreamMarshaller().fromXML( outXml );
View Full Code Here

        expectedXml += "      <type>stilton</type>\n";
        expectedXml += "      <oldPrice>0</oldPrice>\n";
        expectedXml += "      <price>30</price>\n";
        expectedXml += "    </org.foo.Whee>\n";
        expectedXml += "  </result>\n";
        expectedXml += "  <fact-handle identifier=\"outStilton\" external-form=\"" + factHandle.toExternalForm() + "\" /> \n";
        expectedXml += "</execution-results>\n";

        assertXMLEqual( expectedXml,
                        outXml );
View Full Code Here

        public void marshal(Object object,
                            HierarchicalStreamWriter writer,
                            MarshallingContext marshallingContext) {
            FactHandle fh = (FactHandle) object;
            writer.startNode( "external-form" );
            writer.setValue( fh.toExternalForm() );
            writer.endNode();
        }

        public Object unmarshal(HierarchicalStreamReader reader,
                                UnmarshallingContext unmarshallingContext) {
View Full Code Here

                      HierarchicalStreamWriter writer,
                      MarshallingContext marshallingContext) {
      FactHandle fh = (FactHandle) object;
      //writer.startNode("fact-handle");
      writer.addAttribute( "external-form",
                           fh.toExternalForm() );
      //writer.endNode();
  }

  public Object unmarshal(HierarchicalStreamReader hierarchicalStreamReader,
                          UnmarshallingContext unmarshallingContext) {
View Full Code Here

        StatefulKnowledgeSession ksession = createSession();

        ksession.setGlobal("myGlobalObj", new MyObject("myglobalObj"));
        MyObject obj1 = new MyObject("obj1");
        FactHandle handle = ksession.insert(obj1);
        System.out.println("Handle Identity HashCode -> " + handle.toExternalForm());
        Assert.assertNotNull(handle);
        Assert.assertEquals(true, ((DefaultFactHandle) handle).isDisconnected());
        // The session assertMap doesn't find the factHandle for this object
        FactHandle newHandle = ksession.getFactHandle(obj1);
        System.out.println("Handle Identity HashCode -> " + newHandle.toExternalForm());
View Full Code Here

        System.out.println("Handle Identity HashCode -> " + handle.toExternalForm());
        Assert.assertNotNull(handle);
        Assert.assertEquals(true, ((DefaultFactHandle) handle).isDisconnected());
        // The session assertMap doesn't find the factHandle for this object
        FactHandle newHandle = ksession.getFactHandle(obj1);
        System.out.println("Handle Identity HashCode -> " + newHandle.toExternalForm());

        Assert.assertEquals(newHandle, handle);


    }
View Full Code Here

        ksession.setGlobal("myGlobalObj", new MyObject("myglobalObj"));
        MyObject obj1 = new MyObject("obj1");
        FactHandle handle = ksession.insert(obj1);
        Assert.assertNotNull(handle);
        Assert.assertEquals(true, ((DefaultFactHandle) handle).isDisconnected());
        System.out.println("Handle Identity HashCode -> " + handle.toExternalForm());

        //I'm having problems with ObjectStoreWrapper that it's not serializable
        Collection<FactHandle> factHandles = ksession.getFactHandles();
        Assert.assertEquals(1, factHandles.size());
        FactHandle newHandle = factHandles.iterator().next();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.