Commit 21a11d8c authored by Dongyue Mou's avatar Dongyue Mou
Browse files

added test cases for transition coverage

parent 8a521efd
<?xml version="1.0" encoding="UTF-8"?>
<org-fortiss-af3-project:FileProject xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:org-fortiss-af3-component="http://www.fortiss.org/af3/component" xmlns:org-fortiss-af3-expression="http://www.fortiss.org/af3/expression" xmlns:org-fortiss-af3-expression-terms="http://www.fortiss.org/af3/expression/terms" xmlns:org-fortiss-af3-expression-types="http://www.fortiss.org/af3/expression/types" xmlns:org-fortiss-af3-project="http://www.fortiss.org/af3/project" xmlns:org-fortiss-af3-project-configuration="http://www.fortiss.org/af3/project/configuration" xmlns:org-fortiss-af3-project-development="http://www.fortiss.org/af3/project/development" xmlns:org-fortiss-af3-state="http://www.fortiss.org/af3/state" xmlns:org-fortiss-testing-coverage="http://www.fortiss.org/af3/testing/model/coverage" xmlns:org-fortiss-tooling-base-model-layout="http://www.fortiss.org/tooling/base/model/layout" xmlns:testsuite="http://www.fortiss.org/af3/testing/model" name="AF3-Project">
<rootElements xsi:type="org-fortiss-af3-project:ProjectConfiguration" id="1">
<configurationElements xsi:type="org-fortiss-af3-project-configuration:TypeSystemConfiguration" id="2">
<typesystem xsi:type="org-fortiss-af3-expression:MicroTypeSystem"/>
</configurationElements>
<configurationElements xsi:type="org-fortiss-af3-project-configuration:DevelopmentProcessConfiguration" id="3">
<development xsi:type="org-fortiss-af3-project-development:DummyDevelopmentProcess"/>
</configurationElements>
</rootElements>
<rootElements xsi:type="org-fortiss-af3-component:ComponentArchitecture" id="4" name="Component Architecture">
<containedElements xsi:type="org-fortiss-af3-component:Component" id="5" name="Component Architecture Root" comment="">
<containedElements xsi:type="org-fortiss-af3-component:Component" id="6" name="comp" comment="">
<specifications xsi:type="org-fortiss-af3-component:CausalityComponentSpecification"/>
<specifications xsi:type="org-fortiss-af3-state:StateAutomaton">
<containedElements xsi:type="org-fortiss-af3-state:State" id="7" name="Root State" comment="">
<containedElements xsi:type="org-fortiss-af3-state:State" id="8" name="state1" comment="">
<specifications xsi:type="org-fortiss-af3-state:StateSpecification" initial="true">
<idleTransitionsSpecifications/>
</specifications>
<connectors xsi:type="org-fortiss-af3-state:TransitionSegmentExitConnector" id="14" name="Output" comment="" outgoing="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@connections.0">
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Angle" key="cangle" angle="1.9445231467604502"/>
</connectors>
<connectors xsi:type="org-fortiss-af3-state:TransitionSegmentExitConnector" id="17" name="Output1" comment="" outgoing="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@connections.1">
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Angle" key="cangle" angle="0.24925214138521362"/>
</connectors>
<connectors xsi:type="org-fortiss-af3-state:TransitionSegmentEntryConnector" id="21" name="Input" comment="" incoming="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@connections.2">
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Angle" key="cangle" angle="-1.0768549578753155"/>
</connectors>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos" x="215" y="152"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="180" height="112"/>
</containedElements>
<containedElements xsi:type="org-fortiss-af3-state:State" id="9" name="state2" comment="">
<specifications xsi:type="org-fortiss-af3-state:StateSpecification">
<idleTransitionsSpecifications/>
</specifications>
<connectors xsi:type="org-fortiss-af3-state:TransitionSegmentEntryConnector" id="15" name="Input" comment="" incoming="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@connections.0">
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Angle" key="cangle" angle="1.4010180528265581"/>
</connectors>
<connectors xsi:type="org-fortiss-af3-state:TransitionSegmentEntryConnector" id="18" name="Input1" comment="" incoming="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@connections.1">
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Angle" key="cangle" angle="3.0845118711835284"/>
</connectors>
<connectors xsi:type="org-fortiss-af3-state:TransitionSegmentExitConnector" id="20" name="Output" comment="" outgoing="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@connections.2">
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Angle" key="cangle" angle="-2.439335722080786"/>
</connectors>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos" x="539" y="178"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
</containedElements>
<specifications xsi:type="org-fortiss-af3-state:StateSpecification">
<idleTransitionsSpecifications/>
</specifications>
<connections xsi:type="org-fortiss-af3-state:TransitionSegment" id="13" name="Transition Segment" comment="" source="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@containedElements.0/@connectors.0" target="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@containedElements.1/@connectors.0">
<specifications xsi:type="org-fortiss-af3-state:TransitionSegmentSpecification">
<guard>
<expression xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="And"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="Equal"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="boolIn"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:BoolConst" value="true"/>
</arguments>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="Equal"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="intIn"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:IntConst" value="4"/>
</arguments>
</expression>
</guard>
<actions>
<variable identifier="Output"/>
<value xsi:type="org-fortiss-af3-expression-terms:IntConst" value="1"/>
</actions>
</specifications>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points">
<points x="450" y="286"/>
</layoutData>
</connections>
<connections xsi:type="org-fortiss-af3-state:TransitionSegment" id="16" name="Transition Segment" comment="" source="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@containedElements.0/@connectors.1" target="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@containedElements.1/@connectors.1">
<specifications xsi:type="org-fortiss-af3-state:TransitionSegmentSpecification">
<guard>
<expression xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="And"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="Equal"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="boolIn"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:BoolConst"/>
</arguments>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="GreaterThan"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="doubleIn"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:DoubleConst" value="1.0"/>
</arguments>
</expression>
</guard>
<actions>
<variable identifier="Output"/>
<value xsi:type="org-fortiss-af3-expression-terms:IntConst" value="2"/>
</actions>
</specifications>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/>
</connections>
<connections xsi:type="org-fortiss-af3-state:TransitionSegment" id="19" name="Transition Segment" comment="" source="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@containedElements.1/@connectors.2" target="//@rootElements.1/@containedElements.0/@containedElements.0/@specifications.1/@containedElements.0/@containedElements.0/@connectors.2">
<specifications xsi:type="org-fortiss-af3-state:TransitionSegmentSpecification">
<guard>
<expression xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="And"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="And"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="Equal"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="boolIn"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:DefinedConst" value="NoVal"/>
</arguments>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="Equal"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="intIn"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:IntConst" value="16"/>
</arguments>
</arguments>
<arguments xsi:type="org-fortiss-af3-expression-terms:FunctionCall">
<function xsi:type="org-fortiss-af3-expression-terms:PredefinedFunction" operator="Equal"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:Var" identifier="doubleIn"/>
<arguments xsi:type="org-fortiss-af3-expression-terms:DoubleConst" value="2.0"/>
</arguments>
</expression>
</guard>
<actions>
<variable identifier="Output"/>
<value xsi:type="org-fortiss-af3-expression-terms:IntConst" value="3"/>
</actions>
</specifications>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Points" key="points"/>
</connections>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
</containedElements>
</specifications>
<specifications xsi:type="testsuite:TestSuiteSpecification" id="23">
<specifications xsi:type="org-fortiss-testing-coverage:StateCoverage" active="false"/>
<specifications xsi:type="org-fortiss-testing-coverage:TransitionCoverage"/>
</specifications>
<connectors xsi:type="org-fortiss-af3-component:InputPort" id="10" name="boolIn" comment="">
<specifications xsi:type="org-fortiss-af3-component:PortSpecification">
<type xsi:type="org-fortiss-af3-expression-types:TBool"/>
<initialValue xsi:type="org-fortiss-af3-expression-terms:BoolConst"/>
</specifications>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="72" orientation="WEST"/>
</connectors>
<connectors xsi:type="org-fortiss-af3-component:InputPort" id="11" name="doubleIn" comment="">
<specifications xsi:type="org-fortiss-af3-component:PortSpecification">
<type xsi:type="org-fortiss-af3-expression-types:TDouble"/>
<initialValue xsi:type="org-fortiss-af3-expression-terms:DoubleConst"/>
</specifications>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="108" orientation="WEST"/>
</connectors>
<connectors xsi:type="org-fortiss-af3-component:InputPort" id="12" name="intIn" comment="">
<specifications xsi:type="org-fortiss-af3-component:PortSpecification">
<type xsi:type="org-fortiss-af3-expression-types:TInt"/>
<initialValue xsi:type="org-fortiss-af3-expression-terms:IntConst"/>
</specifications>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="36" orientation="WEST"/>
</connectors>
<connectors xsi:type="org-fortiss-af3-component:OutputPort" id="22" name="Output" comment="">
<specifications xsi:type="org-fortiss-af3-component:PortSpecification">
<type xsi:type="org-fortiss-af3-expression-types:TInt"/>
<initialValue xsi:type="org-fortiss-af3-expression-terms:IntConst"/>
</specifications>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="cpos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="cdim" width="0" height="0"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:OffsetOrientation" key="coffsetorient" offset="96" orientation="EAST"/>
</connectors>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos" x="276" y="60"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="217" height="193"/>
</containedElements>
<specifications xsi:type="org-fortiss-af3-component:CausalityComponentSpecification"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Point" key="pos"/>
<layoutData xsi:type="org-fortiss-tooling-base-model-layout:Dimension" key="dim" width="108" height="72"/>
</containedElements>
</rootElements>
</org-fortiss-af3-project:FileProject>
......@@ -21,7 +21,8 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import test.org.fortiss.af3.testing.generator.TestCasesGeneratorTest;
import test.org.fortiss.af3.testing.generator.StateCoverageModelCheckingTest;
import test.org.fortiss.af3.testing.generator.TransitionCoverageModelCheckingTest;
import test.org.fortiss.af3.testing.simulator.TestCaseSimulatorTestWithAutomaton;
/**
......@@ -30,12 +31,13 @@ import test.org.fortiss.af3.testing.simulator.TestCaseSimulatorTestWithAutomaton
* @author ratiu
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: C3CF6ADC362F71AA5E15C53E1DF1DFA7
* @ConQAT.Rating GREEN Hash: DFD7BEAE28EC578E1E83D3A62DBB269D
*/
// @CodeFormatterOff
@RunWith(Suite.class)
@SuiteClasses({
TestCasesGeneratorTest.class,
StateCoverageModelCheckingTest.class,
TransitionCoverageModelCheckingTest.class,
TestCaseSimulatorTestWithAutomaton.class
})
// @CodeFormatterOn
......
......@@ -37,7 +37,6 @@ import org.fortiss.af3.analyses.modelchecking.ModelCheckingAnalysisResult;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.expression.language.evaluation.NoVal;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.state.model.State;
import org.fortiss.af3.testing.Af3TestingActivator;
......@@ -58,9 +57,9 @@ import test.org.fortiss.af3.analyses.base.ModelCheckerAnalysesTestBase;
* @author ratiu
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 6A17ADEFAB8AA4AC5B5BDF2BE8D4AAD2
* @ConQAT.Rating GREEN Hash: 8BC09B18D7A5CC0601F09DDACF4D44FA
*/
public class TestCasesGeneratorTest extends ModelCheckerAnalysesTestBase {
public class StateCoverageModelCheckingTest extends ModelCheckerAnalysesTestBase {
/** The 'TestCase1' component. */
private Component testCase1;
......@@ -79,7 +78,7 @@ public class TestCasesGeneratorTest extends ModelCheckerAnalysesTestBase {
public void setup() {
FileProject project =
loadProjectFromPlugin(Af3TestingActivator.PLUGIN_ID,
"test-data/TestCasesGeneratorTests.af3_20", true);
"test-data/StateCoverageModelCheckingTest.af3_20", true);
ComponentArchitecture ca = findComponentArchitecture(project, "Component Architecture");
Component top = ca.getTopComponent();
......@@ -109,30 +108,30 @@ public class TestCasesGeneratorTest extends ModelCheckerAnalysesTestBase {
{ // check state Init
Entry<State, ModelCheckingAnalysisResult> entry1 = iter.next();
assertEquals("Init", entry1.getKey().getName());
assertEquals(3, entry1.getValue().getNumberOfStates());
assertEquals(1, entry1.getValue().getNumberOfStates());
}
{ // check state First
Entry<State, ModelCheckingAnalysisResult> entry2 = iter.next();
assertEquals("First", entry2.getKey().getName());
ModelCheckingAnalysisResult mcar_First = entry2.getValue();
assertEquals(5, mcar_First.getNumberOfStates());
assertEquals(intConst(0), mcar_First.getValueAsTerm(2, input1));
assertEquals(boolConst(true), mcar_First.getValueAsTerm(2, input2));
assertEquals(2, mcar_First.getNumberOfStates());
assertEquals(intConst(0), mcar_First.getValueAsTerm(1, input1));
assertEquals(boolConst(true), mcar_First.getValueAsTerm(1, input2));
}
{ // check state Second
Entry<State, ModelCheckingAnalysisResult> entry3 = iter.next();
assertEquals("Second", entry3.getKey().getName());
ModelCheckingAnalysisResult mcar_Second = entry3.getValue();
assertEquals(5, mcar_Second.getNumberOfStates());
assertEquals(intConst(1), mcar_Second.getValueAsTerm(2, input1));
assertEquals(NoVal.NOVAL.toITerm(), mcar_Second.getValueAsTerm(2, input2));
assertEquals(2, mcar_Second.getNumberOfStates());
assertEquals(intConst(1), mcar_Second.getValueAsTerm(1, input1));
assertEquals(boolConst(true), mcar_Second.getValueAsTerm(1, input2));
}
{ // check state Third
Entry<State, ModelCheckingAnalysisResult> entry4 = iter.next();
assertEquals("Third", entry4.getKey().getName());
ModelCheckingAnalysisResult mcar_Third = entry4.getValue();
assertEquals(5, mcar_Third.getNumberOfStates());
assertEquals(boolConst(true), mcar_Third.getValueAsTerm(2, input2));
assertEquals(2, mcar_Third.getNumberOfStates());
assertEquals(boolConst(true), mcar_Third.getValueAsTerm(1, input2));
}
ToolRunnerBase.DEBUG = false;
}
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2011 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package test.org.fortiss.af3.testing.generator;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.findComponentArchitecture;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.findInputPort;
import static org.fortiss.af3.component.utils.ComponentArchitectureUtils.findSubComponent;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.boolConst;
import static org.fortiss.af3.expression.utils.ExpressionModelElementFactory.intConst;
import static org.fortiss.af3.project.utils.ProjectUtils.loadProjectFromPlugin;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestSuiteSpecification;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTransitionCoverage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static test.org.fortiss.af3.analyses.base.AnalysesTestsUtils.computeResult;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import org.fortiss.af3.analyses.modelchecking.ModelCheckerConfig;
import org.fortiss.af3.analyses.modelchecking.ModelCheckingAnalysisResult;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.expression.language.evaluation.NoVal;
import org.fortiss.af3.expression.model.terms.DoubleConst;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.project.model.typesystem.ITerm;
import org.fortiss.af3.state.model.State;
import org.fortiss.af3.testing.Af3TestingActivator;
import org.fortiss.af3.testing.generator.modelchecking.TransitionCoverageAnalyzer;
import org.fortiss.af3.testing.model.TestSuiteSpecification;
import org.fortiss.af3.testing.model.coverage.TransitionCoverage;
import org.fortiss.af3.tools.base.ILazyResult;
import org.fortiss.af3.tools.base.ToolRunnerBase;
import org.junit.Before;
import org.junit.Test;
import test.org.fortiss.af3.analyses.base.ModelCheckerAnalysesTestBase;
/**
* Tests for the test-case generator based on the model-checker. These tests are
* based on the data from "test-data/TestCasesGeneratorTests.af3_20"
*
* @author ratiu
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: C49ECEF13F0164C53CEDA376185C66F9
*/
public class TransitionCoverageModelCheckingTest extends ModelCheckerAnalysesTestBase {
/** The 'TestCase1' component. */
private Component comp;
/** The 'Input1' port of 'TestCase1' component. */
private InputPort intIn;
/** The 'Input2' port of 'TestCase1' component. */
private InputPort boolIn;
/** The 'Input2' port of 'TestCase1' component. */
private InputPort doubleIn;
/** Configuration information. */
protected ModelCheckerConfig defaultConfig = new ModelCheckerConfig(-100, 100);
/** set-up */
@Before
public void setup() {
FileProject project =
loadProjectFromPlugin(Af3TestingActivator.PLUGIN_ID,
"test-data/TransitionCoverageModelCheckingTest.af3_20", true);
ComponentArchitecture ca = findComponentArchitecture(project, "Component Architecture");
Component top = ca.getTopComponent();
comp = findSubComponent(top, "comp");
intIn = findInputPort(comp, "intIn");
boolIn = findInputPort(comp, "boolIn");
doubleIn = findInputPort(comp, "doubleIn");
assertNotNull(comp);
assertNotNull(intIn);
assertNotNull(boolIn);
assertNotNull(doubleIn);
}
/** Test test cases for state coverage for "TestCase1" component. */
@Test
public void testStatesReachabilityInSimpleHierarchyComponent() {
ToolRunnerBase.DEBUG = true;
TestSuiteSpecification spec = createTestSuiteSpecification();
TransitionCoverage specPart = createTransitionCoverage(spec);
specPart.setMaxLength(5);
TransitionCoverageAnalyzer gen = new TransitionCoverageAnalyzer(defaultConfig, specPart);
ILazyResult<LinkedHashMap<State, ModelCheckingAnalysisResult>> res =
gen.performAnalysis(comp);
LinkedHashMap<State, ModelCheckingAnalysisResult> pairs = computeResult(res);
assertEquals(3, pairs.size());
Iterator<Entry<State, ModelCheckingAnalysisResult>> iter = pairs.entrySet().iterator();
{ // check state pseudoState0
Entry<State, ModelCheckingAnalysisResult> entry1 = iter.next();
assertEquals("pseudoState0", entry1.getKey().getName());
assertEquals(2, entry1.getValue().getNumberOfStates());
assertEquals(boolConst(true), entry1.getValue().getValueAsTerm(1, boolIn));
assertEquals(intConst(4), entry1.getValue().getValueAsTerm(1, intIn));
}
{ // check state pseudoState1
Entry<State, ModelCheckingAnalysisResult> entry2 = iter.next();
assertEquals("pseudoState1", entry2.getKey().getName());
assertEquals(2, entry2.getValue().getNumberOfStates());
assertEquals(boolConst(false), entry2.getValue().getValueAsTerm(1, boolIn));
double doubleInValue1 =
((DoubleConst)entry2.getValue().getValueAsTerm(1, doubleIn)).getValue();
assertTrue("Expected greater than 1.0 but was: " + doubleInValue1, 1.0 < doubleInValue1);
}
{ // check state pseudoState2
Entry<State, ModelCheckingAnalysisResult> entry3 = iter.next();
assertEquals("pseudoState2", entry3.getKey().getName());
assertEquals(3, entry3.getValue().getNumberOfStates());
// step 1
assertEquals(boolConst(false), entry3.getValue().getValueAsTerm(1, boolIn));
double doubleInValue1 =
((DoubleConst)entry3.getValue().getValueAsTerm(1, doubleIn)).getValue();
assertTrue("Expected greater than 1.0 but was: " + doubleInValue1, 1.0 < doubleInValue1);
// step 2
ITerm boolInValue = entry3.getValue().getValueAsTerm(2, boolIn);
assertTrue("Expected NoVal but was: " + boolInValue, NoVal.isNoValConst(boolInValue));
assertEquals(intConst(16), entry3.getValue().getValueAsTerm(2, intIn));
double doubleInValue2 =
((DoubleConst)entry3.getValue().getValueAsTerm(2, doubleIn)).getValue();
assertTrue("Expected around 2.0 but was: " + doubleInValue2, 1.9 < doubleInValue2 &&
doubleInValue2 < 2.1);
}
ToolRunnerBase.DEBUG = false;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment