File: RFC24.java

package info (click to toggle)
mapserver 6.0.1-3.2%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 17,940 kB
  • sloc: ansic: 209,190; cpp: 53,949; cs: 12,101; python: 5,323; perl: 3,332; makefile: 841; lex: 706; yacc: 609; java: 466; xml: 379; sh: 253; tcl: 158; ruby: 53
file content (111 lines) | stat: -rw-r--r-- 2,526 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import edu.umn.gis.mapscript.*;

/**
 * <p>Title: Mapscript RFC24 tests.</p>
 * <p>Description: Tests for RFC24 implementation. (http://mapserver.gis.umn.edu/development/rfc/ms-rfc-24/)</p>
 * @author Umberto Nicoletti (umberto.nicoletti@gmail.com)
 */

public class RFC24 {
	String mapfile;

	public static void main(String[] args) {
		new RFC24(args[0]).run();
	}
	
	public RFC24(String mapfile) {
		this.mapfile=mapfile;
	}
	
	public void run() {
		System.out.println("Running "+getClass().getName());
		testLayerObj();
		testClassObj();
		testInsertLayerObj();
		testInsertClassObj();
		testGetLayerObj();
		testGetLayerObjByName();
		testGetClassObj();
		System.out.println("Finished "+getClass().getName());
	}
	
	public void testLayerObj() {
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=new layerObj(map);
		
		map=null;
		gc();
		assertNotNull(newLayer.getMap(), "testLayerObj");
	}
	
	public void testInsertLayerObj() {
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=new layerObj(null);
		map.insertLayer(newLayer,-1);
		
		map=null;
		gc();
		assertNotNull(newLayer.getMap(), "testInsertLayerObj");
	}
	
	public void testGetLayerObj() {
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=map.getLayer(1);
		
		map=null;
		gc();
		assertNotNull(newLayer.getMap(), "testGetLayerObj");
	}

	public void testGetLayerObjByName() {
		mapObj map=new mapObj(mapfile);
		layerObj newLayer=map.getLayerByName("POLYGON");
		
		map=null;
		gc();
		assertNotNull(newLayer.getMap(), "testGetLayerObjByName");
	}

	public void testClassObj() {
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=new classObj(layer);
		
		map=null; layer=null;
		gc();
		assertNotNull(newClass.getLayer(), "testClassObj");
	}

	public void testInsertClassObj() {
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=new classObj(null);
		layer.insertClass(newClass,-1);
		
		map=null; layer=null;
		gc();
		assertNotNull(newClass.getLayer(), "testInsertClassObj");
	}

	public void testGetClassObj() {
		mapObj map=new mapObj(mapfile);
		layerObj layer=map.getLayer(1);
		classObj newClass=layer.getClass(0);
		
		map=null; layer=null;
		gc();
		assertNotNull(newClass.getLayer(), "testGetClassObj");
	}

	public void gc() {
		for (int i=0; i<10; i++)
			System.gc();
	}
	
	public void assertNotNull(Object object, String test) {
		if ( object != null )
			System.out.println("\t- "+test+" PASSED");
		else
			System.out.println("\t- "+test+" FAILED");
	}
}