@Test public void testSampleOccurred() throws IOException { System.out.println("sampleOccurred"); SampleResult res = new SampleResult(); res.setResponseData("test".getBytes()); SampleEvent e = new SampleEvent(res, "Test"); FlexibleFileWriter instance = new FlexibleFileWriter(); instance.setColumns("isSuccsessful|\\t||\\t|latency"); String tmpFile = File.createTempFile("ffw_test_", ".txt").getAbsolutePath(); instance.setFilename(tmpFile); instance.testStarted(); for (int n = 0; n < 10; n++) { String exp = "0\t|\t" + n; System.out.println(exp); res.setLatency(n); res.setSampleLabel("n" + n); instance.sampleOccurred(e); } instance.testEnded(); assertTrue(tmpFile.length() > 0); }
@Override public void sampleOccurred(SampleEvent evt) { if (fileChannel == null || !fileChannel.isOpen()) { if (log.isWarnEnabled()) { log.warn("File writer is closed! Maybe test has already been stopped"); } return; } ByteBuffer buf = ByteBuffer.allocateDirect(writeBufferSize); for (int n = 0; n < compiledConsts.length; n++) { if (compiledConsts[n] != null) { synchronized (compiledConsts) { buf.put(compiledConsts[n].duplicate()); } } else { if (!appendSampleResultField(buf, evt.getResult(), compiledFields[n])) { appendSampleVariable(buf, evt, compiledVars[n]); } } } buf.flip(); try { syncWrite(buf); } catch (IOException ex) { log.error("Problems writing to file", ex); } }
FlexibleFileWriter extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent evt) { if (fileChannel == null || !fileChannel.isOpen()) { if (log.isWarnEnabled()) { log.warn("File writer is closed! Maybe test has already been stopped"); } return; } ByteBuffer buf = ByteBuffer.allocateDirect(writeBufferSize); for (int n = 0; n < compiledConsts.length; n++) { if (compiledConsts[n] != null) { synchronized (compiledConsts) { buf.put(compiledConsts[n].duplicate()); } } else { if (!appendSampleResultField(buf, evt.getResult(), compiledFields[n])) { appendSampleVariable(buf, evt, compiledVars[n]); } } } buf.flip(); try { syncWrite(buf); } catch (IOException ex) { log.error("Problems writing to file", ex); } } }
FlexibleFileWriter extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent evt) { if (fileChannel == null || !fileChannel.isOpen()) { if (log.isWarnEnabled()) { log.warn("File writer is closed! Maybe test has already been stopped"); } return; } ByteBuffer buf = ByteBuffer.allocateDirect(writeBufferSize); for (int n = 0; n < compiledConsts.length; n++) { if (compiledConsts[n] != null) { synchronized (compiledConsts) { buf.put(compiledConsts[n].duplicate()); } } else { if (!appendSampleResultField(buf, evt.getResult(), compiledFields[n])) { appendSampleVariable(buf, evt, compiledVars[n]); } } } buf.flip(); try { syncWrite(buf); } catch (IOException ex) { log.error("Problems writing to file", ex); } } FlexibleFileWriter(); }
FlexibleFileWriter extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent evt) { if (fileChannel == null || !fileChannel.isOpen()) { if (log.isWarnEnabled()) { log.warn("File writer is closed! Maybe test has already been stopped"); } return; } ByteBuffer buf = ByteBuffer.allocateDirect(writeBufferSize); for (int n = 0; n < compiledConsts.length; n++) { if (compiledConsts[n] != null) { synchronized (compiledConsts) { buf.put(compiledConsts[n].duplicate()); } } else { if (!appendSampleResultField(buf, evt.getResult(), compiledFields[n])) { appendSampleVariable(buf, evt, compiledVars[n]); } } } buf.flip(); try { syncWrite(buf); } catch (IOException ex) { log.error("Problems writing to file", ex); } } FlexibleFileWriter(); @Override void sampleStarted(SampleEvent e); @Override void sampleStopped(SampleEvent e); @Override void testStarted(); @Override void testStarted(String host); @Override void testEnded(); @Override void testEnded(String host); void setFilename(String name); String getFilename(); void setColumns(String cols); String getColumns(); boolean isOverwrite(); void setOverwrite(boolean ov); void setFileHeader(String str); String getFileHeader(); void setFileFooter(String str); String getFileFooter(); @Override void sampleOccurred(SampleEvent evt); }
FlexibleFileWriter extends AbstractListenerElement implements SampleListener, Serializable,
        TestStateListener, Remoteable, NoThreadClone { @Override public void sampleOccurred(SampleEvent evt) { if (fileChannel == null || !fileChannel.isOpen()) { if (log.isWarnEnabled()) { log.warn("File writer is closed! Maybe test has already been stopped"); } return; } ByteBuffer buf = ByteBuffer.allocateDirect(writeBufferSize); for (int n = 0; n < compiledConsts.length; n++) { if (compiledConsts[n] != null) { synchronized (compiledConsts) { buf.put(compiledConsts[n].duplicate()); } } else { if (!appendSampleResultField(buf, evt.getResult(), compiledFields[n])) { appendSampleVariable(buf, evt, compiledVars[n]); } } } buf.flip(); try { syncWrite(buf); } catch (IOException ex) { log.error("Problems writing to file", ex); } } FlexibleFileWriter(); @Override void sampleStarted(SampleEvent e); @Override void sampleStopped(SampleEvent e); @Override void testStarted(); @Override void testStarted(String host); @Override void testEnded(); @Override void testEnded(String host); void setFilename(String name); String getFilename(); void setColumns(String cols); String getColumns(); boolean isOverwrite(); void setOverwrite(boolean ov); void setFileHeader(String str); String getFileHeader(); void setFileFooter(String str); String getFileFooter(); @Override void sampleOccurred(SampleEvent evt); static final String AVAILABLE_FIELDS; }