-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7ac089
commit bc3726d
Showing
2 changed files
with
58 additions
and
8 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
39 changes: 39 additions & 0 deletions
39
lealone-test/src/test/java/org/lealone/test/misc/PluginManagerTest.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,39 @@ | ||
/* | ||
* Copyright Lealone Database Group. | ||
* Licensed under the Server Side Public License, v 1. | ||
* Initial Developer: zhh | ||
*/ | ||
package org.lealone.test.misc; | ||
|
||
import org.junit.Test; | ||
import org.lealone.db.PluginManager; | ||
import org.lealone.storage.StorageEngine; | ||
import org.lealone.storage.aose.AOStorageEngine; | ||
import org.lealone.test.TestBase; | ||
|
||
public class PluginManagerTest extends TestBase { | ||
@Test | ||
public void run() { | ||
StorageEngine se = PluginManager.getPlugin(StorageEngine.class, AOStorageEngine.NAME); | ||
StorageEngine old = se; | ||
assertTrue(se instanceof AOStorageEngine); | ||
|
||
// 默认是用StorageEngine.class为key,所以用AOStorageEngine.class时找不到 | ||
se = PluginManager.getPlugin(AOStorageEngine.class, AOStorageEngine.NAME); | ||
assertNull(se); | ||
|
||
PluginManager.deregister(StorageEngine.class, old); | ||
se = PluginManager.getPlugin(StorageEngine.class, AOStorageEngine.NAME); | ||
assertNull(se); | ||
|
||
se = new AOStorageEngine(); | ||
PluginManager.register(se, "myaose"); | ||
se = PluginManager.getPlugin(AOStorageEngine.class, "myaose"); | ||
assertNotNull(se); | ||
|
||
// 重新注册回去,避免集成测试时影响其他测试用例 | ||
PluginManager.register(StorageEngine.class, old); | ||
se = PluginManager.getPlugin(StorageEngine.class, AOStorageEngine.NAME); | ||
assertNotNull(se); | ||
} | ||
} |