Package com.sun.sgs.app

Examples of com.sun.sgs.app.Channel


  ClientGroup group = new ClientGroup(user);

  try {
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);
        ClientSession session =
      (ClientSession) dataService.getBinding(user);
        channel.join(session);
        dataService.removeObject(channel);
        try {
      channel.leave(session);
      fail("Expected IllegalStateException");
        } catch (IllegalStateException e) {
      System.err.println(e);
        }
    }
View Full Code Here


    @Test
    public void testChannelLeaveNullClientSession() throws Exception {
 
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel =
        channelService.createChannel("x", null, Delivery.RELIABLE);
    try {
        channel.leave((ClientSession) null);
        fail("Expected NullPointerException");
    } catch (NullPointerException e) {
        System.err.println(e);
    }
      }
View Full Code Here

  ClientGroup group = new ClientGroup(someUsers);
 
  try {
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);
 
        ClientSession moe =
      (ClientSession) dataService.getBinding(MOE);
        channel.join(moe);

        try {
      ClientSession larry =
          (ClientSession) dataService.getBinding(LARRY);
      channel.leave(larry);
      System.err.println("leave of non-member session returned");
     
        } catch (Exception e) {
      System.err.println(e);
      fail("test failed with exception: " + e);
        }
       
    }
       }, taskOwner);

      Thread.sleep(100);
     
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);
 
        ClientSession moe =
      (ClientSession) dataService.getBinding(MOE);

        ClientSession larry =
View Full Code Here

      for (final String user : someUsers) {
   
    txnScheduler.runTask(new TestAbstractKernelRunnable() {
        public void run() {
      Channel channel = getChannel(channelName);
      ClientSession session = getSession(user);
      channel.leave(session);
        }}, taskOwner);

    Thread.sleep(100);
   
    txnScheduler.runTask(new TestAbstractKernelRunnable() {
        public void run() {
      Channel channel = getChannel(channelName);
      ClientSession session = getSession(user);
      if (getSessions(channel).contains(session)) {
          fail("Failed to remove session: " + session);
      }}}, taskOwner);
      }
     
      Thread.sleep(1000);
      assertEquals(count, getObjectCount());
     
      txnScheduler.runTask(new TestAbstractKernelRunnable() {
    public void run() {
        Channel channel = getChannel(channelName);

        int numJoinedSessions = getSessions(channel).size();
        if (numJoinedSessions != 0) {
      fail("Expected no sessions, got " + numJoinedSessions);
        }
View Full Code Here

    // -- Test Channel.leaveAll --

    @Test
    public void testChannelLeaveAllNoTxn() throws Exception {
  Channel channel = createChannel();
  try {
      channel.leaveAll();
      fail("Expected TransactionNotActiveException");
  } catch (TransactionNotActiveException e) {
      System.err.println(e);
  }
    }
View Full Code Here

    @Test
    public void testChannelLeaveAllClosedChannel() throws Exception {
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel =
        channelService.createChannel("x", null, Delivery.RELIABLE);
    dataService.removeObject(channel);
    try {
        channel.leaveAll();
        fail("Expected IllegalStateException");
    } catch (IllegalStateException e) {
        System.err.println(e);
    }
      }
View Full Code Here

    @Test
    public void testChannelLeaveAllNoSessionsJoined() throws Exception {
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel =
        channelService.createChannel("x", null, Delivery.RELIABLE);
    channel.leaveAll();
    System.err.println(
        "leaveAll succeeded with no sessions joined");
      }
  }, taskOwner);
    }
View Full Code Here

    private static byte[] testMessage = new byte[] {'x'};

    @Test
    public void testChannelSendAllNoTxn() throws Exception {
  Channel channel = createChannel();
  try {
      channel.send(null, ByteBuffer.wrap(testMessage));
      fail("Expected TransactionNotActiveException");
  } catch (TransactionNotActiveException e) {
      System.err.println(e);
  }
    }
View Full Code Here

    public void testChannelSendAllClosedChannel() throws Exception {
  final String channelName = "test";
  createChannel(channelName);
  txnScheduler.runTask(new TestAbstractKernelRunnable() {
      public void run() {
    Channel channel = getChannel(channelName);
    dataService.removeObject(channel);
    try {
        channel.send(null, ByteBuffer.wrap(testMessage));
        fail("Expected IllegalStateException");
    } catch (IllegalStateException e) {
        System.err.println(e);
    }
      }
View Full Code Here

         ChannelListener listener,
         Delivery delivery)
    {
        serviceStats.createChannelOp.report();
  try {
      Channel channel = ChannelImpl.newInstance(
    name, listener, delivery, writeBufferSize);
      return channel;
     
  } catch (RuntimeException e) {
      logger.logThrow(Level.FINEST, e, "createChannel:{0} throws");
View Full Code Here

TOP

Related Classes of com.sun.sgs.app.Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.