1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.jameleon.function;
20
21 import junit.framework.Assert;
22 import junit.framework.AssertionFailedError;
23 import net.sf.jameleon.*;
24 import net.sf.jameleon.bean.Attribute;
25 import net.sf.jameleon.data.AbstractDataDrivableTag;
26 import net.sf.jameleon.event.BreakPoint;
27 import net.sf.jameleon.event.FunctionEventHandler;
28 import net.sf.jameleon.exception.JameleonScriptException;
29 import net.sf.jameleon.result.FunctionResult;
30 import net.sf.jameleon.result.FunctionResultRecordable;
31 import net.sf.jameleon.util.AssertLevel;
32 import net.sf.jameleon.util.Configurator;
33 import net.sf.jameleon.util.JameleonUtility;
34 import net.sf.jameleon.util.StateStorer;
35 import org.apache.commons.jelly.MissingAttributeException;
36 import org.apache.commons.jelly.XMLOutput;
37 import org.apache.log4j.Logger;
38
39 import java.io.File;
40 import java.io.IOException;
41 import java.util.ArrayList;
42 import java.util.Iterator;
43 import java.util.List;
44 import java.util.regex.Matcher;
45 import java.util.regex.Pattern;
46
47 /***
48 * <p>
49 * Represents an abstract function point that does a lot behind the scenes for the function point developer.
50 * The following instance variables are described:
51 * <ul>
52 * <li>fResults - Results for this function point. Basically, the same information is kept in the session results
53 * as are in these results, except the function results only keep information about this function.</li>
54 * <li>functionId - This is a brief description of what this function point is used for in the test case. This is a required attribute
55 * that is set in the macro tag of each function point. This is also used for logging and results.</li>
56 * <li>log - @see org.apache.log4j.Logger an easy way to send messages about the function point to the logs.</li>
57 * </ul>
58 * </p>
59 * <p>
60 * The steps to creating an abstract function tag for a plugin are as follows:
61 * <ol>
62 * <li>Implement the optional {@link #store(java.lang.String,int)} method</li>
63 * <li>Override the default behavior of {@link #setupEnvironment}, being sure to call super first. The new behavior should
64 * be to get the corresponding {@link net.sf.jameleon.SessionTag} for the plug-in if a handle on the application
65 * is kept there. Use the Jelly-provided <b>findAncestorWithClass(class)</b> method to get a handle on the parent
66 * SessionTag. The abstract FunctionTag implementation should set the handle on the application being tested to
67 * a local instance variable for easy manipulation for FunctionTag extenders. If use of the plug-in FunctionTag requires
68 * a handle on the application, then it is good practice to throw a JameleonScriptException if the an ancestor of the
69 * plug-in SessionTag isn't found.</li>
70 * <li>Write your wrapper methods to make life easier for implementers of the plug-in.</l>
71 * </ol>
72 * <br>
73 * Actually, to implement a FunctionTag for a plug-in is as simple as extending this base class and nothing more. The
74 * above list is provided as recommendation only.
75 * </p>
76 * <p>
77 * To implement a FunctionTag from an existing plugin, the following methods must be implemented:
78 * <ul>
79 * <li>{@link #testBlock()}</li>
80 * </ul>
81 * The following methods help define the behaviour of the function point and should be implemented not at the plugin level,
82 * but at the customization layer the user will do:
83 * <ul>
84 * <li>{@link #setup()}</li>
85 * <li>{@link #validate()}</li>
86 * <li>{@link #tearDown()}</li>
87 * </ul>
88 * </p>
89 */
90 public abstract class FunctionTag extends JameleonTagSupport implements Storable, BreakPoint {
91 /***
92 * The Results for this function
93 */
94 protected FunctionResult fResults;
95 /***
96 * The id of this function. This is used in the macro as a short description of the function
97 * @jameleon.attribute required="true"
98 */
99 protected String functionId;
100 /***
101 * Tells the GUI to stop at this functional point
102 * @jameleon.attribute required="false"
103 */
104 protected boolean breakPoint;
105 /***
106 * Specifies this is a precondition
107 * @jameleon.attribute required="false"
108 */
109 protected boolean precondition;
110 /***
111 * Specifies this is a postcondition and will therefore get executed even
112 * if a previous functional point or session tag failed.
113 * @jameleon.attribute required="false"
114 */
115 protected boolean postcondition;
116 /***
117 * Specifies a failure is expected.
118 * @jameleon.attribute required="false"
119 */
120 protected boolean expectFailure;
121 /***
122 * Specifies an exception is expected.
123 * @jameleon.attribute required="false"
124 */
125 protected boolean expectException;
126 /***
127 * A list of required attributes for this function point.
128 * @deprecated use getFunctionResults().setErrorFile() instead.
129 */
130 protected File lastFileWritten;
131 /***
132 * A list of parameters passed to this functional point via the <param> tag.
133 */
134 protected ArrayList params;
135
136 /***
137 * The parent session tag of this functional point
138 */
139 protected SessionTag st;
140 /***
141 * The parent test case of this functional point
142 */
143 protected TestCaseTag tct;
144 /***
145 * Stores the state of the application.
146 */
147 protected StateStorer state;
148
149 protected static Logger log = Logger.getLogger(FunctionTag.class.getName());
150
151 AssertLevel assertLevelManager = AssertLevel.getInstance();
152
153 protected ParamTypeValidatable vpt = new DefaultValidParamType();
154 protected static final long NO_DELAY = -1;
155 /***
156 * The delay time to use at the end of each functional point
157 * @jameleon.attribute default="-1"
158 */
159 protected long functionDelay = NO_DELAY;
160
161 protected AbstractDataDrivableTag addt;
162
163 /***
164 * Gets the id of the function being tested. This is usally a short description of how the function point.is used in the test case.
165 * @return functionId - The name of the function
166 */
167 public String getFunctionId(){
168 return functionId;
169 }
170
171 /***
172 * Sets the id of the function being tested.
173 * @param functionId - the id of the function being tested
174 */
175 public void setFunctionId(String functionId){
176 this.functionId = functionId;
177 }
178
179 /***
180 * Sets the value for expectFailure. This attrubute defaults to false, so only set it if true is set.
181 * @param expectFailure - set to true to expect a failure. To invoke this functionality must be 'yes' or 'true'.
182 */
183 public void setExpectFailure( boolean expectFailure ){
184 this.expectFailure = expectFailure;
185 }
186
187 /***
188 * Sets the value for expectException. This attrubute defaults to false.
189 * @param expectException - a value of "yes" or "true" indicates the function tag should only pass if there is an exception.
190 */
191 public void setExpectException( boolean expectException ){
192 this.expectException = expectException;
193 }
194
195 /***
196 * Checks whether this tag is a break point. Used mostly for the GUI.
197 * @return true if this tag is a break point.
198 */
199 public boolean isBreakPoint( ){
200 return breakPoint;
201 }
202
203 /***
204 * Sets the delay time to occur at the end of this functional point.
205 * @param functionDelay - the time in millis.
206 */
207 public void setFunctionDelay( long functionDelay ){
208 this.functionDelay = functionDelay;
209 }
210
211 /***
212 * Does setup for plugin-required intialization. Functional points that implement the plugin should call the super
213 * of method before implementing their own code.
214 */
215 public void setup(){}
216
217 /***
218 * Called when the function is done being executed. Use to clean up resources created in the setup method.
219 */
220 public void tearDown(){}
221
222 /***
223 * Called when the function is done being executed. Use to clean up resources created in the setup method.
224 */
225 public void pluginTearDown(){}
226
227 /***
228 * Contains the actual testing of the function point. Implement this method with
229 * any code that would make the FunctionTag unique. The default implementation does nothing.
230 * Implement this method to make your function tag useful.
231 * @throws Exception when something goes wrong
232 */
233 public void testBlock() throws Exception{}
234
235 /***
236 * Simply calls <code>setupEnvironment()</code>, <code>validate()</code>, <code>setup()</code> and <code>testBlock(XMLOutput out)</code>.
237 * If this method is overridden, you will need to call super.doTag() or else none of the logging or error reporting will work!
238 */
239 public void doTag(XMLOutput out) throws MissingAttributeException{
240 setupEnvironment();
241 FunctionEventHandler eventHandler = FunctionEventHandler.getInstance();
242 if (!addt.getFailedOnCurrentRow() || postcondition) {
243 if (tct.isExecuteTestCase()){
244 traceMsg("BEGIN: "+functionId);
245 long startTime = System.currentTimeMillis();
246 boolean failureOccured = false;
247 boolean exceptionOccured = false;
248 try{
249 testForUnsupportedAttributesCaught();
250 invokeBody(out);
251 setup();
252 broker.transferAttributes(context);
253 eventHandler.beginFunction(this, 1);
254 broker.validate(context);
255 validate();
256 testBlock();
257 if (expectException) {
258 fail("Expected exception, but none was thrown");
259 }
260 }catch(AssertionFailedError afe){
261 if( expectFailure ){
262
263 failureOccured = true;
264 }else{
265
266 exceptionOccured = true;
267 fResults.setError(afe);
268 }
269 } catch(ThreadDeath td){
270 throw td;
271 } catch(Throwable e){
272 if (!expectException) {
273
274 traceMsg(JameleonUtility.getStack(e));
275 fResults.setError(e);
276 exceptionOccured = true;
277 }
278 }finally{
279 if ( expectFailure && !failureOccured ) {
280 exceptionOccured = true;
281 JameleonScriptException jse = new JameleonScriptException("Expected a failure that did not happen: \n", this );
282 fResults.setError(jse);
283 }
284 if ( exceptionOccured ){
285 state.eventOccured(StateStorer.ON_ERROR_EVENT);
286 if ( lastFileWritten != null ){
287 fResults.setErrorFile(lastFileWritten);
288 }
289 addt.setFailedOnCurrentRow(true);
290 traceMsg("##################################################################");
291 traceMsg("FAILED: "+functionId);
292 traceMsg("##################################################################");
293 traceMsg("");
294 }else{
295 traceMsg("SUCCEEDED: "+functionId);
296 }
297 delay();
298 recordFunctionResult(startTime);
299 eventHandler.endFunction(this, 1);
300 }
301 }
302 }else{
303 removeFunctionResult();
304 }
305 cleanUp();
306 }
307
308 /***
309 * If this method is overridden, it is highly suggested that the super
310 * method be called as well.
311 */
312 protected void cleanUp(){
313 expectFailure = false;
314 expectException = false;
315 tearDown();
316 pluginTearDown();
317 fResults.setTag(fp.cloneFP());
318 resetFunctionalPoint();
319 cleanUpEnvironment();
320 if (params != null) {
321 params.clear();
322 params = null;
323 }
324 }
325
326 protected void cleanUpEnvironment(){
327 if (state != null) {
328 state.removeStorable(this);
329 lastFileWritten = null;
330 }
331 }
332
333 protected void traceMsg(String msg){
334 if (tct != null && tct.getTrace()) {
335 System.out.println(msg+"\n");
336 }else{
337 log.debug(msg);
338 }
339 }
340
341 /***
342 * Adds a required attribute to the macro tag defined for this function point. This is used to enforce a certain
343 * attribute be set in the tag of the function point. The javadoc method should be used instead if possible.
344 * @param attribute - The name of the attribute to add to the required list.
345 */
346 public void addRequiredAttribute(String attribute){
347 Attribute attr = fp.getAttribute(attribute);
348 if (attr == null) {
349 attr = new Attribute();
350 attr.setName(attribute);
351 }
352 attr.setRequired(true);
353 broker.registerAttribute(attr);
354 }
355
356
357
358 /***
359 * Sets the variable to a default value in the context. It is recommended that all variables be set
360 * in the context to take advantage of all features provided by Jamaleon.
361 * This can be used when you want the function point to work with both
362 * a CSV file and setting the attributes in the macro. The rule is if the variable is already set ( via
363 * testEnvironment-Applications.properties or the corresponding CSV dile or another funcational point attribute ),
364 * then this won't be set. If you want to set variable in the context, without regard as to the CSV file,
365 * then simply call context.setVariable(String key, String value) ( through the Jelly API ). <br>
366 * <br>
367 * For the order context variables are set in Jameleon, please see the class description of TestCaseTag.
368 * @see TestCaseTag net.sf.jameleon.TestCaseTag
369 * @param attributeName - the name attribute to set
370 * @param attributeValue - the value of the attribute to set.
371 */
372 public void setDefaultVariableValue(String attributeName, String attributeValue){
373 if (isContextVariableNull(attributeName)) {
374 context.setVariable(attributeName,attributeValue);
375 }else{
376 log.debug("setDefaultVariableValue: Not setting variable \""+attributeName+"\" with value \""+attributeValue+"\" because it has already been set");
377 }
378 }
379
380 /***
381 * Sets the variable to a default value in the context. It is recommended that all variables be set
382 * in the context to take advantage of all features provided by Jamaleon.
383 * This can be used when you want the function point to work with both
384 * a CSV file and setting the attributes in the macro. The rule is if the variable is already set ( via
385 * testEnvironment-Applications.properties or the corresponding CSV dile or another funcationl point in the same test case),
386 * then this won't be set. If you want to set variable in the context, without regard as to the CSV file,
387 * then simply call context.setVariable(String key, String value) ( through the Jelly API ). <br>
388 * <br>
389 * For the order context variables are set in Jameleon, please see the class description of TestCaseTag.
390 * @see TestCaseTag net.sf.jameleon.TestCaseTag
391 * @param attributeName - the name attribute to set
392 * @param attributeValue - the value of the attribute to set.
393 */
394 public void setDefaultVariableValue(String attributeName, Object attributeValue){
395 if (isContextVariableNull(attributeName)) {
396 context.setVariable(attributeName,attributeValue);
397 }else{
398 log.debug("setDefaultVariableValue: Not setting variable \""+attributeName+"\" because it has already been set");
399 }
400 }
401
402 /***
403 * Sets the variable, <code>key</code> to the value, <code>value</code>
404 * This is simply a wrapper class for Jelly's own context.setVariable();
405 * @param key - the name attribute to set
406 * @param value - the value of the attribute to set.
407 */
408 public void setVariable(String key, Object value){
409 ContextHelper.setVariable(context, key, value);
410 }
411
412 /***
413 * Gets the variable, <code>key</code> from the test case context.
414 * This is simply a wrapper class for Jelly's own context.getVariable();
415 * @param key - the name attribute to set
416 * @return the value of <code>key</key>
417 */
418 public Object getVariable(String key){
419 return ContextHelper.getVariable(context, key);
420 }
421
422 /***
423 * Removes the variable, <code>key</code> from the test case context.
424 * This is simply a wrapper class for Jelly's own context.removeVariable();
425 * @param key - the name attribute to set
426 */
427 public void removeVariable(String key){
428 ContextHelper.removeVariable(context, key);
429 }
430
431 /***
432 * @return a variable with name <code>key</code> from the context as a String
433 * @param key The variable name
434 */
435 protected String getVariableAsString(String key){
436 return ContextHelper.getVariableAsString(context, key);
437 }
438
439 /***
440 * @return a variable with name <code>key</code> from the context as a (primitive) boolean
441 * @param key The variable name
442 */
443 protected boolean getVariableAsBoolean(String key) {
444 return ContextHelper.getVariableAsBoolean(context, key);
445 }
446
447 /***
448 * Gets a variable from context and casts it to a list. If the value isn't a
449 * List, then it creates a ArrayList and adds the value to it.
450 * @return a variable with name <code>key</code> from the context as a List even if the value is null.
451 * @param key The variable name
452 */
453 protected List getVariableAsList(String key){
454 return ContextHelper.getVariableAsList(context, key);
455 }
456
457 /***
458 * Checks to see if the variable, <code>key</code>, is null or hasn't been set.
459 * @param key - The name of the variable to be checked for a null value. This variable must be a String.
460 * @return true If the variable is set to null or "" then.
461 */
462
463 protected boolean isContextVariableNull(String key){
464 return ContextHelper.isVariableNull(context, key);
465 }
466
467
468
469 /***
470 * This method is called before the testBlock method is called.
471 * If you want to override this method, call super first,
472 * followed by the custom validations that need to occur in your TestStep.
473 * @throws MissingAttributeException - When a required attribute is not set.
474 */
475 protected void validate() throws MissingAttributeException {
476 checkParamTypes();
477 }
478
479 protected void checkParamTypes(){
480 if (params != null) {
481 Iterator it = params.iterator();
482 while (it.hasNext()) {
483 ParamTag p = (ParamTag)it.next();
484 if (!vpt.isValidType(p.getParamType())) {
485 String errMsg = "Unable to find [" + p.getParamType() + "] in the following types: \n";
486 throw new JameleonScriptException(errMsg + vpt.getValidTypes(), this);
487 }
488 }
489 }
490 }
491
492 /***
493 * This method is called before anything else is called.
494 */
495 protected void setupEnvironment() {
496 getParentTags();
497 params = new ArrayList();
498 state = StateStorer.getInstance();
499 state.addStorable(this);
500 fp.setFunctionId(functionId);
501 fResults.setPrecondition(precondition);
502 fResults.setPostcondition(postcondition);
503
504 Configurator config = Configurator.getInstance();
505 String fDelay = config.getValue("functionDelay");
506 if (functionDelay == NO_DELAY &&
507 fDelay != null &&
508 fDelay.trim().length() > 0) {
509 try{
510 setAttribute("functionDelay", fDelay);
511 }catch(NumberFormatException nfe){
512 traceMsg("functionDelay variable in jameleon.conf is not a valid number");
513 }
514
515 }
516 }
517
518 protected void getParentTags(){
519 Object obj = findAncestorWithClass(TestCaseTag.class);
520 if (obj != null){
521 tct = (TestCaseTag)obj;
522 }else{
523 throw new ClassCastException("Can only execute a function tag under the test case tag (testcase)! "+getClass().getName());
524 }
525 obj = findAncestorWithClass(PostconditionTag.class);
526 if (obj != null) {
527 postcondition = true;
528 }
529 obj = findAncestorWithClass(PreconditionTag.class);
530 if (obj != null) {
531 precondition = true;
532 }
533 obj = findAncestorWithClass(SessionTag.class);
534 if (obj != null) {
535 st = (SessionTag)obj;
536 }
537 setUpFunctionResults();
538 addt = (AbstractDataDrivableTag)findAncestorWithClass(AbstractDataDrivableTag.class);
539 }
540
541 protected void setUpFunctionResults(){
542 fResults = new FunctionResult(fp);
543 fResults.copyLocationAwareProperties(this);
544 Object obj = findAncestorWithClass(FunctionResultRecordable.class);
545 if (obj != null) {
546 ((FunctionResultRecordable)obj).recordFunctionResult(fResults);
547 }
548 }
549
550 protected void removeFunctionResult(){
551 if (fResults.getParentResults() != null) {
552 List results = fResults.getParentResults().getChildrenResults();
553 if (results != null) {
554 int index = results.lastIndexOf(fResults);
555 results.remove(index);
556 }
557 }
558 }
559
560 /***
561 * Adds the result for this test step into the session's results
562 * and logs this information to the logger.
563 * @param startTime - The time this test step started execution.
564 */
565 protected void recordFunctionResult(long startTime){
566 fResults.setExecutionTime(System.currentTimeMillis() - startTime);
567 log.debug(fResults);
568 }
569
570 /***
571 * @return The test results of this test step
572 */
573 public FunctionResult getFunctionResults(){
574 return fResults;
575 }
576
577 /***
578 * Gets the matching text found in the given string.
579 * @param text - The text to match against
580 * @param regex - The regex pattern to match. This regex pattern must
581 * have a single grouping representing the desired text.
582 * @param matchingGroup - The group position to match against.
583 *
584 * @return The matching text in the searchString
585 */
586 public String getMatchingRegexText(String text, String regex, int matchingGroup) {
587 Pattern pattern = Pattern.compile(regex);
588 Matcher matcher = pattern.matcher(text);
589 String matched = null;
590 try {
591 if (matcher.find()) {
592 matched = matcher.group(matchingGroup);
593 }
594 } catch (IndexOutOfBoundsException ie) {
595 throw new JameleonScriptException("No group was defined in the following regular expression: ["+regex+"]", this);
596 }
597 return matched;
598 }
599
600 /***
601 * Validates that the provided regex matches the provided text
602 * @param text - The text to match against
603 * @param regex - The regex pattern to match
604 *
605 * @return True if the regex matches or false if it doesn't
606 */
607 public boolean regexMatches(String text, String regex) {
608 boolean matches;
609 if (regex == null) {
610 throw new JameleonScriptException("regex! can not be null", this);
611 }
612 if (text == null) {
613 throw new JameleonScriptException("text! can not be null", this);
614 }
615 Pattern pattern = Pattern.compile(regex);
616 Matcher matcher = pattern.matcher(text);
617 matches = matcher.find();
618 return matches;
619 }
620
621 /***
622 * Gets a String by its default value if an actual value isn't found.
623 * @return a String by its default value if an actual value isn't found..
624 * @param value - the value to return
625 * @param defaultValue - the value to return if the <code>value</code> parameter is null
626 */
627 public String getStringOrDefault(String value, String defaultValue){
628 String returnValue = defaultValue;
629 if (value != null) {
630 returnValue = value;
631 }
632 return returnValue;
633 }
634
635 /***
636 * Gets the parent test case tag
637 * @return the parent test case tag of this tag.
638 */
639 public TestCaseTag getTestCaseTag(){
640 return tct;
641 }
642
643
644 /***
645 * <p>
646 * Stores the current state of the object to a given <code>File</code>. The default
647 * implementation of this method does nothing. Override this method to implement
648 * plug-in specific behavior. Some examples might be:</p>
649 * <ul>
650 * <li>Saving the HTML from an HTTP plug-in during a state change or error</li>
651 * <li>Taking a screen shot for a GUI application during a state change event</li>
652 * </ul>
653 * <p>
654 * A listener is already registered for each function tag. All that is required is
655 * implementing this method.</p>
656 * @param filename the name of the if the file to store the contents to.
657 * @param event The {@link net.sf.jameleon.util.StateStorer event} that occured (error, state change ...).
658 * @throws IOException If the state of the object could not be stored in File <code>f</code>.
659 */
660 public void store(String filename, int event) throws IOException{
661 }
662
663 public SessionTag getSessionTag(){
664 return st;
665 }
666
667 /***
668 * Gets the filename to store the state of the application to.
669 * The default implementation is to simply use timestamps.
670 * If this is not the desired behavior, override this method.
671 * @param event - the StateStorer Event
672 * @return the appropriate filename which starts with ERROR- if the StateStorer Event was an Error
673 */
674 public String getStoreToFileName(int event){
675 String filename = System.currentTimeMillis() +"";
676 if ( event == StateStorer.ON_ERROR_EVENT ) {
677 filename = "ERROR-"+filename;
678 }
679 return filename;
680 }
681
682
683
684 /*****************************************************************************************
685 *Start of Wrapper Methods
686 ****************************************************************************************/
687
688 /***
689 * Runs the run method of a Runnable and records the results appropriately.
690 * @param r - The block of code you want executed ( defined in the run() method ).
691 * @deprecated This method will be removed in the next major release.
692 */
693 protected void assertMethod(Runnable r){
694 r.run();
695 }
696
697 /***
698 * Runs the run method of a Runnable and records the results appropriately.
699 * @param r - The block of code you want executed ( defined in the run() method ).
700 * @param assertLevel - The assert level of when to run the method
701 */
702 protected void assertMethodWithLevel(Runnable r, int assertLevel){
703 if (assertLevelManager.assertPerformable(assertLevel)) {
704 r.run();
705 }
706 }
707
708
709
710 /***
711 * Fails by throwing an AssertionFailedError.
712 */
713 public void fail(){
714 String message = "";
715 int assertLevel = AssertLevel.NO_LEVEL;
716 fail(message, assertLevel);
717 }
718
719 /***
720 * Fails by throwing an AssertionFailedError with a <code>message</code>
721 * @param message - The message to display on failure.
722 */
723 public void fail(final String message){
724 int assertLevel = AssertLevel.NO_LEVEL;
725 fail(message, assertLevel);
726 }
727
728 /***
729 * Fails by throwing an AssertionFailedError with a <code>message</code>
730 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
731 */
732 public void fail(int assertLevel){
733 String message = "";
734 fail(message, assertLevel);
735 }
736
737 /***
738 * Fails by throwing an AssertionFailedError with a <code>message</code>
739 * @param message - The message to display on failure.
740 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
741 */
742 public void fail(final String message, int assertLevel){
743 assertMethodWithLevel(new Runnable() {
744 public void run() {
745 Assert.fail(JameleonUtility.createErrMsg(message));
746 }
747 }, assertLevel);
748 }
749
750 /***
751 * Asserts that a condition is true.
752 * @param condition - The boolean condition to test.
753 */
754 public void assertTrue(final boolean condition) {
755 String message = "assertTrue: ";
756 int assertLevel = AssertLevel.NO_LEVEL;
757 assertTrue(message, condition, assertLevel);
758 }
759
760 /***
761 * Asserts that a condition is true.
762 * @param message - The message to print out if the assert fails
763 * @param condition - The boolean condition to test.
764 */
765 public void assertTrue(final String message, final boolean condition) {
766 int assertLevel = AssertLevel.NO_LEVEL;
767 assertTrue(message, condition, assertLevel);
768 }
769
770 /***
771 * Asserts that a condition is true.
772 * @param condition - The boolean condition to test.
773 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
774 */
775 public void assertTrue(final boolean condition, int assertLevel) {
776 String message = "assertTrue: ";
777 assertTrue(message, condition, assertLevel);
778 }
779
780 /***
781 * Asserts that a condition is true.
782 * @param message - The message to print out if the assert fails
783 * @param condition - The boolean condition to test.
784 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
785 */
786 public void assertTrue(final String message, final boolean condition, int assertLevel) {
787 assertMethodWithLevel(new Runnable() {
788 public void run() {
789 Assert.assertTrue(JameleonUtility.createErrMsg(message),condition);
790 }
791 },assertLevel);
792 }
793
794 /***
795 * Asserts that a condition is false.
796 * @param condition - The boolean condition to test.
797 */
798 public void assertFalse(final boolean condition) {
799 String message = "assertFalse: ";
800 int assertLevel = AssertLevel.NO_LEVEL;
801 assertFalse(message, condition, assertLevel);
802 }
803
804 /***
805 * Asserts that a condition is false.
806 * @param message - The message to print out if the assert fails
807 * @param condition - The boolean condition to test.
808 */
809 public void assertFalse(final String message, final boolean condition) {
810 int assertLevel = AssertLevel.NO_LEVEL;
811 assertFalse(message, condition, assertLevel);
812 }
813
814 /***
815 * Asserts that a condition is false.
816 * @param condition - The boolean condition to test.
817 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
818 */
819 public void assertFalse(final boolean condition, int assertLevel) {
820 String message = "assertFalse: ";
821 assertFalse(message, condition, assertLevel);
822 }
823
824 /***
825 * Asserts that a condition is false.
826 * @param message - The message to print out if the assert fails
827 * @param condition - The boolean condition to test.
828 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
829 */
830 public void assertFalse(final String message, final boolean condition, int assertLevel) {
831 assertMethodWithLevel(new Runnable() {
832 public void run() {
833 Assert.assertFalse(JameleonUtility.createErrMsg(message),condition);
834 }
835 },assertLevel);
836 }
837
838 /***
839 * Asserts that two objects are equal.
840 * @param text - The text to be compared
841 * @param textContained - the text to be contained
842 */
843 public void assertTextContains(final String text, final String textContained) {
844 String message = "assertTextContains: '"+textContained+"' not in given text";
845 int assertLevel = AssertLevel.NO_LEVEL;
846 assertTextContains(message, text, textContained, assertLevel);
847 }
848
849 /***
850 * Asserts that two objects are equal.
851 * @param message - The message to print out if the assert fails
852 * @param text - The text to be compared
853 * @param textContained - the text to be contained
854 */
855 public void assertTextContains(final String message, final String text, final String textContained) {
856 int assertLevel = AssertLevel.NO_LEVEL;
857 assertTextContains(message, text, textContained, assertLevel);
858 }
859
860 /***
861 * Asserts that two objects are equal.
862 * @param text - The text to be compared
863 * @param textContained - the text to be contained
864 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
865 */
866 public void assertTextContains(final String text, final String textContained, int assertLevel) {
867 String message = "assertTextContains: '"+textContained+"' not in given text";
868 assertTextContains(message, text, textContained, assertLevel);
869 }
870
871 /***
872 * Asserts text is contained into some given text.
873 * @param message - The message to print out if the assert fails
874 * @param text - The text to be compared
875 * @param textContained - the text to be contained
876 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
877 */
878 public void assertTextContains(final String message, final String text, final String textContained, int assertLevel) {
879 assertMethodWithLevel(new Runnable() {
880 public void run() {
881 Assert.assertTrue(JameleonUtility.createErrMsg(message), text.indexOf(textContained) >= 0);
882 }
883 },assertLevel);
884 }
885
886 /***
887 * Asserts that the given startingText begins the given text..
888 * @param text - The text to be compared
889 * @param startingText - the text that must be at the beginning.
890 */
891 public void assertTextStartsWith(final String text, final String startingText) {
892 String message = "assertTextStartsWith: '"+startingText+"' is not at the beginning of the given text";
893 int assertLevel = AssertLevel.NO_LEVEL;
894 assertTextStartsWith(message, text, startingText, assertLevel);
895 }
896
897 /***
898 * Asserts that the given startingText begins the given text..
899 * @param message - The message to print out if the assert fails
900 * @param text - The text to be compared
901 * @param startingText - the text that must be at the beginning.
902 */
903 public void assertTextStartsWith(final String message, final String text, final String startingText) {
904 int assertLevel = AssertLevel.NO_LEVEL;
905 assertTextStartsWith(message, text, startingText, assertLevel);
906 }
907
908 /***
909 * Asserts that the given startingText begins the given text..
910 * @param text - The text to be compared
911 * @param startingText - the text that must be at the beginning.
912 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
913 */
914 public void assertTextStartsWith(final String text, final String startingText, int assertLevel) {
915 String message = "assertTextStartsWith: '"+startingText+"' is not at the beginning of the given text";
916 assertTextStartsWith(message, text, startingText, assertLevel);
917 }
918
919 /***
920 * Asserts that the given startingText begins the given text..
921 * @param message - The message to print out if the assert fails
922 * @param text - The text to be compared
923 * @param startingText - the text that must be at the beginning.
924 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
925 */
926 public void assertTextStartsWith(final String message, final String text, final String startingText, int assertLevel) {
927 assertMethodWithLevel(new Runnable() {
928 public void run() {
929 Assert.assertTrue(JameleonUtility.createErrMsg(message), text.startsWith(startingText));
930 }
931 },assertLevel);
932 }
933
934 /***
935 * Asserts that the given endingText is at the end of the given text..
936 * @param text - The text to be compared
937 * @param endingText - the text that must be at the end.
938 */
939 public void assertTextEndsWith(final String text, final String endingText) {
940 String message = "assertTextEndsWith: '"+endingText+"' is not at the end of the given text";
941 int assertLevel = AssertLevel.NO_LEVEL;
942 assertTextEndsWith(message, text, endingText, assertLevel);
943 }
944
945 /***
946 * Asserts that the given endingText is at the end of the given text..
947 * @param message - The message to print out if the assert fails
948 * @param text - The text to be compared
949 * @param endingText - the text that must be at the end.
950 */
951 public void assertTextEndsWith(final String message, final String text, final String endingText) {
952 int assertLevel = AssertLevel.NO_LEVEL;
953 assertTextEndsWith(message, text, endingText, assertLevel);
954 }
955
956 /***
957 * Asserts that the given endingText is at the end of the given text..
958 * @param text - The text to be compared
959 * @param endingText - the text that must be at the end.
960 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
961 */
962 public void assertTextEndsWith(final String text, final String endingText, int assertLevel) {
963 String message = "assertTextEndsWith: '"+endingText+"' is not at the end of the given text";
964 assertTextEndsWith(message, text, endingText, assertLevel);
965 }
966
967 /***
968 * Asserts text is contained into some given text.
969 * @param message - The message to print out if the assert fails
970 * @param text - The text to be compared
971 * @param endingText - the text that must be at the end.
972 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
973 */
974 public void assertTextEndsWith(final String message, final String text, final String endingText, int assertLevel) {
975 assertMethodWithLevel(new Runnable() {
976 public void run() {
977 Assert.assertTrue(JameleonUtility.createErrMsg(message), text.endsWith(endingText));
978 }
979 },assertLevel);
980 }
981
982 /***
983 * Asserts that two objects are equal.
984 * @param expected - The expected value.
985 * @param actual - The value to compare against the <code>expected</code> or the actual value.
986 */
987 public void assertEquals(final Object expected, final Object actual) {
988 String message = "";
989 int assertLevel = AssertLevel.NO_LEVEL;
990 assertEquals(message, expected, actual, assertLevel);
991 }
992
993 /***
994 * Asserts that two objects are equal.
995 * @param message - The message to print out if the assert fails
996 * @param expected - The expected value.
997 * @param actual - The value to compare against the <code>expected</code> or the actual value.
998 */
999 public void assertEquals(final String message, final Object expected, final Object actual) {
1000 int assertLevel = AssertLevel.NO_LEVEL;
1001 assertEquals(message, expected, actual, assertLevel);
1002 }
1003
1004 /***
1005 * Asserts that two objects are equal.
1006 * @param expected - The expected value.
1007 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1008 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1009 */
1010 public void assertEquals(final Object expected, final Object actual, int assertLevel) {
1011 String message = "";
1012 assertEquals(message, expected, actual, assertLevel);
1013 }
1014
1015 /***
1016 * Asserts that two objects are equal.
1017 * @param message - The message to print out if the assert fails
1018 * @param expected - The expected value.
1019 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1020 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1021 */
1022 public void assertEquals(final String message, final Object expected, final Object actual, int assertLevel) {
1023 assertMethodWithLevel(new Runnable() {
1024 public void run() {
1025 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1026 }
1027 },assertLevel);
1028 }
1029
1030 /***
1031 * Asserts that two Strings are equal.
1032 * @param expected - The expected value.
1033 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1034 */
1035 public void assertEquals(final String expected, final String actual) {
1036 String message = "";
1037 int assertLevel = AssertLevel.NO_LEVEL;
1038 assertEquals(message, expected, actual, assertLevel);
1039 }
1040
1041 /***
1042 * Asserts that two Strings are equal.
1043 * @param message - The message to print out if the assert fails
1044 * @param expected - The expected value.
1045 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1046 */
1047 public void assertEquals(final String message, final String expected, final String actual) {
1048 int assertLevel = AssertLevel.NO_LEVEL;
1049 assertEquals(message, expected, actual, assertLevel);
1050 }
1051
1052 /***
1053 * Asserts that two Strings are equal.
1054 * @param expected - The expected value.
1055 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1056 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1057 */
1058 public void assertEquals(final String expected, final String actual, int assertLevel) {
1059 String message = "";
1060 assertEquals(message, expected, actual, assertLevel);
1061 }
1062
1063 /***
1064 * Asserts that two Strings are equal.
1065 * @param message - The message to print out if the assert fails
1066 * @param expected - The expected value.
1067 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1068 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1069 */
1070 public void assertEquals(final String message, final String expected, final String actual, int assertLevel) {
1071 assertMethodWithLevel(new Runnable() {
1072 public void run() {
1073 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1074 }
1075 },assertLevel);
1076 }
1077
1078 /***
1079 * Asserts that two doubles are equal concerning a delta.
1080 * If the expected value is infinity then the delta value is ignored.
1081 * @param expected - The expected value.
1082 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1083 * @param delta - The amount the expected and actual can be different from each other.
1084 */
1085 public void assertEquals(final double expected, final double actual, final double delta) {
1086 String message = "";
1087 int assertLevel = AssertLevel.NO_LEVEL;
1088 assertEquals(message, expected, actual, delta, assertLevel);
1089 }
1090
1091 /***
1092 * Asserts that two doubles are equal concerning a delta.
1093 * If the expected value is infinity then the delta value is ignored.
1094 * @param message - The message to print out if the assert fails
1095 * @param expected - The expected value.
1096 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1097 * @param delta - The amount the expected and actual can be different from each other.
1098 */
1099 public void assertEquals(final String message, final double expected, final double actual, final double delta) {
1100 int assertLevel = AssertLevel.NO_LEVEL;
1101 assertEquals(message, expected, actual, delta, assertLevel);
1102 }
1103
1104 /***
1105 * Asserts that two doubles are equal concerning a delta.
1106 * If the expected value is infinity then the delta value is ignored.
1107 * @param expected - The expected value.
1108 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1109 * @param delta - The amount the expected and actual can be different from each other.
1110 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1111 */
1112 public void assertEquals(final double expected, final double actual, final double delta, int assertLevel) {
1113 String message = "";
1114 assertEquals(message, expected, actual, delta, assertLevel);
1115 }
1116
1117 /***
1118 * Asserts that two doubles are equal concerning a delta.
1119 * If the expected value is infinity then the delta value is ignored.
1120 * @param message - The message to print out if the assert fails
1121 * @param expected - The expected value.
1122 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1123 * @param delta - The amount the expected and actual can be different from each other.
1124 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1125 */
1126 public void assertEquals(final String message, final double expected, final double actual, final double delta, int assertLevel) {
1127 assertMethodWithLevel(new Runnable() {
1128 public void run() {
1129 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual,delta);
1130 }
1131 },assertLevel);
1132 }
1133
1134 /***
1135 * Asserts that two floats are equal concerning a delta.
1136 * If the expected value is infinity then the delta value is ignored.
1137 * @param expected - The expected value.
1138 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1139 * @param delta - The amount the expected and actual can be different from each other.
1140 */
1141 public void assertEquals(final float expected, final float actual, final float delta) {
1142 String message = "";
1143 int assertLevel = AssertLevel.NO_LEVEL;
1144 assertEquals(message, expected, actual, delta, assertLevel);
1145 }
1146
1147 /***
1148 * Asserts that two floats are equal concerning a delta.
1149 * If the expected value is infinity then the delta value is ignored.
1150 * @param message - The message to print out if the assert fails
1151 * @param expected - The expected value.
1152 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1153 * @param delta - The amount the expected and actual can be different from each other.
1154 */
1155 public void assertEquals(final String message, final float expected, final float actual, final float delta) {
1156 int assertLevel = AssertLevel.NO_LEVEL;
1157 assertEquals(message, expected, actual, delta, assertLevel);
1158 }
1159
1160 /***
1161 * Asserts that two floats are equal concerning a delta.
1162 * If the expected value is infinity then the delta value is ignored.
1163 * @param expected - The expected value.
1164 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1165 * @param delta - The amount the expected and actual can be different from each other.
1166 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1167 */
1168 public void assertEquals(final float expected, final float actual, final float delta, int assertLevel) {
1169 String message = "";
1170 assertEquals(message, expected, actual, delta, assertLevel);
1171 }
1172
1173 /***
1174 * Asserts that two floats are equal concerning a delta.
1175 * If the expected value is infinity then the delta value is ignored.
1176 * @param message - The message to print out if the assert fails
1177 * @param expected - The expected value.
1178 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1179 * @param delta - The amount the expected and actual can be different from each other.
1180 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1181 */
1182 public void assertEquals(final String message, final float expected, final float actual, final float delta, int assertLevel) {
1183 assertMethodWithLevel(new Runnable() {
1184 public void run() {
1185 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual,delta);
1186 }
1187 },assertLevel);
1188 }
1189
1190 /***
1191 * Asserts that two longs are equal.
1192 * @param expected - The expected value.
1193 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1194 */
1195 public void assertEquals(final long expected, final long actual) {
1196 String message = "";
1197 int assertLevel = AssertLevel.NO_LEVEL;
1198 assertEquals(message, expected, actual, assertLevel);
1199 }
1200
1201 /***
1202 * Asserts that two longs are equal.
1203 * @param message - The message to print out if the assert fails
1204 * @param expected - The expected value.
1205 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1206 */
1207 public void assertEquals(final String message, final long expected, final long actual) {
1208 int assertLevel = AssertLevel.NO_LEVEL;
1209 assertEquals(message, expected, actual, assertLevel);
1210 }
1211
1212 /***
1213 * Asserts that two longs are equal.
1214 * @param expected - The expected value.
1215 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1216 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1217 */
1218 public void assertEquals(final long expected, final long actual, int assertLevel) {
1219 String message = "";
1220 assertEquals(message, expected, actual, assertLevel);
1221 }
1222
1223 /***
1224 * Asserts that two longs are equal.
1225 * @param message - The message to print out if the assert fails
1226 * @param expected - The expected value.
1227 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1228 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1229 */
1230 public void assertEquals(final String message, final long expected, final long actual, int assertLevel) {
1231 assertMethodWithLevel(new Runnable() {
1232 public void run() {
1233 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1234 }
1235 }, assertLevel);
1236 }
1237
1238 /***
1239 * Asserts that two booleans are equal.
1240 * @param expected - The expected value.
1241 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1242 */
1243 public void assertEquals(final boolean expected, final boolean actual) {
1244 String message = "";
1245 int assertLevel = AssertLevel.NO_LEVEL;
1246 assertEquals(message, expected, actual, assertLevel);
1247 }
1248
1249 /***
1250 * Asserts that two booleans are equal.
1251 * @param message - The message to print out if the assert fails
1252 * @param expected - The expected value.
1253 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1254 */
1255 public void assertEquals(final String message, final boolean expected, final boolean actual) {
1256 int assertLevel = AssertLevel.NO_LEVEL;
1257 assertEquals(message, expected, actual, assertLevel);
1258 }
1259
1260 /***
1261 * Asserts that two booleans are equal.
1262 * @param expected - The expected value.
1263 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1264 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1265 */
1266 public void assertEquals(final boolean expected, final boolean actual, int assertLevel) {
1267 String message = "";
1268 assertEquals(message, expected, actual, assertLevel);
1269 }
1270
1271 /***
1272 * Asserts that two booleans are equal.
1273 * @param message - The message to print out if the assert fails
1274 * @param expected - The expected value.
1275 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1276 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1277 */
1278 public void assertEquals(final String message, final boolean expected, final boolean actual, int assertLevel) {
1279 assertMethodWithLevel(new Runnable() {
1280 public void run() {
1281 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1282 }
1283 }, assertLevel);
1284 }
1285
1286 /***
1287 * Asserts that two bytes are equal.
1288 * @param expected - The expected value.
1289 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1290 */
1291 public void assertEquals(final byte expected, final byte actual) {
1292 String message = "";
1293 int assertLevel = AssertLevel.NO_LEVEL;
1294 assertEquals(message, expected, actual, assertLevel);
1295 }
1296
1297 /***
1298 * Asserts that two bytes are equal.
1299 * @param message - The message to print out if the assert fails
1300 * @param expected - The expected value.
1301 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1302 */
1303 public void assertEquals(final String message, final byte expected, final byte actual) {
1304 int assertLevel = AssertLevel.NO_LEVEL;
1305 assertEquals(message, expected, actual, assertLevel);
1306 }
1307
1308 /***
1309 * Asserts that two bytes are equal.
1310 * @param expected - The expected value.
1311 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1312 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1313 */
1314 public void assertEquals(final byte expected, final byte actual, int assertLevel) {
1315 String message = "";
1316 assertEquals(message, expected, actual, assertLevel);
1317 }
1318
1319 /***
1320 * Asserts that two bytes are equal.
1321 * @param message - The message to print out if the assert fails
1322 * @param expected - The expected value.
1323 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1324 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1325 */
1326 public void assertEquals(final String message, final byte expected, final byte actual, int assertLevel) {
1327 assertMethodWithLevel(new Runnable() {
1328 public void run() {
1329 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1330 }
1331 }, assertLevel);
1332 }
1333
1334 /***
1335 * Asserts that two chars are equal.
1336 * @param expected - The expected value.
1337 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1338 */
1339 public void assertEquals(final char expected, final char actual) {
1340 String message = "";
1341 int assertLevel = AssertLevel.NO_LEVEL;
1342 assertEquals(message, expected, actual, assertLevel);
1343 }
1344
1345 /***
1346 * Asserts that two chars are equal.
1347 * @param message - The message to print out if the assert fails
1348 * @param expected - The expected value.
1349 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1350 */
1351 public void assertEquals(final String message, final char expected, final char actual) {
1352 int assertLevel = AssertLevel.NO_LEVEL;
1353 assertEquals(message, expected, actual, assertLevel);
1354 }
1355
1356 /***
1357 * Asserts that two chars are equal.
1358 * @param expected - The expected value.
1359 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1360 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1361 */
1362 public void assertEquals(final char expected, final char actual, int assertLevel) {
1363 String message = "";
1364 assertEquals(message, expected, actual, assertLevel);
1365 }
1366
1367 /***
1368 * Asserts that two chars are equal.
1369 * @param message - The message to print out if the assert fails
1370 * @param expected - The expected value.
1371 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1372 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1373 */
1374 public void assertEquals(final String message, final char expected, final char actual, int assertLevel) {
1375 assertMethodWithLevel(new Runnable() {
1376 public void run() {
1377 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1378 }
1379 }, assertLevel);
1380 }
1381
1382 /***
1383 * Asserts that two shorts are equal.
1384 * @param expected - The expected value.
1385 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1386 */
1387 public void assertEquals(final short expected, final short actual) {
1388 String message = "";
1389 int assertLevel = AssertLevel.NO_LEVEL;
1390 assertEquals(message, expected, actual, assertLevel);
1391 }
1392
1393 /***
1394 * Asserts that two shorts are equal.
1395 * @param message - The message to print out if the assert fails
1396 * @param expected - The expected value.
1397 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1398 */
1399 public void assertEquals(final String message, final short expected, final short actual) {
1400 int assertLevel = AssertLevel.NO_LEVEL;
1401 assertEquals(message, expected, actual, assertLevel);
1402 }
1403
1404 /***
1405 * Asserts that two shorts are equal.
1406 * @param expected - The expected value.
1407 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1408 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1409 */
1410 public void assertEquals(final short expected, final short actual, int assertLevel) {
1411 String message = "";
1412 assertEquals(message, expected, actual, assertLevel);
1413 }
1414
1415 /***
1416 * Asserts that two shorts are equal.
1417 * @param message - The message to print out if the assert fails
1418 * @param expected - The expected value.
1419 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1420 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1421 */
1422 public void assertEquals(final String message, final short expected, final short actual, int assertLevel) {
1423 assertMethodWithLevel(new Runnable() {
1424 public void run() {
1425 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1426 }
1427 }, assertLevel);
1428 }
1429
1430 /***
1431 * Asserts that two ints are equal.
1432 * @param expected - The expected value.
1433 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1434 */
1435 public void assertEquals(final int expected, final int actual) {
1436 String message = "";
1437 int assertLevel = AssertLevel.NO_LEVEL;
1438 assertEquals(message, expected, actual, assertLevel);
1439 }
1440
1441 /***
1442 * Asserts that two ints are equal.
1443 * @param message - The message to print out if the assert fails
1444 * @param expected - The expected value.
1445 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1446 */
1447 public void assertEquals(final String message, final int expected, final int actual) {
1448 int assertLevel = AssertLevel.NO_LEVEL;
1449 assertEquals(message, expected, actual, assertLevel);
1450 }
1451
1452 /***
1453 * Asserts that two ints are equal.
1454 * @param expected - The expected value.
1455 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1456 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1457 */
1458 public void assertEquals(final int expected, final int actual, int assertLevel) {
1459 String message = "";
1460 assertEquals(message, expected, actual, assertLevel);
1461 }
1462
1463 /***
1464 * Asserts that two ints are equal.
1465 * @param message - The message to print out if the assert fails
1466 * @param expected - The expected value.
1467 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1468 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1469 */
1470 public void assertEquals(final String message, final int expected, final int actual, int assertLevel) {
1471 assertMethodWithLevel(new Runnable() {
1472 public void run() {
1473 Assert.assertEquals(JameleonUtility.createErrMsg(message),expected,actual);
1474 }
1475 }, assertLevel);
1476 }
1477
1478 /***
1479 * Asserts that an object isn't null.
1480 * @param object - The object to test for null
1481 */
1482 public void assertNotNull(final Object object) {
1483 String message = "";
1484 int assertLevel = AssertLevel.NO_LEVEL;
1485 assertNotNull(message, object, assertLevel);
1486 }
1487
1488 /***
1489 * Asserts that an object isn't null.
1490 * @param message - The message to print out if the assert fails
1491 * @param object - The object to test for null
1492 */
1493 public void assertNotNull(final String message, final Object object) {
1494 int assertLevel = AssertLevel.NO_LEVEL;
1495 assertNotNull(message, object, assertLevel);
1496 }
1497
1498 /***
1499 * Asserts that an object isn't null.
1500 * @param object - The object to test for null
1501 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1502 */
1503 public void assertNotNull(final Object object, int assertLevel) {
1504 String message = "";
1505 assertNotNull(message, object, assertLevel);
1506 }
1507
1508 /***
1509 * Asserts that an object isn't null.
1510 * @param message - The message to print out if the assert fails
1511 * @param object - The object to test for null
1512 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1513 */
1514 public void assertNotNull(final String message, final Object object, int assertLevel) {
1515 assertMethodWithLevel(new Runnable() {
1516 public void run() {
1517 Assert.assertNotNull(JameleonUtility.createErrMsg(message),object);
1518 }
1519 }, assertLevel);
1520 }
1521
1522 /***
1523 * Asserts that an object is null.
1524 * @param object - The object to test for null
1525 */
1526 public void assertNull(final Object object) {
1527 String message = "";
1528 int assertLevel = AssertLevel.NO_LEVEL;
1529 assertNull(message, object, assertLevel);
1530 }
1531
1532 /***
1533 * Asserts that an object is null.
1534 * @param message - The message to print out if the assert fails
1535 * @param object - The object to test for null
1536 */
1537 public void assertNull(final String message, final Object object) {
1538 int assertLevel = AssertLevel.NO_LEVEL;
1539 assertNull(message, object, assertLevel);
1540 }
1541
1542 /***
1543 * Asserts that an object is null.
1544 * @param object - The object to test for null
1545 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1546 */
1547 public void assertNull(final Object object, int assertLevel) {
1548 String message = "";
1549 assertNull(message, object, assertLevel);
1550 }
1551
1552 /***
1553 * Asserts that an object is null.
1554 * @param message - The message to print out if the assert fails
1555 * @param object - The object to test for null
1556 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1557 */
1558 public void assertNull(final String message, final Object object, int assertLevel) {
1559 assertMethodWithLevel(new Runnable() {
1560 public void run() {
1561 Assert.assertNull(JameleonUtility.createErrMsg(message),object);
1562 }
1563 }, assertLevel);
1564 }
1565
1566 /***
1567 * Asserts that given regex matches the provided text
1568 * @param text - The text to match the regex against
1569 * @param regex - The regex to match.
1570 */
1571 public void assertRegexMatches(final String text, final String regex) {
1572 String message = "assertRegexMatches";
1573 int assertLevel = AssertLevel.NO_LEVEL;
1574 assertRegexMatches(message, text, regex, assertLevel);
1575 }
1576
1577 /***
1578 * Asserts that given regex matches the provided text
1579 * @param message - The message to print out if the assert fails
1580 * @param text - The text to match the regex against
1581 * @param regex - The regex to match.
1582 */
1583 public void assertRegexMatches(final String message, final String text, final String regex) {
1584 int assertLevel = AssertLevel.NO_LEVEL;
1585 assertRegexMatches(message, text, regex, assertLevel);
1586 }
1587
1588 /***
1589 * Asserts that given regex matches the provided text
1590 * @param text - The text to match the regex against
1591 * @param regex - The regex to match.
1592 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1593 */
1594 public void assertRegexMatches(final String text, final String regex, int assertLevel) {
1595 String message = "assertRegexMatches";
1596 assertRegexMatches(message, text, regex, assertLevel);
1597 }
1598
1599 /***
1600 * Asserts that given regex matches the provided text
1601 * @param message - The message to print out if the assert fails
1602 * @param text - The text to match the regex against
1603 * @param regex - The regex to match.
1604 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1605 */
1606 public void assertRegexMatches(final String message, final String text, final String regex, int assertLevel) {
1607 assertMethodWithLevel(new Runnable() {
1608 public void run() {
1609 Assert.assertTrue(JameleonUtility.createErrMsg(message),regexMatches(text, regex));
1610 }
1611 }, assertLevel);
1612 }
1613
1614 /***
1615 * Asserts that two objects refer to the same object.
1616 * @param expected - The expected value.
1617 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1618 */
1619 public void assertSame(final Object expected, final Object actual) {
1620 String message = "";
1621 int assertLevel = AssertLevel.NO_LEVEL;
1622 assertSame(message, expected, actual, assertLevel);
1623 }
1624
1625 /***
1626 * Asserts that two objects refer to the same object.
1627 * @param message - The message to print out if the assert fails
1628 * @param expected - The expected value.
1629 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1630 */
1631 public void assertSame(final String message, final Object expected, final Object actual) {
1632 int assertLevel = AssertLevel.NO_LEVEL;
1633 assertSame(message, expected, actual, assertLevel);
1634 }
1635
1636 /***
1637 * Asserts that two objects refer to the same object.
1638 * @param expected - The expected value.
1639 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1640 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1641 */
1642 public void assertSame(final Object expected, final Object actual, int assertLevel) {
1643 String message = "";
1644 assertSame(message, expected, actual, assertLevel);
1645 }
1646
1647 /***
1648 * Asserts that two objects refer to the same object.
1649 * @param message - The message to print out if the assert fails
1650 * @param expected - The expected value.
1651 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1652 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1653 */
1654 public void assertSame(final String message, final Object expected, final Object actual, int assertLevel) {
1655 assertMethodWithLevel(new Runnable() {
1656 public void run() {
1657 Assert.assertSame(JameleonUtility.createErrMsg(message),expected,actual);
1658 }
1659 }, assertLevel);
1660 }
1661
1662 /***
1663 * Asserts that two objects refer to the same object.
1664 * @param expected - The expected value.
1665 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1666 */
1667 public void assertNotSame(final Object expected, final Object actual) {
1668 String message = "";
1669 int assertLevel = AssertLevel.NO_LEVEL;
1670 assertNotSame(message, expected, actual, assertLevel);
1671 }
1672
1673 /***
1674 * Asserts that two objects refer to the same object.
1675 * @param message - The message to print out if the assert fails
1676 * @param expected - The expected value.
1677 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1678 */
1679 public void assertNotSame(final String message, final Object expected, final Object actual) {
1680 int assertLevel = AssertLevel.NO_LEVEL;
1681 assertNotSame(message, expected, actual, assertLevel);
1682 }
1683
1684 /***
1685 * Asserts that two objects refer to the same object.
1686 * @param expected - The expected value.
1687 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1688 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1689 */
1690 public void assertNotSame(final Object expected, final Object actual, int assertLevel) {
1691 String message = "";
1692 assertNotSame(message, expected, actual, assertLevel);
1693 }
1694
1695 /***
1696 * Asserts that two objects refer to the same object.
1697 * @param message - The message to print out if the assert fails
1698 * @param expected - The expected value.
1699 * @param actual - The value to compare against the <code>expected</code> or the actual value.
1700 * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1701 */
1702 public void assertNotSame(final String message, final Object expected, final Object actual, int assertLevel) {
1703 assertMethodWithLevel(new Runnable() {
1704 public void run() {
1705 Assert.assertNotSame(JameleonUtility.createErrMsg(message),expected,actual);
1706 }
1707 }, assertLevel);
1708 }
1709
1710
1711
1712 /***
1713 * Adds a ParamTag to the list of parameters
1714 * @param param - the ParamTag to add
1715 */
1716 public void addParam(Object param){
1717 params.add(param);
1718 }
1719
1720 /***
1721 * Gets the nth ParamTag.
1722 * @param index - the index location of the desired ParamTag.
1723 * @return the ParamTag located at index
1724 */
1725 public Object getParam(int index){
1726 return params.get(index);
1727 }
1728
1729 /***
1730 * Gets the list of ParamTags under this tag.
1731 * @return the list of ParamTags under this tag.
1732 */
1733 public List getParams(){
1734 return params;
1735 }
1736
1737 /***
1738 * Gets the number of ParamTags under this tag.
1739 * @return the number of ParamTags under this tag.
1740 */
1741 public int getParamLength(){
1742 return params.size();
1743 }
1744
1745 public void delay(){
1746 delay(functionDelay);
1747 }
1748
1749 public void delay(long delayTime){
1750 if (delayTime > 0) {
1751 synchronized (this){
1752 try {
1753 this.wait(delayTime);
1754 } catch (InterruptedException e) {
1755 e.printStackTrace();
1756 }
1757 }
1758 }
1759 }
1760
1761
1762 }