Search in sources :

Example 1 with ServiceEndpoint

use of javax.jbi.servicedesc.ServiceEndpoint in project petals-bc-gateway by petalslink.

the class ConsumerDomain method splitPerService.

private static Map<QName, Collection<ServiceEndpoint>> splitPerService(final Collection<ServiceEndpoint> endpoints) {
    final Map<QName, Collection<ServiceEndpoint>> res = new HashMap<>();
    for (final ServiceEndpoint endpoint : endpoints) {
        final QName serviceName = endpoint.getServiceName();
        Collection<ServiceEndpoint> c = res.get(serviceName);
        if (c == null) {
            c = new LinkedList<>();
            res.put(serviceName, c);
        }
        c.add(endpoint);
    }
    assert validate(res);
    return res;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Collection(java.util.Collection) ServiceEndpoint(javax.jbi.servicedesc.ServiceEndpoint)

Example 2 with ServiceEndpoint

use of javax.jbi.servicedesc.ServiceEndpoint in project petals-bc-gateway by petalslink.

the class AbstractComponentTest method deployTwoDomains.

/**
 * TODO it would be relevant to check for all domain deployed that everything has been cleaned as desired
 */
protected ServiceEndpoint deployTwoDomains(final boolean specifyService, final boolean specifyEndpoint, @Nullable final String clientCertificate, @Nullable final String clientKey, @Nullable final String clientRemoteCertificate, @Nullable final String serverCertificate, @Nullable final String serverKey, @Nullable final String serverRemoteCertificate, @Nullable final Integer retryMax, @Nullable final Long retryDelay, @Nullable final Long pollingDelay) throws Exception {
    COMPONENT_UNDER_TEST.deployService(SU_CONSUMER_NAME, createHelloConsumes(specifyService, specifyEndpoint, serverCertificate, serverKey, serverRemoteCertificate, pollingDelay));
    COMPONENT_UNDER_TEST.deployService(SU_PROVIDER_NAME, createProvider(TEST_AUTH_NAME, TEST_TRANSPORT_PORT, clientCertificate, clientKey, clientRemoteCertificate, retryMax, retryDelay));
    Awaitility.await("External endpoint not propagated !").atMost(Duration.ofSeconds(10)).until(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return getPropagatedServiceEndpoint() != null;
        }
    });
    final ServiceEndpoint endpoint = getPropagatedServiceEndpoint();
    assert endpoint != null;
    return endpoint;
}
Also used : PetalsException(org.ow2.petals.basisapi.exception.PetalsException) ServiceEndpoint(javax.jbi.servicedesc.ServiceEndpoint)

Example 3 with ServiceEndpoint

use of javax.jbi.servicedesc.ServiceEndpoint in project petals-bc-gateway by petalslink.

the class BcGatewayLifecyclesTest method testNotNewExchangeAfterShutdown.

public void testNotNewExchangeAfterShutdown(final boolean stopConsumer, final boolean stopProvider) throws Exception {
    final ServiceEndpoint endpoint = deployTwoDomains();
    final ServiceProviderImplementation provider = ServiceProviderImplementation.outMessage(OUT);
    COMPONENT_UNDER_TEST.pushRequestToProvider(helloRequest(endpoint, MEPPatternConstants.IN_OUT.value()));
    // let's wait for the request to be on the service provider side
    await().atMost(Duration.ofSeconds(2)).untilAsserted(() -> assertEquals(1, COMPONENT_UNDER_TEST.getRequestsFromConsumerCount()));
    if (stopProvider) {
        COMPONENT_UNDER_TEST.stopService(SU_PROVIDER_NAME);
        COMPONENT_UNDER_TEST.shutdownService(SU_PROVIDER_NAME);
    }
    if (stopConsumer) {
        COMPONENT_UNDER_TEST.stopService(SU_CONSUMER_NAME);
        COMPONENT_UNDER_TEST.shutdownService(SU_CONSUMER_NAME);
    }
    COMPONENT.receiveResponseAsExternalProvider(provider, false);
    final ResponseMessage response = COMPONENT_UNDER_TEST.pollResponseFromProvider(DEFAULT_TIMEOUT_FOR_COMPONENT_SEND);
    MessageChecks.hasOut().andThen(MessageChecks.hasXmlContent(OUT)).checks(response);
    COMPONENT.sendDoneStatus(response, provider);
}
Also used : ServiceProviderImplementation(org.ow2.petals.component.framework.junit.helpers.ServiceProviderImplementation) ResponseMessage(org.ow2.petals.component.framework.junit.ResponseMessage) ServiceEndpoint(javax.jbi.servicedesc.ServiceEndpoint)

Example 4 with ServiceEndpoint

use of javax.jbi.servicedesc.ServiceEndpoint in project petals-bc-gateway by petalslink.

the class BcGatewaySendTest method testTimeout.

@Test
public void testTimeout() throws Exception {
    final ServiceEndpoint endpoint = deployTwoDomains();
    final ServiceProviderImplementation provider = ServiceProviderImplementation.errorMessage(ERROR).with(new MessageChecks() {

        @Override
        public void checks(@Nullable final Message message) throws Exception {
            Thread.sleep(DEFAULT_TIMEOUT_FOR_COMPONENT_SEND + 1000);
        }
    });
    final StatusMessage response = COMPONENT.sendAndGetStatus(helloRequest(endpoint, MEPPatternConstants.IN_OUT.value()), provider);
    assertEquals(AbstractDomain.TIMEOUT_EXCEPTION.getMessage(), response.getError().getMessage());
}
Also used : MessageChecks(org.ow2.petals.component.framework.junit.helpers.MessageChecks) ServiceProviderImplementation(org.ow2.petals.component.framework.junit.helpers.ServiceProviderImplementation) Message(org.ow2.petals.component.framework.junit.Message) StatusMessage(org.ow2.petals.component.framework.junit.StatusMessage) ServiceEndpoint(javax.jbi.servicedesc.ServiceEndpoint) StatusMessage(org.ow2.petals.component.framework.junit.StatusMessage) Test(org.junit.Test)

Example 5 with ServiceEndpoint

use of javax.jbi.servicedesc.ServiceEndpoint in project petals-bc-gateway by petalslink.

the class MonitTraceFilteringTest method deployAndStartSUs.

/**
 * Deploy and start required service units on components.
 *
 * @param ruleIdx
 *            MONIT flow tracing rule index.
 * @param mepType
 *            Current MEP of the current test rule.
 * @param consEnableFlowTracing
 *            Flow tracing activation state to set on the service consumer of the provider domain
 * @param consEnableFlowTracingPropagation
 *            Propagation of the flow tracing activation to set on the service consumer of the provider domain
 * @return The service provider to test running on the component under test.
 */
private ProvidesServiceConfiguration deployAndStartSUs(final String ruleIdPrefix, final MEPType mepType, final Optional<Boolean> consEnableFlowTracing, final Optional<Boolean> consEnableFlowTracingPropagation) throws Exception {
    final ConsumesServiceConfiguration consumerServiceCfg = AbstractEnvironmentTest.createHelloConsumes(true, true, Long.valueOf(30000));
    if (consEnableFlowTracing.isPresent()) {
        consumerServiceCfg.setParameter(new QName("http://petals.ow2.org/components/extensions/version-5", "activate-flow-tracing"), Boolean.toString(consEnableFlowTracing.get()));
    }
    if (consEnableFlowTracingPropagation.isPresent()) {
        consumerServiceCfg.setParameter(new QName("http://petals.ow2.org/components/extensions/version-5", "propagate-flow-tracing-activation"), Boolean.toString(consEnableFlowTracingPropagation.get()));
    }
    this.cutProviderDomain.deployService(AbstractEnvironmentTest.SU_CONSUMER_NAME, consumerServiceCfg);
    this.cutConsumerDomain.deployService(AbstractEnvironmentTest.SU_PROVIDER_NAME, AbstractEnvironmentTest.createProvider(AbstractEnvironmentTest.TEST_AUTH_NAME, TRANSPORT_PORT));
    Awaitility.await().atMost(Duration.ofSeconds(10)).until(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return AbstractEnvironmentTest.getPropagatedServiceEndpoint(cutConsumerDomain) != null;
        }
    });
    final ServiceEndpoint notExtSvcEdp = AbstractEnvironmentTest.getPropagatedServiceEndpoint(this.cutConsumerDomain);
    this.proxyServiceEndpoint = new ProvidesServiceConfiguration(notExtSvcEdp.getInterfaces()[0], notExtSvcEdp.getServiceName(), notExtSvcEdp.getEndpointName());
    return this.proxyServiceEndpoint;
}
Also used : QName(javax.xml.namespace.QName) ConsumesServiceConfiguration(org.ow2.petals.component.framework.junit.impl.ConsumesServiceConfiguration) IOException(java.io.IOException) ServiceEndpoint(javax.jbi.servicedesc.ServiceEndpoint) ProvidesServiceConfiguration(org.ow2.petals.component.framework.junit.impl.ProvidesServiceConfiguration)

Aggregations

ServiceEndpoint (javax.jbi.servicedesc.ServiceEndpoint)8 QName (javax.xml.namespace.QName)3 ServiceProviderImplementation (org.ow2.petals.component.framework.junit.helpers.ServiceProviderImplementation)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 StatusMessage (org.ow2.petals.component.framework.junit.StatusMessage)2 IOException (java.io.IOException)1 PetalsException (org.ow2.petals.basisapi.exception.PetalsException)1 ServiceKey (org.ow2.petals.bc.gateway.commons.messages.ServiceKey)1 TransportedDocument (org.ow2.petals.bc.gateway.commons.messages.TransportedDocument)1 TransportedPropagations (org.ow2.petals.bc.gateway.commons.messages.TransportedPropagations)1 Consumes (org.ow2.petals.component.framework.jbidescriptor.generated.Consumes)1 Message (org.ow2.petals.component.framework.junit.Message)1 RequestMessage (org.ow2.petals.component.framework.junit.RequestMessage)1 ResponseMessage (org.ow2.petals.component.framework.junit.ResponseMessage)1 MessageChecks (org.ow2.petals.component.framework.junit.helpers.MessageChecks)1 ConsumesServiceConfiguration (org.ow2.petals.component.framework.junit.impl.ConsumesServiceConfiguration)1 ProvidesServiceConfiguration (org.ow2.petals.component.framework.junit.impl.ProvidesServiceConfiguration)1