本文整理汇总了Java中org.databene.commons.SystemInfo类的典型用法代码示例。如果您正苦于以下问题:Java SystemInfo类的具体用法?Java SystemInfo怎么用?Java SystemInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SystemInfo类属于org.databene.commons包,在下文中一共展示了SystemInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: environmentFileName
import org.databene.commons.SystemInfo; //导入依赖的package包/类
public static String environmentFileName(String environment) throws IOException {
String filename = environment + ".env.properties";
File file = FileUtil.getFileIgnoreCase(new File(filename), false);
if (!file.exists()) {
File defaultUserHomeFile = new File(SystemInfo.getUserHome() + SystemInfo.getFileSeparator() + "databene", filename);
file = FileUtil.getFileIgnoreCase(defaultUserHomeFile, false);
}
String path;
if (file.exists()) {
path = file.getCanonicalPath();
} else if (IOUtil.isURIAvailable(filename)) {
path = filename;
} else {
throw new ConfigurationError("No environment definition '" + filename + "' found");
}
return path;
}
示例2: format
import org.databene.commons.SystemInfo; //导入依赖的package包/类
public static String format(ResultSet resultSet) throws SQLException {
StringBuilder builder = new StringBuilder();
// format column names
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();
for (int i = 1; i <= columnCount; i++)
builder.append(metaData.getColumnName(i)).append(i < columnCount ? ", " : SystemInfo.getLineSeparator());
// format cells
Object parsed = parseAndSimplifyResultSet(resultSet);
if (parsed instanceof Object[][]) {
for (Object[] row : (Object[][]) parsed) {
builder.append(ArrayFormat.format(", ", row)).append(SystemInfo.getLineSeparator());
}
} else
builder.append(ToStringConverter.convert(parsed, "null"));
return builder.toString();
}
示例3: main
import org.databene.commons.SystemInfo; //导入依赖的package包/类
/** Main method of the class.
* @param args an array of length one, containing the fully qualified name of the class for which to generate Excel documents
* @throws Exception if an error occurs */
public static void main(String[] args) throws Exception {
checkArguments(args);
// create a new AludraTest instance to have configuration framework available
AludraTest aludraTest = AludraTest.startFramework();
try {
AludraTestConfig config = aludraTest.getServiceManager().newImplementorInstance(AludraTestConfig.class);
Class<?> testClass = getTestClass(args);
List<Method> testMethodsWithExcelSource = WizardUtil.getTestMethodsWithExcelSource(testClass);
if (!testMethodsWithExcelSource.isEmpty()) {
LOGGER.info("Generating Excel documents for test class {}", testClass.getName());
for (Method testMethod : testMethodsWithExcelSource) {
File testDataRootFolder = new File(SystemInfo.getCurrentDir(), config.getXlsRootPath()).getCanonicalFile();
JavaBeanExcelDocumentMapper.createOrMergeDocuments(testMethod, testDataRootFolder);
}
}
else {
LOGGER.info("Test class {} does not have test methods with Excel sources", testClass.getName());
}
}
finally {
aludraTest.stopFramework();
}
}
示例4: assertInterchangesMatch
import org.databene.commons.SystemInfo; //导入依赖的package包/类
/** Asserts that two EDIFACT or X12 interchanges are equal.
* @throws FunctionalFailure if they are not equal. */
@Override
public void assertInterchangesMatch(String elementType, String elementName,
Interchange expected, Interchange actual,
EdiComparisonSettings settings) {
AggregateEdiDiff diffs = contentHandler.compare(expected, actual, settings);
memorizeInterchanges(expected, actual, diffs);
int detailCount = diffs.getEdiDetails().size();
if (detailCount > 0) {
String lf = SystemInfo.getLineSeparator();
StringBuilder message = new StringBuilder("Interchanges do not match. Found " + detailCount + " difference");
if (detailCount > 1) {
message.append("s");
}
for (EdiDiffDetail diff : diffs.getEdiDetails()) {
message.append(lf).append(diff);
}
throw new FunctionalFailure(message.toString());
}
}
示例5: checkSystem
import org.databene.commons.SystemInfo; //导入依赖的package包/类
public static void checkSystem(InfoPrinter printer) {
printVersionInfo(printer);
printer.printLines("Configured heap size limit: " + Runtime.getRuntime().maxMemory() / 1024 / 1024 + " MB");
try {
Class.forName("javax.script.ScriptEngine");
} catch (ClassNotFoundException e) {
CONFIG_LOGGER.error("You need to run benerator with Java 6 or greater!");
if (SystemInfo.isMacOsx())
CONFIG_LOGGER.error("Please check the manual for Java setup on Mac OS X.");
System.exit(BeneratorConstants.EXIT_CODE_ERROR);
}
VersionNumber javaVersion = VersionNumber.valueOf(VMInfo.getJavaVersion());
if (javaVersion.compareTo(VersionNumber.valueOf("1.6")) < 0)
CONFIG_LOGGER.warn("benerator is written for and tested under Java 6 - " +
"you managed to set up JSR 223, but may face other problems.");
if (Profiling.isEnabled())
CONFIG_LOGGER.warn("Profiling is active. This may lead to memory issues");
}
示例6: createBeneratorXml
import org.databene.commons.SystemInfo; //导入依赖的package包/类
public void createBeneratorXml() throws IOException, ParseException {
File descriptorFile = new File(setup.getProjectFolder(), "benerator.xml");
if (descriptorFile.exists()) { // not applicable for XML schema based generation
BufferedReader reader = IOUtil.getReaderForURI(descriptorFile.getAbsolutePath());
DefaultHTMLTokenizer tokenizer = new DefaultHTMLTokenizer(reader);
String lineSeparator = setup.getLineSeparator();
if (StringUtil.isEmpty(lineSeparator))
lineSeparator = SystemInfo.getLineSeparator();
LFNormalizingStringBuilder writer = new LFNormalizingStringBuilder(lineSeparator);
while (tokenizer.nextToken() != HTMLTokenizer.END)
processToken(setup, tokenizer, writer);
String xml = writer.toString();
xml = resolveVariables(xml);
IOUtil.writeTextFile(descriptorFile.getAbsolutePath(), xml, "UTF-8");
}
monitor.advance();
}
示例7: testAppend
import org.databene.commons.SystemInfo; //导入依赖的package包/类
@Test
public void testAppend() throws Exception {
if (SystemInfo.isWindows()) { // TODO make this test work on Windows
System.out.println("Skipping testAppend()");
return;
}
try {
CSVEntityExporter exporter = new CSVEntityExporter(customFile.getAbsolutePath(), "name");
exporter.setAppend(true);
cosumeAndClose(exporter);
CSVEntityExporter exporter2 = new CSVEntityExporter(customFile.getAbsolutePath(), "name");
exporter2.setAppend(true);
cosumeAndClose(exporter2);
assertEquals("name\r\nAlice\r\nBob\r\nAlice\r\nBob", getContent(customFile));
} finally {
customFile.delete();
}
}
示例8: testShell
import org.databene.commons.SystemInfo; //导入依赖的package包/类
@Test
public void testShell() {
String cmd = "echo 42";
if (SystemInfo.isWindows())
cmd = "cmd.exe /C " + cmd;
EvaluateStatement stmt = new EvaluateStatement(
true,
constant("result"),
constant(cmd),
null,
constant("shell"),
null,
null,
constant("fatal"),
constant(Encodings.UTF_8),
constant(false),
null,
null);
stmt.execute(context);
assertEquals(42, context.get("result"));
}
示例9: testGetGenerator
import org.databene.commons.SystemInfo; //导入依赖的package包/类
@Test
public void testGetGenerator() throws Exception {
String lf = SystemInfo.getLineSeparator();
String uri = "string://<setup>" + lf +
" <generate name='perGen' type='Person' count='3'>" + lf +
" <id name='id' type='int'/>" + lf +
" <attribute name='name' constant='Alice'/>" + lf +
" </generate>" + lf +
"</setup>";
context.setValidate(false);
Generator<?> generator = new DescriptorBasedGenerator(uri, "perGen", context);
assertEquals(Object.class, generator.getGeneratedType());
assertNotNull(generator);
generator.init(context);
for (int i = 0; i < 3; i++)
checkGeneration((Entity) GeneratorUtil.generateNonNull(generator), i + 1);
assertUnavailable(generator);
generator.close();
}
示例10: getEnvironmentNames
import org.databene.commons.SystemInfo; //导入依赖的package包/类
public static String[] getEnvironmentNames() {
File databeneFolder = new File(SystemInfo.getUserHome(), "databene");
String[] fileNames = databeneFolder.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return (name.toLowerCase().endsWith(".env.properties"));
}
});
String[] result = new String[fileNames.length];
for (int i = 0; i < fileNames.length; i++) {
String fileName = fileNames[i];
result[i] = fileName.substring(0, fileName.length() - ".env.properties".length());
}
return result;
}
示例11: testConfigurationFilePath
import org.databene.commons.SystemInfo; //导入依赖的package包/类
/** Returns the file path of the test configuration file for a given method. */
private String testConfigurationFilePath(Method method) {
Class<?> testClass = method.getDeclaringClass();
String localFileName = getTestConfigFileName(method);
if (localFileName == null) {
return null;
}
String absoluteFilePath = SystemInfo.getCurrentDir() + File.separator
+ aludraConfig.getXlsRootPath();
absoluteFilePath = absoluteFilePath.replace('/', File.separatorChar);
absoluteFilePath = absoluteFilePath + File.separatorChar + testClass.getName().replace('.', File.separatorChar);
return absoluteFilePath + File.separator + localFileName;
}
示例12: actionPerformed
import org.databene.commons.SystemInfo; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt) {
try {
Method testMethod = methodSelector.getSelectedItem();
File testDataRootFolder = new File(SystemInfo.getCurrentDir(), xlsRootPath).getCanonicalFile();
Collection<WorkbookTracker> workbooks = JavaBeanExcelDocumentMapper.createOrMergeDocuments(testMethod,
testDataRootFolder);
displayCreatedFiles(workbooks);
} catch (Exception e) {
JOptionPane.showMessageDialog(ExcelSettingsPane.this, e.getMessage(),
"Error in Excel Creator", JOptionPane.ERROR_MESSAGE);
}
}
示例13: writeInterchange
import org.databene.commons.SystemInfo; //导入依赖的package包/类
/** Writes an EDIFACT or X12 interchange to an {@link OutputStream}. */
@Override
public void writeInterchange(Interchange interchange, OutputStream out, boolean useLinefeed) {
try {
String lineFeed = (useLinefeed ? SystemInfo.getLineSeparator() : null);
new EdiWriter(lineFeed).writeInterchange(interchange, out);
} catch (IOException e) {
throw new TechnicalException("Error writing EDI document", e);
}
}
示例14: SeparatedFileWriter
import org.databene.commons.SystemInfo; //导入依赖的package包/类
/** Constructor which instantiates the internal writer and forwards the argument to it.
* @param out the writer to send the formatted character data to
* @param separator the separator character to use
* @param beanType the type of the beans to persist
* @param header the header to write */
public SeparatedFileWriter(Writer out, Class<? extends SeparatedFileBeanData> beanType, char separator, String header) {
this.writer = new BeanCSVWriter<SeparatedFileBeanData>(out, separator, false, SeparatedUtil.featureNames(beanType));
if (!StringUtil.isEmpty(header)) {
this.writer.setHeaderScript(new ConstantScript(header + SystemInfo.getLineSeparator()));
}
}
示例15: enterLine
import org.databene.commons.SystemInfo; //导入依赖的package包/类
/** Enters the provided text and appends a line feed.
* @param text the text to enter
* @return this */
@SuppressWarnings("unchecked")
public E enterLine(String text) {
String LF = SystemInfo.getLineSeparator();
service.perform().enter(processType, processName, processId, text + LF);
return (E) this;
}