Guest User

Untitled

a guest
Jul 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public class CommandPersistenceTest {
  2.  
  3. private static final String ID_NEW = "newcommand";
  4. private static final String ID_OLD = "oldcommand";
  5.  
  6. @Test
  7. public void testAliasesCorrectlyRegistered() {
  8. CommandManager manager = new CommandManager();
  9. Command newcommand = manager.getCommand(ID_NEW);
  10.  
  11. ICommandService commandService = EasyMock.createNiceMock("commandService", ICommandService.class);
  12. EasyMock.expect(commandService.getCommand(ID_NEW)).andReturn(newcommand);
  13. commandService.defineAlias(ID_OLD, ID_NEW);
  14. IExtensionRegistry extensionRegistry = fakeRegistry(this.getClass(), "plugin-testAliases.xml");
  15. CommandPersistence commandPersistence = new CommandPersistence(commandService, extensionRegistry);
  16. EasyMock.replay(commandService);
  17.  
  18. commandPersistence.read();
  19.  
  20. EasyMock.verify(commandService);
  21. }
  22.  
  23. private IExtensionRegistry fakeRegistry(Class<?> clazz, String filename) {
  24. IExtensionRegistry extensionRegistry = RegistryFactory.createRegistry(null, this, this);
  25. RegistryContributor contributor = new RegistryContributor("com.example", "com.example", null, null);
  26. extensionRegistry.addContribution(clazz.getResourceAsStream(filename), contributor, false, null, null, this);
  27. return extensionRegistry;
  28. }
  29.  
  30. }
Add Comment
Please, Sign In to add comment