Skip to content

Commit

Permalink
Merge 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
  src/test/java/jssc/SerialNativeInterfaceTest.java
  • Loading branch information
hiddenalpha committed Aug 7, 2024
2 parents 6d8ab61 + 8dd99a4 commit 5f8e164
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
java-version: 11
distribution: temurin

- run: sudo apt-get install socat ${{ matrix.packages }}
- run: sudo apt-get update && sudo apt-get install socat ${{ matrix.packages }}
- run: mvn -P "${{ matrix.profile }}" --batch-mode

macos:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A small, single Java library for working with serial ports across various system
<dependency>
<groupId>io.github.java-native</groupId>
<artifactId>jssc</artifactId>
<version>2.9.5</version>
<version>2.9.6</version>
</dependency>
```
* or Gradle (KTS)
Expand All @@ -17,7 +17,7 @@ repositories {
mavenCentral()
}
dependencies {
implementation("io.github.java-native:jssc:2.9.5")
implementation("io.github.java-native:jssc:2.9.6")
}
```
* or Gradle (Groovy)
Expand All @@ -26,7 +26,7 @@ repositories {
mavenCentral()
}
dependencies {
implementation 'io.github.java-native:jssc:2.9.5'
implementation 'io.github.java-native:jssc:2.9.6'
}
```
* [API code examples](../../wiki/examples)
Expand Down
23 changes: 15 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>io.github.java-native</groupId>
<artifactId>jssc</artifactId>
<version>2.9.6-SNAPSHOT</version>
<version>2.9.7-SNAPSHOT</version>

<name>Java Simple Serial Connector</name>
<description>
Expand Down Expand Up @@ -51,7 +51,8 @@
<jar.dependencies.skip>true</jar.dependencies.skip>

<!-- dependency versions a-z -->
<dependency.junit.version>4.12</dependency.junit.version>
<dependency.junit.version>4.13.2</dependency.junit.version>
<dependency.log4j.version>2.22.0</dependency.log4j.version>
<dependency.logback.version>1.2.3</dependency.logback.version>
<dependency.nativelibloader.version>2.5.0</dependency.nativelibloader.version>

Expand Down Expand Up @@ -82,15 +83,21 @@
<version>${dependency.nativelibloader.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${dependency.junit.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${dependency.log4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${dependency.logback.version}</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${dependency.log4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${dependency.junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jssc/SerialNativeInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class SerialNativeInterface {

private static final String libVersion = "2.9.5";
private static final String libVersion = "2.9.6";

/** Linux **/
public static final int OS_LINUX = 0;
Expand Down
Binary file modified src/main/resources-precompiled/natives/linux_32/libjssc.so
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/linux_64/libjssc.so
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/linux_arm/libjssc.so
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/linux_arm64/libjssc.so
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/linux_ppc/libjssc.so
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/linux_riscv32/libjssc.so
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/linux_riscv64/libjssc.so
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/osx_64/libjssc.dylib
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/osx_arm64/libjssc.dylib
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/windows_32/jssc.dll
Binary file not shown.
Binary file modified src/main/resources-precompiled/natives/windows_64/jssc.dll
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion src/test/java/jssc/SerialNativeInterfaceTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jssc;

import jssc.junit.rules.DisplayMethodNameRule;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -13,7 +14,7 @@
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;

public class SerialNativeInterfaceTest {
public class SerialNativeInterfaceTest extends DisplayMethodNameRule {

@Test
public void testInitNativeInterface() {
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/jssc/VirtualPortTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import jssc.junit.rules.DisplayMethodNameRule;
import jssc.junit.rules.VirtualPortRule;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;

public class VirtualPortTest {
public class VirtualPortTest extends DisplayMethodNameRule {

private static final String HELLO_WORLD = "Hello, world!";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jssc.bootpath;

import jssc.SerialNativeInterface;
import jssc.junit.rules.DisplayMethodNameRule;
import org.junit.Test;

import static org.junit.Assert.assertTrue;
Expand All @@ -16,7 +17,7 @@
* - maven-surefire-plugin DOES offer JVM unloading between classes using <code>reuseForks=false</code>
* - Unloading is needed due to NativeLoader.loadLibrary(...) calls System.loadLibrary(...) which is static
*/
public class ManualBootLibraryPathFailedTest {
public class ManualBootLibraryPathFailedTest extends DisplayMethodNameRule {
@Test
public void testBootPathOverride() {
String nativeLibDir = "/"; // This should be valid on all platforms
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/jssc/bootpath/ManualBootLibraryPathTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jssc.bootpath;

import jssc.SerialNativeInterface;
import jssc.junit.rules.DisplayMethodNameRule;
import org.junit.Test;
import org.scijava.nativelib.NativeLibraryUtil;

Expand All @@ -18,7 +19,7 @@
* - maven-surefire-plugin DOES offer JVM unloading between classes using <code>reuseForks=false</code>
* - Unloading is needed due to NativeLoader.loadLibrary(...) calls System.loadLibrary(...) which is static
*/
public class ManualBootLibraryPathTest {
public class ManualBootLibraryPathTest extends DisplayMethodNameRule {
@Test
public void testBootPathOverride() {
String nativeLibDir = NativeLibraryUtil.getPlatformLibraryPath(System.getProperty("user.dir") + "/target/cmake/natives/");
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/jssc/junit/rules/DisplayMethodNameRule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package jssc.junit.rules;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.MarkerManager;
import org.junit.Rule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;

/**
* Adds the method name to the JUnit logs, useful for debugging
*/
public class DisplayMethodNameRule {
@Rule
public TestWatcher methodWatcher = new TestWatcher() {
@Override
protected void starting(Description description) {
Logger log = LogManager.getLogger(description.getTestClass());
log.info(MarkerManager.getMarker("MethodName"), description.getMethodName());
}
};
}
10 changes: 6 additions & 4 deletions src/test/java/jssc/junit/rules/VirtualPortRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import jssc.SerialNativeInterface;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class VirtualPortRule implements TestRule {

private static final Logger LOG = LoggerFactory.getLogger(VirtualPortRule.class);
private static final Logger LOG = LogManager.getLogger(VirtualPortRule.class);

private static final ExecutorService executor = Executors.newCachedThreadPool();

Expand Down Expand Up @@ -97,7 +99,7 @@ public void evaluate() throws Throwable {
} finally {
// stop socat
for (final Future<?> process : VirtualPortRule.this.processes) {
process.cancel(false);
process.cancel(true);
}

executor.shutdown();
Expand Down
22 changes: 22 additions & 0 deletions src/test/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Logging settings for unit tests

# The root logger with appender name
rootLogger=DEBUG,STDOUT,TESTNAME

# Assign STDOUT a valid appender & define its layout
appender.console.name=STDOUT
appender.console.type=Console
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=[%highlight{%p}{INFO=blue}] [%c{1}] %m%n

# Make logs for Junit4 method names look like maven
appender.testName.name=TESTNAME
appender.testName.type=Console
appender.testName.layout.type=PatternLayout
appender.testName.layout.pattern=[%highlight{%p}{INFO=blue}] Running %c.%highlight{%m}{FATAL=bold,white, ERROR=bold,white, WARN=bold,white, INFO=bold,white, DEBUG=bold,white, TRACE=bold,white}%n
appender.testName.filter.1.type=MarkerFilter
appender.testName.filter.1.marker=MethodName
appender.console.filter.1.type=MarkerFilter
appender.console.filter.1.marker=MethodName
appender.console.filter.1.onMatch=DENY
appender.console.filter.1.onMismatch=ACCEPT

0 comments on commit 5f8e164

Please sign in to comment.