Statistics
| Revision:

root / trunk / libraries / libRaster / src-test / org / gvsig / raster / dataaccess / TestDataSourceMultiFile.java @ 11067

History | View | Annotate | Download (5.94 KB)

1
/*
2
 * Created on 19-jul-2006
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 */
25
package org.gvsig.raster.dataaccess;
26

    
27
import junit.framework.TestCase;
28

    
29
import org.gvsig.raster.RasterLibrary;
30
import org.gvsig.raster.dataset.NotSupportedExtensionException;
31
import org.gvsig.raster.dataset.RasterDataset;
32
import org.gvsig.raster.dataset.RasterDriverException;
33

    
34
/**
35
 * Este test prueba la gesti?n de multifichero de la clase RasterMultiFile
36
 * y que incorpora un Grid, as? como la gesti?n de bandas que tiene BandList
37
 * y que incorpora GeoRasterMultiFile.
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 *
40
 */
41
public class TestDataSourceMultiFile extends TestCase{
42
        private String baseDir = "./test-images/";
43

    
44
        private String path1 = baseDir + "band1-30x28byte.tif";
45
        private String path2 = baseDir + "band2-30x28byte.tif";
46
        private String path3 = baseDir + "band3-30x28byte.tif";
47
        
48
        private RasterDataset f1 = null;
49
        private RasterDataset f2 = null;
50
        private RasterDataset f3 = null;
51
        
52
        private DataSource ds = null;
53
        
54
        public void start(){
55
                this.setUp();
56
                this.testStack();
57
        }
58
        
59
        static{
60
                RasterLibrary.wakeUp();
61
        }
62
        
63
        public void setUp() {
64
                System.err.println("TestDataSourceMultiFile running...");
65
                try {
66
                        f1 = RasterDataset.openFile(null, path1);
67
                        f2 = RasterDataset.openFile(null, path2);
68
                        f3 = RasterDataset.openFile(null, path3);
69
                        //f4 = RasterDataset.openFile(null, path4);
70
                } catch (NotSupportedExtensionException e) {
71
                        e.printStackTrace();
72
                } catch (RasterDriverException e) {
73
                        e.printStackTrace();
74
                }
75
        }
76
        
77
        public void testStack(){
78
        
79
                //EL CONSTRUCTOR A?ADE FICHERO 1
80
                ds = new DataSource(f1);
81
                //Comprobaci?n de n?mero y nombre de ficheros
82
                String[] fileList = ds.getGeoRasterMultiFile().getNameDatasetStringList();
83
                assertEquals(fileList.length, 1);
84
                assertEquals(fileList[0], path1);
85
                //Comprobaci?n de bandas
86
                String[] bandList = ds.getGeoRasterMultiFile().getBands().getBandStringList();
87
                assertEquals(bandList.length, 1);
88
                assertEquals(bandList[0], path1);
89
                
90
                //A?ADIMOS FICHERO 2
91
                ds.addFile(f2);
92
                fileList = ds.getGeoRasterMultiFile().getNameDatasetStringList();
93
                //Comprobaci?n de n?mero y nombre de ficheros
94
                assertEquals(fileList.length, 2);
95
                assertEquals(fileList[0], path1);
96
                assertEquals(fileList[1], path2);
97
                //Comprobaci?n de bandas
98
                bandList = ds.getGeoRasterMultiFile().getBands().getBandStringList();
99
                assertEquals(bandList.length, 2);
100
                assertEquals(bandList[0], path1);
101
                assertEquals(bandList[1], path2);
102
                
103
                //A?ADIMOS FICHERO 3
104
                ds.addFile(f3);
105
                fileList = ds.getGeoRasterMultiFile().getNameDatasetStringList();
106
                //Comprobaci?n de n?mero y nombre de ficheros
107
                assertEquals(fileList.length, 3);
108
                assertEquals(fileList[0], path1);
109
                assertEquals(fileList[1], path2);
110
                assertEquals(fileList[2], path3);
111
                //Comprobaci?n de bandas
112
                bandList = ds.getGeoRasterMultiFile().getBands().getBandStringList();
113
                assertEquals(bandList.length, 3);
114
                assertEquals(bandList[0], path1);
115
                assertEquals(bandList[1], path2);
116
                assertEquals(bandList[2], path3);
117
                //Posicion dentro del fichero
118
                int[] bandPos = ds.getGeoRasterMultiFile().getBands().getBandPositionList();
119
                for(int i = 0; i < bandPos.length; i++)
120
                        assertEquals(bandPos[i], 0);
121
                
122
                //ELIMINAMOS FICHERO 2
123
                ds.removeFile(f2);
124
                fileList = ds.getGeoRasterMultiFile().getNameDatasetStringList();
125
                //Comprobaci?n de n?mero y nombre de ficheros
126
                assertEquals(fileList.length, 2);
127
                assertEquals(fileList[0], path1);
128
                assertEquals(fileList[1], path3);
129
                //Comprobaci?n de bandas
130
                bandList = ds.getGeoRasterMultiFile().getBands().getBandStringList();
131
                assertEquals(bandList.length, 2);
132
                assertEquals(bandList[0], path1);
133
                assertEquals(bandList[1], path3);
134
                
135
                //ELIMINAMOS FICHERO 1
136
                ds.removeFile(f1);
137
                fileList = ds.getGeoRasterMultiFile().getNameDatasetStringList();
138
                //Comprobaci?n de n?mero y nombre de ficheros
139
                assertEquals(fileList.length, 1);
140
                assertEquals(fileList[0], path3);
141
                //Comprobaci?n de bandas
142
                bandList = ds.getGeoRasterMultiFile().getBands().getBandStringList();
143
                assertEquals(bandList.length, 1);
144
                assertEquals(bandList[0], path3);
145
                
146
                //ELIMINAMOS FICHERO 3
147
                ds.removeFile(f3);
148
                fileList = ds.getGeoRasterMultiFile().getNameDatasetStringList();
149
                //Comprobaci?n de n?mero y nombre de ficheros
150
                assertEquals(fileList.length, 0);
151
                //Comprobaci?n de bandas
152
                bandList = ds.getGeoRasterMultiFile().getBands().getBandStringList();
153
                assertEquals(bandList.length, 0);
154

    
155
                //A?ADIMOS FICHERO 4
156
                /*ds.addFile(f4);
157
                fileList = ds.getGeoRasterMultiFile().getNameDatasetStringList();
158
                //Comprobaci?n de n?mero y nombre de ficheros
159
                assertEquals(fileList.length, 1);
160
                assertEquals(fileList[0], path4);
161
                //Comprobaci?n de bandas
162
                bandList = ds.getGeoRasterMultiFile().getBands().getBandStringList();
163
                assertEquals(bandList.length, 4);
164
                assertEquals(bandList[0], path4);
165
                assertEquals(bandList[1], path4);
166
                assertEquals(bandList[2], path4);
167
                assertEquals(bandList[3], path4);
168
                //Posicion dentro del fichero
169
                bandPos = ds.getGeoRasterMultiFile().getBands().getBandPositionList();
170
                for(int i = 0; i < bandPos.length; i++)
171
                        assertEquals(bandPos[i], i);*/
172
        }
173

    
174
}