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


Java Util.assertEquals方法代码示例

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


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

示例1: testAcceptLastResponseFilter

import org.jgroups.util.Util; //导入方法依赖的package包/类
/**
 * Runs with response mode of GET_FIRST and the response filter accepts only the last response
 * @throws Exception
 */
public void testAcceptLastResponseFilter() throws Exception {
    RequestOptions options=new RequestOptions(ResponseMode.GET_FIRST, 10000, false,
                                              new RspFilter() {
                                                  int count=0;
                                                  public boolean isAcceptable(Object response, Address sender) {
                                                      return ++count >= 3;
                                                  }
                                                  public boolean needMoreResponses() {return count < 3;}
                                              });

    RspList rsps=disp1.callRemoteMethods(null, "foo", null, null, options);
    System.out.println("responses are:\n" + rsps);
    Util.assertEquals("there should be three response values", 3, rsps.size());
    Util.assertEquals("number of responses received should be 3", 1, rsps.numReceived());
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:RpcDispatcherTest.java

示例2: _testLargeValueUnicastCall

import org.jgroups.util.Util; //导入方法依赖的package包/类
/**
 * Helper method to perform a RPC call on server method "returnValue(int size)" for 
 * an individual group member. 
 * 
 * The method checks that the returned value is non-null and has the correct size. 
 * 
 * @param dst the group member
 * @param size the size of the byte array to be returned
 */
void _testLargeValueUnicastCall(Address dst, int size) throws Exception {

    final long timeout = LARGE_VALUE_TIMEOUT * 1000 ;

    System.out.println("\ntesting unicast call with " + size + " bytes");
    Util.assertNotNull(dst);

    long startTime = System.currentTimeMillis();
    byte[] val=disp1.callRemoteMethod(dst, "largeReturnValue", new Object[]{size}, new Class[]{int.class},
                                         new RequestOptions(ResponseMode.GET_ALL, timeout));
    long stopTime = System.currentTimeMillis();
    System.out.println("test took: " + (stopTime-startTime) + " ms");

    // check value is not null, otherwise fail the test
    Util.assertNotNull("return value should be non-null", val);
    System.out.println("rsp: " + val.length + " bytes");
    
    // returned value should have requested size
    Util.assertEquals("return value does not match requested size", size, val.length);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:30,代码来源:RpcDispatcherTest.java

示例3: testNonTerminatingResponseFilter

import org.jgroups.util.Util; //导入方法依赖的package包/类
/**
 * Tests an incorrect response filter which always returns false for isAcceptable() and true for needsMoreResponses().
 * The call should return anyway after having received all responses, even if none of them was accepted by the
 * filter.
 */
public void testNonTerminatingResponseFilter() throws Exception {
    RequestOptions options=new RequestOptions(ResponseMode.GET_ALL, 10000, false,
                                              new RspFilter() {
                                                  public boolean isAcceptable(Object response, Address sender) {
                                                      return false;
                                                  }
                                                  public boolean needMoreResponses() {return true;}
                                              });

    RspList rsps=disp1.callRemoteMethods(null, "foo", null, null, options);
    System.out.println("responses are:\n" + rsps);
    Util.assertEquals("there should be three response values", 3, rsps.size());
    Util.assertEquals("number of responses received should be 3", 0, rsps.numReceived());
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:20,代码来源:RpcDispatcherTest.java

示例4: assertEquals

import org.jgroups.util.Util; //导入方法依赖的package包/类
protected final static void assertEquals(String message, Object val1, Object val2) {
    Util.assertEquals(message,val1,val2);
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:4,代码来源:ChannelTestBase.java

示例5: testViewChangeBecomeKeyserver

import org.jgroups.util.Util; //导入方法依赖的package包/类
public static void testViewChangeBecomeKeyserver() throws Exception {
    // set up the peer
    ENCRYPT encrypt=new ENCRYPT();
    encrypt.init();

    // set in the observer
    encrypt.setLocalAddress(encrypt_addr);
    MockProtocol observer=new MockProtocol();
    encrypt.setUpProtocol(observer);

    // produce encrypted message
    Cipher cipher=encrypt.getSymEncodingCipher();

    MessageDigest digest=MessageDigest.getInstance("MD5");
    digest.reset();
    digest.update(encrypt.getDesKey().getEncoded());

    byte[] symVersion=digest.digest();
    encrypt.keyServer=false;
    Message msg=new Message().setBuffer(cipher.doFinal("hello".getBytes()))
      .putHeader(ENCRYPT_ID, new EncryptHeader(EncryptHeader.ENCRYPT, symVersion));

    encrypt.up(new Event(Event.MSG, msg));

    // assert that message is queued as we have no key
    Util.assertTrue(observer.upMessages.isEmpty());

    // send a view change to trigger the become key server
    // we use the fact that our address is now the controller one
    View tempView=View.create(encrypt_addr,1,encrypt_addr);
    Event event=new Event(Event.VIEW_CHANGE, tempView);
    // this should have changed us to the key server
    encrypt.up(event);

    // send another encrypted message
    Message msg2=new Message().setBuffer(cipher.doFinal("hello2".getBytes()))
      .putHeader(ENCRYPT_ID,new EncryptHeader(EncryptHeader.ENCRYPT,symVersion));

    // we should have three messages now in our observer that are decrypted
    encrypt.up(new Event(Event.MSG, msg2));
    Util.assertEquals(3, observer.upMessages.size());

    Event sent=observer.upMessages.get("message1");
    Util.assertEquals("hello", new String(((Message)sent.getArg()).getBuffer()));

    sent=observer.upMessages.get("message2");
    Util.assertEquals("hello2", new String(((Message)sent.getArg()).getBuffer()));
}
 
开发者ID:zjumty,项目名称:jgroups-3.6.4-fixed,代码行数:49,代码来源:ENCRYPTAsymmetricTest.java


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