/** * Verify that information about the fencing target gets passed as * environment variables to the fencer. */ @Test public void testTargetAsEnvironment() { if (!Shell.WINDOWS) { fencer.tryFence(TEST_TARGET, "echo $target_host $target_port"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo $ta...rget_port: dummyhost 1234")); } else { fencer.tryFence(TEST_TARGET, "echo %target_host% %target_port%"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo %ta...get_port%: dummyhost 1234")); } }
/** * Verify that information about the fencing target gets passed as * environment variables to the fencer. */ @Test public void testTargetAsEnvironment() { if (!Shell.WINDOWS) { fencer.tryFence(TEST_TARGET, "echo $target_host $target_port"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo $ta...rget_port: dummyhost 1234")); } else { fencer.tryFence(TEST_TARGET, "echo %target_host% %target_port%"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo %ta...get_port%: dummyhost 1234")); } }
/** * Verify that the Configuration gets passed as * environment variables to the fencer. */ @Test public void testConfAsEnvironment() { if (!Shell.WINDOWS) { fencer.tryFence(TEST_TARGET, "echo $in_fencing_tests"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo $in...ing_tests: yessir")); } else { fencer.tryFence(TEST_TARGET, "echo %in_fencing_tests%"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo %in...ng_tests%: yessir")); } }
/** * Verify that the Configuration gets passed as * environment variables to the fencer. */ @Test public void testConfAsEnvironment() { if (!Shell.WINDOWS) { fencer.tryFence(TEST_TARGET, "echo $in_fencing_tests"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo $in...ing_tests: yessir")); } else { fencer.tryFence(TEST_TARGET, "echo %in_fencing_tests%"); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo %in...ng_tests%: yessir")); } }
/** * Test that lines on stdout get passed as INFO * level messages */ @Test public void testStdoutLogging() { assertTrue(fencer.tryFence(TEST_TARGET, "echo hello")); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo hello: hello")); }
/** * Test that lines on stderr get passed as * WARN level log messages */ @Test public void testStderrLogging() { assertTrue(fencer.tryFence(TEST_TARGET, "echo hello>&2")); Mockito.verify(ShellCommandFencer.LOG).warn( Mockito.endsWith("echo hello>&2: hello")); }
/** * Test that lines on stdout get passed as INFO * level messages */ @Test public void testStdoutLogging() { assertTrue(fencer.tryFence(TEST_TARGET, "echo hello")); Mockito.verify(ShellCommandFencer.LOG).info( Mockito.endsWith("echo hello: hello")); }
@Test public void whenPutAndNamespaceMissingThenSetNamespace() { when(memcachedClient.get(namespaceKey)).thenReturn(null); memcachedCache.put(CACHED_OBJECT_KEY, cachedValue); verify(memcachedClient).get(namespaceKey); verify(memcachedClient).set(eq(namespaceKey), eq(CACHE_EXPIRATION), anyString()); verify(memcachedClient).set(endsWith(CACHED_OBJECT_KEY), eq(CACHE_EXPIRATION), eq(cachedValue)); verify(memcachedClient).touch(namespaceKey, CACHE_EXPIRATION); }
/** * Test that lines on stderr get passed as * WARN level log messages */ @Test public void testStderrLogging() { assertTrue(fencer.tryFence(TEST_TARGET, "echo hello>&2")); Mockito.verify(ShellCommandFencer.LOG).warn( Mockito.endsWith("echo hello>&2: hello")); }
/** * Tests sendClient(). * * Expects: 13132531!CLIENT#Christian:(KouChat v0.9.9-dev null)[134]{Linux}<2222>/4444\ */ @Test public void testSendClientMessage() { final String startsWith = "(" + me.getClient() + ")["; final String middle = ".+\\)\\[\\d+\\]\\{.+"; // like:)[134[{ final String endsWidth = "]{" + me.getOperatingSystem() + "}<2222>/4444\\"; messages.sendClient(); verify(service).sendMessageToAllUsers(startsWith(createMessage("CLIENT") + startsWith)); verify(service).sendMessageToAllUsers(matches(middle)); verify(service).sendMessageToAllUsers(endsWith(endsWidth)); }