com.sun.jersey.api.client.ClientResponse

Here are the examples of the java api com.sun.jersey.api.client.ClientResponse taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

602 Examples 7

19 Source : SessionTest.java
with Apache License 2.0
from zhao-baolin

private ZSession createSession(String expire) {
    WebResource wr = sessionsr.queryParam("op", "create").queryParam("expire", expire);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    ClientResponse cr = b.post(ClientResponse.clreplaced, null);
    replacedertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
    return cr.getEnreplacedy(ZSession.clreplaced);
}

19 Source : SessionTest.java
with Apache License 2.0
from zhao-baolin

@Test
public void testDeleteSession() {
    ZSession session = createSession("30");
    WebResource wr = sessionsr.path(session.id);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    replacedertTrue(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
    ClientResponse cr = b.delete(ClientResponse.clreplaced, null);
    replacedertEquals(ClientResponse.Status.NO_CONTENT, cr.getClientResponseStatus());
    replacedertFalse(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
}

19 Source : ITProcessGroupAccessControl.java
with Apache License 2.0
from wangrenlei

private void verifyDelete(final NiFiTestUser user, final String clientId, final int responseCode) throws Exception {
    final ProcessGroupEnreplacedy enreplacedy = createProcessGroup("Copy");
    // create the enreplacedy body
    final Map<String, String> queryParams = new HashMap<>();
    queryParams.put("version", String.valueOf(enreplacedy.getRevision().getVersion()));
    queryParams.put("clientId", clientId);
    // perform the request
    ClientResponse response = user.testDelete(enreplacedy.getUri(), queryParams);
    // ensure the request is failed with a forbidden status code
    replacedertEquals(responseCode, response.getStatus());
}

19 Source : ITProcessGroupAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the WRITE user can put a process group.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutProcessGroup() throws Exception {
    final ProcessGroupEnreplacedy enreplacedy = getRandomProcessGroup(helper.getWriteUser());
    replacedertFalse(enreplacedy.getPermissions().getCanRead());
    replacedertTrue(enreplacedy.getPermissions().getCanWrite());
    replacedertNull(enreplacedy.getComponent());
    final String updatedName = "Updated Name" + count++;
    // attempt to update the name
    final ProcessGroupDTO requestDto = new ProcessGroupDTO();
    requestDto.setId(enreplacedy.getId());
    requestDto.setName(updatedName);
    final long version = enreplacedy.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);
    final ProcessGroupEnreplacedy requestEnreplacedy = new ProcessGroupEnreplacedy();
    requestEnreplacedy.setId(enreplacedy.getId());
    requestEnreplacedy.setRevision(requestRevision);
    requestEnreplacedy.setComponent(requestDto);
    // perform the request
    final ClientResponse response = updateProcessGroup(helper.getWriteUser(), requestEnreplacedy);
    // ensure successful response
    replacedertEquals(200, response.getStatus());
    // get the response
    final ProcessGroupEnreplacedy responseEnreplacedy = response.getEnreplacedy(ProcessGroupEnreplacedy.clreplaced);
    // verify
    replacedertEquals(WRITE_CLIENT_ID, responseEnreplacedy.getRevision().getClientId());
    replacedertEquals(version + 1, responseEnreplacedy.getRevision().getVersion().longValue());
}

19 Source : ITProcessGroupAccessControl.java
with Apache License 2.0
from wangrenlei

private ProcessGroupEnreplacedy getRandomProcessGroup(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the process groups
    final ClientResponse response = user.testGet(url);
    // ensure the response was successful
    replacedertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEnreplacedy flowEnreplacedy = response.getEnreplacedy(ProcessGroupFlowEnreplacedy.clreplaced);
    final FlowDTO flowDto = flowEnreplacedy.getProcessGroupFlow().getFlow();
    final Set<ProcessGroupEnreplacedy> processGroups = flowDto.getProcessGroups();
    // ensure the correct number of process groups
    replacedertFalse(processGroups.isEmpty());
    // use the first process group as the target
    Iterator<ProcessGroupEnreplacedy> processGroupIter = processGroups.iterator();
    replacedertTrue(processGroupIter.hasNext());
    return processGroupIter.next();
}

19 Source : ITProcessGroupAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the READ user cannot put a processor.
 *
 * @throws Exception ex
 */
@Test
public void testReadUserPutProcessGroup() throws Exception {
    final ProcessGroupEnreplacedy enreplacedy = getRandomProcessGroup(helper.getReadUser());
    replacedertTrue(enreplacedy.getPermissions().getCanRead());
    replacedertFalse(enreplacedy.getPermissions().getCanWrite());
    replacedertNotNull(enreplacedy.getComponent());
    // attempt update the name
    enreplacedy.getRevision().setClientId(READ_CLIENT_ID);
    enreplacedy.getComponent().setName("Updated Name" + count++);
    // perform the request
    final ClientResponse response = updateProcessGroup(helper.getReadUser(), enreplacedy);
    // ensure forbidden response
    replacedertEquals(403, response.getStatus());
}

19 Source : ITProcessGroupAccessControl.java
with Apache License 2.0
from wangrenlei

private ProcessGroupEnreplacedy createProcessGroup(final String name) throws Exception {
    String url = helper.getBaseUrl() + "/process-groups/root/process-groups";
    final String updatedName = name + count++;
    // create the process group
    ProcessGroupDTO processor = new ProcessGroupDTO();
    processor.setName(updatedName);
    // create the revision
    final RevisionDTO revision = new RevisionDTO();
    revision.setClientId(READ_WRITE_CLIENT_ID);
    revision.setVersion(0L);
    // create the enreplacedy body
    ProcessGroupEnreplacedy enreplacedy = new ProcessGroupEnreplacedy();
    enreplacedy.setRevision(revision);
    enreplacedy.setComponent(processor);
    // perform the request
    ClientResponse response = helper.getReadWriteUser().testPost(url, enreplacedy);
    // ensure the request is successful
    replacedertEquals(201, response.getStatus());
    // get the enreplacedy body
    enreplacedy = response.getEnreplacedy(ProcessGroupEnreplacedy.clreplaced);
    // verify creation
    processor = enreplacedy.getComponent();
    replacedertEquals(updatedName, processor.getName());
    // get the processor
    return enreplacedy;
}

19 Source : ITProcessGroupAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the NONE user cannot put a process group.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserPutProcessGroup() throws Exception {
    final ProcessGroupEnreplacedy enreplacedy = getRandomProcessGroup(helper.getNoneUser());
    replacedertFalse(enreplacedy.getPermissions().getCanRead());
    replacedertFalse(enreplacedy.getPermissions().getCanWrite());
    replacedertNull(enreplacedy.getComponent());
    final String updatedName = "Updated Name" + count++;
    // attempt to update the name
    final ProcessGroupDTO requestDto = new ProcessGroupDTO();
    requestDto.setId(enreplacedy.getId());
    requestDto.setName(updatedName);
    final long version = enreplacedy.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);
    final ProcessGroupEnreplacedy requestEnreplacedy = new ProcessGroupEnreplacedy();
    requestEnreplacedy.setId(enreplacedy.getId());
    requestEnreplacedy.setRevision(requestRevision);
    requestEnreplacedy.setComponent(requestDto);
    // perform the request
    final ClientResponse response = updateProcessGroup(helper.getNoneUser(), requestEnreplacedy);
    // ensure forbidden response
    replacedertEquals(403, response.getStatus());
}

19 Source : ITOutputPortAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the WRITE user can put an output port.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutOutputPort() throws Exception {
    final PortEnreplacedy enreplacedy = getRandomOutputPort(helper.getWriteUser());
    replacedertFalse(enreplacedy.getPermissions().getCanRead());
    replacedertTrue(enreplacedy.getPermissions().getCanWrite());
    replacedertNull(enreplacedy.getComponent());
    final String updatedName = "Updated Name" + count++;
    // attempt to update the name
    final PortDTO requestDto = new PortDTO();
    requestDto.setId(enreplacedy.getId());
    requestDto.setName(updatedName);
    final long version = enreplacedy.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);
    final PortEnreplacedy requestEnreplacedy = new PortEnreplacedy();
    requestEnreplacedy.setId(enreplacedy.getId());
    requestEnreplacedy.setRevision(requestRevision);
    requestEnreplacedy.setComponent(requestDto);
    // perform the request
    final ClientResponse response = updateOutputPort(helper.getWriteUser(), requestEnreplacedy);
    // ensure successful response
    replacedertEquals(200, response.getStatus());
    // get the response
    final PortEnreplacedy responseEnreplacedy = response.getEnreplacedy(PortEnreplacedy.clreplaced);
    // verify
    replacedertEquals(WRITE_CLIENT_ID, responseEnreplacedy.getRevision().getClientId());
    replacedertEquals(version + 1, responseEnreplacedy.getRevision().getVersion().longValue());
}

19 Source : ITOutputPortAccessControl.java
with Apache License 2.0
from wangrenlei

private PortEnreplacedy getRandomOutputPort(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the output ports
    final ClientResponse response = user.testGet(url);
    // ensure the response was successful
    replacedertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEnreplacedy flowEnreplacedy = response.getEnreplacedy(ProcessGroupFlowEnreplacedy.clreplaced);
    final FlowDTO flowDto = flowEnreplacedy.getProcessGroupFlow().getFlow();
    final Set<PortEnreplacedy> outputPorts = flowDto.getOutputPorts();
    // ensure the correct number of output ports
    replacedertFalse(outputPorts.isEmpty());
    // use the first output port as the target
    Iterator<PortEnreplacedy> outputPorreplaceder = outputPorts.iterator();
    replacedertTrue(outputPorreplaceder.hasNext());
    return outputPorreplaceder.next();
}

19 Source : ITOutputPortAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the READ user cannot put an output port.
 *
 * @throws Exception ex
 */
@Test
public void testReadUserPutOutputPort() throws Exception {
    final PortEnreplacedy enreplacedy = getRandomOutputPort(helper.getReadUser());
    replacedertTrue(enreplacedy.getPermissions().getCanRead());
    replacedertFalse(enreplacedy.getPermissions().getCanWrite());
    replacedertNotNull(enreplacedy.getComponent());
    // attempt update the name
    enreplacedy.getRevision().setClientId(READ_CLIENT_ID);
    enreplacedy.getComponent().setName("Updated Name" + count++);
    // perform the request
    final ClientResponse response = updateOutputPort(helper.getReadUser(), enreplacedy);
    // ensure forbidden response
    replacedertEquals(403, response.getStatus());
}

19 Source : ITOutputPortAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the NONE user cannot put an output port.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserPutOutputPort() throws Exception {
    final PortEnreplacedy enreplacedy = getRandomOutputPort(helper.getNoneUser());
    replacedertFalse(enreplacedy.getPermissions().getCanRead());
    replacedertFalse(enreplacedy.getPermissions().getCanWrite());
    replacedertNull(enreplacedy.getComponent());
    final String updatedName = "Updated Name" + count++;
    // attempt to update the name
    final PortDTO requestDto = new PortDTO();
    requestDto.setId(enreplacedy.getId());
    requestDto.setName(updatedName);
    final long version = enreplacedy.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);
    final PortEnreplacedy requestEnreplacedy = new PortEnreplacedy();
    requestEnreplacedy.setId(enreplacedy.getId());
    requestEnreplacedy.setRevision(requestRevision);
    requestEnreplacedy.setComponent(requestDto);
    // perform the request
    final ClientResponse response = updateOutputPort(helper.getNoneUser(), requestEnreplacedy);
    // ensure forbidden response
    replacedertEquals(403, response.getStatus());
}

19 Source : ITLabelAccessControl.java
with Apache License 2.0
from wangrenlei

private LabelEnreplacedy getRandomLabel(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the labels
    final ClientResponse response = user.testGet(url);
    // ensure the response was successful
    replacedertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEnreplacedy flowEnreplacedy = response.getEnreplacedy(ProcessGroupFlowEnreplacedy.clreplaced);
    final FlowDTO flowDto = flowEnreplacedy.getProcessGroupFlow().getFlow();
    final Set<LabelEnreplacedy> labels = flowDto.getLabels();
    // ensure the correct number of labels
    replacedertFalse(labels.isEmpty());
    // use the first label as the target
    Iterator<LabelEnreplacedy> labelIter = labels.iterator();
    replacedertTrue(labelIter.hasNext());
    return labelIter.next();
}

19 Source : ITInputPortAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the NONE user cannot put an input port.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserPutInputPort() throws Exception {
    final PortEnreplacedy enreplacedy = getRandomInputPort(helper.getNoneUser());
    replacedertFalse(enreplacedy.getPermissions().getCanRead());
    replacedertFalse(enreplacedy.getPermissions().getCanWrite());
    replacedertNull(enreplacedy.getComponent());
    final String updatedName = "Updated Name" + count++;
    // attempt to update the name
    final PortDTO requestDto = new PortDTO();
    requestDto.setId(enreplacedy.getId());
    requestDto.setName(updatedName);
    final long version = enreplacedy.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);
    final PortEnreplacedy requestEnreplacedy = new PortEnreplacedy();
    requestEnreplacedy.setId(enreplacedy.getId());
    requestEnreplacedy.setRevision(requestRevision);
    requestEnreplacedy.setComponent(requestDto);
    // perform the request
    final ClientResponse response = updateInputPort(helper.getNoneUser(), requestEnreplacedy);
    // ensure forbidden response
    replacedertEquals(403, response.getStatus());
}

19 Source : ITInputPortAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the READ user cannot put an input port.
 *
 * @throws Exception ex
 */
@Test
public void testReadUserPutInputPort() throws Exception {
    final PortEnreplacedy enreplacedy = getRandomInputPort(helper.getReadUser());
    replacedertTrue(enreplacedy.getPermissions().getCanRead());
    replacedertFalse(enreplacedy.getPermissions().getCanWrite());
    replacedertNotNull(enreplacedy.getComponent());
    // attempt update the name
    enreplacedy.getRevision().setClientId(READ_CLIENT_ID);
    enreplacedy.getComponent().setName("Updated Name" + count++);
    // perform the request
    final ClientResponse response = updateInputPort(helper.getReadUser(), enreplacedy);
    // ensure forbidden response
    replacedertEquals(403, response.getStatus());
}

19 Source : ITInputPortAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the WRITE user can put an input port.
 *
 * @throws Exception ex
 */
@Test
public void testWriteUserPutInputPort() throws Exception {
    final PortEnreplacedy enreplacedy = getRandomInputPort(helper.getWriteUser());
    replacedertFalse(enreplacedy.getPermissions().getCanRead());
    replacedertTrue(enreplacedy.getPermissions().getCanWrite());
    replacedertNull(enreplacedy.getComponent());
    final String updatedName = "Updated Name" + count++;
    // attempt to update the name
    final PortDTO requestDto = new PortDTO();
    requestDto.setId(enreplacedy.getId());
    requestDto.setName(updatedName);
    final long version = enreplacedy.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.WRITE_CLIENT_ID);
    final PortEnreplacedy requestEnreplacedy = new PortEnreplacedy();
    requestEnreplacedy.setId(enreplacedy.getId());
    requestEnreplacedy.setRevision(requestRevision);
    requestEnreplacedy.setComponent(requestDto);
    // perform the request
    final ClientResponse response = updateInputPort(helper.getWriteUser(), requestEnreplacedy);
    // ensure successful response
    replacedertEquals(200, response.getStatus());
    // get the response
    final PortEnreplacedy responseEnreplacedy = response.getEnreplacedy(PortEnreplacedy.clreplaced);
    // verify
    replacedertEquals(WRITE_CLIENT_ID, responseEnreplacedy.getRevision().getClientId());
    replacedertEquals(version + 1, responseEnreplacedy.getRevision().getVersion().longValue());
}

19 Source : ITFunnelAccessControl.java
with Apache License 2.0
from wangrenlei

private FunnelEnreplacedy createFunnel() throws Exception {
    String url = helper.getBaseUrl() + "/process-groups/root/funnels";
    // create the funnel
    FunnelDTO funnel = new FunnelDTO();
    // create the revision
    final RevisionDTO revision = new RevisionDTO();
    revision.setClientId(READ_WRITE_CLIENT_ID);
    revision.setVersion(0L);
    // create the enreplacedy body
    FunnelEnreplacedy enreplacedy = new FunnelEnreplacedy();
    enreplacedy.setRevision(revision);
    enreplacedy.setComponent(funnel);
    // perform the request
    ClientResponse response = helper.getReadWriteUser().testPost(url, enreplacedy);
    // ensure the request is successful
    replacedertEquals(201, response.getStatus());
    // get the enreplacedy body
    return response.getEnreplacedy(FunnelEnreplacedy.clreplaced);
}

19 Source : ITFunnelAccessControl.java
with Apache License 2.0
from wangrenlei

/**
 * Ensures the NONE user cannot put a funnel.
 *
 * @throws Exception ex
 */
@Test
public void testNoneUserPutFunnel() throws Exception {
    final FunnelEnreplacedy enreplacedy = getRandomFunnel(helper.getNoneUser());
    replacedertFalse(enreplacedy.getPermissions().getCanRead());
    replacedertFalse(enreplacedy.getPermissions().getCanWrite());
    replacedertNull(enreplacedy.getComponent());
    // attempt to update the position
    final FunnelDTO requestDto = new FunnelDTO();
    requestDto.setId(enreplacedy.getId());
    requestDto.setPosition(new PositionDTO(0.0, 15.0));
    final long version = enreplacedy.getRevision().getVersion();
    final RevisionDTO requestRevision = new RevisionDTO();
    requestRevision.setVersion(version);
    requestRevision.setClientId(AccessControlHelper.NONE_CLIENT_ID);
    final FunnelEnreplacedy requestEnreplacedy = new FunnelEnreplacedy();
    requestEnreplacedy.setId(enreplacedy.getId());
    requestEnreplacedy.setRevision(requestRevision);
    requestEnreplacedy.setComponent(requestDto);
    // perform the request
    final ClientResponse response = updateFunnel(helper.getNoneUser(), requestEnreplacedy);
    // ensure forbidden response
    replacedertEquals(403, response.getStatus());
}

19 Source : ITFunnelAccessControl.java
with Apache License 2.0
from wangrenlei

private FunnelEnreplacedy getRandomFunnel(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the flow
    final ClientResponse response = user.testGet(url);
    // ensure the response was successful
    replacedertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEnreplacedy flowEnreplacedy = response.getEnreplacedy(ProcessGroupFlowEnreplacedy.clreplaced);
    final FlowDTO flowDto = flowEnreplacedy.getProcessGroupFlow().getFlow();
    final Set<FunnelEnreplacedy> funnels = flowDto.getFunnels();
    // ensure the correct number of funnels
    replacedertFalse(funnels.isEmpty());
    // use the first funnel as the target
    Iterator<FunnelEnreplacedy> funnelIter = funnels.iterator();
    replacedertTrue(funnelIter.hasNext());
    return funnelIter.next();
}

19 Source : RepositoryCleanupUtil.java
with Apache License 2.0
from tlw-ray

/**
 * Create parameters and send HTTP request to purge REST endpoint
 *
 * @param options
 */
public void purge(String[] options) {
    FormDataMultiPart form = null;
    try {
        Map<String, String> parameters = parseExecutionOptions(options);
        validateParameters(parameters);
        authenticateLoginCredentials();
        String serviceURL = createPurgeServiceURL();
        form = createParametersForm();
        WebResource resource = client.resource(serviceURL);
        ClientResponse response = resource.type(MediaType.MULTIPART_FORM_DATA).post(ClientResponse.clreplaced, form);
        if (response != null && response.getStatus() == 200) {
            String resultLog = response.getEnreplacedy(String.clreplaced);
            String logName = writeLog(resultLog);
            writeOut(Messages.getInstance().getString("REPOSITORY_CLEANUP_UTIL.INFO_0001.OP_SUCCESS", logName), false);
        } else {
            writeOut(Messages.getInstance().getString("REPOSITORY_CLEANUP_UTIL.ERROR_0001.OP_FAILURE"), true);
        }
    } catch (Exception e) {
        if (e.getMessage() != null) {
            System.out.println(e.getMessage());
        } else {
            if (!(e instanceof NormalExitException)) {
                e.printStackTrace();
            }
        }
    } finally {
        if (client != null) {
            client.destroy();
        }
        if (form != null) {
            form.cleanup();
        }
    }
}

19 Source : Rest.java
with Apache License 2.0
from tlw-ray

protected MultivaluedMap<String, String> searchForHeaders(ClientResponse response) {
    return response.getHeaders();
}

19 Source : HttpClientResponse.java
with MIT License
from spring2go

/**
 * A NIWS   Client Response
 * (this version just wraps Jersey Client response)
 * @author stonse
 */
clreplaced HttpClientResponse implements HttpResponse {

    private ClientResponse bcr = null;

    // the request url that got this response
    private URI requestedURI;

    private Multimap<String, String> headers = ArrayListMultimap.<String, String>create();

    public HttpClientResponse(ClientResponse cr) {
        bcr = cr;
        for (Map.Entry<String, List<String>> entry : bcr.getHeaders().entrySet()) {
            if (entry.getKey() != null && entry.getValue() != null) {
                headers.putAll(entry.getKey(), entry.getValue());
            }
        }
    }

    /**
     * Returns the raw enreplacedy if available from the response
     * @return
     * @throws IllegalArgumentException
     * @throws ClientException
     */
    public InputStream getRawEnreplacedy() throws ClientException {
        return bcr.getEnreplacedyInputStream();
    }

    public <T> T getEnreplacedy(Clreplaced<T> c) throws Exception {
        T t = null;
        try {
            t = this.bcr.getEnreplacedy(c);
        } catch (UniformInterfaceException e) {
            throw new ClientException(ClientException.ErrorType.GENERAL, e.getMessage(), e.getCause());
        }
        return t;
    }

    @Override
    public Map<String, Collection<String>> getHeaders() {
        return headers.asMap();
    }

    public int getStatus() {
        return bcr.getStatus();
    }

    @Override
    public boolean isSuccess() {
        boolean isSuccess = false;
        ClientResponse.Status s = bcr != null ? bcr.getClientResponseStatus() : null;
        isSuccess = s != null ? (s.getFamily() == javax.ws.rs.core.Response.Status.Family.SUCCESSFUL) : false;
        return isSuccess;
    }

    public boolean hasEnreplacedy() {
        return bcr.hasEnreplacedy();
    }

    @Override
    public URI getRequestedURI() {
        return this.requestedURI;
    }

    public void setRequestedURI(URI requestedURI) {
        this.requestedURI = requestedURI;
    }

    @Override
    public Object getPayload() throws ClientException {
        if (hasEnreplacedy()) {
            return getRawEnreplacedy();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasPayload() {
        return hasEnreplacedy();
    }

    public ClientResponse getJerseyClientResponse() {
        return bcr;
    }

    @Override
    public void close() {
        bcr.close();
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T> T getEnreplacedy(TypeToken<T> type) throws Exception {
        return (T) getEnreplacedy(type.getRawType());
    }

    @Override
    public InputStream getInputStream() throws ClientException {
        return getRawEnreplacedy();
    }
}

19 Source : SessionTest.java
with Apache License 2.0
from sereca

@Test
public void testDeleteSession() {
    ZSession session = createSession("30");
    WebResource wr = sessionsr.path(session.id);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    replacedert.replacedertTrue(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
    ClientResponse cr = b.delete(ClientResponse.clreplaced, null);
    replacedert.replacedertEquals(ClientResponse.Status.NO_CONTENT, cr.getClientResponseStatus());
    replacedert.replacedertFalse(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
}

19 Source : SessionTest.java
with Apache License 2.0
from sereca

private ZSession createSession(String expire) {
    WebResource wr = sessionsr.queryParam("op", "create").queryParam("expire", expire);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    ClientResponse cr = b.post(ClientResponse.clreplaced, null);
    replacedert.replacedertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
    return cr.getEnreplacedy(ZSession.clreplaced);
}

19 Source : UserPermissionITCase.java
with MIT License
from scm-manager

@Override
protected void checkGetAllResponse(ClientResponse response) {
    replacedume.replacedumeTrue(credentials.getUsername() == null);
    if (!credentials.isAnonymous()) {
        replacedertNotNull(response);
        replacedert.replacedertEquals(200, response.getStatus());
        HalRepresentation repositories = null;
        try {
            repositories = new ObjectMapperProvider().get().readValue(response.getEnreplacedy(String.clreplaced), HalRepresentation.clreplaced);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        replacedertNotNull(repositories);
        replacedertTrue(repositories.getEmbedded().gereplacedemsBy("users").isEmpty());
        response.close();
    }
}

19 Source : RepositorySimplePermissionITCase.java
with MIT License
from scm-manager

/**
 * Method description
 *
 * @param response
 */
@Override
protected void checkGetAllResponse(ClientResponse response) {
    if (!credentials.isAnonymous()) {
        replacedertNotNull(response);
        replacedert.replacedertEquals(200, response.getStatus());
        HalRepresentation repositories = null;
        try {
            repositories = new ObjectMapperProvider().get().readValue(response.getEnreplacedy(String.clreplaced), HalRepresentation.clreplaced);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        replacedertNotNull(repositories);
        replacedertTrue(repositories.getEmbedded().gereplacedemsBy("repositories").isEmpty());
        response.close();
    }
}

19 Source : RepositorySimplePermissionITCase.java
with MIT License
from scm-manager

/**
 * Method description
 *
 * @param response
 */
@Override
protected void checkGetResponse(ClientResponse response) {
    if (!credentials.isAnonymous()) {
        replacedertNotNull(response);
        replacedert.replacedertEquals(403, response.getStatus());
        response.close();
    }
}

19 Source : RepositoryITUtil.java
with MIT License
from scm-manager

public static RepositoryDto getRepository(ScmClient client, URI url) {
    WebResource.Builder wr = createResource(client, url);
    ClientResponse response = wr.get(ClientResponse.clreplaced);
    replacedertNotNull(response);
    replacedert.replacedertEquals(200, response.getStatus());
    String json = response.getEnreplacedy(String.clreplaced);
    RepositoryDto repository = null;
    try {
        repository = new ObjectMapperProvider().get().readerFor(RepositoryDto.clreplaced).readValue(json);
    } catch (IOException e) {
        fail("could not read json:\n" + json);
    }
    response.close();
    replacedertNotNull(repository);
    return repository;
}

19 Source : RepositoryITUtil.java
with MIT License
from scm-manager

public static void deleteRepository(ScmClient client, RepositoryDto repository) {
    URI deleteUrl = getLink(repository, "delete");
    ClientResponse response = createResource(client, deleteUrl).delete(ClientResponse.clreplaced);
    replacedertNotNull(response);
    replacedert.replacedertEquals(204, response.getStatus());
    response.close();
    URI selfUrl = getLink(repository, "self");
    response = createResource(client, selfUrl).get(ClientResponse.clreplaced);
    replacedertNotNull(response);
    replacedert.replacedertEquals(404, response.getStatus());
    response.close();
}

19 Source : AbstractPermissionITCaseBase.java
with MIT License
from scm-manager

/**
 * Method description
 *
 * @param response
 */
protected void checkGetResponse(ClientResponse response) {
    checkResponse(response);
}

19 Source : AbstractPermissionITCaseBase.java
with MIT License
from scm-manager

// ~--- methods --------------------------------------------------------------
/**
 * Method description
 *
 * @param response
 */
protected void checkGetAllResponse(ClientResponse response) {
    checkResponse(response);
}

19 Source : RequestLogger.java
with MIT License
from qmetry

private void printResponseLine(StringBuilder b, long id, ClientResponse response) {
    prefixId(b, id).append(NOTIFICATION_PREFIX).append("Client in-bound response").append("\n");
    prefixId(b, id).append(RESPONSE_PREFIX).append(Integer.toString(response.getStatus())).append("\n");
}

19 Source : ApiClient.java
with Apache License 2.0
from OpenAPITools

/**
 * Invoke API by sending HTTP request with the given options.
 *
 * @param <T> Type
 * @param path The sub-path of the HTTP URL
 * @param method The request method, one of "GET", "POST", "PUT", and "DELETE"
 * @param queryParams The query parameters
 * @param collectionQueryParams The collection query parameters
 * @param body The request body object - if it is not binary, otherwise null
 * @param headerParams The header parameters
 * @param cookieParams The cookie parameters
 * @param formParams The form parameters
 * @param accept The request's Accept header
 * @param contentType The request's Content-Type header
 * @param authNames The authentications to apply
 * @param returnType Return type
 * @return The response body in type of string
 * @throws ApiException API exception
 */
public <T> T invokeAPI(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames, GenericType<T> returnType) throws ApiException {
    ClientResponse response = getAPIResponse(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames);
    statusCode = response.getStatusInfo().getStatusCode();
    responseHeaders = response.getHeaders();
    if (response.getStatusInfo().getStatusCode() == ClientResponse.Status.NO_CONTENT.getStatusCode()) {
        return null;
    } else if (response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
        if (returnType == null)
            return null;
        else
            return response.getEnreplacedy(returnType);
    } else {
        String message = "error";
        String respBody = null;
        if (response.hasEnreplacedy()) {
            try {
                respBody = response.getEnreplacedy(String.clreplaced);
                message = respBody;
            } catch (RuntimeException e) {
            // e.printStackTrace();
            }
        }
        throw new ApiException(response.getStatusInfo().getStatusCode(), message, response.getHeaders(), respBody);
    }
}

19 Source : ApiClient.java
with Apache License 2.0
from OpenAPITools

private ClientResponse getAPIResponse(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String accept, String contentType, String[] authNames) throws ApiException {
    if (body != null && !formParams.isEmpty()) {
        throw new ApiException(500, "Cannot have body and form params");
    }
    updateParamsForAuth(authNames, queryParams, headerParams, cookieParams);
    final String url = buildUrl(path, queryParams, collectionQueryParams);
    Builder builder;
    if (accept == null) {
        builder = httpClient.resource(url).getRequestBuilder();
    } else {
        builder = httpClient.resource(url).accept(accept);
    }
    for (Entry<String, String> keyValue : headerParams.entrySet()) {
        builder = builder.header(keyValue.getKey(), keyValue.getValue());
    }
    for (Map.Entry<String, String> keyValue : defaultHeaderMap.entrySet()) {
        if (!headerParams.containsKey(keyValue.getKey())) {
            builder = builder.header(keyValue.getKey(), keyValue.getValue());
        }
    }
    for (Entry<String, String> keyValue : cookieParams.entrySet()) {
        builder = builder.cookie(new Cookie(keyValue.getKey(), keyValue.getValue()));
    }
    for (Map.Entry<String, String> keyValue : defaultCookieMap.entrySet()) {
        if (!cookieParams.containsKey(keyValue.getKey())) {
            builder = builder.cookie(new Cookie(keyValue.getKey(), keyValue.getValue()));
        }
    }
    ClientResponse response = null;
    if ("GET".equals(method)) {
        response = (ClientResponse) builder.get(ClientResponse.clreplaced);
    } else if ("POST".equals(method)) {
        response = builder.type(contentType).post(ClientResponse.clreplaced, serialize(body, contentType, formParams));
    } else if ("PUT".equals(method)) {
        response = builder.type(contentType).put(ClientResponse.clreplaced, serialize(body, contentType, formParams));
    } else if ("DELETE".equals(method)) {
        response = builder.type(contentType).delete(ClientResponse.clreplaced, serialize(body, contentType, formParams));
    } else if ("PATCH".equals(method)) {
        response = builder.type(contentType).header("X-HTTP-Method-Override", "PATCH").post(ClientResponse.clreplaced, serialize(body, contentType, formParams));
    } else if ("HEAD".equals(method)) {
        response = builder.head();
    } else {
        throw new ApiException(500, "unknown method type " + method);
    }
    return response;
}

19 Source : TestRMWebServicesAppsModification.java
with Apache License 2.0
from NJUJYB

protected String testGetNewApplication(String mediaType) throws JSONException, ParserConfigurationException, IOException, SAXException {
    ClientResponse response = this.constructWebResource("apps", "new-application").accept(mediaType).post(ClientResponse.clreplaced);
    validateResponseStatus(response, Status.OK);
    if (!isAuthenticationEnabled()) {
        return "";
    }
    return validateGetNewApplicationResponse(response);
}

19 Source : TestRMWebServicesAppsModification.java
with Apache License 2.0
from NJUJYB

/**
 * Helper function to wrap frequently used code. It checks the response status
 * and checks if it is the param expectedUnauthorizedMode if we are running
 * with authorization turned off or the param expectedAuthorizedMode preplaceded if
 * we are running with authorization turned on.
 *
 * @param response
 *          the ClientResponse object to be checked
 * @param expectedUnauthorizedMode
 *          the expected Status in unauthorized mode.
 * @param expectedAuthorizedMode
 *          the expected Status in authorized mode.
 */
public void validateResponseStatus(ClientResponse response, Status expectedUnauthorizedMode, Status expectedAuthorizedMode) {
    if (!isAuthenticationEnabled()) {
        replacedertEquals(expectedUnauthorizedMode, response.getClientResponseStatus());
    } else {
        replacedertEquals(expectedAuthorizedMode, response.getClientResponseStatus());
    }
}

19 Source : TestRMWebServicesAppsModification.java
with Apache License 2.0
from NJUJYB

/**
 * Helper function to wrap frequently used code. It checks the response status
 * and checks if it UNAUTHORIZED if we are running with authorization turned
 * off or the param preplaceded if we are running with authorization turned on.
 *
 * @param response
 *          the ClientResponse object to be checked
 * @param expectedAuthorizedMode
 *          the expected Status in authorized mode.
 */
public void validateResponseStatus(ClientResponse response, Status expectedAuthorizedMode) {
    validateResponseStatus(response, Status.UNAUTHORIZED, expectedAuthorizedMode);
}

19 Source : TestRMWebServices.java
with Apache License 2.0
from NJUJYB

@Test
public void testInvalidAccept() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
        responseStr = r.path("ws").path("v1").path("cluster").accept(MediaType.TEXT_PLAIN).get(String.clreplaced);
        fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
        ClientResponse response = ue.getResponse();
        replacedertEquals(Status.INTERNAL_SERVER_ERROR, response.getClientResponseStatus());
        WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
    }
}

19 Source : TestNMWebServices.java
with Apache License 2.0
from NJUJYB

@Test
public void testInvalidAccept() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
        responseStr = r.path("ws").path("v1").path("node").accept(MediaType.TEXT_PLAIN).get(String.clreplaced);
        fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
        ClientResponse response = ue.getResponse();
        replacedertEquals(Status.INTERNAL_SERVER_ERROR, response.getClientResponseStatus());
        WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
    }
}

19 Source : TestAHSWebServices.java
with Apache License 2.0
from NJUJYB

@Test
public void testInvalidAccept() throws JSONException, Exception {
    WebResource r = resource();
    String responseStr = "";
    try {
        responseStr = r.path("ws").path("v1").path("applicationhistory").queryParam("user.name", USERS[round]).accept(MediaType.TEXT_PLAIN).get(String.clreplaced);
        fail("should have thrown exception on invalid uri");
    } catch (UniformInterfaceException ue) {
        ClientResponse response = ue.getResponse();
        replacedertEquals(Status.INTERNAL_SERVER_ERROR, response.getClientResponseStatus());
        WebServicesTestUtils.checkStringMatch("error string exists and shouldn't", "", responseStr);
    }
}

19 Source : TestTimelineClient.java
with Apache License 2.0
from NJUJYB

private static ClientResponse mockEnreplacedyClientResponse(TimelineClientImpl client, ClientResponse.Status status, boolean hasError, boolean hasRuntimeError) {
    ClientResponse response = mock(ClientResponse.clreplaced);
    if (hasRuntimeError) {
        doThrow(new ClientHandlerException(new ConnectException())).when(client).doPostingObject(any(TimelineEnreplacedies.clreplaced), any(String.clreplaced));
        return response;
    }
    doReturn(response).when(client).doPostingObject(any(TimelineEnreplacedies.clreplaced), any(String.clreplaced));
    when(response.getClientResponseStatus()).thenReturn(status);
    TimelinePutResponse.TimelinePutError error = new TimelinePutResponse.TimelinePutError();
    error.setEnreplacedyId("test enreplacedy id");
    error.setEnreplacedyType("test enreplacedy type");
    error.setErrorCode(TimelinePutResponse.TimelinePutError.IO_EXCEPTION);
    TimelinePutResponse putResponse = new TimelinePutResponse();
    if (hasError) {
        putResponse.addError(error);
    }
    when(response.getEnreplacedy(TimelinePutResponse.clreplaced)).thenReturn(putResponse);
    return response;
}

19 Source : TestTimelineClient.java
with Apache License 2.0
from NJUJYB

private static ClientResponse mockDomainClientResponse(TimelineClientImpl client, ClientResponse.Status status, boolean hasRuntimeError) {
    ClientResponse response = mock(ClientResponse.clreplaced);
    if (hasRuntimeError) {
        doThrow(new ClientHandlerException(new ConnectException())).when(client).doPostingObject(any(TimelineDomain.clreplaced), any(String.clreplaced));
        return response;
    }
    doReturn(response).when(client).doPostingObject(any(TimelineDomain.clreplaced), any(String.clreplaced));
    when(response.getClientResponseStatus()).thenReturn(status);
    return response;
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryFinishTimeBegin() throws JSONException, Exception {
    WebResource r = resource();
    // the mockJobs finish time is the current time + some random amount
    Long now = System.currentTimeMillis();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("finishedTimeBegin", String.valueOf(now)).accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
    replacedertEquals("incorrect number of elements", 1, json.length());
    JSONObject jobs = json.getJSONObject("jobs");
    JSONArray arr = jobs.getJSONArray("job");
    replacedertEquals("incorrect number of elements", 3, arr.length());
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryStartTimeEnd() throws JSONException, Exception {
    WebResource r = resource();
    // the mockJobs start time is the current time - some random amount
    Long now = System.currentTimeMillis();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("startedTimeEnd", String.valueOf(now)).accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
    replacedertEquals("incorrect number of elements", 1, json.length());
    JSONObject jobs = json.getJSONObject("jobs");
    JSONArray arr = jobs.getJSONArray("job");
    replacedertEquals("incorrect number of elements", 3, arr.length());
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryFinishTimeInvalidformat() throws JSONException, Exception {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("finishedTimeBegin", "efsd").accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
    JSONObject exception = msg.getJSONObject("RemoteException");
    replacedertEquals("incorrect number of elements", 3, exception.length());
    String message = exception.getString("message");
    String type = exception.getString("exception");
    String clreplacedname = exception.getString("javaClreplacedName");
    WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: Invalid number format: For input string: \"efsd\"", message);
    WebServicesTestUtils.checkStringMatch("exception type", "BadRequestException", type);
    WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.BadRequestException", clreplacedname);
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryStartTimeBegin() throws JSONException, Exception {
    WebResource r = resource();
    // the mockJobs start time is the current time - some random amount
    Long now = System.currentTimeMillis();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("startedTimeBegin", String.valueOf(now)).accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
    replacedertEquals("incorrect number of elements", 1, json.length());
    replacedertEquals("jobs is not null", JSONObject.NULL, json.get("jobs"));
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryFinishTimeBeginNegative() throws JSONException, Exception {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("finishedTimeBegin", String.valueOf(-1000)).accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
    JSONObject exception = msg.getJSONObject("RemoteException");
    replacedertEquals("incorrect number of elements", 3, exception.length());
    String message = exception.getString("message");
    String type = exception.getString("exception");
    String clreplacedname = exception.getString("javaClreplacedName");
    WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: finishedTimeBegin must be greater than 0", message);
    WebServicesTestUtils.checkStringMatch("exception type", "BadRequestException", type);
    WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.BadRequestException", clreplacedname);
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryStartTimeInvalidformat() throws JSONException, Exception {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("startedTimeBegin", "efsd").accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
    JSONObject exception = msg.getJSONObject("RemoteException");
    replacedertEquals("incorrect number of elements", 3, exception.length());
    String message = exception.getString("message");
    String type = exception.getString("exception");
    String clreplacedname = exception.getString("javaClreplacedName");
    WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: Invalid number format: For input string: \"efsd\"", message);
    WebServicesTestUtils.checkStringMatch("exception type", "BadRequestException", type);
    WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.BadRequestException", clreplacedname);
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryLimitInvalid() throws JSONException, Exception {
    WebResource r = resource();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("limit", "-1").accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject msg = response.getEnreplacedy(JSONObject.clreplaced);
    JSONObject exception = msg.getJSONObject("RemoteException");
    replacedertEquals("incorrect number of elements", 3, exception.length());
    String message = exception.getString("message");
    String type = exception.getString("exception");
    String clreplacedname = exception.getString("javaClreplacedName");
    WebServicesTestUtils.checkStringMatch("exception message", "java.lang.Exception: limit value must be greater then 0", message);
    WebServicesTestUtils.checkStringMatch("exception type", "BadRequestException", type);
    WebServicesTestUtils.checkStringMatch("exception clreplacedname", "org.apache.hadoop.yarn.webapp.BadRequestException", clreplacedname);
}

19 Source : TestHsWebServicesJobsQuery.java
with Apache License 2.0
from NJUJYB

@Test
public void testJobsQueryFinishTimeEnd() throws JSONException, Exception {
    WebResource r = resource();
    // the mockJobs finish time is the current time + some random amount
    Long now = System.currentTimeMillis();
    ClientResponse response = r.path("ws").path("v1").path("history").path("mapreduce").path("jobs").queryParam("finishedTimeEnd", String.valueOf(now)).accept(MediaType.APPLICATION_JSON).get(ClientResponse.clreplaced);
    replacedertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEnreplacedy(JSONObject.clreplaced);
    replacedertEquals("incorrect number of elements", 1, json.length());
    replacedertEquals("jobs is not null", JSONObject.NULL, json.get("jobs"));
}

See More Examples