Search in sources :

Example 1 with ResourceUtils

use of org.cloudfoundry.util.ResourceUtils in project cf-java-client by cloudfoundry.

the class BuildpacksTest method uploadDirectory.

@Test
public void uploadDirectory() throws IOException {
    Path buildpack = new ClassPathResource("test-buildpack").getFile().toPath();
    String buildpackName = this.nameFactory.getBuildpackName();
    String filename = buildpack.getFileName().toString();
    createBuildpackId(this.cloudFoundryClient, buildpackName).flatMap(buildpackId -> this.cloudFoundryClient.buildpacks().upload(UploadBuildpackRequest.builder().buildpack(buildpack).buildpackId(buildpackId).filename(filename).build())).map(ResourceUtils::getEntity).as(StepVerifier::create).expectNext(BuildpackEntity.builder().enabled(false).filename(filename + ".zip").locked(false).name(buildpackName).position(3).build()).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : Path(java.nio.file.Path) StepVerifier(reactor.test.StepVerifier) CreateBuildpackResponse(org.cloudfoundry.client.v2.buildpacks.CreateBuildpackResponse) UploadBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.UploadBuildpackRequest) ClassPathResource(org.springframework.core.io.ClassPathResource) CreateBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.CreateBuildpackRequest) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) ResourceUtils(org.cloudfoundry.util.ResourceUtils) BuildpackResource(org.cloudfoundry.client.v2.buildpacks.BuildpackResource) DeleteBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.DeleteBuildpackRequest) Flux(reactor.core.publisher.Flux) BuildpackEntity(org.cloudfoundry.client.v2.buildpacks.BuildpackEntity) UpdateBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.UpdateBuildpackRequest) ListBuildpacksRequest(org.cloudfoundry.client.v2.buildpacks.ListBuildpacksRequest) CloudFoundryClient(org.cloudfoundry.client.CloudFoundryClient) JobUtils(org.cloudfoundry.util.JobUtils) Duration(java.time.Duration) GetBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.GetBuildpackRequest) PaginationUtils(org.cloudfoundry.util.PaginationUtils) Path(java.nio.file.Path) ResourceUtils(org.cloudfoundry.util.ResourceUtils) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with ResourceUtils

use of org.cloudfoundry.util.ResourceUtils in project cf-java-client by cloudfoundry.

the class BuildpacksTest method upload.

@Test
public void upload() throws IOException {
    Path buildpack = new ClassPathResource("test-buildpack.zip").getFile().toPath();
    String buildpackName = this.nameFactory.getBuildpackName();
    createBuildpackId(this.cloudFoundryClient, buildpackName).flatMap(buildpackId -> this.cloudFoundryClient.buildpacks().upload(UploadBuildpackRequest.builder().buildpack(buildpack).buildpackId(buildpackId).filename(buildpack.getFileName().toString()).build())).map(ResourceUtils::getEntity).as(StepVerifier::create).expectNext(BuildpackEntity.builder().enabled(false).filename(buildpack.getFileName().toString()).locked(false).name(buildpackName).position(3).build()).expectComplete().verify(Duration.ofMinutes(5));
}
Also used : Path(java.nio.file.Path) StepVerifier(reactor.test.StepVerifier) CreateBuildpackResponse(org.cloudfoundry.client.v2.buildpacks.CreateBuildpackResponse) UploadBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.UploadBuildpackRequest) ClassPathResource(org.springframework.core.io.ClassPathResource) CreateBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.CreateBuildpackRequest) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) IOException(java.io.IOException) ResourceUtils(org.cloudfoundry.util.ResourceUtils) BuildpackResource(org.cloudfoundry.client.v2.buildpacks.BuildpackResource) DeleteBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.DeleteBuildpackRequest) Flux(reactor.core.publisher.Flux) BuildpackEntity(org.cloudfoundry.client.v2.buildpacks.BuildpackEntity) UpdateBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.UpdateBuildpackRequest) ListBuildpacksRequest(org.cloudfoundry.client.v2.buildpacks.ListBuildpacksRequest) CloudFoundryClient(org.cloudfoundry.client.CloudFoundryClient) JobUtils(org.cloudfoundry.util.JobUtils) Duration(java.time.Duration) GetBuildpackRequest(org.cloudfoundry.client.v2.buildpacks.GetBuildpackRequest) PaginationUtils(org.cloudfoundry.util.PaginationUtils) Path(java.nio.file.Path) ResourceUtils(org.cloudfoundry.util.ResourceUtils) ClassPathResource(org.springframework.core.io.ClassPathResource) AbstractIntegrationTest(org.cloudfoundry.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)2 Path (java.nio.file.Path)2 Duration (java.time.Duration)2 TimeoutException (java.util.concurrent.TimeoutException)2 AbstractIntegrationTest (org.cloudfoundry.AbstractIntegrationTest)2 CloudFoundryClient (org.cloudfoundry.client.CloudFoundryClient)2 BuildpackEntity (org.cloudfoundry.client.v2.buildpacks.BuildpackEntity)2 BuildpackResource (org.cloudfoundry.client.v2.buildpacks.BuildpackResource)2 CreateBuildpackRequest (org.cloudfoundry.client.v2.buildpacks.CreateBuildpackRequest)2 CreateBuildpackResponse (org.cloudfoundry.client.v2.buildpacks.CreateBuildpackResponse)2 DeleteBuildpackRequest (org.cloudfoundry.client.v2.buildpacks.DeleteBuildpackRequest)2 GetBuildpackRequest (org.cloudfoundry.client.v2.buildpacks.GetBuildpackRequest)2 ListBuildpacksRequest (org.cloudfoundry.client.v2.buildpacks.ListBuildpacksRequest)2 UpdateBuildpackRequest (org.cloudfoundry.client.v2.buildpacks.UpdateBuildpackRequest)2 UploadBuildpackRequest (org.cloudfoundry.client.v2.buildpacks.UploadBuildpackRequest)2 JobUtils (org.cloudfoundry.util.JobUtils)2 PaginationUtils (org.cloudfoundry.util.PaginationUtils)2 ResourceUtils (org.cloudfoundry.util.ResourceUtils)2 Test (org.junit.Test)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2