File: TestAllowedMethods.java

package info (click to toggle)
axis 1.4-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 52,100 kB
  • sloc: java: 129,124; xml: 10,602; jsp: 983; sh: 84; cs: 36; makefile: 18
file content (76 lines) | stat: -rw-r--r-- 2,423 bytes parent folder | download | duplicates (10)
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
/*
 * Created by IntelliJ IDEA.
 * User: gdaniels
 * Date: Apr 2, 2002
 * Time: 10:14:06 AM
 * To change template for new class use 
 * Code Style | Class Templates options (Tools | IDE Options).
 */
package test.wsdd;

import junit.framework.TestCase;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.configuration.XMLStringProvider;
import org.apache.axis.deployment.wsdd.WSDDConstants;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.local.LocalTransport;

public class TestAllowedMethods extends TestCase {
    static final String SERVICE_NAME = "AllowedMethodService";
    private static final String MESSAGE = "Allowed method";

    AxisServer server;
    LocalTransport transport;

    // Two-part WSDD, with a space for scope option in the middle
    static final String doc1 =
            "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " +
                  "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" +
            " <service name=\"" + SERVICE_NAME + "\" " +
                      "provider=\"java:RPC\">\n" +
            "   <parameter name=\"allowedMethods\" value=\"allowed\"/>" +
            "   <parameter name=\"className\" value=\"test.wsdd.TestAllowedMethods\"/>" +
            " </service>\n" +
            "</deployment>";

    public TestAllowedMethods() {
        super("test");
    }

    public TestAllowedMethods(String s) {
        super(s);
    }

    protected void setUp() throws Exception {
        XMLStringProvider config = new XMLStringProvider(doc1);
        server = new AxisServer(config);
        transport = new LocalTransport(server);
        transport.setRemoteService(SERVICE_NAME);
    }

    public void testAllowedMethods() throws Exception {
        Call call = new Call(new Service());
        call.setTransport(transport);

        String ret = (String)call.invoke("allowed", null);
        assertEquals("Return didn't match", MESSAGE, ret);

        try {
            ret = (String)call.invoke("disallowed", null);
        } catch (Exception e) {
            // Success, we shouldn't have been allowed to call that.
            return;
        }

        fail("Successfully called disallowed method!");
    }

    public String disallowed() throws Exception {
        return "You shouldn't have called me!";
    }

    public String allowed() {
        return MESSAGE;
    }
}