Skip to content

Instantly share code, notes, and snippets.

View avarabyeu's full-sized avatar

Andrei Varabyeu avarabyeu

View GitHub Profile
public static class ReportPortal4Listener extends BaseTestNGListener {
public ExtendedListener() {
super(Injector.create(
new ConfigurationModule(),
override(new ReportPortalClientModule()).with((Module) binder -> binder.bind(Serializer.class).toProvider(() -> {
ObjectMapper om = new ObjectMapper();
om.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"));
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return new JacksonSerializer(om);
}), new TestNGAgentModule())
public class MyListener extends BaseTestNGListener {
public MyListener() {
super(Injector.create(Modules.combine(Modules.override(new ConfigurationModule())
.with(new Module() {
@Override
public void configure(Binder binder) {
Properties overrides = new Properties();
overrides.setProperty(ListenerProperty.UUID.getPropertyName(), "my crazy uuid");
@avarabyeu
avarabyeu / grafana_setup.sh
Created August 28, 2017 18:18
grafana_setup.sh
#!/bin/bash
./run.sh "${@}" &
timeout 10 bash -c "until </dev/tcp/localhost/3000; do sleep 1; done"
curl -s -H "Content-Type: application/json" \
-XPOST http://admin:admin@localhost:3000/api/datasources \
-d @- <<EOF
{
"name": "influx",
@avarabyeu
avarabyeu / SocksExtensionModule.java
Last active January 10, 2017 12:17
RP socks proxy
public class SocksExtensionModule extends AbstractModule {
@Override
protected void configure() {
}
@Provides
public HttpClient provideHttpClient(@ListenerPropertyValue(ListenerProperty.UUID) String uuid) throws MalformedURLException {
HttpClientFactory httpClientFactory;
List<HttpRequestInterceptor> interceptors = new ArrayList<HttpRequestInterceptor>(1);
@avarabyeu
avarabyeu / rp-eureka-js.js
Created November 10, 2016 17:12
rp-eureka-js.js
const Eureka = require('eureka-js-client').Eureka;
const client = new Eureka({
// application instance information
instance: {
app: 'ui',
hostName: 'localhost',
port: {
"$": 8080,
"@enabled": "true"
@avarabyeu
avarabyeu / docker-compose.yml
Last active September 14, 2016 16:47
Example of Docker Compose descriptor for ReportPortal
## This is example of Docker Compose for ReportPortal
## Do not forget to configure data volumes for production usage
## Execute 'docker-compose -p reportportal up -d --force-recreate'
## to start all containers in daemon mode
## Where:
## '-p reportportal' -- specifies container's prefix (project name)
## '-d' -- enables daemon mode
## '--force-recreate' -- forces re-recreating of all containers
@avarabyeu
avarabyeu / CachedModuleFactory.java
Last active August 29, 2015 14:14
Cache Guice Injector with TestNG (best way)
/**
* @author Andrei Varabyeu
*/
public abstract class CachedModuleFactory<T extends Module> implements IModuleFactory {
private static final Cache<Class<? extends Module>, Injector> CACHE =
CacheBuilder.<Class<? extends Module>, Injector>newBuilder().build();
private final Callable<Injector> INJECTOR_LOADER = new Callable<Injector>() {
@Override
@avarabyeu
avarabyeu / CachedModuleFactory.java
Created February 3, 2015 14:05
Cache Guice Injector with TestNG (another way)
/**
* @author Andrei Varabyeu
*/
public abstract class CachedModuleFactory implements IModuleFactory {
/* delegate creating and holding of parent injector to subclass */
abstract protected Injector getParentInjector();
abstract protected Module createTestModule(ITestContext context, Class<?> testClass);
@avarabyeu
avarabyeu / CachedModuleFactory.java
Last active August 29, 2015 14:14
Cache Guice Injector with TestNG
/**
* @author Andrei Varabyeu
*/
public abstract class CachedModuleFactory implements IModuleFactory {
private static volatile Injector parentInjector;
private static final Object LOCK = new Object();
private Injector getParentInjector() {
@avarabyeu
avarabyeu / CustomSparkFilter.java
Created October 23, 2014 15:04
Custom spark filter with ServletContextListener implementation
@WebFilter(urlPatterns = {"/*"})
@WebListener
public class YourCustomFilter extends SparkFilter implements ServletContextListener {
@Override
protected SparkApplication getApplication(FilterConfig filterConfig) throws ServletException {
return //your SparkApplication;
}
@Override