File: WxSTest.java

package info (click to toggle)
mapserver 5.0.3-3%2Blenny7
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,556 kB
  • ctags: 12,645
  • sloc: ansic: 168,024; cs: 8,534; python: 4,618; sh: 4,213; cpp: 4,059; perl: 2,781; makefile: 787; lex: 564; java: 415; yacc: 334; tcl: 158; ruby: 53
file content (76 lines) | stat: -rw-r--r-- 2,291 bytes parent folder | download | duplicates (5)
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
import edu.umn.gis.mapscript.mapObj;
import edu.umn.gis.mapscript.OWSRequest;
import edu.umn.gis.mapscript.mapscript;

class WxSTest_thread extends Thread {

    public String	mapName;
    public byte[]       resultBytes;

    public void run() {
	mapObj map = new mapObj(mapName);

        map.setMetaData( "ows_onlineresource", "http://dummy.org/" );

        OWSRequest req = new OWSRequest();

        req.setParameter( "SERVICE", "WMS" );
        req.setParameter( "VERSION", "1.1.0" );
        req.setParameter( "REQUEST", "GetCapabilities" );

        mapscript.msIO_installStdoutToBuffer();

        int owsResult = map.OWSDispatch( req );

        if( owsResult != 0 )
            System.out.println( "OWSDispatch Result (expect 0): " + owsResult );

//        System.out.println( "Document:" );
//        System.out.println( mapscript.msIO_getStdoutBufferString() );

        resultBytes = mapscript.msIO_getStdoutBufferBytes();
    }
}

public class WxSTest {
    public static void main(String[] args)  {
        try {
            WxSTest_thread tt[] = new WxSTest_thread[100];
            int i;
            int expectedLength=0, success = 0, failure=0;

            for( i = 0; i < tt.length; i++ )
            {
                tt[i] = new WxSTest_thread();
                tt[i].mapName = args[0];
            }
            
            for( i = 0; i < tt.length; i++ )
                tt[i].start();

            for( i = 0; i < tt.length; i++ )
            {
                tt[i].join();
                if( i == 0 )
                {
                    expectedLength = tt[i].resultBytes.length;
                    System.out.println( "Document Length: " + expectedLength + ", expecting somewhere around 10000 or more." );
                }
                else if( expectedLength != tt[i].resultBytes.length )
                {
                    System.out.println( "Document Length:" + tt[i].resultBytes.length + " Expected:" + expectedLength );
                    failure++;
                }
                else
                    success++;
            }

            System.out.println( "Successes: " + success );
            System.out.println( "Failures: " + failure );

        } catch( Exception e ) {
            e.printStackTrace();
        }
    }
}