KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > NodeManagerTest


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10
11 package org.mmbase.bridge;
12
13 import org.mmbase.tests.*;
14
15 /**
16  * Test class <code>NodeManager</code> from the bridge package.
17  *
18  * @author Jaco de Groot
19  * @author Kees Jongenburger
20  */

21 public class NodeManagerTest extends BridgeTest {
22     Cloud cloud;
23     NodeList nodes;
24     int nrOfTestNodes;
25     public final static String JavaDoc TEST_STRING_VALUE = "C05353E04zz HAVO, Cultuur/Maatschappij, Z'zee, 04-05";
26
27     public NodeManagerTest(String JavaDoc name) {
28         super(name);
29     }
30
31     public void setUp() {
32         // Create some test nodes
33
cloud = getCloud();
34         nodes = cloud.createNodeList();
35         Node node = cloud.getNodeManager("aa").createNode();
36         node.setByteValue("bytefield", "100".getBytes());
37         node.setDoubleValue("doublefield", 200);
38         node.setFloatValue("floatfield", 300);
39         node.setIntValue("intfield", 400);
40         node.setLongValue("longfield", 500);
41         node.setStringValue("stringfield", "600");
42         node.commit();
43         nodes.add(node);
44
45         node = cloud.getNodeManager("aa").createNode();
46         node.setByteValue("bytefield", "100".getBytes());
47         node.setDoubleValue("doublefield", 200);
48         node.setFloatValue("floatfield", 300);
49         node.setIntValue("intfield", 400);
50         node.setLongValue("longfield", 500);
51         node.setStringValue("stringfield", TEST_STRING_VALUE );
52         node.commit();
53
54         nodes.add(node);
55
56     }
57
58     public void tearDown() {
59         // Remove test node.
60

61         for (NodeIterator i = nodes.nodeIterator() ; i.hasNext() ; ){
62             i.nextNode().delete();
63         }
64     }
65
66     public void testGetList() {
67         NodeManager nodeManager = cloud.getNodeManager("aa");
68         NodeList nodeList;
69         nodeList = nodeManager.getList(null, null, null);
70         assertTrue(nodeList.size() == nodes.size());
71         nodeList = nodeManager.getList("", "", "");
72         assertTrue(nodeList.size() == nodes.size());
73     }
74     
75     /**
76      * Test if it is possible to search for a node that contains single quotes
77      */

78     public void testGetListWithQuotes() {
79         NodeManager nodeManager = cloud.getNodeManager("aa");
80         NodeList nodeList = nodeManager.getList("stringfield ='"+ org.mmbase.util.Encode.encode("ESCAPE_SINGLE_QUOTE", TEST_STRING_VALUE) + "'", "", "");
81         assertTrue("Size of result list with constraint on string field is not 1 but " + nodeList.size() + " : " + nodeList, nodeList.size() == 1);
82     }
83     // Add some more list test.
84

85     // Add some tests with wrong formatted parameters.
86

87 }
88
Popular Tags