@@ -0,0 +1,2208 @@
+// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; -*-%0A// vim: et ts=4 sts=4 sw=4 syntax=java%0Apackage com.aragaer.jtt;%0A%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Matchers.*;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.powermock.api.mockito.PowerMockito.*;%0A%0Aimport android.app.Service;%0Aimport android.content.*;%0Aimport android.preference.PreferenceManager;%0Aimport android.os.Handler;%0Aimport android.util.Log;%0A%0Aimport org.junit.*;%0Aimport org.junit.runner.RunWith;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0A%0Aimport com.aragaer.jtt.android.AndroidTicker;%0A%0A%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(%7BAndroidTicker.class, Log.class, Service.class, PreferenceManager.class%7D)%0Apublic class JttServiceTest %7B%0A%0A    private static Context mockContext = mock(Context.class);%0A    private static SharedPreferences mockPref = mock(SharedPreferences.class);%0A    private static Handler mockHandler = mock(Handler.class);%0A%0A    private TestJttService service;%0A%0A    @Before public void setUp() throws Exception %7B%0A        mockStatic(Log.class);%0A        mockStatic(PreferenceManager.class);%0A        when(PreferenceManager.getDefaultSharedPreferences(any(Context.class))).thenReturn(mockPref);%0A        when(mockPref.getString(Settings.PREF_LOCATION, %220.0:0.0%22)).thenReturn(%220.0:0.0%22);%0A        suppress(method(Handler.class, %22sendEmptyMessage%22));%0A        suppress(method(Service.class, %22onCreate%22));%0A%0A        service = spy(new TestJttService());%0A    %7D%0A%0A    @Test public void testStart() %7B%0A        int result = service.onStartCommand(null, 0, 0);%0A        assertEquals(%22onStartCommand returns START_STICKY%22,%0A                     Service.START_STICKY, result);%0A        assertEquals(%22Two recievers registered in onStartCommand%22,%0A                     2, service.receiversRegistered);%0A    %7D%0A%0A    private class TestJttService extends JttService %7B%0A        int receiversRegistered = 0;%0A%0A        @Override public Intent registerReceiver(BroadcastReceiver receiver,%0A                                                 IntentFilter intentFilter) %7B%0A            receiversRegistered++;%0A            return null;%0A        %7D%0A    %7D%0A%7D%0A

Create test for JttService