Skip to content

Instantly share code, notes, and snippets.

View krmahadevan's full-sized avatar
☠️
Threading ain't hard… Locking is!

Krishnan Mahadevan krmahadevan

☠️
Threading ain't hard… Locking is!
View GitHub Profile
@krmahadevan
krmahadevan / CompletableFuturePriorityQueueExample.java
Created December 12, 2023 05:25
Sample that demonstrates how to use CompletableFuture along with callbacks for listening to task completions which uses a ThreadPoolExecutor which is backed by a PriorityBlockingQueue
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.*;
//Works
public class CompletableFuturePriorityQueueExample {
static class Task implements Comparable<Task> {
private final String name;
@krmahadevan
krmahadevan / setup.md
Last active January 4, 2023 14:52
Quick Setup tutorial with Istio and K8s

Setup

Install minikube by referring to instructions here

Start a mini kube cluster with a higher resource configuration

➜  minikube start --cpus 6 --memory 8192
@krmahadevan
krmahadevan / README.md
Last active October 14, 2022 05:07
Bazel games in Selenium (Java focussed )
package com.springpoc.test;
import com.springpoc.config.SpringConfig;
import com.springpoc.util.WebDriverUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
@krmahadevan
krmahadevan / JSONAwareSoftAssertion.java
Last active May 26, 2022 09:51
A soft assertion implementation backed by org.skyscreamer.jsonassert.JSONAssert
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.skyscreamer.jsonassert.JSONParser;
import org.testng.asserts.IAssert;
import org.testng.asserts.SoftAssert;
public class JSONAwareSoftAssertion extends SoftAssert {
@krmahadevan
krmahadevan / build.gradle
Created October 13, 2021 08:13
A Sample Gradle build file that configures TestNG to be run as a custom task
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.2/samples
*/
plugins {
id 'java'
id 'idea'
@krmahadevan
krmahadevan / SampleReporter.java
Created December 27, 2019 04:52
A reporter example that shows how to extract logs for each Test Method in TestNG
import java.util.ArrayList;
import java.util.List;
import org.testng.IReporter;
import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.xml.XmlSuite;
public class SampleReporter implements IReporter {
package com.rationaleemotions.stackoverflow.qn55692848;
import org.testng.annotations.Test;
public class CreateUser {
@Test(priority = 1)
public void one() {}
@Test(priority = 2)
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
package com.rationaleemotions.stackoverflow.qn48792353;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
public class Base {
@BeforeSuite
public void beforeSuite() {
System.err.println("beforeSuite() invoked");
}