1414
1515package com .firebase .ui .database ;
1616
17- import android .test .AndroidTestCase ;
17+ import android .support .test .runner .AndroidJUnit4 ;
18+ import android .test .InstrumentationTestCase ;
19+ import android .test .suitebuilder .annotation .SmallTest ;
1820
1921import com .google .firebase .FirebaseApp ;
2022import com .google .firebase .database .DatabaseError ;
2729import org .junit .After ;
2830import org .junit .Before ;
2931import org .junit .Test ;
32+ import org .junit .runner .RunWith ;
3033
3134import java .util .concurrent .Callable ;
3235import java .util .concurrent .TimeUnit ;
3336
34- public class FirebaseArrayTest extends AndroidTestCase {
37+ @ RunWith (AndroidJUnit4 .class )
38+ @ SmallTest
39+ public class FirebaseArrayTest extends InstrumentationTestCase {
40+
41+ private static final int TIMEOUT = 5000 ;
42+
3543 private DatabaseReference mRef ;
3644 private FirebaseArray mArray ;
3745
3846 @ Before
3947 public void setUp () throws Exception {
40- FirebaseApp app = ApplicationTest .getAppInstance (getContext ());
48+ FirebaseApp app = ApplicationTest .getAppInstance (getInstrumentation (). getContext ());
4149 mRef = FirebaseDatabase .getInstance (app ).getReference ().child ("firebasearray" );
4250 mArray = new FirebaseArray (mRef );
4351 mRef .removeValue ();
@@ -56,8 +64,13 @@ public Boolean call() throws Exception {
5664
5765 @ After
5866 public void tearDown () throws Exception {
59- mArray .cleanup ();
60- mRef .removeValue ();
67+ if (mRef != null ) {
68+ mRef .getRoot ().removeValue ();
69+ }
70+
71+ if (mArray != null ) {
72+ mArray .cleanup ();
73+ }
6174 }
6275
6376 @ Test
@@ -155,7 +168,7 @@ public void onCancelled(DatabaseError databaseError) {
155168 task .run ();
156169 boolean isDone = false ;
157170 long startedAt = System .currentTimeMillis ();
158- while (!isDone && System .currentTimeMillis () - startedAt < 5000 ) {
171+ while (!isDone && System .currentTimeMillis () - startedAt < TIMEOUT ) {
159172 semaphore .tryAcquire (1 , TimeUnit .SECONDS );
160173 try {
161174 isDone = done .call ();
0 commit comments