Search in sources :

Example 1 with JAXBBindingCustomization

use of org.jboss.ws.api.binding.JAXBBindingCustomization in project jbossws-cxf by jbossws.

the class BindingCustomizationTestCase method testCustomizationWriteAccess.

@Test
@RunAsClient
@SuppressWarnings("unchecked")
public void testCustomizationWriteAccess() throws Exception {
    SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
    DeploymentModelFactory deploymentModelFactory = spiProvider.getSPI(DeploymentModelFactory.class);
    Endpoint endpoint = deploymentModelFactory.newHttpEndpoint(null);
    BindingCustomization jaxbCustomization = new JAXBBindingCustomization();
    jaxbCustomization.put("com.sun.xml.bind.defaultNamespaceRemap", "http://org.jboss.bindingCustomization");
    endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
    // a started endpoint should deny customizations
    try {
        endpoint.setState(EndpointState.STARTED);
        endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
        fail("It should not be possible to change bindinig customizations on a started endpoint");
    } catch (Exception e) {
    // all fine, this should happen
    }
}
Also used : Endpoint(org.jboss.wsf.spi.deployment.Endpoint) SPIProvider(org.jboss.wsf.spi.SPIProvider) JAXBBindingCustomization(org.jboss.ws.api.binding.JAXBBindingCustomization) BindingCustomization(org.jboss.ws.api.binding.BindingCustomization) JAXBBindingCustomization(org.jboss.ws.api.binding.JAXBBindingCustomization) DeploymentModelFactory(org.jboss.wsf.spi.deployment.DeploymentModelFactory) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 2 with JAXBBindingCustomization

use of org.jboss.ws.api.binding.JAXBBindingCustomization in project jbossws-cxf by jbossws.

the class BindingCustomizationTestCase method testCustomizationReadAccess.

@Test
@RunAsClient
@SuppressWarnings("unchecked")
public void testCustomizationReadAccess() throws Exception {
    SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
    DeploymentModelFactory deploymentModelFactory = spiProvider.getSPI(DeploymentModelFactory.class);
    Endpoint endpoint = deploymentModelFactory.newHttpEndpoint(null);
    BindingCustomization jaxbCustomization = new JAXBBindingCustomization();
    jaxbCustomization.put("com.sun.xml.bind.defaultNamespaceRemap", "http://org.jboss.bindingCustomization");
    endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
    endpoint.setState(EndpointState.STARTED);
    // read a single customization
    BindingCustomization knownCustomization = endpoint.getAttachment(BindingCustomization.class);
    assertNotNull(knownCustomization);
    // however the iteratoion should be unmodifiable
    try {
        endpoint.addAttachment(BindingCustomization.class, jaxbCustomization);
        fail("Started Endpoints should only expose read acccess to their binding customizations");
    } catch (Exception e) {
    // all fine, we'd expect this
    }
}
Also used : Endpoint(org.jboss.wsf.spi.deployment.Endpoint) SPIProvider(org.jboss.wsf.spi.SPIProvider) JAXBBindingCustomization(org.jboss.ws.api.binding.JAXBBindingCustomization) BindingCustomization(org.jboss.ws.api.binding.BindingCustomization) JAXBBindingCustomization(org.jboss.ws.api.binding.JAXBBindingCustomization) DeploymentModelFactory(org.jboss.wsf.spi.deployment.DeploymentModelFactory) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 3 with JAXBBindingCustomization

use of org.jboss.ws.api.binding.JAXBBindingCustomization in project jbossws-cxf by jbossws.

the class Helper method setBindingCustomizationOnClientSide.

/**
 * Setup binding customization on client side using the JBossWSConfigurer
 *
 * @throws Exception
 */
@SuppressWarnings("unchecked")
private Bus setBindingCustomizationOnClientSide() throws Exception {
    BindingCustomization jaxbCustomizations = new JAXBBindingCustomization();
    if (jaxbIntroUrl == null) {
        jaxbIntroUrl = Thread.currentThread().getContextClassLoader().getResource("jaxb-intros.xml");
    }
    BindingCustomizationFactory.populateBindingCustomization(jaxbIntroUrl.openStream(), jaxbCustomizations);
    Bus bus = BusFactory.newInstance().createBus();
    BusFactory.setThreadDefaultBus(bus);
    JBossWSConfigurer configurer = (JBossWSConfigurer) bus.getExtension(Configurer.class);
    configurer.getCustomizer().setBindingCustomization(jaxbCustomizations);
    return bus;
}
Also used : Bus(org.apache.cxf.Bus) JBossWSConfigurer(org.jboss.wsf.stack.cxf.client.configuration.JBossWSConfigurer) JAXBBindingCustomization(org.jboss.ws.api.binding.JAXBBindingCustomization) BindingCustomization(org.jboss.ws.api.binding.BindingCustomization) JAXBBindingCustomization(org.jboss.ws.api.binding.JAXBBindingCustomization) JBossWSConfigurer(org.jboss.wsf.stack.cxf.client.configuration.JBossWSConfigurer) Configurer(org.apache.cxf.configuration.Configurer)

Aggregations

BindingCustomization (org.jboss.ws.api.binding.BindingCustomization)3 JAXBBindingCustomization (org.jboss.ws.api.binding.JAXBBindingCustomization)3 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)2 SPIProvider (org.jboss.wsf.spi.SPIProvider)2 DeploymentModelFactory (org.jboss.wsf.spi.deployment.DeploymentModelFactory)2 Endpoint (org.jboss.wsf.spi.deployment.Endpoint)2 Test (org.junit.Test)2 Bus (org.apache.cxf.Bus)1 Configurer (org.apache.cxf.configuration.Configurer)1 JBossWSConfigurer (org.jboss.wsf.stack.cxf.client.configuration.JBossWSConfigurer)1