Package org.cloudfoundry.client.lib.domain

Examples of org.cloudfoundry.client.lib.domain.CloudResources


    @Test
    public void shouldPackOnlyMissingResources() throws Exception {
        ZipFile zipFile = new ZipFile(SampleProjects.springTravel());
        try {
            ApplicationArchive archive = new ZipApplicationArchive(zipFile);
            CloudResources allResources = new CloudResources(archive);
            List<CloudResource> resources = new ArrayList<CloudResource>(allResources.asList());
            resources.remove(0);
            CloudResources knownRemoteResources = new CloudResources(resources);
            UploadApplicationPayload payload = new UploadApplicationPayload(archive, knownRemoteResources);
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            FileCopyUtils.copy(payload.getInputStream(), bos);
            assertThat(payload.getArchive(), is(archive));
            assertThat(payload.getTotalUncompressedSize(), is(93));
View Full Code Here


    private ObjectMapper mapper = new ObjectMapper();

    @Test
    public void shouldSerialize() throws Exception {
        CloudResource r = new CloudResource("index.html", 93L, SHA);
        CloudResources o = new CloudResources(Collections.singleton(r));
        String s = mapper.writeValueAsString(o);
        assertThat(s, is(equalTo(JSON)));
    }
View Full Code Here

        assertThat(s, is(equalTo(JSON)));
    }

    @Test
    public void shouldDeserialize() throws JsonParseException, JsonMappingException, IOException {
        CloudResources o = mapper.readValue(JSON, CloudResources.class);
        List<CloudResource> l = o.asList();
        assertThat(l.size(), is(1));
        CloudResource r = l.get(0);
        assertThat(r.getFilename(), is("index.html"));
        assertThat(r.getSha1(), is(SHA));
        assertThat(r.getSize(), is(93L));
View Full Code Here

    }

    @Test
    public void shouldCreateFromIterator() throws Exception {
        Iterator<? extends CloudResource> i = Collections.singleton(new CloudResource("index.html", 93L, SHA)).iterator();
        CloudResources o = new CloudResources(i);
        List<CloudResource> l = o.asList();
        assertThat(l.size(), is(1));
        CloudResource r = l.get(0);
        assertThat(r.getFilename(), is("index.html"));
        assertThat(r.getSha1(), is(SHA));
        assertThat(r.getSize(), is(93L));
View Full Code Here

    @Test
    public void shouldGetFromArchive() throws Exception {
        ZipFile zipFile = new ZipFile(SampleProjects.springTravel());
        try {
            ApplicationArchive archive = new ZipApplicationArchive(zipFile);
            CloudResources o = new CloudResources(archive);
            List<CloudResource> l = o.asList();
            assertThat(l.size(), is(96));
            assertThat(l.get(0).getFilename(), is("index.html"));
        } finally {
            zipFile.close();
        }
View Full Code Here

    @Test
    public void shouldGetFilenames() throws Exception {
        List<CloudResource> resources = new ArrayList<CloudResource>();
        resources.add(new CloudResource("1", 93L, SHA));
        resources.add(new CloudResource("2", 93L, SHA));
        CloudResources o = new CloudResources(resources);
        Set<String> expected = new HashSet<String>(Arrays.asList("1", "2"));
        assertThat(o.getFilenames(), is(expected));
    }
View Full Code Here

    UUID appId = getAppId(appName);

    if (callback == null) {
      callback = UploadStatusCallback.NONE;
    }
    CloudResources knownRemoteResources = getKnownRemoteResources(archive);
    callback.onCheckResources();
    callback.onMatchedFileNames(knownRemoteResources.getFilenames());
    UploadApplicationPayload payload = new UploadApplicationPayload(archive, knownRemoteResources);
    callback.onProcessMatchedResources(payload.getTotalUncompressedSize());
    HttpEntity<?> entity = generatePartialResourceRequest(payload, knownRemoteResources);
    ResponseEntity<Map<String,Map<String,String>>> responseEntity =
                getRestTemplate().exchange(getUrl("/v2/apps/{guid}/bits?async=true"), HttpMethod.PUT, entity,
View Full Code Here

      jobEntity = jobProgressEntity.getBody().get("entity");
    } while (!jobStatus.equals("finished"));
  }

  private CloudResources getKnownRemoteResources(ApplicationArchive archive) throws IOException {
    CloudResources archiveResources = new CloudResources(archive);
    String json = JsonUtil.convertToJson(archiveResources);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(JsonUtil.JSON_MEDIA_TYPE);
    HttpEntity<String> requestEntity = new HttpEntity<String>(json, headers);
    ResponseEntity<String> responseEntity =
      getRestTemplate().exchange(getUrl("/v2/resource_match"), HttpMethod.PUT, requestEntity, String.class);
    List<CloudResource> cloudResources = JsonUtil.convertJsonToCloudResourceList(responseEntity.getBody());
    return new CloudResources(cloudResources);
  }
View Full Code Here

TOP

Related Classes of org.cloudfoundry.client.lib.domain.CloudResources

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.