Alexander Afanasyev | a8bc0d8 | 2016-01-25 17:25:30 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * jndn-management |
| 3 | * Copyright (c) 2016, Regents of the University of California |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms and conditions of the GNU Lesser General Public License, |
| 7 | * version 3, as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope it will be useful, but WITHOUT ANY |
| 10 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 12 | * more details. |
| 13 | */ |
| 14 | package com.intel.jndn.management; |
| 15 | |
| 16 | import java.nio.ByteBuffer; |
| 17 | |
| 18 | /** |
| 19 | * Helper methods for unit tests |
| 20 | */ |
| 21 | public class TestHelper { |
| 22 | /** |
| 23 | * Prevent instances of TestHelper |
| 24 | */ |
| 25 | private TestHelper() { |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Construct ByteBuffer from int[] |
| 30 | */ |
| 31 | public static ByteBuffer |
| 32 | bufferFromIntArray(int[] array) |
| 33 | { |
| 34 | ByteBuffer result = ByteBuffer.allocate(array.length); |
| 35 | for (int value : array) { |
| 36 | result.put((byte) (value & 0xFF)); |
| 37 | } |
| 38 | |
| 39 | result.flip(); |
| 40 | return result; |
| 41 | } |
| 42 | } |