Skip to content

Instantly share code, notes, and snippets.

@aslakknutsen
aslakknutsen / start_testing_java8_today.asciidoc
Last active Apr 26, 2021
Example of how to use both JDK 7 and JDK 8 in one build.
View start_testing_java8_today.asciidoc

JDK 8 Released

Most of us won’t be able to use/deploy JDK 8 in production for a looong time. But that shouldn’t stop us from using it, right?

It should be possible to sneak in JDK 8 in the back way, the same way we snuck in Groovy and other libraries we wanted to use.

The Test Suite to the rescue

The Maven compiler plugin run in two separate lifecycles, compile and testCompile. Those can be configured separately.

@aslakknutsen
aslakknutsen / blog.md
Created Apr 19, 2012
Import your project's history in Sonar
View blog.md

When you do your first Sonar run on your project, you get a lot of new quality numbers to play with, but no trends. You only have one data set for comparison, the now picture.

Wouldn't it be nice if you could see the current trend of the project without waiting a couple of month for the 'daily/weekly' Sonar runs to fill up the data? Well, you're in luck! And if you're using git as a version system as well, this is your day. :)

In the Sonar Advanced Parameter documentation you will find a System Property called sonar.projectDate. The property let you tell Sonar when in time the running analysis was ran.

By combining this property and what your version system does best, track changes to source, we can now play back the history of the project as far as Sonar is concerned.

This little Bash script illustrates the concept. To spell out what it does in human readable form:

View Dockerfile
# Copyright 2018 Datawire. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
View keybase.md

Keybase proof

I hereby claim:

  • I am aslakknutsen on github.
  • I am aslakknutsen (https://keybase.io/aslakknutsen) on keybase.
  • I have a public key ASA0usfakObuP-k6yxY1STXfA80Ais1oIALzlZ_d27Z7AQo

To claim this, I am signing this object:

@aslakknutsen
aslakknutsen / console.log
Last active Nov 8, 2019
Configure Surefire to scan specific Dependencies for Test classes to include in the test run. Allows us to create reusable test jars without having to unpacking the jar content to disk and setting up testClassesDirectory configuration http://jira.codehaus.org/browse/SUREFIRE-569
View console.log
[INFO]
[INFO] --- maven-surefire-plugin:2.14-SNAPSHOT:test (tck-tests) @ arquillian-jbossas-remote-6 ---
[INFO] Surefire report directory: /home/aslak/dev/source/testing/arquillian-container-jbossas/jbossas-remote-6/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running org.arquillian.tck.container.cdi_1_0.CDIBeanLookupWarTestCase
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.866 sec
Running org.arquillian.tck.container.servlet_2_5.MultipleWebContextLookupMultiWarTestCase
@aslakknutsen
aslakknutsen / SUREFIRE-762_AbstractSurefireMojo.patch
Created Aug 18, 2011
Arquillian / Surefire - Using Profiles as separation between TestCompile and TestRuntime. Binding Maven Surefire to operate on different TestRuntimes within the same Maven run
View SUREFIRE-762_AbstractSurefireMojo.patch
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index f9a8db4..ea6f97c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -34,7 +34,10 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
@aslakknutsen
aslakknutsen / template_test.go
Last active Jul 19, 2019
Template based json patch
View template_test.go
func TestX(t *testing.T) {
patchs := []Patch{
Patch{
Name: "telepresence",
Template: []byte(`[
{{ if .Data.Has "/spec/template/metadata/labels/version" }}
{"op": "copy", "from": "/spec/template/metadata/labels/version", "path": "/spec/template/metadata/labels/version-source"},
{{ end }}
{"op": "replace", "path": "/metadata/name", "value": "{{.Data.Value "/metadata/name"}}-{{.NewVersion}}"},
{"op": "replace", "path": "/spec/template/spec/replicas", "value": "1"},
@aslakknutsen
aslakknutsen / vs_test.go
Last active Mar 6, 2019
istio API duplication on DeepCopy
View vs_test.go
import (
"testing"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
v1alpha3 "istio.io/api/networking/v1alpha3"
istionetwork "istio.io/api/pkg/kube/apis/networking/v1alpha3"
)
View deployment_test.go
var objects []runtime.Object
var ctx model.SessionContext
BeforeEach(func() {
ctx = model.SessionContext{
Context: context.TODO(),
Name: "test",
Namespace: "test",
Log: logf.Log.WithName("test"),
Client: fake.NewFakeClient(objects...),
}
View deployment_test.go
var objects []runtime.Object
var ctx model.SessionContext
BeforeEach(func() {
ctx = model.SessionContext{
Context: context.TODO(),
Name: "test",
Namespace: "test",
Log: logf.Log.WithName("test"),
Client: fake.NewFakeClient(objects...),
}