本文整理汇总了Java中org.apache.jorphan.util.JOrphanUtils类的典型用法代码示例。如果您正苦于以下问题:Java JOrphanUtils类的具体用法?Java JOrphanUtils怎么用?Java JOrphanUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JOrphanUtils类属于org.apache.jorphan.util包,在下文中一共展示了JOrphanUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* @see java.lang.Thread#run()
*/
@Override
public void run() {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(is)); // default charset
String line = null;
while ((line = br.readLine()) != null)
{
buffer.append(line);
buffer.append("\r\n");
}
} catch (IOException e) {
buffer.append(e.getMessage());
}
finally
{
JOrphanUtils.closeQuietly(br);
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:StreamGobbler.java
示例2: fixPathEntry
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Fix a path:
* - replace "." by current directory
* - trim any trailing spaces
* - replace \ by /
* - replace // by /
* - remove all trailing /
*/
private static String fixPathEntry(String path){
if (path == null ) {
return null;
}
if (path.equals(".")) { // $NON-NLS-1$
return System.getProperty("user.dir"); // $NON-NLS-1$
}
path = path.trim().replace('\\', '/'); // $NON-NLS-1$ // $NON-NLS-2$
path = JOrphanUtils.substitute(path, "//", "/"); // $NON-NLS-1$// $NON-NLS-2$
while (path.endsWith("/")) { // $NON-NLS-1$
path = path.substring(0, path.length() - 1);
}
return path;
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:24,代码来源:ClassFinder.java
示例3: setText
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Create the file with the given string as content -- or replace it's
* content with the given string if the file already existed.
*
* @param body
* New content for the file.
*/
public void setText(String body) {
Writer writer = null;
try {
if (encoding == null) {
writer = new FileWriter(this);
} else {
writer = new OutputStreamWriter(new FileOutputStream(this), encoding);
}
writer.write(body);
writer.flush();
} catch (IOException ioe) {
log.error("", ioe);
} finally {
JOrphanUtils.closeQuietly(writer);
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:24,代码来源:TextFile.java
示例4: parseResponse
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Converts (X)HTML response to DOM object Tree.
* This version cares of charset of response.
* @param unicodeData
* @return the parsed document
*
*/
private Document parseResponse(String unicodeData)
throws UnsupportedEncodingException, IOException, ParserConfigurationException,SAXException,TidyException
{
//TODO: validate contentType for reasonable types?
// NOTE: responseData encoding is server specific
// Therefore we do byte -> unicode -> byte conversion
// to ensure UTF-8 encoding as required by XPathUtil
// convert unicode String -> UTF-8 bytes
byte[] utf8data = unicodeData.getBytes("UTF-8"); // $NON-NLS-1$
ByteArrayInputStream in = new ByteArrayInputStream(utf8data);
boolean isXML = JOrphanUtils.isXML(utf8data);
// this method assumes UTF-8 input data
return XPathUtil.makeDocument(in,false,false,useNameSpace(),isTolerant(),isQuiet(),showWarnings(),reportErrors()
,isXML, isDownloadDTDs());
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:24,代码来源:XPathExtractor.java
示例5: savePNGWithBatik
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Use Batik to save a PNG of the graph
*
* @param filename
* name of the file to store the image into
* @param image
* to be stored
*/
public void savePNGWithBatik(String filename, BufferedImage image) {
File outfile = new File(filename);
OutputStream fos = createFile(outfile);
if (fos == null) {
return;
}
PNGEncodeParam param = PNGEncodeParam.getDefaultEncodeParam(image);
PNGImageEncoder encoder = new PNGImageEncoder(fos, param);
try {
encoder.encode(image);
} catch (IOException e) {
JMeterUtils.reportErrorToUser("PNGImageEncoder reported: "+e.getMessage(), "Problem creating image file");
} finally {
JOrphanUtils.closeQuietly(fos);
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:25,代码来源:SaveGraphicsService.java
示例6: loadJMeterProperties
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Load the JMeter properties file; if not found, then
* default to "org/apache/jmeter/jmeter.properties" from the classpath
*
* <p>
* c.f. loadProperties
*
* @param file Name of the file from which the JMeter properties should be loaded
*/
public static void loadJMeterProperties(String file) {
Properties p = new Properties(System.getProperties());
InputStream is = null;
try {
File f = new File(file);
is = new FileInputStream(f);
p.load(is);
} catch (IOException e) {
try {
is =
ClassLoader.getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"); // $NON-NLS-1$
if (is == null) {
throw new RuntimeException("Could not read JMeter properties file:"+file);
}
p.load(is);
} catch (IOException ex) {
// JMeter.fail("Could not read internal resource. " +
// "Archive is broken.");
}
} finally {
JOrphanUtils.closeQuietly(is);
}
appProperties = p;
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:34,代码来源:JMeterUtils.java
示例7: loadJmeterProperties
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
public static void loadJmeterProperties(InputStream is){
Properties p = new Properties(System.getProperties());
try {
p.load(is);
} catch (IOException e) {
try {
is =
ClassLoader.getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"); // $NON-NLS-1$
if (is == null) {
throw new RuntimeException("Could not read JMeter properties file: jmeter.properties");
}
p.load(is);
} catch (IOException ex) {
// JMeter.fail("Could not read internal resource. " +
// "Archive is broken.");
}
} finally {
JOrphanUtils.closeQuietly(is);
}
appProperties = p;
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:23,代码来源:JMeterUtils.java
示例8: processFileOrScript
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Process the file or script from the test element.
* <p>
* Sets the following script variables:
* <ul>
* <li>FileName</li>
* <li>Parameters</li>
* <li>bsh.args</li>
* </ul>
* @param bsh the interpreter, not {@code null}
* @return the result of the script, may be {@code null}
*
* @throws JMeterException when working with the bsh fails
*/
protected Object processFileOrScript(BeanShellInterpreter bsh) throws JMeterException{
String fileName = getFilename();
String params = getParameters();
bsh.set("FileName", fileName);//$NON-NLS-1$
// Set params as a single line
bsh.set("Parameters", params); // $NON-NLS-1$
// and set as an array
bsh.set("bsh.args",//$NON-NLS-1$
JOrphanUtils.split(params, " "));//$NON-NLS-1$
if (fileName.length() == 0) {
return bsh.eval(getScript());
}
return bsh.source(fileName);
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:31,代码来源:BeanShellTestElement.java
示例9: testStarted
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
@Override
public void testStarted() {
this.setRunningVersion(true);
TestBeanHelper.prepare(this);
JMeterVariables variables = getThreadContext().getVariables();
String poolName = getDataSource();
if(JOrphanUtils.isBlank(poolName)) {
throw new IllegalArgumentException("Variable Name must not be empty for element:"+getName());
} else if (variables.getObject(poolName) != null) {
log.error("JDBC data source already defined for: "+poolName);
} else {
String maxPool = getPoolMax();
perThreadPoolSet = Collections.synchronizedSet(new HashSet<BasicDataSource>());
if (maxPool.equals("0")){ // i.e. if we want per thread pooling
variables.putObject(poolName, new DataSourceComponentImpl()); // pool will be created later
} else {
BasicDataSource src = initPool(maxPool);
synchronized(this){
dbcpDataSource = src;
variables.putObject(poolName, new DataSourceComponentImpl(dbcpDataSource));
}
}
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:25,代码来源:DataSourceElement.java
示例10: read
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Reads data until the defined EOM byte is reached.
* If there is no EOM byte defined, then reads until
* the end of the stream is reached.
* Response data is converted to hex-encoded binary
* @return hex-encoded binary string
* @throws ReadException when reading fails
*/
@Override
public String read(InputStream is) throws ReadException {
ByteArrayOutputStream w = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[4096];
int x = 0;
while ((x = is.read(buffer)) > -1) {
w.write(buffer, 0, x);
if (useEolByte && (buffer[x - 1] == eolByte)) {
break;
}
}
IOUtils.closeQuietly(w); // For completeness
final String hexString = JOrphanUtils.baToHexString(w.toByteArray());
if(log.isDebugEnabled()) {
log.debug("Read: " + w.size() + "\n" + hexString);
}
return hexString;
} catch (IOException e) {
throw new ReadException("", e, JOrphanUtils.baToHexString(w.toByteArray()));
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:32,代码来源:BinaryTCPClientImpl.java
示例11: read
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String read(InputStream is) throws ReadException{
byte[] msg = new byte[0];
int msgLen = 0;
byte[] lengthBuffer = new byte[lengthPrefixLen];
try {
if (is.read(lengthBuffer, 0, lengthPrefixLen) == lengthPrefixLen) {
msgLen = byteArrayToInt(lengthBuffer);
msg = new byte[msgLen];
int bytes = JOrphanUtils.read(is, msg, 0, msgLen);
if (bytes < msgLen) {
log.warn("Incomplete message read, expected: "+msgLen+" got: "+bytes);
}
}
String buffer = JOrphanUtils.baToHexString(msg);
if(log.isDebugEnabled()) {
log.debug("Read: " + msgLen + "\n" + buffer);
}
return buffer;
}
catch(IOException e) {
throw new ReadException("", e, JOrphanUtils.baToHexString(msg));
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:29,代码来源:LengthPrefixedBinaryTCPClientImpl.java
示例12: save
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Save the authentication data to a file.
*
* @param authFile
* path of the file to save the authentication data to
* @throws IOException
* when writing to the file fails
*/
public void save(String authFile) throws IOException {
File file = new File(authFile);
if (!file.isAbsolute()) {
file = new File(System.getProperty("user.dir"),authFile);
}
PrintWriter writer = null;
try {
writer = new PrintWriter(new FileWriter(file));
writer.println("# JMeter generated Authorization file");
for (int i = 0; i < getAuthObjects().size(); i++) {
Authorization auth = (Authorization) getAuthObjects().get(i).getObjectValue();
writer.println(auth.toString());
}
writer.flush();
writer.close();
} finally {
JOrphanUtils.closeQuietly(writer);
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:28,代码来源:AuthManager.java
示例13: getImplementation
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
public static HTTPAbstractImpl getImplementation(String impl, HTTPSamplerBase base){
if (HTTPSamplerBase.PROTOCOL_FILE.equals(base.getProtocol())) {
return new HTTPFileImpl(base);
}
if (JOrphanUtils.isBlank(impl)){
impl = DEFAULT_CLASSNAME;
}
if (IMPL_JAVA.equals(impl) || HTTP_SAMPLER_JAVA.equals(impl)) {
return new HTTPJavaImpl(base);
} else if (IMPL_HTTP_CLIENT3_1.equals(impl) || HTTP_SAMPLER_APACHE.equals(impl)) {
return new HTTPHC3Impl(base);
} else if (IMPL_HTTP_CLIENT4.equals(impl)) {
return new HTTPHC4Impl(base);
} else {
throw new IllegalArgumentException("Unknown implementation type: '"+impl+"'");
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:18,代码来源:HTTPSamplerFactory.java
示例14: writeFileToStream
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Write the content of a file to the output stream
*
* @param filename the filename of the file to write to the stream
* @param out the stream to write to
* @throws IOException
*/
private static void writeFileToStream(String filename, OutputStream out) throws IOException {
byte[] buf = new byte[1024];
// 1k - the previous 100k made no sense (there's tons of buffers
// elsewhere in the chain) and it caused OOM when many concurrent
// uploads were being done. Could be fixed by increasing the evacuation
// ratio in bin/jmeter[.bat], but this is better.
InputStream in = new BufferedInputStream(new FileInputStream(filename));
int read;
boolean noException = false;
try {
while ((read = in.read(buf)) > 0) {
out.write(buf, 0, read);
}
noException = true;
}
finally {
if(!noException) {
// Exception in progress
JOrphanUtils.closeQuietly(in);
} else {
in.close();
}
}
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:32,代码来源:PostWriter.java
示例15: getFileObjectContent
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Try to load an object from a provided file, so that it can be used as body
* for a JMS message.
* An {@link IllegalStateException} will be thrown if loading the object fails.
*
* @param path Path to the file that will be serialized
* @return Serialized object instance
*/
private static Serializable getFileObjectContent(final String path) {
Serializable readObject = null;
InputStream inputStream = null;
try {
inputStream = new BufferedInputStream(new FileInputStream(path));
XStream xstream = new XStream();
readObject = (Serializable) xstream.fromXML(inputStream, readObject);
} catch (Exception e) {
log.error(e.getLocalizedMessage(), e);
throw new IllegalStateException("Unable to load object instance from file:'"+path+"'", e);
} finally {
JOrphanUtils.closeQuietly(inputStream);
}
return readObject;
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:24,代码来源:PublisherSampler.java
示例16: load
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
private NodeList load() throws IOException, FileNotFoundException, ParserConfigurationException, SAXException,
TransformerException {
InputStream fis = null;
NodeList nl = null;
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
fis = new BufferedInputStream(new FileInputStream(fileName));
nl = XPathUtil.selectNodeList(builder.parse(fis), xpath);
if(log.isDebugEnabled()) {
log.debug("found " + nl.getLength());
}
} catch (TransformerException | SAXException
| ParserConfigurationException | IOException e) {
log.warn(e.toString());
throw e;
} finally {
JOrphanUtils.closeQuietly(fis);
}
return nl;
}
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:22,代码来源:XPathFileContainer.java
示例17: getCertificateDetails
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
public String[] getCertificateDetails()
{
if (isDynamicMode())
{
try
{
X509Certificate caCert = (X509Certificate)sslKeyStore.getCertificate(KeyToolUtils.getRootCAalias());
if (caCert == null)
{
return new String[] { "Could not find certificate" };
}
return new String[] { caCert.getSubjectX500Principal().toString(),
"Fingerprint(SHA1): " + JOrphanUtils.baToHexString(DigestUtils.sha1(caCert.getEncoded()), ' '),
"Created: " + caCert.getNotBefore().toString() };
}
catch (GeneralSecurityException e)
{
LOG.error("Problem reading root CA from keystore", e);
return new String[] { "Problem with root certificate", e.getMessage() };
}
}
return null; // should not happen
}
开发者ID:d0k1,项目名称:jsflight,代码行数:24,代码来源:JMeterProxyControl.java
示例18: setupClasslist
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void setupClasslist(){
classnameCombo.removeAllItems();
methodName.removeAllItems();
try
{
List<String> classList;
classList = ClassFinder.findClassesThatExtend(SPATHS, new Class [] {Specification.class});
ClassFilter filter = new ClassFilter();
filter.setPackages(JOrphanUtils.split(filterpkg.getText(), ",")); //$NON-NLS-1$
// change the classname drop down
Object[] clist = filter.filterArray(classList);
for (int idx=0; idx < clist.length; idx++) {
classnameCombo.addItem(clist[idx]);
}
}
catch (IOException e)
{
log.error("Exception getting interfaces.", e);
}
}
开发者ID:gabehamilton,项目名称:jmeter-spock-sampler,代码行数:22,代码来源:SpockSamplerGui.java
示例19: testStarted
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation") // call to TestBeanHelper.prepare() is intentional
public void testStarted() {
this.setRunningVersion(true);
TestBeanHelper.prepare(this);
JMeterVariables variables = getThreadContext().getVariables();
String poolName = getDataSource();
if(JOrphanUtils.isBlank(poolName)) {
throw new IllegalArgumentException("Variable Name must not be empty for element:"+getName());
} else if (variables.getObject(poolName) != null) {
log.error("JDBC data source already defined for: "+poolName);
} else {
String maxPool = getPoolMax();
perThreadPoolSet = Collections.synchronizedSet(new HashSet<ResourceLimitingJdbcDataSource>());
if (maxPool.equals("0")){ // i.e. if we want per thread pooling
variables.putObject(poolName, new DataSourceComponentImpl()); // pool will be created later
} else {
ResourceLimitingJdbcDataSource src=initPool(maxPool);
synchronized(this){
excaliburSource = src;
variables.putObject(poolName, new DataSourceComponentImpl(excaliburSource));
}
}
}
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:26,代码来源:DataSourceElement.java
示例20: read
import org.apache.jorphan.util.JOrphanUtils; //导入依赖的package包/类
/**
* Reads data until the defined EOM byte is reached.
* If there is no EOM byte defined, then reads until
* the end of the stream is reached.
* Response data is converted to hex-encoded binary
* @return hex-encoded binary string
* @throws ReadException
*/
@Override
public String read(InputStream is) throws ReadException {
ByteArrayOutputStream w = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[4096];
int x = 0;
while ((x = is.read(buffer)) > -1) {
w.write(buffer, 0, x);
if (useEolByte && (buffer[x - 1] == eolByte)) {
break;
}
}
IOUtils.closeQuietly(w); // For completeness
final String hexString = JOrphanUtils.baToHexString(w.toByteArray());
if(log.isDebugEnabled()) {
log.debug("Read: " + w.size() + "\n" + hexString);
}
return hexString;
} catch (IOException e) {
throw new ReadException("", e, JOrphanUtils.baToHexString(w.toByteArray()));
}
}
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:32,代码来源:BinaryTCPClientImpl.java
注:本文中的org.apache.jorphan.util.JOrphanUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论