1   package com.atlassian.plugin.osgi.util;
2   
3   import junit.framework.TestCase;
4   import com.mockobjects.dynamic.Mock;
5   import com.mockobjects.dynamic.C;
6   import com.atlassian.plugin.osgi.util.BundleClassLoaderAccessor;
7   import org.osgi.framework.Bundle;
8   
9   import java.io.IOException;
10  
11  public class TestBundleClassLoaderAccessor extends TestCase
12  {
13      public void testGetResourceAsStream() throws IOException
14      {
15          Mock mockBundle = new Mock(Bundle.class);
16          mockBundle.expectAndReturn("getResource", C.args(C.eq("/foo.txt")), getClass().getResource("/foo.txt"));
17  
18          BundleClassLoaderAccessor.getClassLoader((Bundle) mockBundle.proxy(), null).getResourceAsStream("/foo.txt");
19          byte[] buffer = new byte[1024];
20          assertTrue(buffer.length > 0);
21  
22      }
23  }