Package org.springmodules.jsr94.factory

Examples of org.springmodules.jsr94.factory.AbstractDefaultRuleSourceTests


  /**
   * Tests stateful ruleset execution in Tx
   */
  public void statefulInTransaction() {
    List result = (List) template.executeStateful("test", null, new StatefulRuleSessionCallback() {
          public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
            browserHandle = session.addObject("Gecko");
            session.executeRules();
            return session.getObjects();
          }

        });

    result = (List) template.executeStateful("test", null, new StatefulRuleSessionCallback() {
          public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
            session.removeObject(browserHandle);
            session.addObject("MSIE");
            session.executeRules();
            return session.getObjects();
View Full Code Here


  /**
   * Tests stateful ruleset execition outside Tx
   */
  public void statefulOutsideTransaction() {
    List result = (List) template.executeStateful("test", null, new StatefulRuleSessionCallback() {
          public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
            browserHandle = session.addObject("Gecko");
            session.executeRules();
            return session.getObjects();
          }

        });

    result = (List) template.executeStateful("test", null, new StatefulRuleSessionCallback() {
          public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
            try {
              session.removeObject(browserHandle);
              throw new InvalidRuleSessionException("This must be invalid!");
            }
View Full Code Here

          /* (non-Javadoc)
           * @see org.springframework.transaction.support.TransactionCallback#doInTransaction(org.springframework.transaction.TransactionStatus)
           */
          public Object doInTransaction(TransactionStatus status) {
            List result = (List) template.executeStateful(URI, null, new StatefulRuleSessionCallback() {
                  public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
                    browserHandle = session.addObject("Gecko");
                    session.executeRules();
                    return session.getObjects();
                  }

                });

            result = (List) template.executeStateful(URI, null, new StatefulRuleSessionCallback() {
                  public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
                    session.removeObject(browserHandle);
                    session.addObject("MSIE");
                    session.executeRules();
                    return session.getObjects();
View Full Code Here

   * Tests the executeStateful method outside a transaction
   */
  public void testStatefulOutsideTransaction() {
    final Jsr94Template template = getTemplate("ruleSource");

    List result = (List) template.executeStateful(URI, null, new StatefulRuleSessionCallback() {
          public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
            browserHandle = session.addObject("Gecko");
            session.executeRules();
            return session.getObjects();
          }

        });

    result = (List) template.executeStateful(URI, null, new StatefulRuleSessionCallback() {
          public Object execute(StatefulRuleSession session) throws InvalidRuleSessionException, InvalidHandleException, RemoteException {
            try {
              session.removeObject(browserHandle);
              fail("Cannot remove browserHandle from a new session");
            }
View Full Code Here

    showListCars(cars);
  }

  public void testStateful() {
    final List cars=carsDAO.getCars();
    List modifiedCars=(List)getTemplate().executeStateful(CARS_RULE_URI,null,new StatefulRuleSessionCallback() {
      public Object execute(StatefulRuleSession statefulRuleSession) throws InvalidRuleSessionException,RemoteException {
        statefulRuleSession.addObjects(cars);
        statefulRuleSession.executeRules();
        return statefulRuleSession.getObjects();
      }
View Full Code Here

  /**
   * Tests the executeStateless method
   */
  public void testStateless() {
    List result = (List) getTemplate("ruleSource").executeStateless(URI, null, new StatelessRuleSessionCallback() {
          public Object execute(StatelessRuleSession session) throws InvalidRuleSessionException, RemoteException {
            List inputList = new ArrayList();
            inputList.add("Gecko");
            return session.executeRules(inputList);
          }
View Full Code Here

     * @return List of inferred facts
     * @see #executeStateless(String, List)
     * @see #executeStateless(String, List, ObjectFilter)
     */
  protected List executeStateless(final String uri, final Map properties, final List input, final ObjectFilter filter) {
    return (List) template.executeStateless(uri, properties, new StatelessRuleSessionCallback() {
      public Object execute(StatelessRuleSession session) throws InvalidRuleSessionException, RemoteException {
        List result;
        if (filter != null) {
          result = session.executeRules(input, filter);
        }
View Full Code Here

    }
  }
 
  public void testStateless() {
    final List cars=carsDAO.getCars();
    getTemplate().executeStateless("cars",null,new StatelessRuleSessionCallback() {
      public Object execute(StatelessRuleSession session) throws InvalidRuleSessionException, RemoteException {
        return session.executeRules(cars);
      }
    });
    showListCars(cars);
View Full Code Here

  /**
   * @see org.springmodules.samples.jrules.services.CarsService#getGoodBargainCars()
   */
  public List getGoodBargainCars() {
    final List cars=carsDAO.getCars();
    getTemplate().executeStateless(CARS_RULE_URI,null,new StatelessRuleSessionCallback() {
      public Object execute(StatelessRuleSession session) throws InvalidRuleSessionException, RemoteException {
        return session.executeRules(cars);
      }
    });
    List goodBargainCars=new ArrayList();
View Full Code Here

TOP

Related Classes of org.springmodules.jsr94.factory.AbstractDefaultRuleSourceTests

Copyright © 2018 www.massapicom. 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.