@Test @Ignore("hard to test this case...") public void testTryReachQuotaLimitAndWarningExceededLimit() throws Exception { String body = "1 ar 100 100"; // within 1 second sending more messages than default limit 100. for (int i = 0; i < 1000 / 9; i++) { clientPair.appClient.send("hardware " + body, 1); sleep(9); } verify(clientPair.appClient.responseMock, timeout(1000)) .channelRead(any(), eq(new ResponseMessage(1, QUOTA_LIMIT_EXCEPTION))); verify(clientPair.hardwareClient.responseMock, atLeast(100)) .channelRead(any(), eq(produce(1, HARDWARE, b(body)))); clientPair.appClient.reset(); clientPair.hardwareClient.reset(); // waiting to avoid limit. sleep(1000); for (int i = 0; i < 100000 / 9; i++) { clientPair.appClient.send("hardware " + body, 1); sleep(9); } verify(clientPair.appClient.responseMock, timeout(500)) .channelRead(any(), eq(new ResponseMessage(1, QUOTA_LIMIT_EXCEPTION))); verify(clientPair.hardwareClient.responseMock, atLeast(100)) .channelRead(any(), eq(produce(1, HARDWARE, b(body)))); }
@Test public void testTryReachQuotaLimit() throws Exception { String body = "1 aw 100 100"; // within 1 second sending more messages than default limit 100. for (int i = 0; i < 1000 / 9; i++) { clientPair.hardwareClient.send("hardware " + body); sleep(9); } ArgumentCaptor<ResponseMessage> objectArgumentCaptor = ArgumentCaptor.forClass(ResponseMessage.class); verify(clientPair.hardwareClient.responseMock, timeout(1000)) .channelRead(any(), objectArgumentCaptor.capture()); List<ResponseMessage> arguments = objectArgumentCaptor.getAllValues(); ResponseMessage responseMessage = arguments.get(0); assertTrue(responseMessage.id > 100); // at least 100 iterations should be for (int i = 0; i < 100; i++) { verify(clientPair.appClient.responseMock) .channelRead(any(), eq(produce(i + 1, HARDWARE, b("1 " + body)))); } clientPair.appClient.reset(); clientPair.hardwareClient.reset(); // check no more accepted for (int i = 0; i < 10; i++) { clientPair.hardwareClient.send("hardware " + body); sleep(9); } verify(clientPair.hardwareClient.responseMock, times(0)) .channelRead(any(), eq(new ResponseMessage(1, QUOTA_LIMIT_EXCEPTION))); verify(clientPair.appClient.responseMock, times(0)) .channelRead(any(), eq(produce(1, HARDWARE, b(body)))); }
private void testFunction(IValueBinding b) { final boolean isFNW = b.getControl() instanceof FileNameControl; final Text text; if (isFNW) { text = ((FileNameControl) b.getControl()).getTextControl(); } else { text = (Text) b.getControl(); } final IValidatorAdapterManager vam = IValidatorAdapterManager.Factory.getManager(); sleep(VD * 2); assertEquals(myInitValue, text.getText()); assertEquals(0, vam.getUnboundMessages().size()); // TODO }
@Test public void testTimeout() throws InterruptedException { try { // Set the REST session token timeout to one minute setRestSessionTokenTimeout("1"); // Set a password on the admin user setAdminPassword("", AUTH_PASSWORD); // Wait for just over a minute to give the REST session a chance to timeout Thread.sleep(1 * 60 * 1000); // min * sec * mills // Click the home button. We should see the login screen. We do a manual loop // here rather than the base class methods as they assume Ajax navigation. open("/"); for (int seconds = 0; ; seconds++) { if (seconds >= (30)) { fail("The operation timed out waiting for the page to load."); } boolean loginFormIsDisplayed = false; try { loginFormIsDisplayed = isElementPresent("j_username"); } catch (Exception ex) { } if (loginFormIsDisplayed) { break; } sleep(TIMEOUT_CALLBACK_LOOP); } } finally { // Authenticate so the REST call succeeds authenticate(); // Clear password setAdminPassword(AUTH_PASSWORD, ""); // Clear auth credentials client = Client.create(); // Rest token timeout setRestSessionTokenTimeout("30"); } }
@Test public void testSendReadCommandsForLCD() throws Exception { clientPair.appClient.send("hardware 1 vr 0"); clientPair.appClient.send("hardware 1 vr 1"); verify(clientPair.hardwareClient.responseMock, timeout(500).times(2)).channelRead(any(), any()); verify(clientPair.hardwareClient.responseMock, timeout(500)) .channelRead(any(), eq(produce(1, HARDWARE, b("vr 0")))); verify(clientPair.hardwareClient.responseMock, timeout(500)) .channelRead(any(), eq(produce(2, HARDWARE, b("vr 1")))); clientPair.hardwareClient.reset(); clientPair.appClient.send("hardware 1 vr 0"); clientPair.appClient.send("hardware 1 vr 1"); verify(clientPair.hardwareClient.responseMock, after(500).never()).channelRead(any(), any()); sleep(501); clientPair.appClient.send("hardware 1 vr 0"); clientPair.appClient.send("hardware 1 vr 1"); verify(clientPair.hardwareClient.responseMock, timeout(500).times(2)).channelRead(any(), any()); verify(clientPair.hardwareClient.responseMock, timeout(500)) .channelRead(any(), eq(produce(5, HARDWARE, b("vr 0")))); verify(clientPair.hardwareClient.responseMock, timeout(500)) .channelRead(any(), eq(produce(6, HARDWARE, b("vr 1")))); }