コード例 #1
0
  public void testConstruction() {
    ProtocolProviderServiceIrcImpl provider =
        EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
    IrcConnection connection = EasyMock.createMock(IrcConnection.class);
    EasyMock.replay(provider, connection);

    new CommandFactory(provider, connection);
  }
コード例 #2
0
  public void testConstructionNullProvider() {
    IrcConnection connection = EasyMock.createMock(IrcConnection.class);
    EasyMock.replay(connection);

    try {
      new CommandFactory(null, connection);
      Assert.fail();
    } catch (IllegalArgumentException e) {
    }
  }
コード例 #3
0
  public void testConstructionNullConnection() {
    ProtocolProviderServiceIrcImpl provider =
        EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
    EasyMock.replay(provider);

    try {
      new CommandFactory(provider, null);
      Assert.fail();
    } catch (IllegalArgumentException e) {
    }
  }
コード例 #4
0
  public void testNonExistingCommand() throws BadCommandException {
    ProtocolProviderServiceIrcImpl provider =
        EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
    IrcConnection connection = EasyMock.createMock(IrcConnection.class);
    EasyMock.replay(provider, connection);

    try {
      CommandFactory factory = new CommandFactory(provider, connection);
      factory.createCommand("test");
      Assert.fail();
    } catch (UnsupportedCommandException e) {
    }
  }
コード例 #5
0
  public void testCreateNullCommandName() throws UnsupportedCommandException, BadCommandException {
    ProtocolProviderServiceIrcImpl provider =
        EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
    IrcConnection connection = EasyMock.createMock(IrcConnection.class);
    EasyMock.replay(provider, connection);

    CommandFactory.registerCommand("test", Test.class);
    try {
      CommandFactory factory = new CommandFactory(provider, connection);
      factory.createCommand(null);
      Assert.fail();
    } catch (IllegalArgumentException e) {
    }
    CommandFactory.unregisterCommand(Test.class, null);
  }
コード例 #6
0
  public void testBadCommand() throws UnsupportedCommandException {
    ProtocolProviderServiceIrcImpl provider =
        EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
    IrcConnection connection = EasyMock.createMock(IrcConnection.class);
    EasyMock.replay(provider, connection);

    CommandFactory.registerCommand("test", BadImplementation.class);
    try {
      CommandFactory factory = new CommandFactory(provider, connection);
      factory.createCommand("test");
      Assert.fail();
    } catch (BadCommandException e) {
    } finally {
      CommandFactory.unregisterCommand(BadImplementation.class, null);
    }
  }
コード例 #7
0
  public void testExistingCommand() throws UnsupportedCommandException, BadCommandException {
    ProtocolProviderServiceIrcImpl provider =
        EasyMock.createMock(ProtocolProviderServiceIrcImpl.class);
    IrcConnection connection = EasyMock.createMock(IrcConnection.class);
    EasyMock.replay(provider, connection);

    CommandFactory.registerCommand("test", Test.class);
    try {
      CommandFactory factory = new CommandFactory(provider, connection);
      Command cmd = factory.createCommand("test");
      Assert.assertNotNull(cmd);
      Assert.assertTrue(cmd instanceof Test);
    } finally {
      CommandFactory.unregisterCommand(Test.class, null);
    }
  }