List of usage examples for org.apache.commons.lang SystemUtils LINE_SEPARATOR
String LINE_SEPARATOR
To view the source code for org.apache.commons.lang SystemUtils LINE_SEPARATOR.
Click Source Link
The line.separator
System Property.
From source file:org.apache.geode.test.compiler.UncompiledSourceCodeTest.java
@Test public void fromClassNameWithPackage() throws Exception { UncompiledSourceCode uncompiledSourceCode = UncompiledSourceCode.fromClassName("foo.bar.ClassName"); assertThat(uncompiledSourceCode.simpleClassName).isEqualTo("ClassName"); assertThat(uncompiledSourceCode.sourceCode) .isEqualTo("package foo.bar;" + SystemUtils.LINE_SEPARATOR + "public class ClassName {}"); }
From source file:org.apache.geode.test.junit.rules.gfsh.internal.ProcessLogger.java
public String getOutputText() { return outputLines.stream().map(OutputLine::getLine).collect(joining(SystemUtils.LINE_SEPARATOR)); }
From source file:org.apache.karaf.jaas.modules.krb5.Krb5LoginModuleTest.java
private String createKrb5Conf(ChecksumType checksumType, EncryptionType encryptionType, boolean isTcp) throws IOException { File file = folder.newFile("krb5.conf"); String data = ""; data += "[libdefaults]" + SystemUtils.LINE_SEPARATOR; data += "default_realm = " + REALM + SystemUtils.LINE_SEPARATOR; data += "default_tkt_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; data += "default_tgs_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; data += "permitted_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; // data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; // data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; data += "default-checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; if (isTcp) {/*from w w w . j a va 2 s . c o m*/ data += "udp_preference_limit = 1" + SystemUtils.LINE_SEPARATOR; } data += "[realms]" + SystemUtils.LINE_SEPARATOR; data += REALM + " = {" + SystemUtils.LINE_SEPARATOR; data += "kdc = " + HOSTNAME + ":" + kdcServer.getTransports()[0].getPort() + SystemUtils.LINE_SEPARATOR; data += "}" + SystemUtils.LINE_SEPARATOR; data += "[domain_realm]" + SystemUtils.LINE_SEPARATOR; data += "." + Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR; data += Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR; FileUtils.writeStringToFile(file, data); return file.getAbsolutePath(); }
From source file:org.apache.maven.plugin.javadoc.AbstractJavadocMojo.java
/** * Generate an <code>options</code> file for all options and arguments and add the <code>@options</code> in the * command line./*from w w w . ja v a2 s. c o m*/ * * @param cmd not null * @param arguments not null * @param javadocOutputDirectory not null * @throws MavenReportException if any * @see <a href="http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#argumentfiles"> * Reference Guide, Command line argument files</a> * @see #OPTIONS_FILE_NAME */ private void addCommandLineOptions(Commandline cmd, List<String> arguments, File javadocOutputDirectory) throws MavenReportException { File optionsFile = new File(javadocOutputDirectory, OPTIONS_FILE_NAME); StringBuilder options = new StringBuilder(); options.append( StringUtils.join(arguments.toArray(new String[arguments.size()]), SystemUtils.LINE_SEPARATOR)); try { FileUtils.fileWrite(optionsFile.getAbsolutePath(), null /* platform encoding */, options.toString()); } catch (IOException e) { throw new MavenReportException( "Unable to write '" + optionsFile.getName() + "' temporary file for command execution", e); } cmd.createArg().setValue("@" + OPTIONS_FILE_NAME); }
From source file:org.apache.maven.plugin.javadoc.AbstractJavadocMojo.java
/** * Generate a file called <code>argfile</code> (or <code>files</code>, depending the JDK) to hold files and add * the <code>@argfile</code> (or <code>@file</code>, depending the JDK) in the command line. * * @param cmd not null * @param javadocOutputDirectory not null * @param files not null * @throws MavenReportException if any// ww w. j av a 2 s.co m * @see <a href="http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#argumentfiles"> * Reference Guide, Command line argument files * </a> * @see <a href="http://docs.oracle.com/javase/1.4.2/docs/tooldocs/javadoc/whatsnew-1.4.html#runningjavadoc"> * What s New in Javadoc 1.4 * </a> * @see #isJavaDocVersionAtLeast(float) * @see #ARGFILE_FILE_NAME * @see #FILES_FILE_NAME */ private void addCommandLineArgFile(Commandline cmd, File javadocOutputDirectory, List<String> files) throws MavenReportException { File argfileFile; if (isJavaDocVersionAtLeast(SINCE_JAVADOC_1_4)) { argfileFile = new File(javadocOutputDirectory, ARGFILE_FILE_NAME); cmd.createArg().setValue("@" + ARGFILE_FILE_NAME); } else { argfileFile = new File(javadocOutputDirectory, FILES_FILE_NAME); cmd.createArg().setValue("@" + FILES_FILE_NAME); } try { FileUtils.fileWrite(argfileFile.getAbsolutePath(), null /* platform encoding */, StringUtils.join(files.iterator(), SystemUtils.LINE_SEPARATOR)); } catch (IOException e) { throw new MavenReportException( "Unable to write '" + argfileFile.getName() + "' temporary file for command execution", e); } }
From source file:org.apache.maven.plugin.javadoc.AbstractJavadocMojo.java
/** * Generate a file called <code>packages</code> to hold all package names and add the <code>@packages</code> in * the command line.// w ww . ja v a 2 s . c o m * * @param cmd not null * @param javadocOutputDirectory not null * @param packageNames not null * @throws MavenReportException if any * @see <a href="http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/javadoc.html#argumentfiles"> * Reference Guide, Command line argument files</a> * @see #PACKAGES_FILE_NAME */ private void addCommandLinePackages(Commandline cmd, File javadocOutputDirectory, List<String> packageNames) throws MavenReportException { File packagesFile = new File(javadocOutputDirectory, PACKAGES_FILE_NAME); try { FileUtils.fileWrite(packagesFile.getAbsolutePath(), null /* platform encoding */, StringUtils.join(packageNames.iterator(), SystemUtils.LINE_SEPARATOR)); } catch (IOException e) { throw new MavenReportException( "Unable to write '" + packagesFile.getName() + "' temporary file for command execution", e); } cmd.createArg().setValue("@" + PACKAGES_FILE_NAME); }
From source file:org.apache.maven.shared.release.phase.AbstractReleaseTestCase.java
protected void comparePomFiles(File expectedFile, File actualFile, boolean normalizeLineEndings) throws IOException { Reader expected = null;//w ww .j ava 2 s . c o m Reader actual = null; try { expected = ReaderFactory.newXmlReader(expectedFile); actual = ReaderFactory.newXmlReader(actualFile); StringBuffer sb = new StringBuffer("Check the transformed POM " + actualFile); sb.append(SystemUtils.LINE_SEPARATOR); final String remoteRepositoryURL = getRemoteRepositoryURL(); XMLUnit.setNormalizeWhitespace(true); Diff diff = XMLUnit.compareXML(expected, actual); diff.overrideDifferenceListener(new DifferenceListener() { public void skippedComparison(Node arg0, Node arg1) { //do nothing } public int differenceFound(Difference difference) { if ("${remoterepo}".equals(difference.getControlNodeDetail().getValue()) && remoteRepositoryURL.equals(difference.getTestNodeDetail().getValue())) { return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL; } else { return DifferenceListener.RETURN_ACCEPT_DIFFERENCE; } } }); diff.appendMessage(sb); XMLAssert.assertXMLIdentical(diff, true); } catch (SAXException e) { fail(e.getMessage()); } finally { IOUtil.close(expected); IOUtil.close(actual); } }
From source file:org.apache.ojb.broker.cache.CacheDistributor.java
public ObjectCacheInternal getCache(Class targetClass) { /*//from www . j a v a 2 s .c om the priorities to find an ObjectCache for a specific object are: 1. try to find a cache defined per class 2. try to find a cache defined per jdbc-connection-descriptor */ boolean useConnectionLevelCache = false; ObjectCacheInternal retval = null; /* first search in class-descriptor, then in jdbc-connection-descriptor for ObjectCacheDescriptor. */ ObjectCacheDescriptor ocd = searchInClassDescriptor(targetClass); if (ocd == null) { ocd = searchInJdbcConnectionDescriptor(); useConnectionLevelCache = true; } if (ocd == null) { throw new OJBRuntimeException("No object cache descriptor found for " + targetClass + ", using PBKey " + broker.getPBKey() + ". Please set a cache descriptor in jdbc-connection-descriptor or in class-descriptor"); } else { // use a class-descriptor level cache if (!useConnectionLevelCache) { if (!descriptorBasedCaches) { synchronized (caches) { retval = lookupCache(targetClass); if (retval == null) { if (log.isEnabledFor(Logger.INFO)) { String eol = SystemUtils.LINE_SEPARATOR; log.info(eol + "<====" + eol + "Setup new object cache instance on CLASS LEVEL for" + eol + "PersistenceBroker: " + broker + eol + "descriptorBasedCache: " + descriptorBasedCaches + eol + "Class: " + targetClass + eol + "ObjectCache: " + ocd + eol + "====>"); } retval = prepareAndAddCache(targetClass, ocd); } } } else { synchronized (caches) { retval = lookupCache(ocd); if (retval == null) { if (log.isEnabledFor(Logger.INFO)) { String eol = SystemUtils.LINE_SEPARATOR; log.info(eol + "<====" + eol + "Setup new object cache instance on CLASS LEVEL for" + eol + "PersistenceBroker: " + broker + eol + "descriptorBasedCache: " + descriptorBasedCaches + eol + "class: " + targetClass + eol + "ObjectCache: " + ocd + eol + "====>"); } retval = prepareAndAddCache(ocd, ocd); } } } } // use a jdbc-connection-descriptor level cache else { if (isExcluded(targetClass)) { if (log.isDebugEnabled()) log.debug("Class '" + targetClass.getName() + "' is excluded from being cached"); retval = DUMMY_CACHE; } else { String jcdAlias = broker.serviceConnectionManager().getConnectionDescriptor().getJcdAlias(); synchronized (caches) { retval = lookupCache(jcdAlias); if (retval == null) { if (log.isEnabledFor(Logger.INFO)) { String eol = SystemUtils.LINE_SEPARATOR; log.info(eol + "<====" + eol + "Setup new object cache instance on CONNECTION LEVEL for" + eol + "PersistenceBroker: " + broker + eol + "descriptorBasedCache: " + descriptorBasedCaches + eol + "Connection jcdAlias: " + jcdAlias + eol + "Calling class: " + targetClass + "ObjectCache: " + ocd + eol + "====>"); } retval = prepareAndAddCache(jcdAlias, ocd); } } } } } return retval; }
From source file:org.apache.ojb.broker.core.IdentityFactoryImpl.java
/** * Helper method which supports creation of proper error messages. * * @param ex An exception to include or <em>null</em>. * @param message The error message or <em>null</em>. * @param objectToIdentify The current used object or <em>null</em>. * @param topLevelClass The object top-level class or <em>null</em>. * @param realClass The object real class or <em>null</em>. * @param pks The associated PK values of the object or <em>null</em>. * @return The generated exception./*from w ww . java 2s . c o m*/ */ private PersistenceBrokerException createException(final Exception ex, String message, final Object objectToIdentify, Class topLevelClass, Class realClass, Object[] pks) { final String eol = SystemUtils.LINE_SEPARATOR; StringBuffer msg = new StringBuffer(); if (message == null) { msg.append("Unexpected error: "); } else { msg.append(message).append(" :"); } if (topLevelClass != null) msg.append(eol).append("objectTopLevelClass=").append(topLevelClass.getName()); if (realClass != null) msg.append(eol).append("objectRealClass=").append(realClass.getName()); if (pks != null) msg.append(eol).append("pkValues=").append(ArrayUtils.toString(pks)); if (objectToIdentify != null) msg.append(eol).append("object to identify: ").append(objectToIdentify); if (ex != null) { // add causing stack trace Throwable rootCause = ExceptionUtils.getRootCause(ex); if (rootCause != null) { msg.append(eol).append("The root stack trace is --> "); String rootStack = ExceptionUtils.getStackTrace(rootCause); msg.append(eol).append(rootStack); } return new PersistenceBrokerException(msg.toString(), ex); } else { return new PersistenceBrokerException(msg.toString()); } }
From source file:org.apache.ojb.broker.Identity.java
private ClassNotPersistenceCapableException createException(String msg, final Object objectToIdentify, final Exception e) { final String eol = SystemUtils.LINE_SEPARATOR; if (msg == null) { msg = "Unexpected error:"; }/*www . jav a2s.com*/ if (e != null) { return new ClassNotPersistenceCapableException(msg + eol + "objectTopLevelClass=" + (m_objectsTopLevelClass != null ? m_objectsTopLevelClass.getName() : null) + eol + "objectRealClass=" + (m_objectsRealClass != null ? m_objectsRealClass.getName() : null) + eol + "pkValues=" + (m_pkValues != null ? ArrayUtils.toString(m_pkValues) : null) + (objectToIdentify != null ? (eol + "object to identify: " + objectToIdentify) : ""), e); } else { return new ClassNotPersistenceCapableException(msg + eol + "objectTopLevelClass=" + (m_objectsTopLevelClass != null ? m_objectsTopLevelClass.getName() : null) + eol + "objectRealClass=" + (m_objectsRealClass != null ? m_objectsRealClass.getName() : null) + eol + "pkValues=" + (m_pkValues != null ? ArrayUtils.toString(m_pkValues) : null) + eol + "object to identify: " + objectToIdentify); } }