private void checkReentrancy(ProxyBusObject proxy) {
   try {
     /* does the proxy implement InterfaceB? */
     InterfaceB intf = proxy.getInterface(InterfaceB.class);
     try {
       String id = intf.methodB();
       assertEquals(proxy.getBusName() + "@" + proxy.getObjPath(), id);
     } catch (BusException e) {
       // OK we might get ER_BUS_BLOCKING_CALL_NOT_ALLOWED here
       if (!e.getMessage().equals("ER_BUS_BLOCKING_CALL_NOT_ALLOWED")) {
         e.printStackTrace();
         fail("recieved an unexpected BusException.");
       }
     }
     bus.enableConcurrentCallbacks();
     try {
       String id = intf.methodB();
       assertEquals(proxy.getBusName() + "@" + proxy.getObjPath(), id);
     } catch (BusException e) {
       fail("method invocation failed: " + e);
     }
   } catch (ClassCastException cce) {
     /* no it doesn't -> then it must implement InterfaceA, right? */
     InterfaceA intf = proxy.getInterface(InterfaceA.class);
     try {
       String id = intf.methodA();
       assertEquals(proxy.getBusName() + "@" + proxy.getObjPath(), id);
     } catch (BusException e) {
       // OK we might get ER_BUS_BLOCKING_CALL_NOT_ALLOWED here
       if (!e.getMessage().equals("ER_BUS_BLOCKING_CALL_NOT_ALLOWED")) {
         e.printStackTrace();
         fail("recieved an unexpected BusException.");
       }
     }
     bus.enableConcurrentCallbacks();
     try {
       String id = intf.methodA();
       assertEquals(proxy.getBusName() + "@" + proxy.getObjPath(), id);
     } catch (BusException e) {
       fail("method invocation failed: " + e);
     }
   }
 }
  public void testClose() throws Exception {
    Participant provider = new Participant("prov");
    Participant consumer = new Participant("cons");
    final Observer obs = newObserver(consumer, InterfaceA.class);
    final ObserverListener listener = new ObserverListener(consumer);
    obs.registerListener(listener);
    provider.createA(A);
    waitForEvent(listener, provider, A);

    ProxyBusObject pbo = obs.getFirst();
    assertNotNull(pbo);

    obs.close();
    obs.close();
    obs.registerListener(listener);
    assertNull(obs.getFirst());
    assertNull(obs.get(pbo.getBusName(), pbo.getObjPath()));
    assertNull(obs.getNext(pbo));
    obs.unregisterListener(listener);
    obs.unregisterAllListeners();
    obs.close();
    Thread.sleep(100);
    listener.expectInvocations(0);
  }
 private void checkGet(ProxyBusObject obj, Observer obs) {
   assertSame(obj, obs.get(obj.getBusName(), obj.getObjPath()));
 }