Search in sources :

Example 1 with GenericGenericClass

use of org.apache.cxf.javascript.fortest.GenericGenericClass in project cxf by apache.

the class GenericAegisTest method testGenerateJavascript.

// the claim is that code generation makes this go boom.
@Test
public void testGenerateJavascript() throws Exception {
    // Create our service implementation
    GenericGenericClass<String> impl = new GenericGenericClass<String>();
    // Create our Server
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    // we sure can't get a .class for the interface, can we?
    svrFactory.setServiceClass(impl.getClass());
    svrFactory.setAddress("http://localhost:" + PORT + "/aegisgeneric");
    svrFactory.setServiceBean(impl);
    Server server = svrFactory.create();
    ServiceInfo serviceInfo = ((EndpointImpl) server.getEndpoint()).getEndpointInfo().getService();
    Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
    BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo);
    NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo.getXmlSchemaCollection());
    for (SchemaInfo schema : schemata) {
        SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo.getXmlSchemaCollection(), prefixManager, nameManager);
        String allThatJavascript = builder.generateCodeForSchema(schema.getSchema());
        assertNotNull(allThatJavascript);
    }
    ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo, null, prefixManager, nameManager);
    serviceBuilder.walk();
    String serviceJavascript = serviceBuilder.getCode();
    assertNotNull(serviceJavascript);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) ServiceJavascriptBuilder(org.apache.cxf.javascript.service.ServiceJavascriptBuilder) Server(org.apache.cxf.endpoint.Server) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) GenericGenericClass(org.apache.cxf.javascript.fortest.GenericGenericClass) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) SchemaJavascriptBuilder(org.apache.cxf.javascript.types.SchemaJavascriptBuilder) Test(org.junit.Test)

Aggregations

Server (org.apache.cxf.endpoint.Server)1 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)1 GenericGenericClass (org.apache.cxf.javascript.fortest.GenericGenericClass)1 ServiceJavascriptBuilder (org.apache.cxf.javascript.service.ServiceJavascriptBuilder)1 SchemaJavascriptBuilder (org.apache.cxf.javascript.types.SchemaJavascriptBuilder)1 SchemaInfo (org.apache.cxf.service.model.SchemaInfo)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1 Test (org.junit.Test)1