diff --git a/firebase.json b/firebase.json index 81fba82..ad7bf19 100644 --- a/firebase.json +++ b/firebase.json @@ -1,4 +1,5 @@ { + "project_id": "geofire-java", "firebase": "geofire-java", "public": "site", "ignore": [ diff --git a/pom.xml b/pom.xml index 12ead4f..12bf171 100644 --- a/pom.xml +++ b/pom.xml @@ -78,14 +78,9 @@ - com.firebase - - firebase-client-jvm - [2.0.0,) - + com.google.firebase + firebase-server-sdk + [3.0.0,) provided diff --git a/src/main/java/com/firebase/geofire/GeoFire.java b/src/main/java/com/firebase/geofire/GeoFire.java index 20449b9..ff8b5b3 100644 --- a/src/main/java/com/firebase/geofire/GeoFire.java +++ b/src/main/java/com/firebase/geofire/GeoFire.java @@ -28,9 +28,11 @@ package com.firebase.geofire; -import com.firebase.client.*; import com.firebase.geofire.core.GeoHash; -import com.firebase.geofire.util.GeoUtils; +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.ValueEventListener; import java.util.*; @@ -46,10 +48,11 @@ public static interface CompletionListener { /** * Called once a location was successfully saved on the server or an error occurred. On success, the parameter * error will be null; in case of an error, the error will be passed to this method. - * @param key The key whose location was saved + * + * @param key The key whose location was saved * @param error The error or null if no error occurred */ - public void onComplete(String key, FirebaseError error); + public void onComplete(String key, DatabaseError error); } /** @@ -73,14 +76,14 @@ public void onDataChange(DataSnapshot dataSnapshot) { this.callback.onLocationResult(dataSnapshot.getKey(), location); } else { String message = "GeoFire data has invalid format: " + dataSnapshot.getValue(); - this.callback.onCancelled(new FirebaseError(FirebaseError.UNKNOWN_ERROR, message)); + this.callback.onCancelled(DatabaseError.fromStatus(message)); } } } @Override - public void onCancelled(FirebaseError firebaseError) { - this.callback.onCancelled(firebaseError); + public void onCancelled(DatabaseError databaseError) { + this.callback.onCancelled(databaseError); } } @@ -88,8 +91,8 @@ static GeoLocation getLocationValue(DataSnapshot dataSnapshot) { try { Map data = dataSnapshot.getValue(Map.class); List location = (List) data.get("l"); - Number latitudeObj = (Number)location.get(0); - Number longitudeObj = (Number)location.get(1); + Number latitudeObj = (Number) location.get(0); + Number longitudeObj = (Number) location.get(1); double latitude = latitudeObj.doubleValue(); double longitude = longitudeObj.doubleValue(); if (location.size() == 2 && GeoLocation.coordinatesValid(latitude, longitude)) { @@ -97,8 +100,6 @@ static GeoLocation getLocationValue(DataSnapshot dataSnapshot) { } else { return null; } - } catch (FirebaseException e) { - return null; } catch (NullPointerException e) { return null; } catch (ClassCastException e) { @@ -106,30 +107,32 @@ static GeoLocation getLocationValue(DataSnapshot dataSnapshot) { } } - private final Firebase firebase; + private final DatabaseReference databaseReference; /** * Creates a new GeoFire instance at the given Firebase reference. - * @param firebase The Firebase reference this GeoFire instance uses + * + * @param databaseReference The Firebase reference this GeoFire instance uses */ - public GeoFire(Firebase firebase) { - this.firebase = firebase; + public GeoFire(DatabaseReference databaseReference) { + this.databaseReference = databaseReference; } /** * @return The Firebase reference this GeoFire instance uses */ - public Firebase getFirebase() { - return this.firebase; + public DatabaseReference getDatabaseReference() { + return this.databaseReference; } - Firebase firebaseRefForKey(String key) { - return this.firebase.child(key); + DatabaseReference getDatabaseRefForKey(String key) { + return this.databaseReference.child(key); } /** * Sets the location for a given key. - * @param key The key to save the location for + * + * @param key The key to save the location for * @param location The location of this key */ public void setLocation(String key, GeoLocation location) { @@ -138,8 +141,9 @@ public void setLocation(String key, GeoLocation location) { /** * Sets the location for a given key. - * @param key The key to save the location for - * @param location The location of this key + * + * @param key The key to save the location for + * @param location The location of this key * @param completionListener A listener that is called once the location was successfully saved on the server or an * error occurred */ @@ -147,18 +151,16 @@ public void setLocation(final String key, final GeoLocation location, final Comp if (key == null) { throw new NullPointerException(); } - Firebase keyRef = this.firebaseRefForKey(key); + DatabaseReference keyRef = this.getDatabaseRefForKey(key); GeoHash geoHash = new GeoHash(location); Map updates = new HashMap(); updates.put("g", geoHash.getGeoHashString()); updates.put("l", new double[]{location.latitude, location.longitude}); if (completionListener != null) { - keyRef.setValue(updates, geoHash.getGeoHashString(), new Firebase.CompletionListener() { + keyRef.setValue(updates, geoHash.getGeoHashString(), new DatabaseReference.CompletionListener() { @Override - public void onComplete(FirebaseError error, Firebase firebase) { - if (completionListener != null) { - completionListener.onComplete(key, error); - } + public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { + completionListener.onComplete(key, databaseError); } }); } else { @@ -168,6 +170,7 @@ public void onComplete(FirebaseError error, Firebase firebase) { /** * Removes the location for a key from this GeoFire. + * * @param key The key to remove from this GeoFire */ public void removeLocation(String key) { @@ -176,7 +179,8 @@ public void removeLocation(String key) { /** * Removes the location for a key from this GeoFire. - * @param key The key to remove from this GeoFire + * + * @param key The key to remove from this GeoFire * @param completionListener A completion listener that is called once the location is successfully removed * from the server or an error occurred */ @@ -184,12 +188,12 @@ public void removeLocation(final String key, final CompletionListener completion if (key == null) { throw new NullPointerException(); } - Firebase keyRef = this.firebaseRefForKey(key); + DatabaseReference keyRef = this.getDatabaseRefForKey(key); if (completionListener != null) { - keyRef.setValue(null, new Firebase.CompletionListener() { + keyRef.setValue(null, new DatabaseReference.CompletionListener() { @Override - public void onComplete(FirebaseError error, Firebase firebase) { - completionListener.onComplete(key, error); + public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { + completionListener.onComplete(key, databaseError); } }); } else { @@ -200,17 +204,18 @@ public void onComplete(FirebaseError error, Firebase firebase) { /** * Gets the current location for a key and calls the callback with the current value. * - * @param key The key whose location to get + * @param key The key whose location to get * @param callback The callback that is called once the location is retrieved */ public void getLocation(String key, LocationCallback callback) { - Firebase keyFirebase = this.firebaseRefForKey(key); + DatabaseReference keyRef = this.getDatabaseRefForKey(key); LocationValueEventListener valueListener = new LocationValueEventListener(callback); - keyFirebase.addListenerForSingleValueEvent(valueListener); + keyRef.addListenerForSingleValueEvent(valueListener); } /** * Returns a new Query object centered at the given location and with the given radius. + * * @param center The center of the query * @param radius The radius of the query, in kilometers * @return The new GeoQuery object diff --git a/src/main/java/com/firebase/geofire/GeoQuery.java b/src/main/java/com/firebase/geofire/GeoQuery.java index 6cae1b0..08d110d 100644 --- a/src/main/java/com/firebase/geofire/GeoQuery.java +++ b/src/main/java/com/firebase/geofire/GeoQuery.java @@ -28,10 +28,13 @@ package com.firebase.geofire; -import com.firebase.client.*; import com.firebase.geofire.core.GeoHash; import com.firebase.geofire.core.GeoHashQuery; import com.firebase.geofire.util.GeoUtils; +import com.google.firebase.FirebaseApp; +import com.google.firebase.database.*; +import com.google.firebase.database.core.EventTarget; +import com.google.firebase.database.core.Repo; import java.util.*; @@ -80,7 +83,7 @@ public synchronized void onChildMoved(DataSnapshot dataSnapshot, String s) { } @Override - public synchronized void onCancelled(FirebaseError firebaseError) { + public synchronized void onCancelled(DatabaseError databaseError) { // ignore, our API does not support onCancelled } }; @@ -112,8 +115,8 @@ private boolean locationIsInQuery(GeoLocation location) { } private void postEvent(Runnable r) { - EventTarget target = Firebase.getDefaultConfig().getEventTarget(); - target.postEvent(r); + Repo repo = geoFire.getDatabaseReference().getRepo(); + repo.postEvent(r); } private void updateLocationInfo(final String key, final GeoLocation location) { @@ -209,13 +212,13 @@ public void onDataChange(DataSnapshot dataSnapshot) { } @Override - public void onCancelled(final FirebaseError firebaseError) { + public void onCancelled(final DatabaseError databaseError) { synchronized (GeoQuery.this) { for (final GeoQueryEventListener listener : GeoQuery.this.eventListeners) { postEvent(new Runnable() { @Override public void run() { - listener.onGeoQueryError(firebaseError); + listener.onGeoQueryError(databaseError); } }); } @@ -238,8 +241,8 @@ private void setupQueries() { for (final GeoHashQuery query: newQueries) { if (!oldQueries.contains(query)) { outstandingQueries.add(query); - Firebase firebase = this.geoFire.getFirebase(); - Query firebaseQuery = firebase.orderByChild("g").startAt(query.getStartValue()).endAt(query.getEndValue()); + DatabaseReference databaseReference = this.geoFire.getDatabaseReference(); + Query firebaseQuery = databaseReference.orderByChild("g").startAt(query.getStartValue()).endAt(query.getEndValue()); firebaseQuery.addChildEventListener(this.childEventLister); addValueToReadyListener(firebaseQuery, query); firebaseQueries.put(query, firebaseQuery); @@ -283,7 +286,7 @@ private void childRemoved(DataSnapshot dataSnapshot) { final String key = dataSnapshot.getKey(); final LocationInfo info = this.locationInfos.get(key); if (info != null) { - this.geoFire.firebaseRefForKey(key).addListenerForSingleValueEvent(new ValueEventListener() { + this.geoFire.getDatabaseRefForKey(key).addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { synchronized(GeoQuery.this) { @@ -307,7 +310,7 @@ public void run() { } @Override - public void onCancelled(FirebaseError firebaseError) { + public void onCancelled(DatabaseError databaseError) { // tough luck } }); diff --git a/src/main/java/com/firebase/geofire/GeoQueryEventListener.java b/src/main/java/com/firebase/geofire/GeoQueryEventListener.java index 81174c0..adfc515 100644 --- a/src/main/java/com/firebase/geofire/GeoQueryEventListener.java +++ b/src/main/java/com/firebase/geofire/GeoQueryEventListener.java @@ -28,7 +28,7 @@ package com.firebase.geofire; -import com.firebase.client.FirebaseError; +import com.google.firebase.database.DatabaseError; /** * GeoQuery notifies listeners with this interface about keys that entered, exited, or moved within the query. @@ -75,6 +75,6 @@ public interface GeoQueryEventListener { * Called in case an error occurred while retrieving locations for a query, e.g. violating security rules. * @param error The error that occurred while retrieving the query */ - public void onGeoQueryError(FirebaseError error); + public void onGeoQueryError(DatabaseError error); } diff --git a/src/main/java/com/firebase/geofire/LocationCallback.java b/src/main/java/com/firebase/geofire/LocationCallback.java index bd33d4a..7d84eee 100644 --- a/src/main/java/com/firebase/geofire/LocationCallback.java +++ b/src/main/java/com/firebase/geofire/LocationCallback.java @@ -28,7 +28,7 @@ package com.firebase.geofire; -import com.firebase.client.FirebaseError; +import com.google.firebase.database.DatabaseError; /** * Classes implementing this interface can be used to receive the locations stored in GeoFire. @@ -45,8 +45,8 @@ public interface LocationCallback { /** * Called if the callback could not be added due to failure on the server or security rules. - * @param firebaseError The error that occurred + * @param databaseError The error that occurred */ - public void onCancelled(FirebaseError firebaseError); + public void onCancelled(DatabaseError databaseError); } diff --git a/src/main/java/com/firebase/geofire/example/Example.java b/src/main/java/com/firebase/geofire/example/Example.java index 3994b6d..0df32cc 100644 --- a/src/main/java/com/firebase/geofire/example/Example.java +++ b/src/main/java/com/firebase/geofire/example/Example.java @@ -1,16 +1,17 @@ package com.firebase.geofire.example; -import com.firebase.client.Firebase; -import com.firebase.client.FirebaseError; import com.firebase.geofire.GeoFire; import com.firebase.geofire.GeoLocation; import com.firebase.geofire.GeoQuery; import com.firebase.geofire.GeoQueryEventListener; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; +import com.google.firebase.database.FirebaseDatabase; public class Example { public static void main(String[] args) throws InterruptedException { - Firebase firebase = new Firebase("https://geofire-v3.firebaseio.com/geofire"); + DatabaseReference firebase = FirebaseDatabase.getInstance().getReferenceFromUrl("https://geofire-v3.firebaseio.com/geofire"); GeoFire geoFire = new GeoFire(firebase); GeoQuery query = geoFire.queryAtLocation(new GeoLocation(37.7, -122.4), 10); query.addGeoQueryEventListener(new GeoQueryEventListener() { @@ -35,7 +36,7 @@ public void onGeoQueryReady() { } @Override - public void onGeoQueryError(FirebaseError error) { + public void onGeoQueryError(DatabaseError error) { System.err.println("There was an error querying locations: " + error.getMessage()); } }); diff --git a/src/test/java/com/firebase/geofire/GeoFireTest.java b/src/test/java/com/firebase/geofire/GeoFireTest.java index a57c3f9..478dc62 100644 --- a/src/test/java/com/firebase/geofire/GeoFireTest.java +++ b/src/test/java/com/firebase/geofire/GeoFireTest.java @@ -1,9 +1,9 @@ package com.firebase.geofire; -import com.firebase.client.DataSnapshot; -import com.firebase.client.Firebase; -import com.firebase.client.FirebaseError; import com.firebase.geofire.util.ReadFuture; +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.DatabaseReference; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -28,7 +28,7 @@ public void geoFireSetsLocations() throws InterruptedException, ExecutionExcepti setLoc(geoFire, "loc2", 50, 50); setLoc(geoFire, "loc3", -90, -90, true); - Future future = new ReadFuture(geoFire.getFirebase()); + Future future = new ReadFuture(geoFire.getDatabaseReference()); Map expected = new HashMap(); expected.put("loc1", new HashMap() {{ put("l", Arrays.asList(0.0, 0.0)); @@ -78,7 +78,7 @@ public void getLocationReturnsCorrectLocation() throws InterruptedException, Exe @Test public void getLocationOnWrongDataReturnsError() throws InterruptedException { GeoFire geoFire = newTestGeoFire(); - setValueAndWait(geoFire.firebaseRefForKey("loc1"), "NaN"); + setValueAndWait(geoFire.getDatabaseRefForKey("loc1"), "NaN"); final Semaphore semaphore = new Semaphore(0); geoFire.getLocation("loc1", new LocationCallback() { @@ -88,13 +88,13 @@ public void onLocationResult(String key, GeoLocation location) { } @Override - public void onCancelled(FirebaseError firebaseError) { + public void onCancelled(DatabaseError databaseError) { semaphore.release(); } }); semaphore.tryAcquire(TestHelpers.TIMEOUT_SECONDS, TimeUnit.SECONDS); - setValueAndWait(geoFire.firebaseRefForKey("loc2"), new HashMap() {{ + setValueAndWait(geoFire.getDatabaseRefForKey("loc2"), new HashMap() {{ put("l", 10); put("g", "abc"); }}); @@ -106,7 +106,7 @@ public void onLocationResult(String key, GeoLocation location) { } @Override - public void onCancelled(FirebaseError firebaseError) { + public void onCancelled(DatabaseError databaseError) { semaphore.release(); } }); @@ -136,15 +136,15 @@ public void invalidCoordinatesThrowException() { @Test public void locationWorksWithLongs() throws InterruptedException, ExecutionException, TimeoutException { GeoFire geoFire = newTestGeoFire(); - Firebase firebase = geoFire.firebaseRefForKey("loc"); + DatabaseReference databaseReference = geoFire.getDatabaseRefForKey("loc"); final Semaphore semaphore = new Semaphore(0); - firebase.setValue(new HashMap() {{ + databaseReference.setValue(new HashMap() {{ put("l", Arrays.asList(1L, 2L)); put("g", "7zzzzzzzzz"); // this is wrong but we don't care in this test - }}, "7zzzzzzzzz", new Firebase.CompletionListener() { + }}, "7zzzzzzzzz", new DatabaseReference.CompletionListener() { @Override - public void onComplete(FirebaseError error, Firebase firebase) { + public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { semaphore.release(); } }); diff --git a/src/test/java/com/firebase/geofire/GeoQueryEventTestListener.java b/src/test/java/com/firebase/geofire/GeoQueryEventTestListener.java index 80e5036..008fdd0 100644 --- a/src/test/java/com/firebase/geofire/GeoQueryEventTestListener.java +++ b/src/test/java/com/firebase/geofire/GeoQueryEventTestListener.java @@ -1,6 +1,6 @@ package com.firebase.geofire; -import com.firebase.client.FirebaseError; +import com.google.firebase.database.DatabaseError; public class GeoQueryEventTestListener extends TestListener implements GeoQueryEventListener { @@ -56,6 +56,6 @@ public void onGeoQueryReady() { } @Override - public void onGeoQueryError(FirebaseError error) { + public void onGeoQueryError(DatabaseError error) { } } diff --git a/src/test/java/com/firebase/geofire/GeoQueryTest.java b/src/test/java/com/firebase/geofire/GeoQueryTest.java index 212d6c8..ec028cc 100644 --- a/src/test/java/com/firebase/geofire/GeoQueryTest.java +++ b/src/test/java/com/firebase/geofire/GeoQueryTest.java @@ -1,6 +1,6 @@ package com.firebase.geofire; -import com.firebase.client.FirebaseError; +import com.google.firebase.database.DatabaseError; import junit.framework.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -243,7 +243,7 @@ public void onGeoQueryReady() { } @Override - public void onGeoQueryError(FirebaseError error) { + public void onGeoQueryError(DatabaseError error) { } }); @@ -285,7 +285,7 @@ public void onGeoQueryReady() { } @Override - public void onGeoQueryError(FirebaseError error) { + public void onGeoQueryError(DatabaseError error) { } }); @@ -310,7 +310,7 @@ public void onGeoQueryReady() { } @Override - public void onGeoQueryError(FirebaseError error) { + public void onGeoQueryError(DatabaseError error) { } }); Assert.assertTrue(semaphore.tryAcquire(10, TimeUnit.MILLISECONDS)); @@ -352,7 +352,7 @@ public void onGeoQueryReady() { } @Override - public void onGeoQueryError(FirebaseError error) { + public void onGeoQueryError(DatabaseError error) { } }); diff --git a/src/test/java/com/firebase/geofire/RealDataTest.java b/src/test/java/com/firebase/geofire/RealDataTest.java index de8630a..c5766c7 100644 --- a/src/test/java/com/firebase/geofire/RealDataTest.java +++ b/src/test/java/com/firebase/geofire/RealDataTest.java @@ -1,11 +1,17 @@ package com.firebase.geofire; -import com.firebase.client.*; import com.firebase.geofire.core.SimpleFuture; +import com.google.firebase.FirebaseApp; +import com.google.firebase.FirebaseOptions; +import com.google.firebase.database.*; +import com.google.firebase.database.core.Repo; +import com.oracle.javafx.jmx.json.JSONException; import junit.framework.Assert; import org.junit.After; import org.junit.Before; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; @@ -13,20 +19,25 @@ public class RealDataTest { - Firebase firebase; + DatabaseReference databaseReference; @Before - public void setup() { - Config cfg = Firebase.getDefaultConfig(); - if (!cfg.isFrozen()) { - cfg.setLogLevel(Logger.Level.DEBUG); + public void setup() throws FileNotFoundException { + String databaseUrl = String.format("https://%s.firebaseio-demo.com", TestHelpers.randomAlphaNumericString(16)); + FirebaseOptions firebaseOptions = new FirebaseOptions.Builder() + .setDatabaseUrl(databaseUrl) + .setServiceAccount(new FileInputStream("firebase.json")) + .build(); + FirebaseApp.initializeApp(firebaseOptions); + this.databaseReference = FirebaseDatabase.getInstance().getReferenceFromUrl(databaseUrl); + Repo repo= databaseReference.getRepo(); + if (repo != null) { + FirebaseDatabase.getInstance().setLogLevel(Logger.Level.DEBUG); } - this.firebase = new Firebase(String.format("https://%s.firebaseio-demo.com", - TestHelpers.randomAlphaNumericString(16))); } public GeoFire newTestGeoFire() { - return new GeoFire(this.firebase.child(TestHelpers.randomAlphaNumericString(16))); + return new GeoFire(this.databaseReference.child(TestHelpers.randomAlphaNumericString(16))); } protected void setLoc(GeoFire geoFire, String key, double latitude, double longitude) { @@ -37,12 +48,12 @@ protected void removeLoc(GeoFire geoFire, String key) { removeLoc(geoFire, key, false); } - protected void setValueAndWait(Firebase firebase, Object value) { - final SimpleFuture futureError = new SimpleFuture(); - firebase.setValue(value, new Firebase.CompletionListener() { + protected void setValueAndWait(DatabaseReference databaseReference, Object value) { + final SimpleFuture futureError = new SimpleFuture(); + databaseReference.setValue(value, new DatabaseReference.CompletionListener() { @Override - public void onComplete(FirebaseError error, Firebase firebase) { - futureError.put(error); + public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) { + futureError.put(databaseError); } }); try { @@ -57,11 +68,11 @@ public void onComplete(FirebaseError error, Firebase firebase) { } protected void setLoc(GeoFire geoFire, String key, double latitude, double longitude, boolean wait) { - final SimpleFuture futureError = new SimpleFuture(); + final SimpleFuture futureError = new SimpleFuture(); geoFire.setLocation(key, new GeoLocation(latitude, longitude), new GeoFire.CompletionListener() { @Override - public void onComplete(String key, FirebaseError firebaseError) { - futureError.put(firebaseError); + public void onComplete(String key, DatabaseError error) { + futureError.put(error); } }); if (wait) { @@ -78,11 +89,11 @@ public void onComplete(String key, FirebaseError firebaseError) { } protected void removeLoc(GeoFire geoFire, String key, boolean wait) { - final SimpleFuture futureError = new SimpleFuture(); + final SimpleFuture futureError = new SimpleFuture(); geoFire.removeLocation(key, new GeoFire.CompletionListener() { @Override - public void onComplete(String key, FirebaseError firebaseError) { - futureError.put(firebaseError); + public void onComplete(String key, DatabaseError error) { + futureError.put(error); } }); if (wait) { @@ -100,15 +111,15 @@ public void onComplete(String key, FirebaseError firebaseError) { protected void waitForGeoFireReady(GeoFire geoFire) throws InterruptedException { final Semaphore semaphore = new Semaphore(0); - geoFire.getFirebase().addListenerForSingleValueEvent(new ValueEventListener() { + geoFire.getDatabaseReference().addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { semaphore.release(); } @Override - public void onCancelled(FirebaseError firebaseError) { - Assert.fail("Firebase error: " + firebaseError); + public void onCancelled(DatabaseError databaseError) { + Assert.fail("Firebase error: " + databaseError); } }); Assert.assertTrue("Timeout occured!", semaphore.tryAcquire(TestHelpers.TIMEOUT_SECONDS, TimeUnit.SECONDS)); @@ -116,7 +127,7 @@ public void onCancelled(FirebaseError firebaseError) { @After public void teardown() { - this.firebase.setValue(null); - this.firebase = null; + this.databaseReference.setValue(null); + this.databaseReference = null; } } diff --git a/src/test/java/com/firebase/geofire/TestCallback.java b/src/test/java/com/firebase/geofire/TestCallback.java index 966301c..bc96da7 100644 --- a/src/test/java/com/firebase/geofire/TestCallback.java +++ b/src/test/java/com/firebase/geofire/TestCallback.java @@ -1,7 +1,7 @@ package com.firebase.geofire; -import com.firebase.client.FirebaseError; import com.firebase.geofire.core.SimpleFuture; +import com.google.firebase.database.DatabaseError; import org.junit.Assert; import java.util.concurrent.ExecutionException; @@ -37,7 +37,7 @@ public void onLocationResult(String key, GeoLocation location) { } @Override - public void onCancelled(FirebaseError firebaseError) { + public void onCancelled(DatabaseError firebaseError) { Assert.fail("Firebase synchronization failed: " + firebaseError); } } diff --git a/src/test/java/com/firebase/geofire/util/ReadFuture.java b/src/test/java/com/firebase/geofire/util/ReadFuture.java index e4431ef..b7e9651 100644 --- a/src/test/java/com/firebase/geofire/util/ReadFuture.java +++ b/src/test/java/com/firebase/geofire/util/ReadFuture.java @@ -1,10 +1,10 @@ package com.firebase.geofire.util; -import com.firebase.client.DataSnapshot; -import com.firebase.client.FirebaseError; -import com.firebase.client.Query; -import com.firebase.client.ValueEventListener; import com.firebase.geofire.core.SimpleFuture; +import com.google.firebase.database.DataSnapshot; +import com.google.firebase.database.DatabaseError; +import com.google.firebase.database.Query; +import com.google.firebase.database.ValueEventListener; public class ReadFuture extends SimpleFuture { @@ -16,8 +16,8 @@ public void onDataChange(DataSnapshot dataSnapshot) { } @Override - public void onCancelled(FirebaseError firebaseError) { - ReadFuture.this.put(firebaseError); + public void onCancelled(DatabaseError databaseError) { + ReadFuture.this.put(databaseError); } }); }