1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.scxml;
18  
19  import java.util.HashSet;
20  import java.util.Set;
21  
22  import org.apache.commons.scxml.model.State;
23  import org.apache.commons.scxml.model.TransitionTarget;
24  
25  import junit.framework.Test;
26  import junit.framework.TestCase;
27  import junit.framework.TestSuite;
28  
29  public class BuiltinTest extends TestCase {
30  
31      public BuiltinTest(String testName) {
32          super(testName);
33      }
34  
35      public static Test suite() {
36          return new TestSuite(BuiltinTest.class);
37      }
38  
39      public static void main(String args[]) {
40          String[] testCaseName = { BuiltinTest.class.getName()};
41          junit.textui.TestRunner.main(testCaseName);
42      }
43      
44      public void testIsMemberEmptySet() {
45          Set set = new HashSet();
46          
47          assertFalse(Builtin.isMember(set, "on"));
48      }
49      
50      public void testIsMemberFalse() {
51          TransitionTarget state = new State();
52          state.setId("off");
53          
54          Set set = new HashSet();
55          set.add(state);
56          
57          assertFalse(Builtin.isMember(set, "on"));
58      }
59      
60      public void testIsMemberTrue() {
61          TransitionTarget state = new State();
62          state.setId("on");
63          
64          Set set = new HashSet();
65          set.add(state);
66          
67          assertTrue(Builtin.isMember(set, "on"));
68      }
69  
70  }