001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.filter.v1_0;
017:
018: import org.w3c.dom.Document;
019: import org.opengis.filter.expression.Add;
020: import org.opengis.filter.expression.BinaryExpression;
021: import org.opengis.filter.expression.Divide;
022: import org.opengis.filter.expression.Multiply;
023: import org.opengis.filter.expression.Subtract;
024:
025: public class BinaryOperatorTypeBindingTest extends FilterTestSupport {
026: public void testBinaryOperatorType() {
027: assertEquals(BinaryExpression.class, binding(
028: OGC.BinaryOperatorType).getType());
029: }
030:
031: public void testAddType() {
032: assertEquals(Add.class, binding(OGC.Add).getType());
033: }
034:
035: public void testAddParse() throws Exception {
036: FilterMockData.add(document, document);
037:
038: Add add = (Add) parse();
039:
040: assertNotNull(add.getExpression1());
041: assertNotNull(add.getExpression2());
042: }
043:
044: public void testAddEncode() throws Exception {
045: Document dom = encode(FilterMockData.add(), OGC.Add);
046:
047: assertEquals(2, dom.getElementsByTagNameNS(OGC.NAMESPACE,
048: OGC.Literal.getLocalPart()).getLength());
049: }
050:
051: public void testSubType() {
052: assertEquals(Subtract.class, binding(OGC.Sub).getType());
053: }
054:
055: public void testSubParse() throws Exception {
056: FilterMockData.sub(document, document);
057:
058: Subtract sub = (Subtract) parse();
059:
060: assertNotNull(sub.getExpression1());
061: assertNotNull(sub.getExpression2());
062: }
063:
064: public void testSubEncode() throws Exception {
065: Document dom = encode(FilterMockData.sub(), OGC.Sub);
066: assertEquals(2, dom.getElementsByTagNameNS(OGC.NAMESPACE,
067: OGC.Literal.getLocalPart()).getLength());
068: }
069:
070: public void testDivType() {
071: assertEquals(Divide.class, binding(OGC.Div).getType());
072: }
073:
074: public void testDivParse() throws Exception {
075: FilterMockData.div(document, document);
076:
077: Divide div = (Divide) parse();
078:
079: assertNotNull(div.getExpression1());
080: assertNotNull(div.getExpression2());
081: }
082:
083: public void testDivEncode() throws Exception {
084: Document dom = encode(FilterMockData.div(), OGC.Div);
085: assertEquals(2, dom.getElementsByTagNameNS(OGC.NAMESPACE,
086: OGC.Literal.getLocalPart()).getLength());
087: }
088:
089: public void testMulType() {
090: assertEquals(Multiply.class, binding(OGC.Mul).getType());
091: }
092:
093: public void testMulParse() throws Exception {
094: FilterMockData.mul(document, document);
095:
096: Multiply mul = (Multiply) parse();
097:
098: assertNotNull(mul.getExpression1());
099: assertNotNull(mul.getExpression2());
100: }
101:
102: public void testMulEncode() throws Exception {
103: Document dom = encode(FilterMockData.mul(), OGC.Mul);
104: assertEquals(2, dom.getElementsByTagNameNS(OGC.NAMESPACE,
105: OGC.Literal.getLocalPart()).getLength());
106: }
107: }
|