root / branches / v2_0_0_prep / libraries / org.gvsig.exportto / org.gvsig.exportto.lib / org.gvsig.exportto.lib.api / src / test / java / org / gvsig / exportto / ExporttoServiceTest.java @ 34981
History | View | Annotate | Download (3.72 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.exportto; |
23 |
|
24 |
import org.gvsig.fmap.dal.DALLocator; |
25 |
import org.gvsig.fmap.dal.DataManager; |
26 |
import org.gvsig.fmap.dal.DataServerExplorer; |
27 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
28 |
import org.gvsig.fmap.dal.DataStoreParameters; |
29 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
30 |
import org.gvsig.fmap.dal.exception.DataException; |
31 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
32 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
33 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
34 |
|
35 |
/**
|
36 |
* API compatibility tests for {@link ExporttoService} implementations.
|
37 |
*
|
38 |
* @author gvSIG Team
|
39 |
* @version $Id$
|
40 |
*/
|
41 |
public abstract class ExporttoServiceTest extends |
42 |
AbstractLibraryAutoInitTestCase { |
43 |
|
44 |
protected ExporttoManager manager;
|
45 |
protected DataManager dataManager = null; |
46 |
|
47 |
@Override
|
48 |
protected void doSetUp() throws Exception { |
49 |
manager = ExporttoLocator.getManager(); |
50 |
dataManager = DALLocator.getDataManager(); |
51 |
} |
52 |
|
53 |
/**
|
54 |
* Returns an instance of the {@link ExporttoService}.
|
55 |
*
|
56 |
* @return a {@link ExporttoService} instance
|
57 |
* @throws ValidateDataParametersException
|
58 |
* @throws DataException
|
59 |
* @throws Exception
|
60 |
* if there is any error creating the instance
|
61 |
*/
|
62 |
protected ExporttoService createService() throws ValidateDataParametersException, DataException{ |
63 |
DataServerExplorerParameters dataServerExplorerParameters = |
64 |
dataManager.createServerExplorerParameters("FilesystemExplorer");
|
65 |
DataServerExplorer dataServerExplorer = |
66 |
dataManager.openServerExplorer("FilesystemExplorer", dataServerExplorerParameters);
|
67 |
NewDataStoreParameters newDataStoreParameters = dataServerExplorer.getAddParameters("Shape");
|
68 |
return manager.getExporttoService(dataServerExplorer, newDataStoreParameters);
|
69 |
} |
70 |
|
71 |
/**
|
72 |
* Test for the {@link ExporttoService#export(org.gvsig.fmap.dal.feature.FeatureSet)} method.
|
73 |
*/
|
74 |
public void testExporttoServiceCreation() { |
75 |
ExporttoService exportService; |
76 |
try {
|
77 |
exportService = createService(); |
78 |
assertNotNull(exportService); |
79 |
//TODO a test for the export service
|
80 |
//exportService.export(featureSet);
|
81 |
|
82 |
} catch (ValidateDataParametersException e) {
|
83 |
assertNull(e); |
84 |
} catch (DataException e) {
|
85 |
assertNull(e); |
86 |
} |
87 |
} |
88 |
|
89 |
@SuppressWarnings("unused") |
90 |
private FeatureStore createMemoryFeatureStore() throws ValidateDataParametersException, DataException{ |
91 |
DataStoreParameters memoryParameters = dataManager.createStoreParameters("Memory");
|
92 |
FeatureStore featureStore = (FeatureStore) dataManager.openStore("Memory", memoryParameters);
|
93 |
return (FeatureStore) featureStore.getFeatureSet();
|
94 |
} |
95 |
} |