Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/objectweb/jtests/jms/conform/selector/SelectorSyntaxTest.java


1   /*
2    * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3    * Copyright (C) 2002 INRIA
4    * Contact: joram-team@objectweb.org
5    * 
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or any later version.
10   * 
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19   * USA
20   * 
21   * Initial developer(s): Jeff Mesnil (jmesnil@inrialpes.fr)
22   * Contributor(s): ______________________________________.
23   */
24  
25  package org.objectweb.jtests.jms.conform.selector;
26  
27  import org.objectweb.jtests.jms.framework.*;
28  import junit.framework.*;
29  import org.objectweb.jtests.jms.admin.*;
30  
31  import javax.jms.*;
32  import javax.naming.*;
33  
34  /**
35   * Test the syntax of of message selector of JMS
36   *
37   * @author Jeff Mesnil (jmesnil@inrialpes.fr)
38   * @version $Id: SelectorSyntaxTest.java,v 1.1 2002/04/21 21:15:19 chirino Exp $
39   */
40  public class SelectorSyntaxTest extends PTPTestCase {
41  
42      /**
43       * Test syntax of "<em>identifier</em> IS [NOT] NULL"
44       */
45      public void testNull() {
46          try {
47              receiver  = receiverSession.createReceiver(receiverQueue, "prop_name IS NULL");
48              receiver  = receiverSession.createReceiver(receiverQueue, "prop_name IS NOT NULL");
49          } catch (JMSException e) {
50              fail(e);
51          }
52      }
53    
54      /**
55       * Test syntax of "<em>identifier</em> [NOT] LIKE <em>pattern-value</em> [ESCAPE <em>escape-character</em>]"
56       */
57      public void testLike() {
58          try {
59              receiver  = receiverSession.createReceiver(receiverQueue, "phone LIKE '12%3'");
60              receiver  = receiverSession.createReceiver(receiverQueue, "word LIKE 'l_se'");
61              receiver  = receiverSession.createReceiver(receiverQueue, "underscored LIKE '\\_%' ESCAPE '\\'");
62              receiver  = receiverSession.createReceiver(receiverQueue, "phone NOT LIKE '12%3'");
63          } catch (JMSException e) {
64              fail(e);
65          }
66      }
67  
68      /**
69       * Test syntax of "<em>identifier</em> [NOT] IN (<em>string-literal1</em>, <em>string-literal2</em>,...)"
70       */
71      public void testIn() {
72          try {
73              receiver  = receiverSession.createReceiver(receiverQueue, "Country IN ('UK', 'US', 'France')");
74              receiver  = receiverSession.createReceiver(receiverQueue, "Country NOT IN ('UK', 'US', 'France')");
75          } catch (JMSException e) {
76              fail(e);
77          }
78      }
79    
80      /**
81       * Test syntax of "<em>arithmetic-expr1</em> [NOT] BETWEEN <em>arithmetic-expr2</em> and <em>arithmetic-expr3</em>"
82       */
83      public void testBetween() {
84          try {
85              receiver  = receiverSession.createReceiver(receiverQueue, "age BETWEEN 15 and 19");
86              receiver  = receiverSession.createReceiver(receiverQueue, "age NOT BETWEEN 15 and 19");
87          } catch (JMSException e) {
88              fail(e);
89          }
90      }
91    
92      /**
93       * Test diffent syntax for approximate numeric literal (+6.2, -95.7, 7.)
94       */
95      public void testApproximateNumericLiteral() {
96          try {
97              receiver  = receiverSession.createReceiver(receiverQueue, "average = +6.2");
98              receiver  = receiverSession.createReceiver(receiverQueue, "average = -95.7");
99              receiver  = receiverSession.createReceiver(receiverQueue, "average = 7.");
100         } catch (JMSException e) {
101             fail(e);
102         }
103     }
104 
105     /**
106      * Test diffent syntax for exact numeric literal (+62, -957, 57)
107      */
108     public void testExactNumericLiteral() {
109         try {
110             receiver  = receiverSession.createReceiver(receiverQueue, "average = +62");
111             receiver  = receiverSession.createReceiver(receiverQueue, "max = -957");
112             receiver  = receiverSession.createReceiver(receiverQueue, "max = 57");
113         } catch (JMSException e) {
114             fail(e);
115         }
116     }
117 
118     /**
119      * Test diffent syntax for zero as an exact or an approximate numeric literal (0, 0.0, 0.)
120      */
121     public void testZero() {
122         try {
123             receiver  = receiverSession.createReceiver(receiverQueue, "max = 0");
124             receiver  = receiverSession.createReceiver(receiverQueue, "max = 0.0");
125             receiver  = receiverSession.createReceiver(receiverQueue, "max = 0.");
126         } catch (JMSException e) {
127             fail(e);
128         }
129     }
130 
131     /**
132      * Test diffent syntax for string literal ('literal' and 'literal''s')
133      */
134     public void testString() {
135         try {
136             receiver  = receiverSession.createReceiver(receiverQueue, "string = 'literal'");
137             receiver  = receiverSession.createReceiver(receiverQueue, "string = 'literal''s'");
138         } catch (JMSException e) {
139             fail(e);
140         }
141     }
142     
143     /** 
144      * Method to use this class in a Test suite
145      */
146     public static Test suite() {
147         return new TestSuite(SelectorSyntaxTest.class);
148     }
149     
150     public SelectorSyntaxTest(String name) {
151         super(name);
152     }
153 }