public void testGetLatestArtists() throws SQLException { final Properties p = createMock(Properties.class); expect(p.get(Constants.WWW_BROWSE_LATEST_ARTISTS_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<Artist> artists = b.getLatestArtists(); assertNotNull(artists); assertEquals(2, artists.size()); verify(db); verify(st); verify(rs); verify(p); }
public void testGetLatestArtistsQuery() throws Exception { final Database db = new TestDatabase(); final Latester b = new Latester(); b.setProperties(TestUtils.getProperties()); b.setDatabase(db); b.getLatestArtists(); }