示例#1
0
 @Test
 public void assertDeleteWorkspaceClosesReader() throws Exception {
   Reader spy = spy(new StringReader(""));
   when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(spy);
   new Workspaces(server).deleteWorkspace(new Workspace(server, "name"));
   verify(spy).close();
 }
示例#2
0
 @Test
 public void assertUnknownWorkspaceDoesNotExists() throws Exception {
   when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader(""));
   Workspaces workspaces = new Workspaces(server);
   assertFalse(
       "The unknown workspace was reported as existing",
       workspaces.exists(new Workspace(server, "name1")));
 }
示例#3
0
  @Test
  public void assertGettingNewWorkspaceIsNotRetrievingServerList() throws Exception {
    when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader(""));

    Workspaces workspaces = new Workspaces(server);
    workspaces.newWorkspace("name1");
    assertNotNull("The get new workspace returned null", workspaces.getWorkspace("name1"));
    verify(server, times(1)).execute(isA(MaskedArgumentListBuilder.class));
  }
示例#4
0
  @Test
  public void assertNewWorkspaceIsAddedToMap() throws Exception {
    when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader(""));

    Workspaces workspaces = new Workspaces(server);
    Workspace workspace = workspaces.newWorkspace("name1");
    assertNotNull("The new workspace was null", workspace);
    assertTrue("The workspace was reported as non existant", workspaces.exists(workspace));
  }
示例#5
0
  @Test
  public void assertNewWorkspaceExistsIsNotRetrievingServerList() throws Exception {
    when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader(""));

    Workspaces workspaces = new Workspaces(server);
    Workspace workspace = workspaces.newWorkspace("name1");
    assertTrue("The get new workspace did not exists", workspaces.exists(workspace));
    verify(server, times(1)).execute(isA(MaskedArgumentListBuilder.class));
  }
示例#6
0
  @Test
  public void assertWorkspaceExistsWithOnlyName() throws Exception {
    when(server.execute(isA(MaskedArgumentListBuilder.class)))
        .thenReturn(
            new StringReader(
                "--------- -------------- -------- ----------------------------------------------------------------------------------------------------------\n"
                    + "\n"
                    + "name1     SND\\redsolo_cp COMPUTER\n"));

    Workspaces workspaces = new Workspaces(server);
    assertTrue("The workspace was reported as non existant", workspaces.exists("name1"));
  }
示例#7
0
  @Test
  public void assertListFromServerIsParsedProperly() throws Exception {
    when(server.execute(isA(MaskedArgumentListBuilder.class)))
        .thenReturn(
            new StringReader(
                "--------- -------------- -------- ----------------------------------------------------------------------------------------------------------\n"
                    + "\n"
                    + "name1     SND\\redsolo_cp COMPUTER\n"));

    Workspaces workspaces = new Workspaces(server);
    Workspace workspace = workspaces.getWorkspace("name1");
    assertNotNull("Workspace was null", workspace);
  }
示例#8
0
 @Test
 public void assertWorkspaceIsDeletedFromMap() throws Exception {
   when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader(""));
   Workspaces workspaces = new Workspaces(server);
   // Populate the map in test object
   assertFalse(
       "The workspace was reported as existant", workspaces.exists(new Workspace(server, "name")));
   Workspace workspace = workspaces.newWorkspace("name");
   assertTrue(
       "The workspace was reported as non existant",
       workspaces.exists(new Workspace(server, "name")));
   workspaces.deleteWorkspace(workspace);
   assertFalse("The workspace was reported as existant", workspaces.exists(workspace));
 }
  public void serverConnected(Server server) {
    for (int i = 0; i < _start.getCommands().length; i++) {
      String cmd = _start.getCommands()[i];
      if ((cmd.startsWith("/")) && (server instanceof IRCServer))
        ((IRCServer) server).getStatus().sendString(_start.getCommands()[i]);
      else server.execute(_start.getCommands()[i]);
    }

    Enumeration<Plugin> enum1 = _plugins.elements();
    while (enum1.hasMoreElements()) {
      Plugin plugin = (Plugin) enum1.nextElement();
      plugin.serverConnected(server);
    }
  }
示例#10
0
 @Test
 public void assertGetUnknownWorkspaceReturnsNull() throws Exception {
   when(server.execute(isA(MaskedArgumentListBuilder.class))).thenReturn(new StringReader(""));
   Workspaces workspaces = new Workspaces(server);
   assertNull("The unknown workspace was not null", workspaces.getWorkspace("name1"));
 }