Search in sources :

Example 16 with Holder

use of javax.xml.ws.Holder in project midpoint by Evolveum.

the class ExportAction method executeGet.

private void executeGet(ModelPortType port, Writer writer) throws FaultMessage, IOException, JAXBException {
    SelectorQualifiedGetOptionsType options = createOptions();
    QName type = ObjectType.getType(getParams().getType());
    if (type == null) {
        type = ObjectType.OBJECT.getType();
    }
    Holder<com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> object = new Holder<>();
    Holder<OperationResultType> result = new Holder<>();
    port.getObject(type, getParams().getOid(), options, object, result);
    ToolsUtils.serializeObject(object.value, writer);
}
Also used : ObjectType(com.evolveum.midpoint.cli.ninja.util.ObjectType) QName(javax.xml.namespace.QName) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 17 with Holder

use of javax.xml.ws.Holder in project java-chassis by ServiceComb.

the class TestShutdownHookHandler method testShutdownHookHandlerReject.

@Test
public void testShutdownHookHandlerReject() throws Exception {
    Deencapsulation.setField(ShutdownHookHandler.INSTANCE, "shuttingDown", true);
    Holder<InvocationType> typeHolder = new Holder<>(InvocationType.PRODUCER);
    Invocation invocation = new MockUp<Invocation>() {

        @Mock
        public InvocationType getInvocationType() {
            return typeHolder.value;
        }
    }.getMockInstance();
    ShutdownHookHandler handler = ShutdownHookHandler.INSTANCE;
    handler.handle(invocation, asyncResp -> {
        InvocationException e = asyncResp.getResult();
        Assert.assertEquals(((CommonExceptionData) e.getErrorData()).getMessage(), "shutting down in progress");
        Assert.assertEquals(e.getStatusCode(), 590);
    });
    typeHolder.value = InvocationType.CONSUMER;
    handler.handle(invocation, asyncResp -> {
        InvocationException e = asyncResp.getResult();
        Assert.assertEquals(((CommonExceptionData) e.getErrorData()).getMessage(), "shutting down in progress");
        Assert.assertEquals(e.getStatusCode(), 490);
    });
}
Also used : Invocation(io.servicecomb.core.Invocation) InvocationException(io.servicecomb.core.exception.InvocationException) Holder(javax.xml.ws.Holder) InvocationType(io.servicecomb.core.invocation.InvocationType) Mock(mockit.Mock) Test(org.junit.Test)

Example 18 with Holder

use of javax.xml.ws.Holder in project java-chassis by ServiceComb.

the class VertxUtils method blockDeploy.

public static <VERTICLE extends AbstractVerticle> boolean blockDeploy(Vertx vertx, Class<VERTICLE> cls, DeploymentOptions options) throws InterruptedException {
    Holder<Boolean> result = new Holder<>();
    CountDownLatch latch = new CountDownLatch(1);
    vertx.deployVerticle(cls.getName(), options, ar -> {
        result.value = ar.succeeded();
        if (ar.failed()) {
            LOGGER.error("deploy vertx failed, cause ", ar.cause());
        }
        latch.countDown();
    });
    latch.await();
    return result.value;
}
Also used : Holder(javax.xml.ws.Holder) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 19 with Holder

use of javax.xml.ws.Holder in project java-chassis by ServiceComb.

the class TestHighwayServerConnection method testRequestError.

@Test
public void testRequestError() throws Exception {
    header.setMsgType(MsgType.REQUEST);
    Buffer headerBuffer = createBuffer(requestHeaderSchema, header);
    Buffer bodyBuffer = Buffer.buffer();
    Holder<Boolean> holder = new Holder<>(false);
    new MockUp<HighwayServerInvoke>() {

        @Mock
        public boolean init(NetSocket netSocket, long msgId, RequestHeader header, Buffer bodyBuffer) {
            return false;
        }
    };
    connection.handle(0, headerBuffer, bodyBuffer);
    Assert.assertEquals(null, connection.getProtocol());
    Assert.assertEquals(null, connection.getZipName());
    Assert.assertEquals(false, holder.value);
}
Also used : LinkedBuffer(io.protostuff.LinkedBuffer) Buffer(io.vertx.core.buffer.Buffer) NetSocket(io.vertx.core.net.NetSocket) Holder(javax.xml.ws.Holder) RequestHeader(io.servicecomb.transport.highway.message.RequestHeader) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 20 with Holder

use of javax.xml.ws.Holder in project java-chassis by ServiceComb.

the class ServiceRegistryClientImpl method unregisterMicroserviceInstance.

@Override
public boolean unregisterMicroserviceInstance(String microserviceId, String microserviceInstanceId) {
    Holder<HttpClientResponse> holder = new Holder<>();
    IpPort ipPort = IpPortManager.INSTANCE.get();
    StringBuilder url = new StringBuilder(Const.MS_API_PATH);
    url.append(Const.MICROSERVICE_PATH).append("/").append(microserviceId).append(Const.INSTANCES_PATH).append("/").append(microserviceInstanceId);
    CountDownLatch countDownLatch = new CountDownLatch(1);
    RestUtils.delete(ipPort, url.toString(), new RequestParam(), syncHandler(countDownLatch, HttpClientResponse.class, holder));
    try {
        countDownLatch.await();
        if (holder.value != null) {
            if (holder.value.statusCode() == Status.OK.getStatusCode()) {
                return true;
            }
            LOGGER.warn(holder.value.statusMessage());
        }
    } catch (Exception e) {
        LOGGER.error("unregister microservice instance {}/{} failed", microserviceId, microserviceInstanceId, e);
    }
    return false;
}
Also used : Holder(javax.xml.ws.Holder) HttpClientResponse(io.vertx.core.http.HttpClientResponse) IpPort(io.servicecomb.foundation.common.net.IpPort) CountDownLatch(java.util.concurrent.CountDownLatch) ClientException(io.servicecomb.serviceregistry.client.ClientException)

Aggregations

Holder (javax.xml.ws.Holder)129 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)77 Test (org.testng.annotations.Test)53 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)48 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)33 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)29 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)29 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)24 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)23 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)23 Test (org.junit.Test)23 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)21 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)19 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)18 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)16 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)15 CountDownLatch (java.util.concurrent.CountDownLatch)15 IpPort (io.servicecomb.foundation.common.net.IpPort)14 ClientException (io.servicecomb.serviceregistry.client.ClientException)14