Skip to content

Commit

Permalink
Break compatibility with Java 6 & 7
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauer committed Nov 5, 2018
1 parent 1d6ca61 commit 8759a18
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ script: mvn clean package -P strict
after_success:
- mvn jacoco:report coveralls:report
jdk:
- oraclejdk7
- oraclejdk8
- oraclejdk9
- oraclejdk10
branches:
only:
- master
Expand Down
25 changes: 1 addition & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.6</java.version>
<java.version>1.8</java.version>

<junit.version>4.12</junit.version>

Expand All @@ -65,7 +65,6 @@

<maven.checkstyle.plugin.version>3.0.0</maven.checkstyle.plugin.version>
<maven.pmd.plugin.version>3.11.0</maven.pmd.plugin.version>
<maven.animal.sniffer.plugin.version>1.17</maven.animal.sniffer.plugin.version>
<maven.jacoco.plugin.version>0.8.2</maven.jacoco.plugin.version>
<maven.coveralls.plugin.version>4.3.0</maven.coveralls.plugin.version>
</properties>
Expand Down Expand Up @@ -243,28 +242,6 @@
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>${maven.animal.sniffer.plugin.version}</version>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.1</version>
</signature>
</configuration>
<executions>
<execution>
<id>check-java16</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.METHOD})
public @interface IfJavaVersion {

String JAVA_6 = "1.6";
String JAVA_7 = "1.7";
String JAVA_8 = "1.8";
String JAVA_9 = "1.9";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public boolean isSatisfied(final CheckerContext<AppIsInstalled> context) throws
}


private boolean appsInstalled(final String... applications) throws Exception {
private boolean appsInstalled(final String... applications) {
for (final String application : applications) {
final String app = PropUtils.injectProperties(application);
if (!isAppInstalled(app)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ private boolean isSatisfied(final String target, final long max, final long min)
final long freeSpace = file.getFreeSpace();
if (min != HasFreeSpace.UNDEFINED && freeSpace < min) {
return false;
} else if (max != HasFreeSpace.UNDEFINED && freeSpace > max) {
return false;
}
return max == HasFreeSpace.UNDEFINED || freeSpace <= max;
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class IfJavaVersionChecker implements ConditionChecker<IfJavaVersion> {

public static final String PROPERTY_JAVA_VERSION = "java.version";
private static final String PROPERTY_JAVA_VERSION = "java.version";


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

public class IfScriptChecker implements ConditionChecker<IfScript> {

public static final String CONTEXT_ENV = "env";
public static final String CONTEXT_PROPS = "props";
public static final String CONTEXT_TEST = "test";
public static final String CONTEXT_CONSOLE = "console";
public static final String CONTEXT_CONTEXT = "context";
private static final String CONTEXT_ENV = "env";
private static final String CONTEXT_PROPS = "props";
private static final String CONTEXT_TEST = "test";
private static final String CONTEXT_CONSOLE = "console";
private static final String CONTEXT_CONTEXT = "context";


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class RunningOnOSChecker implements ConditionChecker<RunningOnOS> {

public static final String PROPERTY_OS_NAME = "os.name";
private static final String PROPERTY_OS_NAME = "os.name";


/**
Expand All @@ -25,7 +25,7 @@ public boolean isSatisfied(final CheckerContext<RunningOnOS> context) throws Exc
}


public static String currentOS() {
private static String currentOS() {
return PropUtils.getSystemProperty(PROPERTY_OS_NAME).toLowerCase();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public boolean isSatisfied(final CheckerContext<UrlIsReachable> context) throws
}


private boolean isReachable(final String[] urlAddresses, final int timeout) throws Exception {
private boolean isReachable(final String[] urlAddresses, final int timeout) {
for (final String urlAddress : urlAddresses) {
final String url = PropUtils.injectProperties(urlAddress);
if (!isReachable(url, timeout)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ private ConditionCheckerExecutor() {
}


@SafeVarargs
@SuppressWarnings("rawtypes")
public static boolean isSatisfied(
final CheckerContext<?> context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

public final class InOutUtils {

public static final int BUFFER_SIZE = 1024;
public static final int EOF = -1;
private static final int BUFFER_SIZE = 1024;
private static final int EOF = -1;


private InOutUtils() {
Expand All @@ -29,9 +29,7 @@ public static boolean closeQuietly(final Closeable closeable) {
}
}

public static void copy(
final InputStream input, final OutputStream output
) throws IOException {
public static void copy(final InputStream input, final OutputStream output) throws IOException {
final byte[] bytes = new byte[BUFFER_SIZE];
int read;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public final class NetUtils {

public static final String HTTP_PREFIX = "http://";
private static final String HTTP_PREFIX = "http://";


private NetUtils() {
Expand All @@ -35,9 +35,7 @@ public static String fixScheme(final String address) {
return address;
}

public static File copyURLContentToFile(
final URLConnection connection, final String target
) throws Exception {
public static File copyURLContentToFile(final URLConnection connection, final String target) throws Exception {
InputStream input = null;
OutputStream output = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

public final class PropUtils {

public static final String VAR_PREFIX = "${";
public static final String VAR_POSTFIX = "}";
private static final String VAR_PREFIX = "${";
private static final String VAR_POSTFIX = "}";


private PropUtils() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public final class ReflexUtils {

public static final String PACKAGE_JAVA_LANG_ANNOTATION = "java.lang.annotation";
private static final String PACKAGE_JAVA_LANG_ANNOTATION = "java.lang.annotation";


private ReflexUtils() {
Expand Down Expand Up @@ -50,7 +50,7 @@ public static <T extends AccessibleObject> T makeAccessible(final T object) {
}

public static Collection<Annotation> findAllAnnotations(final Class<?> clazz) {
final List<Annotation> result = new ArrayList<Annotation>();
final List<Annotation> result = new ArrayList<>();
Class<?> current = clazz;

while (current != Object.class && current != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package com.github.vbauer.jconditions.annotation;

import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.Callable;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import com.github.vbauer.jconditions.checker.IfJavaVersionChecker;
import com.github.vbauer.jconditions.core.CheckerContext;
import com.github.vbauer.jconditions.core.ConditionChecker;
Expand All @@ -16,6 +8,13 @@
import com.github.vbauer.jconditions.misc.Never;
import com.github.vbauer.jconditions.util.FSUtils;
import com.github.vbauer.jconditions.util.PropUtils;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import java.net.URL;
import java.net.URLConnection;
import java.util.concurrent.Callable;

/**
* @author Vladislav Bauer
Expand All @@ -24,7 +23,7 @@
@Ignore
public abstract class AbstractAnnotationsTest implements InterfaceAnnotationsTest {

public final boolean isSatisfiedInnerCheck = false;
private final boolean isSatisfiedInnerCheck = false;


@Test
Expand Down Expand Up @@ -66,25 +65,25 @@ public void testAppIsInstalled() throws Exception {

@Test
@AppIsInstalled({ "fake-app-12345" })
public void testAppIsNotInstalled() throws Exception {
public void testAppIsNotInstalled() {
Assert.fail();
}

@Test
@ExistsOnFS("pom.xml")
public void testFileExists() throws Exception {
public void testFileExists() {
Assert.assertTrue(FSUtils.fileExists("pom.xml"));
}

@Test
@ExistsOnFS(value = "src", type = { ExistsOnFS.Type.DIRECTORY, ExistsOnFS.Type.SYMLINK })
public void testDirectoryExists() throws Exception {
public void testDirectoryExists() {
Assert.assertTrue(FSUtils.directoryExists("src"));
}

@Test
@ExistsOnFS("pom.xml2")
public void testFileNotExists() throws Exception {
public void testFileNotExists() {
Assert.fail();
}

Expand All @@ -102,7 +101,7 @@ public void testUrlIsReachable() throws Exception {

@Test
@UrlIsReachable("http://it-is-a-wrong-url-address.com")
public void testUrlIsNotReachable() throws Exception {
public void testUrlIsNotReachable() {
Assert.fail();
}

Expand All @@ -129,19 +128,19 @@ public void testHasClass() throws Exception {

@Test
@HasClass("org.wrong.package.WrongClass")
public void testHasClassNegative() throws Exception {
public void testHasClassNegative() {
Assert.fail();
}

@Test
@HasPackage("org.junit")
public void testHasPackage() throws Exception {
public void testHasPackage() {
Assert.assertNotNull(Package.getPackage("org.junit"));
}

@Test
@HasPackage("org.wrong.package")
public void testHasPackageNegative() throws Exception {
public void testHasPackageNegative() {
Assert.fail();
}

Expand Down Expand Up @@ -221,19 +220,20 @@ public void testResourceIsAvailableCache() {
checkTempFile("google.html");
}

@Test
@IfJavaVersion(IfJavaVersion.JAVA_7)
public void testIfJavaVersion7() {
Assert.assertTrue(IfJavaVersionChecker.javaVersion().contains("7"));
}

@Test
@IfJavaVersion(IfJavaVersion.JAVA_8)
public void testIfJavaVersion8() {
Assert.assertTrue(IfJavaVersionChecker.javaVersion().contains("8"));
Assert.assertNotNull(javaslang.Tuple0.instance());
}

@Test
@IfJavaVersion(IfJavaVersion.JAVA_9)
public void testIfJavaVersion9() {
Assert.assertTrue(IfJavaVersionChecker.javaVersion().contains("9"));
Assert.assertNotNull(javaslang.Tuple0.instance());
}

@Test
@HasFreeSpace(value = { "/", "C:\\" }, min = 1024)
public void testHasFreeSpace() {
Expand Down Expand Up @@ -283,7 +283,7 @@ private void checkTempFile(final String filePath) {
*/
private static final class ExceptionClass<T> implements ConditionChecker<T> {
@Override
public boolean isSatisfied(final CheckerContext<T> context) throws Exception {
public boolean isSatisfied(final CheckerContext<T> context) {
throw new RuntimeException();
}
}
Expand All @@ -293,7 +293,7 @@ public boolean isSatisfied(final CheckerContext<T> context) throws Exception {
*/
private class InnerClass<T> implements ConditionChecker<T> {
@Override
public boolean isSatisfied(final CheckerContext<T> context) throws Exception {
public boolean isSatisfied(final CheckerContext<T> context) {
return isSatisfiedInnerCheck;
}
}
Expand All @@ -303,7 +303,7 @@ public boolean isSatisfied(final CheckerContext<T> context) throws Exception {
*/
private static class StaticNestedClass<T> implements ConditionChecker<T> {
@Override
public boolean isSatisfied(final CheckerContext<T> context) throws Exception {
public boolean isSatisfied(final CheckerContext<T> context) {
return false;
}
}
Expand All @@ -313,7 +313,7 @@ public boolean isSatisfied(final CheckerContext<T> context) throws Exception {
*/
private static class ExtraContext implements Callable<Boolean> {
@Override
public Boolean call() throws Exception {
public Boolean call() {
return false;
}
}
Expand Down

0 comments on commit 8759a18

Please sign in to comment.