List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling null .
From source file:com.pentaho.ctools.cdf.MetaLayerHomeDashboard.java
/** * ############################### Test Case 1 ############################### * * Test Case Name://from w w w .jav a 2 s.c o m * MetaLayer Home Dashboard - clicking details * Description: * We pretend to validate when user click on 'Details...' a pop-up message * is displayed. * Steps: * 1. Open the MetaLayer Home Dashboard. * 2. Click in 'Details...'. * 3. Check if we have width = 500 and height = 600 */ @Test public void tc1_LinkDetails_PopupJPivot() { this.log.info("tc1_LinkDetails_PopupJPivot"); /* * ## Step 1 */ driver.get(baseUrl + "api/repos/%3Apublic%3Aplugin-samples%3Apentaho-cdf%3A20-samples%3Ahome_dashboard_2%3Ahome_dashboard_metalayer.xcdf/generatedContent"); //NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); //Wait for title become visible and with value 'Community Dashboard Framework' String titlePage = this.elemHelper.WaitForTitle(driver, "Community Dashboard Framework"); //Wait for visibility of 'Top Ten Customers' String expectedSampleTitle = "Top Ten Customers"; String actualSampleTitle = this.elemHelper.WaitForTextPresence(driver, By.xpath("//div[@id='titleObject']"), expectedSampleTitle); // Validate the sample that we are testing is the one assertEquals(titlePage, "Community Dashboard Framework"); assertEquals(actualSampleTitle, expectedSampleTitle); /* * ## Step 2 */ //Wait for visibility of 'topTenCustomersDetailsObject' the text 'Details' WebElement linkDetails = this.elemHelper.FindElement(driver, By.linkText("Details...")); assertEquals("Details...", linkDetails.getText()); //click on the 'Details...' linkDetails.click(); /* * ## Step 3 */ //Wait for the frame this.elemHelper.WaitForElementPresenceAndVisible(driver, By.id("fancybox-content")); this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//iframe")); WebElement frame = this.elemHelper.FindElement(driver, By.xpath("//iframe")); String valueFrameAttrSrc = frame.getAttribute("src"); ///pentaho/plugin/jpivot/Pivot?solution=system&path=%2Fpublic%2Fplugin-samples%2Fpentaho-cdf%2Factions&action=jpivot.xaction&width=500&height=600 //Check if we have the sizes 500 and 600 assertTrue(StringUtils.containsIgnoreCase(valueFrameAttrSrc, "&width=500&height=600")); //NOTE - we have to wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); //Wait for the element be visible. WebDriver driverFrame = driver.switchTo().frame(frame); assertNotNull(this.elemHelper.FindElement(driverFrame, By.xpath("//div[@id='internal_content']"))); assertEquals("Measures", this.elemHelper.WaitForElementPresentGetText(driverFrame, By.xpath("//div[@id='internal_content']/table/tbody/tr[2]/td[2]/p/table/tbody/tr/th[2]"))); assertEquals("Australian Collectors, Co.", this.elemHelper.WaitForElementPresentGetText(driverFrame, By .xpath("//div[@id='internal_content']/table[1]/tbody/tr[2]/td[2]/p[1]/table/tbody/tr[5]/th/div"))); assertEquals("180,125", this.elemHelper.WaitForElementPresentGetText(driverFrame, By.xpath("//div[@id='internal_content']/table[1]/tbody/tr[2]/td[2]/p[1]/table/tbody/tr[7]/td"))); //Close pop-up driver.switchTo().defaultContent(); wait.until(ExpectedConditions.elementToBeClickable(By.id("fancybox-close"))); String background = this.elemHelper.FindElement(driver, By.cssSelector("#fancybox-close")) .getCssValue("background-image"); String background1 = background.substring(background.indexOf(34) + 1, background.lastIndexOf(34)); assertEquals("http://localhost:8080/pentaho/api/repos/pentaho-cdf/js-legacy/lib/fancybox/fancybox.png", background1); this.elemHelper.FindElement(driver, By.id("fancybox-close")).click(); this.elemHelper.WaitForElementInvisibility(driver, By.id("fancybox-content")); assertEquals("200", Integer.toString(HttpUtils.GetResponseCode(background1, "admin", "password"))); }
From source file:io.cloudslang.content.database.utils.SQLUtils.java
/** * Some databases (Sybase) throw exceptions during a database restore. This function processes that exception, and if it is that type, builds up the output of the command * * @param e The exception to analyze/* w ww . j a v a 2 s .co m*/ * @return The output of the dump command * @throws java.sql.SQLException If it was not a successful load command's exception. */ public static String processLoadException(SQLException e) throws SQLException { final String sqlState = e.getSQLState(); if (sqlState != null && StringUtils.equalsIgnoreCase(sqlState, "s1000")) { SQLException f = e; StringBuilder s = new StringBuilder(); s.append(f.getMessage()); while ((f = f.getNextException()) != null) s.append("\n").append(f.getMessage()); String str = s.toString(); if (StringUtils.containsIgnoreCase(str, "load is complete")) return str; } throw e; }
From source file:com.glaf.oa.purchase.web.springmvc.PurchaseitemController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Purchaseitem purchaseitem = purchaseitemService .getPurchaseitem(RequestUtils.getLong(request, "purchaseitemid")); if (purchaseitem != null) { request.setAttribute("purchaseitem", purchaseitem); JSONObject rowJSON = purchaseitem.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); }/*from ww w. jav a2 s. c o m*/ boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (purchaseitem != null) { } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("purchaseitem.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/purchaseitem/edit", modelMap); }
From source file:com.feilong.core.lang.StringUtilTest.java
/** * Checks if is contain ignore case.// w w w .j a v a2s.c o m */ @Test public void testContainsIgnoreCase() { assertEquals(false, StringUtils.containsIgnoreCase(null, "")); LOGGER.debug(StringUtils.containsIgnoreCase(TEXT, null) + ""); LOGGER.debug(StringUtils.containsIgnoreCase(TEXT, "") + ""); assertEquals(true, StringUtils.containsIgnoreCase(TEXT, "feilong")); assertEquals(false, StringUtils.containsIgnoreCase(TEXT, "feilong1")); assertEquals(true, StringUtils.containsIgnoreCase(TEXT, "feiLong")); assertEquals(true, StringUtils.containsIgnoreCase("jiiiiiinxin.feilong", "Xin")); }
From source file:gobblin.data.management.conversion.hive.query.HiveValidationQueryGenerator.java
/*** * Generates Hive SQL that can be used to validate the quality between two {@link Table}s or optionally * {@link Partition}. The query returned is a basic join query that returns the number of records matched * between the two {@link Table}s./* ww w . j a v a 2 s .co m*/ * The responsibility of actually comparing this value with the expected module should be implemented by * the user. * * @param sourceTable Source Hive {@link Table} name. * @param sourceDb Source Hive database name. * @param targetTable Target Hive {@link Table} name. * @param optionalPartition Optional {@link Partition} to limit the comparison. * @return Query to find number of rows common between two tables. */ public static String generateDataValidationQuery(String sourceTable, String sourceDb, Table targetTable, Optional<Partition> optionalPartition, boolean isNestedORC) { StringBuilder sb = new StringBuilder(); // Query head sb.append("SELECT count(*) FROM `").append(sourceDb).append("`.`").append(sourceTable).append("` s JOIN `") .append(targetTable.getDbName()).append("`.`").append(targetTable.getTableName()) .append("` t ON \n"); // Columns equality boolean isFirst = true; List<FieldSchema> fieldList = targetTable.getSd().getCols(); for (FieldSchema field : fieldList) { // Do not add maps in the join clause. Hive does not support map joins LIHADOOP-21956 if (StringUtils.startsWithIgnoreCase(field.getType(), "map")) { continue; } if (StringUtils.containsIgnoreCase(field.getType(), ":map")) { continue; } if (isFirst) { isFirst = false; } else { sb.append(" AND \n"); } if (isNestedORC) { sb.append("\ts.`").append(field.getName()).append("`<=>"); } else { // The source column lineage information is available in field's comment. Remove the description prefix "from flatten_source" String colName = field.getComment().replaceAll("from flatten_source ", "").trim(); sb.append("\ts.`").append(colName.replaceAll("\\.", "`.`")).append("`<=>"); } sb.append("t.`").append(field.getName()).append("` "); } sb.append("\n"); // Partition projection if (optionalPartition.isPresent()) { Partition partition = optionalPartition.get(); String partitionsInfoString = partition.getName(); List<String> pInfo = Splitter.on(",").omitEmptyStrings().trimResults() .splitToList(partitionsInfoString); for (int i = 0; i < pInfo.size(); i++) { List<String> partitionInfoParts = Splitter.on("=").omitEmptyStrings().trimResults() .splitToList(pInfo.get(i)); if (partitionInfoParts.size() != 2) { throw new IllegalArgumentException(String.format( "Partition details should be of the format partitionName=partitionValue. Recieved: %s", pInfo.get(i))); } if (i == 0) { // add where clause sb.append(" WHERE \n"); } else { sb.append(" AND "); } // add project for source and destination partition sb.append(String.format("s.`%s`='%s' ", partitionInfoParts.get(0), partitionInfoParts.get(1))); sb.append(" AND "); sb.append(String.format("t.`%s`='%s' ", partitionInfoParts.get(0), partitionInfoParts.get(1))); } } return sb.toString(); }
From source file:cgeo.geocaching.connector.oc.OCApiConnector.java
/** * get the OC1234 geocode from an internal cache id, for URLs like host.tld/viewcache.php?cacheid *///from www . j a v a2 s. com @Nullable protected String getGeocodeFromCacheId(final String url, final String host) { final Uri uri = Uri.parse(url); if (!StringUtils.containsIgnoreCase(uri.getHost(), host)) { return null; } // host.tld/viewcache.php?cacheid=cacheid final String id = uri.getPath().startsWith("/viewcache.php") ? uri.getQueryParameter("cacheid") : ""; if (StringUtils.isNotBlank(id)) { final String geocode = Maybe.fromCallable(new Callable<String>() { @Override public String call() throws Exception { final String normalizedUrl = StringUtils.replaceIgnoreCase(url, getShortHost(), getShortHost()); return OkapiClient.getGeocodeByUrl(OCApiConnector.this, normalizedUrl); } }).subscribeOn(AndroidRxUtils.networkScheduler).blockingGet(); if (geocode != null && canHandle(geocode)) { return geocode; } } return null; }
From source file:de.micromata.genome.logging.spi.ifiles.IndexedReader.java
boolean apply(Integer offset, Integer loglevel, String category, String msg, List<Pair<String, String>> logAttributes) throws IOException { String s;//www .j ava 2 s . c om if (loglevel != null) { s = indexHeader.readSearchFromLog(offset, logRandomAccessFile, StdSearchFields.Level.name()); if (s != null) { LogLevel ll = LogLevel.fromString(s, LogLevel.Fatal); if (ll.getLevel() < loglevel) { return false; } } } if (category != null) { s = indexHeader.readSearchFromLog(offset, logRandomAccessFile, StdSearchFields.Category.name()); if (s != null) { if (StringUtils.containsIgnoreCase(s, category) == false) { return false; } } } if (msg != null) { s = indexHeader.readSearchFromLog(offset, logRandomAccessFile, StdSearchFields.ShortMessage.name()); if (s != null) { if (StringUtils.containsIgnoreCase(s, msg) == false) { return false; } } } if (logAttributes == null || logAttributes.isEmpty() == true) { return true; } for (Pair<String, String> attr : logAttributes) { s = indexHeader.readSearchFromLog(offset, logRandomAccessFile, attr.getFirst()); if (StringUtils.containsIgnoreCase(s, attr.getSecond()) == false) { return false; } } return true; }
From source file:com.ibasco.agql.examples.base.BaseExample.java
@SuppressWarnings("unchecked") protected String promptInput(String message, boolean required, String defaultReturnValue, String defaultProperty) { Scanner userInput = new Scanner(System.in); String returnValue;/*from w w w. ja va 2 s.co m*/ //perform some bit of magic to determine if the prompt is a password type boolean inputEmpty, isPassword = StringUtils.containsIgnoreCase(message, "password"); int retryCounter = 0; String defaultValue = defaultReturnValue; //Get value from file (if available) if (!StringUtils.isEmpty(defaultProperty)) { if (isPassword) { try { String defaultProp = getProp(defaultProperty); if (!StringUtils.isEmpty(defaultProp)) defaultValue = decrypt(defaultProp); } catch (Exception e) { throw new AsyncGameLibUncheckedException(e); } } else { defaultValue = getProp(defaultProperty); } } do { if (!StringUtils.isEmpty(defaultValue)) { if (isPassword) { System.out.printf("%s [%s]: ", message, StringUtils.replaceAll(defaultValue, ".", "*")); } else System.out.printf("%s [%s]: ", message, defaultValue); } else { System.out.printf("%s: ", message); } System.out.flush(); returnValue = StringUtils.defaultIfEmpty(userInput.nextLine(), defaultValue); inputEmpty = StringUtils.isEmpty(returnValue); } while ((inputEmpty && ++retryCounter < 3) && required); //If the token is still empty, throw an error if (inputEmpty && required) { System.err.println("Required parameter is missing"); } else if (inputEmpty && !StringUtils.isEmpty(defaultValue)) { returnValue = defaultValue; } //Save to properties file if (!StringUtils.isEmpty(defaultProperty)) { if (isPassword) { try { saveProp(defaultProperty, encrypt(returnValue)); } catch (Exception e) { throw new AsyncGameLibUncheckedException(e); } } else { saveProp(defaultProperty, returnValue); } } return returnValue; }
From source file:com.glaf.oa.optional.web.springmvc.OptionalController.java
@RequestMapping("/edit") public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) { RequestUtils.setRequestParameterToAttribute(request); request.removeAttribute("canSubmit"); Optional optional = optionalService.getOptional(RequestUtils.getInt(request, "optionalId")); if (optional != null) { request.setAttribute("optional", optional); JSONObject rowJSON = optional.toJsonObject(); request.setAttribute("x_json", rowJSON.toJSONString()); }//from www .j av a 2 s. c o m boolean canUpdate = false; String x_method = request.getParameter("x_method"); if (StringUtils.equals(x_method, "submit")) { } if (StringUtils.containsIgnoreCase(x_method, "update")) { if (optional != null) { canUpdate = true; } } request.setAttribute("canUpdate", canUpdate); String view = request.getParameter("view"); if (StringUtils.isNotEmpty(view)) { return new ModelAndView(view, modelMap); } String x_view = ViewProperties.getString("optional.edit"); if (StringUtils.isNotEmpty(x_view)) { return new ModelAndView(x_view, modelMap); } return new ModelAndView("/oa/optional/edit", modelMap); }
From source file:com.moviejukebox.reader.MovieNFOReader.java
/** * Try and read a NFO file for information * * First try as XML format file, then check to see if it contains XML and text and split it to read each part * * @param nfoFile// w ww .ja v a2 s .c o m * @param movie * @return */ public static boolean readNfoFile(File nfoFile, Movie movie) { String nfoText = FileTools.readFileToString(nfoFile); boolean parsedNfo = Boolean.FALSE; // Was the NFO XML parsed correctly or at all boolean hasXml = Boolean.FALSE; if (StringUtils.containsIgnoreCase(nfoText, XML_START + TYPE_MOVIE) || StringUtils.containsIgnoreCase(nfoText, XML_START + TYPE_TVSHOW) || StringUtils.containsIgnoreCase(nfoText, XML_START + TYPE_EPISODE)) { hasXml = Boolean.TRUE; } // If the file has XML tags in it, try reading it as a pure XML file if (hasXml) { parsedNfo = readXmlNfo(nfoFile, movie); } // If it has XML in it, but didn't parse correctly, try splitting it out if (hasXml && !parsedNfo) { int posMovie = findPosition(nfoText, TYPE_MOVIE); int posTv = findPosition(nfoText, TYPE_TVSHOW); int posEp = findPosition(nfoText, TYPE_EPISODE); int start = Math.min(posMovie, Math.min(posTv, posEp)); posMovie = StringUtils.indexOf(nfoText, XML_END + TYPE_MOVIE); posTv = StringUtils.indexOf(nfoText, XML_END + TYPE_TVSHOW); posEp = StringUtils.indexOf(nfoText, XML_END + TYPE_EPISODE); int end = Math.max(posMovie, Math.max(posTv, posEp)); if ((end > -1) && (end > start)) { end = StringUtils.indexOf(nfoText, '>', end) + 1; // Send text to be read String nfoTrimmed = StringUtils.substring(nfoText, start, end); parsedNfo = readXmlNfo(nfoTrimmed, movie, nfoFile.getName()); nfoTrimmed = StringUtils.remove(nfoText, nfoTrimmed); if (parsedNfo && nfoTrimmed.length() > 0) { // We have some text left, so scan that with the text scanner readTextNfo(nfoTrimmed, movie); } } } // If the XML wasn't found or parsed correctly, then fall back to the old method if (parsedNfo) { LOG.debug("Successfully scanned {} as XML format", nfoFile.getName()); } else { parsedNfo = MovieNFOReader.readTextNfo(nfoText, movie); if (parsedNfo) { LOG.debug("Successfully scanned {} as text format", nfoFile.getName()); } else { LOG.debug("Failed to find any information in {}", nfoFile.getName()); } } return Boolean.FALSE; }