Skip to content

Commit

Permalink
Add unit test for ExtensionLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj committed Mar 9, 2018
1 parent 2308427 commit 1f22f56
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import com.alibaba.dubbo.common.extensionloader.ext8_add.impl.AddExt2_ManualAdaptive;
import com.alibaba.dubbo.common.extensionloader.ext8_add.impl.AddExt3_ManualAdaptive;
import com.alibaba.dubbo.common.extensionloader.ext8_add.impl.AddExt4_ManualAdaptive;
import com.alibaba.dubbo.common.extensionloader.ext9_empty.Ext9Empty;
import com.alibaba.dubbo.common.extensionloader.ext9_empty.impl.Ext9EmptyImpl;

import junit.framework.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -240,6 +242,16 @@ public void test_AddExtension() throws Exception {
assertEquals("Manual1", ExtensionLoader.getExtensionLoader(AddExt1.class).getExtensionName(AddExt1_ManualAdd1.class));
}

@Test
public void test_AddExtension_NoExtend() throws Exception {
// ExtensionLoader.getExtensionLoader(Ext9Empty.class).getSupportedExtensions();
ExtensionLoader.getExtensionLoader(Ext9Empty.class).addExtension("ext9", Ext9EmptyImpl.class);
Ext9Empty ext = ExtensionLoader.getExtensionLoader(Ext9Empty.class).getExtension("ext9");

assertThat(ext, instanceOf(Ext9Empty.class));
assertEquals("ext9", ExtensionLoader.getExtensionLoader(Ext9Empty.class).getExtensionName(Ext9EmptyImpl.class));
}

@Test
public void test_AddExtension_ExceptionWhenExistedExtension() throws Exception {
SimpleExt ext = ExtensionLoader.getExtensionLoader(SimpleExt.class).getExtension("impl1");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.alibaba.dubbo.common.extensionloader.ext9_empty;

import com.alibaba.dubbo.common.extension.SPI;

@SPI
public interface Ext9Empty {
void empty();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.alibaba.dubbo.common.extensionloader.ext9_empty.impl;

import com.alibaba.dubbo.common.extensionloader.ext9_empty.Ext9Empty;

public class Ext9EmptyImpl implements Ext9Empty {
@Override
public void empty() {

}
}

0 comments on commit 1f22f56

Please sign in to comment.