Statistics
| Revision:

root / org.gvsig.proj / branches / refactor2018 / org.gvsig.proj / org.gvsig.proj.catalog / org.gvsig.proj.catalog.api / src / test / java / org / gvsig / proj / CRSCatalogueManagerIT.java @ 793

History | View | Annotate | Download (3.64 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.proj;
24

    
25
import java.util.List;
26

    
27
import org.gvsig.proj.catalogue.CRSCatalogueManager;
28
import org.gvsig.proj.catalogue.CRSDefinition;
29
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
30

    
31
/**
32
 * {@link CoordinateReferenceSystemManager} API acceptance tests.
33
 * 
34
 * @author gvSIG Team
35
 */
36
public abstract class CRSCatalogueManagerIT extends
37
    AbstractLibraryAutoInitTestCase {
38

    
39
    protected CRSCatalogueManager manager;
40

    
41
    protected void doSetUp() throws Exception {
42
        manager = createProjectionManager();
43
    }
44

    
45
    /**
46
     * Creates a {@link CoordinateReferenceSystemManager} instance.
47
     * 
48
     * @return the {@link CoordinateReferenceSystemManager} instance
49
     */
50
    protected abstract CRSCatalogueManager createProjectionManager();
51

    
52
    /**
53
     * Returns the authority name to use to create the projections to test.
54
     * 
55
     * @return the authority name
56
     */
57
    protected abstract String getAuthorityName();
58

    
59
    /**
60
     * Returns the code to use to create the projections to test.
61
     * 
62
     * @return the code
63
     */
64
    protected abstract String getCode();
65

    
66
    /**
67
     * Test method for
68
     * {@link org.gvsig.proj.CoordinateReferenceSystemManager#getAuthorityNames()}
69
     * .
70
     */
71
    public void testGetAuthorityNames() {
72
        List names = manager.getAuthorityNames();
73
        assertNotNull(names);
74
        assertTrue("Authority names list is empty", names.size() > 0);
75
        for (int i = 0; i < names.size(); i++) {
76
            if (!(names.get(i) instanceof String)) {
77
                fail("At least one authority name is not a String");
78
            }
79
        }
80
    }
81

    
82
    /**
83
     * Test method for
84
     * {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCodes(java.lang.String)}
85
     * .
86
     */
87
    public void testGetCodes() {
88
        List names = manager.getAuthorityNames();
89
        for (int i = 0; i < names.size(); i++) {
90
            List codes = manager.getCodes((String) names.get(i));
91
            for (int j = 0; j < codes.size(); j++) {
92
                if (!(codes.get(i) instanceof String)) {
93
                    fail("At least one code of the authority " + names.get(i)
94
                        + " is not a String");
95
                }
96
            }
97
        }
98
    }
99

    
100
    /**
101
     * Test method for
102
     * {@link org.gvsig.proj.CoordinateReferenceSystemManager#getCoordinateReferenceSystem(java.lang.String, java.lang.String)}
103
     */
104
    public void testGetDefinition() throws Exception {
105
            String code = getAuthorityName() + ":" + getCode();
106
        CRSDefinition projection =
107
            manager.getCRSDefinition(code);
108
        //FIXME: assertEquals(getAuthorityName(), projection.getAuthorityName());
109
        //FIXME: assertEquals(getCode(), projection.getCode());
110
    }
111

    
112
}