gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.impl / src / test / java / org / gvsig / raster / cache / buffer / impl / stripecache / vertical / TestRWOneValue.java @ 991
History | View | Annotate | Download (1.88 KB)
1 |
package org.gvsig.raster.cache.buffer.impl.stripecache.vertical; |
---|---|
2 |
|
3 |
import java.awt.image.DataBuffer; |
4 |
import java.io.IOException; |
5 |
|
6 |
import junit.framework.TestCase; |
7 |
|
8 |
import org.gvsig.raster.cache.buffer.impl.BufferCacheManagerImpl; |
9 |
|
10 |
/**
|
11 |
* This test creates a buffer and write a number in each element of each band.
|
12 |
* Then, it reads from the buffer the numbers and check it.
|
13 |
*
|
14 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
15 |
*/
|
16 |
public class TestRWOneValue extends TestCase { |
17 |
|
18 |
public void start() { |
19 |
this.setUp();
|
20 |
this.testStack();
|
21 |
} |
22 |
|
23 |
public void setUp() { |
24 |
System.err.println("StripeCache TestRWOneValue running..."); |
25 |
} |
26 |
|
27 |
public void testStack() { |
28 |
long t1 = System.currentTimeMillis(); |
29 |
|
30 |
//Reducimos el tama?o de la cache para una prueba con menos datos
|
31 |
BufferCacheManagerImpl.cacheSize = 2;
|
32 |
BufferCacheManagerImpl.pageSize = 0.2;
|
33 |
|
34 |
RasterVertCacheBuffer buf = new RasterVertCacheBuffer(DataBuffer.TYPE_BYTE, 2571, 1942, 3); |
35 |
|
36 |
for (int iBand = 0; iBand < buf.getBandCount(); iBand++) { |
37 |
for (int col = 0; col < buf.getWidth(); col++) { |
38 |
for (int row = 0; row < buf.getHeight(); row++) { |
39 |
byte n = (byte)(8 + iBand); |
40 |
byte m = (byte)(34 + iBand); |
41 |
if(row == 1001 && col == 1032) |
42 |
buf.setElem(row, col, iBand, n); |
43 |
else
|
44 |
buf.setElem(row, col, iBand, m); |
45 |
} |
46 |
} |
47 |
} |
48 |
|
49 |
for (int iBand = 0; iBand < buf.getBandCount(); iBand++) { |
50 |
for (int col = 0; col < buf.getWidth(); col++) { |
51 |
for (int row = 0; row < buf.getHeight(); row++) { |
52 |
byte n = buf.getElemByte(row, col, iBand);
|
53 |
byte m = (byte)(34 + iBand); |
54 |
if(n != m)
|
55 |
;//System.out.println(n + " " + row + "," + col);
|
56 |
else
|
57 |
assertEquals(n, m); |
58 |
} |
59 |
} |
60 |
} |
61 |
try {
|
62 |
buf.free(); |
63 |
} catch (IOException e) { |
64 |
e.printStackTrace(); |
65 |
} |
66 |
long t2 = System.currentTimeMillis(); |
67 |
System.out.println("Tiempo StripeCache TestRWOneValue: " + (t2 - t1) + " milisegundos"); |
68 |
} |
69 |
|
70 |
} |