Skip to content
Permalink
Browse files
Adds CatalogApi test using equivalent non deprecated method
Signed-off-by: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
  • Loading branch information
grkvlt committed Feb 11, 2021
1 parent 554a149 commit f150eedb34f6a050cfc1db5fae9fdef95e567b9a
Showing 1 changed file with 23 additions and 3 deletions.
@@ -37,6 +37,7 @@
import org.apache.brooklyn.core.location.BasicLocationRegistry;
import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.core.typereg.BrooklynBomYamlCatalogBundleResolver;
import org.apache.brooklyn.rest.BrooklynRestApiLauncher;
import org.apache.brooklyn.rest.BrooklynRestApiLauncherTest;
import org.apache.brooklyn.rest.domain.ApplicationSummary;
@@ -113,13 +114,32 @@ public void testCatalogApiLocations() throws Exception {
log.info("locations from catalog are: "+locations);
}

public void testCatalogCreate()throws Exception {
final Response response = api.getCatalogApi().createFromUpload(getFileContentsAsString("catalog/test-catalog.bom").getBytes(), false);
// Note that the API method called here is now deprecated.
// The equivalent call is used in testCatalogCreate below.
public void testCatalogCreateFromYamlDeprecated()throws Exception {
String yaml = getFileContentsAsString("catalog/test-catalog.bom");
yaml = yaml.replaceAll("simple-tomcat", "simple-tomcat-yaml");
final Response response = api.getCatalogApi().createFromYaml(yaml, false);
Asserts.assertEquals(response.getStatus(), 201);
Asserts.assertStringContains(String.valueOf(response.getEntity()), "simple-tomcat:1.0");
Asserts.assertStringContains(String.valueOf(response.getEntity()), "simple-tomcat-yaml:1.0");
}

// Note that the API method called here is now deprecated.
// The equivalent call is used in testCatalogCreate below.
public void testCatalogCreateFromUploadDeprecated()throws Exception {
String yaml = getFileContentsAsString("catalog/test-catalog.bom");
yaml = yaml.replaceAll("simple-tomcat", "simple-tomcat-upload");
final Response response = api.getCatalogApi().createFromUpload(yaml.getBytes(), false);
Asserts.assertEquals(response.getStatus(), 201);
Asserts.assertStringContains(String.valueOf(response.getEntity()), "simple-tomcat-upload:1.0");
}

public void testCatalogCreate()throws Exception {
String yaml = getFileContentsAsString("catalog/test-catalog.bom");
final Response response = api.getCatalogApi().create(yaml.getBytes(), BrooklynBomYamlCatalogBundleResolver.FORMAT, false, true, false);
Asserts.assertEquals(response.getStatus(), 201);
Asserts.assertStringContains(String.valueOf(response.getEntity()), "simple-tomcat:1.0");
}

public void testApplicationApiList() throws Exception {
List<ApplicationSummary> apps = api.getApplicationApi().list(null);

0 comments on commit f150eed

Please sign in to comment.