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.env; 018 019import java.net.URL; 020 021import org.apache.commons.scxml2.model.ModelException; 022import org.junit.Assert; 023import org.junit.Test; 024 025/** 026 * Unit tests {@link org.apache.commons.scxml2.env.AbstractStateMachine}. 027 */ 028public class AbstractStateMachineTest { 029 030 @Test 031 public void testMoreThanOneScxmlDocument() throws Exception { 032 URL fooScxmlDocument = getClass().getResource("foo.xml"); 033 URL barScxmlDocument = getClass().getResource("bar.xml"); 034 035 Foo f = new Foo(fooScxmlDocument); 036 Bar b = new Bar(barScxmlDocument); 037 038 Assert.assertTrue(f.fooCalled()); 039 Assert.assertTrue(b.barCalled()); 040 } 041 042 private class Foo extends AbstractStateMachine { 043 044 private boolean fooCalled; 045 046 public Foo(final URL scxmlDocument) throws ModelException { 047 super(scxmlDocument); 048 } 049 050 public void foo() { 051 fooCalled = true; 052 } 053 054 public boolean fooCalled() { 055 return fooCalled; 056 } 057 } 058 059 private class Bar extends AbstractStateMachine { 060 061 private boolean barCalled; 062 063 public Bar(final URL scxmlDocument) throws ModelException { 064 super(scxmlDocument); 065 } 066 067 public void bar() { 068 barCalled = true; 069 } 070 071 public boolean barCalled() { 072 return barCalled; 073 } 074 } 075}