public void testConstructor() throws Exception {

    Map<String, String> map = new HashMap<String, String>();
    map.put(
        Constants.SERVER_ROP_EVENT_BRIDGE_FACTORY_PROPERTY, MockEventBridgeFactory.class.getName());

    ObjectContextFactory factory =
        new ObjectContextFactory() {

          public ObjectContext createContext(DataChannel parent) {
            return null;
          }

          public ObjectContext createContext() {
            return null;
          }
        };
    BaseRemoteService service =
        new BaseRemoteService(factory, map) {

          @Override
          protected ServerSession createServerSession() {
            return null;
          }

          @Override
          protected ServerSession createServerSession(String name) {
            return null;
          }

          @Override
          protected ServerSession getServerSession() {
            return null;
          }
        };
    assertEquals(MockEventBridgeFactory.class.getName(), service.getEventBridgeFactoryName());
    assertSame(factory, service.contextFactory);
  }
  public void testProcessMessageExceptionSerializability() throws Throwable {

    Map<String, String> map = new HashMap<String, String>();
    ObjectContextFactory factory =
        new ObjectContextFactory() {

          public ObjectContext createContext(DataChannel parent) {
            return null;
          }

          public ObjectContext createContext() {
            return null;
          }
        };
    BaseRemoteService service =
        new BaseRemoteService(factory, map) {

          @Override
          protected ServerSession createServerSession() {
            return new ServerSession(new RemoteSession("a"), null);
          }

          @Override
          protected ServerSession createServerSession(String name) {
            return createServerSession();
          }

          @Override
          protected ServerSession getServerSession() {
            return createServerSession();
          }
        };

    try {
      service.processMessage(
          new QueryMessage(null) {

            @Override
            public Query getQuery() {
              // serializable exception thrown
              throw new CayenneRuntimeException();
            }
          });

      fail("Expected to throw");
    } catch (Exception ex) {
      Util.cloneViaSerialization(ex);
    }

    try {
      service.processMessage(
          new QueryMessage(null) {

            @Override
            public Query getQuery() {
              // non-serializable exception thrown
              throw new MockUnserializableException();
            }
          });

      fail("Expected to throw");
    } catch (Exception ex) {
      Util.cloneViaSerialization(ex);
    }
  }