mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-4.0' into trunk
This commit is contained in:
commit
643b9b776f
|
|
@ -44,6 +44,7 @@ Merged from 3.11:
|
|||
* Update Jackson from 2.9.10 to 2.12.5 (CASSANDRA-16851)
|
||||
* Make assassinate more resilient to missing tokens (CASSANDRA-16847)
|
||||
Merged from 3.0:
|
||||
* ArrayIndexOutOfBoundsException in FunctionResource#fromName (CASSANDRA-16977, CASSANDRA-16995)
|
||||
* CVE-2015-0886 Security vulnerability in jbcrypt is addressed (CASSANDRA-9384)
|
||||
* Avoid useless SSTable reads during single partition queries (CASSANDRA-16944)
|
||||
* Debian init respects CASSANDRA_HEAPDUMP_DIR (CASSANDRA-13843)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.db.marshal.DoubleType;
|
||||
import org.apache.cassandra.db.marshal.Int32Type;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ResourcesTest
|
||||
{
|
||||
|
||||
@Test
|
||||
public void testRoleResourceNameConversion()
|
||||
{
|
||||
assertEquals(RoleResource.root(), Resources.fromName("roles"));
|
||||
assertEquals("roles", RoleResource.root().getName());
|
||||
|
||||
assertEquals(RoleResource.role("role1"), Resources.fromName("roles/role1"));
|
||||
assertEquals("roles/role1", RoleResource.role("role1").getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataResourceNameConversion()
|
||||
{
|
||||
assertEquals(DataResource.root(), Resources.fromName("data"));
|
||||
assertEquals("data", DataResource.root().getName());
|
||||
|
||||
assertEquals(DataResource.keyspace("ks1"), Resources.fromName("data/ks1"));
|
||||
assertEquals("data/ks1", DataResource.keyspace("ks1").getName());
|
||||
|
||||
assertEquals(DataResource.table("ks1", "t1"), Resources.fromName("data/ks1/t1"));
|
||||
assertEquals("data/ks1/t1", DataResource.table("ks1", "t1").getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunctionResourceNameConversion()
|
||||
{
|
||||
assertEquals(FunctionResource.root(), Resources.fromName("functions"));
|
||||
assertEquals("functions", FunctionResource.root().getName());
|
||||
|
||||
assertEquals(FunctionResource.keyspace("ks1"), Resources.fromName("functions/ks1"));
|
||||
assertEquals("functions/ks1", FunctionResource.keyspace("ks1").getName());
|
||||
|
||||
assertEquals(FunctionResource.function("ks1", "f1", Collections.emptyList()),
|
||||
Resources.fromName("functions/ks1/f1[]"));
|
||||
// this is actually supported by an explicit check in TypeParser
|
||||
assertEquals(FunctionResource.function("ks1", "f1", Arrays.asList(Int32Type.instance, DoubleType.instance)),
|
||||
Resources.fromName("functions/ks1/f1[Int32Type^DoubleType]"));
|
||||
assertEquals("functions/ks1/f1[]",
|
||||
FunctionResource.function("ks1", "f1", Collections.emptyList()).getName());
|
||||
|
||||
assertEquals(FunctionResource.function("ks1", "f1", Arrays.asList(Int32Type.instance, DoubleType.instance)),
|
||||
Resources.fromName("functions/ks1/f1[org.apache.cassandra.db.marshal.Int32Type^org.apache.cassandra.db.marshal.DoubleType]"));
|
||||
assertEquals("functions/ks1/f1[org.apache.cassandra.db.marshal.Int32Type^org.apache.cassandra.db.marshal.DoubleType]",
|
||||
FunctionResource.function("ks1", "f1", Arrays.asList(Int32Type.instance, DoubleType.instance)).getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJMXResourceNameConversion()
|
||||
{
|
||||
assertEquals(JMXResource.root(), Resources.fromName("mbean"));
|
||||
assertEquals("mbean", JMXResource.root().getName());
|
||||
|
||||
assertEquals(JMXResource.mbean("org.apache.cassandra.auth:type=*"),
|
||||
Resources.fromName("mbean/org.apache.cassandra.auth:type=*"));
|
||||
assertEquals("mbean/org.apache.cassandra.auth:type=*",
|
||||
JMXResource.mbean("org.apache.cassandra.auth:type=*").getName());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue