本文整理汇总了Java中org.apache.commons.io.output.NullWriter类的典型用法代码示例。如果您正苦于以下问题:Java NullWriter类的具体用法?Java NullWriter怎么用?Java NullWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NullWriter类属于org.apache.commons.io.output包,在下文中一共展示了NullWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkBusesValues
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkBusesValues() {
assertTrue(BusesValidation.checkBuses("test", loadP, loadQ, genP, genQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ,
lineP, lineQ, twtP, twtQ, tltP, tltQ, looseConfig, NullWriter.NULL_WRITER));
assertFalse(BusesValidation.checkBuses("test", loadP, loadQ, genP, genQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ,
lineP, lineQ, twtP, twtQ, tltP, tltQ, strictConfig, NullWriter.NULL_WRITER));
assertFalse(BusesValidation.checkBuses("test", loadP, 174.4932f, genP, genQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ,
lineP, lineQ, twtP, twtQ, tltP, tltQ, looseConfig, NullWriter.NULL_WRITER));
// check NaN values
assertFalse(BusesValidation.checkBuses("test", Double.NaN, loadQ, genP, genQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ,
lineP, lineQ, twtP, twtQ, tltP, tltQ, looseConfig, NullWriter.NULL_WRITER));
assertFalse(BusesValidation.checkBuses("test", loadP, loadQ, genP, genQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ,
lineP, lineQ, twtP, Double.NaN, tltP, tltQ, looseConfig, NullWriter.NULL_WRITER));
looseConfig.setOkMissingValues(true);
assertTrue(BusesValidation.checkBuses("test", Double.NaN, loadQ, genP, genQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ,
lineP, lineQ, twtP, twtQ, tltP, tltQ, looseConfig, NullWriter.NULL_WRITER));
assertTrue(BusesValidation.checkBuses("test", loadP, loadQ, genP, genQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ,
lineP, lineQ, twtP, Double.NaN, tltP, tltQ, looseConfig, NullWriter.NULL_WRITER));
looseConfig.setOkMissingValues(false);
}
示例2: checkShuntsValues
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkShuntsValues() {
// “p” is always NaN
assertTrue(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
p = 1f;
assertFalse(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
p = Float.NaN;
// “q” = - bPerSection * currentSectionCount * v^2
assertTrue(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
q = 170.52f;
assertFalse(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
assertTrue(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, looseConfig, NullWriter.NULL_WRITER));
q = 171.52f;
assertFalse(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, looseConfig, NullWriter.NULL_WRITER));
q = 170.50537f;
// check with NaN values
assertFalse(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, Float.NaN, v, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
assertFalse(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, Float.NaN, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
strictConfig.setOkMissingValues(true);
assertTrue(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, Float.NaN, v, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
assertTrue(ShuntCompensatorsValidation.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, Float.NaN, qMax, nominalV, strictConfig, NullWriter.NULL_WRITER));
}
示例3: visitRule
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Override
public Object visitRule(VtlRule rule) throws VilException {
net.ssehub.easy.instantiation.core.model.templateModel.ITracer tracer
= TracerFactory.createTemplateLanguageTracer();
TracerFactory.registerTemplateLanguageTracer(tracer);
Writer writer = new NullWriter(); // not for reuse
Map<String, Object> localParam = new HashMap<String, Object>(); // by default
localParam.put(PARAM_CONFIG, environment.getTopLevelConfiguration());
localParam.put(PARAM_TARGET, null); // for now
TemplateLangExecution exec = new TemplateLangExecution(tracer, writer, localParam);
Def def = rule.getDef();
Template template = (Template) def.getParent();
exec.getRuntimeEnvironment().switchContext(template);
exec.visitModelHeader(template);
Object result = def.accept(exec);
TracerFactory.unregisterTemplateLanguageTracer(tracer);
return result;
}
示例4: FastaReferenceWriter
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
/**
* Creates a reference FASTA file writer.
* <p>
* You can specify a specific path for the index and dictionary file. If either set to {@code null} such
* a file won't be generated.
* </p>
*
* @param fastaFile the output fasta file path.
* @param indexFile the path of the index file, if requested, {@code null} if none should be generated.
* @param dictFile the path of the dictFile, if requested, {@code null} if nono should be generated.
* @throws IllegalArgumentException if {@code fastaFile} is {@code null} or {@code basesPerLine} is 0 or negative.
* @throws IOException if such exception is thrown when accessing the output path resources.
*/
public FastaReferenceWriter(final Path fastaFile, final int basesPerLine, final Path indexFile, final Path dictFile)
throws IOException
{
// This code is a slight repeat of {@link #FastaReferenceWriter(OutputStream,int,OutputStream,OutputStream)
// for the sake of avoiding creating output if basesPerLine is invalid.
this.defaultBasePerLine = checkBasesPerLine(basesPerLine);
this.fastaStream = new CountingOutputStream(Files.newOutputStream(Utils.nonNull(fastaFile)));
this.indexWriter = indexFile == null ? new NullWriter() : new OutputStreamWriter(Files.newOutputStream(indexFile), CHARSET);
final BufferedWriter dictWriter = new BufferedWriter(dictFile == null ? new NullWriter() : new OutputStreamWriter(Files.newOutputStream(dictFile), CHARSET));
this.dictWriter = dictWriter;
this.dictCodec = new SAMSequenceDictionaryCodec(dictWriter);
this.dictCodec.encodeHeaderLine(false);
this.sequenceNamesAndSizes = new LinkedHashMap<>();
}
示例5: testSuccess
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void testSuccess() throws UnsupportedEncodingException, IOException {
final AppStatus appStatus = new AppStatus();
final StatusWebHandler statusWeb = new StatusWebHandler();
statusWeb.setAppStatus(appStatus);
statusWeb.setApplicationName("test");
final Map<String, IPage> pages = new HashMap<String, IPage>();
final StatusPage page = new StatusPage();
pages.put(page.getId(), page);
statusWeb.setPages(pages);
statusWeb.init();
final HttpServletRequest servlet = mock(HttpServletRequest.class);
final HttpServletRequest request = mock(HttpServletRequest.class);
final HttpServletResponse response = mock(HttpServletResponse.class);
final StubServletOutputStream sos = new StubServletOutputStream();
when(response.getWriter()).thenReturn(new PrintWriter(new NullWriter()));
when(response.getOutputStream()).thenReturn(sos);
page.doGet(statusWeb, request, response);
verify(response).setStatus(200);
}
示例6: processSourceFile
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
private void processSourceFile(VelocityEngine engine,
VelocityContext context, File sourceFile, boolean shouldWriteOutput) {
final Template sourceTemplate;
try {
final String relativeFileName = configuration
.calculateRelativeSourceFileName(sourceFile);
sourceTemplate = engine.getTemplate(relativeFileName, "UTF-8");
final StringWriter sw = shouldWriteOutput ? new StringWriter()
: null;
final NullWriter nw = shouldWriteOutput ? null : new NullWriter();
final Writer w = shouldWriteOutput ? sw : nw;
sourceTemplate.merge(context, w);
if (shouldWriteOutput) {
String content = sw.toString();
sw.close();
File file = new File(configuration.getTargetDirectoryName()
+ "/" + relativeFileName);
writer.write(file, content, "UTF-8");
} else {
nw.close();
}
} catch (Exception e) {
LOG.error("", e);
}
}
示例7: checkWarnings
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkWarnings() {
schemaRule.generate(schema, "com.example", config);
schemaRule.compile(compiler, new NullWriter(), new ArrayList<File>(), config);
List<Diagnostic<? extends JavaFileObject>> warnings = warnings(schemaRule.getDiagnostics());
assertThat(warnings, matcher);
}
示例8: checkSvcs
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkSvcs() {
// active power should be equal to 0
assertTrue(StaticVarCompensatorsValidation.checkSVCs(svc, strictConfig, NullWriter.NULL_WRITER));
Mockito.when(svcTerminal.getP()).thenReturn(-39.8f);
assertFalse(StaticVarCompensatorsValidation.checkSVCs(svc, strictConfig, NullWriter.NULL_WRITER));
// the unit is disconnected
Mockito.when(svcBusView.getBus()).thenReturn(null);
assertTrue(StaticVarCompensatorsValidation.checkSVCs(svc, strictConfig, NullWriter.NULL_WRITER));
}
示例9: checkNetworkSvcs
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkNetworkSvcs() {
Network network = Mockito.mock(Network.class);
Mockito.when(network.getId()).thenReturn("network");
Mockito.when(network.getStaticVarCompensatorStream()).thenAnswer(dummy -> Stream.of(svc));
assertTrue(StaticVarCompensatorsValidation.checkSVCs(network, looseConfig, NullWriter.NULL_WRITER));
}
示例10: checkNetworkGenerators
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkNetworkGenerators() {
Network.BusView networkBusView = Mockito.mock(Network.BusView.class);
Mockito.when(networkBusView.getBusStream()).thenAnswer(dummy -> Stream.of(bus));
Network network = Mockito.mock(Network.class);
Mockito.when(network.getId()).thenReturn("network");
Mockito.when(network.getBusView()).thenReturn(networkBusView);
assertTrue(BusesValidation.checkBuses(network, looseConfig, NullWriter.NULL_WRITER));
assertFalse(BusesValidation.checkBuses(network, strictConfig, NullWriter.NULL_WRITER));
}
示例11: checkGenerators
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkGenerators() {
// active power should be equal to setpoint
assertTrue(GeneratorsValidation.checkGenerators(generator, strictConfig, NullWriter.NULL_WRITER));
Mockito.when(genTerminal.getP()).thenReturn(-39.8f);
assertFalse(GeneratorsValidation.checkGenerators(generator, strictConfig, NullWriter.NULL_WRITER));
// the unit is disconnected
Mockito.when(genBusView.getBus()).thenReturn(null);
assertTrue(GeneratorsValidation.checkGenerators(generator, strictConfig, NullWriter.NULL_WRITER));
}
示例12: checkNetworkGenerators
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkNetworkGenerators() {
Bus genBus1 = Mockito.mock(Bus.class);
Mockito.when(genBus1.getV()).thenReturn(v);
BusView genBusView1 = Mockito.mock(BusView.class);
Mockito.when(genBusView1.getBus()).thenReturn(genBus1);
Terminal genTerminal1 = Mockito.mock(Terminal.class);
Mockito.when(genTerminal1.getP()).thenReturn(p);
Mockito.when(genTerminal1.getQ()).thenReturn(q);
Mockito.when(genTerminal1.getBusView()).thenReturn(genBusView1);
ReactiveLimits genReactiveLimits1 = Mockito.mock(ReactiveLimits.class);
Mockito.when(genReactiveLimits1.getMinQ(Mockito.anyFloat())).thenReturn(minQ);
Mockito.when(genReactiveLimits1.getMaxQ(Mockito.anyFloat())).thenReturn(maxQ);
Generator generator1 = Mockito.mock(Generator.class);
Mockito.when(generator1.getId()).thenReturn("gen");
Mockito.when(generator1.getTerminal()).thenReturn(genTerminal1);
Mockito.when(generator1.getTargetP()).thenReturn(targetP);
Mockito.when(generator1.getTargetQ()).thenReturn(targetQ);
Mockito.when(generator1.getTargetV()).thenReturn(targetV);
Mockito.when(generator1.getReactiveLimits()).thenReturn(genReactiveLimits1);
assertTrue(GeneratorsValidation.checkGenerators(generator1, strictConfig, NullWriter.NULL_WRITER));
Network network = Mockito.mock(Network.class);
Mockito.when(network.getId()).thenReturn("network");
Mockito.when(network.getGeneratorStream()).thenAnswer(dummy -> Stream.of(generator, generator1));
assertTrue(GeneratorsValidation.checkGenerators(network, looseConfig, NullWriter.NULL_WRITER));
}
示例13: checkShunts
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkShunts() {
// “q” = - bPerSection * currentSectionCount * v^2
assertTrue(ShuntCompensatorsValidation.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER));
Mockito.when(shuntTerminal.getQ()).thenReturn(171.52f);
assertFalse(ShuntCompensatorsValidation.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER));
// if the shunt is disconnected then either “q” is not defined or “q” is 0
Mockito.when(shuntBusView.getBus()).thenReturn(null);
assertFalse(ShuntCompensatorsValidation.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER));
Mockito.when(shuntTerminal.getQ()).thenReturn(Float.NaN);
assertTrue(ShuntCompensatorsValidation.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER));
}
示例14: checkNetworkShunts
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkNetworkShunts() {
Network network = Mockito.mock(Network.class);
Mockito.when(network.getId()).thenReturn("network");
Mockito.when(network.getShuntStream()).thenAnswer(dummy -> Stream.of(shunt));
assertTrue(ShuntCompensatorsValidation.checkShunts(network, strictConfig, NullWriter.NULL_WRITER));
}
示例15: checkLineFlows
import org.apache.commons.io.output.NullWriter; //导入依赖的package包/类
@Test
public void checkLineFlows() {
assertTrue(FlowsValidation.checkFlows(line1, looseConfig, NullWriter.NULL_WRITER));
assertFalse(FlowsValidation.checkFlows(line1, strictConfig, NullWriter.NULL_WRITER));
Mockito.when(bus1.isInMainConnectedComponent()).thenReturn(false);
Mockito.when(bus2.isInMainConnectedComponent()).thenReturn(false);
assertTrue(FlowsValidation.checkFlows(line1, strictConfig, NullWriter.NULL_WRITER));
}