/** * @param color * @return whether the color is testable, i.e defined as a rgb color */ public static boolean isColorTestable(final String color) { return !StringUtils.contains(color, BACKGROUND_IMAGE_KEY) && !StringUtils.contains(color, GRADIENT_KEY) && !StringUtils.contains(color, ALPHA_COLOR_KEY) && !StringUtils.equalsIgnoreCase(color, TRANSPARENT_KEY) && StringUtils.startsWith(color, RGB_COLOR_KEY); }
public void aGrepResultsWithMultipleFiles() { GrepResults results = grep( constantExpression("ER"), on(Arrays.asList(localProfileWithWildecard("*"))), extraLinesAfter(20)); for (GrepResult result : results) { if (result.getFileName().endsWith("gz")) { assertThat( StringUtils.contains( result.filterBy(regularExpression("E(.*)OR")).getText(), "GZ ERROR 1"), is(true)); assertThat( StringUtils.contains( result.filterBy(regularExpression("E(.*)OR")).getText(), "GZ ERROR 2"), is(true)); } else { assertThat( StringUtils.contains( result.filterBy(regularExpression("E(.*)OR")).getText(), "ERROR 1"), is(true)); assertThat( StringUtils.contains( result.filterBy(regularExpression("E(.*)OR")).getText(), "ERROR 2"), is(true)); } } }
/** Tests toString. */ @Test public void testToStringLLC() throws Exception { LLC llc = deserializer.deserialize(bytes, 0, bytes.length); String str = llc.toString(); assertTrue(StringUtils.contains(str, "dsap=" + dsap)); assertTrue(StringUtils.contains(str, "ssap=" + ssap)); assertTrue(StringUtils.contains(str, "ctrl=" + ctrl)); }
@Test public void should_not_return_skin_and_validation_and_if_profiled_is_not_endpoint() { String message; Mockito.when(profiled.level()).thenReturn("service"); message = aspect.getStopWatchMessage(profiled, joinPoint, new Object(), new Throwable()); Assert.assertNotNull(message); Assert.assertFalse(StringUtils.contains(message, ",SKIN=")); Assert.assertFalse(StringUtils.contains(message, ",VALIDATION=")); Assert.assertFalse(StringUtils.contains(message, ",IP=")); }
/** * 从DataSoure中取出connection, 根据connection的metadata中的jdbcUrl判断Dialect类型. 仅支持Oracle, H2, * MySql,如需更多数据库类型,请仿照此类自行编写。 */ public static String getDialect(DataSource dataSource) { String jdbcUrl = getJdbcUrlFromDataSource(dataSource); // 根据jdbc url判断dialect if (StringUtils.contains(jdbcUrl, ":h2:")) { return H2Dialect.class.getName(); } else if (StringUtils.contains(jdbcUrl, ":mysql:")) { return MySQL5InnoDBDialect.class.getName(); } else if (StringUtils.contains(jdbcUrl, ":oracle:")) { return Oracle10gDialect.class.getName(); } else { throw new IllegalArgumentException("Unknown Database of " + jdbcUrl); } }
/** * @param buffer * @param zout * @param file * @param folderName * @throws FileNotFoundException (subclass of IOException) * @throws IOException */ private static void addFileToZip( byte[] buffer, ZipOutputStream zout, File file, String folderName) throws IOException { if (StringUtils.contains(file.getName(), MIMETYPE) || StringUtils.contains(file.getName(), CONTAINER_XML)) { LOGGER.debug("Skipping " + file.getName()); return; } LOGGER.debug("Adding " + file.getName()); // create object of FileInputStream for source file FileInputStream fin = new FileInputStream(file); // TODO upgrade to Java 7 and use AutoCloseable instead of try try { /* * To begin writing ZipEntry in the zip file, use * * void putNextEntry(ZipEntry entry) method of ZipOutputStream * class. * * This method begins writing a new Zip entry to the zip file and * positions the stream to the start of the entry data. */ zout.putNextEntry(new ZipEntry(folderName + "/" + file.getName())); /* * After creating entry in the zip file, actually write the file. */ int length; while ((length = fin.read(buffer)) > 0) { zout.write(buffer, 0, length); } /* * After writing the file to ZipOutputStream, use * * void closeEntry() method of ZipOutputStream class to close the * current entry and position the stream to write the next entry. */ zout.closeEntry(); } finally { // close the InputStream fin.close(); } }
@Test public void should_return_exception_and_code_and_skin_and_validation_and_ip_if_profiled_is_endpoint() { String message; Mockito.when(profiled.level()).thenReturn("endpoint"); message = aspect.getStopWatchMessage(profiled, joinPoint, new Object(), new RuntimeException()); Assert.assertNotNull(message); Assert.assertTrue(StringUtils.contains(message, ",SKIN=")); Assert.assertTrue(StringUtils.contains(message, ",VALIDATION=")); Assert.assertTrue(StringUtils.contains(message, ",IP=")); Assert.assertTrue(StringUtils.contains(message, ",EXCEPTION=")); Assert.assertTrue(StringUtils.contains(message, ",MSG=")); }
public Object getReferencedProperty( final GraphObject entity, final String refKey, final Object initialData, final int depth) throws FrameworkException { final String DEFAULT_VALUE_SEP = "!"; final String[] parts = refKey.split("[\\.]+"); Object _data = initialData; // walk through template parts for (int i = 0; i < parts.length; i++) { String key = parts[i]; String defaultValue = null; if (StringUtils.contains(key, DEFAULT_VALUE_SEP)) { String[] ref = StringUtils.split(key, DEFAULT_VALUE_SEP); key = ref[0]; if (ref.length > 1) { defaultValue = ref[1]; } } _data = evaluate(entity, key, _data, defaultValue, i + depth); } return _data; }
/** * Extracts the username from the specified DN. If the username cannot be extracted because the CN * is in an unrecognized format, the entire CN is returned. If the CN cannot be extracted because * the DN is in an unrecognized format, the entire DN is returned. * * @param dn the dn to extract the username from * @return the exatracted username */ public static String extractUsername(String dn) { String username = dn; String cn = ""; // ensure the dn is specified if (StringUtils.isNotBlank(dn)) { // attempt to locate the cn if (dn.startsWith("CN=")) { cn = StringUtils.substringBetween(dn, "CN=", ","); } else if (dn.startsWith("/CN=")) { cn = StringUtils.substringBetween(dn, "CN=", "/"); } else if (dn.startsWith("C=") || dn.startsWith("/C=")) { cn = StringUtils.substringAfter(dn, "CN="); } else if (dn.startsWith("/") && StringUtils.contains(dn, "CN=")) { cn = StringUtils.substringAfter(dn, "CN="); } // attempt to get the username from the cn if (StringUtils.isNotBlank(cn)) { if (cn.endsWith(")")) { username = StringUtils.substringBetween(cn, "(", ")"); } else if (cn.contains(" ")) { username = StringUtils.substringAfterLast(cn, " "); } else { username = cn; } } } return username; }
static RabbitConnectionFactoryConfig uriToConnectionConfig(String uri) { RabbitConnectionFactoryConfig properties = new RabbitConnectionFactoryConfig(); if (isNotEmpty(uri)) { String username = StringUtils.substringBetween(uri, "amqp://", ":"); String password = StringUtils.substringBetween(uri, username + ":", "@"); String hostWithPort = StringUtils.substringBetween(uri, "@", "/"); // If no virtual host is specified if (isEmpty(hostWithPort)) { hostWithPort = StringUtils.substringAfter(uri, "@"); } int port = properties.getPort(); String host = hostWithPort; boolean hasPort = StringUtils.contains(hostWithPort, ":"); if (hasPort) { host = StringUtils.substringBefore(hostWithPort, ":"); port = NumberUtils.toInt(StringUtils.substringAfter(hostWithPort, ":")); } String virtualHost = StringUtils.substringAfter(uri, hostWithPort + "/"); properties.setUsername(username); properties.setPassword(password); properties.setHost(host); properties.setPort(port); if (isNotEmpty(virtualHost)) { properties.setVirtualHost(virtualHost); } } return properties; }
public static <T extends Comparable<T>> Range<T> parse(String value, Function<String, T> parser) { Validate.notNull(parser, "Parser is required"); if (StringUtils.isBlank(value) || StringUtils.equals(SEPARATOR, value)) { return Ranges.all(); } else if (!StringUtils.contains(value, SEPARATOR)) { T element = parser.apply(value); return Ranges.atMost(element); } else { String lower = StringUtils.substringBefore(value, SEPARATOR); String upper = StringUtils.substringAfter(value, SEPARATOR); if (StringUtils.isBlank(lower)) { // ..n Pair<T, BoundType> boundary = parseUpperBoundary(upper, parser); return Ranges.upTo(boundary.getLeft(), boundary.getRight()); } else if (StringUtils.isBlank(upper)) { // n.. Pair<T, BoundType> boundary = parseLowerBoundary(lower, parser); return Ranges.downTo(boundary.getLeft(), boundary.getRight()); } else { // n..m Pair<T, BoundType> down = parseLowerBoundary(lower, parser); Pair<T, BoundType> up = parseUpperBoundary(upper, parser); return Ranges.range(down.getLeft(), down.getRight(), up.getLeft(), up.getRight()); } } }
public void aGrepResultsSetWithSingleFileMultipleExtracts() { GrepResults results = grep(constantExpression("ERROR 1"), on(localProfile()), extraLinesAfter(20)); for (GrepResult result : results.filterBy(regularExpression("f(.*)e")).filterBy(regularExpression("ext(.*)ct"))) { assertThat(StringUtils.contains(result.getText(), "fine extract"), is(true)); } }
/** * @param expression * @param singular * @param plural * @return * @since https://github.com/RedHogs/cron-parser/issues/2 */ protected String plural(String expression, String singular, String plural) { if (NumberUtils.isNumber(expression) && (Integer.parseInt(expression) > 1)) { return plural; } else if (StringUtils.contains(expression, ",")) { return plural; } return singular; }
public void aGrepResultsWithSingleFile() { GrepResults results = grep(constantExpression("ERROR 1"), on(localProfile()), extraLinesAfter(20)); for (GrepResult result : results) { assertThat( StringUtils.contains( result.getText(), "customer Marco(id=12345) has been updated successfully"), is(true)); } }
public static boolean checkAccetptGzip(HttpServletRequest request) { // Http1.1 header String acceptEncoding = request.getHeader("Accept-Encoding"); if (StringUtils.contains(acceptEncoding, "gzip")) { return true; } else { return false; } }
@Test public void should_return_null_in_result() { String message; Mockito.when(profiled.level()).thenReturn("endpoint"); message = aspect.getStopWatchMessage(profiled, joinPoint, null, new Exception()); Assert.assertNotNull(message); Assert.assertTrue(StringUtils.contains(message, "RESULT=null")); }
/** * Extract from the audit parameter the referential. Regarding this value, the returned page * displays results sorted by tests or criterion * * @param request * @param arsc * @return */ private String computeDisplayScope(HttpServletRequest request, AuditResultSortCommand arsc) { if (StringUtils.contains( request.getHeader(TgolKeyStore.REFERER_HEADER_KEY), TgolKeyStore.CRITERION_RESULT_PAGE_KEY)) { return TgolKeyStore.CRITERION_DISPLAY_SCOPE_VALUE; } if (arsc != null) { return arsc.getDisplayScope(); } return TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE; }
@Override public boolean includes(String suffixPart) { if (StringUtils.contains(suffixPart, UrlSuffixUtil.KEY_VALUE_DELIMITER)) { return true; } // We need to unescape the suffix part before comparing it to the source path to remove String unescapedPart = UrlSuffixUtil.decodeResourcePathPart(suffixPart); return !unescapedPart.equals(resourcePathToRemove); }
@Override public void updateConfiguration(PropertiesConfiguration configuration) { if (configuration.getProperty("database").equals("derby")) { String url = (String) configuration.getProperty("database.url"); if (!StringUtils.contains(url, ";upgrade=")) { url += ";upgrade=true"; } configuration.setProperty("database.url", url); } }
private static boolean containMarker(String line, String[] markers) { for (String marker : markers) { if (StringUtils.isEmpty(marker)) { continue; } if (StringUtils.contains(line, marker)) { return true; } } return false; }
/** * Replaces a JavaType fullyQualifiedName for a shorter name using '~' for TopLevelPackage * * @param cid ClassOrInterfaceTypeDetails of a JavaType * @param currentText String current text for option value * @return the String representing a JavaType with its name shortened */ private String replaceTopLevelPackageString(ClassOrInterfaceTypeDetails cid, String currentText) { String javaTypeFullyQualilfiedName = cid.getType().getFullyQualifiedTypeName(); String javaTypeString = ""; String topLevelPackageString = ""; // Add module value to topLevelPackage when necessary if (StringUtils.isNotBlank(cid.getType().getModule()) && !cid.getType().getModule().equals(projectOperations.getFocusedModuleName())) { // Target module is not focused javaTypeString = cid.getType().getModule().concat(LogicalPath.MODULE_PATH_SEPARATOR); topLevelPackageString = projectOperations .getTopLevelPackage(cid.getType().getModule()) .getFullyQualifiedPackageName(); } else if (StringUtils.isNotBlank(cid.getType().getModule()) && cid.getType().getModule().equals(projectOperations.getFocusedModuleName()) && (currentText.startsWith(cid.getType().getModule()) || cid.getType().getModule().startsWith(currentText)) && StringUtils.isNotBlank(currentText)) { // Target module is focused but user wrote it javaTypeString = cid.getType().getModule().concat(LogicalPath.MODULE_PATH_SEPARATOR); topLevelPackageString = projectOperations .getTopLevelPackage(cid.getType().getModule()) .getFullyQualifiedPackageName(); } else { // Not multimodule project topLevelPackageString = projectOperations.getFocusedTopLevelPackage().getFullyQualifiedPackageName(); } // Autocomplete with abbreviate or full qualified mode String auxString = javaTypeString.concat( StringUtils.replace(javaTypeFullyQualilfiedName, topLevelPackageString, "~")); if ((StringUtils.isBlank(currentText) || auxString.startsWith(currentText)) && StringUtils.contains(javaTypeFullyQualilfiedName, topLevelPackageString)) { // Value is for autocomplete only or user wrote abbreviate value javaTypeString = auxString; } else { // Value could be for autocomplete or for validation javaTypeString = String.format("%s%s", javaTypeString, javaTypeFullyQualilfiedName); } return javaTypeString; }
@Override protected void select(SSPHandler sspHandler) { ElementSelector es = new SimpleElementSelector(FLASH_CONTENT_CSS_LIKE_QUERY); es.selectElements(sspHandler, decidableElements); es = new SimpleElementSelector(SCRIPT_ELEMENT); es.selectElements(sspHandler, notDecidableElements); Iterator<Element> iter = notDecidableElements.get().iterator(); while (iter.hasNext()) { Element script = iter.next(); if (!StringUtils.contains(script.html(), SWF_EXT)) { iter.remove(); } } }
private String getDelimiter(String text) { if (StringUtils.contains(text, "//") && StringUtils.indexOf(text, "//") == 0) { Character delimiterDummy = text.charAt(2); int end; for (end = 2; end < text.length(); end++) { Character currItem = text.charAt(end); if (!currItem.equals(delimiterDummy)) { break; } } return text.substring(2, end); } return null; }
/** * Op. * * @param op1 the op1 * @param op2 the op2 * @return true, if successful */ protected final boolean op(final String op1, final String op2) { switch (this.getOperator()) { case CONTAINS_IC: return StringUtils.containsIgnoreCase(op1, op2); case CONTAINS: return StringUtils.contains(op1, op2); case EQUALS: return op1.equals(op2); case EQUALS_IC: return op1.equalsIgnoreCase(op2); default: return false; } }
/** * 获取属性名字路径 * * @param propertyName 属性名 * @param root Query roots always reference entities * @return {@link Path} */ public static Path<?> getPath(String propertyName, Root<?> root) { Path<?> path = null; if (StringUtils.contains(propertyName, ".")) { String[] propertys = StringUtils.splitByWholeSeparator(propertyName, "."); path = root.get(propertys[0]); for (int i = 1; i < propertys.length; i++) { path = path.get(propertys[i]); } } else { path = root.get(propertyName); } return path; }
private static String validateName(String name) { name = StringUtils.strip(name); byte[] nameBytes = name.getBytes(); for (byte b : nameBytes) { if ((b >= 0 && b <= 31) || (b == 127)) { throw new IllegalArgumentException("name contains unprintable character(s)"); } } if (name.startsWith(".")) { throw new IllegalArgumentException("name starts with a dot"); } name = StringUtils.strip(name, "."); if (StringUtils.contains(name, "\"*/:<>?\\|")) { throw new IllegalArgumentException("name contains illegal character(s)"); } return name; }
public static boolean isGoogleMapsInstalled() { // Check if API key is available final String mapsKey = CgeoApplication.getInstance().getString(R.string.maps_api_key); if (StringUtils.length(mapsKey) < 30 || StringUtils.contains(mapsKey, "key")) { Log.w("No Google API key available."); return false; } // Check if API is available try { Class.forName("com.google.android.maps.MapActivity"); } catch (final ClassNotFoundException ignored) { return false; } // Assume that Google Maps is available and working return true; }
/** 检查浏览器客户端是否支持gzip编码. */ private static boolean checkAccetptGzip(HttpServletRequest request) { // Http1.1 header String acceptEncoding = request.getHeader("Accept-Encoding"); return StringUtils.contains(acceptEncoding, "gzip"); }
@Override protected void setProcess() { // ---------------------------------------------------------------------- // ------------------------------1Passed-01------------------------------ // ---------------------------------------------------------------------- ProcessResult processResult = processPageTest("AW22.Test.1.2.2-1Passed-01"); // check test result assertEquals(TestSolution.PASSED, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------1Passed-02------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-1Passed-02"); // check test result assertEquals(TestSolution.PASSED, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------1Passed-03------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-1Passed-03"); // check test result assertEquals(TestSolution.PASSED, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------1Passed-04------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-1Passed-04"); // check test result assertEquals(TestSolution.PASSED, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(3, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------1Passed-05------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-1Passed-05"); // check test result assertEquals(TestSolution.PASSED, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------2Failed-01------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-2Failed-01"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.FAILED, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); SourceCodeRemark processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.FAILED, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); Iterator<EvidenceElement> iter = processRemark.getElementList().iterator(); EvidenceElement ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "Not empty alt")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------2Failed-02------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-2Failed-02"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.FAILED, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.FAILED, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "Not empty alt")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------2Failed-03------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-2Failed-03"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.FAILED, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.FAILED, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "Not empty alt")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------2Failed-04------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-2Failed-04"); // check number of elements in the page assertEquals(3, processResult.getElementCounter()); // check test result assertEquals(TestSolution.FAILED, processResult.getValue()); // check number of remarks and their value assertEquals(3, processResult.getRemarkSet().size()); Iterator<ProcessRemark> pIter = processResult.getRemarkSet().iterator(); processRemark = (SourceCodeRemark) pIter.next(); assertEquals( RemarkMessageStore.DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.FAILED, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "Not empty alt")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); processRemark = (SourceCodeRemark) pIter.next(); assertEquals( RemarkMessageStore.DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.FAILED, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "Not empty alt")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); processRemark = (SourceCodeRemark) pIter.next(); assertEquals( RemarkMessageStore.DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.FAILED, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "Not empty alt")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------2Failed-05------------------------------ // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-2Failed-05"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.FAILED, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.DECORATIVE_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.FAILED, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "Not empty alt")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------3NMI-01--------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-3NMI-01"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.CHECK_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------3NMI-02--------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-3NMI-02"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.CHECK_ELEMENT_WITH_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------3NMI-03--------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-3NMI-03"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.CHECK_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------3NMI-04--------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-3NMI-04"); // check number of elements in the page assertEquals(1, processResult.getElementCounter()); // check test result assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.CHECK_ELEMENT_WITH_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------3NMI-05--------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-3NMI-05"); // check number of elements in the page assertEquals(2, processResult.getElementCounter()); // check test result assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.CHECK_ELEMENT_WITH_NOT_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------3NMI-06--------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-3NMI-06"); // check number of elements in the page assertEquals(2, processResult.getElementCounter()); // check test result assertEquals(TestSolution.NEED_MORE_INFO, processResult.getValue()); // check number of remarks and their value assertEquals(1, processResult.getRemarkSet().size()); processRemark = ((SourceCodeRemark) ((LinkedHashSet) processResult.getRemarkSet()).iterator().next()); assertEquals( RemarkMessageStore.CHECK_ELEMENT_WITH_EMPTY_ALT_MSG, processRemark.getMessageCode()); assertEquals(TestSolution.NEED_MORE_INFO, processRemark.getIssue()); assertEquals(HtmlElementStore.AREA_ELEMENT, processRemark.getTarget()); assertNotNull(processRemark.getSnippet()); // check number of evidence elements and their value assertEquals(1, processRemark.getElementList().size()); iter = processRemark.getElementList().iterator(); ee = iter.next(); assertTrue(StringUtils.contains(ee.getValue(), "")); assertEquals(ALT_ATTR, ee.getEvidence().getCode()); // ---------------------------------------------------------------------- // ------------------------------4NA-01---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-01"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-02---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-02"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-03---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-03"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-04---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-04"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-05---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-05"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-06---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-06"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-07---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-07"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-08---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-08"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-09---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-09"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); // ---------------------------------------------------------------------- // ------------------------------4NA-10---------------------------------- // ---------------------------------------------------------------------- processResult = processPageTest("AW22.Test.1.2.2-4NA-10"); // check test result assertEquals(TestSolution.NOT_APPLICABLE, processResult.getValue()); // check test has no remark assertNull(processResult.getRemarkSet()); // check number of elements in the page assertEquals(0, processResult.getElementCounter()); }
public static boolean isArray(String arrayTypeName) { return StringUtils.contains(arrayTypeName, "["); }