List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY
String[] EMPTY_STRING_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.
Click Source Link
String
array. From source file:org.marketcetera.util.file.SmartLinksDirectoryWalkerTest.java
@Test public void walk() throws Exception { String root;// ww w . ja va 2 s. c o m String dir; String[] files = TEST_FILE_LIST; if (OperatingSystem.LOCAL.isUnix()) { dir = TEST_DIR_UNIX; root = TEST_ROOT_UNIX; files = (String[]) ArrayUtils.add(files, TEST_LINK_NAME); } else if (OperatingSystem.LOCAL.isWin32()) { dir = TEST_DIR_WIN32; root = TEST_ROOT_WIN32; } else { throw new AssertionError("Unknown platform"); } String[] dirs = (String[]) ArrayUtils.add(TEST_DIR_LIST, dir); ListWalker walker = new ListWalker(false); walker.apply(root); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertEquals(3, walker.getMaxDepth()); Vector<String> results = new Vector<String>(); walker = new ListWalker(false); walker.apply(root, results); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertArrayPermutation(ArrayUtils.addAll(files, dirs), results.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); assertEquals(3, walker.getMaxDepth()); files = TEST_FILE_LIST; dirs = (String[]) ArrayUtils.add(TEST_DIR_LIST, dir); if (OperatingSystem.LOCAL.isUnix()) { files = (String[]) ArrayUtils.add(files, TEST_LINK_CONTENTS); dirs = (String[]) ArrayUtils.add(dirs, TEST_LINK_NAME); } walker = new ListWalker(true); walker.apply(root); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertEquals(3, walker.getMaxDepth()); results = new Vector<String>(); walker = new ListWalker(true); walker.apply(root, results); assertArrayPermutation(files, walker.getFiles()); assertArrayPermutation(dirs, walker.getDirectories()); assertArrayPermutation(ArrayUtils.addAll(files, dirs), results.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); assertEquals(3, walker.getMaxDepth()); }
From source file:org.marketcetera.util.misc.ReflectUtilsTest.java
@Test public void fields() { assertNamesMatch(ArrayUtils.EMPTY_STRING_ARRAY, ReflectUtils.getAllFields(Empty.class)); assertNamesMatch(new String[] { SIMPLE_FIELD }, ReflectUtils.getAllFields(Simple.class)); assertNamesMatch(new String[] { SIMPLE_FIELD, DERIVED_FIELD }, ReflectUtils.getAllFields(Derived.class)); assertNamesMatch(new String[] { IFACE_FIELD }, ReflectUtils.getAllFields(IFace.class)); assertNamesMatch(new String[] { SIMPLE_FIELD, IFACE_FIELD, COMPLEX_BASE_FIELD }, ReflectUtils.getAllFields(ComplexBase.class)); assertNamesMatch(new String[] { SIMPLE_FIELD, IFACE_FIELD, COMPLEX_BASE_FIELD, COMPLEX_DERIVED_FIELD }, ReflectUtils.getAllFields(ComplexDerived.class)); }
From source file:org.marketcetera.util.test.CollectionAssertTest.java
@Test public void equal() { assertArrayPermutation(null, null);/* w ww. j a va 2 s. co m*/ assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY); assertArrayPermutation(new Integer[] { 1 }, new Integer[] { 1 }); assertArrayPermutation(new Integer[] { 1, null }, new Integer[] { null, 1 }); assertArrayPermutation(new Integer[] { null, null }, new Integer[] { null, null }); assertArrayPermutation(new Long[] { 1L, 2L, 1L }, new Long[] { 1L, 1L, 2L }); }
From source file:org.marketcetera.util.test.CollectionAssertTest.java
@Test public void expectedNull() { try {//from ww w. ja v a 2s. c om assertArrayPermutation(null, ArrayUtils.EMPTY_STRING_ARRAY); } catch (AssertionError ex) { assertEquals("expected array is null but actual is not", ex.getMessage()); return; } fail(); }
From source file:org.marketcetera.util.test.CollectionAssertTest.java
@Test public void actualNull() { try {/*from w w w .jav a 2s . com*/ assertArrayPermutation(ArrayUtils.EMPTY_STRING_ARRAY, null); } catch (AssertionError ex) { assertEquals("actual array is null but expected is not", ex.getMessage()); return; } fail(); }
From source file:org.nuxeo.webengine.sites.listeners.SitesWikiListener.java
private String[] getLinks(String content) { if (content == null) { return ArrayUtils.EMPTY_STRING_ARRAY; }/*from w ww. jav a 2s . c o m*/ int contentLength = content.length(); if (contentLength == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } List<String> returnList = new ArrayList<String>(); int currentPosition = 0; while (currentPosition < (contentLength - 1)) { int startPosition = content.indexOf(openBracket, currentPosition); if (startPosition < 0) { break; } startPosition++; int endPosition = content.indexOf(closeBracket, startPosition); if (endPosition < 0) { break; } returnList.add(content.substring(startPosition, endPosition)); currentPosition = endPosition + 1; } if (!returnList.isEmpty()) { return returnList.toArray(new String[returnList.size()]); } else { return ArrayUtils.EMPTY_STRING_ARRAY; } }
From source file:org.onehippo.cms7.brokenlinks.BrokenLinksTest.java
@Test public void testBadInternalLinks() throws Exception { DocumentText documents = new DocumentText() { public String getTextForDocument(int index) { return TEXT4; }//from ww w . j av a2 s.co m }; for (int count : new int[] { 10, 10 }) { levels.push(count); } List<String> createdDocIds = new ArrayList<String>(100); createDocuments(session.getRootNode().getNode("test"), levels, 0, documents, createdDocIds); int documentCount = createdDocIds.size(); // build valid linked nodes under the html compound node of each created document. for (int i = 0; i < documentCount; i++) { String docId = createdDocIds.get(i); Node docNode = session.getNodeByIdentifier(docId); Node htmlNode = docNode.getNode(HTML_COMPOUND_NODE_NAME); Node internalDocLinkNode = htmlNode.addNode(DEFAULT_INTERNAL_DOC_LINK_NAME, HippoNodeType.NT_FACETSELECT); // set a bad UUID here to see if it check the invalidity!!! internalDocLinkNode.setProperty(HippoNodeType.HIPPO_DOCBASE, "00000000-0000-0000-0000-000000000000"); internalDocLinkNode.setProperty(HippoNodeType.HIPPO_FACETS, ArrayUtils.EMPTY_STRING_ARRAY); internalDocLinkNode.setProperty(HippoNodeType.HIPPO_MODES, ArrayUtils.EMPTY_STRING_ARRAY); internalDocLinkNode.setProperty(HippoNodeType.HIPPO_VALUES, ArrayUtils.EMPTY_STRING_ARRAY); session.save(); } session.refresh(false); new BrokenLinksCheckingJob().execute(jobContext); session.refresh(false); QueryResult result = session.getWorkspace().getQueryManager() .createQuery("SELECT * FROM [brokenlinks:brokenlinks]", Query.JCR_SQL2).execute(); assertEquals(100, countDocuments(result)); }
From source file:org.onehippo.cms7.brokenlinks.BrokenLinksTest.java
@Test public void testGoodInternalLinks() throws Exception { DocumentText documents = new DocumentText() { public String getTextForDocument(int index) { return TEXT4; }// w w w. j a v a 2 s .co m }; for (int count : new int[] { 10, 10 }) { levels.push(count); } List<String> createdDocIds = new ArrayList<String>(100); createDocuments(session.getRootNode().getNode("test"), levels, 0, documents, createdDocIds); int documentCount = createdDocIds.size(); // build valid linked nodes under the html compound node of each created document. for (int i = 0; i < documentCount; i++) { String docId = createdDocIds.get(i); String linkedDocId = createdDocIds.get(documentCount - i - 1); Node docNode = session.getNodeByIdentifier(docId); Node htmlNode = docNode.getNode(HTML_COMPOUND_NODE_NAME); Node internalDocLinkNode = htmlNode.addNode(DEFAULT_INTERNAL_DOC_LINK_NAME, HippoNodeType.NT_FACETSELECT); internalDocLinkNode.setProperty(HippoNodeType.HIPPO_DOCBASE, linkedDocId); internalDocLinkNode.setProperty(HippoNodeType.HIPPO_FACETS, ArrayUtils.EMPTY_STRING_ARRAY); internalDocLinkNode.setProperty(HippoNodeType.HIPPO_MODES, ArrayUtils.EMPTY_STRING_ARRAY); internalDocLinkNode.setProperty(HippoNodeType.HIPPO_VALUES, ArrayUtils.EMPTY_STRING_ARRAY); session.save(); } session.refresh(false); new BrokenLinksCheckingJob().execute(jobContext); session.refresh(false); QueryResult result = session.getWorkspace().getQueryManager() .createQuery("SELECT * FROM [brokenlinks:brokenlinks]", Query.JCR_SQL2).execute(); assertEquals(0, countDocuments(result)); }
From source file:org.onehippo.cms7.essentials.components.cms.blog.BlogImporterJob.java
private String[] extractArray(final String value) { final String[] retValue; if (Strings.isNullOrEmpty(value)) { retValue = ArrayUtils.EMPTY_STRING_ARRAY; } else {// w w w .j a v a 2 s.c om final Iterator<String> iterator = Splitter.on(SPLITTER).omitEmptyStrings().split(value).iterator(); final List<String> strings = Lists.newArrayList(iterator); retValue = strings.toArray(new String[strings.size()]); } return retValue; }
From source file:org.onehippo.cms7.essentials.components.cms.modules.BlogListenerModule.java
@Override protected void doConfigure(final Node moduleConfig) throws RepositoryException { cronExpression = JcrUtils.getStringProperty(moduleConfig, CONFIG_CRONEXPRESSION_PROPERTY, null); projectNamespace = JcrUtils.getStringProperty(moduleConfig, "projectNamespace", null); active = JcrUtils.getBooleanProperty(moduleConfig, "active", Boolean.FALSE); runNow = JcrUtils.getBooleanProperty(moduleConfig, "runInstantly", Boolean.FALSE); blogBasePath = JcrUtils.getStringProperty(moduleConfig, BlogImporterJob.BLOGS_BASE_PATH, null); authorsBasePath = JcrUtils.getStringProperty(moduleConfig, BlogImporterJob.AUTHORS_BASE_PATH, null); urls = readStrings(moduleConfig, BlogImporterJob.URLS); authors = readStrings(moduleConfig, BlogImporterJob.AUTHORS); if (authors.length != urls.length) { log.error("Authors and URL size mismatch, no blogs will be imported."); authors = ArrayUtils.EMPTY_STRING_ARRAY; urls = ArrayUtils.EMPTY_STRING_ARRAY; }//w w w . j a v a 2s. c om }