1 19 package org.enhydra.zeus; 20 21 import junit.framework.Test; 22 import junit.framework.TestCase; 23 import junit.framework.TestSuite; 24 25 import org.enhydra.zeus.InvalidCollectionTypeException; 27 28 42 public abstract class AbstractBindingTest extends TestCase { 43 44 52 public abstract Binding createBinding(); 53 54 61 public AbstractBindingTest(String name) { 62 super(name); 63 } 64 65 74 public static Test suite() { 75 return new TestSuite(AbstractBindingTest.class); 76 } 77 78 83 public void testGetXMLName() { 84 Binding binding = createBinding(); 85 String expected = "my_xml_name"; 86 87 binding.setXMLName(expected); 88 assertEquals(expected, binding.getXMLName()); 89 } 90 91 96 public void testSetXMLName() { 97 Binding binding = createBinding(); 98 String expected1 = "my_xml_name_1"; 99 String expected2 = "my_xml_name_2"; 100 101 binding.setXMLName(expected1); 102 assertEquals(expected1, binding.getXMLName()); 103 binding.setXMLName(expected2); 104 assertEquals(expected2, binding.getXMLName()); 105 } 106 107 112 public void testGetXMLNamespaceURI() { 113 Binding binding = createBinding(); 114 String expected = "http://www.namespace.com"; 115 116 binding.setXMLNamespaceURI(expected); 117 assertEquals(expected, binding.getXMLNamespaceURI()); 118 } 119 120 125 public void testSetXMLNamespaceURI() { 126 Binding binding = createBinding(); 127 String expected1 = "http://www.namespace1.com"; 128 String expected2 = "http://www.namespace2.com"; 129 130 binding.setXMLNamespaceURI(expected1); 131 assertEquals(expected1, binding.getXMLNamespaceURI()); 132 binding.setXMLNamespaceURI(expected2); 133 assertEquals(expected2, binding.getXMLNamespaceURI()); 134 } 135 136 141 public void testGetXMLType() { 142 Binding binding = createBinding(); 143 String expected = "my_xml_type"; 144 145 binding.setXMLType(expected); 146 assertEquals(expected, binding.getXMLType()); 147 } 148 149 154 public void testSetXMLType() { 155 Binding binding = createBinding(); 156 String expected1 = "my_xml_type_1"; 157 String expected2 = "my_xml_type_2"; 158 159 binding.setXMLType(expected1); 160 assertEquals(expected1, binding.getXMLType()); 161 binding.setXMLType(expected2); 162 assertEquals(expected2, binding.getXMLType()); 163 } 164 165 170 public void testGetXMLTypeNamespaceURI() { 171 Binding binding = createBinding(); 172 String expected = "http://www.typeNamespace.com"; 173 174 binding.setXMLTypeNamespaceURI(expected); 175 assertEquals(expected, binding.getXMLTypeNamespaceURI()); 176 } 177 178 183 public void testSetXMLTypeNamespaceURI() { 184 Binding binding = createBinding(); 185 String expected1 = "http://www.typeNamespace1.com"; 186 String expected2 = "http://www.typeNamespace2.com"; 187 188 binding.setXMLTypeNamespaceURI(expected1); 189 assertEquals(expected1, binding.getXMLTypeNamespaceURI()); 190 binding.setXMLTypeNamespaceURI(expected2); 191 assertEquals(expected2, binding.getXMLTypeNamespaceURI()); 192 } 193 194 199 public void testGetJavaName() { 200 Binding binding = createBinding(); 201 String expected = "myJavaName"; 202 203 binding.setJavaName(expected); 204 assertEquals(expected, binding.getJavaName()); 205 } 206 207 212 public void testSetJavaName() { 213 Binding binding = createBinding(); 214 String expected1 = "myJavaName1"; 215 String expected2 = "myJavaName2"; 216 217 binding.setJavaName(expected1); 218 assertEquals(expected1, binding.getJavaName()); 219 binding.setJavaName(expected2); 220 assertEquals(expected2, binding.getJavaName()); 221 } 222 223 228 public void testGetJavaVariableName() { 229 Binding binding = createBinding(); 230 String expected = "myJavaVariableName"; 231 232 binding.setJavaVariableName(expected); 233 assertEquals(expected, binding.getJavaVariableName()); 234 } 235 236 241 public void testSetJavaVariableName() { 242 Binding binding = createBinding(); 243 String expected1 = "myJavaVariableName1"; 244 String expected2 = "myJavaVariableName2"; 245 246 binding.setJavaVariableName(expected1); 247 assertEquals(expected1, binding.getJavaVariableName()); 248 binding.setJavaVariableName(expected2); 249 assertEquals(expected2, binding.getJavaVariableName()); 250 } 251 252 257 public void testGetJavaType() { 258 Binding binding = createBinding(); 259 String expected = "MyType"; 260 261 binding.setJavaType(expected); 262 assertEquals(expected, binding.getJavaType()); 263 } 264 265 270 public void testSetJavaType() { 271 Binding binding = createBinding(); 272 String expected1 = "MyType1"; 273 String expected2 = "MyType2"; 274 275 binding.setJavaType(expected1); 276 assertEquals(expected1, binding.getJavaType()); 277 binding.setJavaType(expected2); 278 assertEquals(expected2, binding.getJavaType()); 279 } 280 281 286 public void testGetJavaInterfacePackage() { 287 Binding binding = createBinding(); 288 String expected = "org.my.interface.package"; 289 290 binding.setJavaInterfacePackage(expected); 291 assertEquals(expected, binding.getJavaInterfacePackage()); 292 } 293 294 299 public void testSetJavaInterfacePackage() { 300 Binding binding = createBinding(); 301 String expected1 = "org.my.interface.package1"; 302 String expected2 = "org.my.interface.package2"; 303 304 binding.setJavaInterfacePackage(expected1); 305 assertEquals(expected1, binding.getJavaInterfacePackage()); 306 binding.setJavaInterfacePackage(expected2); 307 assertEquals(expected2, binding.getJavaInterfacePackage()); 308 } 309 310 315 public void testGetJavaImplementationPackage() { 316 Binding binding = createBinding(); 317 String expected = "org.my.implementation.package"; 318 319 binding.setJavaImplementationPackage(expected); 320 assertEquals(expected, binding.getJavaImplementationPackage()); 321 } 322 323 328 public void testSetJavaImplementationPackage() { 329 Binding binding = createBinding(); 330 String expected1 = "org.my.implementation.package1"; 331 String expected2 = "org.my.implementation.package2"; 332 333 binding.setJavaImplementationPackage(expected1); 334 assertEquals(expected1, binding.getJavaImplementationPackage()); 335 binding.setJavaImplementationPackage(expected2); 336 assertEquals(expected2, binding.getJavaImplementationPackage()); 337 } 338 339 344 public void testGetJavaCollectionClass() { 345 Binding binding = createBinding(); 346 String expected = "java.util.List"; 347 348 try { 349 binding.setJavaCollectionClass(expected); 350 assertEquals(expected, binding.getJavaCollectionClass()); 351 } catch (InvalidCollectionTypeException e) { 352 assertTrue(false); 354 } 355 } 356 357 362 public void testSetJavaCollectionClass() { 363 Binding binding = createBinding(); 364 String collection1 = "java.util.List"; 365 String collection2 = "java.util.ArrayList"; 366 boolean success = true; 367 368 try { 369 binding.setJavaCollectionClass(collection1); 370 binding.setJavaCollectionClass(collection2); 371 } catch (InvalidCollectionTypeException e) { 372 success = false; 374 } 375 376 assertTrue(success); 377 } 378 379 386 public void testSetJavaCollectionClassNegative() { 387 Binding binding = createBinding(); 388 String expected = "java.lang.String"; 389 boolean caught = false; 390 391 try { 392 binding.setJavaCollectionClass(expected); 393 assertEquals(expected, binding.getJavaCollectionClass()); 394 } catch (InvalidCollectionTypeException e) { 395 caught = true; 397 } finally { 398 assertTrue(caught); 399 } 400 } 401 402 407 public void testIsJavaSerializable() { 408 Binding binding = createBinding(); 409 boolean expected = true; 410 411 binding.setIsJavaSerializable(expected); 412 assertEquals(expected, binding.isJavaSerializable()); 413 } 414 415 420 public void testSetIsJavaSerializable() { 421 Binding binding = createBinding(); 422 boolean expected1 = true; 423 boolean expected2 = false; 424 425 binding.setIsJavaSerializable(expected1); 426 assertEquals(expected1, binding.isJavaSerializable()); 427 binding.setIsJavaSerializable(expected2); 428 assertEquals(expected2, binding.isJavaSerializable()); 429 } 430 } 431 432 | Popular Tags |