pax_global_header00006660000000000000000000000064130646431220014513gustar00rootroot0000000000000052 comment=d1db86a0d2966dcf47087340bbd0727a9d508b3e finbin-0.6.2/000077500000000000000000000000001306464312200127655ustar00rootroot00000000000000finbin-0.6.2/.gitignore000066400000000000000000000002161306464312200147540ustar00rootroot00000000000000# for Eclipse .classpath .project .settings # for IDEA *.iml *.ipr *.iws .idea/ # for build target build # for mac .DS_Store /examples/ finbin-0.6.2/LICENSE000066400000000000000000000020531306464312200137720ustar00rootroot00000000000000MIT License Copyright (c) 2017 Tom Misawa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. finbin-0.6.2/README.md000066400000000000000000000100211306464312200142360ustar00rootroot00000000000000# Overview 'finbin' is a java library for finding the specified sequence of bytes from the big-size sequence of bytes. You can find out quickly from the big size (like mega-bytes binary) of the binary data. It is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0). [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.riversun/finbin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.riversun/finbin) ## you want to search byte[] from a BIG file? Check this.You can search sequence of bytes from gigabyte-order file with low memory consumption. https://github.com/riversun/bigdoc # classes & methods ## BigBinarySearcher class - public List searchBigBytes(byte[] srcBytes, byte[] searchBytes) - For big byte array binary data, search bytes faster in a concurrent processing. - and derivation of the method ## Example for big bytes(Multi-Threaded) ### search for a sequence of bytes by using *searchBigBytes* If you want to search an array of bytes of mega-bytes order of size,try to use *searchBigBytes*. ```java package org.example; import java.util.List; import org.riversun.finbin.BigBinarySearcher; public class Example { public static void main(String[] args) throws Exception { BigBinarySearcher bbs = new BigBinarySearcher(); // UTF-8 without BOM byte[] iamBigSrcBytes = "Hello world.It's a small world.".getBytes("utf-8"); byte[] searchBytes = "world".getBytes("utf-8"); List indexList = bbs.searchBigBytes(iamBigSrcBytes, searchBytes); System.out.println("indexList=" + indexList); } } ``` ## BinarySearcher class - public int indexOf(byte[] srcBytes, byte[] searchBytes) - For small byte array binary data, Returns the index within this byte-array of the first occurrence of the specified(search bytes) byte array. - public List searchBytes(byte[] srcBytes, byte[] searchBytes) - For small byte array binary data, Search bytes in byte array returns indexes within this byte-array of all occurrences of the specified(search bytes) byte array. - and derivation of the method ----- ## Examples for small bytes(Single-Threaded) ### search for a sequence of bytes by using *indexOf* ```java package org.example; import org.riversun.finbin.BinarySearcher; public class Example1 { public static void main(String[] args) throws Exception { BinarySearcher bs = new BinarySearcher(); // UTF-8 without BOM byte[] srcBytes = "Hello world.It's a small world.".getBytes("utf-8"); byte[] searchBytes = "world".getBytes("utf-8"); int index = bs.indexOf(srcBytes, searchBytes); System.out.println("index=" + index); } } ``` 1. srcBytes is ``` 0x48,0x65,0x6C,0x6C,0x6F,0x20,0x77,0x6F,0x72,0x6C,0x64,0x2E,0x49,0x74,0x27,0x73,0x20,0x61,0x20,0x73,0x6D,0x61,0x6C,0x6C,0x20,0x77,0x6F,0x72,0x6C,0x64,0x2E ``` 2. searchBytes is ``` 0x77,0x6F,0x72,0x6C,0x64 ``` so it results in ``` index=6 ``` ### search for a sequence of bytes by using *searchBytes* ```java package org.example; import java.util.List; import org.riversun.finbin.BinarySearcher; public class Example2 { public static void main(String[] args) throws Exception { BinarySearcher bs = new BinarySearcher(); // UTF-8 without BOM byte[] srcBytes = "Hello world.It's a small world.".getBytes("utf-8"); byte[] searchBytes = "world".getBytes("utf-8"); List indexList = bs.searchBytes(srcBytes, searchBytes); System.out.println("indexList=" + indexList); } } ``` so it results in ``` indexList=[6, 25] ``` - Please note The result is different depending on the environment of the Java ,Java version and compiler or runtime optimization. # More Details See javadoc as follows. https://riversun.github.io/javadoc/finbin/ #Downloads ## maven - You can add dependencies to maven pom.xml file. ```xml org.riversun finbin 0.6.2 ``` finbin-0.6.2/pom.xml000066400000000000000000000066661306464312200143200ustar00rootroot00000000000000 4.0.0 org.riversun finbin 0.6.2 jar finbin Hi-speed search for a byte sequence in a big byte array. https://github.com/riversun/finbin MIT License http://www.opensource.org/licenses/mit-license.php repo https://github.com/riversun/finbin scm:git:git://github.com/riversun/finbin.git scm:git:git://github.com/riversun/finbin.git riversun Tom Misawa riversun.org@gmail.com http://riversun.org GitHub https://github.com/riversun/finbin/issues UTF-8 junit junit 4.7 test ossrh https://oss.sonatype.org/content/repositories/snapshots ossrh https://oss.sonatype.org/service/local/staging/deploy/maven2/ org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 examples/**/* org.apache.maven.plugins maven-gpg-plugin 1.5 sign-artifacts verify sign org.apache.maven.plugins maven-source-plugin 2.3 attach-sources jar org.apache.maven.plugins maven-javadoc-plugin attach-javadocs jar true 1.5 protected UTF-8 UTF-8 UTF-8 -J-Duser.language=en finbin-0.6.2/src/000077500000000000000000000000001306464312200135545ustar00rootroot00000000000000finbin-0.6.2/src/main/000077500000000000000000000000001306464312200145005ustar00rootroot00000000000000finbin-0.6.2/src/main/java/000077500000000000000000000000001306464312200154215ustar00rootroot00000000000000finbin-0.6.2/src/main/java/org/000077500000000000000000000000001306464312200162105ustar00rootroot00000000000000finbin-0.6.2/src/main/java/org/riversun/000077500000000000000000000000001306464312200200655ustar00rootroot00000000000000finbin-0.6.2/src/main/java/org/riversun/finbin/000077500000000000000000000000001306464312200213325ustar00rootroot00000000000000finbin-0.6.2/src/main/java/org/riversun/finbin/BigBinarySearcher.java000066400000000000000000000143731306464312200255300ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; /** * * Search target big bytes(byte[]) from source bytes(byte[])
*
* This class is going to scan byte[] data in concurrent by using threads, it is * effective(means faster speed) in big size(kiloBytes-megaBytes) byte[] data.
* * @author Tom Misawa (riversun.org@gmail.com) */ public class BigBinarySearcher extends BinarySearcher { // max number of thread private static final int DEFAULT_MAX_NUM_OF_THREADS = 128; // thread number no limit public static final int THREADS_NO_LIMIT = 0; // magic number guided by experiment private static final int DEFAULT_ANALYZE_BYTE_ARRAY_UNIT_SIZE = 512; private int analyzeByteArrayUnitSize = DEFAULT_ANALYZE_BYTE_ARRAY_UNIT_SIZE; private int maxNumOfThreads = DEFAULT_MAX_NUM_OF_THREADS; /** * Set buffer size for searching a sequence of bytes Increased the size of * buffer does not means improving a performance
* * @param bufferSize */ public void setBufferSize(int bufferSize) { this.analyzeByteArrayUnitSize = bufferSize; } /** * Set max number of thread to concurrent access to byte[] data
* Increased the number of threads does not means improving a performance
* * @param maxNumOfThreads */ public void setMaxNumOfThreads(int maxNumOfThreads) { this.maxNumOfThreads = maxNumOfThreads; } /** * Search bytes faster in a concurrent processing. * * @param srcBytes * @param searchBytes * @return */ public List searchBigBytes(byte[] srcBytes, byte[] searchBytes) { int numOfThreadsOptimized = (srcBytes.length / analyzeByteArrayUnitSize); if (numOfThreadsOptimized == 0) { numOfThreadsOptimized = 1; } return searchBigBytes(srcBytes, searchBytes, numOfThreadsOptimized); } /** * Search bytes faster in a concurrent processing with concurrency level. * * @param srcBytes * @param searchBytes * @param numOfThreads * @return */ public List searchBigBytes(byte[] srcBytes, byte[] searchBytes, int numOfThreads) { if (numOfThreads == 0) { numOfThreads = 1; } final int sizeOfSrcBytes = srcBytes.length; final int sizeOfSearchBytes = searchBytes.length; final int bytesToReadBlockSize = (srcBytes.length - (sizeOfSearchBytes)) / numOfThreads; final int threadPoolSize; if (maxNumOfThreads == THREADS_NO_LIMIT) { threadPoolSize = numOfThreads; } else { threadPoolSize = maxNumOfThreads; } final ExecutorService executorService = Executors.newFixedThreadPool(threadPoolSize); final List>> futureList = new ArrayList>>(); for (int i = 0; i < numOfThreads; i++) { final int offset = bytesToReadBlockSize * i; final int readLeng; if (i == numOfThreads - 1) { // if it's the last element. readLeng = sizeOfSrcBytes - offset - 1; } else { // else , add the overlapping part size to blockSize readLeng = bytesToReadBlockSize + sizeOfSearchBytes; } final Future> future = executorService.submit(new BinarySearchTask(srcBytes, searchBytes, offset, readLeng)); futureList.add(future); } executorService.shutdown(); // Remove duplicate indexes final List resultIndexList = new CopyOnWriteArrayList(); for (Future> future : futureList) { try { List rawIndexList = future.get(); for (int i = 0; i < rawIndexList.size(); i++) { Integer integer = rawIndexList.get(i); if (resultIndexList.contains(integer)) { // if already exists , skip } else { resultIndexList.add(integer); } } } catch (InterruptedException e) { } catch (ExecutionException e) { } } // Sort in ascending order resultIndexList.sort(new Comparator() { public int compare(Integer num1, Integer num2) { if (num1 > num2) { return 1; } else if (num1 < num2) { return -1; } return 0; } }); return resultIndexList; } final class BinarySearchTask implements Callable> { final byte[] srcBytes; final byte[] searchBytes; final int offset; final int readLeng; BinarySearchTask(byte[] srcBytes, byte[] searchBytes, int offset, int readLeng) { this.srcBytes = srcBytes; this.offset = offset; this.readLeng = readLeng; this.searchBytes = searchBytes; } public List call() throws Exception { final BinarySearcher binSearcher = new BinarySearcher(); final List resultIndexList = binSearcher.searchBytes(srcBytes, searchBytes, offset, offset + readLeng); return resultIndexList; } } } finbin-0.6.2/src/main/java/org/riversun/finbin/BinarySearcher.java000066400000000000000000000124071306464312200251020ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; import java.util.ArrayList; import java.util.List; /** * * Search target bytes(byte[]) from source bytes(byte[])
*
* This class is going to scan byte[] data to sequential, it is effective in * small size(less than 1kBytes) byte[] data.
* * @author Tom Misawa (riversun.org@gmail.com) * */ public class BinarySearcher { /** * Returns the index within this byte-array of the first occurrence of the * specified(search bytes) byte array.
* * @param srcBytes * @param searchBytes * @return */ public int indexOf(byte[] srcBytes, byte[] searchBytes) { final int startIndex = 0; final int endIndex = srcBytes.length - 1; return indexOf(srcBytes, searchBytes, startIndex, endIndex); } /** * Returns the index within this byte-array of the first occurrence of the * specified(search bytes) byte array.
* Starting the search at the specified index
* * @param srcBytes * @param searchBytes * @param startIndex * @return */ public int indexOf(byte[] srcBytes, byte[] searchBytes, int startIndex) { final int endIndex = srcBytes.length - 1; return indexOf(srcBytes, searchBytes, startIndex, endIndex); } /** * Returns the index within this byte-array of the first occurrence of the * specified(search bytes) byte array.
* Starting the search at the specified index, and end at the specified * index. * * @param srcBytes * @param searchBytes * @param startIndex * @param endIndex * @return */ public int indexOf(byte[] srcBytes, byte[] searchBytes, int startIndex, int endIndex) { final int searchBytesLeng = searchBytes.length; if (searchBytesLeng == 0 || (endIndex - startIndex + 1) < searchBytesLeng) { return -1; } final int srcBytesLeng = srcBytes.length; final int maxScanStartPosIdx = srcBytesLeng - searchBytesLeng; final int loopEndIdx; if (endIndex < maxScanStartPosIdx) { loopEndIdx = endIndex; } else { loopEndIdx = maxScanStartPosIdx; } int lastScanIdx = -1; label: // goto label for (int i = startIndex; i <= loopEndIdx; i++) { for (int j = 0; j < searchBytesLeng; j++) { if (srcBytes[i + j] != searchBytes[j]) { continue label; } lastScanIdx = i + j; } if (endIndex < lastScanIdx || lastScanIdx - i + 1 < searchBytesLeng) { // it becomes more than the last index // or less than the number of search bytes return -1; } return i; } return -1; } /** * Search bytes in byte array returns indexes within this byte-array of all * occurrences of the specified(search bytes) byte array. * * @param srcBytes * @param searchBytes * @return result index list */ public List searchBytes(byte[] srcBytes, byte[] searchBytes) { final int startIdx = 0; final int endIdx = srcBytes.length - 1; return searchBytes(srcBytes, searchBytes, startIdx, endIdx); } public List searchBytes(byte[] srcBytes, byte[] searchBytes, int searchStartIndex) { final int endIdx = srcBytes.length - 1; return searchBytes(srcBytes, searchBytes, searchStartIndex, endIdx); } /** * Search bytes in byte array returns indexes within this byte-array of all * occurrences of the specified(search bytes) byte array in the specified * range * * @param srcBytes * @param searchBytes * @param searchStartIndex * @param searchEndIndex * @return result index list */ public List searchBytes(byte[] srcBytes, byte[] searchBytes, int searchStartIndex, int searchEndIndex) { final int destSize = searchBytes.length; final List positionIndexList = new ArrayList(); int cursor = searchStartIndex; while (cursor < searchEndIndex + 1) { final int index = indexOf(srcBytes, searchBytes, cursor, searchEndIndex); if (index >= 0) { positionIndexList.add(index); cursor = index + destSize; } else { cursor++; } } return positionIndexList; } } finbin-0.6.2/src/main/java/org/riversun/finbin/BinaryUtil.java000066400000000000000000000125641306464312200242670ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Paths; /** * Helper class for finbin test
* * @author Tom Misawa (riversun.org@gmail.com) * */ public class BinaryUtil { /** * Get UTF-8 without BOM encoded bytes from String * * @param text * @return */ public static byte[] getBytes(String text) { byte[] bytes = new byte[] {}; try { bytes = text.getBytes("utf-8"); } catch (UnsupportedEncodingException e) { } return bytes; } /** * Copy src bytes[] into dest bytes[] * * @param dest * @param src * @param copyToIndex */ public static void memcopy(byte[] dest, byte[] src, int copyToIndex) { System.arraycopy(src, 0, dest, copyToIndex, src.length); } /** * load from file * * @param file * @return */ public static byte[] loadBytesFromFile(File file) { byte[] bytes = null; try { bytes = Files.readAllBytes(Paths.get(file.getAbsolutePath())); } catch (IOException e) { e.printStackTrace(); } return bytes; } /** * save to file * * @param data * @param file */ public static void saveBytesToFile(byte[] data, File file) { if (data == null) { return; } FileOutputStream fos = null; BufferedOutputStream bos = null; try { fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos); bos.write(data); bos.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (bos != null) { try { bos.close(); } catch (IOException e) { e.printStackTrace(); } } if (fos != null) { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } /** * Pretty print byte[] with Ascii char and subscript of the array * * @param array */ public static void print(byte[] array) { String[] name = new String[] { "+0", "+1", "+2", "+3", "+4", "+5", "+6", "+7", "+8", "+9", "+a", "+b", "+c", "+d", "+e", "+f" }; for (int i = 0; i < 16; i++) { System.out.print(name[i] + " "); } System.out.println(); for (int i = 0; i < array.length; i++) { if (i != 0 && i % 16 == 0) { System.out.println(); } byte b = array[i]; System.out.print(String.format("%02x", b).toUpperCase() + " "); } System.out.println(); } /** * Pretty print byte[] with Ascii char * * @param array */ public static void printWithAscii(byte[] array) { String[] name = new String[] { "+0", "+1", "+2", "+3", "+4", "+5", "+6", "+7", "+8", "+9", "+a", "+b", "+c", "+d", "+e", "+f" }; for (int i = 0; i < 16; i++) { System.out.print(name[i] + " " + " "); } System.out.println(); for (int i = 0; i < array.length; i++) { if (i != 0 && i % 16 == 0) { System.out.println(); } byte b = array[i]; String str = " "; if (32 <= (int) b && (int) b <= 126) { str = String.valueOf((char) b); } System.out.print(String.format("%02x", b).toUpperCase() + "(" + str + ")" + " "); } System.out.println(); } /** * Pretty print byte[] with Ascii char and subscript of the array * * @param array */ public static void printWithAsciiWithIndex(byte[] array) { String[] name = new String[] { "+0", "+1", "+2", "+3", "+4", "+5", "+6", "+7", "+8", "+9", "+a", "+b", "+c", "+d", "+e", "+f" }; for (int i = 0; i < 16; i++) { System.out.print(name[i] + " " + " " + " "); } System.out.println(); for (int i = 0; i < array.length; i++) { if (i != 0 && i % 16 == 0) { System.out.println(); } byte b = array[i]; String str = " "; if (32 <= (int) b && (int) b <= 126) { str = String.valueOf((char) b); } System.out.print(String.format("%02x", b).toUpperCase() + "(" + str + ")" + "[" + String.format("%03d", i) + "]" + " "); } System.out.println(); } } finbin-0.6.2/src/test/000077500000000000000000000000001306464312200145335ustar00rootroot00000000000000finbin-0.6.2/src/test/java/000077500000000000000000000000001306464312200154545ustar00rootroot00000000000000finbin-0.6.2/src/test/java/org/000077500000000000000000000000001306464312200162435ustar00rootroot00000000000000finbin-0.6.2/src/test/java/org/riversun/000077500000000000000000000000001306464312200201205ustar00rootroot00000000000000finbin-0.6.2/src/test/java/org/riversun/finbin/000077500000000000000000000000001306464312200213655ustar00rootroot00000000000000finbin-0.6.2/src/test/java/org/riversun/finbin/AppTest.java000066400000000000000000000030221306464312200236050ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; /** * Test suite
* * Tom Misawa (riversun.org@gmail.com) */ @RunWith(Suite.class) @SuiteClasses({ TestBinarySearcher.class, TestBigBinarySearcher.class }) public class AppTest { } finbin-0.6.2/src/test/java/org/riversun/finbin/GenTestBinaryData.java000066400000000000000000000037301306464312200255430ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; import java.io.File; /** * * Binary file generator for Test
* Tom Misawa (riversun.org@gmail.com) */ public class GenTestBinaryData { public static void main(String[] args) { // please edit final int size = 64 * 1024; // please edit final String filepath = "src/test/resources/finbin_test_064kbyte.bin"; // please edit final int step = 5000; byte[] testBinary = new byte[size]; byte[] textBytes = BinaryUtil.getBytes("hello world."); // place binary token to search for (int i = 0; i < testBinary.length; i += step) { BinaryUtil.memcopy(testBinary, textBytes, i); } // save to file BinaryUtil.saveBytesToFile(testBinary, new File(filepath)); } } finbin-0.6.2/src/test/java/org/riversun/finbin/TestBase.java000066400000000000000000000070461306464312200237510ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; /** * Unit test base class provides TEST VALUEs
* * Tom Misawa (riversun.org@gmail.com) * */ public class TestBase { public static final byte[] SMALL_SIZE_TEST_BYTES; public static final String SMALL_SIZE_TEST_TEXT = // small size "Hello I'm so happy.Hello world.I love this world.It's a small world."; public static final byte[] MID_SIZE_TEST_BYTES; public static final String MID_SIZE_TEST_TEXT = // mid size "Though yet of Hamlet our dear brother’s death The" + // L00 " memory be green, and that it us befitted To bear " + // L01 "our hearts in grief and our whole kingdom To be co" + // L02 "ntracted in one brow of woe, Yet so far hath discr" + // L03 "etion fought with nature That we with wisest sorro" + // L04 "w think on him Together with remembrance of oursel" + // L05 "ves. Therefore our sometime sister, now our queen," + // L06 " Th' imperial jointress to this warlike state, Hav" + // L07 "e we?as ’twere with a defeated joy, With an auspi" + // L08 "cious and a dropping eye, With mirth in funeral an" + // L09 "d with dirge in marriage, In equal scale weighing " + // L11 "delight and dole? Taken to wife. Nor have we herei" + // L12 "n barred Your better wisdoms, which have freely go" + // L13 "ne With this affair along. For all, our thanks. No" + // L14 "w follows that you know. Young Fortinbras, Holding" + // L15 " a weak supposal of our worth Or thinking by our l" + // L16 "ate dear brother’s death Our state to be disjoint" + // L17 " and out of frame, Colleagued with the dream of hi" + // L18 "s advantage, He hath not failed to pester us with " + // L19 "message Importing the surrender of those lands Los" + // L20 "t by his father, with all bonds of law, To our mos" + // L21 "t valiant brother. So much for him.";// L22 static { MID_SIZE_TEST_BYTES = getBytes(MID_SIZE_TEST_TEXT); SMALL_SIZE_TEST_BYTES = getBytes(SMALL_SIZE_TEST_TEXT); } static byte[] getBytes(String text) { return BinaryUtil.getBytes(text); } static long startTime = 0; static long stopTime = 0; static void startTimer() { startTime = System.currentTimeMillis(); } static long stopTimer() { stopTime = System.currentTimeMillis(); return (stopTime - startTime); } } finbin-0.6.2/src/test/java/org/riversun/finbin/TestBigBinarySearcher.java000066400000000000000000000157341306464312200264250ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; import static org.junit.Assert.assertTrue; import java.io.File; import java.util.Arrays; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; public class TestBigBinarySearcher extends TestBase { @Rule public TestName name = new TestName(); @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void testSearchBytes_64K() { BinarySearcher bs = new BinarySearcher(); // Test binary size is 3 mega-bytes. byte[] srcBytes = BinaryUtil.loadBytesFromFile(new File("src/test/resources/finbin_test_064kbyte.bin")); String searchText = "hello world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 0, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000 }; startTimer(); List resultList = bs.searchBytes(srcBytes, searchBytes); long ellapsedTimeInMillis = stopTimer(); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); System.out.println("[" + name.getMethodName() + "] ellapsed " + ellapsedTimeInMillis + " millis for " + srcBytes.length / 1024 + " kbytes"); } @Test public void testSearchBytes_500K() { BinarySearcher bs = new BinarySearcher(); // Test binary size is 3 mega-bytes. byte[] srcBytes = BinaryUtil.loadBytesFromFile(new File("src/test/resources/finbin_test_500kbyte.bin")); String searchText = "hello world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000, 400000, 450000, 500000 }; startTimer(); List resultList = bs.searchBytes(srcBytes, searchBytes); long ellapsedTimeInMillis = stopTimer(); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); System.out.println("[" + name.getMethodName() + "] ellapsed " + ellapsedTimeInMillis + " millis for " + srcBytes.length / 1024 + " kbytes"); } @Test public void testSearchBigBytes_64K() { BigBinarySearcher bbs = new BigBinarySearcher(); // Test binary size is 3 mega-bytes. byte[] srcBytes = BinaryUtil.loadBytesFromFile(new File("src/test/resources/finbin_test_064kbyte.bin")); String searchText = "hello world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 0, 5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000 }; startTimer(); List resultList = bbs.searchBigBytes(srcBytes, searchBytes); long ellapsedTimeInMillis = stopTimer(); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); System.out.println("[" + name.getMethodName() + "] ellapsed " + ellapsedTimeInMillis + " millis for " + srcBytes.length / 1024 + " kbytes"); } @Test public void testSearchBigBytes_500K() { BigBinarySearcher bbs = new BigBinarySearcher(); // Test binary size is 3 mega-bytes. byte[] srcBytes = BinaryUtil.loadBytesFromFile(new File("src/test/resources/finbin_test_500kbyte.bin")); String searchText = "hello world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 0, 50000, 100000, 150000, 200000, 250000, 300000, 350000, 400000, 450000, 500000 }; startTimer(); List resultList = bbs.searchBigBytes(srcBytes, searchBytes); long ellapsedTimeInMillis = stopTimer(); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); System.out.println("[" + name.getMethodName() + "] ellapsed " + ellapsedTimeInMillis + " millis for " + srcBytes.length / 1024 + " kbytes"); } @Test public void testSearchBigBytes_1000K() { BigBinarySearcher bbs = new BigBinarySearcher(); // Test binary size is 3 mega-bytes. byte[] srcBytes = BinaryUtil.loadBytesFromFile(new File("src/test/resources/finbin_test_1mbyte.bin")); String searchText = "hello world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 0, 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000 }; startTimer(); List resultList = bbs.searchBigBytes(srcBytes, searchBytes); long ellapsedTimeInMillis = stopTimer(); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); System.out.println("[" + name.getMethodName() + "] ellapsed " + ellapsedTimeInMillis + " millis for " + srcBytes.length / 1024 + " kbytes"); } @Test public void testSearchBigBytes_3000K() { BigBinarySearcher bbs = new BigBinarySearcher(); // Test binary size is 3 mega-bytes. byte[] srcBytes = BinaryUtil.loadBytesFromFile(new File("src/test/resources/finbin_test_3mbyte.bin")); String searchText = "hello world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 0, 200000, 400000, 600000, 800000, 1000000, 1200000, 1400000, 1600000, 1800000, 2000000, 2200000, 2400000, 2600000, 2800000, 3000000 }; startTimer(); List resultList = bbs.searchBigBytes(srcBytes, searchBytes); long ellapsedTimeInMillis = stopTimer(); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); System.out.println("[" + name.getMethodName() + "] ellapsed " + ellapsedTimeInMillis + " millis for " + srcBytes.length / 1024 + " kbytes"); } } finbin-0.6.2/src/test/java/org/riversun/finbin/TestBinarySearcher.java000066400000000000000000000235251306464312200260000ustar00rootroot00000000000000/* finbin - Hi-speed search byte[] data from big byte[] * * Copyright (c) 2015 Tom Misawa(riversun.org@gmail.com) * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ package org.riversun.finbin; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Test; /** * Unit tests for BinarySearcher
* * Tom Misawa (riversun.org@gmail.com) * */ public class TestBinarySearcher extends TestBase { @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void testIndexOf_01_TinyData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = getBytes("hello world"); String searchText = "hello"; byte[] searchBytes = getBytes(searchText); final int expected = 0; final int resultVal = bs.indexOf(srcBytes, searchBytes); assertEquals(expected, resultVal); } @Test public void testIndexOf_02_TinyData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = getBytes("hello world"); String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int expected = 6; final int resultVal = bs.indexOf(srcBytes, searchBytes); assertEquals(expected, resultVal); } // test empty bytes @Test public void testIndexOf_03_TinyData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = getBytes("hello world"); byte[] searchBytes = new byte[] {}; final int expected = -1; final int resultVal = bs.indexOf(srcBytes, searchBytes); assertEquals(expected, resultVal); } @Test public void testIndexOf_04_TinyData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = getBytes("hello world"); String searchText = "worlds"; byte[] searchBytes = getBytes(searchText); final int expected = -1; final int resultVal = bs.indexOf(srcBytes, searchBytes); assertEquals(expected, resultVal); } @Test public void testIndexOf_01_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int expected = 25; final int resultVal = bs.indexOf(srcBytes, searchBytes); assertEquals(expected, resultVal); } // with startIndex @Test public void testIndexOf_02_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int startIndex = 5; final int expected = 25; final int resultVal = bs.indexOf(srcBytes, searchBytes, startIndex); assertEquals(expected, resultVal); } // start after first occurrence @Test public void testIndexOf_03_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int startIndex = 26; final int expected = 43; final int resultVal = bs.indexOf(srcBytes, searchBytes, startIndex); assertEquals(expected, resultVal); } // search startIndex to endIndex @Test public void testIndexOf_04_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int startIndex = 0; final int endIndex = 29; final int expected = 25; final int resultVal = bs.indexOf(srcBytes, searchBytes, startIndex, endIndex); assertEquals(expected, resultVal); } // boundary test failure pattern(didn't go to the last char of world) @Test public void testIndexOf_05_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int startIndex = 0; final int endIndex = 28; final int expected = -1; final int resultVal = bs.indexOf(srcBytes, searchBytes, startIndex, endIndex); assertEquals(expected, resultVal); } // boundary test ok pattern @Test public void testIndexOf_06_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int startIndex = 0; final int endIndex = 29; final int expected = 25; final int resultVal = bs.indexOf(srcBytes, searchBytes, startIndex, endIndex); assertEquals(expected, resultVal); } @Test public void testIndexOf_01_MidData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = MID_SIZE_TEST_BYTES; String searchText = "with"; byte[] searchBytes = getBytes(searchText); final int expected = 214; final int resultVal = bs.indexOf(srcBytes, searchBytes); assertEquals(expected, resultVal); } // with startIndex @Test public void testIndexOf_02_MidData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = MID_SIZE_TEST_BYTES; String searchText = "with"; byte[] searchBytes = getBytes(searchText); final int startIndex = 220; final int expected = 234; final int resultVal = bs.indexOf(srcBytes, searchBytes, startIndex); assertEquals(expected, resultVal); } // searchText placed in start position of the byte array. @Test public void testSearchBytes_01_TinyData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = getBytes("hello world"); String searchText = "hello"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 0 }; List resultList = bs.searchBytes(srcBytes, searchBytes); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); } // searchText placed in start position of the byte array. @Test public void testSearchBytes_02_TinyData() { BinarySearcher bs = new BinarySearcher(); byte[] srcBytes = getBytes("hello world"); String searchText = "world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 6 }; List resultList = bs.searchBytes(srcBytes, searchBytes); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); } // test searchBytes method @Test public void testSearchBytes_01_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); Integer[] expectedArray = new Integer[] { 25, 43, 62 }; List resultList = bs.searchBytes(srcBytes, searchBytes); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); } // with start index @Test public void testSearchBytes_02_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int startIndex = 26; Integer[] expectedArray = new Integer[] { 43, 62 }; List resultList = bs.searchBytes(srcBytes, searchBytes, startIndex); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); } // with start index and end index @Test public void testSearchBytes_03_SmallData() { BinarySearcher bs = new BinarySearcher(); // "Hello I'm so happy.Hello world.I love this world.It's a small world."; byte[] srcBytes = SMALL_SIZE_TEST_BYTES; String searchText = "world"; byte[] searchBytes = getBytes(searchText); final int startIndex = 26; final int endIndex = 50; Integer[] expectedArray = new Integer[] { 43 }; List resultList = bs.searchBytes(srcBytes, searchBytes, startIndex, endIndex); Integer[] resultArray = resultList.toArray(new Integer[] {}); assertTrue(Arrays.equals(expectedArray, resultArray)); } }finbin-0.6.2/src/test/resources/000077500000000000000000000000001306464312200165455ustar00rootroot00000000000000finbin-0.6.2/src/test/resources/finbin_test_064kbyte.bin000066400000000000000000002000001306464312200231630ustar00rootroot00000000000000hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.finbin-0.6.2/src/test/resources/finbin_test_1mbyte.bin000066400000000000000000040000001306464312200230160ustar00rootroot00000000000000hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.finbin-0.6.2/src/test/resources/finbin_test_3mbyte.bin000066400000000000000000140000001306464312200230210ustar00rootroot00000000000000hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.finbin-0.6.2/src/test/resources/finbin_test_500kbyte.bin000066400000000000000000017500001306464312200231710ustar00rootroot00000000000000hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.