org.apache.commons.io.output.NullOutputStream Java Examples
The following examples show how to use
org.apache.commons.io.output.NullOutputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseAndroidTest.java From kripton with Apache License 2.0 | 6 votes |
/** * Setup. */ @Before public void setup() { //final String value = System.getProperty(KRIPTON_DEBUG_MODE); final String value = System.getProperty(KRIPTON_DEBUG_MODE); if ("false".equals(value)) { ShadowLog.stream = new PrintStream(new NullOutputStream()); // we are in test, but we don't see log on System.out System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); } else { ShadowLog.stream = System.out; } KriptonLibrary.init(RuntimeEnvironment.application); }
Example #2
Source File: TransformationService.java From data-prep with Apache License 2.0 | 6 votes |
/** * Add the following preparation in cache. * * @param preparation the preparation to cache. * @param stepId the preparation step id. */ private void addPreparationInCache(PreparationDTO preparation, String stepId) { final ExportParameters exportParameters = new ExportParameters(); exportParameters.setPreparationId(preparation.getId()); exportParameters.setExportType("JSON"); exportParameters.setStepId(stepId); exportParameters.setDatasetId(preparation.getDataSetId()); final StreamingResponseBody streamingResponseBody = executeSampleExportStrategy(exportParameters); try { // the result is not important here as it will be cached ! streamingResponseBody.writeTo(new NullOutputStream()); } catch (IOException e) { throw new TDPException(UNEXPECTED_EXCEPTION, e); } }
Example #3
Source File: PreparationExportStrategyTest.java From data-prep with Apache License 2.0 | 6 votes |
@Test public void shouldUsedVersionedPreparation() throws IOException { // Given final ExportParameters parameters = new ExportParameters(); parameters.setExportType("JSON"); parameters.setPreparationId("prep-1234"); parameters.setStepId("step-1234"); final PreparationDTO preparation = new PreparationDTO(); preparation.setId("prep-1234"); preparation.setHeadId("step-1234"); configurePreparation(preparation, "prep-1234", "step-1234"); // When final StreamingResponseBody body = strategy.execute(parameters); body.writeTo(new NullOutputStream()); // Then final ArgumentCaptor<Configuration> captor = ArgumentCaptor.forClass(Configuration.class); verify(transformer).buildExecutable(any(), captor.capture()); assertEquals("prep-1234", captor.getValue().getPreparationId()); assertEquals("step-1234", captor.getValue().getPreparation().getHeadId()); }
Example #4
Source File: Dl4jMlpClassifier.java From wekaDeeplearning4j with GNU General Public License v3.0 | 6 votes |
/** * Custom serialization method. * * @param oos the object output stream */ private void writeObject(ObjectOutputStream oos) throws IOException { // figure out size of the written network CountingOutputStream cos = new CountingOutputStream(new NullOutputStream()); if (isInitializationFinished) { ModelSerializer.writeModel(model, cos, false); } modelSize = cos.getByteCount(); // default serialization oos.defaultWriteObject(); // Write layer configurations String[] layerConfigs = new String[layers.length]; for (int i = 0; i < layers.length; i++) { layerConfigs[i] = layers[i].getClass().getName() + "::" + weka.core.Utils.joinOptions(layers[i].getOptions()); } oos.writeObject(layerConfigs); // actually write the network if (isInitializationFinished) { ModelSerializer.writeModel(model, oos, false); } }
Example #5
Source File: PreparationExportStrategyTest.java From data-prep with Apache License 2.0 | 6 votes |
@Test public void shouldUsedHeadPreparation() throws IOException { // Given final ExportParameters parameters = new ExportParameters(); parameters.setExportType("JSON"); parameters.setPreparationId("prep-1234"); parameters.setStepId("head"); final PreparationDTO preparation = new PreparationDTO(); preparation.getSteps().add(Step.ROOT_STEP.id()); preparation.setId("prep-1234"); preparation.setHeadId("head"); configurePreparation(preparation, "prep-1234", "head"); // When final StreamingResponseBody body = strategy.execute(parameters); body.writeTo(new NullOutputStream()); // Then final ArgumentCaptor<Configuration> captor = ArgumentCaptor.forClass(Configuration.class); verify(transformer).buildExecutable(any(), captor.capture()); assertEquals("prep-1234", captor.getValue().getPreparationId()); assertEquals("head", captor.getValue().getPreparation().getHeadId()); }
Example #6
Source File: TransformationService.java From data-prep with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/apply", method = POST) @ApiOperation(value = "Run the transformation given the provided export parameters", notes = "This operation transforms the dataset or preparation using parameters in export parameters.") @VolumeMetered @AsyncOperation(conditionalClass = GetPrepContentAsyncCondition.class, // resultUrlGenerator = PreparationGetContentUrlGenerator.class, // executionIdGeneratorClass = ExportParametersExecutionIdGenerator.class // ) public StreamingResponseBody execute(@ApiParam( value = "Preparation id to apply.") @RequestBody @Valid @AsyncParameter @AsyncExecutionId final ExportParameters parameters) throws IOException { // Async behavior final ConditionalTest conditionalTest = applicationContext.getBean(GetPrepContentAsyncCondition.class); if (conditionalTest.apply(parameters)) { // write to cache executeSampleExportStrategy(parameters).writeTo(new NullOutputStream()); return outputStream -> { }; } else { // sync behavior return executeSampleExportStrategy(parameters); } }
Example #7
Source File: ListContainerLoopPerformanceTest.java From viritin with Apache License 2.0 | 6 votes |
public void loopAllEntitiesAndProperties() throws IOException { NullOutputStream nullOutputStream = new NullOutputStream(); List<Person> listOfPersons = Service.getListOfPersons(100 * 1000); long currentTimeMillis = System.currentTimeMillis(); ListContainer<Person> listContainer = new ListContainer<>( listOfPersons); Collection<?> ids = listContainer.getContainerPropertyIds(); for (int i = 0; i < listContainer.size(); i++) { Item item = listContainer.getItem(listOfPersons.get(i)); for (Object propertyId : ids) { Property itemProperty = item.getItemProperty(propertyId); final Object value = itemProperty.getValue(); nullOutputStream.write(value.toString().getBytes()); LOG.log(Level.FINEST, "Property: %s", value); } } LOG. log(Level.INFO, "Looping all properties in 100 000 Items took {0}ms", (System.currentTimeMillis() - currentTimeMillis)); }
Example #8
Source File: ListContainerLoopPerformanceTest.java From viritin with Apache License 2.0 | 6 votes |
public void loopAllEntitiesAndPropertiesWithBeanItemContainer() throws IOException { NullOutputStream nullOutputStream = new NullOutputStream(); List<Person> listOfPersons = Service.getListOfPersons(100 * 1000); long currentTimeMillis = System.currentTimeMillis(); BeanItemContainer<Person> c = new BeanItemContainer<>( Person.class, listOfPersons); Collection<?> ids = c.getContainerPropertyIds(); for (int i = 0; i < c.size(); i++) { Item item = c.getItem(listOfPersons.get(i)); for (Object propertyId : ids) { Property itemProperty = item.getItemProperty(propertyId); final Object value = itemProperty.getValue(); nullOutputStream.write(value.toString().getBytes()); LOG.log(Level.FINEST, "Property: %s", value); } } // ~ 350ms in 1.34, MacBook Pro (Retina, Mid 2012) 2.3Gz i7 // ~ + 3-10ms in 1.35, when changing ListContainer to use PropertyUtils instead of WrapDynaBean LOG. log(Level.INFO, "BIC from core: Looping all properties in 100 000 Items took {0}ms", (System.currentTimeMillis() - currentTimeMillis)); }
Example #9
Source File: ReleasableOutputStreamTest.java From data-prep with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { releasableOutputStream = new ReleasableOutputStream(new NullOutputStream(), () -> wasCalled.set(true)); failedReleasableOutputStream = new ReleasableOutputStream(new OutputStream() { @Override public void write(int b) throws IOException { throw new IOException("Oops"); } @Override public void flush() throws IOException { throw new IOException("Oops"); } }, () -> wasCalled.set(true)); }
Example #10
Source File: PreparationUtilsTest.java From data-prep with Apache License 2.0 | 6 votes |
@Test public void prettyPrint() throws Exception { // given final String version = versionService.version().getVersionId(); final List<Action> actions = getSimpleAction("uppercase", "column_name", "lastname"); final PreparationActions newContent = new PreparationActions(actions, version); final Step step = new Step(Step.ROOT_STEP.id(), newContent.id(), version); final Preparation preparation = new Preparation("#15325878", "1234", step.id(), version); repository.add(newContent); repository.add(step); repository.add(preparation); // when PreparationUtils.prettyPrint(repository, preparation, new NullOutputStream()); // Basic walk through code, no assert. }
Example #11
Source File: HttpClientRequestExecutorTest.java From esigate with Apache License 2.0 | 6 votes |
/** * Test that we don't have a NullpointerException when forcing the caching (ttl). * * @throws Exception */ public void testForcedTtlWith304ResponseCode() throws Exception { properties = new PropertiesBuilder() // .set(Parameters.REMOTE_URL_BASE, "http://localhost:8080") // .set(Parameters.TTL, 1000) // Default value .build(); createHttpClientRequestExecutor(); DriverRequest originalRequest = TestUtils.createDriverRequest(driver); originalRequest.getOriginalRequest().addHeader("If-Modified-Since", "Fri, 15 Jun 2012 21:06:25 GMT"); OutgoingRequest request = httpClientRequestExecutor.createOutgoingRequest(originalRequest, "http://localhost:8080", false); HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_NOT_MODIFIED, "Not Modified")); mockConnectionManager.setResponse(response); HttpResponse result = httpClientRequestExecutor.execute(request); if (result.getEntity() != null) { result.getEntity().writeTo(new NullOutputStream()); // We should have had a NullpointerException } }
Example #12
Source File: HttpClientRequestExecutorTest.java From esigate with Apache License 2.0 | 6 votes |
/** * Test that we don't have a NullpointerException when forcing the caching (ttl). * * @throws Exception */ public void testForcedTtlWith301ResponseCode() throws Exception { properties = new PropertiesBuilder() // .set(Parameters.REMOTE_URL_BASE, "http://localhost:8080") // .set(Parameters.TTL, 1000) // Default value .build(); createHttpClientRequestExecutor(); DriverRequest originalRequest = TestUtils.createDriverRequest(driver); OutgoingRequest request = httpClientRequestExecutor.createOutgoingRequest(originalRequest, "http://localhost:8080", true); HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_MOVED_PERMANENTLY, "Moved permanently")); response.addHeader("Location", "http://www.foo.com"); mockConnectionManager.setResponse(response); HttpResponse result = httpClientRequestExecutor.execute(request); if (result.getEntity() != null) { result.getEntity().writeTo(new NullOutputStream()); // We should have had a NullpointerException } }
Example #13
Source File: HttpClientRequestExecutorTest.java From esigate with Apache License 2.0 | 6 votes |
/** * Test that we don't have a NullpointerException when forcing the caching (ttl). * * @throws Exception */ public void testForcedTtlWith302ResponseCode() throws Exception { properties = new PropertiesBuilder() // .set(Parameters.REMOTE_URL_BASE, "http://localhost:8080") // .set(Parameters.TTL, 1000) // .build(); createHttpClientRequestExecutor(); DriverRequest originalRequest = TestUtils.createDriverRequest(driver); OutgoingRequest request = httpClientRequestExecutor.createOutgoingRequest(originalRequest, "http://localhost:8080", true); HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_MOVED_TEMPORARILY, "Moved temporarily")); response.addHeader("Location", "http://www.foo.com"); mockConnectionManager.setResponse(response); HttpResponse result = httpClientRequestExecutor.execute(request); if (result.getEntity() != null) { result.getEntity().writeTo(new NullOutputStream()); // We should have had a NullpointerException } }
Example #14
Source File: Dl4jMlpClassifier.java From wekaDeeplearning4j with GNU General Public License v3.0 | 6 votes |
/** * Custom serialization method. * * @param oos the object output stream */ private void writeObject(ObjectOutputStream oos) throws IOException { // figure out size of the written network CountingOutputStream cos = new CountingOutputStream(new NullOutputStream()); if (isInitializationFinished) { ModelSerializer.writeModel(model, cos, false); } modelSize = cos.getByteCount(); // default serialization oos.defaultWriteObject(); // Write layer configurations String[] layerConfigs = new String[layers.length]; for (int i = 0; i < layers.length; i++) { layerConfigs[i] = layers[i].getClass().getName() + "::" + weka.core.Utils.joinOptions(layers[i].getOptions()); } oos.writeObject(layerConfigs); // actually write the network if (isInitializationFinished) { ModelSerializer.writeModel(model, oos, false); } }
Example #15
Source File: ARCWriterTest.java From webarchive-commons with Apache License 2.0 | 6 votes |
public void testWriteGiantRecord() throws IOException { PrintStream dummyStream = new PrintStream(new NullOutputStream()); ARCWriter arcWriter = new ARCWriter( SERIAL_NO, dummyStream, new File("dummy"), new WriterPoolSettingsData( "", "", -1, false, null, null)); assertNotNull(arcWriter); // Start the record with an arbitrary 14-digit date per RFC2540 long now = System.currentTimeMillis(); long recordLength = org.apache.commons.io.FileUtils.ONE_GB * 3; arcWriter.write("dummy:uri", "application/octet-stream", "0.1.2.3", now, recordLength, new NullInputStream(recordLength)); arcWriter.close(); }
Example #16
Source File: GoogleStorageReadFeatureTest.java From cyberduck with GNU General Public License v3.0 | 6 votes |
@Test public void testDownloadGzip() throws Exception { final int length = 1457; final byte[] content = RandomUtils.nextBytes(length); final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path file = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final TransferStatus status = new TransferStatus().length(content.length); status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), status)); final OutputStream out = new GoogleStorageWriteFeature(session).write(file, status, new DisabledConnectionCallback()); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); out.close(); final InputStream in = new GoogleStorageReadFeature(session).read(file, status, new DisabledConnectionCallback()); assertNotNull(in); new StreamCopier(status, status).transfer(in, new NullOutputStream()); assertEquals(content.length, status.getOffset()); assertEquals(content.length, status.getLength()); in.close(); new GoogleStorageDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
Example #17
Source File: S3ReadFeatureTest.java From cyberduck with GNU General Public License v3.0 | 6 votes |
@Test public void testDownloadGzip() throws Exception { final int length = 1457; final byte[] content = RandomUtils.nextBytes(length); final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path file = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final TransferStatus status = new TransferStatus().length(content.length); status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), status)); final OutputStream out = new S3WriteFeature(session).write(file, status, new DisabledConnectionCallback()); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); out.close(); final InputStream in = new S3ReadFeature(session).read(file, status, new DisabledConnectionCallback()); assertNotNull(in); new StreamCopier(status, status).transfer(in, new NullOutputStream()); assertEquals(content.length, status.getOffset()); assertEquals(content.length, status.getLength()); in.close(); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
Example #18
Source File: SentrySchemaTool.java From incubator-sentry with Apache License 2.0 | 6 votes |
public void runBeeLine(String sqlScriptFile) throws IOException { List<String> argList = new ArrayList<String>(); argList.add("-u"); argList.add(connectionURL); argList.add("-d"); argList .add(driver); argList.add("-n"); argList.add(userName); argList.add("-p"); argList.add(passWord); argList.add("-f"); argList.add(sqlScriptFile); BeeLine beeLine = new BeeLine(); if (!verbose) { beeLine.setOutputStream(new PrintStream(new NullOutputStream())); // beeLine.getOpts().setSilent(true); } // beeLine.getOpts().setAllowMultiLineCommand(false); // beeLine.getOpts().setIsolation("TRANSACTION_READ_COMMITTED"); int status = beeLine.begin(argList.toArray(new String[0]), null); if (status != 0) { throw new IOException("Schema script failed, errorcode " + status); } }
Example #19
Source File: TestRDFXMLSerializer.java From incubator-taverna-language with Apache License 2.0 | 6 votes |
@Test public void workflowBundle() throws Exception { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); // To test that seeAlso URIs are stored serializer.workflowDoc(new NullOutputStream(), workflowBundle.getMainWorkflow(), URI.create(HELLOWORLD_RDF)); serializer.profileDoc(new NullOutputStream(), workflowBundle.getProfiles().getByName("tavernaWorkbench"), URI.create(TAVERNAWORKBENCH_RDF)); serializer.profileDoc(new NullOutputStream(), workflowBundle.getProfiles().getByName("tavernaServer"), URI.create(TAVERNASERVER_RDF)); serializer.workflowBundleDoc(outStream, URI.create("workflowBundle.rdf")); //System.out.write(outStream.toByteArray()); Document doc = parseXml(outStream); Element root = doc.getRootElement(); checkRoot(root); checkWorkflowBundleDocument(root); }
Example #20
Source File: SendFileXEP0096.java From jmeter-bzm-plugins with Apache License 2.0 | 6 votes |
@Override public void fileTransferRequest(FileTransferRequest request) { final IncomingFileTransfer transfer = request.accept(); Thread transferThread = new Thread(new Runnable() { public void run() { try { OutputStream os = new NullOutputStream(); InputStream is = transfer.recieveFile(); log.debug("Reading from stream: " + is.available()); IOUtils.copy(is, os); log.debug("Left in stream: " + is.available()); } catch (Exception e) { log.error("Failed incoming file transfer", e); } } }); transferThread.start(); }
Example #21
Source File: AbstractBaseTest.java From kripton with Apache License 2.0 | 6 votes |
/** * Setup. */ @Before public void setup() { final String value = System.getProperty(KRIPTON_DEBUG_MODE); if ("false".equals(value)) { // we are in test, but we don't see log on System.out System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); } // when we run junit test, AnnotationProcessor is always in TEST_MODE System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] (%2$s) %5$s %6$s%n"); KriptonBinder.registryBinder(new KriptonYamlContext()); KriptonBinder.registryBinder(new KriptonPropertiesContext()); KriptonBinder.registryBinder(new KriptonCborContext()); KriptonBinder.registryBinder(new KriptonSmileContext()); }
Example #22
Source File: BaseProcessorTest.java From kripton with Apache License 2.0 | 6 votes |
/** * Before. */ @Before public void before() { String value = System.getProperty(KRIPTON_DEBUG_MODE); String logEnabledvalue = System.getProperty(KRIPTON_GENERATE_LOG_MODE); // value = "true"; if ("false".equals(value)) { // we are in test, but we don't see log on System.out System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); } else { BaseProcessor.DEBUG_MODE = true; } if ("false".equals(logEnabledvalue)) { BaseProcessor.LOG_GENERATION_ENABLED_MODE = false; } else { BaseProcessor.LOG_GENERATION_ENABLED_MODE = true; } // when we run junit test, AnnotationProcessor is always in TEST_MODE BaseProcessor.JUNIT_TEST_MODE = true; System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] (%2$s) %5$s %6$s%n"); }
Example #23
Source File: ZipUtil.java From sofa-jraft with Apache License 2.0 | 6 votes |
public static void decompress(final String sourceFile, final String outputDir, final Checksum checksum) throws IOException { try (final FileInputStream fis = new FileInputStream(sourceFile); final CheckedInputStream cis = new CheckedInputStream(fis, checksum); final ZipInputStream zis = new ZipInputStream(new BufferedInputStream(cis))) { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { final String fileName = entry.getName(); final File entryFile = new File(Paths.get(outputDir, fileName).toString()); FileUtils.forceMkdir(entryFile.getParentFile()); try (final FileOutputStream fos = new FileOutputStream(entryFile); final BufferedOutputStream bos = new BufferedOutputStream(fos)) { IOUtils.copy(zis, bos); bos.flush(); fos.getFD().sync(); } } // Continue to read all remaining bytes(extra metadata of ZipEntry) directly from the checked stream, // Otherwise, the checksum value maybe unexpected. // // See https://coderanch.com/t/279175/java/ZipInputStream IOUtils.copy(cis, NullOutputStream.NULL_OUTPUT_STREAM); } }
Example #24
Source File: FluoProgramTest.java From fluo with Apache License 2.0 | 5 votes |
@BeforeClass public static void disablePrinting() { outPS = System.out; errPS = System.err; // This will hide usage and error logs when running tests try (PrintStream ps = new PrintStream(new NullOutputStream())) { System.setOut(ps); System.setErr(ps); } }
Example #25
Source File: BaseAndroidTest.java From kripton with Apache License 2.0 | 5 votes |
/** * Setup. */ @Before public void setup() { final String value = System.getProperty(KRIPTON_DEBUG_MODE); if ("false".equals(value)) { ShadowLog.stream = new PrintStream(new NullOutputStream()); // we are in test, but we don't see log on System.out System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); } else { ShadowLog.stream = System.out; } KriptonLibrary.init(RuntimeEnvironment.application); }
Example #26
Source File: HideOutput.java From uima-uimafit with Apache License 2.0 | 5 votes |
/** * calling this constructor will silence System.out and System.err until {@link #restoreOutput()} * is called by setting them to this OutputStream */ public HideOutput() { this.out = System.out; this.err = System.err; System.setOut(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM)); System.setErr(new PrintStream(NullOutputStream.NULL_OUTPUT_STREAM)); }
Example #27
Source File: UserRequestLogic.java From syncope with Apache License 2.0 | 5 votes |
protected UserRequest doStart( final String bpmnProcess, final User user, final WorkflowTaskExecInput inputVariables) { // check if BPMN process exists bpmnProcessManager.exportProcess(bpmnProcess, BpmnProcessFormat.XML, new NullOutputStream()); return userRequestHandler.start(bpmnProcess, user, inputVariables); }
Example #28
Source File: BaseAndroidTest.java From kripton with Apache License 2.0 | 5 votes |
/** * Setup. */ @Before public void setup() { final String value = System.getProperty(KRIPTON_DEBUG_MODE); if ("false".equals(value)) { ShadowLog.stream = new PrintStream(new NullOutputStream()); // we are in test, but we don't see log on System.out System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); } else { ShadowLog.stream = System.out; } KriptonLibrary.init(RuntimeEnvironment.application); }
Example #29
Source File: SetStepRowMetadata.java From data-prep with Apache License 2.0 | 5 votes |
/** * Update the given preparation's steps with row metadata. * * @param preparation the preparation. * @param currentProcessingNumber the number of the current preparation. * @param total the total number of preparation. */ private void setStepRowMetadata(PersistentPreparation preparation, AtomicLong currentProcessingNumber, long total) { LOGGER.info("[{}/{}] preparation #{} migration starting...", currentProcessingNumber.addAndGet(1), total, preparation.getId()); // Check if preparation is accessible to end user final Folder folder = folderRepository.locateEntry(preparation.id(), PREPARATION); if (folder == null) { LOGGER.warn("Preparation {} does not belong to a folder, skip migration (not accessible to user).", preparation.getName()); return; } // Run preparation final ExportParameters exportParameters = new ExportParameters(); exportParameters.setPreparationId(preparation.getId()); exportParameters.setDatasetId(preparation.getDataSetId()); exportParameters.setExportType("JSON"); // just process the preparation, the transformation service will automatically update the steps with row metadata try (NullOutputStream outputStream = new NullOutputStream()) { service.execute(exportParameters).writeTo(outputStream); } catch (Throwable e) { LOGGER.warn( "Error processing preparation {} (#{}), semantic categories are not properly stored and may change if you change them using the data quality command line", preparation.getName(), preparation.getId()); LOGGER.debug("Here is the stacktrace", e); } LOGGER.info("[{}/{}] preparation #{} done", currentProcessingNumber.get(), total, preparation.getId()); }
Example #30
Source File: AbstractBaseTest.java From kripton with Apache License 2.0 | 5 votes |
/** * Setup. */ @Before public void setup() { final String value = System.getProperty(KRIPTON_DEBUG_MODE); if ("false".equals(value)) { // we are in test, but we don't see log on System.out System.setOut(new PrintStream(new NullOutputStream())); System.setErr(new PrintStream(new NullOutputStream())); } // when we run junit test, AnnotationProcessor is always in TEST_MODE System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tH:%1$tM:%1$tS.%1$tL %4$-7s [%3$s] (%2$s) %5$s %6$s%n"); // KriptonBinder.registryBinder(new KriptonCborContext()); }