You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2021/09/24 06:38:59 UTC

[cassandra] branch cassandra-4.0 updated (50e0b40 -> e8c6752)

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

bereng pushed a change to branch cassandra-4.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git.


    from 50e0b40  Fix org.apache.cassandra.distributed.test.OptimiseStreamsRepairTest.randomTest
     new 1aa7fb1  ArrayIndexOutOfBoundsException in FunctionResource#fromName
     new e8c6752  Merge branch 'cassandra-3.11' into cassandra-4.0

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/cassandra/auth/FunctionResource.java    |   5 +-
 .../cassandra/auth/FunctionResourceTest.java       | 117 +++++++++++++++++++++
 2 files changed, 121 insertions(+), 1 deletion(-)
 create mode 100644 test/unit/org/apache/cassandra/auth/FunctionResourceTest.java

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


[cassandra] 01/01: Merge branch 'cassandra-3.11' into cassandra-4.0

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

bereng pushed a commit to branch cassandra-4.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit e8c675250a3740c1e795cbe70ec5b474401fe688
Merge: 50e0b40 1aa7fb1
Author: Bereng <be...@gmail.com>
AuthorDate: Fri Sep 24 08:34:42 2021 +0200

    Merge branch 'cassandra-3.11' into cassandra-4.0

 .../apache/cassandra/auth/FunctionResource.java    |   5 +-
 .../cassandra/auth/FunctionResourceTest.java       | 117 +++++++++++++++++++++
 2 files changed, 121 insertions(+), 1 deletion(-)

diff --cc test/unit/org/apache/cassandra/auth/FunctionResourceTest.java
index 0000000,54da393..07a4b10
mode 000000,100644..100644
--- a/test/unit/org/apache/cassandra/auth/FunctionResourceTest.java
+++ b/test/unit/org/apache/cassandra/auth/FunctionResourceTest.java
@@@ -1,0 -1,115 +1,117 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one
+  * or more contributor license agreements.  See the NOTICE file
+  * distributed with this work for additional information
+  * regarding copyright ownership.  The ASF licenses this file
+  * to you under the Apache License, Version 2.0 (the
+  * "License"); you may not use this file except in compliance
+  * with the License.  You may obtain a copy of the License at
+  *
+  *     http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
++
+ package org.apache.cassandra.auth;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+ import org.junit.Test;
+ 
+ import org.apache.cassandra.db.marshal.AbstractType;
+ import org.apache.cassandra.db.marshal.TypeParser;
+ 
+ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+ import static org.junit.Assert.assertEquals;
+ 
+ public class FunctionResourceTest
+ {
+     private static final String ks = "fr_ks";
+     private static final String func = "functions";
+     private static final String name = "concat";
+     private static final String varType = "org.apache.cassandra.db.marshal.UTF8Type";
+ 
+     @Test
+     public void testFunction() throws Exception
+     {
+         FunctionResource expected = FunctionResource.root();
+         FunctionResource actual = FunctionResource.fromName(func);
+         assertEquals(expected, actual);
+         assertEquals(expected.getName(), actual.getName());
+     }
+ 
+     @Test
+     public void testFunctionKeyspace() throws Exception
+     {
+         FunctionResource expected = FunctionResource.keyspace(ks);
+         FunctionResource actual = FunctionResource.fromName(String.format("%s/%s", func, ks));
+         assertEquals(expected, actual);
+         assertEquals(expected.getKeyspace(), actual.getKeyspace());
+     }
+ 
+     @Test
+     public void testFunctionWithSingleInputParameter() throws Exception
+     {
+         List<AbstractType<?>> argTypes = new ArrayList<>();
+         argTypes.add(TypeParser.parse(varType));
+         FunctionResource expected = FunctionResource.function(ks, name, argTypes);
+         FunctionResource actual = FunctionResource.fromName(String.format("%s/%s/%s[%s]", func, ks, name, varType));
+         assertEquals(expected, actual);
+         assertEquals(expected.getKeyspace(), actual.getKeyspace());
+     }
+ 
+     @Test
 -    public void testFunctionWithMultipleInputParameters() throws Exception
++    public void testFunctionWithMultipleInputParameter() throws Exception
+     {
+         List<AbstractType<?>> argTypes = new ArrayList<>();
+         argTypes.add(TypeParser.parse(varType));
+         argTypes.add(TypeParser.parse(varType));
+         FunctionResource expected = FunctionResource.function(ks, name, argTypes);
+         FunctionResource actual = FunctionResource.fromName(String.format("%s/%s/%s[%s^%s]", func, ks, name, varType, varType));
+         assertEquals(expected, actual);
+         assertEquals(expected.getKeyspace(), actual.getKeyspace());
+     }
+ 
+     @Test
 -    public void testFunctionWithoutInputParameters() throws Exception
++    public void testFunctionWithoutInputParameter() throws Exception
+     {
+         List<AbstractType<?>> argTypes = new ArrayList<>();
+         FunctionResource expected = FunctionResource.function(ks, name, argTypes);
+         FunctionResource actual = FunctionResource.fromName(String.format("%s/%s/%s[]", func, ks, name));
+         assertEquals(expected, actual);
+         assertEquals(expected.getKeyspace(), actual.getKeyspace());
+ 
+         String error = "functions/fr_ks/concat is not a valid function resource name. It must end with \"[]\"";
+         assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> FunctionResource.fromName(String.format("%s/%s/%s",
+                                                                                                                            func,
+                                                                                                                            ks,
+                                                                                                                            name)))
+                                                                  .withMessage(error);
+     }
+ 
+     @Test
+     public void testInvalidFunctionName()
+     {
+         String expected = "functions_test is not a valid function resource name";
+         assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> FunctionResource.fromName("functions_test"))
+                                                                  .withMessage(expected);
+     }
+ 
+     @Test
+     public void testFunctionWithInvalidInput()
+     {
+         String expected = String.format("%s/%s/%s[%s]/test is not a valid function resource name", func, ks, name, varType);
+         assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> FunctionResource.fromName(String.format("%s/%s/%s[%s]/test",
+                                                                                                                            func,
+                                                                                                                            ks,
+                                                                                                                            name,
+                                                                                                                            varType)))
+                                                                  .withMessage(expected);
++        ;
+     }
+ }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org