public Object[] getErrors () { return SpaceUtil.inpAll(this, ERROR); } public Object getError () {
/** * @param key * key whose mapping is to be removed from registrar. */ public static void unregister(String key) { SpaceUtil.wipe(sp, key); }
@Test public void testInpAll1() throws Throwable { Space sp = SpaceFactory.getSpace("testSpaceUtilSpaceUri"); SpaceUtil.nextLong(sp, ""); Object[] result = SpaceUtil.inpAll(sp, ""); assertEquals("(TSpace) sp.entries.size()", 0, ((TSpace) sp).entries.size()); assertFalse("(TSpace) sp.entries.containsKey(\"\")", ((TSpace) sp).entries.containsKey("")); assertEquals("result.length", 1, result.length); assertEquals("result[0]", 1L, result[0]); }
@Test public void testNextLongThrowsNullPointerException1() throws Throwable { try { SpaceUtil.nextLong(null, ""); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
@Test public void testConstructor() throws Throwable { new SpaceUtil(); assertTrue("Test completed without Exception", true); }
@Test public void testNextLong() throws Throwable { Space sp = new TSpace(); long result = SpaceUtil.nextLong(sp, ""); assertEquals("(TSpace) sp.entries.size()", 1, ((TSpace) sp).entries.size()); assertEquals("result", 1L, result); }
private void flushInput() { SpaceUtil.wipe(sp,in); }
public void startService () { if (!listenerRegistered) { listenerRegistered = true; // Handle messages that could be in the in queue at start time synchronized (sp) { Object[] pending = SpaceUtil.inpAll(sp, in); sp.addListener (in, this); for (Object o : pending) sp.out(in, o); } } } public void stopService () {
@Test public void testNextLongThrowsNullPointerException() throws Throwable { Space sp = new TSpace(); try { SpaceUtil.nextLong(sp, null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertEquals("ex.getMessage()", "key=null, value=1", ex.getMessage()); assertTrue("(TSpace) sp.isEmpty()", ((TSpace) sp).isEmpty()); } }
private void takeOffline() { SpaceUtil.wipe(sp, ready); }
@Test public void testInpAllThrowsNullPointerException() throws Throwable { try { SpaceUtil.inpAll(null, ""); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } }
private ISOChannel getNextChannel() { ISOChannel c = null; for (int size = channels.length; size > 0; size--) { c = channels[roundRobinCounter++ % channels.length]; if (c != null && c.isConnected()) break; } if (c == null) SpaceUtil.wipe(sp, ready); return c; } private int getConnectedCount() {
@Test public void testInpAll() throws Throwable { Object[] result = SpaceUtil.inpAll(new TSpace(), "testString"); assertEquals("result.length", 0, result.length); }
private void waitForReceiverToExit() { join(receiver); SpaceUtil.wipe(sp, ready); } private void join(Thread thread) {
protected void purge (long id, boolean full) { String stateKey = getKey (STATE, id); String contextKey = getKey (CONTEXT, id); String groupsKey = getKey (GROUPS, id); synchronized (psp) { commitOff (psp); if (full) SpaceUtil.wipe(psp, stateKey); SpaceUtil.wipe(psp, contextKey); SpaceUtil.wipe(psp, groupsKey); commitOn (psp); } }
public static long nextLong (Space sp, Object key) { long l = 0L; synchronized (sp) { Object obj = sp.inp (key); wipe (sp, key); // just in case if (obj instanceof Long) l = (Long) obj; sp.out (key, ++l); } return l; } public static boolean outIfEmpty (Space sp, Object key, Object value, long nrdTimeout, long outTimeout) {
protected void disconnect () { // do not synchronize on this as both Sender and Receiver can deadlock against a thread calling stop() synchronized (disconnectLock) { try { SpaceUtil.wipe(sp, ready); channel.disconnect(); } catch (Exception e) { getLog().warn("disconnect", e); } } } public synchronized void setHost (String host) {
private void disconnect (ISOChannel channel) { try { if (getConnectedCount() <= 1) SpaceUtil.wipe(sp, ready); channel.disconnect (); } catch (IOException e) { getLog().warn ("disconnect", e); } } private void disconnectAll() {
protected void setState (long id, Integer state) { String stateKey = getKey (STATE, id); synchronized (psp) { commitOff (psp); SpaceUtil.wipe(psp, stateKey); if (state!= null) psp.out (stateKey, state); commitOn (psp); } } protected void addGroup (long id, String groupName) {
@Test public void testWipeThrowsNullPointerException() throws Throwable { try { SpaceUtil.wipe(null, ""); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { assertNull("ex.getMessage()", ex.getMessage()); } } }