PageRenderTime 97ms CodeModel.GetById 89ms app.highlight 6ms RepoModel.GetById 1ms 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
 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 */
14package xml.parser;
15
16// {{{ jUnit imports 
17import java.util.concurrent.TimeUnit;
18
19import org.junit.*;
20import static org.junit.Assert.*;
21
22import org.fest.swing.fixture.*;
23import org.fest.swing.core.*;
24import org.fest.swing.finder.*;
25import org.fest.swing.edt.*;
26import org.fest.swing.timing.*;
27
28import static org.fest.assertions.Assertions.*;
29
30import org.gjt.sp.jedit.testframework.Log;
31import org.gjt.sp.jedit.testframework.TestUtils;
32
33import static xml.XMLTestUtils.*;
34// }}}
35
36import java.io.*;
37import java.net.*;
38import java.util.*;
39
40import xml.completion.*;
41import xml.completion.ElementDecl.AttributeDecl;
42import xml.Resolver;
43
44import org.gjt.sp.jedit.jEdit;
45/**
46 * $Id$
47 */
48public class XSDSchemaToCompletionTest{
49	private static File testData;
50
51    @BeforeClass
52    public static void setUpjEdit() throws IOException{
53        TestUtils.beforeClass();
54        testData = new File(System.getProperty("test_data")).getCanonicalFile();
55        assertTrue(testData.exists());
56    }
57
58    @AfterClass
59    public static void tearDownjEdit() {
60        TestUtils.afterClass();
61    }
62
63    @Test
64    public void testNant() throws IOException, org.xml.sax.SAXException {
65    	File f = new File(testData,"nant/mini-nant.xsd");
66    	Map<String,CompletionInfo> schemas = 
67    		XSDSchemaToCompletion.getCompletionInfoFromSchema(f.getPath()
68    				, null
69    				, null
70    				, null
71    				, TestUtils.view().getBuffer());
72		assertEquals(1,schemas.size());
73		assertTrue(schemas.containsKey("http://nant.sf.net/release/0.85/nant.xsd"));
74		CompletionInfo info = schemas.get("http://nant.sf.net/release/0.85/nant.xsd");
75		assertEquals(1,info.elementHash.size()); // only project is top level
76		assertThat(info.elementHash.keySet()).containsOnly("project");
77		ElementDecl prj = info.elementHash.get("project");
78		assertThat(prj.content).containsOnly("if");
79		ElementDecl ifd = prj.elementHash.get("if");
80		assertSame(ifd, ifd.elementHash.get("if"));
81    }
82    
83
84}