@Test
public void testReadLine() throws Exception {

    ExtensionLoader loader = new ExtensionLoader<Filter>(Filter.class, false, null);
    URL url = Filter.class.getResource("/META-INF/sofa-rpc/" + Filter.class.getName());
    try {
        loader.readLine(url, "com.alipay.sofa.rpc.ext.NotFilter");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    Assert.assertTrue(loader.all.isEmpty());
    try {
        loader.readLine(url, null);
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    Assert.assertTrue(loader.all.isEmpty());
    try {
        loader.readLine(url, "    ");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    Assert.assertTrue(loader.all.isEmpty());
    loader.all.clear();
    try {
        loader.readLine(url, "com.alipay.sofa.rpc.ext.WrongFilter0");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    try {
        loader.readLine(url, "com.alipay.sofa.rpc.ext.WrongFilter1");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    try {
        loader.readLine(url, "com.alipay.sofa.rpc.ext.WrongFilter2");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    try {
        loader.readLine(url, "com.alipay.sofa.rpc.ext.WrongFilter3");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    try {
        loader.readLine(url, "w3=com.alipay.sofa.rpc.ext.WrongFilter4");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    try {
        loader.readLine(url, "echo1=com.alipay.sofa.rpc.ext.ExtensionFilter");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    Assert.assertTrue(loader.all.isEmpty());
    try {
        loader.readLine(url, "com.alipay.sofa.rpc.ext.RightFilter0");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    Assert.assertFalse(loader.all.isEmpty());
    loader.all.clear();
    try {
        loader.readLine(url, "rightxx0=com.alipay.sofa.rpc.ext.RightFilter0");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    Assert.assertFalse(loader.all.isEmpty());
    // 重复加载
    boolean isOk = true;
    try {
        loader.readLine(url, "com.alipay.sofa.rpc.ext.RightFilter0");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
        isOk = false;
    }
    Assert.assertFalse(isOk);
    Assert.assertFalse(loader.all.isEmpty());
    Assert.assertTrue(loader.all.size() == 1);
    ExtensionLoader loader2 = new ExtensionLoader<Protocol>(Protocol.class, false, null);
    URL url2 = Filter.class.getResource("/META-INF/sofa-rpc/" + Protocol.class.getName());
    try {
        loader2.readLine(url2, "com.alipay.sofa.rpc.ext.WrongProtocol");
    } catch (Throwable t) {
        LOGGER.error(t.getMessage());
    }
    Assert.assertTrue(loader2.all.isEmpty());
}