This is an automated email from the ASF dual-hosted git repository.

jcabrerizo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-client.git


The following commit(s) were added to refs/heads/master by this push:
     new f150eed  Adds CatalogApi test using equivalent non deprecated method
     new fd31f7f  Merge pull request #85 from grkvlt/fix/deprecated-api-test
f150eed is described below

commit f150eedb34f6a050cfc1db5fae9fdef95e567b9a
Author: Andrew Donald Kennedy <[email protected]>
AuthorDate: Thu Feb 11 10:47:43 2021 +0000

    Adds CatalogApi test using equivalent non deprecated method
    
    Signed-off-by: Andrew Donald Kennedy <[email protected]>
---
 .../rest/client/BrooklynApiRestClientTest.java     | 26 +++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git 
a/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
 
b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
index d5d8d92..4165dd9 100644
--- 
a/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
+++ 
b/java/src/test/java/org/apache/brooklyn/rest/client/BrooklynApiRestClientTest.java
@@ -37,6 +37,7 @@ import org.apache.brooklyn.core.entity.StartableApplication;
 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 class BrooklynApiRestClientTest {
         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);

Reply via email to