1
|
package edu.ucsb.nceas.metacattest.service;
|
2
|
|
3
|
import edu.ucsb.nceas.metacat.service.XMLSchemaParser;
|
4
|
import edu.ucsb.nceas.metacat.service.XMLSchemaService;
|
5
|
|
6
|
import junit.framework.Test;
|
7
|
import junit.framework.TestCase;
|
8
|
import junit.framework.TestResult;
|
9
|
import junit.framework.TestSuite;
|
10
|
|
11
|
/**
|
12
|
* Junit test for XMLSchemaService
|
13
|
* @author tao
|
14
|
*
|
15
|
*/
|
16
|
public class XMLSchemaServiceTest extends TestCase
|
17
|
{
|
18
|
|
19
|
/**
|
20
|
* Constructor to build the test
|
21
|
*
|
22
|
* @param name the name of the test method
|
23
|
*/
|
24
|
public XMLSchemaServiceTest(String name)
|
25
|
{
|
26
|
super(name);
|
27
|
}
|
28
|
|
29
|
/**
|
30
|
* Establish a testing framework by initializing appropriate objects
|
31
|
*/
|
32
|
public void setUp()
|
33
|
{
|
34
|
|
35
|
}
|
36
|
|
37
|
/**
|
38
|
* Release any objects after tests are complete
|
39
|
*/
|
40
|
public void tearDown()
|
41
|
{
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* Create a suite of tests to be run together
|
46
|
*/
|
47
|
public static Test suite()
|
48
|
{
|
49
|
TestSuite suite = new TestSuite();
|
50
|
suite.addTest(new XMLSchemaServiceTest("initialize"));
|
51
|
suite.addTest(new XMLSchemaServiceTest("testGetBaseUrlFromSchemaURL"));
|
52
|
return suite;
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* Run an initial test that always passes to check that the test
|
57
|
* harness is working.
|
58
|
*/
|
59
|
public void initialize()
|
60
|
{
|
61
|
assertTrue(1 == 1);
|
62
|
}
|
63
|
|
64
|
public void testGetBaseUrlFromSchemaURL()
|
65
|
{
|
66
|
String url="http://www.example.com/metacat/example.xsd";
|
67
|
String base = "http://www.example.com/metacat/";
|
68
|
String baseURL = XMLSchemaService.getBaseUrlFromSchemaURL(url);
|
69
|
assertTrue("The base url should be "+base, baseURL.equals(base));
|
70
|
url = "www.example.com/example.xsd";
|
71
|
baseURL = XMLSchemaService.getBaseUrlFromSchemaURL(url);
|
72
|
assertTrue("The base url should be "+null, baseURL==null);
|
73
|
url="http://www.example.com/metacat/";
|
74
|
baseURL = XMLSchemaService.getBaseUrlFromSchemaURL(url);
|
75
|
assertTrue("The base url should be "+url, baseURL.equals(url));
|
76
|
}
|
77
|
}
|