Tidy testapp and poms. (#1521)

Closes #1520.
This commit is contained in:
Michael Reiche
2022-08-01 11:54:13 -07:00
committed by GitHub
parent e9f9d66abe
commit a92ebd06ab
12 changed files with 182 additions and 151 deletions

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

View File

@@ -19,10 +19,19 @@
<java-module-name>spring.data.couchbase</java-module-name>
<jodatime>2.10.13</jodatime>
<jakarta.validation>3.0.1</jakarta.validation>
<hibernate.validator>7.0.1.Final</hibernate.validator>
<apt>1.1.3</apt>
<querydsl>5.0.0</querydsl>
<mysema.querydsl>3.7.4</mysema.querydsl>
<jakarta.enterprise>3.0.0</jakarta.enterprise>
<org.hibernate.validator>7.0.1.Final</org.hibernate.validator>
<jakarta.el>4.0.0</jakarta.el>
<javax.el>3.0.0</javax.el>
<org.glassfish>4.0.2</org.glassfish>
<org.apache.geronimo.specs>1.0.1</org.apache.geronimo.specs>
<javax.interceptor>1.2.1</javax.interceptor>
<com.couchbase.mock>1.5.25</com.couchbase.mock>
<com.squareup.okhttp3>4.8.1</com.squareup.okhttp3>
<org.awaitility>4.0.3</org.awaitility>
</properties>
<dependencyManagement>
@@ -67,19 +76,11 @@
<version>${springdata.commons}</version>
</dependency>
<!-- in parent
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
<version>${couchbase}</version>
</dependency>
-->
<!-- CDI -->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>3.0.0</version>
<version>${jakarta.enterprise}</version>
</dependency>
<dependency>
@@ -92,14 +93,7 @@
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>7.0.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<version>${org.hibernate.validator}</version>
<scope>test</scope>
</dependency>
@@ -137,7 +131,7 @@
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<version>4.0.0</version>
<version>${jakarta.el}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
@@ -145,14 +139,14 @@
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
<version>${javax.el}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.el</artifactId>
<version>4.0.2</version>
<version>${jakarta.el}</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
@@ -162,42 +156,35 @@
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_2.0_spec</artifactId>
<version>1.0.1</version>
<version>${org.apache.geronimo.specs}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.interceptor</groupId>
<artifactId>javax.interceptor-api</artifactId>
<version>1.2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-se</artifactId>
<version>${webbeans}</version>
<version>${javax.interceptor}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.couchbase.mock</groupId>
<artifactId>CouchbaseMock</artifactId>
<version>1.5.25</version>
<version>${com.couchbase.mock}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.8.1</version>
<version>${com.squareup.okhttp3}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp-tls</artifactId>
<version>4.8.1</version>
<version>${com.squareup.okhttp3}</version>
<scope>test</scope>
</dependency>
@@ -226,7 +213,7 @@
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.0.3</version>
<version>${org.awaitility}</version>
<scope>test</scope>
</dependency>

View File

@@ -1,59 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
</dependency>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--- for testing only -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<properties>
<springdata.couchbase>5.0.0-SNAPSHOT</springdata.couchbase>
</properties>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.10.1</version>
</dependency>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-couchbase</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-couchbase</artifactId>
<version>${springdata.couchbase}</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--
<version>3.0.0-SNAPSHOT</version>
-->
</plugin>
</plugins>
</build>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
@@ -72,24 +71,15 @@
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>https://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
<!--
<pluginRepositories>
<pluginRepository>
<id>spring-plugins-release</id>
<url>https://repo.spring.io/plugins-release</url>
<id>spring-snapshots</id>
<url>https://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
-->
</project>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2022 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.
@@ -29,7 +29,6 @@ import java.time.LocalDateTime;
/**
* Airport entity
*
* @author Michael Nitschinger
* @author Michael Reiche
*/
@Document
@@ -79,19 +78,6 @@ public class Airport {
return openDate;
}
/*
public Airport withId(String id) {
return new Airport(id, this.iata, this.icao);
}
public Airport withIcao(String icao) {
return new Airport(this.getId(), this.iata, icao);
}
public Airport withIata(String iata) {
return new Airport(this.getId(), iata, this.icao);
}
*/
public Airport clearVersion() {
version = Long.valueOf(0);
return this;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2021 the original author or authors.
* Copyright 2022 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.demo;
import com.couchbase.client.java.query.QueryScanConsistency;
@@ -32,10 +31,11 @@ import java.util.Optional;
/**
* Airport repository for testing <br>
*
* @author Michael Reiche
*/
@Repository
@Document
// @ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
public interface AirportRepository extends CouchbaseRepository<Airport, String> {
// override an annotate with REQUEST_PLUS
@@ -49,7 +49,7 @@ public interface AirportRepository extends CouchbaseRepository<Airport, String>
@ScanConsistency(query = QueryScanConsistency.REQUEST_PLUS)
Airport findByIata(String iata);
@ScanConsistency(query = QueryScanConsistency.NOT_BOUNDED)
@ScanConsistency(query = QueryScanConsistency.NOT_BOUNDED)
Airport iata(String iata);
@Query("#{#n1ql.selectEntity} where iata = $1")

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2022 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 com.example.demo;
import com.couchbase.client.java.transactions.TransactionResult;
@@ -9,6 +24,11 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
*
*
* @author Michael Reiche
*/
@Service
@Transactional
public class AirportService {

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2022 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 com.example.demo;
import com.couchbase.client.java.transactions.TransactionResult;
@@ -10,13 +25,13 @@ import org.springframework.stereotype.Component;
/**
* Components of the type CommandLineRunner are called right after the application start up. So the method *run* is
* called as soon as the application starts.
*
* @author Michael Reiche
*/
@Component
public class CmdRunner implements CommandLineRunner {
@Autowired AirportRepository airportRepository;
@Autowired
IndexDetailRepository indexDetailRepository;
@Autowired CouchbaseTemplate template;
@Autowired CouchbaseClientFactory couchbaseClientFactory;
@Autowired AirportService airportService;

View File

@@ -1,21 +1,33 @@
/*
* Copyright 2022 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 com.example.demo;
import com.couchbase.client.core.env.IoEnvironment;
import com.couchbase.client.core.env.SecurityConfig;
import com.couchbase.client.core.msg.kv.DurabilityLevel;
import com.couchbase.client.java.codec.JacksonJsonSerializer;
import com.couchbase.client.java.env.ClusterEnvironment;
import com.couchbase.client.java.json.JsonValueModule;
import com.couchbase.client.java.transactions.config.TransactionsConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
import org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories;
import java.time.Duration;
/**
*
*
* @author Michael Reiche
*/
@Configuration
@EnableCouchbaseRepositories({"com.example.demo", "com.wu.onep.ordnrt.cbviewsrch.repository"})
public class Config extends AbstractCouchbaseConfiguration {
@@ -41,18 +53,8 @@ public class Config extends AbstractCouchbaseConfiguration {
@Override
public void configureEnvironment(ClusterEnvironment.Builder builder){
builder.jsonSerializer(getSerializer())
.securityConfig(SecurityConfig.enableNativeTls(false))
.ioEnvironment(IoEnvironment.enableNativeIo(false));
// builder.transactionsConfig(TransactionsConfig.durabilityLevel(DurabilityLevel.NONE));
}
private static JacksonJsonSerializer getSerializer() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JsonValueModule());
mapper.registerModule(new JavaTimeModule()); // this handles LocalDateTime
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
return JacksonJsonSerializer.create(mapper);
}
}

View File

@@ -1,19 +1,35 @@
/*
* Copyright 2022 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 com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import java.util.Properties;
/**
*
*
* @author Michael Reiche
*/
@SpringBootApplication
public class DemoApplication {
char a = '\u00A0';
public static void main(String[] args) {
new SpringApplicationBuilder ( DemoApplication.class)
.properties("spring.main.allow-bean-definition-overriding=true")
.build()
.run(args);
SpringApplication.run( DemoApplication.class, args );
}
}

View File

@@ -1,6 +0,0 @@
package com.example.demo;
public enum Iata {
vie, // must be lower-case to match "vie" as airport.iata is always specified in lowercase
xxx
}

View File

@@ -1 +1 @@
#spring.main.allow-bean-definition-overriding=true
spring.main.allow-bean-definition-overriding=true

View File

@@ -1,8 +1,28 @@
/*
* Copyright 2022 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 com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
/**
*
*
* @author Michael Reiche
*/
@SpringBootTest
class DemoApplicationTests {