Package org.springmodules.jsr94.factory

Examples of org.springmodules.jsr94.factory.AbstractRuleServiceProviderTests


  private RuleSession createRuleSession(final String uri, final Map properties, final int type) {
    try {
      return getRuleSource().createSession(uri, properties, type);
    }
    catch (RuleExecutionSetNotFoundException ex) {
      throw new Jsr94RuleExecutionSetNotFoundException(ex);
    }
    catch (RuleSessionTypeUnsupportedException ex) {
      throw new Jsr94RuleSessionTypeUnsupportedException(ex);
    }
    catch (RuleSessionCreateException ex) {
View Full Code Here


    }
    catch (RuleSessionTypeUnsupportedException ex) {
      throw new Jsr94RuleSessionTypeUnsupportedException(ex);
    }
    catch (RuleSessionCreateException ex) {
      throw new Jsr94RuleSessionCreateException(ex);
    }
    catch (RemoteException ex) {
      throw new Jsr94RemoteException(ex);
    }
  }
View Full Code Here

    }
    catch (RuleExecutionSetNotFoundException ex) {
      throw new Jsr94RuleExecutionSetNotFoundException(ex);
    }
    catch (RuleSessionTypeUnsupportedException ex) {
      throw new Jsr94RuleSessionTypeUnsupportedException(ex);
    }
    catch (RuleSessionCreateException ex) {
      throw new Jsr94RuleSessionCreateException(ex);
    }
    catch (RemoteException ex) {
View Full Code Here

  /**
   * Tests the executeStateful method within a transaction
   */
  public void testStatefulInTransaction() {
    final Jsr94Template template = getTemplate("ruleSource");
    final Jsr94TransactionManager transactionManager = new Jsr94TransactionManager();
    transactionManager.setRuleSource(template.getRuleSource());
    final TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    List result = (List) txTemplate.execute(new TransactionCallback() {

          /* (non-Javadoc)
           * @see org.springframework.transaction.support.TransactionCallback#doInTransaction(org.springframework.transaction.TransactionStatus)
View Full Code Here

    providerProperties.put("providerProperties", "providerProperties");
    rulesetProperties.put("rulesetProperties", "rulesetProperties");
    registrationProperties.put("registrationProperties", "registrationProperties");

    DefaultRuleSource rs = new DefaultRuleSource();
    rs.setBindUri("foo");
    rs.setRuleAdministrator(ruleAdministrator);
    rs.setRuleRuntime(ruleRuntime);
    rs.setSource(source);
    rs.setRegistrationProperties(registrationProperties);
    rs.setRulesetProperties(rulesetProperties);
    rs.setProviderProperties(providerProperties);

    ruleAdministrator.getLocalRuleExecutionSetProvider(providerProperties);
    controlRuleAdministrator.setReturnValue(ruleExecutionSetProvider);

    source.getInputStream();
    controlSource.setReturnValue(null);

    ruleExecutionSetProvider.createRuleExecutionSet((InputStream) null, rulesetProperties);
    controlRuleExecutionSetProvider.setReturnValue(null);
    ruleAdministrator.registerRuleExecutionSet("foo", null, registrationProperties);

    controlSource.replay();
    controlRuleAdministrator.replay();
    controlRuleExecutionSetProvider.replay();
    controlRuleRuntime.replay();

    rs.afterPropertiesSet();

    controlRuleAdministrator.verify();
  }
View Full Code Here

  /**
   * Tests the getObject() and afterPropertiesSet() methods
   */
  public void testInitialization() throws Exception {
    DefaultRuleSource source = new DefaultRuleSource();

    // test the afterPropertiesSet() calls
    try {
      source.afterPropertiesSet();
      fail("ruleAdministrator, ruleRuntime, bindUri and source not set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setBindUri(BIND_URI);
    try {
      source.afterPropertiesSet();
      fail("ruleAdministrator, ruleRuntime and source not set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setSource(new ClassPathResource(RULES_RESOURCE));
    try {
      source.afterPropertiesSet();
      fail("ruleAdministrator, ruleRuntime not set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setRuleAdministrator(ruleAdministrator);
    try {
      source.afterPropertiesSet();
      fail("ruleRuntime not set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setRuleRuntime(ruleRuntime);
    source.afterPropertiesSet();

    try {
      source.createSession(BIND_URI + "-foo", null, RuleRuntime.STATELESS_SESSION_TYPE);
      fail("Ruleset at uri " + BIND_URI + "-foo exists!");
    }
    catch (RuleExecutionSetNotFoundException ex) {
      // expected
    }

    StatelessRuleSession session = (StatelessRuleSession) source.createSession(BIND_URI, null, RuleRuntime.STATELESS_SESSION_TYPE);
    assertNotNull("Created session is null", session);
    session.release();
  }
View Full Code Here

     *
     * @throws Exception If anything goes wrong
     */
  public void testStatelessExecution() throws Exception {
    // create the source
    DefaultRuleSource source = new DefaultRuleSource();
    setProperties(source);
    source.afterPropertiesSet();

    // get the stateless session
    StatelessRuleSession session = (StatelessRuleSession) source.createSession(BIND_URI, null, RuleRuntime.STATELESS_SESSION_TYPE);

    // execute it
    List facts = new ArrayList();
    facts.add("Gecko");
    facts = session.executeRules(facts);
View Full Code Here

   * Test session creation & execution
   * @throws Exception If anything goes wrong
   */
  public void testStatefulExecution() throws Exception {
    // create the source
    DefaultRuleSource source = new DefaultRuleSource();
    setProperties(source);
    source.afterPropertiesSet();

    // get the stateless session
    StatefulRuleSession session = (StatefulRuleSession) source.createSession(BIND_URI, null, RuleRuntime.STATEFUL_SESSION_TYPE);

    // execute it
    List facts = new ArrayList();
    facts.add("Gecko");
    session.addObjects(facts);
View Full Code Here

  /**
   * Tests the getObject() and afterPropertiesSet() methods
   */
  public void testInitialization() throws Exception {
    DefaultRuleSource source = new DefaultRuleSource();

    // test the afterPropertiesSet() calls
    try {
      source.afterPropertiesSet();
      fail("ruleServiceProvider, bindUri and source not set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setBindUri(BIND_URI);
    try {
      source.afterPropertiesSet();
      fail("ruleAdministrator, ruleRuntime and source not set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setSource(new ClassPathResource(RULES_RESOURCE));
    try {
      source.afterPropertiesSet();
      fail("ruleAdministrator, ruleRuntime not set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }

    source.setRuleServiceProvider(getProvider());
    source.setRuleAdministrator(ruleAdministrator);
    try {
      source.afterPropertiesSet();
      fail("ruleServiceProvider AND ruleAdministrator set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setRuleAdministrator(null);
    source.setRuleRuntime(ruleRuntime);
    try {
      source.afterPropertiesSet();
      fail("ruleServiceProvider AND ruleRuntime set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }
    source.setRuleAdministrator(ruleAdministrator);
    try {
      source.afterPropertiesSet();
      fail("ruleServiceProvider AND ruleRuntime and ruleAdministrator set");
    }
    catch (IllegalArgumentException ex) {
      // expected
    }

    source.setRuleAdministrator(null);
    source.setRuleRuntime(null);
    source.afterPropertiesSet();

    try {
      source.createSession(BIND_URI + "-foo", null, RuleRuntime.STATELESS_SESSION_TYPE);
      fail("Ruleset at uri " + BIND_URI + "-foo exists!");
    }
    catch (RuleExecutionSetNotFoundException ex) {
      // expected
    }

    StatelessRuleSession session = (StatelessRuleSession) source.createSession(BIND_URI, null, RuleRuntime.STATELESS_SESSION_TYPE);
    assertNotNull("Created session is null", session);
    session.release();
  }
View Full Code Here

     *
     * @param ruleSourceBeanName
     * @return A Jsr94Template instance
     */
  private Jsr94Template getTemplate(String ruleSourceBeanName) {
    RuleSource source = (RuleSource) context.getBean(ruleSourceBeanName);

    return new Jsr94Template(source);
  }
View Full Code Here

TOP

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

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.