blob: 492d272e31ed0f2a7697da783eaa935c9abc67c6 [file] [log] [blame]
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -08001/*
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 */
14package com.intel.jndn.management;
15
16import java.nio.ByteBuffer;
17
18/**
Alexander Afanasyeve36e1af2016-02-19 18:06:05 -080019 * Helper methods for unit tests.
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080020 */
Alexander Afanasyeve36e1af2016-02-19 18:06:05 -080021public final class TestHelper {
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080022 /**
Alexander Afanasyeve36e1af2016-02-19 18:06:05 -080023 * Prevent instances of TestHelper.
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080024 */
25 private TestHelper() {
26 }
27
28 /**
Alexander Afanasyeve36e1af2016-02-19 18:06:05 -080029 * Construct ByteBuffer from int[].
30 *
31 * @param array array to convert
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080032 */
33 public static ByteBuffer
Alexander Afanasyeve36e1af2016-02-19 18:06:05 -080034 bufferFromIntArray(final int[] array) {
Alexander Afanasyeva8bc0d82016-01-25 17:25:30 -080035 ByteBuffer result = ByteBuffer.allocate(array.length);
36 for (int value : array) {
37 result.put((byte) (value & 0xFF));
38 }
39
40 result.flip();
41 return result;
42 }
43}