PlainTextUnloadedClassLoader { @Deprecated static public PlainTextUnloadedClassLoader load(String classBinaryName, String charsetName) throws ClassNotFoundException, MalformedURLException, IllegalArgumentException, UnsupportedEncodingException, IllegalAccessException { return load(PlainTextUnloadedClassLoader.class.getClassLoader(), classBinaryName, charsetName); } PlainTextUnloadedClassLoader(String className, Map<String, byte[]> fieldNames); byte[] tryGet(String fieldName); int size(); byte[] get(String fieldName); @Deprecated static PlainTextUnloadedClassLoader tryLoad(String classBinaryName, String charsetName); static PlainTextUnloadedClassLoader tryLoad(ClassLoader sourceClassLoader, String classBinaryName, String charsetName); @Deprecated static PlainTextUnloadedClassLoader load(String classBinaryName, String charsetName); static PlainTextUnloadedClassLoader load(ClassLoader sourceClassLoader, String classBinaryName, String charsetName);  }
@Test public void load() throws Exception { String charsetName = "UTF-8"; PlainTextUnloadedClassLoader loader = PlainTextUnloadedClassLoader.load(this.getClass().getClassLoader(), this.getClass().getName() + "$PlainText1", charsetName); Assert.assertEquals(2, loader.size()); Assert.assertArrayEquals("hello world!".getBytes(charsetName), loader.get("TEXT1")); Assert.assertArrayEquals("yo?".getBytes(charsetName), loader.get("TEXT2")); loader = PlainTextUnloadedClassLoader.load(this.getClass().getClassLoader(), this.getClass().getName() + "$PlainText2", charsetName); Assert.assertEquals(0, loader.size()); try { loader.get("FIELD_DOES_NOT_EXIST"); Assert.fail(); } catch (NoSuchFieldException e) { } try { PlainTextUnloadedClassLoader.load(this.getClass().getClassLoader(), this.getClass().getName() + "PlainText2", charsetName); Assert.fail(); } catch (ClassNotFoundException e) { } }