svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.lib / org.gvsig.exportto.lib.api / src / test / java / org / gvsig / exportto / ExporttoServiceTest.java @ 43364
History | View | Annotate | Download (3.82 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.exportto; |
25 |
|
26 |
import org.gvsig.fmap.dal.DALLocator; |
27 |
import org.gvsig.fmap.dal.DataManager; |
28 |
import org.gvsig.fmap.dal.DataServerExplorer; |
29 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
30 |
import org.gvsig.fmap.dal.DataStoreParameters; |
31 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
32 |
import org.gvsig.fmap.dal.exception.DataException; |
33 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
34 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
35 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
36 |
|
37 |
/**
|
38 |
* API compatibility tests for {@link ExporttoService} implementations.
|
39 |
*
|
40 |
* @author gvSIG Team
|
41 |
* @version $Id$
|
42 |
*/
|
43 |
public abstract class ExporttoServiceTest extends |
44 |
AbstractLibraryAutoInitTestCase { |
45 |
|
46 |
protected ExporttoManager manager;
|
47 |
protected DataManager dataManager = null; |
48 |
|
49 |
@Override
|
50 |
protected void doSetUp() throws Exception { |
51 |
manager = ExporttoLocator.getManager(); |
52 |
dataManager = DALLocator.getDataManager(); |
53 |
} |
54 |
|
55 |
/**
|
56 |
* Returns an instance of the {@link ExporttoService}.
|
57 |
*
|
58 |
* @return a {@link ExporttoService} instance
|
59 |
* @throws ValidateDataParametersException
|
60 |
* @throws DataException
|
61 |
* @throws Exception
|
62 |
* if there is any error creating the instance
|
63 |
*/
|
64 |
protected ExporttoService createService()
|
65 |
throws ValidateDataParametersException, DataException {
|
66 |
DataServerExplorerParameters dataServerExplorerParameters = |
67 |
dataManager.createServerExplorerParameters("FilesystemExplorer");
|
68 |
DataServerExplorer dataServerExplorer = |
69 |
dataManager.openServerExplorer("FilesystemExplorer",
|
70 |
dataServerExplorerParameters); |
71 |
NewDataStoreParameters newDataStoreParameters = |
72 |
dataServerExplorer.getAddParameters("Shape");
|
73 |
return manager.getExporttoService(dataServerExplorer,
|
74 |
newDataStoreParameters, null);
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Test for the
|
79 |
* {@link ExporttoService#export(org.gvsig.fmap.dal.feature.FeatureSet)}
|
80 |
* method.
|
81 |
*/
|
82 |
public void testExporttoServiceCreation() { |
83 |
ExporttoService exportService; |
84 |
try {
|
85 |
exportService = createService(); |
86 |
assertNotNull(exportService); |
87 |
// TODO a test for the export service
|
88 |
// exportService.export(featureSet);
|
89 |
|
90 |
} catch (ValidateDataParametersException e) {
|
91 |
assertNull(e); |
92 |
} catch (DataException e) {
|
93 |
assertNull(e); |
94 |
} |
95 |
} |
96 |
|
97 |
@SuppressWarnings("unused") |
98 |
private FeatureStore createMemoryFeatureStore()
|
99 |
throws ValidateDataParametersException, DataException {
|
100 |
DataStoreParameters memoryParameters = |
101 |
dataManager.createStoreParameters("Memory");
|
102 |
FeatureStore featureStore = |
103 |
(FeatureStore) dataManager.openStore("Memory", memoryParameters);
|
104 |
return (FeatureStore) featureStore.getFeatureSet();
|
105 |
} |
106 |
} |