Revision 35333 branches/dal_time_support/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/impl/DefaultMapContextManagerTest.java
DefaultMapContextManagerTest.java | ||
---|---|---|
36 | 36 |
import org.gvsig.fmap.crs.CRSFactory; |
37 | 37 |
import org.gvsig.fmap.dal.exception.ReadException; |
38 | 38 |
import org.gvsig.fmap.dal.feature.Feature; |
39 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
39 | 40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
40 | 41 |
import org.gvsig.fmap.mapcontext.MapContext; |
41 | 42 |
import org.gvsig.fmap.mapcontext.MapContextDrawer; |
... | ... | |
62 | 63 |
* @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a> |
63 | 64 |
*/ |
64 | 65 |
public class DefaultMapContextManagerTest extends |
65 |
AbstractLibraryAutoInitTestCase {
|
|
66 |
AbstractLibraryAutoInitTestCase { |
|
66 | 67 |
|
67 |
private DefaultMapContextManager manager;
|
|
68 |
private DefaultMapContextManager manager;
|
|
68 | 69 |
|
69 |
protected void doSetUp() throws Exception { |
|
70 |
manager = new DefaultMapContextManager(); |
|
71 |
|
|
72 |
manager.registerLegend("DummyLegend", DummyVectorLegend.class); |
|
73 |
manager.setDefaultVectorLegend("DummyLegend"); |
|
74 |
manager.registerLegendReader("Dummy", DummyLegendReader.class); |
|
75 |
manager.registerLegendWriter("DummyLegend", "Dummy", DummyLegendWriter.class); |
|
76 |
} |
|
70 |
protected void doSetUp() throws Exception { |
|
71 |
manager = new DefaultMapContextManager(); |
|
77 | 72 |
|
78 |
protected void tearDown() throws Exception { |
|
79 |
super.tearDown(); |
|
80 |
} |
|
73 |
manager.registerLegend("DummyLegend", DummyVectorLegend.class); |
|
74 |
manager.setDefaultVectorLegend("DummyLegend"); |
|
75 |
manager.registerLegendReader("Dummy", DummyLegendReader.class); |
|
76 |
manager.registerLegendWriter("DummyLegend", "Dummy", DummyLegendWriter.class); |
|
77 |
} |
|
81 | 78 |
|
82 |
/** |
|
83 |
* Test method for |
|
84 |
* {@link org.gvsig.fmap.mapcontext.impl.DefaultMapContextManager#createDefaultMapContextDrawerInstance()} |
|
85 |
* . |
|
86 |
*/ |
|
87 |
public void testGetDefaultMapContextDrawerInstance() throws Exception { |
|
79 |
protected void tearDown() throws Exception { |
|
80 |
super.tearDown(); |
|
81 |
} |
|
88 | 82 |
|
89 |
manager.setDefaultMapContextDrawer(DummyMapContextDrawer.class); |
|
83 |
/** |
|
84 |
* Test method for |
|
85 |
* {@link org.gvsig.fmap.mapcontext.impl.DefaultMapContextManager#createDefaultMapContextDrawerInstance()} |
|
86 |
* . |
|
87 |
*/ |
|
88 |
public void testGetDefaultMapContextDrawerInstance() throws Exception { |
|
90 | 89 |
|
91 |
MapContextDrawer drawer = manager |
|
92 |
.createDefaultMapContextDrawerInstance(); |
|
90 |
manager.setDefaultMapContextDrawer(DummyMapContextDrawer.class); |
|
93 | 91 |
|
94 |
assertNotNull("The created MapContextDrawer instance can't be null", |
|
95 |
drawer); |
|
96 |
assertTrue( |
|
97 |
"The created MapContextDrawer is not instance of the registered class" |
|
98 |
+ DummyMapContextDrawer.class, |
|
99 |
drawer instanceof DummyMapContextDrawer); |
|
100 |
} |
|
92 |
MapContextDrawer drawer = manager |
|
93 |
.createDefaultMapContextDrawerInstance(); |
|
101 | 94 |
|
102 |
/** |
|
103 |
* Test method for |
|
104 |
* {@link org.gvsig.fmap.mapcontext.impl.DefaultMapContextManager#setDefaultMapContextDrawer(java.lang.Class)} |
|
105 |
* . |
|
106 |
*/ |
|
107 |
public void testSetDefaultMapContextDrawer() throws Exception { |
|
95 |
assertNotNull("The created MapContextDrawer instance can't be null", |
|
96 |
drawer); |
|
97 |
assertTrue( |
|
98 |
"The created MapContextDrawer is not instance of the registered class" |
|
99 |
+ DummyMapContextDrawer.class, |
|
100 |
drawer instanceof DummyMapContextDrawer); |
|
101 |
} |
|
108 | 102 |
|
109 |
// First, try to register an invalid class |
|
110 |
try { |
|
111 |
manager.setDefaultMapContextDrawer(Object.class); |
|
112 |
fail("Error, a class that does not implement the MapContextDrawer " |
|
113 |
+ "interface has been accepted"); |
|
114 |
} catch (MapContextRuntimeException e) { |
|
115 |
// OK |
|
116 |
} |
|
103 |
/** |
|
104 |
* Test method for |
|
105 |
* {@link org.gvsig.fmap.mapcontext.impl.DefaultMapContextManager#setDefaultMapContextDrawer(java.lang.Class)} |
|
106 |
* . |
|
107 |
*/ |
|
108 |
public void testSetDefaultMapContextDrawer() throws Exception { |
|
117 | 109 |
|
118 |
// Next, try to register a valid class |
|
119 |
manager.setDefaultMapContextDrawer(DummyMapContextDrawer.class); |
|
120 |
} |
|
110 |
// First, try to register an invalid class |
|
111 |
try { |
|
112 |
manager.setDefaultMapContextDrawer(Object.class); |
|
113 |
fail("Error, a class that does not implement the MapContextDrawer " |
|
114 |
+ "interface has been accepted"); |
|
115 |
} catch (MapContextRuntimeException e) { |
|
116 |
// OK |
|
117 |
} |
|
121 | 118 |
|
122 |
public void testCreateGraphicsLayer() throws Exception {
|
|
123 |
assertNotNull(manager.createGraphicsLayer(CRSFactory.getCRS("EPSG:23030")));
|
|
124 |
}
|
|
119 |
// Next, try to register a valid class
|
|
120 |
manager.setDefaultMapContextDrawer(DummyMapContextDrawer.class);
|
|
121 |
}
|
|
125 | 122 |
|
126 |
public void testCreateDefaultVectorLegend() throws Exception { |
|
123 |
public void testCreateGraphicsLayer() throws Exception { |
|
124 |
assertNotNull(manager.createGraphicsLayer(CRSFactory.getCRS("EPSG:23030"))); |
|
125 |
} |
|
127 | 126 |
|
128 |
IVectorLegend legend = manager.createDefaultVectorLegend(1); |
|
129 |
assertNotNull(legend); |
|
130 |
assertTrue(legend instanceof DummyVectorLegend); |
|
131 |
} |
|
127 |
public void testCreateDefaultVectorLegend() throws Exception { |
|
132 | 128 |
|
133 |
public void testRegisterCreateLegend() throws Exception { |
|
129 |
IVectorLegend legend = manager.createDefaultVectorLegend(1); |
|
130 |
assertNotNull(legend); |
|
131 |
assertTrue(legend instanceof DummyVectorLegend); |
|
132 |
} |
|
134 | 133 |
|
135 |
manager.registerLegend("DummyLegend", DummyVectorLegend.class);
|
|
134 |
public void testRegisterCreateLegend() throws Exception {
|
|
136 | 135 |
|
137 |
ILegend legend = manager.createLegend("DummyLegend"); |
|
138 |
assertNotNull(legend); |
|
139 |
assertTrue(legend instanceof DummyVectorLegend); |
|
136 |
manager.registerLegend("DummyLegend", DummyVectorLegend.class); |
|
140 | 137 |
|
141 |
assertNull(manager.createLegend("NONE")); |
|
142 |
} |
|
138 |
ILegend legend = manager.createLegend("DummyLegend"); |
|
139 |
assertNotNull(legend); |
|
140 |
assertTrue(legend instanceof DummyVectorLegend); |
|
143 | 141 |
|
144 |
public void testRegisterCreateLegendReader() throws Exception { |
|
142 |
assertNull(manager.createLegend("NONE")); |
|
143 |
} |
|
145 | 144 |
|
146 |
manager.registerLegendReader("Dummy", DummyLegendReader.class);
|
|
145 |
public void testRegisterCreateLegendReader() throws Exception {
|
|
147 | 146 |
|
148 |
ILegendReader legendReader = manager.createLegendReader("Dummy"); |
|
149 |
assertNotNull(legendReader); |
|
150 |
assertTrue(legendReader instanceof DummyLegendReader); |
|
147 |
manager.registerLegendReader("Dummy", DummyLegendReader.class); |
|
151 | 148 |
|
152 |
assertNull(manager.createLegendReader("NONE")); |
|
153 |
} |
|
149 |
ILegendReader legendReader = manager.createLegendReader("Dummy"); |
|
150 |
assertNotNull(legendReader); |
|
151 |
assertTrue(legendReader instanceof DummyLegendReader); |
|
154 | 152 |
|
155 |
public void testRegisterCreateLegendWriter() throws Exception { |
|
153 |
assertNull(manager.createLegendReader("NONE")); |
|
154 |
} |
|
156 | 155 |
|
157 |
manager.registerLegend("DummyLegend", DummyVectorLegend.class);
|
|
156 |
public void testRegisterCreateLegendWriter() throws Exception {
|
|
158 | 157 |
|
159 |
manager.registerLegendWriter("DummyLegend", "Dummy", |
|
160 |
DummyLegendWriter.class); |
|
158 |
manager.registerLegend("DummyLegend", DummyVectorLegend.class); |
|
161 | 159 |
|
162 |
// Test the registered writer is created |
|
163 |
ILegendWriter legendWriter = manager.createLegendWriter("DummyLegend", |
|
164 |
"Dummy"); |
|
165 |
assertNotNull(legendWriter); |
|
166 |
assertTrue(legendWriter instanceof DummyLegendWriter); |
|
160 |
manager.registerLegendWriter("DummyLegend", "Dummy", |
|
161 |
DummyLegendWriter.class); |
|
167 | 162 |
|
168 |
// Test non registered cases
|
|
169 |
assertNull(manager.createLegendWriter("NONE", "Dummy"));
|
|
170 |
assertNull(manager.createLegendWriter("DummyLegend", "NONE"));
|
|
171 |
assertNull(manager.createLegendWriter("NONE", "NONE"));
|
|
172 |
}
|
|
163 |
// Test the registered writer is created
|
|
164 |
ILegendWriter legendWriter = manager.createLegendWriter("DummyLegend",
|
|
165 |
"Dummy");
|
|
166 |
assertNotNull(legendWriter);
|
|
167 |
assertTrue(legendWriter instanceof DummyLegendWriter);
|
|
173 | 168 |
|
174 |
public static class DummyMapContextDrawer implements MapContextDrawer { |
|
169 |
// Test non registered cases |
|
170 |
assertNull(manager.createLegendWriter("NONE", "Dummy")); |
|
171 |
assertNull(manager.createLegendWriter("DummyLegend", "NONE")); |
|
172 |
assertNull(manager.createLegendWriter("NONE", "NONE")); |
|
173 |
} |
|
175 | 174 |
|
176 |
public void dispose() { |
|
177 |
} |
|
175 |
public static class DummyMapContextDrawer implements MapContextDrawer { |
|
178 | 176 |
|
179 |
public void draw(FLayers root, BufferedImage image, Graphics2D g, |
|
180 |
Cancellable cancel, double scale) throws ReadException { |
|
181 |
} |
|
177 |
public void dispose() { |
|
178 |
} |
|
182 | 179 |
|
183 |
public void print(FLayers root, Graphics2D g, Cancellable cancel,
|
|
184 |
double scale, PrintAttributes properties) throws ReadException {
|
|
185 |
}
|
|
180 |
public void draw(FLayers root, BufferedImage image, Graphics2D g,
|
|
181 |
Cancellable cancel, double scale) throws ReadException {
|
|
182 |
}
|
|
186 | 183 |
|
187 |
public void setMapContext(MapContext mapContext) { |
|
188 |
} |
|
184 |
public void print(FLayers root, Graphics2D g, Cancellable cancel, |
|
185 |
double scale, PrintAttributes properties) throws ReadException { |
|
186 |
} |
|
189 | 187 |
|
190 |
public void setViewPort(ViewPort viewPort) {
|
|
191 |
}
|
|
188 |
public void setMapContext(MapContext mapContext) {
|
|
189 |
}
|
|
192 | 190 |
|
193 |
} |
|
191 |
public void setViewPort(ViewPort viewPort) { |
|
192 |
} |
|
194 | 193 |
|
195 |
public static class DummyLegendReader implements ILegendReader {
|
|
194 |
}
|
|
196 | 195 |
|
197 |
}
|
|
196 |
public static class DummyLegendReader implements ILegendReader {
|
|
198 | 197 |
|
199 |
public static class DummyLegendWriter implements ILegendWriter {
|
|
198 |
}
|
|
200 | 199 |
|
201 |
}
|
|
200 |
public static class DummyLegendWriter implements ILegendWriter {
|
|
202 | 201 |
|
203 |
public static class DummyVectorLegend implements IVectorLegend {
|
|
202 |
}
|
|
204 | 203 |
|
205 |
public void draw(BufferedImage image, Graphics2D graphics2d, |
|
206 |
ViewPort viewPort, Cancellable cancel, double scale, |
|
207 |
Map queryParameters, ICoordTrans coordTrans, |
|
208 |
FeatureStore featureStore, Evaluator evaluator) throws LegendException { |
|
209 |
// Empty method |
|
210 |
} |
|
204 |
public static class DummyVectorLegend implements IVectorLegend { |
|
211 | 205 |
|
212 |
public int getShapeType() { |
|
213 |
// Empty method |
|
214 |
return 0; |
|
215 |
} |
|
206 |
public void draw(BufferedImage image, Graphics2D graphics2d, |
|
207 |
ViewPort viewPort, Cancellable cancel, double scale, |
|
208 |
Map queryParameters, ICoordTrans coordTrans, |
|
209 |
FeatureStore featureStore, FeatureQuery featureQuery) throws LegendException { |
|
210 |
// Empty method |
|
211 |
} |
|
216 | 212 |
|
217 |
public ISymbol getSymbolByFeature(Feature feat) |
|
218 |
throws MapContextException { |
|
219 |
// Empty method |
|
220 |
return null; |
|
221 |
} |
|
213 |
public void draw(BufferedImage image, Graphics2D graphics2d, |
|
214 |
ViewPort viewPort, Cancellable cancel, double scale, |
|
215 |
Map queryParameters, ICoordTrans coordTrans, |
|
216 |
FeatureStore featureStore) throws LegendException { |
|
217 |
// Empty method |
|
218 |
} |
|
222 | 219 |
|
223 |
public boolean isSuitableForShapeType(int shapeType) {
|
|
224 |
// Empty method
|
|
225 |
return false;
|
|
226 |
}
|
|
220 |
public int getShapeType() {
|
|
221 |
// Empty method
|
|
222 |
return 0;
|
|
223 |
}
|
|
227 | 224 |
|
228 |
public boolean isUseDefaultSymbol() { |
|
229 |
// Empty method |
|
230 |
return false; |
|
231 |
} |
|
225 |
public ISymbol getSymbolByFeature(Feature feat) |
|
226 |
throws MapContextException { |
|
227 |
// Empty method |
|
228 |
return null; |
|
229 |
} |
|
232 | 230 |
|
233 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
234 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
|
235 |
FeatureStore featureStore, Evaluator evaluator, PrintAttributes properties) |
|
236 |
throws LegendException { |
|
237 |
// Empty method |
|
238 |
} |
|
231 |
public boolean isSuitableForShapeType(int shapeType) { |
|
232 |
// Empty method |
|
233 |
return false; |
|
234 |
} |
|
239 | 235 |
|
240 |
public void setDefaultSymbol(ISymbol s) { |
|
241 |
// Empty method |
|
242 |
} |
|
236 |
public boolean isUseDefaultSymbol() { |
|
237 |
// Empty method |
|
238 |
return false; |
|
239 |
} |
|
243 | 240 |
|
244 |
public void setShapeType(int shapeType) { |
|
245 |
// Empty method |
|
246 |
} |
|
241 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
242 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
|
243 |
FeatureStore featureStore, PrintAttributes properties) |
|
244 |
throws LegendException { |
|
245 |
// Empty method |
|
246 |
} |
|
247 | 247 |
|
248 |
public void useDefaultSymbol(boolean b) { |
|
249 |
// Empty method |
|
250 |
} |
|
248 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
|
249 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
|
250 |
FeatureStore featureStore, FeatureQuery featureQuery, PrintAttributes properties) |
|
251 |
throws LegendException { |
|
252 |
// Empty method |
|
253 |
} |
|
251 | 254 |
|
252 |
public void addLegendListener(LegendContentsChangedListener listener) {
|
|
253 |
// Empty method
|
|
254 |
}
|
|
255 |
public void setDefaultSymbol(ISymbol s) {
|
|
256 |
// Empty method
|
|
257 |
}
|
|
255 | 258 |
|
256 |
public ILegend cloneLegend() { |
|
257 |
// Empty method |
|
258 |
return null; |
|
259 |
} |
|
259 |
public void setShapeType(int shapeType) { |
|
260 |
// Empty method |
|
261 |
} |
|
260 | 262 |
|
261 |
public Object clone() throws CloneNotSupportedException { |
|
262 |
// TODO Auto-generated method stub |
|
263 |
return super.clone(); |
|
264 |
} |
|
263 |
public void useDefaultSymbol(boolean b) { |
|
264 |
// Empty method |
|
265 |
} |
|
265 | 266 |
|
266 |
public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
|
|
267 |
// Empty method
|
|
268 |
}
|
|
267 |
public void addLegendListener(LegendContentsChangedListener listener) {
|
|
268 |
// Empty method
|
|
269 |
}
|
|
269 | 270 |
|
270 |
public ISymbol getDefaultSymbol() {
|
|
271 |
// Empty method
|
|
272 |
return null;
|
|
273 |
}
|
|
271 |
public ILegend cloneLegend() {
|
|
272 |
// Empty method
|
|
273 |
return null;
|
|
274 |
}
|
|
274 | 275 |
|
275 |
public LegendContentsChangedListener[] getListeners() {
|
|
276 |
// Empty method
|
|
277 |
return null;
|
|
278 |
}
|
|
276 |
public Object clone() throws CloneNotSupportedException {
|
|
277 |
// TODO Auto-generated method stub
|
|
278 |
return super.clone();
|
|
279 |
}
|
|
279 | 280 |
|
280 |
public void removeLegendListener(LegendContentsChangedListener listener) {
|
|
281 |
// Empty method
|
|
282 |
}
|
|
281 |
public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
|
|
282 |
// Empty method
|
|
283 |
}
|
|
283 | 284 |
|
284 |
public void loadFromState(PersistentState state)
|
|
285 |
throws PersistenceException {
|
|
286 |
// Empty method
|
|
287 |
}
|
|
285 |
public ISymbol getDefaultSymbol() {
|
|
286 |
// Empty method
|
|
287 |
return null;
|
|
288 |
}
|
|
288 | 289 |
|
289 |
public void saveToState(PersistentState state)
|
|
290 |
throws PersistenceException {
|
|
291 |
// Empty method
|
|
292 |
}
|
|
290 |
public LegendContentsChangedListener[] getListeners() {
|
|
291 |
// Empty method
|
|
292 |
return null;
|
|
293 |
}
|
|
293 | 294 |
|
294 |
public void addDrawingObserver(Observer observer) {
|
|
295 |
// Empty method
|
|
296 |
}
|
|
295 |
public void removeLegendListener(LegendContentsChangedListener listener) {
|
|
296 |
// Empty method
|
|
297 |
}
|
|
297 | 298 |
|
298 |
public void deleteDrawingObserver(Observer observer) { |
|
299 |
// Empty method |
|
300 |
} |
|
299 |
public void loadFromState(PersistentState state) |
|
300 |
throws PersistenceException { |
|
301 |
// Empty method |
|
302 |
} |
|
301 | 303 |
|
302 |
public void deleteDrawingObservers() { |
|
303 |
// Empty method |
|
304 |
} |
|
305 |
} |
|
304 |
public void saveToState(PersistentState state) |
|
305 |
throws PersistenceException { |
|
306 |
// Empty method |
|
307 |
} |
|
308 |
|
|
309 |
public void addDrawingObserver(Observer observer) { |
|
310 |
// Empty method |
|
311 |
} |
|
312 |
|
|
313 |
public void deleteDrawingObserver(Observer observer) { |
|
314 |
// Empty method |
|
315 |
} |
|
316 |
|
|
317 |
public void deleteDrawingObservers() { |
|
318 |
// Empty method |
|
319 |
} |
|
320 |
} |
|
306 | 321 |
} |
Also available in: Unified diff