当前位置: 首页>>代码示例>>Java>>正文


Java FirebaseApp.delete方法代码示例

本文整理汇总了Java中com.google.firebase.FirebaseApp.delete方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseApp.delete方法的具体用法?Java FirebaseApp.delete怎么用?Java FirebaseApp.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.firebase.FirebaseApp的用法示例。


在下文中一共展示了FirebaseApp.delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInvokeAfterAppDelete

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Test
public void testInvokeAfterAppDelete() throws Exception {
  FirebaseApp app = FirebaseApp.initializeApp(firebaseOptions, "testInvokeAfterAppDelete");
  FirebaseAuth auth = FirebaseAuth.getInstance(app);
  assertNotNull(auth);
  app.delete();

  for (Method method : auth.getClass().getDeclaredMethods()) {
    int modifiers = method.getModifiers();
    if (!Modifier.isPublic(modifiers) || Modifier.isStatic(modifiers)) {
      continue;
    }

    List<Object> parameters = new ArrayList<>(method.getParameterTypes().length);
    for (Class<?> parameterType : method.getParameterTypes()) {
      parameters.add(Defaults.defaultValue(parameterType));
    }
    try {
      method.invoke(auth, parameters.toArray());
      fail("No error thrown when invoking auth after deleting app; method: " + method.getName());
    } catch (InvocationTargetException expected) {
      String message = "FirebaseAuth instance is no longer alive. This happens when "
          + "the parent FirebaseApp instance has been deleted.";
      Throwable cause = expected.getCause();
      assertTrue(cause instanceof IllegalStateException);
      assertEquals(message, cause.getMessage());
    }
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:30,代码来源:FirebaseAuthTest.java

示例2: testInitAfterAppDelete

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Test
public void testInitAfterAppDelete() throws ExecutionException, InterruptedException,
    TimeoutException {
  FirebaseApp app = FirebaseApp.initializeApp(firebaseOptions, "testInitAfterAppDelete");
  FirebaseAuth auth1 = FirebaseAuth.getInstance(app);
  assertNotNull(auth1);
  app.delete();

  app = FirebaseApp.initializeApp(firebaseOptions, "testInitAfterAppDelete");
  FirebaseAuth auth2 = FirebaseAuth.getInstance(app);
  assertNotNull(auth2);
  assertNotSame(auth1, auth2);

  if (isCertCredential) {
    ApiFuture<String> future = auth2.createCustomTokenAsync("foo");
    assertNotNull(future);
    assertNotNull(future.get(TestUtils.TEST_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:20,代码来源:FirebaseAuthTest.java

示例3: testAppDelete

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Test
public void testAppDelete() throws IOException {
  FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder()
      .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream()))
      .setStorageBucket("mock-bucket-name")
      .build());

  assertNotNull(StorageClient.getInstance());
  assertNotNull(StorageClient.getInstance(app));
  app.delete();
  try {
    StorageClient.getInstance(app);
    fail("No error thrown for deleted app");
  } catch (IllegalStateException expected) {
    // ignore
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:18,代码来源:StorageClientTest.java

示例4: testInitAfterAppDelete

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Test
public void testInitAfterAppDelete() throws ExecutionException, InterruptedException,
    TimeoutException {
  FirebaseApp app = FirebaseApp.initializeApp(firebaseOptions, "testInitAfterAppDelete");
  FirebaseDatabase db1 = FirebaseDatabase.getInstance(app);
  assertNotNull(db1);
  app.delete();

  app = FirebaseApp.initializeApp(firebaseOptions, "testInitAfterAppDelete");
  FirebaseDatabase db2 = FirebaseDatabase.getInstance(app);
  assertNotNull(db2);
  assertNotSame(db1, db2);
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:14,代码来源:FirebaseDatabaseTest.java

示例5: testAppDelete

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Test
public void testAppDelete() throws ExecutionException, InterruptedException {
  FirebaseApp app = FirebaseApp.initializeApp(firebaseOptions, "testAppDelete");
  FirebaseAuth auth = FirebaseAuth.getInstance(app);
  assertNotNull(auth);
  app.delete();
  try {
    FirebaseAuth.getInstance(app);
    fail("No error thrown when getting auth instance after deleting app");
  } catch (IllegalStateException expected) {
    // ignore
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:14,代码来源:FirebaseAuthTest.java

示例6: testDefaultThreadManager

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Test
public void testDefaultThreadManager() throws Exception {
  Assume.assumeFalse(GaeThreadFactory.isAvailable());

  FirebaseOptions options = new FirebaseOptions.Builder()
      .setCredentials(new MockGoogleCredentials())
      .build();
  FirebaseApp defaultApp = FirebaseApp.initializeApp(options);
  final Map<String, Object> threadInfo = new HashMap<>();
  Callable<Void> command = new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      Thread thread = Thread.currentThread();
      threadInfo.put("name", thread.getName());
      threadInfo.put("daemon", thread.isDaemon());
      return null;
    }
  };
  Tasks.await(ImplFirebaseTrampolines.submitCallable(defaultApp, command));

  // Check for default JVM thread properties.
  assertTrue(threadInfo.get("name").toString().startsWith("firebase-default-"));
  assertTrue((Boolean) threadInfo.get("daemon"));

  defaultApp.delete();
  try {
    ImplFirebaseTrampolines.submitCallable(defaultApp, command);
    fail("No error thrown when submitting to deleted app");
  } catch (RejectedExecutionException expected) {
    // expected
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:33,代码来源:FirebaseThreadManagersTest.java

示例7: testDeleteInstanceIdError

import com.google.firebase.FirebaseApp; //导入方法依赖的package包/类
@Test
public void testDeleteInstanceIdError() throws Exception {
  Map<Integer, String> errors = ImmutableMap.of(
      404, "Instance ID \"test-iid\": Failed to find the instance ID.",
      429, "Instance ID \"test-iid\": Request throttled out by the backend server.",
      500, "Instance ID \"test-iid\": Internal server error.",
      501, "Error while invoking instance ID service."
  );

  String url = "https://console.firebase.google.com/v1/project/test-project/instanceId/test-iid";
  for (Map.Entry<Integer, String> entry : errors.entrySet()) {
    MockLowLevelHttpResponse response = new MockLowLevelHttpResponse()
        .setStatusCode(entry.getKey())
        .setContent("test error");
    MockHttpTransport transport = new MockHttpTransport.Builder()
        .setLowLevelHttpResponse(response)
        .build();
    FirebaseOptions options = new FirebaseOptions.Builder()
        .setCredentials(new MockGoogleCredentials("test-token"))
        .setProjectId("test-project")
        .setHttpTransport(transport)
        .build();
    final FirebaseApp app = FirebaseApp.initializeApp(options);

    FirebaseInstanceId instanceId = FirebaseInstanceId.getInstance();
    TestResponseInterceptor interceptor = new TestResponseInterceptor();
    instanceId.setInterceptor(interceptor);
    try {
      instanceId.deleteInstanceIdAsync("test-iid").get();
      fail("No error thrown for HTTP error");
    } catch (ExecutionException e) {
      assertTrue(e.getCause() instanceof FirebaseInstanceIdException);
      assertEquals(entry.getValue(), e.getCause().getMessage());
      assertTrue(e.getCause().getCause() instanceof HttpResponseException);
    }

    assertNotNull(interceptor.getResponse());
    HttpRequest request = interceptor.getResponse().getRequest();
    assertEquals("DELETE", request.getRequestMethod());
    assertEquals(url, request.getUrl().toString());
    assertEquals("Bearer test-token", request.getHeaders().getAuthorization());
    app.delete();
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:45,代码来源:FirebaseInstanceIdTest.java


注:本文中的com.google.firebase.FirebaseApp.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。