Skip to content
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 the original author or authors.
* Copyright 2013-2026 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -131,7 +131,9 @@ public Mono<ListPackageDropletsResponse> listDroplets(ListPackageDropletsRequest
public Mono<UploadPackageResponse> upload(UploadPackageRequest request) {
Path bits = request.getBits();

if (bits.toFile().isDirectory()) {
// bits is null when uploading via resource matching only (all files already cached on
// server)
if (bits != null && bits.toFile().isDirectory()) {
return FileUtils.compress(bits)
.map(
temporaryFile ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void updateCustomErrorMessage() {
.as(StepVerifier::create)
.expectNext(newMessage)
.expectComplete()
.verify(Duration.ofMinutes(5));
.verify(Duration.ofMinutes(8));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.cloudfoundry.client.v3.applications.Application;
import org.cloudfoundry.client.v3.applications.ApplicationRelationships;
import org.cloudfoundry.client.v3.applications.CreateApplicationRequest;
import org.cloudfoundry.client.v3.featureflags.GetFeatureFlagRequest;
import org.cloudfoundry.client.v3.packages.CreatePackageRequest;
import org.cloudfoundry.client.v3.packages.GetPackageRequest;
import org.cloudfoundry.client.v3.packages.GetPackageResponse;
Expand All @@ -40,8 +41,8 @@
import org.cloudfoundry.util.DelayTimeoutException;
import org.cloudfoundry.util.ExceptionUtils;
import org.cloudfoundry.util.ResourceMatchingUtilsV3;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import reactor.core.Exceptions;
Expand All @@ -54,22 +55,23 @@ public class ResourceMatchTest extends AbstractIntegrationTest {

@Autowired private Mono<String> spaceId;

// enable resource_matching with: cf enable-feature-flag resource_matching
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_9)
@Test
@Disabled(
"Cloud Controller is configured not to cache resource smaller than 4k - Find a better"
+ " way to test this")
@DisabledIf("resource_matching_disabled")
public void upload() throws IOException {
createAndUploadPackage()
.flatMap(this::waitForReady)
.then(
ResourceMatchingUtilsV3.getMatchedResources(
this.cloudFoundryClient,
new ClassPathResource("test-application.zip").getFile().toPath()))
new ClassPathResource("test-service-broker.jar")
.getFile()
.toPath()))
.as(StepVerifier::create)
.consumeNextWith(matchedResources -> assertThat(matchedResources).isNotEmpty())
.expectComplete()
.verify(Duration.ofMinutes(5));
.verify(Duration.ofMinutes(10));
}

private Mono<String> createAndUploadPackage() {
Expand Down Expand Up @@ -130,7 +132,7 @@ private Mono<String> createAndUploadPackage() {
.packageId(packageId)
.bits(
new ClassPathResource(
"test-application.zip")
"test-service-broker.jar")
.getFile()
.toPath())
.build());
Expand Down Expand Up @@ -168,4 +170,13 @@ private Mono<GetPackageResponse> waitForReady(String packageId) {
"Package %s timed out during upload processing",
packageId));
}

boolean resource_matching_disabled() {
return !this.cloudFoundryClient
.featureFlagsV3()
.get(GetFeatureFlagRequest.builder().name("resource_matching").build())
.map(response -> response.getEnabled())
.onErrorReturn(false)
.block();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.cloudfoundry.client.v3.spaces.UpdateSpaceRequest;
import org.cloudfoundry.util.JobUtils;
import org.cloudfoundry.util.PaginationUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
Expand Down Expand Up @@ -177,8 +176,8 @@ public void delete() {
}

// TODO: Await resolution of https://github.com/cloudfoundry/cloud_controller_ng/issues/1876
// Issue from 2020 is not closed, but test seems to run.
@IfCloudFoundryVersion(greaterThan = CloudFoundryVersion.PCF_2_9)
@Disabled("Await https://github.com/cloudfoundry/cf-java-client/issues/1876")
@Test
public void deleteUnmappedRoutes() {
String domainName = this.nameFactory.getDomainName();
Expand Down
Loading