1 10 11 package org.mmbase.bridge; 12 13 import org.mmbase.tests.*; 14 19 public class CloudTest extends BridgeTest { 20 Cloud cloud; 21 Node aaNode1; 22 Node aaNode2; 23 Node bbNode; 24 Node[] bbNodes; 25 int nrOfBBNodes; 26 27 public CloudTest(String name) { 28 super(name); 29 } 30 31 public void setUp() { 32 cloud = getCloud(); 34 aaNode1 = cloud.getNodeManager("aa").createNode(); 35 aaNode1.setStringValue("stringfield", "startnode1"); 36 aaNode1.commit(); 37 aaNode2 = cloud.getNodeManager("aa").createNode(); 38 aaNode2.setStringValue("stringfield", "startnode2"); 39 aaNode2.commit(); 40 bbNode = cloud.getNodeManager("bb").createNode(); 41 bbNode.setStringValue("stringfield", "bbNode"); 42 bbNode.commit(); 43 RelationManager relationManager; 44 relationManager = cloud.getRelationManager("aa", "bb", "related"); 45 Relation relation; 46 relation = relationManager.createRelation(aaNode2, bbNode); 47 relation.commit(); 48 bbNodes = new Node[11]; 49 nrOfBBNodes = 0; 50 for (int i = -5; i < 6; i++) { 51 String s = new Integer (i).toString(); 52 Node node; 53 node = cloud.getNodeManager("bb").createNode(); 54 node.setByteValue("bytefield", s.getBytes()); 55 node.setDoubleValue("doublefield", i); 56 node.setFloatValue("floatfield", i); 57 node.setIntValue("intfield", i); 58 node.setLongValue("longfield", i); 59 node.setStringValue("stringfield", s); 60 node.commit(); 61 bbNodes[nrOfBBNodes] = node; 62 relation = relationManager.createRelation(aaNode1, node); 63 relation.commit(); 64 nrOfBBNodes++; 65 } 66 } 67 68 public void tearDown() { 69 aaNode1.delete(true); 71 aaNode2.delete(true); 72 bbNode.delete(true); 73 for (int i = 0; i < nrOfBBNodes; i++) { 74 bbNodes[i].delete(true); 75 } 76 } 77 78 public void testGetList() { 79 NodeList nodeList; 80 nodeList = cloud.getList("" + aaNode1.getNumber(), "aa,bb", "aa.bytefield", "", "", "", "", false); 81 assertTrue(nodeList.size() == nrOfBBNodes); 82 } 83 84 public void testGetListWithNullParameters() { 85 try { 86 cloud.getList(null, null, null, null, null, null, null, false); 87 fail("Should raise a BridgeException"); 88 } catch (BridgeException e) {} 89 } 90 91 public void testGetListWithEmptyParameters() { 92 try { 93 cloud.getList("", "", "", "", "", "", "", false); 94 fail("Should raise a BridgeException"); 95 } catch (BridgeException e) {} 96 } 97 98 public void testGetListWithNullParameterStartNodes() { 99 NodeList nodeList; 100 nodeList = cloud.getList(null, "aa,bb", "aa.bytefield", "", "", "", "", false); 101 assertTrue(nodeList.size() == nrOfBBNodes + 1); 102 } 103 104 public void testGetListWithEmptyParameterStartNodes() { 105 NodeList nodeList; 106 nodeList = cloud.getList("", "aa,bb", "aa.bytefield", "", "", "", "", false); 107 assertTrue(nodeList.size() == nrOfBBNodes + 1); 108 } 109 110 121 122 public void testGetListWithNullParameterNodePath() { 123 try { 124 cloud.getList(null, null, "bytefield", "", "", "", "", false); 125 fail("Should raise a BridgeException"); 126 } catch (BridgeException e) {} 127 } 128 129 public void testGetListWithEmptyParameterNodePath() { 130 try { 131 cloud.getList(null, "", "bytefield", "", "", "", "", false); 132 fail("Should raise a BridgeException"); 133 } catch (BridgeException e) {} 134 } 135 136 public void testGetListWithInvalidParameterNodePath() { 137 try { 138 cloud.getList(null, "x", "bytefield", "", "", "", "", false); 139 fail("Should raise a BridgeException"); 140 } catch (BridgeException e) {} 141 } 142 143 154 155 165 166 public void testGetListWithInvalidParameterFields() { 167 try { 168 NodeList nodeList; 169 nodeList = cloud.getList(null, "aa,bb", "x", "", "", "", "", false); 170 fail("Should raise a BridgeException, but returned: " + nodeList); 171 } catch (BridgeException e) {} 172 } 173 174 public void testGetListWithConstraint() { 175 cloud.getList(null, "aa,bb,aa", "bb.number,bb.owner", "bb.owner ='test'", "bb.number", "UP", "destination", false ); 184 }; 185 186 public void testGetListWithConstraint2() { 187 cloud.getList(null, "aa,bb,aa", "bb.number,bb.owner", "bb.number <>1234", "bb.number", "UP", "destination", false ); 196 } 197 213 214 216 } 217 | Popular Tags |