1 package test.wsdd; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 import junit.framework.TestSuite; 6 import org.apache.axis.Handler; 7 import org.apache.axis.handlers.soap.SOAPService; 8 import org.apache.axis.configuration.XMLStringProvider; 9 import org.apache.axis.deployment.wsdd.WSDDConstants; 10 import org.apache.axis.server.AxisServer; 11 12 import java.util.List ; 13 14 public class TestRoles extends TestCase 15 { 16 static final String GLOBAL_ROLE = "http://apache.org/globalRole"; 17 static final String SERVICE_ROLE = "http://apache.org/serviceRole"; 18 static final String SERVICE_NAME = "roleService"; 19 20 static final String doc = 21 "<deployment xmlns=\"http://xml.apache.org/axis/wsdd/\" " + 22 "xmlns:java=\"" + WSDDConstants.URI_WSDD_JAVA + "\">\n" + 23 " <globalConfiguration>\n" + 24 " <role>" + GLOBAL_ROLE + "</role>\n" + 25 " </globalConfiguration>\n" + 26 " <service name=\"" + SERVICE_NAME + "\">\n" + 27 " <parameter name=\"className\" value=\"test.wsdd.TestRoles\"/>\n" + 28 " <role>" + SERVICE_ROLE + "</role>" + 29 " </service>\n"+ 30 "</deployment>"; 31 32 public TestRoles (String name) { 33 super(name); 34 } 35 36 public static Test suite() { 37 return new TestSuite(TestRoles.class); 38 } 39 40 protected void setup() { 41 } 42 43 51 public void testOptions() throws Exception 52 { 53 XMLStringProvider provider = new XMLStringProvider(doc); 54 AxisServer server = new AxisServer(provider); 55 56 SOAPService service = server.getService(SERVICE_NAME); 57 assertNotNull("Couldn't get service from engine!", service); 58 59 List roles = service.getRoles(); 60 assertTrue("Service role not accessible", 61 roles.contains(SERVICE_ROLE)); 62 assertTrue("Global role not accessible", 63 roles.contains(GLOBAL_ROLE)); 64 65 roles = service.getServiceActors(); 66 assertTrue("Service role not accessible from specific list", 67 roles.contains(SERVICE_ROLE)); 68 assertFalse("Global role is accessible from specific list", 69 roles.contains(GLOBAL_ROLE)); 70 } 71 72 public static void main(String [] args) throws Exception { 73 TestRoles tester = new TestRoles("foo"); 74 tester.testOptions(); 75 } 76 } 77 | Popular Tags |