snuyanzin commented on code in PR #28789:
URL: https://github.com/apache/flink/pull/28789#discussion_r4178661448


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/common/sql/ConnectionITCase.java:
##########
@@ -76,11 +88,87 @@ void testCreateTemporaryConnectionRejectsDuplicate() {
 
     @Test
     void testCreatePermanentConnectionRejectedWithoutSecretStore() {
-        assertThatThrownBy(() -> tEnv().executeSql("CREATE CONNECTION my_conn 
WITH ('k' = 'v')"))
+        assertThatThrownBy(() -> tEnv.executeSql("CREATE CONNECTION my_conn 
WITH ('k' = 'v')"))
                 .isInstanceOf(ValidationException.class)
                 .hasMessageContaining("WritableSecretStore must be 
configured");
     }
 
+    @Test
+    void testDropTemporaryConnection() {
+        tEnv.executeSql("CREATE TEMPORARY CONNECTION my_conn WITH ('k' = 
'v')");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isPresent();
+
+        tEnv.executeSql("DROP TEMPORARY CONNECTION my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropTemporaryConnectionIfExists() {
+        tEnv.executeSql("DROP TEMPORARY CONNECTION IF EXISTS my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropMissingTemporaryConnectionRejected() {
+        assertThatThrownBy(() -> tEnv.executeSql("DROP TEMPORARY CONNECTION 
my_conn"))
+                .isInstanceOf(ValidationException.class)
+                .hasMessage(
+                        "Temporary connection with identifier '%s' does not 
exist.",
+                        connectionIdentifier("my_conn").asSummaryString());
+    }
+
+    @Test
+    void testDropPermanentConnection() throws Exception {
+        ObjectIdentifier identifier = connectionIdentifier("my_conn");
+        catalogManager()
+                .getCatalog(identifier.getCatalogName())
+                .orElseThrow()
+                .createConnection(
+                        identifier.toObjectPath(),
+                        CatalogConnection.of(Map.of("k", "v"), null),
+                        false);
+        assertThat(catalogManager().getConnection(identifier)).isPresent();
+
+        tEnv.executeSql("DROP CONNECTION my_conn");
+
+        assertThat(catalogManager().getConnection(identifier)).isEmpty();
+    }
+
+    @Test
+    void testDropPermanentConnectionIfExists() {
+        tEnv.executeSql("DROP CONNECTION IF EXISTS my_conn");
+
+        
assertThat(catalogManager().getConnection(connectionIdentifier("my_conn"))).isEmpty();
+    }
+
+    @Test
+    void testDropMissingPermanentConnectionRejected() {

Review Comment:
   please do not use names longer than 20 chars if there is no good 
justification for this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to