diff options
| author | Arne Schwabe <arne@rfc2549.org> | 2024-12-28 02:53:10 +0100 |
|---|---|---|
| committer | Arne Schwabe <arne@rfc2549.org> | 2024-12-28 02:53:10 +0100 |
| commit | 4a982ab52771dacf610d2c10bc64daf41fc3443b (patch) | |
| tree | f720ea9c45e2e18f5def656122dfdd7e1fbc9461 /main/src/test/java | |
| parent | 88be0bea2da73f1036be3fbea65f17fb1c967860 (diff) | |
Fix marschalling with very long long messages
Diffstat (limited to 'main/src/test/java')
| -rw-r--r-- | main/src/test/java/de/blinkt/openvpn/core/TestLog.kt | 35 | ||||
| -rw-r--r-- | main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java | 5 |
2 files changed, 37 insertions, 3 deletions
diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestLog.kt b/main/src/test/java/de/blinkt/openvpn/core/TestLog.kt new file mode 100644 index 00000000..4cce96ad --- /dev/null +++ b/main/src/test/java/de/blinkt/openvpn/core/TestLog.kt @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012-2024 Arne Schwabe + * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt + */ + +package de.blinkt.openvpn.core + +import org.junit.Assert +import org.junit.Test + +class TestLog { + + @Test + fun testMarschTooLong() + { + /* generate a string that is 16k long */ + var longtsring = ""; + + while (longtsring.length < 16384) + { + longtsring += "very very long string indeed" + } + val li = LogItem(VpnStatus.LogLevel.VERBOSE, longtsring) + + val libytes = li.marschaledBytes; + + Assert.assertTrue(libytes.size > 2000); + Assert.assertTrue(libytes.size < 12000); + + + val liback = LogItem(libytes, libytes.size) + val msgback = liback.getString(null) + Assert.assertTrue(msgback.endsWith("...[too long]")) + } +}
\ No newline at end of file diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java b/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java index e024bf90..be4621c6 100644 --- a/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java +++ b/main/src/test/java/de/blinkt/openvpn/core/TestLogFileHandler.java @@ -7,10 +7,9 @@ package de.blinkt.openvpn.core; import android.annotation.SuppressLint; -import junit.framework.Assert; - import org.junit.Before; import org.junit.Test; +import org.junit.Assert; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -42,7 +41,7 @@ public class TestLogFileHandler { lfh.writeEscapedBytes(testUnescaped); byte[] result = byteArrayOutputStream.toByteArray(); - Assert.assertTrue(Arrays.equals(expectedEscaped, result)); + Assert.assertArrayEquals(expectedEscaped, result); } @Test |
