This is an automated email from the ASF dual-hosted git repository.
veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git
The following commit(s) were added to refs/heads/master by this push:
new 616e29494 Change TestBlob.value type from int to byte
616e29494 is described below
commit 616e29494e5aac202007bad434af68668b37faff
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Sun Feb 1 12:21:26 2026 +0000
Change TestBlob.value type from int to byte
- Change the field type from int to byte to better represent the byte values
- Add a compatibility constructor that accepts int with range validation
- Use Guava Preconditions.checkArgument() to validate the 0-255 range
- Add Guava dependency to blob-testutils pom.xml
- Update read() and writeTo() to use (value & 0xFF) for proper unsigned
conversion
---
pom.xml | 5 +++++
testing/blob-testutils/pom.xml | 4 ++++
.../java/org/apache/axiom/testutils/blob/TestBlob.java | 17 +++++++++++++----
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index a57fa5879..b6ad51145 100644
--- a/pom.xml
+++ b/pom.xml
@@ -527,6 +527,11 @@
<artifactId>auto-service-annotations</artifactId>
<version>${auto-service.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>33.3.1-jre</version>
+ </dependency>
<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
diff --git a/testing/blob-testutils/pom.xml b/testing/blob-testutils/pom.xml
index 505c42942..afb5a6fb5 100644
--- a/testing/blob-testutils/pom.xml
+++ b/testing/blob-testutils/pom.xml
@@ -40,5 +40,9 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git
a/testing/blob-testutils/src/main/java/org/apache/axiom/testutils/blob/TestBlob.java
b/testing/blob-testutils/src/main/java/org/apache/axiom/testutils/blob/TestBlob.java
index 5231aee2f..ebddf6ebb 100644
---
a/testing/blob-testutils/src/main/java/org/apache/axiom/testutils/blob/TestBlob.java
+++
b/testing/blob-testutils/src/main/java/org/apache/axiom/testutils/blob/TestBlob.java
@@ -23,6 +23,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import com.google.common.base.Preconditions;
+
import org.apache.axiom.blob.Blob;
import org.apache.axiom.ext.io.StreamCopyException;
@@ -31,14 +33,21 @@ import org.apache.axiom.ext.io.StreamCopyException;
* specified value.
*/
public class TestBlob implements Blob {
- final int value;
+ final byte value;
final long length;
- public TestBlob(int value, long length) {
+ public TestBlob(byte value, long length) {
this.value = value;
this.length = length;
}
+ public TestBlob(int value, long length) {
+ Preconditions.checkArgument(
+ value >= 0 && value < 256, "value must be in the range 0-255,
got: %s", value);
+ this.value = (byte) value;
+ this.length = length;
+ }
+
@Override
public InputStream getInputStream() throws IOException {
return new InputStream() {
@@ -50,7 +59,7 @@ public class TestBlob implements Blob {
return -1;
} else {
position++;
- return value;
+ return value & 0xFF;
}
}
};
@@ -60,7 +69,7 @@ public class TestBlob implements Blob {
public void writeTo(OutputStream out) throws StreamCopyException {
for (long i = 0; i < length; i++) {
try {
- out.write(value);
+ out.write(value & 0xFF);
} catch (IOException ex) {
throw new StreamCopyException(StreamCopyException.WRITE, ex);
}