Skip to content

Instantly share code, notes, and snippets.

View izimin's full-sized avatar
🏠
Working from home

Ilya Zimin izimin

🏠
Working from home
View GitHub Profile
@izimin
izimin / Testcontainers.txt
Last active January 20, 2023 09:24
Settings Testcontainers
### dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.playtika.testcontainers</groupId>
<artifactId>embedded-postgresql</artifactId>
@izimin
izimin / GetHtmlContentByUrl.java
Last active April 18, 2024 19:07
HTML content by URL
private static String getHtmlContentByUrl(String url) {
String content = null;
URLConnection connection;
try {
connection = new URL(url).openConnection();
Scanner scanner = new Scanner(connection.getInputStream());
scanner.useDelimiter("\\Z");
content = scanner.next();
} catch (Exception ex) {
ex.printStackTrace();
@izimin
izimin / docker-compose.yml
Last active December 31, 2022 15:05
docker-compose: postgres, mysql, zookeeper, kafka, rabbitmq, sonarqube
version: '3.3'
services:
postgres:
image: postgres:14-alpine
container_name: postgres
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "demo"
@izimin
izimin / Rest Assured (Spring Boot)
Last active October 17, 2022 10:57
Rest Assured Testing Spring Boot Application (dependencies, bootstrap.yml, application-localtest.properties, AbstractIntegrationTest.java)
--- Dependencies ---
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
<version>3.1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.playtika.testcontainers</groupId>
@izimin
izimin / application.properties
Created October 17, 2022 08:29
h2 Data JPA Test
spring.datasource.url=jdbc:h2://mem:db;DB_CLOSE_DELAY=-1
spring.datasource.username=123
spring.datasource.password=123
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.hibernate.use_sql_comments=false
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
@izimin
izimin / jcache-properties.yml
Created June 28, 2021 13:22
Setting properties for jcache
spring:
jpa:
properties:
hibernate:
cache:
use_second_level_cache: true
use_query_cache: true
region:
factory_class: org.hibernate.cache.jcache.JCacheRegionFactory
javax:
@izimin
izimin / jcache.xml
Created June 28, 2021 13:20
Jcache xml config example
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ehcache.org/v3"
xsi:schemaLocation="
http://www.ehcache.org/v3
https://www.ehcache.org/schema/ehcache-core.xsd">
<cache-template name="default">
<expiry>
<ttl unit="days">1</ttl>
</expiry>
@izimin
izimin / spy.properties
Last active December 6, 2021 16:20
Config for p6spy
driverlist=org.postgresql.Driver
appender=com.p6spy.engine.spy.appender.StdoutLogger
logMessageFormat=ru.izimin.HibernateBasicSqlFormatter
excludecategories=info,debug,result,resultset,rollback,commit
databaseDialectDateFormat=YYYY-MM-dd HH:mm:ss
exclude=SPRING_SESSION,SPRING_SESSION_ATTRIBUTES
filter=true
# spring.datasource.driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# spring.datasource.url: jdbc:p6spy:postgresql://localhost:5432/db
@izimin
izimin / HibernateBasicSqlFormatter.java
Created June 28, 2021 13:10
Sql formatter for p6spy
public class HibernateBasicSqlFormatter implements MessageFormattingStrategy {
private final Formatter formatter = new BasicFormatterImpl();
@Override
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
String res = !sql.isEmpty() ? sql : prepared;
if (res.isEmpty()) {
return "";
}