Esempio n. 1
0
  public void testGetLatestAlbums() throws SQLException {

    final Properties p = createMock(Properties.class);
    expect(p.get(Constants.WWW_BROWSE_LATEST_ALBUMS_COUNT, 10)).andReturn(10l);
    replay(p);

    final ResultSet rs = createNiceMock(ResultSet.class);
    expect(rs.next()).andReturn(true);
    expect(rs.next()).andReturn(true);
    expect(rs.next()).andReturn(false);
    replay(rs);

    final PreparedStatement st = createMock(PreparedStatement.class);
    st.setInt(1, 10);
    expect(st.executeQuery()).andReturn(rs).times(1);
    replay(st);

    final Database db = createMock(Database.class);
    expect(db.prepare((String) anyObject())).andReturn(st).times(1);
    replay(db);

    final Latester b = new Latester();
    b.setProperties(p);
    b.setDatabase(db);

    final Vector<Album> albums = b.getLatestAlbums();

    assertNotNull(albums);
    assertEquals(2, albums.size());

    verify(db);
    verify(st);
    verify(rs);
    verify(p);
  }
Esempio n. 2
0
  /**
   * handles the CMD_PROPSET command to set a particular application property
   *
   * @param args command arguments
   */
  public String execute(final String[] args) {

    final String name = args[1];
    final String value = Utils.joinArray(args, " ", 2, args.length - 1);

    p.set(name, value);
    p.save();

    return locale.getString("con.msg.propertySaved");
  }
Esempio n. 3
0
  /** lays out the GUI components in their right places */
  protected void layoutComponents() {

    log.debug("Laying out GUI components");

    setIconImage(r.getImage("icons/16x16/sockso.png"));
    setLayout(new BorderLayout());
    add(getMainPane(), BorderLayout.CENTER);
    add(getBottomPane(), BorderLayout.SOUTH);

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(final WindowEvent evt) {
            if (tray.isActive()) toggleVisibility();
            else exit();
          }
        });
    setSize(new Dimension(700, 500));
    setLocationRelativeTo(null);

    p.addPropertiesListener(this);

    // done with splash now
    Splash.close();
  }
Esempio n. 4
0
  /** checks with the user they want to do it, then closes the app */
  public void exit() {

    if (p.get(Constants.APP_CONFIRM_EXIT).equals(Properties.YES))
      if (JOptionPane.showConfirmDialog(
              this, "Are you sure you want to exit?", "Exit Sockso", JOptionPane.YES_NO_OPTION)
          != JOptionPane.YES_OPTION) return;

    com.pugh.sockso.Main.exit();
  }
Esempio n. 5
0
  public void open() {

    initComponents();
    layoutComponents();

    // check to see if we should start minimized or not
    boolean setVisible = true;
    if (tray.isActive() && p.get(Constants.APP_START_MINIMIZED).equals(Properties.YES))
      setVisible = false;
    setVisible(setVisible);
  }