Skip to content

Commit 1f34b7e

Browse files
committed
Polishing.
Guard Cassandra index creation. Original pull request: #672 See #671
1 parent e66d317 commit 1f34b7e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cassandra/example/src/test/java/example/springdata/cassandra/basic/BasicUserRepositoryTests.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2013-2021 the original author or authors.
2+
* Copyright 2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -18,11 +18,11 @@
1818
import static org.assertj.core.api.Assertions.*;
1919
import static org.assertj.core.api.Assumptions.*;
2020

21-
import java.util.stream.LongStream;
22-
2321
import example.springdata.cassandra.util.CassandraKeyspace;
2422
import example.springdata.cassandra.util.CassandraVersion;
2523

24+
import java.util.stream.LongStream;
25+
2626
import org.junit.jupiter.api.BeforeEach;
2727
import org.junit.jupiter.api.Test;
2828

@@ -112,7 +112,8 @@ void findByDerivedQueryMethodWithSASI() throws InterruptedException {
112112

113113
assumeThat(CassandraVersion.getReleaseVersion(session).isGreaterThanOrEqualTo(CASSANDRA_3_4)).isTrue();
114114

115-
session.execute("CREATE CUSTOM INDEX ON users (lname) USING 'org.apache.cassandra.index.sasi.SASIIndex';");
115+
session.execute(
116+
"CREATE CUSTOM INDEX IF NOT EXISTS users_lname_idx_1 ON users (lname) USING 'org.apache.cassandra.index.sasi.SASIIndex';");
116117
/*
117118
Cassandra secondary indexes are created in the background without the possibility to check
118119
whether they are available or not. So we are forced to just wait. *sigh*
@@ -132,7 +133,8 @@ void limitResultSize() throws InterruptedException {
132133

133134
assumeThat(CassandraVersion.getReleaseVersion(session).isGreaterThanOrEqualTo(CASSANDRA_3_4)).isTrue();
134135

135-
session.execute("CREATE CUSTOM INDEX ON users (lname) USING 'org.apache.cassandra.index.sasi.SASIIndex';");
136+
session.execute(
137+
"CREATE CUSTOM INDEX IF NOT EXISTS users_lname_idx_1 ON users (lname) USING 'org.apache.cassandra.index.sasi.SASIIndex';");
136138
/*
137139
Cassandra secondary indexes are created in the background without the possibility to check
138140
whether they are available or not. So we are forced to just wait. *sigh*

0 commit comments

Comments
 (0)