@Test public void consistencyCheckerLogUseSystemTimezoneIfConfigurable() throws Exception { TimeZone defaultTimeZone = TimeZone.getDefault(); try { ConsistencyCheckService service = mock( ConsistencyCheckService.class ); Mockito.when( service.runFullConsistencyCheck( any( DatabaseLayout.class ), any( Config.class ), any( ProgressMonitorFactory.class ), any( LogProvider.class ), any( FileSystemAbstraction.class ), eq( false ), any( ConsistencyFlags.class ) ) ) .then( invocationOnMock -> { LogProvider provider = invocationOnMock.getArgument( 3 ); provider.getLog( "test" ).info( "testMessage" ); return ConsistencyCheckService.Result.success( new File( StringUtils.EMPTY ) ); } ); File storeDir = testDirectory.directory(); File configFile = testDirectory.file( Config.DEFAULT_CONFIG_FILE_NAME ); Properties properties = new Properties(); properties.setProperty( GraphDatabaseSettings.db_timezone.name(), LogTimeZone.SYSTEM.name() ); properties.store( new FileWriter( configFile ), null ); String[] args = {storeDir.getPath(), "-config", configFile.getPath()}; checkLogRecordTimeZone( service, args, 5, "+0500" ); checkLogRecordTimeZone( service, args, -5, "-0500" ); } finally { TimeZone.setDefault( defaultTimeZone ); } }
private void checkStartLogLine( int hoursShift, String timeZoneSuffix ) throws IOException { TimeZone.setDefault( TimeZone.getTimeZone( ZoneOffset.ofHours( hoursShift ) ) ); File storeDir = testDirectory.storeDir( String.valueOf( hoursShift ) ); File databaseDirectory = testDirectory.databaseLayout( storeDir ).databaseDirectory(); GraphDatabaseService database = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( databaseDirectory ) .setConfig( GraphDatabaseSettings.db_timezone, LogTimeZone.SYSTEM.name() ).newGraphDatabase(); database.shutdown(); Path databasePath = storeDir.toPath(); Path debugLog = Paths.get( "logs", "debug.log" ); String debugLogLine = getLogLine( databasePath, debugLog ); assertTrue( debugLogLine, debugLogLine.contains( timeZoneSuffix ) ); }
@Test public void shouldImportDataComingFromCsvFiles() throws Exception { // GIVEN Config dbConfig = Config.builder().withSetting( db_timezone, LogTimeZone.SYSTEM.name() ).build(); try ( JobScheduler scheduler = new ThreadPoolJobScheduler() ) { BatchImporter importer = new ParallelBatchImporter( directory.databaseLayout(), fileSystemRule.get(), null, smallBatchSizeConfig(), NullLogService.getInstance(), invisible(), AdditionalInitialIds.EMPTY, dbConfig, RecordFormatSelector.defaultFormat(), NO_MONITOR, scheduler ); List<InputEntity> nodeData = randomNodeData(); List<InputEntity> relationshipData = randomRelationshipData( nodeData ); // WHEN importer.doImport( csv( nodeDataAsFile( nodeData ), relationshipDataAsFile( relationshipData ), IdType.STRING, lowBufferSize( COMMAS ), silentBadCollector( 0 ) ) ); // THEN verifyImportedData( nodeData, relationshipData ); } }