assertEquals(new String(((Message)sent.getArg()).getBuffer()),"hello2");
assertEquals("hello2", new String(((Message)sent.getArg()).getBuffer()));
	public void testViewChangeBecomeKeyserver() throws Exception{		// set up the peer		ENCRYPT encrypt = new ENCRYPT();		try {			encrypt.init();		} catch (Exception e){			fail(e.getMessage());		}				// set in the observer		MockAddress tempAddress = new MockAddress("encrypt");		encrypt.setLocal_addr(tempAddress);		MockObserver observer = new MockObserver();		encrypt.setObserver(observer);				// produce encrypted message		Cipher cipher = encrypt.getSymEncodingCipher();				MessageDigest digest = MessageDigest.getInstance("MD5");		digest.reset();		digest.update(encrypt.getDesKey().getEncoded());	     		String symVersion = new String(digest.digest(), "UTF-8");				encrypt.keyServer = false;		Message msg = new Message();		msg.setBuffer(cipher.doFinal("hello".getBytes()));		msg.putHeader(EncryptHeader.KEY, new EncryptHeader(				EncryptHeader.ENCRYPT, symVersion));				Event evt = new Event(Event.MSG,msg);		//pass in event to encrypt layer				encrypt.up(evt);				// assert that message is queued as we have no key		assertTrue(observer.getUpMessages().isEmpty());				// send a view change to trigger the become key server		// we use the fact that our address is now the controller one		Vector tempVector = new Vector();		tempVector.add(tempAddress);		View tempView = new View(new ViewId(tempAddress,1),tempVector);		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();		msg2.setBuffer(cipher.doFinal("hello2".getBytes()));		msg2.putHeader(EncryptHeader.KEY, new EncryptHeader(				EncryptHeader.ENCRYPT, symVersion));				// we should have three messages now in our observer		// that are decrypted				Event evt2 = new Event(Event.MSG,msg2);		encrypt.up(evt2);		assertEquals(3,observer.getUpMessages().size());						Event sent = (Event)observer.getUpMessages().get("message1");						assertEquals(new String(((Message)sent.getArg()).getBuffer()),"hello");				sent = (Event)observer.getUpMessages().get("message2");				assertEquals(new String(((Message)sent.getArg()).getBuffer()),"hello2");				}