Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Marco Gueka

🎯
Focusing
View GitHub Profile
View http-ping.py
#! /usr/bin/python3
import pip._vendor.requests as requests
import sys
import time
import socket
import re
# TODO add a validation param
url = sys.argv[1]
counter = 0
@Gueka
Gueka / WeatherServiceTest.java
Created Aug 14, 2019
How to configure mockito with spring boot for test
View WeatherServiceTest.java
package net.gueka.tutorials.weatherapi.service;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
@Gueka
Gueka / WeatherService.java
Created Aug 14, 2019
How to configure a service using spring cache abstraction
View WeatherService.java
package net.gueka.tutorials.weatherapi.service;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.ResponseEntity;
@Gueka
Gueka / WeatherService.java
Last active Aug 14, 2019
How to configure a service using spring cache abstraction
View WeatherService.java
@Slf4j
@Service
@CacheConfig(cacheNames={"weather"})
public class WeatherService {
public static final String WEATHER_API_URL = "https://api.openweathermap.org/data/2.5/weather?zip=%s,%s&appid=%s&units=metric";
@Value("${weather.appid}")
String appid;
@Gueka
Gueka / schema.xsd
Created Aug 9, 2019
Example of a xsd file
View schema.xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.gueka.net/promo/schema"
targetNamespace="http://www.gueka.net/promo/schema" elementFormDefault="qualified">
<xs:element name="promotionRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="data" type="tns:data"/>
</xs:sequence>
</xs:complexType>
</xs:element>
@Gueka
Gueka / gradle.build
Created Aug 9, 2019
Gradle example to create a SOAP web service with spring boot
View gradle.build
buildscript {
ext {
jaxbVersion = '2.3.2'
wsdlVersion = '1.6.3'
junitVersion = '5.3.2'
}
}
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
@Gueka
Gueka / WebServiceConfig.java
Last active Aug 9, 2019
Example of a soap service configuration
View WebServiceConfig.java
package net.gueka.promo.config;
import javax.servlet.Servlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.EnableWs;
@Gueka
Gueka / IntegrationTest.java
Created Aug 1, 2019
An integration test example for Spring boot with Cassandra embedded database
View IntegrationTest.java
package net.gueka.user;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
@Gueka
Gueka / UserRepository.java
Created Aug 1, 2019
An Spring boot Cassandra repository example
View UserRepository.java
package net.gueka.user.repository;
import java.util.UUID;
import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.stereotype.Repository;
import net.gueka.user.model.User;
@Repository
@Gueka
Gueka / User.java
Created Aug 1, 2019
Cassandra model for spring boot using lombok
View User.java
package net.gueka.user.model;
import java.util.List;
import java.util.UUID;
import com.datastax.driver.core.DataType.Name;
import org.springframework.data.cassandra.core.mapping.CassandraType;
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
import org.springframework.data.cassandra.core.mapping.Table;