1 package org.codehaus.xfire.java; 2 3 import java.util.Collection; 4 import org.codehaus.plexus.PlexusTestCase; 5 import org.codehaus.xfire.SOAPConstants; 6 import org.codehaus.xfire.java.mapping.TypeMapping; 7 import org.codehaus.xfire.java.mapping.TypeMappingRegistry; 8 import org.codehaus.xfire.java.test.Echo; 9 import org.codehaus.xfire.java.type.Type; 10 import org.codehaus.xfire.service.Service; 11 import org.dom4j.QName; 12 13 14 /*** 15 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 16 * @since Feb 21, 2004 17 */ 18 public class JavaServiceTest 19 extends PlexusTestCase 20 { 21 public void testServiceRegister() throws Exception 22 { 23 AbstractJavaService hello = (AbstractJavaService) lookup( Service.ROLE, "echo" ); 24 25 assertEquals( "Echo", hello.getName() ); 26 27 assertEquals( Echo.class, hello.getServiceClass() ); 28 29 assertNotNull( hello.getServiceHandler() ); 30 31 assertNotNull( hello.getFaultHandler() ); 32 33 assertEquals( 1, hello.getOperations().size() ); 34 35 36 TypeMappingRegistry reg = (TypeMappingRegistry) lookup ( TypeMappingRegistry.ROLE ); 37 38 TypeMapping tm = reg.getTypeMapping( "urn:Echo" ); 39 40 assertNotNull( tm ); 41 42 assertSame( hello.getTypeMapping(), tm ); 43 44 45 tm = reg.getDefaultTypeMapping(); 46 47 assertNotNull( tm ); 48 49 50 Type type = hello.getTypeMapping().getType( String.class ); 51 52 assertNotNull( type ); 53 54 type = hello.getTypeMapping().getType( String.class, QName.get( "string", SOAPConstants.XSD) ); 55 56 assertNotNull( type ); 57 } 58 59 public void testStaticMethods() throws Exception 60 { 61 AbstractJavaService hello = (AbstractJavaService) lookup( Service.ROLE, "StaticEcho" ); 62 63 Collection ops = hello.getOperations(); 64 assertEquals( 1, ops.size() ); 65 } 66 }