Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
106 lines (97 sloc) 3.78 KB
########################################################################
# JBoss, Home of Professional Open Source
# Copyright 2011, Red Hat and individual contributors as identified
# by the @authors tag. See the copyright.txt in the distribution for a
# full listing of individual contributors.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this software; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
# @authors Andrew Dinn
#
########################################################################
# rule script used by test method BasicTests.testForwardPublishing
#
########################################################################
# A rule to create the rendezvous and counter for
# the Binder or BindingReplacer
RULE create rendezvous and counter
CLASS TextLineProcessor
METHOD <init>
IF TRUE
DO createRendezvous($0, 2, true);
createCounter($0)
ENDRULE
# A rule to increment the counter for the Binder or BindingReplacer each time a line of text is
# about to be processed. Note the use of the ^ to propagate this rule into subclass implementations
# of the abstract method defined by TextLineProcessor.
RULE increment Binder or BindingReplacer line counter
CLASS ^TextLineProcessor
METHOD transform
AT ENTRY
IF TRUE
DO incrementCounter($0)
ENDRULE
# A rule to enter the first rendezvous for the Binder
# This rule stops the Binder at the point where it is about to process the 3rd line
# The Binder will only continue when the test program enters the same rendezvous
RULE enter first Binder rendezvous
CLASS Binder
METHOD transform
AT ENTRY
IF readCounter($0) == 3
DO rendezvous($0)
ENDRULE
# A rule to enter the second rendezvous for the Binder
# This rule stops the Binder after it has processed the 3rd line. The test program can
# enter this rendezvous and on return be sure that the 3rd line has been processed
RULE enter second Binder rendezvous
CLASS Binder
METHOD transform
AT EXIT
IF readCounter($0) == 3
DO rendezvous($0)
ENDRULE
# A rule to enter the first rendezvous for the BindingReplacer
# This rule stops the BindingReplacer at the point where it is about to process the 2nd line
# The BindingReplacer will only continue when the test program enters the same rendezvous
RULE enter first BindingReplacer rendezvous
CLASS BindingReplacer
METHOD transform
AT ENTRY
IF readCounter($0) == 2
DO rendezvous($0)
ENDRULE
# A rule to enter the second rendezvous for the BindingReplacer
# This rule stops the BindingReplacer after it has processed the 2nd line. The test program can
# enter this rendezvous and on return be sure that the 2nd line has been processed.
RULE enter second BindingReplacer rendezvous
CLASS BindingReplacer
METHOD transform
AT EXIT
IF readCounter($0) == 2
DO rendezvous($0)
ENDRULE
# A rule which injects code into the test method triggerRendezvous
# The test program can call triggerRendezvous in order to enter either the
# Binder or the BindingReplacer rendezvous and it will only return when the
# Binder or BindingReplacer has also entered the rendezvous. The String
# argument $1 is used to identify which rendezvous to enter.
RULE allow test thread to enter rendezvous
CLASS BytemanNGTests
METHOD triggerRendezvous
IF TRUE
DO rendezvous($1)
ENDRULE