View Javadoc
1 /*** 2 * Redistribution and use of this software and associated documentation 3 * ("Software"), with or without modification, are permitted provided 4 * that the following conditions are met: 5 * 6 * 1. Redistributions of source code must retain copyright 7 * statements and notices. Redistributions must also contain a 8 * copy of this document. 9 * 10 * 2. Redistributions in binary form must reproduce the 11 * above copyright notice, this list of conditions and the 12 * following disclaimer in the documentation and/or other 13 * materials provided with the distribution. 14 * 15 * 3. The name "Exolab" must not be used to endorse or promote 16 * products derived from this Software without prior written 17 * permission of Exoffice Technologies. For written permission, 18 * please contact tma@netspace.net.au. 19 * 20 * 4. Products derived from this Software may not be called "Exolab" 21 * nor may "Exolab" appear in their names without prior written 22 * permission of Exoffice Technologies. Exolab is a registered 23 * trademark of Exoffice Technologies. 24 * 25 * 5. Due credit should be given to the Exolab Project 26 * (http://www.exolab.org/). 27 * 28 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS 29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 32 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 39 * OF THE POSSIBILITY OF SUCH DAMAGE. 40 * 41 * Copyright 2001-2004 (C) Exoffice Technologies Inc. All Rights Reserved. 42 * 43 * $Id: BetweenOperatorTest.java,v 1.5 2004/02/03 21:52:11 tanderson Exp $ 44 */ 45 package org.exolab.jmscts.test.selector; 46 47 import java.util.HashMap; 48 49 import junit.framework.Test; 50 51 import org.exolab.jmscts.core.TestCreator; 52 53 54 /*** 55 * This class tests selector containing the BETWEEN operator. 56 * 57 * @author <a href="mailto:tma@netspace.net.au">Tim Anderson</a> 58 * @version $Revision: 1.5 $ 59 * @see AbstractSelectorTestCase 60 * @jmscts.message BytesMessage 61 */ 62 public class BetweenOperatorTest extends AbstractSelectorTestCase { 63 64 /*** 65 * Message properties 66 */ 67 private static final HashMap PROPERTIES = new HashMap(); 68 69 70 /*** 71 * Create an instance of this class for a specific test case 72 * 73 * @param name the name of test case 74 */ 75 public BetweenOperatorTest(String name) { 76 super(name); 77 } 78 79 /*** 80 * Sets up the test suite 81 * 82 * @return an instance of this class that may be run by 83 * {@link org.exolab.jmscts.core.JMSTestRunner} 84 */ 85 public static Test suite() { 86 return TestCreator.createSendReceiveTest(BetweenOperatorTest.class); 87 } 88 89 /*** 90 * Verifies that the selector <code>17 between 16 and 18</code> selects 91 * all messages 92 * 93 * @jmscts.requirement selector.operator.between 94 * @jmscts.requirement selector.expression 95 * @throws Exception for any error 96 */ 97 public void testBetween1() throws Exception { 98 checkSelector("17 between 16 and 18", true); 99 } 100 101 /*** 102 * Verifies that the selector <code>17 between 18 and 19</code> selects 103 * no messages 104 * 105 * @jmscts.requirement selector.operator.between 106 * @jmscts.requirement selector.expression 107 * @throws Exception for any error 108 */ 109 public void testBetween2() throws Exception { 110 checkSelector("17 between 18 and 19", false); 111 } 112 113 /*** 114 * Verifies that the selector <code>17 Between 17 And 17</code> selects 115 * all messages 116 * 117 * @jmscts.requirement selector.operator.between 118 * @jmscts.requirement selector.expression 119 * @jmscts.requirement selector.reservedwords.case 120 * @throws Exception for any error 121 */ 122 public void testBetween3() throws Exception { 123 checkSelector("17 Between 17 And 17", true); 124 } 125 126 /*** 127 * Verifies that the selector <code>17 between 4 * 4 and 10 + 8</code> 128 * selects all messages 129 * 130 * @jmscts.requirement selector.operator.between 131 * @jmscts.requirement selector.expression 132 * @throws Exception for any error 133 */ 134 public void testBetween4() throws Exception { 135 checkSelector("17 between 4 * 4 and 10 + 8", true); 136 } 137 138 /*** 139 * Verifies that the selector <code>17 between 4 * 5 and 10 + 12</code> 140 * selects no messages 141 * 142 * @jmscts.requirement selector.operator.between 143 * @jmscts.requirement selector.expression 144 * @throws Exception for any error 145 */ 146 public void testBetween5() throws Exception { 147 checkSelector("17 between 4 * 5 and 10 + 12", false); 148 } 149 150 /*** 151 * Verifies that the selector <code>two between one and three</code> 152 * selects all messages, where one, two and three are integer properties 153 * with with corresponding values 154 * 155 * @jmscts.requirement selector.operator.between 156 * @jmscts.requirement selector.expression 157 * @throws Exception for any error 158 */ 159 public void testBetween6() throws Exception { 160 checkSelector("two between one and three", true, PROPERTIES); 161 } 162 163 /*** 164 * Verifies that the selector <code>17 not between 18 and 19</code> selects 165 * all messages 166 * 167 * @jmscts.requirement selector.operator.between 168 * @jmscts.requirement selector.expression 169 * @throws Exception for any error 170 */ 171 public void testNotBetween1() throws Exception { 172 checkSelector("17 not between 18 and 19", true); 173 } 174 175 /*** 176 * Verifies that the selector <code>17 not between 16 and 18</code> selects 177 * no messages 178 * 179 * @jmscts.requirement selector.operator.between 180 * @jmscts.requirement selector.expression 181 * @throws Exception for any error 182 */ 183 public void testNotBetween2() throws Exception { 184 checkSelector("17 not between 16 and 18", false); 185 } 186 187 /*** 188 * Verifies that the selector <code>17 not between 17 and 17</code> selects 189 * no messages 190 * 191 * @jmscts.requirement selector.operator.between 192 * @jmscts.requirement selector.expression 193 * @throws Exception for any error 194 */ 195 public void testNotBetween3() throws Exception { 196 checkSelector("17 NOT between 17 and 17", false); 197 } 198 199 /*** 200 * Verifies that the selector <code>17 Not Between 4 * 5 And 20 / 1</code> 201 * selects all messages 202 * 203 * @jmscts.requirement selector.operator.between 204 * @jmscts.requirement selector.expression 205 * @jmscts.requirement selector.reservedwords.case 206 * @throws Exception for any error 207 */ 208 public void testNotBetween4() throws Exception { 209 checkSelector("17 Not Between 4 * 5 And 20 / 1", true); 210 } 211 212 /*** 213 * Verifies that the selector <code>two not between one and three</code> 214 * selects all messages, where one, two and three are integer properties 215 * with with corresponding values 216 * 217 * @jmscts.requirement selector.operator.between 218 * @jmscts.requirement selector.expression 219 * @throws Exception for any error 220 */ 221 public void testNotBetween5() throws Exception { 222 checkSelector("two not between one and three", false, PROPERTIES); 223 } 224 225 /*** 226 * Verifies that the selector <code>dummy between 1 and 10</code> selects 227 * no messages, for the unset property 'dummy' 228 * 229 * @jmscts.requirement selector.operator.between 230 * @jmscts.requirement selector.expression 231 * @jmscts.requirement selector.values.null 232 * @throws Exception for any error 233 */ 234 public void testUnsetProperty1() throws Exception { 235 checkSelector("dummy between 1 and 10", false); 236 } 237 238 /*** 239 * Verifies that the selector <code>1 between dummy and 10</code> selects 240 * no messages, for the unset property 'dummy' 241 * 242 * @jmscts.requirement selector.operator.between 243 * @jmscts.requirement selector.expression 244 * @jmscts.requirement selector.values.null 245 * @throws Exception for any error 246 */ 247 public void testUnsetProperty2() throws Exception { 248 checkSelector("1 between dummy and 10", false); 249 } 250 251 /*** 252 * Verifies that the selector <code>1 between 0 and dummy</code> selects 253 * no messages, for the unset property 'dummy' 254 * 255 * @jmscts.requirement selector.operator.between 256 * @jmscts.requirement selector.expression 257 * @jmscts.requirement selector.values.null 258 * @throws Exception for any error 259 */ 260 public void testUnsetProperty3() throws Exception { 261 checkSelector("1 between 0 and dummy", false); 262 } 263 264 /*** 265 * Verifies that the selector <code>two between '1' and '3'</code> 266 * throws InvalidSelectorException 267 * 268 * @jmscts.requirement selector.validation 269 * @throws Exception for any error 270 */ 271 public void testInvalid1() throws Exception { 272 checkInvalidSelector("two between '1' and '3'"); 273 } 274 275 /*** 276 * Verifies that the selector <code>one between false and true</code> 277 * throws InvalidSelectorException 278 * 279 * @jmscts.requirement selector.validation 280 * @throws Exception for any error 281 */ 282 public void testInvalid2() throws Exception { 283 checkInvalidSelector("one between false and true"); 284 } 285 286 /*** 287 * Verifies that the selector <code>b' between 'a' and 'c'</code> 288 * throws InvalidSelectorException 289 * 290 * @jmscts.requirement selector.validation 291 * @throws Exception for any error 292 */ 293 public void testInvalid3() throws Exception { 294 checkInvalidSelector("'b' between 'a' and 'c'"); 295 } 296 297 /*** 298 * Verifies that the selector <code>between 1 and 3</code> 299 * throws InvalidSelectorException 300 * 301 * @jmscts.requirement selector.validation 302 * @throws Exception for any error 303 */ 304 public void testInvalid4() throws Exception { 305 checkInvalidSelector("between 1 and 3"); 306 } 307 308 /*** 309 * Verifies that the selector <code>not between 1 and 3</code> 310 * throws InvalidSelectorException 311 * 312 * @jmscts.requirement selector.validation 313 * @throws Exception for any error 314 */ 315 public void testInvalid5() throws Exception { 316 checkInvalidSelector("not between 1 and 3"); 317 } 318 319 /*** 320 * Verifies that the selector <code>2 between 1, 3</code> 321 * throws InvalidSelectorException 322 * 323 * @jmscts.requirement selector.validation 324 * @throws Exception for any error 325 */ 326 public void testInvalid6() throws Exception { 327 checkInvalidSelector("2 between 1, 3"); 328 } 329 330 /*** 331 * Verifies that the selector <code>2 between 1 and</code> 332 * throws InvalidSelectorException 333 * 334 * @jmscts.requirement selector.validation 335 * @throws Exception for any error 336 */ 337 public void testInvalid7() throws Exception { 338 checkInvalidSelector("2 between 1 and"); 339 } 340 341 /*** 342 * Verifies that the selector <code>2 between and 3</code> 343 * throws InvalidSelectorException 344 * 345 * @jmscts.requirement selector.validation 346 * @throws Exception for any error 347 */ 348 public void testInvalid8() throws Exception { 349 checkInvalidSelector("2 between and 3"); 350 } 351 352 /*** 353 * Verifies that the selector <code>JMSMessageID between 1 and 10</code> 354 * throws InvalidSelectorException 355 * 356 * @jmscts.requirement selector.validation 357 * @throws Exception for any error 358 */ 359 public void testInvalid9() throws Exception { 360 checkInvalidSelector("JMSMessageID between 1 and 10"); 361 } 362 363 static { 364 PROPERTIES.put("one", new Integer(1)); 365 PROPERTIES.put("two", new Integer(2)); 366 PROPERTIES.put("three", new Integer(3)); 367 } 368 369 }

This page was automatically generated by Maven