PageRenderTime 33ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/bundles/plugins-trunk/XML/test/xml/parser/XSDSchemaToCompletionTest.java

#
Java | 84 lines | 52 code | 14 blank | 18 comment | 0 complexity | 30bf63dc8fe8c4f947e6710681e9ddfe MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * XSDNGCompletionTest.java
  3. * :folding=explicit:collapseFolds=1:
  4. *
  5. * Copyright (C) 2011 Eric Le Lay
  6. *
  7. * The XML plugin is licensed under the GNU General Public License, with
  8. * the following exception:
  9. *
  10. * "Permission is granted to link this code with software released under
  11. * the Apache license version 1.1, for example used by the Xerces XML
  12. * parser package."
  13. */
  14. package xml.parser;
  15. // {{{ jUnit imports
  16. import java.util.concurrent.TimeUnit;
  17. import org.junit.*;
  18. import static org.junit.Assert.*;
  19. import org.fest.swing.fixture.*;
  20. import org.fest.swing.core.*;
  21. import org.fest.swing.finder.*;
  22. import org.fest.swing.edt.*;
  23. import org.fest.swing.timing.*;
  24. import static org.fest.assertions.Assertions.*;
  25. import org.gjt.sp.jedit.testframework.Log;
  26. import org.gjt.sp.jedit.testframework.TestUtils;
  27. import static xml.XMLTestUtils.*;
  28. // }}}
  29. import java.io.*;
  30. import java.net.*;
  31. import java.util.*;
  32. import xml.completion.*;
  33. import xml.completion.ElementDecl.AttributeDecl;
  34. import xml.Resolver;
  35. import org.gjt.sp.jedit.jEdit;
  36. /**
  37. * $Id$
  38. */
  39. public class XSDSchemaToCompletionTest{
  40. private static File testData;
  41. @BeforeClass
  42. public static void setUpjEdit() throws IOException{
  43. TestUtils.beforeClass();
  44. testData = new File(System.getProperty("test_data")).getCanonicalFile();
  45. assertTrue(testData.exists());
  46. }
  47. @AfterClass
  48. public static void tearDownjEdit() {
  49. TestUtils.afterClass();
  50. }
  51. @Test
  52. public void testNant() throws IOException, org.xml.sax.SAXException {
  53. File f = new File(testData,"nant/mini-nant.xsd");
  54. Map<String,CompletionInfo> schemas =
  55. XSDSchemaToCompletion.getCompletionInfoFromSchema(f.getPath()
  56. , null
  57. , null
  58. , null
  59. , TestUtils.view().getBuffer());
  60. assertEquals(1,schemas.size());
  61. assertTrue(schemas.containsKey("http://nant.sf.net/release/0.85/nant.xsd"));
  62. CompletionInfo info = schemas.get("http://nant.sf.net/release/0.85/nant.xsd");
  63. assertEquals(1,info.elementHash.size()); // only project is top level
  64. assertThat(info.elementHash.keySet()).containsOnly("project");
  65. ElementDecl prj = info.elementHash.get("project");
  66. assertThat(prj.content).containsOnly("if");
  67. ElementDecl ifd = prj.elementHash.get("if");
  68. assertSame(ifd, ifd.elementHash.get("if"));
  69. }
  70. }