01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestImageContentLoader.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.cmf.loader;
09:
10: import com.uwyn.rife.resources.ResourceFinderClasspath;
11: import com.uwyn.rife.tools.FileUtils;
12: import java.awt.Image;
13: import java.net.URL;
14: import java.util.HashSet;
15: import java.util.Set;
16: import junit.framework.TestCase;
17:
18: public class TestImageContentLoader extends TestCase {
19: public TestImageContentLoader(String name) {
20: super (name);
21: }
22:
23: public void testLoad() throws Exception {
24: ImageContentLoader loader = new ImageContentLoader();
25: Set<String> errors = new HashSet<String>();
26: URL image_resource = ResourceFinderClasspath.getInstance()
27: .getResource("uwyn.png");
28:
29: byte[] image_bytes = FileUtils.readBytes(image_resource);
30: Image image = loader.load(image_bytes, false, errors);
31:
32: assertNotNull(image);
33: assertEquals(0, errors.size());
34: }
35:
36: public void testLoadNull() throws Exception {
37: ImageContentLoader loader = new ImageContentLoader();
38: Set<String> errors = new HashSet<String>();
39:
40: Image image = loader.load(null, false, errors);
41:
42: assertNull(image);
43: assertEquals(0, errors.size());
44: }
45:
46: public void getBackends() throws Exception {
47: ImageContentLoader loader = new ImageContentLoader();
48: assertTrue(loader.getBackends().size() > 0);
49: }
50: }
|