001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.scxml2.issues; 018 019import java.util.Set; 020 021import org.apache.commons.scxml2.SCXMLExecutor; 022import org.apache.commons.scxml2.SCXMLTestHelper; 023import org.apache.commons.scxml2.model.EnterableState; 024 025import org.junit.Assert; 026import org.junit.Test; 027 028/** 029 * Test cases for issue 62. 030 * FIXED 031 */ 032public class Issue62Test { 033 034 @Test 035 public void test01issue62() throws Exception { 036 SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/issues/issue62-01.xml"); 037 exec.go(); 038 Set<EnterableState> currentStates = exec.getStatus().getStates(); 039 Assert.assertEquals(1, currentStates.size()); 040 Assert.assertEquals("s1.1", currentStates.iterator().next().getId()); 041 SCXMLTestHelper.assertPostTriggerState(exec, "foo", "s1.1"); 042 } 043 044 @Test 045 public void test02issue62() throws Exception { 046 SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/issues/issue62-02.xml"); 047 exec.go(); 048 fragmenttest(exec); 049 } 050 051 @Test 052 public void test03issue62() throws Exception { 053 SCXMLExecutor exec = SCXMLTestHelper.getExecutor("org/apache/commons/scxml2/issues/issue62-03.xml"); 054 exec.go(); 055 fragmenttest(exec); 056 } 057 058 private void fragmenttest(SCXMLExecutor exec) throws Exception { 059 Set<EnterableState> currentStates = exec.getStatus().getStates(); 060 Assert.assertEquals(1, currentStates.size()); 061 Assert.assertEquals("s1", currentStates.iterator().next().getId()); 062 SCXMLTestHelper.assertPostTriggerState(exec, "foo", "e1.1.1"); 063 SCXMLTestHelper.assertPostTriggerState(exec, "bar", "e1.1.2"); 064 SCXMLTestHelper.assertPostTriggerState(exec, "baz", "s3"); 065 Assert.assertTrue(exec.getStatus().isFinal()); 066 } 067} 068