/eclipse-dtp-1.10/org.eclipse.datatools.enablement.oda-DTP_1_10_0_Release_201206131012/tests/org.eclipse.datatools.enablement.oda.xml.tests/test/org/eclipse/datatools/enablement/oda/xml/RelationInformationTest.java

# · Java · 72 lines · 47 code · 9 blank · 16 comment · 0 complexity · 335706e9adf297fd4bea72c8d344e62b MD5 · raw file

  1. /*******************************************************************************
  2. * Copyright (c) 2004, 2005 Actuate Corporation.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Actuate Corporation - initial API and implementation
  10. *******************************************************************************/
  11. package org.eclipse.datatools.enablement.oda.xml;
  12. import org.eclipse.datatools.enablement.oda.xml.util.RelationInformation;
  13. /**
  14. *
  15. */
  16. public class RelationInformationTest extends BaseTest
  17. {
  18. private String testString = "person#:#[/personnel/person/name]#:#{name.family;String;/family},{name.given;String;/given},{email;String;../email},{link.subordinates;String;../link/@subordinates}"+
  19. "#-#name#:#[//name]#:#{family;String;/family},{given;String;/given}"+
  20. "#-#def#:#[//name]#:#{col1;String;../../../@stage},{col2;String;../../B/@stage}"+
  21. "#-#abc#:#[//abcd/ok/../def/gh]#:#{column1;String;../../abc/../abc/../abc},{column2;String;abc/../../../abc},{column3;String;abc/def/ghi/../abc},{column4;String;../../../../../ab}"+
  22. "#-#nested#:#[//*/def]#:#{column1;String;@attr1},{column2;String;../ghi/@attr2},{column3;String;../@attr3},{column4;String;../jkl/@attr5},{column5;String;../../@attr6}"+
  23. "#-#nested2#:#[//book]#:#{column1;String;@attr1},{column2;String;../@attr2}"+
  24. "#-#table1#:#[/root/country]#:#{name;String;/city[@iscapital='y']/@name}"+
  25. "#-#table2#:#[/root/country]#:#{name;String;/city[2]/@name}"+
  26. "#-#table3#:#[/root/country]#:#{name;String;/city[2][@iscapital='y']/@name}"+
  27. "#-#table4#:#[/root/country/city]#:#{name;String;[@iscapital='y']/@name}";
  28. private RelationInformation ri1;
  29. protected void setUp( ) throws Exception
  30. {
  31. super.setUp( );
  32. this.ri1= new RelationInformation(testString);
  33. }
  34. protected void tearDown( ) throws Exception
  35. {
  36. super.tearDown( );
  37. }
  38. /*
  39. * Test method for 'org.eclipse.datatools.enablement.oda.xml.RelationInformation.getTableColumnType(String, String)'
  40. */
  41. public void testGetTableColumnType( )
  42. {
  43. assertEquals(ri1.getTableColumnType("person","name.family"), "String");
  44. assertEquals(ri1.getTableColumnType("person","name.given"),"String");
  45. assertEquals(ri1.getTableColumnType("person","email"),"String");
  46. assertEquals(ri1.getTableColumnType("person","link.subordinates"),"String");
  47. assertEquals(ri1.getTableColumnType("name","family"),"String");
  48. assertEquals(ri1.getTableColumnType("name","given"),"String");
  49. assertEquals(ri1.getTableColumnType( "table1", "name" ),"String");
  50. assertEquals(ri1.getTableColumnType( "table2", "name" ),"String");
  51. assertEquals(ri1.getTableColumnType( "table3", "name" ),"String");
  52. assertEquals(ri1.getTableColumnType( "table4", "name" ),"String");
  53. }
  54. public void testGetTabelRootPath()
  55. {
  56. assertEquals(ri1.getTableRootPath("person"),"/personnel/person/name");
  57. assertEquals(ri1.getTableRootPath("name"),"//name");
  58. assertEquals(ri1.getTableRootPath("table1"),"/root/country");
  59. assertEquals(ri1.getTableRootPath("table2"),"/root/country");
  60. assertEquals(ri1.getTableRootPath("table3"),"/root/country");
  61. assertEquals(ri1.getTableRootPath("table4"),"/root/country/city");
  62. }
  63. }