Package com.pugh.sockso.music

Examples of com.pugh.sockso.music.CoverArt


    public boolean isCached( String name ) {
        return isCached;
    }
    @Override
    public CoverArt getCoverArt(String item){
        return new CoverArt(item);
    }
View Full Code Here


public class RemoteCovererTest extends SocksoTestCase {

    public void testServeCover() throws Exception {
       
        final CoverSearch coverSearch = createNiceMock( CoverSearch.class );
        final CoverArt coverArt = new CoverArt("ar123");
        expect( coverSearch.getCover("ar123") ).andReturn( coverArt );
        replay( coverSearch );
       
        RemoteCoverer coverer = new NeuteredRemoteCoverer( coverSearch );
        coverer.setProperties( new StringProperties() );
View Full Code Here

            if ( urlString != null ) {

                final URL url = new URL( urlString );
                final HttpURLConnection cnn = (HttpURLConnection) url.openConnection();
                final BufferedImage cover = ImageIO.read( cnn.getInputStream() );
                CoverArt coverArtImage = new CoverArt( itemName, cover );
                return coverArtImage;

            }

        }
View Full Code Here

    public boolean serveCover( final String itemName ) throws IOException, CacheException {
       
        final Locale locale = getLocale();
        final String noCoverId = "nocover-" + locale.getLangCode();
        final boolean coverIsCached = coverCache.isCached( noCoverId );
        final CoverArt cover = getNoCoverArt( noCoverId );

        serveCover( cover, "noCover", coverIsCached );

        return true;
       
View Full Code Here

        final Locale locale = getLocale();
        final Properties properties = getProperties();
       
        return coverCache.isCached( noCoverId )
                ? coverCache.getCoverArt(noCoverId)
                : new CoverArt(noCoverId, CoverArt.createNoCoverImage(properties, locale));

    }
View Full Code Here

     */

    public CoverArt getCoverArt(String itemName) throws CacheException {
       
        final CachedObject obj = readRaw(itemName);
        final CoverArt cover = (CoverArt) obj.getValue();

        return cover;

    }
View Full Code Here

            final File coverFile = getCoverCacheFile(key, ext);

            try {
                final BufferedImage image = ImageIO.read(coverFile);
                final CoverArt cover = new CoverArt(key, image);
                return new CachedObject(cover, -1);
            }

            catch(IOException e) {
                throw new CacheException("Error reading image: " + coverFile.toString(), e );
View Full Code Here

     */

    @Override
    protected void writeRaw( String key, CachedObject object ) throws CacheException {

        final CoverArt cover = (CoverArt) object.getValue();
        final BufferedImage image = cover.getImage();
        final String extension = DEFAULT_IMAGE_TYPE;
        final File imageFile = getCoverCacheFile(key, extension);

        try {
            ImageIO.write(image, extension, imageFile);
View Full Code Here

    }

    public void testIsCached() throws IOException, CacheException {
        String itemName = "al123";
        BufferedImage image = ImageIO.read(new File("test/data/covers/" + itemName + ".jpg"));
        CoverArt coverArt = new CoverArt(itemName, image);
        cache.addToCache(coverArt);

        boolean expResult = true;
        boolean result = cache.isCached(itemName);
        assertEquals(expResult, result);
View Full Code Here

    public void testGetCachedImageExtension() throws IOException {
        String itemName = "al123";
        BufferedImage image = ImageIO.read(new File("test/data/covers/" + itemName + ".jpg"));

        CoverArt coverArt = new CoverArt(itemName, image);

        String expResult = "jpg";
        String result = cache.getCachedImageExtension(itemName);
        assertEquals(expResult, result);
    }
View Full Code Here

TOP

Related Classes of com.pugh.sockso.music.CoverArt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.