public void radioButtonMenuItemClick() throws Throwable { driver = new JavaDriver(); WebElement menu = driver.findElement(By.cssSelector("menu")); AssertJUnit.assertEquals("A Menu", menu.getText()); new Actions(driver).moveToElement(menu).click().perform(); List<WebElement> menuItems = driver.findElements(By.cssSelector("radio-button-menu-item")); int i = menuItems.size(); assertMenuItemClick(menuItems, --i, "Another one (an instance of JRadioButtonMenuItem)\n"); WebElement currRadioButton = menuItems.get(i); AssertJUnit.assertEquals("true", currRadioButton.getAttribute("selected")); new Actions(driver).moveToElement(menu).click().perform(); assertMenuItemClick(menuItems, --i, "A radio button menu item (an instance of JRadioButtonMenuItem)\n"); currRadioButton = menuItems.get(i); new Actions(driver).moveToElement(menu).click().perform(); AssertJUnit.assertEquals("true", currRadioButton.getAttribute("selected")); }
public void columnSelection() throws Throwable { driver = new JavaDriver(); List<WebElement> checkboxes = driver.findElements(By.cssSelector("check-box")); // Setting Column Selection checkboxes.get(1).click(); List<WebElement> radiobuttons = driver.findElements(By.cssSelector("radio-button")); // Setting Single Selection radiobuttons.get(1).click(); WebElement table = driver.findElement(By.cssSelector("table")); int columnCount = new Integer(table.getAttribute("columnCount")); AssertJUnit.assertEquals(5, columnCount); for (int colNum = 0; colNum < columnCount; colNum++) { assertClickOnColumn(table, colNum); } assertShiftClickSingleSelection(table); }
@Test public void testClassificationStreamProcessorExtension6() throws InterruptedException { logger.info("HoeffdingClassifierStreamProcessorExtension TestCase - Incompatible model"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " + "double, attribute_3 double);"; String query = ("@info(name = 'query1') from StreamA#streamingml:hoeffdingTreeClassifier('model1', " + "attribute_0, attribute_1, attribute_2) \n" + "select attribute_0, attribute_1, attribute_2, attribute_3, prediction, confidenceLevel " + "insert into outputStream;"); try { SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(trainingStream + inStreamDefinition + trainingQuery + query); AssertJUnit.fail(); } catch (Exception e) { logger.error(e.getCause().getMessage()); AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException); AssertJUnit.assertTrue(e.getCause().getMessage().contains("Invalid number of feature attributes " + "for streamingml:hoeffdingTreeClassifier. This Stream Processor is defined with " + "4 features, but found 3 feature")); } }
@Test public void select() { @SuppressWarnings("unchecked") ListView<String> listView = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { @SuppressWarnings("unchecked") ChoiceBoxListCell<String> cell = (ChoiceBoxListCell<String>) getCellAt(listView, 3); Point2D point = getPoint(listView, 3); RFXListView rfxListView = new RFXListView(listView, null, point, lr); rfxListView.focusGained(rfxListView); cell.startEdit(); cell.updateItem("Option 3", false); cell.commitEdit("Option 3"); rfxListView.focusLost(rfxListView); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Option 3", recording.getParameters()[0]); }
@Test public void jsonSourceMapperTest15() throws InterruptedException { log.info("test JsonSourceMapper with test json missing attribute"); log = Logger.getLogger(JsonSourceMapper.class); UnitTestAppender appender = new UnitTestAppender(); log.addAppender(appender); String streams = "" + "@App:name('TestSiddhiApp')" + "@source(type='inMemory', topic='stock', @map(type='json')) " + "define stream FooStream (symbol string, price float, volume long); " + "define stream BarStream (symbol string, price float, volume long); "; String query = "" + "from FooStream " + "select * " + "insert into BarStream; "; SiddhiManager siddhiManager = new SiddhiManager(); SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(streams + query); siddhiAppRuntime.start(); InMemoryBroker.publish("stock", "12"); AssertJUnit.assertTrue(appender.getMessages().contains("Json message 12 contains missing attributes")); siddhiAppRuntime.shutdown(); }
public void assertContentDuplicates() throws InterruptedException { siw(new Runnable() { @Override public void run() { combo = (JComboBox) ComponentUtils.findComponent(JComboBox.class, frame); } }); final RComboBox rCombo = new RComboBox(combo, null, null, new LoggingRecorder()); final Object[] content = new Object[] { null }; siw(new Runnable() { @Override public void run() { content[0] = rCombo.getContent(); } }); JSONArray a = new JSONArray(content[0]); AssertJUnit.assertEquals("[[\"Phillip\",\"Larry\",\"Lisa\",\"James\",\"Larry(1)\"]]", a.toString()); }
public void sendKeysKeyboardMap() throws Throwable { if (System.getProperty("java.version", "").matches("1.7.*") && isRobot()) { throw new SkipException("Fails on Java 1.7, looks like some problem with Robot in 1.7"); } kss.clear(); driver.sendKeys(textField, "A"); new WaitWithoutException("Waiting for the keypress") { @Override public boolean until() { try { return kss.toString().contains(KeyStroke.getKeyStroke("released SHIFT").toString()); } catch (Throwable t) { return false; } } }; List<KeyStroke> expected = Arrays.asList(KeyStroke.getKeyStroke("shift pressed SHIFT"), KeyStroke.getKeyStroke("shift pressed A"), KeyStroke.getKeyStroke("shift typed A"), KeyStroke.getKeyStroke("shift released A"), KeyStroke.getKeyStroke("released SHIFT")); AssertJUnit.assertEquals(expected.toString(), kss.toString()); }
public void nextTokenOperators() throws Throwable { SelectorLexer selectorLexer = new SelectorLexer(">+~=^=$=*="); Token nextToken; nextToken = selectorLexer.nextToken(); AssertJUnit.assertEquals(TokenType.TT_GREATER, nextToken.getType()); nextToken = selectorLexer.nextToken(); AssertJUnit.assertEquals(TokenType.TT_PLUS, nextToken.getType()); nextToken = selectorLexer.nextToken(); AssertJUnit.assertEquals(TokenType.TT_TILDE, nextToken.getType()); nextToken = selectorLexer.nextToken(); AssertJUnit.assertEquals(TokenType.TT_EQUALS, nextToken.getType()); nextToken = selectorLexer.nextToken(); AssertJUnit.assertEquals(TokenType.TT_PREFIXMATCH, nextToken.getType()); nextToken = selectorLexer.nextToken(); AssertJUnit.assertEquals(TokenType.TT_SUFFIXMATCH, nextToken.getType()); nextToken = selectorLexer.nextToken(); AssertJUnit.assertEquals(TokenType.TT_SUBSTRINGMATCH, nextToken.getType()); }
void getAttributes() throws Throwable { driver = new JavaDriver(); List<WebElement> radioButtons = driver.findElements(By.cssSelector("radio-button")); AssertJUnit.assertEquals(5, radioButtons.size()); AssertJUnit.assertEquals("Bird", radioButtons.get(0).getAttribute("buttonText")); AssertJUnit.assertEquals("true", radioButtons.get(0).getAttribute("selected")); AssertJUnit.assertEquals("Cat", radioButtons.get(1).getAttribute("buttonText")); AssertJUnit.assertEquals("false", radioButtons.get(1).getAttribute("selected")); radioButtons.get(1).click(); AssertJUnit.assertEquals("false", radioButtons.get(0).getAttribute("selected")); AssertJUnit.assertEquals("true", radioButtons.get(1).getAttribute("selected")); AssertJUnit.assertEquals("false", radioButtons.get(2).getAttribute("selected")); AssertJUnit.assertEquals("false", radioButtons.get(3).getAttribute("selected")); AssertJUnit.assertEquals("false", radioButtons.get(4).getAttribute("selected")); AssertJUnit.assertEquals("Pig", radioButtons.get(4).getAttribute("actionCommand")); }
public void getCellEditor() throws Throwable { driver = new JavaDriver(); WebElement cell = driver.findElement(By.cssSelector("table::mnth-cell(1,2)::editor")); AssertJUnit.assertEquals("button", cell.getTagName()); cell.click(); driver.switchTo().window("Pick a Color"); WebElement tab = driver.findElement(By.cssSelector("tabbed-pane::all-tabs[text='RGB']")); tab.click(); WebElement tabcomponent = driver.findElement(By.cssSelector("tabbed-pane::all-tabs[text='RGB']::component")); List<WebElement> spinners = tabcomponent.findElements(By.cssSelector("spinner")); List<WebElement> all = spinners.get(0).findElements(By.cssSelector("*")); List<String> s = new ArrayList<String>(); for (WebElement webElement : all) { s.add(webElement.getTagName()); } WebElement tf = spinners.get(0).findElement(By.cssSelector("formatted-text-field")); tf.clear(); tf.sendKeys("234", Keys.TAB); driver.findElement(By.cssSelector("button[text='OK']")).click(); }
public void clickWithNativeEvents() throws Throwable { DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("nativeEvents", true); driver = new JavaDriver(new JavaProfile(), caps, caps); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.setLocationRelativeTo(null); frame.setVisible(true); } }); WebElement element1 = driver.findElement(By.name("click-me")); element1.click(); AssertJUnit.assertTrue(buttonClicked); buttonClicked = false; new Actions(driver).click().perform(); AssertJUnit.assertTrue(buttonClicked); AssertJUnit.assertTrue(buttonMouseActions.toString().contains("clicked(1)")); buttonMouseActions.setLength(0); new Actions(driver).contextClick().perform(); AssertJUnit.assertTrue(buttonMouseActions.toString(), buttonMouseActions.toString().contains("pressed(3-popup)") || buttonMouseActions.toString().contains("released(3-popup)")); }
public void click() throws Throwable { driver = new JavaDriver(); List<WebElement> buttons = driver.findElements(By.cssSelector("button")); AssertJUnit.assertEquals(3, buttons.size()); WebElement b1 = buttons.get(0); AssertJUnit.assertEquals("<html><center><b><u>D</u>isable</b><br><font color=#ffffdd>middle button</font>", b1.getText()); WebElement b2 = buttons.get(1); AssertJUnit.assertEquals("middle button", b2.getText()); WebElement b3 = buttons.get(2); AssertJUnit.assertEquals("<html><center><b><u>E</u>nable</b><br><font color=#ffffdd>middle button</font>", b3.getText()); AssertJUnit.assertEquals("true", b1.getAttribute("enabled")); AssertJUnit.assertEquals("true", b2.getAttribute("enabled")); AssertJUnit.assertEquals("false", b3.getAttribute("enabled")); b1.click(); AssertJUnit.assertEquals("false", b1.getAttribute("enabled")); AssertJUnit.assertEquals("false", b2.getAttribute("enabled")); AssertJUnit.assertEquals("true", b3.getAttribute("enabled")); }
public void selectForHomeDirFileSelection() throws Throwable { IJavaElement button = driver.findElementByTagName("button"); button.click(); new DeviceTest.WaitWithoutException("Waiting for the window to open") { @Override public boolean until() { try { driver.switchTo().window("Open"); return true; } catch (Throwable t) { } return false; } }; driver.switchTo().window("Open"); IJavaElement fc = driver.findElementByTagName("file-chooser"); File file = new File(System.getProperty("user.home")); marathon_select(fc, file.getAbsolutePath()); String attribute = fc.getAttribute("selectedFile"); AssertJUnit.assertEquals(file.getAbsoluteFile().toString(), attribute); }
@Test public void testHoeffdingClassifierLearningExtension4() throws InterruptedException { logger.info("HoeffdingClassifierUpdaterStreamProcessorExtension TestCase - Label is not of type string or " + "bool"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " + "double, attribute_3 double, attribute_4 int );"; String query = ("@info(name = 'query1') from StreamA#streamingml:updateHoeffdingTree('model1', 3, " + "attribute_0, attribute_1 , attribute_2 ,attribute_3,attribute_4) select attribute_0, " + "attribute_1, attribute_2, attribute_3, accuracy insert into" + " outputStream;"); try { SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query); } catch (Exception e) { logger.error(e.getCause().getMessage()); AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException); AssertJUnit.assertTrue(e.getCause().getMessage().contains("[label attribute] in 6 th index of " + "classifierUpdate should be either a BOOL or a STRING but found INT")); } }
@Test public void select() { @SuppressWarnings("unchecked") ListView<String> listView = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { @SuppressWarnings("unchecked") ComboBoxListCell<String> cell = (ComboBoxListCell<String>) getCellAt(listView, 3); Point2D point = getPoint(listView, 3); RFXListView rfxListView = new RFXListView(listView, null, point, lr); rfxListView.focusGained(rfxListView); cell.startEdit(); cell.updateItem("Option 3", false); cell.commitEdit("Option 3"); rfxListView.focusLost(rfxListView); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Option 3", recording.getParameters()[0]); }
public void sendKeys() throws Throwable { driver = new JavaDriver(); List<WebElement> buttons = driver.findElements(By.cssSelector("button")); AssertJUnit.assertEquals(3, buttons.size()); WebElement b1 = buttons.get(0); AssertJUnit.assertEquals("Disable middle button", b1.getText()); WebElement b2 = buttons.get(1); AssertJUnit.assertEquals("Middle button", b2.getText()); WebElement b3 = buttons.get(2); AssertJUnit.assertEquals("Enable middle button", b3.getText()); AssertJUnit.assertEquals("true", b1.getAttribute("enabled")); AssertJUnit.assertEquals("true", b2.getAttribute("enabled")); AssertJUnit.assertEquals("false", b3.getAttribute("enabled")); b1.sendKeys(Keys.SPACE); AssertJUnit.assertEquals("false", b1.getAttribute("enabled")); AssertJUnit.assertEquals("false", b2.getAttribute("enabled")); AssertJUnit.assertEquals("true", b3.getAttribute("enabled")); }
@Test public void selectAllRows() { TreeTableView<?> treeTableView = (TreeTableView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-table-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); RFXTreeTableView rfxTreeTableView = new RFXTreeTableView(treeTableView, null, null, lr); int count = treeTableView.getExpandedItemCount(); for (int i = 0; i < count; i++) { treeTableView.getSelectionModel().select(i); } rfxTreeTableView.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("all", recording.getParameters()[0]); }
public void multpleNodesSelected() throws Throwable, InvocationTargetException { final JTree tree = (JTree) ComponentUtils.findComponent(JTree.class, frame); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); siw(new Runnable() { @Override public void run() { tree.expandRow(0); tree.setSelectionRows(new int[] { 0, 2 }); } }); final LoggingRecorder lr = new LoggingRecorder(); siw(new Runnable() { @Override public void run() { RTree rTree = new RTree(tree, null, null, lr); rTree.focusLost(null); } }); Call call = lr.getCall(); AssertJUnit.assertEquals("select", call.getFunction()); AssertJUnit.assertEquals("[/Root Node, /Root Node/Parent 2]", call.getState()); }
@Test public void testClusTree2D_4() throws Exception { logger.info("ClusTreeStreamProcessorExtension Test - Test case to validate maxIterations to be constant"); SiddhiManager siddhiManager = new SiddhiManager(); String inputStream = "define stream InputStream (x double, y double, maxIterations int);"; String query = ( "@info(name = 'query1') " + "from InputStream#streamingml:clusTree(2, maxIterations, 20, 5, 50, x, y) " + "select closestCentroidCoordinate1, closestCentroidCoordinate2, x, y " + "insert into OutputStream;"); try { SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inputStream + query); } catch (Exception e) { logger.info("Error caught"); AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException); AssertJUnit.assertTrue(e.getCause().getMessage().contains("Maximum iterations has to be a constant but " + "found org.wso2.siddhi.core.executor.VariableExpressionExecutor")); } }
public void selectTabWithMultipleDuplicates() { siw(new Runnable() { @Override public void run() { JTabbedPane tp = (JTabbedPane) ComponentUtils.findComponent(JTabbedPane.class, frame); tp.addTab("Tab 2", icon, makeTextPanel("Panel #5"), "is a duplicate"); tp.addTab("Tab 2", icon, makeTextPanel("Panel #6"), "is a duplicate"); } }); IJavaElement tabbedPane = driver.findElementByTagName("tabbed-pane"); IJavaElement tab1 = tabbedPane.findElementByCssSelector(".::nth-tab(2)"); tab1.click(); AssertJUnit.assertEquals("1", tabbedPane.getAttribute("selectedIndex")); AssertJUnit.assertEquals("Tab 2", tab1.getText()); IJavaElement tab2 = tabbedPane.findElementByCssSelector(".::nth-tab(5)"); tab2.click(); AssertJUnit.assertEquals("4", tabbedPane.getAttribute("selectedIndex")); AssertJUnit.assertEquals("Tab 2(1)", tab2.getText()); IJavaElement tab3 = tabbedPane.findElementByCssSelector(".::nth-tab(6)"); tab3.click(); AssertJUnit.assertEquals("5", tabbedPane.getAttribute("selectedIndex")); AssertJUnit.assertEquals("Tab 2(2)", tab3.getText()); }
public void expandTree() throws Throwable { WebElement tree = page.getTree(); tree.click(); WebElement root = tree.findElement(By.cssSelector(".::nth-node(1)")); AssertJUnit.assertEquals("false", root.getAttribute("expanded")); AssertJUnit.assertEquals(1 + "", tree.getAttribute("rowCount")); new Actions(driver).doubleClick(root).perform(); new WebDriverWait(driver, 3).until(hasAttributeValue(root, "expanded", "true")); AssertJUnit.assertEquals("true", root.getAttribute("expanded")); AssertJUnit.assertEquals(3 + "", tree.getAttribute("rowCount")); WebElement node1 = tree.findElement(By.cssSelector(".::nth-node(2)")); AssertJUnit.assertEquals("Parent 1", node1.getText()); new Actions(driver).doubleClick(node1).perform(); WebElement node2 = tree.findElement(By.cssSelector(".::nth-node(3)")); AssertJUnit.assertEquals("Child 1", node2.getText()); WebElement node3 = tree.findElement(By.cssSelector(".::nth-node(4)")); AssertJUnit.assertEquals("Child 2", node3.getText()); WebElement node4 = tree.findElement(By.cssSelector(".::nth-node(5)")); AssertJUnit.assertEquals("Parent 2", node4.getText()); new Actions(driver).doubleClick(node4).perform(); WebElement node5 = tree.findElement(By.cssSelector(".::nth-node(6)")); AssertJUnit.assertEquals("Child 1", node5.getText()); WebElement node6 = tree.findElement(By.cssSelector(".::nth-node(7)")); AssertJUnit.assertEquals("Child 2", node6.getText()); }
public void clickItem() throws Throwable { driver = new JavaDriver(); String[] patternExamples = { "Bird", "Cat", "Dog", "Rabbit", "Pig" }; WebElement combo = driver.findElement(By.cssSelector("combo-box")); AssertJUnit.assertEquals("" + 4, combo.getAttribute("selectedIndex")); WebElement option; for (int i = 0; i < patternExamples.length; i++) { option = driver.findElement(By.cssSelector("combo-box::nth-option(" + (i + 1) + ")")); option.click(); AssertJUnit.assertEquals("" + i, combo.getAttribute("selectedIndex")); } for (int i = patternExamples.length - 1; i >= 0; i--) { option = driver.findElement(By.cssSelector("combo-box::nth-option(" + (i + 1) + ")")); option.click(); AssertJUnit.assertEquals("" + i, combo.getAttribute("selectedIndex")); } }
@Test public void testUpdateUpdateRegressionLearningStreamProcessorExtension7() throws InterruptedException { logger.info("UpdateUpdateRegressionLearningStreamProcessorExtension TestCase " + "- Features are of un-supported type"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " + "double, attribute_3 String, attribute_4 double );"; String query = ("@info(name = 'query1') from StreamA#streamingml:updateAMRulesRegressor('model1', " + "attribute_0, attribute_1 , attribute_2 ,attribute_3,attribute_4) select attribute_0, " + " attribute_1, attribute_2, attribute_3, meanSquaredError insert into outputStream;"); try { SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query); } catch (Exception e) { logger.error(e.getCause().getMessage()); AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException); AssertJUnit.assertTrue(e.getCause().getMessage().contains("model.features in 5th parameter is not " + "a numerical type attribute. Found STRING. Check the input stream definition.")); } }
@Test public void testRegressionStreamProcessorExtension11() throws InterruptedException { logger.info("RegressionLearningStreamProcessorExtension TestCase " + "- configure an AMRules Regressor mode with non existing stream"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " + "double, attribute_3 int, attribute_4 double );"; String query = ("@info(name = 'query1') from StreamA#streamingml:AMRulesRegressor('ml', attribute_5 ) " + "select att_0 as attribute_0, " + "att_1 as attribute_1,att_2 as attribute_2,att_3 as attribute_3, accuracy insert into" + " outputStream;"); try { SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query); } catch (Exception e) { logger.error(e.getMessage()); AssertJUnit.assertTrue(e instanceof AttributeNotExistException); AssertJUnit.assertTrue(e.getMessage().contains("Cannot find attribute type as 'attribute_5' " + "does not exist in 'StreamA'")); } }
public void getWindowHandles() throws Throwable { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { d2 = new JDialog(frame, false); d2.setTitle("My Dialog 2"); d2.pack(); d2.setVisible(true); } }); Collection<String> windowHandles = driver.getWindowHandles(); AssertJUnit.assertEquals(2, windowHandles.size()); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { d2.dispose(); } }); }
@Test public void getText() throws Throwable { Slider slider = (Slider) getPrimaryStage().getScene().getRoot().lookup(".slider"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); Platform.runLater(new Runnable() { @Override public void run() { slider.setValue(25.0); RFXSlider rfxSlider = new RFXSlider(slider, null, null, lr); rfxSlider.focusLost(null); text.add(rfxSlider.getAttribute("text")); } }); new Wait("Waiting for slider text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("25.0", text.get(0)); }
public void sendKeys() throws Throwable { driver = new JavaDriver(); List<WebElement> checkBoxes = driver.findElements(By.cssSelector("check-box")); AssertJUnit.assertEquals(4, checkBoxes.size()); WebElement chkbox1 = checkBoxes.get(0); AssertJUnit.assertEquals("Chin", chkbox1.getAttribute("buttonText")); WebElement chkbox2 = checkBoxes.get(1); AssertJUnit.assertEquals("Glasses", chkbox2.getAttribute("buttonText")); WebElement chkbox3 = checkBoxes.get(2); AssertJUnit.assertEquals("Hair", chkbox3.getAttribute("buttonText")); WebElement chkbox4 = checkBoxes.get(3); AssertJUnit.assertEquals("Teeth", chkbox4.getAttribute("buttonText")); AssertJUnit.assertEquals("true", chkbox1.getAttribute("selected")); AssertJUnit.assertEquals("true", chkbox2.getAttribute("selected")); AssertJUnit.assertEquals("true", chkbox3.getAttribute("selected")); AssertJUnit.assertEquals("true", chkbox4.getAttribute("selected")); chkbox3.sendKeys(Keys.SPACE); AssertJUnit.assertEquals("true", chkbox1.getAttribute("selected")); AssertJUnit.assertEquals("true", chkbox2.getAttribute("selected")); AssertJUnit.assertEquals("false", chkbox3.getAttribute("selected")); AssertJUnit.assertEquals("true", chkbox4.getAttribute("selected")); }
@Test public void htmlOptionSelect() { @SuppressWarnings("unchecked") ChoiceBox<String> choiceBox = (ChoiceBox<String>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); String text = "This is a test text"; final String htmlText = "<html><font color=\"RED\"><h1><This is also content>" + text + "</h1></html>"; Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getItems().add(htmlText); choiceBox.getSelectionModel().select(htmlText); rfxChoiceBox.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals(text, recording.getParameters()[0]); }
public void tabUseAsContainer() throws Throwable { driver = new JavaDriver(); List<WebElement> tabs = driver.findElements(By.cssSelector("tabbed-pane::nth-tab(1)")); AssertJUnit.assertEquals(1, tabs.size()); AssertJUnit.assertEquals("Tab 1", tabs.get(0).getText()); List<WebElement> panels = driver.findElements(By.cssSelector("tabbed-pane::nth-tab(1)::component")); panels = tabs.get(0).findElements(By.cssSelector(".::component")); AssertJUnit.assertEquals(1, panels.size()); AssertJUnit.assertEquals("panel", panels.get(0).getTagName()); List<WebElement> labels = panels.get(0).findElements(By.cssSelector("label")); AssertJUnit.assertEquals(1, labels.size()); AssertJUnit.assertEquals("Panel #1", labels.get(0).getText()); panels = driver.findElements(By.cssSelector("tabbed-pane::nth-tab(2)::component")); AssertJUnit.assertEquals(1, panels.size()); AssertJUnit.assertEquals("panel", panels.get(0).getTagName()); labels = panels.get(0).findElements(By.cssSelector("label")); AssertJUnit.assertEquals(1, labels.size()); AssertJUnit.assertEquals("Panel #2", labels.get(0).getText()); }
public void altContextClick() { try { buttonClicked = false; EventQueueWait.requestFocus(button); driver.pressKey(button, JavaAgentKeys.ALT); driver.click(button, Buttons.RIGHT, 1, 0, 0); driver.releaseKey(button, JavaAgentKeys.ALT); new DeviceTest.WaitWithoutException("Waiting for events to be processed") { @Override public boolean until() { return buttonClicked; } }; AssertJUnit.assertTrue(buttonClicked); AssertJUnit.assertEquals(MouseEvent.BUTTON3, clickedButton); AssertJUnit.assertFalse(popupTriggerClicked); AssertJUnit.assertTrue(altDown); AssertJUnit.assertFalse(metaDown); AssertJUnit.assertFalse(controlDown); AssertJUnit.assertFalse(shiftDown); AssertJUnit.assertFalse(altGraphDown); AssertJUnit.assertEquals(1, maxClickCount); } finally { Logger.getLogger(DeviceMouseTest.class.getName()).info(mouseText.toString()); moveCursorAway(); } }
@Test public void testUpdateUpdateRegressionLearningStreamProcessorExtension5() throws InterruptedException { logger.info("UpdateUpdateRegressionLearningStreamProcessorExtension TestCase " + "- number of parameters not accepted"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream StreamA (attribute_0 double, attribute_1 double, attribute_2 " + "double, attribute_3 int, attribute_4 double );"; String query = ("@info(name = 'query1') from StreamA#streamingml:updateAMRulesRegressor('model1', 3, " + "attribute_0, attribute_1 , attribute_2 ,attribute_3,attribute_4) select attribute_0, " + "attribute_1, attribute_2, attribute_3, accuracy insert into" + " outputStream;"); try { SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(inStreamDefinition + query); } catch (Exception e) { logger.error(e.getCause().getMessage()); AssertJUnit.assertTrue(e instanceof SiddhiAppCreationException); AssertJUnit.assertTrue(e.getCause().getMessage().contains("Number of hyper-parameters needed for " + "model manual configuration is 5 but found 1")); } }
public void getAttributes() throws Throwable { driver = new JavaDriver(); List<WebElement> labels = driver.findElements(By.cssSelector("label")); AssertJUnit.assertEquals(3, labels.size()); WebElement label = labels.get(0); AssertJUnit.assertEquals("Image and Text", label.getText()); AssertJUnit.assertEquals("0", label.getAttribute("horizontalAlignment")); AssertJUnit.assertEquals("a pretty but meaningless splat", label.getAttribute("icon")); AssertJUnit.assertEquals("22", label.getAttribute("icon.iconHeight")); }
public void findEntryFora() { KeyboardMap kbMap = new KeyboardMap('a'); List<CharSequence[]> keys = kbMap.getKeys(); AssertJUnit.assertEquals(1, keys.size()); CharSequence[] cs = keys.get(0); AssertJUnit.assertEquals(1, cs.length); AssertJUnit.assertEquals("" + KeyEvent.VK_A, cs[0]); }
public void findContainerNP() { List<List<String>> np = config.findContainerNP(Window.class); AssertJUnit.assertEquals(1, np.size()); np = config.findContainerNP(JInternalFrame.class); AssertJUnit.assertEquals(1, np.size()); np = config.findContainerNP(JWindow.class); AssertJUnit.assertEquals(2, np.size()); }
public void keys() throws Throwable { driver = new JavaDriver(); SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { frame.setLocationRelativeTo(null); frame.setVisible(true); textField.requestFocusInWindow(); } }); AssertJUnit.assertEquals("", EventQueueWait.call(textField, "getText")); WebElement element1 = driver.findElement(By.name("text-field")); new Actions(driver).sendKeys(element1, "Hello World").perform(); AssertJUnit.assertEquals("Hello World", EventQueueWait.call(textField, "getText")); }
public void testMouseUp() { mouseText.setLength(0); EventQueueWait.requestFocus(button); driver.buttonDown(button, Buttons.LEFT, 0, 0); driver.buttonUp(button, Buttons.LEFT, 0, 0); final String expected = "Button1+pressed Button1+released"; new WaitWithoutException() { @Override public boolean until() { return expected.equals(mouseText.toString().trim()); } }.wait("Mouse text is empty", 3000, 500); AssertJUnit.assertEquals(expected, mouseText.toString().trim()); }
public void getNthOption() throws Throwable { driver = new JavaDriver(); AssertJUnit.assertEquals(1, driver.findElements(By.cssSelector("combo-box")).size()); AssertJUnit.assertEquals("Bird", driver.findElement(By.cssSelector("combo-box::nth-option(1)")).getText()); AssertJUnit.assertEquals("Cat", driver.findElement(By.cssSelector("combo-box::nth-option(2)")).getText()); AssertJUnit.assertEquals("Dog", driver.findElement(By.cssSelector("combo-box::nth-option(3)")).getText()); AssertJUnit.assertEquals("Rabbit", driver.findElement(By.cssSelector("combo-box::nth-option(4)")).getText()); AssertJUnit.assertEquals("Pig", driver.findElement(By.cssSelector("combo-box::nth-option(5)")).getText()); }
@Test public void getText() { IJavaFXElement spinner = driver.findElementByName("integer-spinner"); List<String> text = new ArrayList<>(); Platform.runLater(() -> { spinner.marathon_select("35"); text.add(spinner.getAttribute("text")); }); new Wait("Waiting for the spinner text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("35", text.get(0)); }
public void testClick() { buttonClicked = false; EventQueueWait.requestFocus(button); driver.click(button, null, null, Buttons.LEFT, 1, 0, 0); new WaitWithoutException() { @Override public boolean until() { return buttonClicked; } }.wait("Button is not clicked", 3000, 500); AssertJUnit.assertEquals(true, buttonClicked); }
@Test public void getText() { List<String> text = new ArrayList<>(); Platform.runLater(() -> { tableView.marathon_select("{\"rows\":[1]}"); text.add(tableView.getAttribute("text")); }); new Wait("Wating for table text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("{\"rows\":[1]}", text.get(0)); }