<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A Tool Chain for Test-driven Development of Reference Net Software Components in the Context of CAPA Agents</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Martin Wincierz</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Theoretical Foundations of Computer Science (TGI) Department of Informatics, University of Hamburg</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <fpage>197</fpage>
      <lpage>214</lpage>
      <abstract>
        <p>Testing is common practice in the realm of software engineering. Especially in agile approaches, where test-driven development can be seen as integral. Capa agents are developed under the agile Paose approach. Their internal components are implemented using Java reference nets which combine the semantics of P/T nets and Java. The existing testing methods for these kinds of nets are either difficult to learn or ill-suited for testdriven development and regression testing. In this work a tool chain is presented which allows testing of reference nets using regular Java classes. For this purpose an extension of the well-established JUnit framework is provided. All tools are designed to be easily understood by developers of Capa agents. This is achieved by a mixture of automatic code generation, repurposing other tools of the Paose approach, and employing a style of testing that is reminiscent of regular Java tests. While most of the code generating tools are limited to the context of Capa agents, regression testing is possible for any kind of reference net. The findings may help in the development of testing frameworks for other high-level Petri net formalisms.</p>
      </abstract>
      <kwd-group>
        <kwd>High-level Petri nets</kwd>
        <kwd>testing</kwd>
        <kwd>agile development</kwd>
        <kwd>agile modeling</kwd>
        <kwd>regression tests</kwd>
        <kwd>automated tests</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Capa (Concurrent Agent Platform Architecture) allows for the construction of
software agents based on reference nets [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. These are developed under the agile
Paose (Petri net-based Agent-Oriented Software Engineering) approach which
is described in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] and expanded upon in [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. This approach employs the guiding
metaphor of the multi-agent system of developers. The communicative nature of
agile procedures mirror the developed agent systems. Many agile practices such
as Pair-programming and common code ownership are already part of Paose.
Until now however, there was no explicit support for automatically executed
regression tests, let alone test-driven development, both of which are part of
many other agile approaches.
      </p>
      <p>The tools presented in this work allow for the test-driven development of
regression tests for Capa agent components. These tests are written using the
JUnit framework which is already well-supported by many continuous integration
softwares. Furthermore the techniques presented are at least partly applicable
to general reference nets. As such it is of interest to ask if the ability to develop
high-level Petri nets under a test-driven approach is useful in a more general
case outside of Capa agents. This will be discussed in the first part of this work,
before introducing the tool chain in the second.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Background</title>
      <p>We briefly introduce (Java) reference nets, the general structure of a Capa agent,
some important aspects of Paose and the widely used JUnit framework.
2.1</p>
      <sec id="sec-2-1">
        <title>Java Reference Nets</title>
        <p>
          Java reference nets, from here on simply referred to as reference nets, were first
introduced by Kummer [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ]. They support a hierarchical nets-within-net
structure (with nets as tokens), as well as Java inscriptions that are executed when
a transition is fired [
          <xref ref-type="bibr" rid="ref13">13</xref>
          ]. Reference nets can be executed directly by the
Renew Petri net simulator with true concurrency semantics. Reference nets in
Renew consist of templates and net instances that are generated from these
templates. The net instances can be considered as objects. The semantics allow
for most Java commands as well as some additional statements like guards and
synchronous channels which are explained under Net Interfaces. Tokens are
references to reference nets / Java objects. The content of the Java objects can be
changed / manipulated by Java code being executed by firing a transition.
Net Interfaces The interfaces of reference nets are implemented with
synchronous channels. These consist of two parts: an uplink and a downlink, as
depicted in Figure 1. Downlinks have the form &lt;target net instance&gt;:&lt;channel
name&gt;(&lt;parameter&gt;*). Uplinks have the same form, except they do not have
a target net instance. When an up- or downlink is enabled, the simulator tries
to find a corresponding counterpart with the same channel name and matching
parameters. Previously unbound parameters are bound to the value provided
by the other channel if applicable. This allows exchange of objects / values /
references between net instances. If a matching channel is found and all
parameters can be bound to a value, both transitions fire synchronously. More than
two transitions can be synchronized by using more channel inscriptions, with the
restriction that only one uplink is allowed per transition.
        </p>
        <p>Stub Classes Reference nets are themselves Java objects. To allow easy
access to their interfaces one can use stub classes which are generated from stub
files with Java-like syntax. They basically function as adapters and make net
instances available for Java classes. Usage of stub classes actually allows to
exchange every Java object by a reference net instance and vice versa.</p>
        <p>The example shown in Figure 2 shows the stub syntax and resulting Java code
for one of the standard interfaces used in Paose. The channel name
“newExchange” is a standard name that is used multiple times. The specific channel
instance is identified with the provided String id. Since this id will never change
during runtime, it is declared in the method body. This simplifies the job of
testers, as they do not have to know the channel instance of the net. Instead
this task is shifted to the person writing the stub file. This is important because
the correct implementation of the stub class depends on the use of the interface.
Both, uplinks and downlinks, can be used to send and receive information,
sometimes both at once. Since Java only allows for a single return value, channels
might require multiple corresponding Java methods.</p>
        <p>1 public void i n p u t
2 ( f i n a l Object ppo , f i n a l int ppid ){
3 . . .
4 SimulationThreadPool . g e t C u r r e n t ( ) .
5 e x e c u t e (new Runnable ( ) {
6 public void run ( ) {
7 de . renew . u n i f y . Tuple inTuple ;
23451 b}(tShOrteribasijnk:egncvetwso=oiEd",xitcneihnstatpnCuigdhet a()sn{,noe,l "id; ) ; 1111012398 } do_S.ue.yi.tn.nTrscetuhnaprenolwcen=e.i dus,"aennt.iierfoeywnnE.ReTxwecuq.hpuaclenaegsl toel"u..ts, TyinnuTcphulepro;len)i z; e (
2.2</p>
      </sec>
      <sec id="sec-2-2">
        <title>Capa Agents</title>
        <p>The agent itself is accessible through the “receive” and “send” transitions which
are inscribed with synchronous channels of the same name. Messages given as
parameters via synchronization are Java objects of a specific type.
Protocols are tied to an act of communication and exist only as long as that
communication lasts. They are implemented as instances of reference nets and
are held in the place labeled “conversations”.</p>
        <p>Decision components as well are implemented as instances of reference nets.
They are however instantiated when the agent is started and their lifetime is
usually the full runtime of the agent itself. They are used to model proactive
behavior of the agent, but also to implement services used by multiple protocols.
The exchange transition (located between conversations and decision
components) is used to synchronize uplinks of the “dcexchange” channel in protocols
with uplinks of the “exchange” channel in decision components. The same
channel can be used to allow communication between two decision components (not
modeled in the figure). Individual instances of these uplinks are identified via
additions to the channel name provided as String parameters. Examples of this
can be seen in Figure 4.</p>
        <p>Agent-, protocol- and decision component-nets, as well as their respective
interfaces, are the main concern when black-box testing Capa agents.
2.3</p>
      </sec>
      <sec id="sec-2-3">
        <title>Some Paose Concepts</title>
        <p>Full comprehension of the Paose approach is not required in order to understand
this work. Therefore this section will only address two tools which are part of
the Paose development process and which are used during testing later on.
Net Components are subnets which serve as templates for recurring
functionality within the nets. For example there exist net components for the
aforementioned “exchange” channel, as seen in Figure 4. Net Components consist of
regular net elements and are only visually distinguishable, i.e. they are easily
recognized by humans, but no meta information about them is kept in the net
template.
Agent Interaction Protocols (AIP) are extended UML sequence diagrams.
They are used to model interactions between different agents1. An example can
be seen later in Figure 7. It is possible to automatically generate net skeletons
of protocol nets from the models. This is done by mapping the inscriptions on
the diagram elements to Net Components which are then drawn and connected
in the same order.
2.4</p>
      </sec>
      <sec id="sec-2-4">
        <title>The JUnit Framework</title>
        <p>
          JUnit is a testing framework for Java applications [
          <xref ref-type="bibr" rid="ref1">1</xref>
          ]. It is designed for the
creation of regression tests. Automatic execution of JUnit tests is supported by
many continuous integration programs. The testing process is shown in Figure 5.
        </p>
        <p>Tests can be started, manually or automatically, from the IDE or from the
command line using build tools. To execute the tests a controller class called test
runner is used. Often test classes specify which runner is supposed to execute
them.</p>
        <p>The runner creates a TestResult object which is usually used to generate a
test report. The design of the report depends on the implementation but often
includes the number of failed and succeeding tests, the expended time and the
stack trace in case of a failure.</p>
        <p>JUnit4 heavily relies on reflectively manipulating tests by use of annotations.
The @RunWith annotation is used to specify the runner class. @Test marks the
tests themselves. Optionally a time limit may be set, which is useful if deadlocks
1 More specifically the interactions between agent roles.
are a concern. @Before and @After are called before and, respectively, after each
test. They are used for setting up the testing environment and returning it to
its prior state after testing.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Petri Nets in Agile Development</title>
      <p>The core practices of Agile Modeling are introduced and it is shown that Petri
nets can be used in conformance with them. It is also argued why Petri nets are
especially useful as a modeling language in agile development.
3.1</p>
      <sec id="sec-3-1">
        <title>Agile Modeling</title>
        <p>
          Agile Modeling, as it is presented by Ambler [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ], is, much like agile development,
not a specified process, but attempts to be a guideline to modelers. “Agile
Modeling is not a prescriptive process. [...] it does not define detailed procedures for
how to create a given type of model, instead it provides advice for how to be
effective as a modeler.” [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ] Its ideas mirror those of agile development and Ambler
explicitly shows its conformity with eXtreme Programming [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. Agile Modeling
is based on its own set of principles which is put into action via eleven core
practices organized into four categories [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. In this section it is shown that Petri
nets can be used according to these practices and are therefore applicable to
Agile Modeling.
        </p>
        <p>Iterative and Incremental Modeling The first practice is apply the right
artifacts. Petri nets cannot be considered a universal modeling language but are
useful in modeling concurrent behavior. For these kinds of tasks, they are indeed
the right artifacts. Similarly the practice iterate to another artifact is easy to
fulfill if we assume that Petri nets are not our only means of modeling. If one is
stuck during the modeling of a net, switching to a different modeling task may
bring clarification.</p>
        <p>
          The practices create several models in parallel and model in small increments
require a specific style of nets. More precisely they require nets that are limited
in their scope. This can be achieved by hierarchical net structures, as is done
in Renew with the nets-within-net approach or CPNTools with hierarchical
Coloured Petri Nets [
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]. The nets-within-net formalism even allows the exchange
of subnets at runtime.
        </p>
        <p>
          Teamwork The practices of this category are model with others, active
stakeholder participation, collective ownership and display models publicly. All of this
is part of the Paose approach and has been successfully done within the context
of a Petri nets-based software development environment. [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]
Simplicity This category encompasses the practices create simple content,
depict models simply and use the simplest tools. Again, it is assumed that Petri
nets are only used to model concurrent software components. The nets can be
refined from simple P/T nets into high-level Petri nets. There exists a number
of modeling tools but for early designs they can also be easily drawn by hand.
Validation The first practice of this category, consider testability, is the main
subject of this work. The second, prove it with code, is elaborated on in Section
3.2.
3.2
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>Combining Model and Implementation</title>
        <p>It has been have established that Petri nets can be used as a modeling language
in agile development. To take this a step further it is shown that Petri nets are
especially useful in agile approaches due to the nets being executable.</p>
        <p>
          Research suggests that there are significant advantages keeping models and
code consistent [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. This is, however, difficult to achieve in agile projects, as the
software is continually evolving. Reference nets are Turing equivalent and used
as both a modeling and implementation language in our Paose approach. This
ensures that the model automatically evolves alongside the code, as they are
indeed the same. Petri nets are therefore highly suitable for agile development
processes.
        </p>
        <p>
          The design / testing paradigm favored in eXtreme-Programming and other
agile approaches is test-driven development [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]. Tests are written before the
implementing code and serve as a guideline to programmers. Instead of being
seen as additional work after the actual programming job is done, testing is
part of the design itself [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. Executable Petri nets can be seen as both, model
and implementation. If they are used in agile development, it is only natural to
design them according to agile practices. Therefore the approach to test Petri
nets always also incorporates the notion of test-driven modeling.
4
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Related Work</title>
      <p>The idea of test-driven modeling has been proposed before.</p>
      <p>
        Hawari et al. [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] used the phrase of test-driven models. They did not include
the technical framework, but rather followed the idea of testing for different
parameter simulations. In the following we illustrate how to set up the modeling
approach for the use of current software engineering methods.
      </p>
      <p>
        Zhang and Patel have successfully used similar techniques with executable
UML in industry software projects [
        <xref ref-type="bibr" rid="ref19 ref20">19, 20</xref>
        ]. Their process is very close to the one
presented later. “First, we create the UML sequence diagrams, then we create
both UML model and test cases (for unit, integration, and system testing)
according to the sequence diagrams.” [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] This work, however, is the first to apply
this to Petri nets.
      </p>
      <p>
        Walkinshaw and Derrick [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ] follow the idea of inferring (automata) models
from Erlang code and to generate model-based tests according to possible traces
of the models to test software. They herewith avoid the involvement of users and
gain an automated test generation. In the approach presented the models can
be used directly and therefore do not need to be guessed or deduced from some
code executions. This is one of the advantage when following a model driven
software engineering approach where the models can directly be used for code
execution as in Paose .
      </p>
      <p>In the realm of Petri nets, testing is more associated with the techniques of
verification or model checking. The presented approach is not competitive, but
complementary to these. If the state-space becomes too large or the problem
simply becomes undecidable due to added semantics, testing might be a good
alternative.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Requirements</title>
      <p>Decisions that have been made regarding some aspects of the tools are clarified.
Requirements and motivations that guided the development are explained.
5.1</p>
      <sec id="sec-5-1">
        <title>Functional and Non-functional Requirements</title>
        <p>
          The testing methods presented are specifically designed to satisfy the needs of
agile development. For this purpose three main points that had to be
incorporated were identified:
Test-driven Development Adapted to Petri nets, this means tests can be
written even before the net structure is known. In the field of testing this is known
as black-box testing [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ]. Rather than a finished program only the interfaces of
the (net-)object are needed. Tests are designed to fail and the code is written
iteratively to gradually fulfill the testing requirements.
        </p>
        <p>
          Small-scale Unit- and System-wide Integration Tests Kent Beck
recommended when talking about eXtreme Programming :
“If the gap [between writing code and tests] is minutes, the cost of communicating
expectations between two people would be prohibitive.” [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] The short iterations
require the availability of small-scale unit-tests. These are tests of a single net
or a small grouping of nets. Beck also acknowledges that usually these tests are
not enough:
“A programmer or even a pair bring to their code and tests a singular point
of view [...].” He therefore proposes: “One set [of tests] is written from the
perspective of the programmers, [...] another set is written from the perspective of
customers or users [...].” [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ] These tests use the interfaces open to customers.
They are system-wide tests, that can be used to avoid unexpected side-effects
when integrating smaller software-modules into larger systems. In the context
of Renew and its reference net formalism, which was the main concern of our
testing efforts, there is no need to differentiate between the views on a technical
level. The nets-within-net property of reference nets allow for hierarchical
structures within the nets. System tests are therefore unit-tests of nets that are high
in the hierarchy. Trivially, all of these tests have to be regression tests. Once
written, they can be called multiple times. During the implementation phase
this is usually done manually by programmers in order to guide them in writing
code. Once a test successfully completes, it is called automatically every time
new code is integrated into the software. This is done to avoid unexpected side
effects and is known as integration testing [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ].
        </p>
        <p>
          Usability and Heterogeneous Skill Sets The importance of this last point
is difficult to quantify for a more general case. In academic software-projects
however, a significant discrepancy in the abilities of programmers has been
observed. As a joint Bachelor’s and Master’s project, both seasoned programmers
with several years of working experience, as well as beginners who have never
used a UNIX operating system before are working together [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ]. The upfront
workload and difficulty of learning Paose techniques for the first time often
proved to be a hurdle. Therefore one of the goals for this work was to create
a testing framework and tool chain that is as easy to use as the rest of the
Paose techniques, but is as self-explanatory as possible to not further increase
the learning time.
5.2
        </p>
      </sec>
      <sec id="sec-5-2">
        <title>Choosing a Test Language</title>
        <p>
          To write tests the testing-framework JUnit is used. Its use was already suggested
in earlier works, however favoring a hybrid solution that relied on JUnit only
for starting and controlling tests. In the first approach the tests themselves were
written in the language of the test-objects, i.e. with reference nets [
          <xref ref-type="bibr" rid="ref16 ref5">5, 16</xref>
          ]. In this
contribution it was decided on a different approach. The tests are fully written
as Java classes. In [
          <xref ref-type="bibr" rid="ref18">18</xref>
          ] the approach has been implemented and tested. There
are several reasons for this choice.
        </p>
        <p>Familiarity As mentioned earlier, some of the participants of academic Capa
software projects have never seen Petri nets before, let alone used them for
programming. However in order to even create something that is in need of testing,
a certain degree of Java knowledge can be assumed. By relying solely on Java,
tests are not much different from what a Java programmer would usually write,
therefore shortening the time needed to learn the testing process. For developers
that are completely new to programming with nets, we can also assume that
the tests themselves are much less prone to failures and errors compared to the
new language of Petri nets. Especially in the context of test-driven development,
in which tests are written before the implementation, it is likely that the first
attempts using nets are faulty, effectively defeating the purpose of writing these
tests.</p>
        <p>Support Features Renew provides some support features to developers, but
not nearly as many as comparable IDEs for wide-spread high-level programming
languages. The main draw of programming with reference nets, the concurrency,
is completely irrelevant for the tests themselves.
JUnit Functionality JUnit provides additional functionality, for example
methods that are called before each individual test or expecting a test to fail due to
an exception.</p>
      </sec>
      <sec id="sec-5-3">
        <title>Separation of Test and Implementation The implementation of the tested</title>
        <p>functionality is completely separated from its test. The net instance used can
be exchanged for a different kind or even a Java class. Apart from technical
advantages, this also better conforms to the goals of testdriven development.
Theoretically, tests created this way could be written without any knowledge of
Petri nets, preventing any chance of the tests being influenced by the
implementation.
6</p>
        <p>The MulanNetTest Plugin
This Renew plugin was developed as part of a Bachelor’s thesis by the author.
It was later expanded upon by adding support for the JUnit framework. All
tools will be explained using the “WebChat” example. A use case can be seen in
Figure 6.
The first task when writing tests before the implementation is done, is to provide
interfaces against which can be tested. For agents and protocols this is easy.
Agents only provide their standard interfaces. Protocols can be generated from
the AIP. Decision components however are entirely created by the developers.</p>
        <p>To solve this, the AIP were extended to include both types of internal
components. An example for the WebChat application can be seen in Figure 7.
Depending on the outgoing and incoming arrows, as well as their inscriptions,
net components are generated and connected in the order according to the
diagram. From the model in Figure 7 four nets are generated: Two protocol nets
and two decision component nets. The net ’Sender_DC’ can be seen in Figure 8.
The commentary fields employ the new comment tool. It allows developers to
append blue text to net elements which is also added to the elements’ meta
information and can later be retrieved.
In order to test the newly generated nets with JUnit, an adapter stub class
has to be created. This is done automatically by mapping the standardized Net
Component interfaces to code in net stub syntax. The Components are identified
by naming the place containing the channel name after the interface type. For all
places that have non-standardized names getter/setter methods are created. The
result can be seen in Figure 9. The commentary is read from the place’s meta
information and is also written into the final Java class. The stub generation is
done within the IDE via a context menu, as seen in Figure 10.
6.3</p>
      </sec>
      <sec id="sec-5-4">
        <title>A JUnit Adapter for Petri Nets</title>
        <p>To write the tests themselves the JUnit framework is employed and an adapter
for this was created. First all newly added elements are explained. An in depth
example is given in the next section.</p>
        <p>Wincierz: Test-driven Development of Reference Nets 209
A e</p>
        <p>o
om n</p>
        <p>n
u n
ig ah
F c
1
2
3
4
5
6
7
8
9
/
Receive t h e answer
from t h e p r o t o c o l
/
void r e c e i v e A n s w e r ( Object o , int i d ){
S t r i n g s=" r e c e i v e A n s w e r " ;
t h i s : exchange ( s , o , i d ) ;
}
Annotations The adapter mirrors JUnit4 ’s use of reflection. New annotations
are @Repeat(int), which allows easy repetition of a test class, and @Concurrent
Parameters(Object[][]), which is modeled after the @Parameters class used
with the Parameterized test runner. It is used to define an array of arrays.
For each entry of the super-array, a new test instance will be created and run
concurrently. The sub-array values are reflectively injected into fields annotated
with @ConcurrentParameter(int) according to the given adicity. This is also
modeled after the regular JUnit functionality of the Parameterized runner.
Thus users who have used it before, will hopefully understand the principle
immediately.</p>
        <p>RenewTestRunner The adapter is designed to be very close to regular JUnit
in its use, as to allow easy adoption of its functionality. The core element is
a custom test runner, which automatically starts a new Renew instance. The
runner is designed to support the new annotations.</p>
        <p>RenewTestClass All tests have to extend this class. This is more akin to the
older JUnit version 3, where all tests had to extend a TestClass. It is necessary
because of Renew ’s plugin based architecture. New instances of Renew are
run in a new class loader to ensure the correct order of loading the plugins. The
test runner cannot read the objects annotated with @ConcurrentParameters,
therefore this task as well as the field injection is done by the test class itself upon
being called reflectively. In addition the RenewTestClass provides convenience
methods to synchronize testing phases. This is elaborated on in the example.
6.4</p>
      </sec>
      <sec id="sec-5-5">
        <title>Example Test Class</title>
        <p>The code example shows a simple test class. The artifact to be tested is the
“Sender_DC” net. During setup a new instance of the net is created (line 17/18),
which is then wrapped in a stub adapter at the beginning of the test (line 24).
The net instance is static because it will be used by the three instances of the
test class with the different specified parameters.</p>
        <p>The tests are synchronized using the finishPhase() method (lines 23,34,38).
The test will wait until all instances of the test class have finished the current
phase. The phases can be distinguished as executing and evaluation phases.
Between each phase the simulation engine is halted / restarted. This ensures
that during execution all test instances are active in the same part of the net,
thus possibly provoking concurrency failures if existent.</p>
        <p>Not all stub methods have been shown, but the methods can be easily
matched to their respective channels in the net graphic by their names. In this
case only the first half of the net is tested. A message is received from the web
interface and given to the protocol net. The test concludes successfully, if both
messages are the same. Since no functionality has been implemented, the test
will fail after 3000 milliseconds.
@Repeat ( t i m e s = 3)
@RunWith( v a l u e = RenewTestRunner . c l a s s )
public c l a s s WebChatTest extends RenewTestClass {
@ConcurrentParameters
public Object [ ] [ ] params = {{ " house " , 1} , {" c a r " , 2} , {" p e t r i " , 3 } } ;
@ConcurrentParameter ( v a l u e = 0)
public S t r i n g message ;
s t a t i c N e t I n s t a n c e i n s t a n c e ;
@Before
public void s e t u p ( ) {</p>
        <p>Net net = Net . forName ( "Sender_DC" ) ;
i n s t a n c e = net . b u i l d I n s t a n c e ( ) ;
}
@Test ( timeout = 3000)
public void t e s t M e s s a g i n g ( ) {
t h i s . f i n i s h P h a s e ( ) ;
Sender_DCStub stub = new Sender_DCStub ( i n s t a n c e ) ;
WebEventAction wea = new WebEventAction ( ) ;
WebEvent we = new WebEvent ( ) ;
VTSequence v t s = new VTSequence ( ) ;
we . setData ( t h i s . message ) ;
v t s . add ( we ) ;
wea . s e t E v e n t s ( v t s ) ;
wea . setName ( "" ) ;
34
35
36
37
38
39
40
41
42
43
44
45 }
}
stub .AGENTLET_DC_ACTION_HANDLE_WEB_EVENTSIn( wea , t h i s . i d ) ;
t h i s . f i n i s h P h a s e ( ) ;
stub . askForMessageIn ( Boolean .TRUE, t h i s . i d ) ;
S t r i n g r e s u l t = stub . askForMessageOut ( t h i s . i d ) ;
t h i s . f i n i s h P h a s e ( ) ;</p>
        <p>A s s e r t . a s s e r t E q u a l s ( t h i s . message , r e s u l t ) ;
7</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Discussion</title>
      <p>The code generation tools are useful in the context of Capa agents, but
difficult to extend to more general cases. The unification mechanism of synchronous
channels makes a mapping to Java methods problematic, as the number of
required methods increases exponentially with the number of parameters, since
any combination of receiving and giving Objects has to be taken into account.
Other high-level Petri net formalisms with more specified interfaces might be
more suitable.</p>
      <p>The JUnit extension however allows the testing of all reference nets, provided
a net stub is manually created. Writing the tests is about as difficult as testing
regular Java classes and should not require special knowledge about Petri nets.</p>
      <p>The testing methods have proven to be able to find semantical failures in
Capa applications. Other properties, like liveness, are not possible to determine
using testing. For this a combined approach with verification techniques might
be a solution.</p>
      <p>Also the JUnit extension in its current form is costly to use. To provide a
clean environment, a new instance of Renew is started before each test. This
takes about three to five seconds depending on the hardware on which the tests
are run.</p>
      <p>Despite some flaws the tools presented allow for easier testing and thereby
higher quality of code. Automatic test execution will likely improve the
integration process during development, although this has to be further observed in
practice. The increased degree of testability improves the usefulness of reference
nets not only as a programming, but also as a modeling language.
8</p>
    </sec>
    <sec id="sec-7">
      <title>Conclusion</title>
      <p>High-level Petri nets can combine graphical feedback with early simulation and
might therefore be suitable as a modeling language in agile development.
Especially of interest is the notion of test-driven modeling, which has been done
before with other modeling languages, but has not been tried with Petri nets.
A tool chain was presented with which test-driven development of Capa agents
becomes possible. The agent’s internal components are reference nets which
function as both implementation as well as their own model. The testing process was
shown using a simple example.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1. Junit4. http://junit.org/junit4/. Accessed:
          <fpage>2017</fpage>
          -01-05.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>S.</given-names>
            <surname>Ambler</surname>
          </string-name>
          . Agile Modeling:
          <article-title>Effective Practices for EXtreme Programming and the Unified Process. Programming, software development</article-title>
          . Wiley,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>Kent</given-names>
            <surname>Beck</surname>
          </string-name>
          .
          <source>Extreme Programming Explained. Addison Wesley</source>
          , Boston,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>Lawrence</given-names>
            <surname>Cabac</surname>
          </string-name>
          .
          <article-title>Modeling Petri Net-Based Multi-Agent Applications</article-title>
          , volume
          <volume>5</volume>
          <source>of Agent Technology - Theory and Applications</source>
          . Logos Verlag, Berlin,
          <year>2010</year>
          . http://www.sub.uni-hamburg.de/opus/volltexte/2010/4666/.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>Lawrence</given-names>
            <surname>Cabac</surname>
          </string-name>
          , Michael Duvigneau, Daniel Moldt, and Matthias WesterEbbinghaus.
          <article-title>Towards unit testing for Java reference nets</article-title>
          .
          <source>In Robin Bergenthum and Jörg Desel</source>
          , editors,
          <source>Algorithmen und Werkzeuge für Petrinetze. 18. Workshop AWPN</source>
          <year>2011</year>
          , Hagen,
          <year>September 2011</year>
          . Tagungsband, pages
          <fpage>1</fpage>
          -
          <lpage>6</lpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>Michael</given-names>
            <surname>Duvigneau</surname>
          </string-name>
          , Daniel Moldt, and
          <string-name>
            <given-names>Heiko</given-names>
            <surname>Rölke</surname>
          </string-name>
          .
          <article-title>Concurrent architecture for a multi-agent platform</article-title>
          . In Fausto Giunchiglia, James Odell, and Gerhard Weiß, editors,
          <source>Agent-Oriented Software Engineering III. Third International Workshop</source>
          , Agent-oriented
          <source>Software Engineering (AOSE)</source>
          <year>2002</year>
          , Bologna, Italy,
          <year>July 2002</year>
          .
          <source>Revised Papers and Invited Contributions</source>
          , volume
          <volume>2585</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>59</fpage>
          -
          <lpage>72</lpage>
          , Berlin Heidelberg New York,
          <year>2003</year>
          . Springer-Verlag.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>Steve</given-names>
            <surname>Freeman</surname>
          </string-name>
          and
          <string-name>
            <given-names>Nat</given-names>
            <surname>Pryce</surname>
          </string-name>
          . Growing
          <string-name>
            <surname>Object-Oriented</surname>
            <given-names>Software</given-names>
          </string-name>
          ,
          <article-title>Guided by Tests</article-title>
          .
          <source>Addison Wesley</source>
          , Upper Saddle River, NJ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Andrew</surname>
            <given-names>M Gravell</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Yvonne</given-names>
            <surname>Howard</surname>
          </string-name>
          ,
          <string-name>
            <surname>Juan-Carlos</surname>
            <given-names>Augusto</given-names>
          </string-name>
          ,
          <string-name>
            <given-names>Carla</given-names>
            <surname>Ferreira</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Stefan</given-names>
            <surname>Gruner</surname>
          </string-name>
          .
          <article-title>Concurrent development of model and implementation</article-title>
          .
          <source>16th International Conference on Software &amp; Systems Engineering and their Applications</source>
          ,
          <source>event date: 2/12/2003</source>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>Matthias</given-names>
            <surname>Güttler</surname>
          </string-name>
          .
          <article-title>Integration einer agilen Projektmanagementumgebung in ein verteiltes Team</article-title>
          .
          <source>Diploma thesis</source>
          , University of Hamburg, Department of Informatics, Vogt-Kölln Str. 30,
          <string-name>
            <given-names>D</given-names>
            <surname>-</surname>
          </string-name>
          22527
          <string-name>
            <surname>Hamburg</surname>
          </string-name>
          ,
          <year>November 2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10. Aliah Hazmah Hawari and
          <string-name>
            <surname>Zeti-Azura</surname>
          </string-name>
          Mohamed-Hussein.
          <article-title>Simulation of a Petri net-based model of the terpenoid biosynthesis pathway</article-title>
          .
          <source>BMC Bioinformatics</source>
          ,
          <volume>11</volume>
          (
          <issue>1</issue>
          ):
          <fpage>83</fpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>Kurt</given-names>
            <surname>Jensen and Lars M. Kristensen</surname>
          </string-name>
          .
          <source>Coloured Petri Nets: Modelling and Validation of Concurrent Systems</source>
          . Springer Publishing Company,
          <source>Incorporated, 1st edition</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>Olaf</given-names>
            <surname>Kummer</surname>
          </string-name>
          . Referenznetze. Logos Verlag, Berlin,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Olaf</surname>
            <given-names>Kummer</given-names>
          </string-name>
          , Frank Wienberg, Michael Duvigneau, Lawrence Cabac,
          <string-name>
            <given-names>Michael</given-names>
            <surname>Haustermann</surname>
          </string-name>
          , and David Mosteller. Renew - the Reference Net Workshop. Available at: http://www.renew.de/,
          <source>June 2016. Release 2</source>
          .
          <fpage>5</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <given-names>Dennis</given-names>
            <surname>Schmitz</surname>
          </string-name>
          .
          <article-title>Neugestaltung von Lernmaterialien zur Unterstützung der Lehrenden und Lernenden in der petrinetzbasierten und agentenorientierten Softwareentwicklung</article-title>
          .
          <source>Master thesis</source>
          , University of Hamburg, Department of Informatics,
          <source>VogtKölln Str</source>
          . 30,
          <string-name>
            <given-names>D</given-names>
            <surname>-</surname>
          </string-name>
          22527
          <string-name>
            <surname>Hamburg</surname>
          </string-name>
          ,
          <year>February 2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <given-names>Uwe</given-names>
            <surname>Vigenschow</surname>
          </string-name>
          .
          <article-title>Testen von Software und Embedded Systems: professionelles Vorgehen mit modellbasierten und objektorientierten Ansätzen</article-title>
          . dpunkt, Heidelberg,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Florian</surname>
          </string-name>
          von Stosch.
          <article-title>Entwicklung eines Testrahmenwerks für Mulan-Protokollnetze</article-title>
          .
          <source>Bachelor thesis</source>
          , University of Hamburg, Department of Informatics, Vogt-Kölln Str. 30,
          <string-name>
            <given-names>D</given-names>
            <surname>-</surname>
          </string-name>
          22527
          <string-name>
            <surname>Hamburg</surname>
          </string-name>
          ,
          <year>September 2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <given-names>Neil</given-names>
            <surname>Walkinshaw</surname>
          </string-name>
          and John Derrick.
          <article-title>Incrementally discovering testable specifications from program executions</article-title>
          . In Frank S. de Boer,
          <string-name>
            <surname>Marcello M. Bonsangue</surname>
          </string-name>
          , Stefan Hallerstede, and Michael Leuschel, editors,
          <source>Formal Methods for Components and Objects - 8th International Symposium, FMCO</source>
          <year>2009</year>
          , Eindhoven,
          <source>The Netherlands, November 4-6</source>
          ,
          <year>2009</year>
          .
          <source>Revised Selected Papers</source>
          , volume
          <volume>6286</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>272</fpage>
          -
          <lpage>289</lpage>
          . Springer,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>Martin</given-names>
            <surname>Wincierz</surname>
          </string-name>
          .
          <article-title>Erweiterung des PAOSE Softwareentwicklungsansatzes um ein Testkonzept und Bereitstellung von Plugins zu dessen technischer Umsetzung</article-title>
          .
          <source>Bachelor thesis</source>
          , University of Hamburg, Department of Informatics, Vogt-Kölln Str. 30,
          <string-name>
            <given-names>D</given-names>
            <surname>-</surname>
          </string-name>
          22527
          <string-name>
            <surname>Hamburg</surname>
          </string-name>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <given-names>Y.</given-names>
            <surname>Zhang</surname>
          </string-name>
          and
          <string-name>
            <given-names>S.</given-names>
            <surname>Patel</surname>
          </string-name>
          .
          <article-title>Agile model-driven development in practice</article-title>
          .
          <source>IEEE Software</source>
          ,
          <volume>28</volume>
          (
          <issue>2</issue>
          ):
          <fpage>84</fpage>
          -
          <lpage>91</lpage>
          ,
          <year>March 2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          20.
          <string-name>
            <given-names>Yuefeng</given-names>
            <surname>Zhang</surname>
          </string-name>
          .
          <article-title>Test-driven modeling for model-driven development</article-title>
          .
          <source>IEEE Software</source>
          ,
          <volume>21</volume>
          (
          <issue>5</issue>
          ):
          <fpage>80</fpage>
          -
          <lpage>86</lpage>
          ,
          <year>Sept 2004</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>