Examples of MyObject


Examples of org.drools.grid.NodeTests.MyObject

    @Test
   
    public void remoteKAgentRuleTest() throws IOException, IOException, IOException, IOException, InterruptedException {
        StatefulKnowledgeSession ksession = createSession();
        ksession.setGlobal( "myGlobalObj", new MyObject( "myglobalObj" ) );
       
        MyObject obj1 = new MyObject( "obj1" );
        ksession.insert( obj1 );

        int fired = ksession.fireAllRules();
        Assert.assertEquals( 1, fired );

        String changeSetString = "<change-set xmlns='http://drools.org/drools-5.0/change-set'>"
                + "<add>"
                + "<resource type=\"DRL\" source=\"classpath:simple.drl\" />"
                + "</add>"
                + "</change-set>"
                + "";
        Resource changeSetRes = new ByteArrayResource( changeSetString.getBytes() );
        ( (InternalResource) changeSetRes ).setResourceType( ResourceType.CHANGE_SET );
       
       
       
        KnowledgeAgent kAgent = GridHelper.getInstance().getKnowledgeAgentRemoteClient( grid2, remoteN1.getId(), "ksession-rules" );
        kAgent.applyChangeSet( changeSetRes );

        Thread.sleep(5000);

        MyObject obj2 = new MyObject("obj2");
        ksession.insert(obj2);
        fired = ksession.fireAllRules();
       
        Assert.assertEquals(2, fired);
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void executeBatchTest() {
        StatefulKnowledgeSession ksession = createSession();

        List<GenericCommand<?>> cmds = new ArrayList<GenericCommand<?>>();
        cmds.add((GenericCommand<?>)CommandFactory.newSetGlobal("myGlobalObj", new MyObject("myglobalObj")));
        cmds.add((GenericCommand<?>)CommandFactory.newInsert(new MyObject("obj1"), "myObject1"));
        cmds.add((GenericCommand<?>)CommandFactory.newFireAllRules());
        BatchExecutionCommandImpl batch = new BatchExecutionCommandImpl(cmds, "out");
       
        ExecutionResults results = ksession.execute(batch);
       
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void executeAsyncBatchTest() throws InterruptedException {
        StatefulKnowledgeSession ksession = createSession();

        List<Command> cmds = new ArrayList<Command>();
        cmds.add(CommandFactory.newSetGlobal("myGlobalObj", new MyObject("myglobalObj")));

        MyObject myObject = new MyObject("obj1");
        cmds.add(CommandFactory.newInsert(myObject));
        cmds.add(CommandFactory.newFireAllRules());
        AsyncBatchExecutionCommandImpl batch = new AsyncBatchExecutionCommandImpl(cmds);
       
        ExecutionResults results = ksession.execute(batch);
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void insertTest() {
        StatefulKnowledgeSession ksession = createSession();

        ksession.setGlobal("myGlobalObj", new MyObject("myglobalObj"));

        FactHandle handle = ksession.insert(new MyObject("obj1"));
        Assert.assertNotNull(handle);
        Assert.assertEquals(true, ((DefaultFactHandle) handle).isDisconnected());

        int fired = ksession.fireAllRules();
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void getGlobalTest() {
        StatefulKnowledgeSession ksession = createSession();

        ksession.setGlobal("myGlobalObj", new MyObject("myglobalObj"));

        Assert.assertEquals("myglobalObj", ((MyObject) ksession.getGlobal("myGlobalObj")).getName());

    }
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void retractTest() {
        StatefulKnowledgeSession ksession = createSession();

        ksession.setGlobal("myGlobalObj", new MyObject("myglobalObj"));

        FactHandle handle = ksession.insert(new MyObject("obj1"));
        Assert.assertNotNull(handle);
        Assert.assertEquals(true, ((DefaultFactHandle) handle).isDisconnected());

        int fired = ksession.fireAllRules();
        Assert.assertEquals(fired, 1);
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void updateTest() {
        StatefulKnowledgeSession ksession = createSession();

        ksession.setGlobal("myGlobalObj", new MyObject("myglobalObj"));

        FactHandle handle = ksession.insert(new MyObject("obj1"));
        Assert.assertNotNull(handle);
        Assert.assertEquals(true, ((DefaultFactHandle) handle).isDisconnected());

        int fired = ksession.fireAllRules();
        Assert.assertEquals(fired, 1);

        Assert.assertEquals(1, ksession.getFactCount());

        ksession.update(handle, new MyObject("obj2"));

        Assert.assertEquals(1, ksession.getFactCount());

        fired = ksession.fireAllRules();
        Assert.assertEquals(fired, 1);
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Ignore // FIX
    public void getFactHandleTest() {
        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
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void getFactHandlesTest() {
        StatefulKnowledgeSession ksession = createSession();

        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());
View Full Code Here

Examples of org.drools.grid.NodeTests.MyObject

    @Test
    public void getObjectTest() {
        StatefulKnowledgeSession ksession = createSession();

        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());

        Object result = ksession.getObject(handle);
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.