Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CommandPersistenceTest {
- private static final String ID_NEW = "newcommand";
- private static final String ID_OLD = "oldcommand";
- @Test
- public void testAliasesCorrectlyRegistered() {
- CommandManager manager = new CommandManager();
- Command newcommand = manager.getCommand(ID_NEW);
- ICommandService commandService = EasyMock.createNiceMock("commandService", ICommandService.class);
- EasyMock.expect(commandService.getCommand(ID_NEW)).andReturn(newcommand);
- commandService.defineAlias(ID_OLD, ID_NEW);
- IExtensionRegistry extensionRegistry = fakeRegistry(this.getClass(), "plugin-testAliases.xml");
- CommandPersistence commandPersistence = new CommandPersistence(commandService, extensionRegistry);
- EasyMock.replay(commandService);
- commandPersistence.read();
- EasyMock.verify(commandService);
- }
- private IExtensionRegistry fakeRegistry(Class<?> clazz, String filename) {
- IExtensionRegistry extensionRegistry = RegistryFactory.createRegistry(null, this, this);
- RegistryContributor contributor = new RegistryContributor("com.example", "com.example", null, null);
- extensionRegistry.addContribution(clazz.getResourceAsStream(filename), contributor, false, null, null, this);
- return extensionRegistry;
- }
- }
Add Comment
Please, Sign In to add comment