forked from apache/dubbo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DUBBO-627 添加单元测试,覆盖 export 时是否能把 generic 的配置发布到 registry 上
- Loading branch information
kimi
committed
Jan 11, 2013
1 parent
b90c3b3
commit 3416402
Showing
4 changed files
with
109 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...bo-config-spring/src/test/java/com/alibaba/dubbo/config/spring/registry/MockRegistry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.alibaba.dubbo.config.spring.registry; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.alibaba.dubbo.common.URL; | ||
import com.alibaba.dubbo.registry.NotifyListener; | ||
import com.alibaba.dubbo.registry.Registry; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">kimi</a> | ||
*/ | ||
public class MockRegistry implements Registry { | ||
|
||
private URL url; | ||
|
||
private List<URL> registered = new ArrayList<URL>(); | ||
|
||
private List<URL> subscribered = new ArrayList<URL>(); | ||
|
||
public List<URL> getRegistered() { | ||
return registered; | ||
} | ||
|
||
public List<URL> getSubscribered() { | ||
return subscribered; | ||
} | ||
|
||
public MockRegistry(URL url) { | ||
if (url == null) { | ||
throw new NullPointerException(); | ||
} | ||
this.url = url; | ||
} | ||
|
||
public URL getUrl() { | ||
return url; | ||
} | ||
|
||
public boolean isAvailable() { | ||
return true; | ||
} | ||
|
||
public void destroy() { | ||
|
||
} | ||
|
||
public void register(URL url) { | ||
registered.add(url); | ||
} | ||
|
||
public void unregister(URL url) { | ||
registered.remove(url); | ||
} | ||
|
||
public void subscribe(URL url, NotifyListener listener) { | ||
subscribered.add(url); | ||
} | ||
|
||
public void unsubscribe(URL url, NotifyListener listener) { | ||
subscribered.remove(url); | ||
} | ||
|
||
public List<URL> lookup(URL url) { | ||
return null; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ig-spring/src/test/java/com/alibaba/dubbo/config/spring/registry/MockRegistryFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.alibaba.dubbo.config.spring.registry; | ||
|
||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.alibaba.dubbo.common.URL; | ||
import com.alibaba.dubbo.registry.Registry; | ||
import com.alibaba.dubbo.registry.RegistryFactory; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">kimi</a> | ||
*/ | ||
public class MockRegistryFactory implements RegistryFactory { | ||
|
||
private static final Map<URL, Registry> registries = new HashMap<URL, Registry>(); | ||
|
||
public Registry getRegistry(URL url) { | ||
MockRegistry registry = new MockRegistry(url); | ||
registries.put(url, registry); | ||
return registry; | ||
} | ||
|
||
public static Collection<Registry> getCachedRegistry() { | ||
return registries.values(); | ||
} | ||
|
||
public static void cleanCachedRegistry() { | ||
registries.clear(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ing/src/test/resources/META-INF/dubbo/internal/com.alibaba.dubbo.registry.RegistryFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mock=com.alibaba.dubbo.config.spring.registry.MockRegistryFactory |