Upgrade to Apache Cassandra 4.3.1
See gh-19588
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.cassandra;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
|
||||
@Table
|
||||
public class Customer {
|
||||
|
||||
@PrimaryKey
|
||||
private UUID id;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
public Customer() {
|
||||
}
|
||||
|
||||
public Customer(UUID id, String firstName, String lastName) {
|
||||
this.id = id;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id, this.firstName, this.lastName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.cassandra;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.cassandra.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface CustomerRepository extends CrudRepository<Customer, String> {
|
||||
|
||||
@Query("Select * from customer where firstname=?0")
|
||||
Customer findByFirstName(String firstName);
|
||||
|
||||
@Query("Select * from customer where lastname=?0")
|
||||
List<Customer> findByLastName(String lastName);
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.cassandra;
|
||||
|
||||
import com.datastax.driver.core.utils.UUIDs;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleCassandraApplication implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private CustomerRepository repository;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
this.repository.deleteAll();
|
||||
|
||||
// save a couple of customers
|
||||
this.repository.save(new Customer(UUIDs.timeBased(), "Alice", "Smith"));
|
||||
this.repository.save(new Customer(UUIDs.timeBased(), "Bob", "Smith"));
|
||||
|
||||
// fetch all customers
|
||||
System.out.println("Customers found with findAll():");
|
||||
System.out.println("-------------------------------");
|
||||
for (Customer customer : this.repository.findAll()) {
|
||||
System.out.println(customer);
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
// fetch an individual customer
|
||||
System.out.println("Customer found with findByFirstName('Alice'):");
|
||||
System.out.println("--------------------------------");
|
||||
System.out.println(this.repository.findByFirstName("Alice"));
|
||||
|
||||
System.out.println("Customers found with findByLastName('Smith'):");
|
||||
System.out.println("--------------------------------");
|
||||
for (Customer customer : this.repository.findByLastName("Smith")) {
|
||||
System.out.println(customer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SampleCassandraApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
spring.data.cassandra.keyspace-name=mykeyspace
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.cassandra;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.cassandraunit.spring.CassandraUnitDependencyInjectionTestExecutionListener;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
public class OrderedCassandraTestExecutionListener extends CassandraUnitDependencyInjectionTestExecutionListener {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(OrderedCassandraTestExecutionListener.class);
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanServer() {
|
||||
try {
|
||||
super.cleanServer();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.warn("Failure during server cleanup", ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed 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
|
||||
*
|
||||
* https://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 smoketest.data.cassandra;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.cassandraunit.spring.CassandraDataSet;
|
||||
import org.cassandraunit.spring.EmbeddedCassandra;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.system.CapturedOutput;
|
||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.TestExecutionListeners.MergeMode;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link SampleCassandraApplication}.
|
||||
*/
|
||||
@TestExecutionListeners(mergeMode = MergeMode.MERGE_WITH_DEFAULTS,
|
||||
listeners = { OrderedCassandraTestExecutionListener.class })
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
@SpringBootTest
|
||||
@CassandraDataSet(keyspace = "mykeyspace", value = "setup.cql")
|
||||
@EmbeddedCassandra(timeout = 60000)
|
||||
class SampleCassandraApplicationTests {
|
||||
|
||||
@Test
|
||||
void testDefaultSettings(CapturedOutput output) {
|
||||
Assumptions.assumeFalse(this::runningOnWindows);
|
||||
assertThat(output).contains("firstName='Alice', lastName='Smith'");
|
||||
}
|
||||
|
||||
private boolean runningOnWindows() {
|
||||
return File.separatorChar == '\\';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
CREATE TABLE customer (id TimeUUID PRIMARY KEY, firstname text, lastname text);
|
||||
CREATE INDEX customerfistnameindex ON customer (firstname);
|
||||
CREATE INDEX customersecondnameindex ON customer (lastname);
|
||||
Reference in New Issue
Block a user