001 // jademx - JADE management using JMX
002 // Copyright 2005 Caboodle Networks, Inc.
003 //
004 // This library is free software; you can redistribute it and/or
005 // modify it under the terms of the GNU Lesser General Public
006 // License as published by the Free Software Foundation; either
007 // version 2.1 of the License, or (at your option) any later version.
008 //
009 // This library is distributed in the hope that it will be useful,
010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 // Lesser General Public License for more details.
013 //
014 // You should have received a copy of the GNU Lesser General Public
015 // License along with this library; if not, write to the Free Software
016 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
017
018 package jade.jademx.unit;
019
020
021 import java.util.Properties;
022
023 import jade.jademx.JadeMXSuiteTest;
024 import jade.jademx.agent.JademxAgent;
025 import jade.jademx.util.iso8601.Duration;
026 import jade.lang.acl.ACLMessage;
027 import junit.framework.Test;
028 import junit.framework.TestCase;
029 import junit.framework.TestSuite;
030
031 /**
032 * unit testing test
033 * @author David Bernstein, <a href="http://www.caboodlenetworks.com"
034 * >Caboodle Networks, Inc.</a>
035 */
036 public class UnitTestBehaviourTest extends TestCase {
037
038 /** non-null JademxAgent to use */
039 private JademxAgent jademxAgent = new JademxAgent();
040 /** non-null ACL message to use */
041 private ACLMessage aclMessage = new ACLMessage( ACLMessage.INFORM );
042 /** non-null duration to use */
043 private Duration duration = new Duration("PT1M");
044 /** non-null properties to use */
045 private Properties properties = new Properties();
046
047 /**
048 * test for expected exception when passing null JademxAgent to constructor
049 */
050 public void testNullJademxAgent() {
051 try {
052 new UnitTestBehaviour( null, aclMessage, aclMessage, duration, properties);
053 fail("failed to catch null JademxAgent passed to UnitTestBehaviour constructor");
054 }
055 catch ( IllegalArgumentException iae ) {
056 assertTrue(true);
057 }
058 }
059
060 /**
061 * test for expected exception when passing null expected message to constructor
062 */
063 public void testNullExpectedMessage() {
064 try {
065 new UnitTestBehaviour( jademxAgent, null, aclMessage, duration, properties);
066 fail("failed to catch null expected message passed to UnitTestBehaviour constructor");
067 }
068 catch ( IllegalArgumentException iae ) {
069 assertTrue(true);
070 }
071 }
072
073 /**
074 * test for expected exception when passing null inject message to constructor
075 */
076 public void testNullInjectMessage() {
077 try {
078 new UnitTestBehaviour( jademxAgent, aclMessage, null, duration, properties);
079 fail("failed to catch null inject message passed to UnitTestBehaviour constructor");
080 }
081 catch ( IllegalArgumentException iae ) {
082 assertTrue(true);
083 }
084 }
085
086 /**
087 * test for expected exception when passing null timeout to constructor
088 */
089 public void testNullTimeout() {
090 try {
091 new UnitTestBehaviour( jademxAgent, aclMessage, aclMessage, null, properties);
092 fail("failed to catch null timeout passed to UnitTestBehaviour constructor");
093 }
094 catch ( IllegalArgumentException iae ) {
095 assertTrue(true);
096 }
097 }
098
099 /**
100 * test for expected exception when passing null variable properties to constructor
101 */
102 public void testNullProperties() {
103 try {
104 new UnitTestBehaviour( jademxAgent, aclMessage, aclMessage, duration, null);
105 fail("failed to catch null properties passed to UnitTestBehaviour constructor");
106 }
107 catch ( IllegalArgumentException iae ) {
108 assertTrue(true);
109 }
110 }
111
112
113 // suite
114
115 /**
116 * return the implicit suite of tests
117 * @return the implicit suite of tests
118 */
119 public static Test suite() {
120 return new TestSuite(
121 UnitTestBehaviourTest.class,
122 JadeMXSuiteTest.nameWithClass( UnitTestBehaviourTest.class,
123 "testing UnitTestBehaviour") );
124 }
125
126 }