Project

General

Profile

Download (3.53 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.api.service.lsid;
11

    
12
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
13
import static org.junit.Assert.assertNotNull;
14

    
15
import java.io.FileNotFoundException;
16
import java.io.InputStreamReader;
17
import java.io.StringReader;
18

    
19
import javax.xml.transform.Source;
20

    
21
import org.custommonkey.xmlunit.XMLUnit;
22
import org.junit.Before;
23
import org.junit.Ignore;
24
import org.junit.Test;
25
import org.unitils.dbunit.annotation.DataSet;
26
import org.unitils.spring.annotation.SpringBeanByType;
27

    
28
import com.ibm.lsid.ExpiringResponse;
29
import com.ibm.lsid.server.LSIDServerException;
30

    
31
import eu.etaxonomy.cdm.api.service.lsid.impl.LsidRegistryImpl;
32
import eu.etaxonomy.cdm.model.common.LSID;
33
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
34

    
35
@DataSet("LSIDAuthorityServiceTest.testGetAvailableServices.xml")
36
public class LSIDAuthorityServiceTest extends CdmIntegrationTest {
37

    
38
	@SpringBeanByType
39
	private LSIDAuthorityService lsidAuthorityService;
40

    
41
	@SpringBeanByType
42
	private LSIDRegistry lsidRegistry;
43

    
44
	private LSID knownLsid;
45
	private LSID unknownLsid;
46

    
47
	@Before
48
	public void setUp() throws Exception {
49
		unknownLsid = new LSID("fred.org", "dagg", "1", null);
50
		knownLsid = new LSID("example.org", "taxonconcepts", "1", null);
51
		XMLUnit.setControlParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
52
	    XMLUnit.setTestParser("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
53
	    XMLUnit.setSAXParserFactory("org.apache.xerces.jaxp.SAXParserFactoryImpl");
54
	    XMLUnit.setIgnoreWhitespace(true);
55
	    ((LsidRegistryImpl)lsidRegistry).init();
56
	}
57

    
58
	@Test
59
	public void testInit()	{
60
		assertNotNull("lsidAuthorityService should exist",lsidAuthorityService);
61
	}
62

    
63
	@Test
64
	public void testGetAuthorityWSDL() throws Exception {
65
		ExpiringResponse expiringResponse = lsidAuthorityService.getAuthorityWSDL();
66
		String resource = "/eu/etaxonomy/cdm/api/service/lsid/LSIDAuthorityServiceTest.testGetAuthorityWSDL-result.wsdl";
67
		String result = transformSourceToString((Source) expiringResponse.getValue());
68

    
69
		assertXMLEqual("getAuthorityWSDL should return an xml source equal to the test resource",new InputStreamReader(this.getClass().getResourceAsStream(resource)),new StringReader(result));
70
	}
71

    
72
	/**
73
	 * Unfortunately, the ordering of the services switches round between linux and windows.
74
	 * This is why we ignore this test failure.
75
	 *
76
	 * @throws Exception
77
	 */
78
	@Test
79
	@Ignore
80
	public void testGetAvailableServicesWithKnownLSID() throws Exception {
81
		ExpiringResponse expiringResponse = lsidAuthorityService.getAvailableServices(knownLsid);
82

    
83
		String resource = "/eu/etaxonomy/cdm/api/service/lsid/LSIDAuthorityServiceTest.testGetAvailableServicesWithKnownLSID-result.wsdl";
84
		String result = transformSourceToString((Source) expiringResponse.getValue());
85
		assertXMLEqual("getAvailableServices should return an xml source equal to the test resource",new InputStreamReader(this.getClass().getResourceAsStream(resource)),new StringReader(result));
86
	}
87

    
88
	@Test(expected= LSIDServerException.class)
89
	public void testGetAvailableServicesWithUnknownLSID() throws Exception {
90
		lsidAuthorityService.getAvailableServices(unknownLsid);
91
	}
92

    
93
    @Override
94
    public void createTestDataSet() throws FileNotFoundException {}
95
}
(1-1/4)