This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.codefx.demo.junit5; | |
import org.junit.gen5.api.Test; | |
import org.junit.gen5.junit4.runner.JUnit5; | |
import org.junit.runner.RunWith; | |
/** | |
* Typical "Hello World"; runs as a JUnit 4 test. | |
*/ | |
@RunWith(JUnit5.class) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.codefx.lab; | |
import java.lang.reflect.Method; | |
import java.net.URL; | |
import java.net.URLStreamHandler; | |
public class GetURLStreamHandler { | |
public static void main(String[] args) throws Exception { | |
printDefaultPortForProtocol("http"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Reordering { | |
private static Constructed constructed; | |
public static void main(String[] args) throws Exception { | |
new Thread(Reordering::constructForever).start(); | |
Thread.sleep(100); | |
checkInitializationUntilFails(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.codefx.lab.visibility; | |
class PackagePrivate { | |
public String publicToUpper(String s) { | |
return s.toUpperCase(); | |
} | |
String packageToUpper(String s) { | |
return s.toUpperCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MethodReferencesToStaticMethodsDemo { | |
public Optional<String> firstSpecialString(Collection<String> strings) { | |
return strings.stream() | |
.filter(MethodReferencesToStaticMethodsDemo::isSpecial) | |
.findFirst(); | |
} | |
public Optional<String> anySpecialString(Collection<String> strings) { | |
return strings.stream() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.codefx.lab.stream; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.ForkJoinPool; | |
import java.util.function.Consumer; | |
import java.util.stream.IntStream; | |
public class ParallelStream { | |
public static void main(String[] args) throws InterruptedException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the Gist for a post I wrote about publishing snapshots with Gradle's maven-publish plugin: | |
// http://blog.codefx.org/tools/snapshots-gradle-maven-publish-plugin | |
// PROJECT_NAME is defined in settings.gradle | |
group 'PROJECT_GROUP' | |
version 'PROJECT_VERSION' | |
apply plugin: 'java' | |
apply plugin: 'maven-publish' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0"> | |
<persistence-unit name="statistics-unit" transaction-type="RESOURCE_LOCAL"> | |
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> | |
<exclude-unlisted-classes>true</exclude-unlisted-classes> | |
<properties> | |
<property name="javax.persistence.jdbc.driver" value="org.h2.Driver" /> | |
<property name="javax.persistence.jdbc.url" | |
value="jdbc:h2:mem:test;INIT=CREATE SCHEMA IF NOT EXISTS test\;RUNSCRIPT FROM 'classpath:META-INF/init.sql'" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.codefx.demo.junit5.extensions.RandomParameterExtensionTest.RandomProvider; | |
import org.junit.jupiter.api.AfterAll; | |
import org.junit.jupiter.api.AfterEach; | |
import org.junit.jupiter.api.BeforeAll; | |
import org.junit.jupiter.api.BeforeEach; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.extension.ExtendWith; | |
import org.junit.jupiter.api.extension.ExtensionContext; | |
import org.junit.jupiter.api.extension.ParameterContext; | |
import org.junit.jupiter.api.extension.ParameterResolutionException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* RELEASED UNDER CC-0 (https://creativecommons.org/publicdomain/zero/1.0/): | |
* | |
* You can copy, modify, distribute and perform the work, even for commercial | |
* purposes, all without asking permission. | |
*/ | |
import java.lang.reflect.Method; | |
public class JavaVersionSniffer { |