SetWireTest.java :  » Workflow-Engines » jbpm-jpdl-4 » org » jbpm » pvm » internal » wire » Java Open Source

Java Open Source » Workflow Engines » jbpm jpdl 4 
jbpm jpdl 4 » org » jbpm » pvm » internal » wire » SetWireTest.java
package org.jbpm.pvm.internal.wire;

import java.util.List;
import java.util.Set;

import org.jbpm.pvm.internal.xml.Problem;

public class SetWireTest extends WireTestCase {

  public void testSet() {
    WireContext wireContext = createWireContext(
      "<objects>" +
      "  <set name='s'>" +
      "    <true />" +
      "    <string value='' />" +
      "    <null />" +
      "    <object name='o' class='"+Object.class.getName()+"' />" +
      "  </set>" +
      "</objects>"
    );
    
    Set s = (Set) wireContext.get("s");
    assertEquals(s.toString(), 4, s.size());
    assertTrue(s.contains(Boolean.TRUE));
    assertTrue(s.contains(""));
    assertTrue(s.contains(null));
    
    Object o = wireContext.get("o");
    assertNotNull(o);
    assertTrue(s.contains(o));
  }

  public void testCustomListType() {
    WireContext wireContext = createWireContext(
      "<objects>" +
      "  <set name='s' class='java.util.TreeSet' />" +
      "</objects>"
    );
    assertEquals(java.util.TreeSet.class, wireContext.get("s").getClass());
  }

  public void testInvalidSetType() {
    List<Problem> problems = parseProblems(
        "<objects>" +
        "  <set name='s' class='invalid-set-type'/>" +
        "</objects>"
    );

    assertTextPresent("class invalid-set-type could not be found", problems.get(0).getMsg());
  }

  public void testUnknownValue() {
    List<Problem> problems = parseProblems(
      "<objects>" +
      "  <set name='s'>" +
      "    <unknown-descriptor />" +
      "  </set>" +
      "</objects>"
    );
    assertNotNull(problems);
    assertTextPresent("unrecognized element: <unknown-descriptor", problems.get(0).getMsg());
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.