// Test Case 6: Password Empty - Error private void profileSetUpPasswordEmpty() throws InterruptedException { profilePage1(); driver.findElement(By.id("nickName")).click(); driver.findElement(By.id("nickName")).clear(); driver.findElement(By.id("nickName")).sendKeys("Neel"); new Select(driver.findElement(By.id("DOBMonth"))).selectByVisibleText("January"); driver.findElement(By.cssSelector("option[value=\"01\"]")).click(); new Select(driver.findElement(By.id("DOBDay"))).selectByVisibleText("04"); driver.findElement(By.cssSelector("#DOBDay > option[value=\"02\"]")).click(); new Select(driver.findElement(By.id("DOBYear"))).selectByVisibleText("1994"); driver.findElement(By.cssSelector("option[value=\"1994\"]")).click(); driver.findElement(By.id("email")).click(); driver.findElement(By.id("email")).clear(); driver.findElement(By.id("email")).sendKeys("*****@*****.**"); driver.findElement(By.id("emailConfirmation")).click(); driver.findElement(By.id("emailConfirmation")).clear(); driver.findElement(By.id("emailConfirmation")).sendKeys("*****@*****.**"); driver.findElement(By.id("password")).click(); driver.findElement(By.id("password")).clear(); Thread.sleep(3000); driver.findElement(By.cssSelector("input.submitButton.green")).click(); Thread.sleep(3000); System.out.println("ERROR: Password Missing"); }
@Test public void testTextLoad() { DataFrame df1 = context .read() .text( Thread.currentThread() .getContextClassLoader() .getResource("text-suite.txt") .toString()); Assert.assertEquals(4L, df1.count()); DataFrame df2 = context .read() .text( Thread.currentThread() .getContextClassLoader() .getResource("text-suite.txt") .toString(), Thread.currentThread() .getContextClassLoader() .getResource("text-suite2.txt") .toString()); Assert.assertEquals(5L, df2.count()); }
/** * Tests the behavior of Zookeeper upon a restart. ZK should clean up old coordinates. * * @throws Exception */ @Test public void testZookeeperRestarts() throws Exception { final CountDownLatch connectedLatch1 = new CountDownLatch(1); final CountDownLatch connectedLatch2 = new CountDownLatch(3); TestCoordinateListener listener = setUpListenerEnvironment(connectedLatch1, connectedLatch2); assertTrue(connectedLatch1.await(20, TimeUnit.SECONDS)); log.info("Killing zookeeper"); forwarder.terminate(); ezk.shutdown(); ezk.del(); ezk.init(); Thread.sleep(2000); forwarder = new PortForwarder(forwarderPort, "127.0.0.1", zkport); int timeoutSecs = 30; while (--timeoutSecs > 0) { Thread.sleep(1000); } Coordinate c = Coordinate.parse("1.service.user.cell"); cn.createCoordinate(c); Thread.sleep(9000); assertEquals( listener.events.get(listener.events.size() - 1), CoordinateListener.Event.COORDINATE_OK); }
// Delete CSR @Test public void Test5() throws Exception { driver.get(baseUrl + "/#/host/magehostmanager.magemojo.com/configuration/ssl"); driver.findElement(By.xpath("//a[contains(text(),'www.Testing5.com')]")).click(); assertEquals( "Download CSR www.Testing5.com", driver.findElement(By.xpath("//legend[4]")).getText()); driver.findElement(By.xpath("(//button[@type='button'])[8]")).click(); assertEquals( "Confirmation Window", driver.findElement(By.cssSelector("h3.modal-title.ng-binding")).getText()); assertTrue(isElementPresent(By.xpath("//div[3]/button[2]"))); driver.findElement(By.xpath("//div[3]/button")).click(); for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if ("Successfully deleted the CSR." .equals(driver.findElement(By.xpath("//div[@id='toast-container']/div")).getText())) break; } catch (Exception e) { } Thread.sleep(1000); } for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (!isElementPresent(By.xpath("//a[contains(text(),'www.Testing5.com')]"))) break; } catch (Exception e) { } Thread.sleep(1000); } }
@Test public void testCoordinateListenerConnectionDiesReconnectAfterTimeout() throws Exception { final CountDownLatch connectedLatch1 = new CountDownLatch(2); final CountDownLatch connectedLatch2 = new CountDownLatch(6); TestCoordinateListener listener = setUpListenerEnvironment(connectedLatch1, connectedLatch2); assertTrue(connectedLatch1.await(20, TimeUnit.SECONDS)); assertEquals( CoordinateListener.Event.COORDINATE_OK, listener.events.get(listener.events.size() - 1)); log.info("Killing connection"); forwarder.terminate(); log.info("Connection down."); Thread.sleep(9000); log.info("Recreating connection soon" + forwarderPort + "->" + zkport); Thread.sleep(1000); assertEquals( CoordinateListener.Event.NO_CONNECTION_TO_STORAGE, listener.events.get(listener.events.size() - 1)); forwarder = new PortForwarder(forwarderPort, "127.0.0.1", zkport); assertTrue(connectedLatch2.await(20, TimeUnit.SECONDS)); for (int c = 0; c < 100; c++) { if (CoordinateListener.Event.COORDINATE_OK == listener.events.get(listener.events.size() - 1)) { break; } Thread.sleep(300); } Thread.sleep(4500); assertEquals( CoordinateListener.Event.COORDINATE_OK, listener.events.get(listener.events.size() - 1)); forwarder.terminate(); }
public void fiveSecondTimeoutAndInterruptible(int timeoutMs) { Thread.interrupted(); try { Thread.sleep(timeoutMs); } catch (InterruptedException e) { interrupted.set(true); } }
public void runTest( final String url, final int urlGroupSize, final ExceptionHandler exceptionHandler, int threadCount) { ok = true; long beginTime = System.currentTimeMillis(); ArrayList<Thread> list = new ArrayList<Thread>(); for (int t = 1; t <= threadCount; t++) { Thread tt = new Thread(url + "_runTest_" + t) { @Override public void run() { boolean useGroup = urlGroupSize > 1; for (int i = 1; i <= urlGroupSize; i++) { if (!ok) return; String resp = null; Throwable t = null; try { if (useGroup) { resp = httpClientUtils.get(url + i); } else { resp = httpClientUtils.get(url); } } catch (Throwable e) { Throwable ee = ExceptionUtils.getRootCause(e); if (ee == null) { ee = e; } Logger.error(this, "", ee); t = ee; } finally { if (ok) { ok = exceptionHandler.handle(t); } } Logger.info(this, "resp[" + i + "]=========[" + resp + "]========="); } } }; list.add(tt); tt.start(); } for (Thread tt : list) { try { tt.join(); } catch (InterruptedException e) { throw new RuntimeException(e); } } Assert.assertTrue(ok); Logger.info(this, "take time milliseconds: " + (System.currentTimeMillis() - beginTime)); }
// *** l'utilisation des données "......" // ** et des données de longeurs de "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" // pour le champ nom // * l'impossibilité de modifier l'id d'un motif de remplacemnt une fois enregistré @Test public void testSSV8VALDEBTA008cIntegrationTests() throws Exception { driver.get(baseUrl + "/selectsystem-view-tomcat-oracle/login.xhtml"); Thread.sleep(1000); findElement(By.id("j_username")).clear(); findElement(By.id("j_username")).sendKeys("usercenter"); Thread.sleep(1000); findElement(By.id("j_password")).clear(); findElement(By.id("j_password")).sendKeys("pwd8888"); findElement(By.cssSelector("#login > img[alt=\"Frensh\"]")).click(); optionalClick(By.xpath("//span/a")); findElement(By.id("form:table:1:sdksds")).click(); findElement(By.xpath("(//img[@alt='English'])[4]")).click(); findElement(By.xpath("(//a[contains(text(),'Card Replacement Motif')])[2]")).click(); new Select(findElement(By.id("globalCardReplacementMotifForm:bank"))) .selectByVisibleText("banque test 3"); Thread.sleep(1000); findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img")) .click(); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys(".........."); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).sendKeys("ReasRp_031"); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img")) .click(); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys("ReasRp_031"); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")) .sendKeys("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn"); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement(By.xpath("//table[@id='globalCardReplacementMotifForm:AZ']/tbody/tr/td/a[3]/img")) .click(); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputIdeee")).sendKeys("ReasRp_033"); Thread.sleep(1000); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).clear(); findElement(By.id("globalCardReplacementMotifForm:inputLabeeee")).sendKeys("ReasRp_033"); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement( By.id( "globalCardReplacementMotifForm:searchCardDesignFeesResultsId:0:scxqsjhvcqjshcvhqsceee")) .click(); findElement(By.cssSelector("img[alt=\"save2\"]")).click(); findElement(By.id("globalCardReplacementMotifForm:fdfdfffffipppipppiiegggeooo")).click(); findElement(By.xpath("(//img[@alt='English'])[2]")).click(); }
@Test public void testOtsi() throws Exception { driver.get(baseUrl + "/"); driver.findElement(By.linkText("Kandidaadid")).click(); // Warning: waitForTextPresent may require manual changes for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")) break; } catch (Exception e) { } Thread.sleep(1000); } driver.findElement(By.id("nimi")).clear(); driver.findElement(By.id("nimi")).sendKeys("Magdalena"); try { assertEquals("Magdalena", driver.findElement(By.id("nimi")).getAttribute("value")); } catch (Error e) { verificationErrors.append(e.toString()); } driver.findElement(By.id("sButton")).click(); // Warning: waitForTextPresent may require manual changes for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Magdalena Malejeva[\\s\\S]*$")) break; } catch (Exception e) { } Thread.sleep(1000); } // Warning: verifyTextNotPresent may require manual changes try { assertFalse( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } }
@Test public void testInterruptTerminalEventAwaitAndUnsubscribe() { TestSubscriber<Integer> ts = TestSubscriber.create(); final Thread t0 = Thread.currentThread(); Worker w = Schedulers.computation().createWorker(); try { w.schedule( new Action0() { @Override public void call() { t0.interrupt(); } }, 200, TimeUnit.MILLISECONDS); ts.awaitTerminalEventAndUnsubscribeOnTimeout(5, TimeUnit.SECONDS); if (!ts.isUnsubscribed()) { fail("Did not unsubscribe!"); } } finally { w.unsubscribe(); } }
@Override public void subscribe(final Subscriber<? super String> observer) { observer.onSubscribe(EmptySubscription.INSTANCE); t = new Thread( new Runnable() { @Override public void run() { for (String s : valuesToReturn) { if (s == null) { System.out.println("throwing exception"); try { Thread.sleep(100); } catch (Throwable e) { } observer.onError(new NullPointerException()); return; } else { observer.onNext(s); } } System.out.println("subscription complete"); observer.onComplete(); } }); t.start(); }
@Test public void testPersistenceTimer2() throws Exception { KieSession service = (KieSession) ctx.getBean("jpaSingleSessionCommandService2"); int sessionId = service.getId(); ProcessInstance processInstance = service.startProcess("org.drools.test.ProcessTimer2"); log.info("Started process instance {}", processInstance.getId()); Thread.sleep(2000); final Environment env = (Environment) ctx.getBean("env"); /* Environment env = KnowledgeBaseFactory.newEnvironment(); env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, ctx.getBean( "myEmf" ) ); env.set( EnvironmentName.TRANSACTION_MANAGER, ctx.getBean( "txManager" ) ); */ KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1"); KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence"); service = kstore.loadKieSession(sessionId, kbase1, null, env); processInstance = service.getProcessInstance(processInstance.getId()); assertNull(processInstance); }
@StartSaga @SagaEventHandler(associationProperty = "myIdentifier") public void handleSomeEvent(SlowStartingEvent event) throws InterruptedException { event.getStartCdl().countDown(); capturedEvents.add(event); Thread.sleep(event.getDuration()); }
public static void main(String[] args) throws IOException { final File socketFile = new File(new File(System.getProperty("java.io.tmpdir")), "junixsocket-test.sock"); AFUNIXServerSocket server = AFUNIXServerSocket.newInstance(); server.bind(new AFUNIXSocketAddress(socketFile)); System.out.println("server: " + server); while (!Thread.interrupted()) { System.out.println("Waiting for connection..."); Socket sock = server.accept(); System.out.println("Connected: " + sock); InputStream is = sock.getInputStream(); OutputStream os = sock.getOutputStream(); System.out.println("Saying hello to client " + os); os.write("Hello, dear Client".getBytes()); os.flush(); byte[] buf = new byte[128]; int read = is.read(buf); System.out.println("Client's response: " + new String(buf, 0, read)); os.close(); is.close(); sock.close(); } }
@Test public void testObserveOnWithSlowConsumer() { int NUM = (int) (Observable.bufferSize() * 0.2); AtomicInteger c = new AtomicInteger(); TestSubscriber<Integer> ts = new TestSubscriber<>(); incrementingIntegers(c) .observeOn(Schedulers.computation()) .map( i -> { try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); } return i; }) .take(NUM) .subscribe(ts); ts.awaitTerminalEvent(); ts.assertNoErrors(); System.out.println( "testObserveOnWithSlowConsumer => Received: " + ts.valueCount() + " Emitted: " + c.get()); assertEquals(NUM, ts.valueCount()); assertTrue(c.get() < Observable.bufferSize() * 2); }
@Test(timeout = 2000) public void testFirehoseFailsAsExpected() { AtomicInteger c = new AtomicInteger(); TestSubscriber<Integer> ts = new TestSubscriber<>(); firehose(c) .observeOn(Schedulers.computation()) .map( v -> { try { Thread.sleep(10); } catch (Exception e) { e.printStackTrace(); } return v; }) .subscribe(ts); ts.awaitTerminalEvent(); System.out.println( "testFirehoseFailsAsExpected => Received: " + ts.valueCount() + " Emitted: " + c.get()); // FIXME it is possible slow is not slow enough or the main gets delayed and thus more than one // source value is emitted. int vc = ts.valueCount(); assertTrue("10 < " + vc, vc <= 10); ts.assertError(MissingBackpressureException.class); }
@Test public void testLoginToCamcast() throws Exception { driver.get(DataServiceProperties.APPURL); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*User name[\\s\\S]*$")); Thread.sleep(1000); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Password[\\s\\S]*$")); userLogin.UserLoginCredentials(driver); // userLogin.ChangePassword(driver); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Sign out[\\s\\S]*$")); driver.findElement(By.linkText("Sign out")).click(); }
@Test public void testInterruptTerminalEventAwaitTimed() { TestSubscriber<Integer> ts = TestSubscriber.create(); final Thread t0 = Thread.currentThread(); Worker w = Schedulers.computation().createWorker(); try { w.schedule( new Action0() { @Override public void call() { t0.interrupt(); } }, 200, TimeUnit.MILLISECONDS); try { ts.awaitTerminalEvent(5, TimeUnit.SECONDS); fail("Did not interrupt wait!"); } catch (RuntimeException ex) { if (!(ex.getCause() instanceof InterruptedException)) { fail("The cause is not InterruptedException! " + ex.getCause()); } } } finally { w.unsubscribe(); } }
private static void waitAQuarterSecond() { try { Thread.sleep(250); } catch (InterruptedException e) { e.printStackTrace(); } }
private void AreaOfStudy() throws IOException, InterruptedException { // Click Area of School driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Area of Study\")]")) .click(); // Select One Area Study new Select(driver.findElement(By.id("edit-area-of-study-parent"))) .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies"); // Wait For Another Select List To Load Thread.sleep(5000); // Select Subareas of Study new Select(driver.findElement(By.xpath("//div[@id='child-area-of-study-wrapper']//select"))) .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies, Other"); // Click Apply driver.findElement(By.id("edit-area-of-study-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
@Test public void testCircularRouteDetection() throws Exception { String wildcardConfiguration = "{" + "\"nats_to_redis_map\" : [" + "{" + "\"subject\" : \"foo\"," + "\"channel\" : \"NATS\"" + "}" + "]," + "\"redis_to_nats_map\" : [" + "{" + "\"channel\" : \"NATS\"," + "\"subject\" : \"foo\"" + "}" + "]" + "}"; System.setProperty(RedisPubSubPlugin.CONFIG_URL, generateContentFile(wildcardConfiguration)); Connector c = new Connector(); ExecutorService executor = Executors.newFixedThreadPool(1); executor.execute(c); Thread.sleep(1000); c.shutdown(); // TODO - check logs for circular route message. }
@Test public void testCreateBroker() { System.out.println("testCreateBroker"); Platform.runLater( new Runnable() { @Override public void run() { synchronized (lock) { // Setup act = new ChildActivity(); act.setScene(new HBox()); Response response = new Response(); response.setStatus(Status.OK); response.setActivity(act); browser.getBrowserPanel().receiveResponse(response); } } }); try { Thread.sleep(100); } catch (InterruptedException ex) { ex.printStackTrace(); } synchronized (lock) { assertNotNull(act.createBroker()); } }
@Test public void testRedisToNats() throws Exception { System.clearProperty(RedisPubSubPlugin.CONFIG_URL); Connector c = new Connector(); ExecutorService executor = Executors.newFixedThreadPool(6); RedisPublisher rp = new RedisPublisher("rp", "Export_NATS", 5); NatsSubscriber ns = new NatsSubscriber("ns", "Import.Redis", 5); // start the connector executor.execute(c); // start the subsciber app executor.execute(ns); // wait for subscriber to be ready. ns.waitUntilReady(); // let the connector start Thread.sleep(2000); // start the publisher executor.execute(rp); // wait for the subscriber to complete. ns.waitForCompletion(); Assert.assertTrue("Invalid count", ns.getMessageCount() == 5); c.shutdown(); }
@Test public void testSendAndReceive() throws Exception { // Run the main controller ControllerRunner controllerRunner = new ControllerRunner(10, 9090, InetAddress.getLocalHost(), "127.0.0.1", 8008); controllerRunner.run(); System.out.println("Controller running"); Random random = new Random(); int player = random.nextInt(); // Connect a new controller and send test alarm Controller controller = new Controller(10); Socket connection1 = controller.connectTo(InetAddress.getLocalHost().getHostAddress(), 9090); Alarm alarm = new Alarm(player, System.currentTimeMillis(), new PlayerCause(player)); controller.send(alarm, connection1); Controller controller2 = new Controller(10); Socket connection2 = controller2.connectTo(InetAddress.getLocalHost().getHostAddress(), 9090); long alarmtime = System.currentTimeMillis() + 500; Position position1 = new Position(player, System.currentTimeMillis(), 1, 2, 3); Position position2 = new Position(player, alarmtime, 100, 200, 300); controller2.send(position1, connection2); controller2.send(position2, connection2); controller2.send(new Request(player, DataType.ACCEL, -1, -1), connection2); controller2.send(new Request(player, DataType.POS, -1, -1), connection2); Thread.sleep(15000); List<Sendable> received = controller2.receive(connection2); List<Alarm> alarms = new ArrayList<Alarm>(); List<Acceleration> accelerations = new ArrayList<Acceleration>(); List<Position> positions = new ArrayList<Position>(); // Distribute the sendable objects for (Sendable sendable : received) { if (sendable instanceof Alarm) { alarms.add((Alarm) sendable); } else if (sendable instanceof Service) { Service service = (Service) sendable; List<?> data = service.getData(); for (Object o : data) { if (o instanceof Acceleration) { accelerations.add((Acceleration) o); } else if (o instanceof Position) { positions.add((Position) o); } } } } controller.disconnectFromClient(connection1); controller2.disconnectFromClient(connection2); assertTrue("Alarm was not sent from controller", alarms.size() >= 1); assertTrue("Acceleration not received from controller", accelerations.size() >= 1); assertTrue("Position 1 not contained in received positions", positions.contains(position1)); assertTrue("Position 2 not contained in received positions", positions.contains(position2)); }
@Test public void testPersistenceTimer() throws Exception { System.out.println("TMPDIR == " + TMPDIR); log.info("---> get bean jpaSingleSessionCommandService2"); KieSession service = (KieSession) ctx.getBean("jpaSingleSessionCommandService2"); int sessionId = service.getId(); log.info("---> created SingleSessionCommandService id: " + sessionId); ProcessInstance processInstance = service.startProcess("org.drools.test.ProcessTimer"); long procId = processInstance.getId(); log.info("---> Started ProcessTimer id: {}", procId); service.dispose(); log.info("---> session disposed"); final Environment env = (Environment) ctx.getBean("env"); /* Environment env = KnowledgeBaseFactory.newEnvironment(); env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, ctx.getBean( "myEmf" ) ); env.set( EnvironmentName.TRANSACTION_MANAGER, ctx.getBean( "txManager" ) ); */ KieStoreServices kstore = (KieStoreServices) ctx.getBean("kstore1"); KieBase kbase1 = (KieBase) ctx.getBean("kb_persistence"); service = kstore.loadKieSession(sessionId, kbase1, null, env); log.info("---> load session: " + sessionId); processInstance = service.getProcessInstance(procId); log.info("---> GetProcessInstanceCommand id: " + procId); assertNotNull(processInstance); Thread.sleep(1000); log.info("---> session disposed"); service.dispose(); service = kstore.loadKieSession(sessionId, kbase1, null, env); log.info("---> load session: " + sessionId); Thread.sleep(3000); log.info("---> GetProcessInstanceCommand id: " + procId); processInstance = service.getProcessInstance(procId); log.info("---> session disposed"); assertNull(processInstance); }
@Test( dataProvider = "addNewAgentApplicant", dataProviderClass = applicantDataInternationalNewApplicant.class) public void testEnterDataAddNewApplicant( String loginEmail, String loginPassword, String firstName, String lastName, String birthDay, String birthMonth, String birthYear) throws Exception { // Add new applicant to Agent Thread.sleep(300); // Test case from HERE to CITIZENSHIP will fail if the applicant already exists. driver.findElement(By.id("field-email")).clear(); driver.findElement(By.id("field-email")).sendKeys(loginEmail); Thread.sleep(150); driver.findElement(By.id("field-confirmEmail")).clear(); driver.findElement(By.id("field-confirmEmail")).sendKeys(loginEmail); Thread.sleep(100); driver.findElement(By.id("field-firstName")).clear(); driver.findElement(By.id("field-firstName")).sendKeys(firstName); driver.findElement(By.id("field-lastName")).clear(); driver.findElement(By.id("field-lastName")).sendKeys(lastName); new Select(driver.findElement(By.name("dayOfBirth"))).selectByVisibleText(birthDay); new Select(driver.findElement(By.name("monthOfBirth"))).selectByVisibleText(birthMonth); new Select(driver.findElement(By.name("yearOfBirth"))).selectByVisibleText(birthYear); driver.findElement(By.xpath("//button[@type='submit']")).click(); System.out.println("Applicant = " + loginEmail); Thread.sleep(500); try { assertEquals( "Profile Information", driver.findElement(By.cssSelector("h3.col-xs-12")).getText()); } catch (Error e) { screenShots.takeScreenShot("enterDataAddNewAppl"); verificationErrors.append(e.toString()); } }
@Test public void testNatsSubjectFanIntoRedis() throws Exception { int count = 5; String config = "{" + "\"nats_to_redis_map\" : [" + "{" + "\"subject\" : \"Export.Redis1\"," + "\"channel\" : \"Import_NATS\"" + "}," + "{" + "\"subject\" : \"Export.Redis2\"," + "\"channel\" : \"Import_NATS\"" + "}," + "{" + "\"subject\" : \"Export.Redis3\"," + "\"channel\" : \"Import_NATS\"" + "}" + "]" + "}"; System.setProperty(RedisPubSubPlugin.CONFIG_URL, generateContentFile(config)); Connector c = new Connector(); ExecutorService executor = Executors.newFixedThreadPool(10); NatsPublisher np1 = new NatsPublisher("np1", "Export.Redis1", count); NatsPublisher np2 = new NatsPublisher("np2", "Export.Redis2", count); NatsPublisher np3 = new NatsPublisher("np3", "Export.Redis3", count); RedisSubscriber rs1 = new RedisSubscriber("rs1", "Import_NATS", count * 3); // start the subsciber apps executor.execute(rs1); // wait for subscribers to be ready. rs1.waitUntilReady(); // start the connector executor.execute(c); Thread.sleep(1000); ; // start the publishers executor.execute(np1); executor.execute(np2); executor.execute(np3); // wait for the subscribers to complete. rs1.waitForCompletion(); Assert.assertTrue("Invalid count", rs1.getMessageCount() == (count * 3)); c.shutdown(); }
protected void waitForDelete(String tableName) throws Exception { for (int i = 0; i < MAX_WAIT_ITERATION; i++) { if (!admin.tableExists(tableName)) { return; } Thread.sleep(WAIT_INTERVAL); } Assert.fail(getMethodName() + " failed"); }
@Test public void testSubscribeOnScheduling() { // in a loop for repeating the concurrency in this to increase chance of failure for (int i = 0; i < 100; i++) { int NUM = (int) (RxRingBuffer.SIZE * 2.1); AtomicInteger c = new AtomicInteger(); ConcurrentLinkedQueue<Thread> threads = new ConcurrentLinkedQueue<Thread>(); TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); // observeOn is there to make it async and need backpressure incrementingIntegers(c, threads) .subscribeOn(Schedulers.computation()) .observeOn(Schedulers.computation()) .take(NUM) .subscribe(ts); ts.awaitTerminalEvent(); ts.assertNoErrors(); System.out.println( "testSubscribeOnScheduling => Received: " + ts.getOnNextEvents().size() + " Emitted: " + c.get()); assertEquals(NUM, ts.getOnNextEvents().size()); assertTrue(c.get() < RxRingBuffer.SIZE * 4); Thread first = null; for (Thread t : threads) { System.out.println("testSubscribeOnScheduling => thread: " + t); if (first == null) { first = t; } else { if (!first.equals(t)) { fail("Expected to see the same thread"); } } } System.out.println( "testSubscribeOnScheduling => Number of batch requests seen: " + threads.size()); assertTrue(threads.size() > 1); System.out.println( "-------------------------------------------------------------------------------------------"); } }
private void run( Runnable runnable, int numberOfRequests, final ConcurrentHashMap<String, Boolean> results) throws InterruptedException { Boolean finalResult = true; LOGGER.info("Tests start now!"); final ArrayList<Thread> threads = new ArrayList<>(); for (int i = 0; i < numberOfRequests; i++) { Thread t = new Thread(runnable, "pipeline" + i); threads.add(t); } for (Thread t : threads) { Thread.sleep(1000 * (new Random().nextInt(3) + 1)); t.setUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { LOGGER.error("Exception " + e + " from thread " + t); results.put(t.getName(), false); } }); t.start(); } for (Thread t : threads) { int i = threads.indexOf(t); if (i == (numberOfRequests - 1)) { // takeHeapDump(dumpDir, i); } t.join(); } for (String threadId : results.keySet()) { finalResult = results.get(threadId) && finalResult; } assertThat(finalResult, is(true)); }