List of usage examples for org.apache.commons.io.output NullOutputStream nullOutputStream
public static OutputStream nullOutputStream()
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}. * @throws IOException if the test Excel file will be not found *///from w w w. j a va 2 s . c o m @Test public void testImportAttributesGroupNotExists() throws IOException { PrintWriter logWriter = new PrintWriter(new NullOutputStream()); Resource excel = new ClassPathResource(EXCEL_TEST_FILES + "enumAttributesGroupTest.xls"); excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter); commit(); beginTransaction(); EnumAT enumAt = (EnumAT) attributeTypeService.getAttributeTypeByName("Test"); assertNotNull(enumAt); assertEquals(attributeTypeGroupService.getStandardAttributeTypeGroup(), enumAt.getAttributeTypeGroup()); }
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}. * @throws IOException if the test Excel file will be not found *///from w w w . java 2 s. co m @Test public void testImportAttributesActivatedTypes() throws IOException { PrintWriter logWriter = new PrintWriter(new NullOutputStream()); Resource excel = new ClassPathResource(EXCEL_TEST_FILES + "enumAttributesActivatedTypesTest.xls"); excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter); commit(); beginTransaction(); EnumAT enumAt = (EnumAT) attributeTypeService.getAttributeTypeByName("Test"); assertNotNull(enumAt); Set<BuildingBlockType> bbTypes = enumAt.getBuildingBlockTypes(); assertEquals(1, bbTypes.size()); assertTrue(bbTypes.contains( buildingBlockTypeService.getBuildingBlockTypeByType(TypeOfBuildingBlock.BUSINESSPROCESS))); }
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplValuesTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}. * @throws IOException if the test Excel file will be not found *///ww w . j a va 2s . c om @Test public void testImportAttributesRangeInvalid() throws IOException { PrintWriter logWriter = new PrintWriter(new NullOutputStream()); Resource excel = new ClassPathResource(EXCEL_TEST_FILES + "numberAttributesRangeInvalidTest.xls"); excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter); commit(); beginTransaction(); NumberAT numberAt = (NumberAT) attributeTypeService.getAttributeTypeByName("NumberAt"); assertNotNull(numberAt); assertEquals(false, numberAt.isRangeUniformyDistributed()); assertTrue(numberAt.getRangeValues().isEmpty()); }
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplValuesTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}. * @throws IOException if the test Excel file will be not found *//*from ww w . j a v a 2 s . c o m*/ @Test public void testImportAttributesRangeToMany() throws IOException { PrintWriter logWriter = new PrintWriter(new NullOutputStream()); Resource excel = new ClassPathResource(EXCEL_TEST_FILES + "numberAttributesRangeToManyTest.xls"); excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter); commit(); beginTransaction(); NumberAT numberAt = (NumberAT) attributeTypeService.getAttributeTypeByName("NumberAt"); assertNotNull(numberAt); assertEquals(false, numberAt.isRangeUniformyDistributed()); Set<RangeValue> ranges = numberAt.getRangeValues(); assertEquals(4, ranges.size()); Set<BigDecimal> values = Sets.newHashSet(); for (RangeValue rv : ranges) { values.add(rv.getValue()); } assertTrue(values.contains(new BigDecimal("1.00"))); assertTrue(values.contains(new BigDecimal("2.00"))); assertTrue(values.contains(new BigDecimal("3.00"))); assertTrue(values.contains(new BigDecimal("4.00"))); }
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}. * @throws IOException if the test Excel file will be not found *///from w w w .j a v a 2s . c o m @Test public void testImportAttributesActivatedTypesNotAvailable() throws IOException { PrintWriter logWriter = new PrintWriter(new NullOutputStream()); Resource excel = new ClassPathResource( EXCEL_TEST_FILES + "enumAttributesActivatedTypesNotAvailableTest.xls"); excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter); commit(); beginTransaction(); EnumAT enumAt = (EnumAT) attributeTypeService.getAttributeTypeByName("Test"); assertNotNull(enumAt); Set<BuildingBlockType> bbTypes = enumAt.getBuildingBlockTypes(); assertEquals(0, bbTypes.size()); }
From source file:com.github.trugath.jdalvikvm.VirtualMachineTest.java
private VirtualMachine run(final byte[] dexFileContent, final String mainClassName, final boolean runInNewThread) { lines.clear();//from w w w .ja va 2 s.c om final PrintStream oldErr = System.err; final PrintStream newOutAndErr = new PrintStream(new NullOutputStream()) { public synchronized void println(Object o) { println("" + o); } public void println(int x) { println("" + x); } public void println(long l) { println("" + l); } public void println(float f) { println("" + f); } public void println(double d) { println("" + d); } public synchronized void println(String x) { lines.add(x); } }; System.setOut(newOutAndErr); System.setErr(newOutAndErr); final VirtualMachine vm = new VirtualMachine() { protected void error(Throwable e) { System.setErr(oldErr); e.printStackTrace(); System.setErr(newOutAndErr); } }; vm.load(dexFileContent); if (runInNewThread) { new java.lang.Thread() { public void run() { vm.run(mainClassName, new String[0]); } }.start(); } else { vm.run(mainClassName, new String[0]); } return vm; }
From source file:br.gov.jfrj.siga.cd.AssinaturaDigital.java
@SuppressWarnings("unchecked") protected static byte[] getHasheableRangeFromPDF(byte[] pdf) throws Exception { PdfReader reader = new PdfReader(pdf); OutputStream fout = new NullOutputStream(); final int SIZE = 128000; PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); PdfSignatureAppearance sap = stp.getSignatureAppearance(); PdfDictionary dic = new PdfDictionary(); dic.put(PdfName.TYPE, PdfName.SIG);/* ww w.j ava 2s .c o m*/ dic.put(PdfName.FILTER, new PdfName("Adobe.PPKMS")); dic.put(PdfName.SUBFILTER, new PdfName("adbe.pkcs7.detached")); sap.setCryptoDictionary(dic); HashMap exc = new HashMap(); exc.put(PdfName.CONTENTS, new Integer(SIZE)); sap.preClose(exc); byte[] data = streamToByteArray(sap.getRangeStream()); byte[] outc = new byte[(SIZE - 2) / 2]; PdfDictionary dic2 = new PdfDictionary(); dic2.put(PdfName.CONTENTS, new PdfString(outc).setHexWriting(true)); sap.close(dic2); System.out.println("Hash: " + MessageDigest.getInstance("MD5").digest(data, 0, data.length)); return data; }
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}. * @throws IOException if the test Excel file will be not found *///from w w w .j ava 2 s . co m @Test public void testImportAttributesActivatedTypesInvalid() throws IOException { PrintWriter logWriter = new PrintWriter(new NullOutputStream()); Resource excel = new ClassPathResource(EXCEL_TEST_FILES + "enumAttributesActivatedTypesInvalidTest.xls"); excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter); commit(); beginTransaction(); EnumAT enumAt = (EnumAT) attributeTypeService.getAttributeTypeByName("Test"); assertNotNull(enumAt); Set<BuildingBlockType> bbTypes = enumAt.getBuildingBlockTypes(); assertEquals(0, bbTypes.size()); }
From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplValuesTest.java
/** * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}. * @throws IOException if the test Excel file will be not found *//*from www. j a va 2 s. c om*/ @Test public void testImportAttributesRangeMulti() throws IOException { PrintWriter logWriter = new PrintWriter(new NullOutputStream()); Resource excel = new ClassPathResource(EXCEL_TEST_FILES + "numberAttributesRangeMultiTest.xls"); excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter); commit(); beginTransaction(); NumberAT numberAt = (NumberAT) attributeTypeService.getAttributeTypeByName("NumberAt"); assertNotNull(numberAt); assertEquals(false, numberAt.isRangeUniformyDistributed()); Set<RangeValue> ranges = numberAt.getRangeValues(); assertEquals(2, ranges.size()); Set<BigDecimal> values = Sets.newHashSet(); for (RangeValue rv : ranges) { values.add(rv.getValue()); } assertTrue(values.contains(new BigDecimal("1.00"))); assertTrue(values.contains(new BigDecimal("2.00"))); }
From source file:cz.cuni.amis.planning4j.external.impl.itsimple.ItSimplePlanningProcess.java
public void destroyProcess() { if (process != null) { try {// w ww .ja v a 2 s . com process.exitValue(); //this throws an exception only iff the process has not yet stopped } catch (IllegalThreadStateException ingoredException) { InputStream is = process.getInputStream(); InputStream es = process.getErrorStream(); if (processPid > 0) { killPlannerByPID(); } process.destroy(); //should read and discard all output try { IOUtils.copy(is, new NullOutputStream()); } catch (IOException ex) { logger.debug("Error consuming output:" + ex.getMessage(), ex); } try { IOUtils.copy(es, new NullOutputStream()); } catch (IOException ex) { logger.debug("Error consuming error output:" + ex.getMessage(), ex); } } } }