/* * Copyright (c) 2012 Daniel Huckaby * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.handlerexploit.prime.utils; import java.lang.reflect.Method; import java.util.concurrent.ExecutorService; import junit.framework.Assert; import org.junit.Test; public class ImageManagerTests { private static final String SOURCE = "https://github.com/DHuckaby/Prime/raw/master/examples/res/drawable-hdpi/ic_launcher.png"; @Test public void copyURLToByteArray() throws Exception { Method method = ImageManager.class.getDeclaredMethod("copyURLToByteArray", String.class); method.setAccessible(true); byte[] byteArray = (byte[]) method.invoke(null, new Object[] {SOURCE}); Assert.assertNotNull(byteArray); Assert.assertTrue(byteArray.length > 0); byteArray = (byte[]) (byte[]) method.invoke(null, new Object[] {null}); Assert.assertNull(byteArray); } @Test public void getKey() throws Exception { Method method = ImageManager.class.getDeclaredMethod("getKey", String.class); method.setAccessible(true); String key = (String) method.invoke(null, new Object[] {SOURCE}); Assert.assertNotNull(key); key = (String) method.invoke(null, new Object[] {null}); Assert.assertNull(key); } @Test public void newConfiguredThreadPool() throws Exception { Method method = ImageManager.class.getDeclaredMethod("newConfiguredThreadPool"); method.setAccessible(true); ExecutorService executorService = (ExecutorService) method.invoke(null); Assert.assertNotNull(executorService); } }