[mapserver-commits] r7176 - in trunk/mapserver/mapscript/java: .
examples
svn at osgeo.org
svn at osgeo.org
Sun Dec 16 08:13:34 EST 2007
Author: unicoletti
Date: 2007-12-16 08:13:33 -0500 (Sun, 16 Dec 2007)
New Revision: 7176
Added:
trunk/mapserver/mapscript/java/examples/RFC24.java
Modified:
trunk/mapserver/mapscript/java/Makefile.in
trunk/mapserver/mapscript/java/javamodule.i
Log:
RFC24: implementation of item 3.2
Modified: trunk/mapserver/mapscript/java/Makefile.in
===================================================================
--- trunk/mapserver/mapscript/java/Makefile.in 2007-12-16 10:53:41 UTC (rev 7175)
+++ trunk/mapserver/mapscript/java/Makefile.in 2007-12-16 13:13:33 UTC (rev 7176)
@@ -251,7 +251,7 @@
rm -rf tests/threadtest/*.class
test:
- $(JAVAC) -classpath ./:examples/:./mapscript.jar -d examples/ examples/ConnPool.java examples/DrawMap.java examples/DumpShp.java examples/MakePoint.java examples/QueryByAttribute.java examples/ShapeInfo.java examples/WxSTest.java examples/Metadata.java examples/RunTimeBuiltWMSClient.java
+ $(JAVAC) -classpath ./:examples/:./mapscript.jar -d examples/ examples/RFC24.java examples/ConnPool.java examples/DrawMap.java examples/DumpShp.java examples/MakePoint.java examples/QueryByAttribute.java examples/ShapeInfo.java examples/WxSTest.java examples/Metadata.java examples/RunTimeBuiltWMSClient.java
$(JAVAC) -encoding iso-8859-15 -classpath ./:examples/:./mapscript.jar -d examples/ examples/QueryByAttributeUnicode.java
$(JAVA) -classpath ./:examples/:./mapscript.jar -Djava.library.path=. DumpShp ../../tests/point.shp
$(JAVA) -classpath ./:examples/:./mapscript.jar -Djava.library.path=. ShapeInfo ../../tests/point.shp ../../tests/point.dbf
@@ -259,6 +259,7 @@
$(JAVA) -classpath ./:examples/:./mapscript.jar -Djava.library.path=. ConnPool
$(JAVA) -classpath ./:examples/:./mapscript.jar -Djava.library.path=. QueryByAttribute ../../tests/test.map
$(JAVA) -classpath ./:examples/:./mapscript.jar -Djava.library.path=. WxSTest ../../tests/test.map
+ $(JAVA) -classpath ./:examples/:./mapscript.jar -Djava.library.path=. RFC24 ../../tests/test.map
LC_ALL=de_DE $(JAVA) -classpath ./:examples/:./mapscript.jar -Djava.library.path=. QueryByAttributeUnicode data/subset-umlauts.map
threadtests:
Added: trunk/mapserver/mapscript/java/examples/RFC24.java
===================================================================
--- trunk/mapserver/mapscript/java/examples/RFC24.java (rev 0)
+++ trunk/mapserver/mapscript/java/examples/RFC24.java 2007-12-16 13:13:33 UTC (rev 7176)
@@ -0,0 +1,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 at 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");
+ }
+}
Modified: trunk/mapserver/mapscript/java/javamodule.i
===================================================================
--- trunk/mapserver/mapscript/java/javamodule.i 2007-12-16 10:53:41 UTC (rev 7175)
+++ trunk/mapserver/mapscript/java/javamodule.i 2007-12-16 13:13:33 UTC (rev 7176)
@@ -130,3 +130,88 @@
%typemap(out) char * {
$result = JNU_NewStringNative(jenv, $1);
}
+
+/*
+===============================================================================
+RFC-24 implementation follows
+===============================================================================
+ Modified constructor according to:
+ - cache population and sync, item 3.2
+*/
+%typemap(javaconstruct) layerObj(mapObj map) %{ {
+ this($imcall, true);
+ if (map != null) {
+ this.map=map;
+ }
+}
+%}
+
+%typemap(javaconstruct) classObj(layerObj layer) %{ {
+ this($imcall, true);
+ if (layer != null) {
+ this.layer=layer;
+ }
+}
+%}
+
+%typemap(javaout) int insertLayer {
+ // call the C API
+ int actualIndex=$jnicall;
+ /* Store parent reference, item 3.2 */
+ layer.map=this;
+ return actualIndex;
+}
+
+%typemap(javaout) layerObj* getLayer {
+ // call the C API
+ long cPtr=$jnicall;
+ layerObj layer = null;
+ if (cPtr != 0) {
+ layer=new layerObj(cPtr, true);
+ /* Store parent reference, item 3.2 */
+ layer.map=this;
+ }
+ return layer;
+}
+
+%typemap(javaout) layerObj* getLayerByName {
+ // call the C API
+ long cPtr=$jnicall;
+ layerObj layer = null;
+ if (cPtr != 0) {
+ layer=new layerObj(cPtr, true);
+ /* Store parent reference, item 3.2 */
+ layer.map=this;
+ }
+ return layer;
+}
+
+%typemap(javaout) int insertClass {
+ // call the C API
+ int actualIndex=$jnicall;
+ /* Store parent reference, item 3.2 */
+ classobj.layer=this;
+ return actualIndex;
+}
+
+%typemap(javaout) classObj* getClass {
+ // call the C API
+ long cPtr=$jnicall;
+ classObj clazz = null;
+ if (cPtr != 0) {
+ clazz=new classObj(cPtr, true);
+ /* Store parent reference, item 3.2 */
+ clazz.layer=this;
+ }
+ return clazz;
+}
+
+%typemap(javacode) layerObj %{
+ /* parent reference, RFC-24 item 3.2 */
+ mapObj map=null;
+%}
+
+%typemap(javacode) classObj %{
+ /* parent reference, RFC-24 item 3.2 */
+ layerObj layer=null;
+%}
More information about the mapserver-commits
mailing list