Skip to content

Instantly share code, notes, and snippets.

View rmcdouga's full-sized avatar

Rob McDougall rmcdouga

View GitHub Profile
@rmcdouga
rmcdouga / logback-test.xml
Created June 5, 2023 14:49
Logback file configuration to turn up wiremock debugging. Placed in the src/test/resources directory.
<configuration>
<!-- Turning down the wiremock logging -->
<!-- based on https://stackoverflow.com/questions/44460834/cant-turn-off-debug-logging-for-wiremock -->
<logger name="com.github.tomakehurst.wiremock" level="DEBUG" />
<logger name="wiremock.org" level="DEBUG" />
<logger name="WireMock" level="DEBUG" />
<!-- wiremock has per endpoint servlet logging -->
<logger name="/" level="DEBUG" />
</configuration>
@rmcdouga
rmcdouga / Jakarta_Activation_Wishlist.md
Last active April 6, 2023 12:26
Jakarta Activation Wish List
  1. Add a ByteArrayDataSource
    This seems like an odd ommission, surely an in-memory data source makes sense and is trivial to implement (but no more trivial than FileDataSource). It would save people from having to implement this in many places.

  2. Move Implementation tests into API project, convert to JUnit 5
    The jakarta.activation apis are a mix of API and implementation. Is there any reason why the implementation pieces are not tested within the API project? Having the tests closer to the code would ease the maintenance burdon and be more in line with modern practices. This will help new contributors.

  3. Add "name" attribute

@rmcdouga
rmcdouga / gist:117a947d3488b1a47a1bb656c6ba017f
Created March 3, 2023 15:44
PlantUML Helpful Starter Sample
@startuml Diagram
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
!define DEVICONS https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/devicons2
!define FONTAWESOME https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/font-awesome-5
!define MATERIAL https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/master/material
!include FONTAWESOME/java.puml
!include FONTAWESOME/linux.puml
!include DEVICONS/dot_net.puml
!include DEVICONS/spring.puml

JBang Commands that are useful

Playwright

Downloads and installs the browsers required to run playwright jbang -m com.microsoft.playwright.CLI com.microsoft.playwright:playwright:RELEASE install

Launches browser and records session as Java code jbang -m com.microsoft.playwright.CLI com.microsoft.playwright:playwright:RELEASE codegen -o Example.java

@WireMockTest
class SampleTest {
private static final boolean WIREMOCK_RECORDING = false; // true tells WIREMOCK to call AEM and record the result
private static final boolean SAVE_RESULTS = false; // true saves the resuts in the actualResults directory
@BeforeEach
void setUp(WireMockRuntimeInfo wmRuntimeInfo) throws Exception {
underTest = new Sample(createAemConfig("localhost", wmRuntimeInfo.getHttpPort()));
if (WIREMOCK_RECORDING) {
@rmcdouga
rmcdouga / .gitignore
Last active May 14, 2022 12:42
.gitignore for an Eclipse Maven project
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
@rmcdouga
rmcdouga / HtmlFormDocument.java
Last active September 1, 2022 20:59
Utilities for testing outputs (Pdf.java uses Apache PDFBox to validate a PDF in tests and HtmlFormDocument uses JSoup to parse HTML)
package com.github.rmcdouga;
import static org.junit.jupiter.api.Assertions.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
package com.github.rmcdouga.gist;
import java.io.Serializable;
/**
* <p>A convenience class to represent name-value pairs.</p>
*
* Code was blatantly stolen from javafx.util.Pair class
*
* @param <K>
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
private <T> void setIfNotNull(final Consumer<T> setter, final T value) {
if (value != null) {
setter.accept(value);
}
}