All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.bluebill.mobile.android.BlueBillLookupTest Maven / Gradle / Ivy

The newest version!
/***********************************************************************************************************************
 *
 * blueBill Mobile - open source birdwatching
 * ==========================================
 *
 * Copyright (C) 2009, 2010 by Tidalwave s.a.s. (http://www.tidalwave.it)
 * http://bluebill.tidalwave.it/mobile/
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************
 *
 * $Id: BlueBillLookupTest.java,v c9aee682bc72 2010/08/06 15:21:23 fabrizio $
 *
 **********************************************************************************************************************/
package it.tidalwave.bluebill.mobile.android;

import javax.annotation.Nonnull;
import org.openide.util.Lookup;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import it.tidalwave.bluebill.factsheet.FactSheetFactory;
import it.tidalwave.bluebill.factsheet.impl.DefaultFactSheetFactory;
import it.tidalwave.mobile.location.LocationFinder;
import it.tidalwave.mobile.preferences.PreferencesAdapter;
import it.tidalwave.mobile.location.LocationPreferences;
import it.tidalwave.mobile.android.location.AndroidLocationFinder;
import it.tidalwave.mobile.android.preferences.AndroidPreferencesAdapter;
import it.tidalwave.mobile.android.location.AndroidLocationPreferences;
import it.tidalwave.bluebill.observation.ObservationManager;
import it.tidalwave.bluebill.mobile.DefaultGeneralPreferences;
import it.tidalwave.bluebill.mobile.GeneralPreferences;
import it.tidalwave.bluebill.mobile.android.news.AndroidNewsController;
import it.tidalwave.bluebill.mobile.android.taxonomy.AndroidTaxonomyPreferences;
import it.tidalwave.bluebill.mobile.network.DefaultNetworkingPreferences;
import it.tidalwave.bluebill.mobile.network.NetworkingPreferences;
import it.tidalwave.bluebill.mobile.news.NewsController;
import it.tidalwave.bluebill.mobile.observation.BlueBillObservationManager;
import it.tidalwave.bluebill.mobile.observation.DefaultObservationPreferences;
import it.tidalwave.bluebill.mobile.observation.ObservationClipboard;
import it.tidalwave.bluebill.mobile.observation.ObservationPreferences;
import it.tidalwave.bluebill.mobile.share.DefaultSharingPreferences;
import it.tidalwave.bluebill.mobile.share.SharingPreferences;
import it.tidalwave.bluebill.mobile.taxonomy.TaxonomyPreferences;
import it.tidalwave.mobile.android.io.AndroidMasterFileSystem;
import it.tidalwave.mobile.android.media.AndroidMediaPlayer;
import it.tidalwave.mobile.io.MasterFileSystem;
import it.tidalwave.mobile.media.MediaPlayer;

/***********************************************************************************************************************
 *
 * @author  Fabrizio Giudici
 * @version $Id: $
 *
 **********************************************************************************************************************/
public class BlueBillLookupTest extends AndroidTestCase
  {
    private BlueBillLookup fixture;

    @Override
    protected void setUp()
      throws Exception
      {
        super.setUp();
        fixture = new BlueBillLookup();
      }
      
    @SmallTest
    public void mustLookupTheRequiredServices()
      {
        assertLookup(fixture, FactSheetFactory.class,       DefaultFactSheetFactory.class);
//        assertLookup(fixture, FactSheetProvider.class,      XenoCantoFactSheetProvider.class);
        assertLookup(fixture, GeneralPreferences.class,     DefaultGeneralPreferences.class);
        assertLookup(fixture, LocationFinder.class,         AndroidLocationFinder.class);
        assertLookup(fixture, LocationPreferences.class,    AndroidLocationPreferences.class);
        assertLookup(fixture, MasterFileSystem.class,       AndroidMasterFileSystem.class);
        assertLookup(fixture, MediaPlayer.class,            AndroidMediaPlayer.class);
        assertLookup(fixture, NewsController.class,         AndroidNewsController.class);
        assertLookup(fixture, PreferencesAdapter.class,     AndroidPreferencesAdapter.class);
        assertLookup(fixture, TaxonomyPreferences.class,    AndroidTaxonomyPreferences.class);
        assertLookup(fixture, ObservationClipboard.class,   ObservationClipboard.class);
        assertLookup(fixture, ObservationManager.class,     BlueBillObservationManager.class);
        assertLookup(fixture, ObservationPreferences.class, DefaultObservationPreferences.class);
        assertLookup(fixture, SharingPreferences.class,     DefaultSharingPreferences.class);
        assertLookup(fixture, NetworkingPreferences.class,  DefaultNetworkingPreferences.class);
      }

    private static  void assertLookup (final @Nonnull Lookup lookup,
                                          final @Nonnull Class serviceClass,
                                          final @Nonnull Class implementationClass)
      {
        final T service = lookup.lookup(serviceClass);
        assertNotNull("Cannot lookup service " + serviceClass, service);
        Class actualClass = service.getClass();
        assertTrue("Not the expected implementation: " + actualClass + ", expected: " + implementationClass, actualClass.equals(implementationClass));
      }
  }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy