From 0dae54aeb33d93895f913cb557ab3fb9978119b8 Mon Sep 17 00:00:00 2001 From: Ruben de Laat Date: Thu, 15 Oct 2015 16:15:11 +0200 Subject: [PATCH] Work in progress refactoring to Path system --- .../src/org/bimserver/BimServerImporter.java | 39 ++++-------- .../org/bimserver/client/BimServerClient.java | 12 ++-- .../plugins/deserializers/Deserializer.java | 23 +------ .../deserializers/EmfDeserializer.java | 27 ++------ .../plugins/serializers/EmfSerializer.java | 15 +++-- .../plugins/serializers/Serializer.java | 21 +------ .../services/BimServerClientInterface.java | 23 +------ .../src/org/bimserver/test/AddFurniture.java | 27 ++------ .../org/bimserver/test/ExtractFurniture.java | 25 ++------ .../bimserver/test/ImportLargeProject.java | 58 +++++++---------- .../bimserver/test/TestAddExtendedData.java | 21 +------ ...TestDownloadBinaryGeometrySimultanous.java | 21 +------ .../src/org/bimserver/test/TestUploadDir.java | 44 +++++-------- .../test/TestUploadSameModelALot.java | 21 +------ Tests/src/org/bimserver/test/Tmp.java | 4 +- .../test/framework/FolderWalker.java | 49 ++++++--------- .../bimserver/test/framework/RemoteTest.java | 25 ++------ .../test/framework/TestConfiguration.java | 14 +++-- .../test/framework/TestFileProvider.java | 21 +------ .../test/framework/TestFramework.java | 43 +++++-------- .../test/framework/actions/CheckinAction.java | 23 +------ .../actions/DownloadModelLowLevel.java | 21 +------ .../actions/DownloadRevisionAction.java | 32 +++------- .../test/framework/tests/TestAll.java | 25 ++------ .../test/framework/tests/TestCheckin.java | 25 ++------ .../test/framework/tests/TestCheckin2.java | 25 ++------ .../test/framework/tests/TestCheckinAll.java | 25 ++------ .../test/framework/tests/TestCollada.java | 21 +------ .../test/framework/tests/TestJson.java | 25 ++------ .../framework/tests/TestProtocolBuffers.java | 28 ++------- Tests/src/org/bimserver/tests/Bla.java | 13 ++-- .../org/bimserver/tests/ChangeSetTest.java | 8 +-- .../src/org/bimserver/tests/CityGmlTest.java | 23 +------ .../org/bimserver/tests/ColladaTester.java | 6 +- .../src/org/bimserver/tests/CompareTest.java | 10 +-- .../org/bimserver/tests/CreateRunTest.java | 42 ------------- .../org/bimserver/tests/DatabaseDebugger.java | 4 +- .../org/bimserver/tests/DatabaseTester.java | 4 +- Tests/src/org/bimserver/tests/FileLoader.java | 35 ++++------- Tests/src/org/bimserver/tests/GetLogs.java | 24 ++----- .../org/bimserver/tests/GuidHighlighter.java | 24 ++----- .../tests/GuidHighlighterTester.java | 16 ++--- .../src/org/bimserver/tests/Ifc2CodbTest.java | 20 +++--- .../org/bimserver/tests/IfcRioleringTest.java | 24 ++----- .../tests/IfcToBerkeleyAndBackTest.java | 4 +- .../bimserver/tests/IfcToEmfAndBackTest.java | 18 +++--- .../org/bimserver/tests/IfcXmlReadTest.java | 28 ++------- .../org/bimserver/tests/LargeFileTest.java | 23 +------ Tests/src/org/bimserver/tests/MergeTest.java | 10 +-- .../bimserver/tests/NewDatabaseTester.java | 6 +- .../bimserver/tests/PerformanceTester.java | 8 +-- Tests/src/org/bimserver/tests/ReadTest.java | 23 +------ .../bimserver/tests/RevisionMergeTest.java | 23 +------ Tests/src/org/bimserver/tests/RudeBackup.java | 2 +- Tests/src/org/bimserver/tests/Search.java | 61 ++++++++---------- .../bimserver/tests/StructureAnalyzer.java | 23 +------ .../org/bimserver/tests/TestBimQlSoap.java | 21 +------ .../src/org/bimserver/tests/TestCityGML.java | 22 +------ .../src/org/bimserver/tests/TestCollada.java | 20 +----- .../tests/TestColladaSerializer.java | 39 +++++------- Tests/src/org/bimserver/tests/TestColor.java | 24 +------ .../src/org/bimserver/tests/TestDatabase.java | 32 +++------- .../org/bimserver/tests/TestDeserializer.java | 20 +----- Tests/src/org/bimserver/tests/TestFile.java | 63 +++++++------------ .../bimserver/tests/TestFileConstants.java | 4 +- Tests/src/org/bimserver/tests/TestGen.java | 21 +------ Tests/src/org/bimserver/tests/TestGuid.java | 21 +------ .../tests/TestIfcEngineEmbedded.java | 27 +------- .../src/org/bimserver/tests/TestIfcFile.java | 23 +------ Tests/src/org/bimserver/tests/TestInOut.java | 17 ++--- .../TestJsonSerializerMultipleRevisions.java | 23 +------ Tests/src/org/bimserver/tests/TestKmz.java | 23 +------ .../bimserver/tests/TestManyRevisions.java | 9 +-- .../bimserver/tests/TestSceneJsDownload.java | 21 +------ .../TestSimultaniousDownloadWithCaching.java | 18 +++--- Tests/src/org/bimserver/tests/Visualise.java | 3 +- .../bimserver/tests/WebserviceReadTest.java | 2 +- .../bimserver/tests/WebserviceWriteTest.java | 4 +- Tests/src/org/bimserver/tests/XsltTest.java | 28 ++------- Tests/src/org/bimserver/tests/diff/Diff.java | 28 ++------- .../org/bimserver/tests/diff/DiffReader.java | 5 +- .../org/bimserver/tests/diff/FullModel.java | 10 +-- .../PerformanceTestIfcStepSerializer.java | 6 +- .../unittests/TestClientEmfModelLocal.java | 13 ++-- .../unittests/TestEmbeddedBimServer.java | 32 +++------- .../TestIfcSerializeDeserialize.java | 8 +-- .../unittests/TestIfcStepDeserializer.java | 6 +- .../unittests/TestIfcStepSerializer.java | 6 +- .../unittests/TestLowLevelChanges.java | 2 +- Tests/test/org/bimserver/tests/AllTests.java | 10 +-- .../tests/emf/ContainedInStructure.java | 4 +- .../bimserver/tests/emf/CreateProperties.java | 4 +- .../org/bimserver/tests/emf/ListWalls.java | 4 +- .../tests/emf/LoadCompleteModel.java | 4 +- .../org/bimserver/tests/emf/MoveObject.java | 6 +- .../bimserver/tests/emf/ReadProperties.java | 4 +- .../org/bimserver/tests/emf/ReadTrim.java | 4 +- .../tests/emf/RemoveReferenceList.java | 6 +- .../tests/ifc/TestJapaneseChars.java | 5 +- .../tests/lowlevel/MoveFurniture.java | 6 +- .../tests/lowlevel/RemoveObject2.java | 6 +- .../bimserver/tests/lowlevel/SetString.java | 10 +-- .../tests/serviceinterface/QueryJava.java | 4 +- .../SingleCheckinAndDownload.java | 7 ++- .../SingleCheckinAndDownloadSimplified.java | 5 +- .../tests/serviceinterface/SubProjects.java | 8 ++- .../download/DownloadLatestRevisions.java | 13 ++-- .../IfcGeometryRemover.java | 7 ++- .../IfcGeometryRemoverTest.java | 18 +++--- .../saapc/SurfaceAreaAndPeopleCalculator.java | 11 ++-- Tools/src/org/bimserver/saapc/Test.java | 4 +- .../bimserver/tools/colorizer/Colorizer.java | 11 ++-- 112 files changed, 568 insertions(+), 1459 deletions(-) delete mode 100644 Tests/src/org/bimserver/tests/CreateRunTest.java diff --git a/BimServer/src/org/bimserver/BimServerImporter.java b/BimServer/src/org/bimserver/BimServerImporter.java index a5d2c54fad..6d89493764 100644 --- a/BimServer/src/org/bimserver/BimServerImporter.java +++ b/BimServer/src/org/bimserver/BimServerImporter.java @@ -1,24 +1,8 @@ package org.bimserver; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -54,6 +38,7 @@ import org.bimserver.shared.exceptions.ServiceException; import org.bimserver.shared.exceptions.UserException; import org.bimserver.utils.Formatters; +import org.bimserver.utils.PathUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,10 +91,10 @@ class Key { public String comment; public long userId; public Date date; - public File file; + public Path file; public long poid; - public Key(File file, long oid, String comment, Date date, long userId) { + public Key(Path file, long oid, String comment, Date date, long userId) { this.file = file; poid = oid; this.comment = comment; @@ -148,7 +133,7 @@ public void start() { // client.getPluginInterface().setDefaultRenderEngine(renderEnginePluginConfiguration.getOid()); // } // } - File incoming = new File(path); + Path incoming = Paths.get(path); final Map comments = new TreeMap<>(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); for (SProject project : remoteClient.getBimsie1ServiceInterface().getAllProjects(false, false)) { @@ -157,11 +142,11 @@ public void start() { gregorianCalendar.setTime(revision.getDate()); if (!revision.getComment().startsWith("generated for")) { User user = users.get(revision.getUserId()); - File userFolder = new File(incoming, user.getUsername()); + Path userFolder = incoming.resolve(user.getUsername()); boolean found = false; - for (File file : userFolder.listFiles()) { - if (file.getName().endsWith(revision.getComment())) { - String dateStr = file.getName().substring(0, 19); + for (Path file : PathUtils.getDirectories(userFolder)) { + if (file.getFileName().toString().endsWith(revision.getComment())) { + String dateStr = file.getFileName().toString().substring(0, 19); Date parse = dateFormat.parse(dateStr); GregorianCalendar fileDate = new GregorianCalendar(); fileDate.setTime(parse); @@ -187,7 +172,7 @@ public void start() { @Override public void run() { Key key = comments.get(gregorianCalendar); - LOGGER.info("Checking in: " + key.file.getName() + " " + Formatters.bytesToString(key.file.length())); + LOGGER.info("Checking in: " + key.file.getFileName().toString() + " " + Formatters.bytesToString(key.file.toFile().length())); Project sProject = projects.get(key.poid); try { SDeserializerPluginConfiguration desserializer = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", sProject.getOid()); @@ -232,6 +217,8 @@ public void run() { LOGGER.error("", e); } catch (ParseException e) { LOGGER.error("", e); + } catch (IOException e) { + LOGGER.error("", e); } } diff --git a/BimServerClientLib/src/org/bimserver/client/BimServerClient.java b/BimServerClientLib/src/org/bimserver/client/BimServerClient.java index 68ec420737..22b04b3bee 100644 --- a/BimServerClientLib/src/org/bimserver/client/BimServerClient.java +++ b/BimServerClientLib/src/org/bimserver/client/BimServerClient.java @@ -18,12 +18,12 @@ *****************************************************************************/ import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Path; import java.util.HashSet; import java.util.Set; @@ -253,9 +253,9 @@ public void registerTokenChangeListener(TokenChangeListener tokenChangeListener) tokenChangeListeners.add(tokenChangeListener); } - public long checkin(long poid, String comment, long deserializerOid, boolean merge, boolean sync, File file) throws IOException, UserException, ServerException { - FileInputStream fis = new FileInputStream(file); - long result = checkin(poid, comment, deserializerOid, merge, sync, file.length(), file.getName(), fis); + public long checkin(long poid, String comment, long deserializerOid, boolean merge, boolean sync, Path file) throws IOException, UserException, ServerException { + FileInputStream fis = new FileInputStream(file.toFile()); + long result = checkin(poid, comment, deserializerOid, merge, sync, file.toFile().length(), file.getFileName().toString(), fis); if (sync) { fis.close(); } @@ -287,8 +287,8 @@ public void download(long roid, long serializerOid, OutputStream outputStream) { } } - public void download(long roid, long serializerOid, File file) throws IOException { - FileOutputStream outputStream = new FileOutputStream(file); + public void download(long roid, long serializerOid, Path file) throws IOException { + FileOutputStream outputStream = new FileOutputStream(file.toFile()); try { download(roid, serializerOid, outputStream); } finally { diff --git a/Shared/src/org/bimserver/plugins/deserializers/Deserializer.java b/Shared/src/org/bimserver/plugins/deserializers/Deserializer.java index 1b27eab94b..fce095fa15 100644 --- a/Shared/src/org/bimserver/plugins/deserializers/Deserializer.java +++ b/Shared/src/org/bimserver/plugins/deserializers/Deserializer.java @@ -1,32 +1,15 @@ package org.bimserver.plugins.deserializers; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.InputStream; +import java.nio.file.Path; import org.bimserver.emf.IfcModelInterface; import org.bimserver.emf.PackageMetaData; public interface Deserializer { void init(PackageMetaData packageMetaData); - IfcModelInterface read(File file, ByteProgressReporter progressReporter) throws DeserializeException; + IfcModelInterface read(Path file, ByteProgressReporter progressReporter) throws DeserializeException; IfcModelInterface read(InputStream inputStream, String fileName, long fileSize, ByteProgressReporter progressReporter) throws DeserializeException; - IfcModelInterface read(File file) throws DeserializeException; + IfcModelInterface read(Path file) throws DeserializeException; IfcModelInterface read(InputStream inputStream, String fileName, long fileSize) throws DeserializeException; } \ No newline at end of file diff --git a/Shared/src/org/bimserver/plugins/deserializers/EmfDeserializer.java b/Shared/src/org/bimserver/plugins/deserializers/EmfDeserializer.java index 3eabb3bbfd..ed94cb1a8f 100644 --- a/Shared/src/org/bimserver/plugins/deserializers/EmfDeserializer.java +++ b/Shared/src/org/bimserver/plugins/deserializers/EmfDeserializer.java @@ -1,27 +1,10 @@ package org.bimserver.plugins.deserializers; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Path; import org.bimserver.emf.IfcModelInterface; import org.bimserver.emf.PackageMetaData; @@ -45,12 +28,12 @@ public IfcModelInterface read(InputStream in, String filename, long fileSize) th } @Override - public IfcModelInterface read(File file, ByteProgressReporter progressReporter) throws DeserializeException { + public IfcModelInterface read(Path file, ByteProgressReporter progressReporter) throws DeserializeException { FileInputStream fileInputStream; try { - fileInputStream = new FileInputStream(file); + fileInputStream = new FileInputStream(file.toFile()); try { - return read(fileInputStream, file.getName(), file.length(), progressReporter); + return read(fileInputStream, file.getFileName().toString(), file.toFile().length(), progressReporter); } finally { try { fileInputStream.close(); @@ -63,7 +46,7 @@ public IfcModelInterface read(File file, ByteProgressReporter progressReporter) } } - public IfcModelInterface read(File file) throws DeserializeException { + public IfcModelInterface read(Path file) throws DeserializeException { return read(file, null); } } \ No newline at end of file diff --git a/Shared/src/org/bimserver/plugins/serializers/EmfSerializer.java b/Shared/src/org/bimserver/plugins/serializers/EmfSerializer.java index ab4311f56f..a720b74c80 100644 --- a/Shared/src/org/bimserver/plugins/serializers/EmfSerializer.java +++ b/Shared/src/org/bimserver/plugins/serializers/EmfSerializer.java @@ -18,12 +18,12 @@ *****************************************************************************/ import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; import org.bimserver.emf.IdEObject; import org.bimserver.emf.IdEObjectImpl; @@ -127,11 +127,14 @@ public void writeToOutputStream(OutputStream outputStream, ProgressReporter prog if(progressReporter!=null) progressReporter.update(1, 1); } - public void writeToFile(File file, ProgressReporter progressReporter) throws SerializerException { + public void writeToFile(Path file, ProgressReporter progressReporter) throws SerializerException { try { - FileOutputStream fos = new FileOutputStream(file); - writeToOutputStream(fos, progressReporter); - fos.close(); + OutputStream outputStream = Files.newOutputStream(file); + try { + writeToOutputStream(outputStream, progressReporter); + } finally { + outputStream.close(); + } } catch (FileNotFoundException e) { LOGGER.error("", e); } catch (IOException e) { diff --git a/Shared/src/org/bimserver/plugins/serializers/Serializer.java b/Shared/src/org/bimserver/plugins/serializers/Serializer.java index f3b0eb1993..908f87fdcb 100644 --- a/Shared/src/org/bimserver/plugins/serializers/Serializer.java +++ b/Shared/src/org/bimserver/plugins/serializers/Serializer.java @@ -1,26 +1,9 @@ package org.bimserver.plugins.serializers; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Path; import org.bimserver.emf.IfcModelInterface; import org.bimserver.emf.PackageMetaData; @@ -29,7 +12,7 @@ public interface Serializer { void init(IfcModelInterface model, ProjectInfo projectInfo, PluginManager pluginManager, RenderEnginePlugin renderEnginePlugin, PackageMetaData packageMetaData, boolean normalizeOids) throws SerializerException; - void writeToFile(File file, ProgressReporter progressReporter) throws SerializerException; + void writeToFile(Path file, ProgressReporter progressReporter) throws SerializerException; byte[] getBytes(); IfcModelInterface getModel(); InputStream getInputStream() throws IOException; diff --git a/Shared/src/org/bimserver/plugins/services/BimServerClientInterface.java b/Shared/src/org/bimserver/plugins/services/BimServerClientInterface.java index 685942da71..2f2dadc815 100644 --- a/Shared/src/org/bimserver/plugins/services/BimServerClientInterface.java +++ b/Shared/src/org/bimserver/plugins/services/BimServerClientInterface.java @@ -1,26 +1,9 @@ package org.bimserver.plugins.services; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Path; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SProject; @@ -44,9 +27,9 @@ public interface BimServerClientInterface extends ServiceHolder { void commit(IfcModelInterface model, String comment); void download(long roid, long serializerOid, OutputStream outputStream); - void download(long roid, long serializerOid, File file) throws IOException; + void download(long roid, long serializerOid, Path file) throws IOException; - long checkin(long poid, String string, long deserializerOid, boolean merge, boolean sync, File file) throws IOException, UserException, ServerException; + long checkin(long poid, String string, long deserializerOid, boolean merge, boolean sync, Path file) throws IOException, UserException, ServerException; /** * Convenience method that given you the InputStream belonging to an already started download diff --git a/Tests/src/org/bimserver/test/AddFurniture.java b/Tests/src/org/bimserver/test/AddFurniture.java index c27844a36f..c15b849f94 100644 --- a/Tests/src/org/bimserver/test/AddFurniture.java +++ b/Tests/src/org/bimserver/test/AddFurniture.java @@ -1,23 +1,6 @@ package org.bimserver.test; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import java.util.List; import org.bimserver.LocalDevPluginLoader; @@ -54,17 +37,17 @@ public class AddFurniture { public static void main(String[] args) { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(null); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); - IfcModelInterface model = deserializer.read(new File("../TestData/data/AC9R1-Haus-G-H-Ver2-2x3.ifc")); + IfcModelInterface model = deserializer.read(Paths.get("../TestData/data/AC9R1-Haus-G-H-Ver2-2x3.ifc")); deserializer = deserializerPlugin.createDeserializer(null); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); - IfcModelInterface furnishingModel = deserializer.read(new File("test.ifc")); + IfcModelInterface furnishingModel = deserializer.read(Paths.get ("test.ifc")); model.fixOids(new IncrementingOidProvider()); long oid = model.getHighestOid(); @@ -145,7 +128,7 @@ public static void main(String[] args) { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(null); serializer.init(model, null, pluginManager, null, null, true); - serializer.writeToFile(new File("withfurn.ifc"), null); + serializer.writeToFile(Paths.get("withfurn.ifc"), null); } catch (PluginException e) { e.printStackTrace(); } catch (DeserializeException e) { diff --git a/Tests/src/org/bimserver/test/ExtractFurniture.java b/Tests/src/org/bimserver/test/ExtractFurniture.java index ce6545e53a..a97595ff8c 100644 --- a/Tests/src/org/bimserver/test/ExtractFurniture.java +++ b/Tests/src/org/bimserver/test/ExtractFurniture.java @@ -1,23 +1,6 @@ package org.bimserver.test; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterface; @@ -44,7 +27,7 @@ public class ExtractFurniture { public static void main(String[] args) { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(null); @@ -52,7 +35,7 @@ public static void main(String[] args) { PackageMetaData packageMetaData = metaDataManager.getPackageMetaData("ifc2x3tc1"); deserializer.init(packageMetaData); - IfcModelInterface model = deserializer.read(new File("../TestData/data/ADT-FZK-Haus-2005-2006.ifc")); + IfcModelInterface model = deserializer.read(Paths.get("../TestData/data/ADT-FZK-Haus-2005-2006.ifc")); model.fixOids(new IncrementingOidProvider()); IfcFurnishingElement picknick = (IfcFurnishingElement) model.getByName(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank"); @@ -65,7 +48,7 @@ public static void main(String[] args) { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(null); serializer.init(newModel, null, pluginManager, null, packageMetaData, true); - serializer.writeToFile(new File("test.ifc"), null); + serializer.writeToFile(Paths.get("test.ifc"), null); } catch (PluginException e) { e.printStackTrace(); } catch (DeserializeException e) { diff --git a/Tests/src/org/bimserver/test/ImportLargeProject.java b/Tests/src/org/bimserver/test/ImportLargeProject.java index 585f6e1f80..5fa1a9e830 100644 --- a/Tests/src/org/bimserver/test/ImportLargeProject.java +++ b/Tests/src/org/bimserver/test/ImportLargeProject.java @@ -1,24 +1,8 @@ package org.bimserver.test; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -33,7 +17,7 @@ public class ImportLargeProject { public static void main(String[] args) { BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080"); try { - File baseFolder = new File("C:\\Users\\Ruben de Laat\\Documents\\ttt"); + Path baseFolder = Paths.get("C:\\Users\\Ruben de Laat\\Documents\\ttt"); Bimsie1ServiceInterface serviceInterface = client.getBimsie1ServiceInterface(); SProject mainProject = serviceInterface.addProject("Tekla Demo Model", "ifc2x3tc1"); @@ -71,27 +55,27 @@ public static void main(String[] args) { SDeserializerPluginConfiguration deserializer = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", grid.getOid()); - client.checkin(teklaHouseStructural.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Structural.ifcZIP")); - client.checkin(teklaHouseGrids.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Grids.ifc")); - client.checkin(teklaHouseFoundationFootings.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Foundation Footings.ifcZIP")); - client.checkin(teklaHouseFoundationPiles.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Foundation Piles.ifcZIP")); - client.checkin(teklaHouseFoundationRebars.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Foundation Rebars.ifcZIP")); - client.checkin(teklaHouseFoundationEmbedments.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Foundation Embedments.ifcZIP")); - client.checkin(teklaHousePrecastRebars.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Precast Rebars.ifcZIP")); - client.checkin(teklaHousePrecastConcrete.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Precast Concrete.ifcZIP")); -// client.checkin(teklaHouseCIPPours.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House CIP Pours.ifc")); - client.checkin(teklaHouseCIPRebars.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House CIP Rebars.ifcZIP")); - client.checkin(teklaHouseCIPColumns.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House CIP Columns.ifcZIP")); - client.checkin(teklaHouseArchitectural.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House Architectural.ifczip")); - client.checkin(teklaHouseMEPGround.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House MEP, Ground.ifc")); - client.checkin(teklaHouseMEP1.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House MEP, 1st.ifc")); - client.checkin(teklaHouseMEP2.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House MEP, 2nd.ifc")); - client.checkin(teklaHouseMEP3.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House MEP, 3rd.ifc")); - client.checkin(teklaHouseMEPRoof.getOid(), "Initial", deserializer.getOid(), false, true, new File(baseFolder, "Tekla House MEP, Roof.ifc")); + client.checkin(teklaHouseStructural.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Structural.ifcZIP")); + client.checkin(teklaHouseGrids.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Grids.ifc")); + client.checkin(teklaHouseFoundationFootings.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Foundation Footings.ifcZIP")); + client.checkin(teklaHouseFoundationPiles.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Foundation Piles.ifcZIP")); + client.checkin(teklaHouseFoundationRebars.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Foundation Rebars.ifcZIP")); + client.checkin(teklaHouseFoundationEmbedments.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Foundation Embedments.ifcZIP")); + client.checkin(teklaHousePrecastRebars.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Precast Rebars.ifcZIP")); + client.checkin(teklaHousePrecastConcrete.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Precast Concrete.ifcZIP")); +// client.checkin(teklaHouseCIPPours.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder, "Tekla House CIP Pours.ifc")); + client.checkin(teklaHouseCIPRebars.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House CIP Rebars.ifcZIP")); + client.checkin(teklaHouseCIPColumns.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House CIP Columns.ifcZIP")); + client.checkin(teklaHouseArchitectural.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House Architectural.ifczip")); + client.checkin(teklaHouseMEPGround.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House MEP, Ground.ifc")); + client.checkin(teklaHouseMEP1.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House MEP, 1st.ifc")); + client.checkin(teklaHouseMEP2.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House MEP, 2nd.ifc")); + client.checkin(teklaHouseMEP3.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House MEP, 3rd.ifc")); + client.checkin(teklaHouseMEPRoof.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder.resolve("Tekla House MEP, Roof.ifc")); mainProject = serviceInterface.getProjectByPoid(mainProject.getOid()); SSerializerPluginConfiguration serializer = client.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc"); - client.download(mainProject.getLastRevisionId(), serializer.getOid(), new File("output.ifc")); + client.download(mainProject.getLastRevisionId(), serializer.getOid(), Paths.get("output.ifc")); } catch (ServiceException e) { e.printStackTrace(); } catch (PublicInterfaceNotFoundException e) { diff --git a/Tests/src/org/bimserver/test/TestAddExtendedData.java b/Tests/src/org/bimserver/test/TestAddExtendedData.java index a417a5cd8b..44e65b65f1 100644 --- a/Tests/src/org/bimserver/test/TestAddExtendedData.java +++ b/Tests/src/org/bimserver/test/TestAddExtendedData.java @@ -1,24 +1,7 @@ package org.bimserver.test; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -50,7 +33,7 @@ private void start() { SProject project = client.getBimsie1ServiceInterface().addProject("test23", "ifc2x3tc1"); SDeserializerPluginConfiguration deserializerForExtension = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); - client.checkin(project.getOid(), "initial", deserializerForExtension.getOid(), false, true, new File("../TestData/data/AC11-FZK-Haus-IFC.ifc")); + client.checkin(project.getOid(), "initial", deserializerForExtension.getOid(), false, true, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc")); project = client.getBimsie1ServiceInterface().getProjectByPoid(project.getOid()); diff --git a/Tests/src/org/bimserver/test/TestDownloadBinaryGeometrySimultanous.java b/Tests/src/org/bimserver/test/TestDownloadBinaryGeometrySimultanous.java index a030f15793..0774bdff43 100644 --- a/Tests/src/org/bimserver/test/TestDownloadBinaryGeometrySimultanous.java +++ b/Tests/src/org/bimserver/test/TestDownloadBinaryGeometrySimultanous.java @@ -1,24 +1,7 @@ package org.bimserver.test; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.interfaces.objects.SProject; @@ -49,7 +32,7 @@ public Runner(BimServerClientInterface client, SSerializerPluginConfiguration se @Override public void run() { try { - client.download(project.getLastRevisionId(), serializer.getOid(), new File("output" + i + ".data")); + client.download(project.getLastRevisionId(), serializer.getOid(), Paths.get("output" + i + ".data")); } catch (IOException e) { e.printStackTrace(); } diff --git a/Tests/src/org/bimserver/test/TestUploadDir.java b/Tests/src/org/bimserver/test/TestUploadDir.java index bcd9e45783..1d0bb7f7ac 100644 --- a/Tests/src/org/bimserver/test/TestUploadDir.java +++ b/Tests/src/org/bimserver/test/TestUploadDir.java @@ -1,24 +1,9 @@ package org.bimserver.test; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -29,6 +14,7 @@ import org.bimserver.shared.exceptions.ServiceException; import org.bimserver.shared.exceptions.UserException; import org.bimserver.utils.Formatters; +import org.bimserver.utils.PathUtils; public class TestUploadDir { private BimServerClientInterface client; @@ -42,8 +28,8 @@ private void start() { client = LocalDevSetup.setupJson("http://localhost:8080"); client.getSettingsInterface().setGenerateGeometryOnCheckin(false); - File directory = new File("d:\\testfiles"); - for (File f : directory.listFiles()) { + Path directory = Paths.get("d:\\testfiles"); + for (Path f : PathUtils.getDirectories(directory)) { process(f, null); } } catch (ServiceException e) { @@ -55,29 +41,29 @@ private void start() { } } - private void process(File directory, SProject parentProject) throws ServerException, UserException, PublicInterfaceNotFoundException, IOException { - if (directory.isDirectory()) { + private void process(Path directory, SProject parentProject) throws ServerException, UserException, PublicInterfaceNotFoundException, IOException { + if (Files.isDirectory(directory)) { SProject project = null; if (parentProject == null) { - project = client.getBimsie1ServiceInterface().addProject(directory.getName(), "ifc2x3tc1"); + project = client.getBimsie1ServiceInterface().addProject(directory.getFileName().toString(), "ifc2x3tc1"); } else { - project = client.getBimsie1ServiceInterface().addProjectAsSubProject(directory.getName(), parentProject.getOid(), "ifc2x3tc1"); + project = client.getBimsie1ServiceInterface().addProjectAsSubProject(directory.getFileName().toString(), parentProject.getOid(), "ifc2x3tc1"); } - for (File file : directory.listFiles()) { + for (Path file : PathUtils.getDirectories(directory)) { process(file, project); } } else { - String lowerCase = directory.getName().toLowerCase(); + String lowerCase = directory.getFileName().toString().toLowerCase(); if (lowerCase.endsWith("ifc") || lowerCase.endsWith("ifcxml") || lowerCase.endsWith("ifczip")) { - SDeserializerPluginConfiguration deserializerForExtension = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension(directory.getName().substring(directory.getName().lastIndexOf(".") + 1), parentProject.getOid()); - System.out.println("Checking in " + directory.getAbsolutePath() + " - " + Formatters.bytesToString(directory.length())); + SDeserializerPluginConfiguration deserializerForExtension = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension(directory.getFileName().toString().substring(directory.getFileName().toString().lastIndexOf(".") + 1), parentProject.getOid()); + System.out.println("Checking in " + directory.toString() + " - " + Formatters.bytesToString(directory.toFile().length())); try { client.checkin(parentProject.getOid(), "", deserializerForExtension.getOid(), false, true, directory); } catch (UserException e) { e.printStackTrace(); } } else { - System.out.println("Ignoring " + directory.getAbsolutePath()); + System.out.println("Ignoring " + directory.toString()); } } } diff --git a/Tests/src/org/bimserver/test/TestUploadSameModelALot.java b/Tests/src/org/bimserver/test/TestUploadSameModelALot.java index 0bf048ef98..3926e3dd38 100644 --- a/Tests/src/org/bimserver/test/TestUploadSameModelALot.java +++ b/Tests/src/org/bimserver/test/TestUploadSameModelALot.java @@ -1,24 +1,7 @@ package org.bimserver.test; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -41,7 +24,7 @@ private void start() { SProject project = client.getBimsie1ServiceInterface().addProject("P" + i, "ifc2x3tc1"); SDeserializerPluginConfiguration deserializerForExtension = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); System.out.println(i); - client.checkin(project.getOid(), "C" + i, deserializerForExtension.getOid(), false, true, new File("../TestData/data/AC11-FZK-Haus-IFC.ifc")); + client.checkin(project.getOid(), "C" + i, deserializerForExtension.getOid(), false, true, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc")); } } catch (ServiceException e) { e.printStackTrace(); diff --git a/Tests/src/org/bimserver/test/Tmp.java b/Tests/src/org/bimserver/test/Tmp.java index cbc9baaaf0..b0ef8be5f3 100644 --- a/Tests/src/org/bimserver/test/Tmp.java +++ b/Tests/src/org/bimserver/test/Tmp.java @@ -1,7 +1,7 @@ package org.bimserver.test; -import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.emf.IfcModelInterface; @@ -26,7 +26,7 @@ public static void main(String[] args) { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); // Checkin file - bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); + bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); // Refresh project project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid()); diff --git a/Tests/src/org/bimserver/test/framework/FolderWalker.java b/Tests/src/org/bimserver/test/framework/FolderWalker.java index 9a23d57b87..abd9fccf0b 100644 --- a/Tests/src/org/bimserver/test/framework/FolderWalker.java +++ b/Tests/src/org/bimserver/test/framework/FolderWalker.java @@ -1,24 +1,10 @@ package org.bimserver.test.framework; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; +import org.bimserver.utils.PathUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,29 +12,30 @@ public class FolderWalker implements TestFileProvider { private static final Logger LOGGER = LoggerFactory.getLogger(FolderWalker.class); private volatile int current = 0; - private final File[] listFiles; + private List listFiles; private final TestFramework testFramework; private int lastPerc; - public FolderWalker(File folder, TestFramework testFramework) { + public FolderWalker(Path folder, TestFramework testFramework) { this.testFramework = testFramework; - this.listFiles = folder.listFiles(); + try { + this.listFiles = PathUtils.getDirectories(folder); + } catch (IOException e) { + e.printStackTrace(); + } } @Override - public synchronized File getNewFile() { - if (current >= listFiles.length) { + public synchronized Path getNewFile() { + if (current >= listFiles.size()) { testFramework.stop(); return null; } - File next = listFiles[current++]; - if (next.getName().contains(".svn")) { - return getNewFile(); - } - if (!next.isFile()) { - return getNewFile(); - } - int percentage = current / listFiles.length; + Path next = listFiles.get(current++); +// if (!next.isFile()) { +// return getNewFile(); +// } + int percentage = current / listFiles.size(); if (percentage > lastPerc) { LOGGER.info(""); LOGGER.info(""); diff --git a/Tests/src/org/bimserver/test/framework/RemoteTest.java b/Tests/src/org/bimserver/test/framework/RemoteTest.java index 5cb3f1ed57..7f2aa8dc60 100644 --- a/Tests/src/org/bimserver/test/framework/RemoteTest.java +++ b/Tests/src/org/bimserver/test/framework/RemoteTest.java @@ -1,23 +1,6 @@ package org.bimserver.test.framework; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.RandomBimServerClientFactory.Type; @@ -28,11 +11,11 @@ public static void main(String[] args) { TestConfiguration testConfiguration = new TestConfiguration(); TestFramework testFramework = new TestFramework(testConfiguration, new OptionsParser(args).getPluginDirectories()); - testConfiguration.setHomeDir(new File("/opt/bimservertest")); + testConfiguration.setHomeDir(Paths.get("/opt/bimservertest")); testConfiguration.setActionFactory(new AllActionsFactory(testFramework)); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.values())); - testConfiguration.setTestFileProvider(new FolderWalker(new File("/mnt/sata1/ifcselected"), testFramework)); - testConfiguration.setOutputFolder(new File("/opt/output")); + testConfiguration.setTestFileProvider(new FolderWalker(Paths.get("/mnt/sata1/ifcselected"), testFramework)); + testConfiguration.setOutputFolder(Paths.get("/opt/output")); testConfiguration.setNrVirtualUsers(4); testFramework.start(); diff --git a/Tests/src/org/bimserver/test/framework/TestConfiguration.java b/Tests/src/org/bimserver/test/framework/TestConfiguration.java index 30bf1ee867..749463d804 100644 --- a/Tests/src/org/bimserver/test/framework/TestConfiguration.java +++ b/Tests/src/org/bimserver/test/framework/TestConfiguration.java @@ -18,6 +18,8 @@ *****************************************************************************/ import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import org.bimserver.shared.BimServerClientFactory; import org.bimserver.test.framework.actions.ActionFactory; @@ -31,9 +33,9 @@ public class TestConfiguration { private boolean stopOnServerException = true; private boolean stopNoVirtualUsers = true; private ActionFactory actionFactory; - private File outputFolder; + private Path outputFolder; private BimServerClientFactory bimServerClientFactory; - private File homeDir = new File("home"); + private Path homeDir = Paths.get("home"); private TestFileProvider testFileProvider; public int getNrVirtualUsers() { @@ -92,11 +94,11 @@ public void setActionFactory(ActionFactory actionFactory) { this.actionFactory = actionFactory; } - public File getOutputFolder() { + public Path getOutputFolder() { return outputFolder; } - public void setOutputFolder(File outputFolder) { + public void setOutputFolder(Path outputFolder) { this.outputFolder = outputFolder; } @@ -108,11 +110,11 @@ public void setBimServerClientFactory(BimServerClientFactory bimServerClientFact this.bimServerClientFactory = bimServerClientFactory; } - public File getHomeDir() { + public Path getHomeDir() { return homeDir; } - public void setHomeDir(File homeDir) { + public void setHomeDir(Path homeDir) { this.homeDir = homeDir; } diff --git a/Tests/src/org/bimserver/test/framework/TestFileProvider.java b/Tests/src/org/bimserver/test/framework/TestFileProvider.java index 1b4606b8fd..86e46e984e 100644 --- a/Tests/src/org/bimserver/test/framework/TestFileProvider.java +++ b/Tests/src/org/bimserver/test/framework/TestFileProvider.java @@ -1,24 +1,7 @@ package org.bimserver.test.framework; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Path; public interface TestFileProvider { - File getNewFile(); + Path getNewFile(); } diff --git a/Tests/src/org/bimserver/test/framework/TestFramework.java b/Tests/src/org/bimserver/test/framework/TestFramework.java index a795c0bbd0..c863b0d10d 100644 --- a/Tests/src/org/bimserver/test/framework/TestFramework.java +++ b/Tests/src/org/bimserver/test/framework/TestFramework.java @@ -1,28 +1,12 @@ package org.bimserver.test.framework; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashSet; import java.util.Set; -import org.apache.commons.io.FileUtils; import org.bimserver.BimServer; import org.bimserver.BimServerConfig; import org.bimserver.EmbeddedWebServer; @@ -33,6 +17,7 @@ import org.bimserver.shared.LocalDevelopmentResourceFetcher; import org.bimserver.shared.interfaces.AdminInterface; import org.bimserver.shared.interfaces.SettingsInterface; +import org.bimserver.utils.PathUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,9 +29,9 @@ public class TestFramework { private final TestResults testResults = new TestResults(); private BimServer bimServer; - private File[] pluginDirectories; + private Path[] pluginDirectories; - public TestFramework(TestConfiguration testConfiguration, File[] pluginDirectories) { + public TestFramework(TestConfiguration testConfiguration, Path[] pluginDirectories) { this.testConfiguration = testConfiguration; this.pluginDirectories = pluginDirectories; } @@ -55,8 +40,8 @@ public void start() { if (testConfiguration.isStartEmbeddedBimServer()) { if (testConfiguration.isCleanEnvironmentFirst()) { try { - if (testConfiguration.getHomeDir().isDirectory()) { - FileUtils.forceDelete(testConfiguration.getHomeDir()); + if (Files.isDirectory(testConfiguration.getHomeDir())) { + PathUtils.removeDirectoryWithContent(testConfiguration.getHomeDir()); } } catch (IOException e) { e.printStackTrace(); @@ -66,7 +51,7 @@ public void start() { bimServerConfig.setStartEmbeddedWebServer(true); bimServerConfig.setHomeDir(testConfiguration.getHomeDir()); bimServerConfig.setPort(8080); - bimServerConfig.setResourceFetcher(new LocalDevelopmentResourceFetcher(new File("../"))); + bimServerConfig.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../"))); bimServerConfig.setClassPath(System.getProperty("java.class.path")); bimServer = new BimServer(bimServerConfig); EmbeddedWebServer embeddedWebServer = bimServer.getEmbeddedWebServer(); @@ -87,8 +72,12 @@ public void start() { LOGGER.error("", e); } } - if (!testConfiguration.getOutputFolder().exists()) { - testConfiguration.getOutputFolder().mkdir(); + if (!Files.exists(testConfiguration.getOutputFolder())) { + try { + PathUtils.removeDirectoryWithContent(testConfiguration.getOutputFolder()); + } catch (IOException e) { + e.printStackTrace(); + } } VirtualUserFactory virtualUserFactory = new VirtualUserFactory(this, testConfiguration.getBimServerClientFactory()); for (int i=0; i. - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Path; import org.bimserver.interfaces.objects.SActionState; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -42,8 +25,8 @@ public CheckinAction(TestFramework testFramework, CheckinSettings settings) { @Override public void execute(VirtualUser virtualUser) throws ServerException, UserException, PublicInterfaceNotFoundException { SProject project = virtualUser.getRandomProject(); - File randomFile = getTestFramework().getTestFile(); - String fileName = randomFile.getName(); + Path randomFile = getTestFramework().getTestFile(); + String fileName = randomFile.getFileName().toString(); String extension = fileName.substring(fileName.lastIndexOf(".") + 1); SDeserializerPluginConfiguration suggestedDeserializerForExtension = virtualUser.getBimServerClient().getBimsie1ServiceInterface().getSuggestedDeserializerForExtension(extension, project.getOid()); diff --git a/Tests/src/org/bimserver/test/framework/actions/DownloadModelLowLevel.java b/Tests/src/org/bimserver/test/framework/actions/DownloadModelLowLevel.java index d9793dd465..5e7db57987 100644 --- a/Tests/src/org/bimserver/test/framework/actions/DownloadModelLowLevel.java +++ b/Tests/src/org/bimserver/test/framework/actions/DownloadModelLowLevel.java @@ -1,24 +1,5 @@ package org.bimserver.test.framework.actions; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; - import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SProject; import org.bimserver.interfaces.objects.SRevision; @@ -55,7 +36,7 @@ public void execute(VirtualUser virtualUser) throws ServerException, UserExcepti Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); model.generateMinimalExpressIds(); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), null, false); - serializer.writeToFile(new File(getTestFramework().getTestConfiguration().getOutputFolder(), "test.ifc"), null); + serializer.writeToFile(getTestFramework().getTestConfiguration().getOutputFolder().resolve("test.ifc"), null); } catch (BimServerClientException e1) { e1.printStackTrace(); } catch (RenderEngineException e) { diff --git a/Tests/src/org/bimserver/test/framework/actions/DownloadRevisionAction.java b/Tests/src/org/bimserver/test/framework/actions/DownloadRevisionAction.java index 89908fdb62..3ab3a3e474 100644 --- a/Tests/src/org/bimserver/test/framework/actions/DownloadRevisionAction.java +++ b/Tests/src/org/bimserver/test/framework/actions/DownloadRevisionAction.java @@ -1,26 +1,10 @@ package org.bimserver.test.framework.actions; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.List; import org.apache.commons.io.IOUtils; @@ -81,10 +65,14 @@ public void execute(VirtualUser virtualUser) throws ServerException, UserExcepti if (downloadData != null) { PluginConfiguration pluginConfiguration = new PluginConfiguration(virtualUser.getBimServerClient().getPluginInterface().getPluginSettings(serializer.getOid())); String filename = project.getName() + "." + revision.getId() + "." + pluginConfiguration.getString(SerializerPlugin.EXTENSION); - FileOutputStream fos = new FileOutputStream(new File(getTestFramework().getTestConfiguration().getOutputFolder(), filename)); - IOUtils.copy(downloadData, fos); + Path resolve = getTestFramework().getTestConfiguration().getOutputFolder().resolve(filename); + OutputStream outputStream = Files.newOutputStream(resolve); + try { + IOUtils.copy(downloadData, outputStream); + } finally { + outputStream.close(); + } virtualUser.getLogger().info(filename + " downloaded"); - fos.close(); } else { virtualUser.getLogger().warn("Downloaddata = null..."); } diff --git a/Tests/src/org/bimserver/test/framework/tests/TestAll.java b/Tests/src/org/bimserver/test/framework/tests/TestAll.java index 2f70103abb..cd28174919 100644 --- a/Tests/src/org/bimserver/test/framework/tests/TestAll.java +++ b/Tests/src/org/bimserver/test/framework/tests/TestAll.java @@ -1,23 +1,6 @@ package org.bimserver.test.framework.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.FolderWalker; @@ -32,11 +15,11 @@ public static void main(String[] args) { TestConfiguration testConfiguration = new TestConfiguration(); TestFramework testFramework = new TestFramework(testConfiguration, new OptionsParser(args).getPluginDirectories()); - testConfiguration.setHomeDir(new File("E:\\Test")); + testConfiguration.setHomeDir(Paths.get("E:\\Test")); testConfiguration.setActionFactory(new AllActionsFactory(testFramework)); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.JSON)); - testConfiguration.setTestFileProvider(new FolderWalker(new File("E:\\Ifc Files"), testFramework)); - testConfiguration.setOutputFolder(new File("E:\\Output")); + testConfiguration.setTestFileProvider(new FolderWalker(Paths.get("E:\\Ifc Files"), testFramework)); + testConfiguration.setOutputFolder(Paths.get("E:\\Output")); testConfiguration.setNrVirtualUsers(8); testFramework.start(); diff --git a/Tests/src/org/bimserver/test/framework/tests/TestCheckin.java b/Tests/src/org/bimserver/test/framework/tests/TestCheckin.java index e69d7e247f..e61f28cf50 100644 --- a/Tests/src/org/bimserver/test/framework/tests/TestCheckin.java +++ b/Tests/src/org/bimserver/test/framework/tests/TestCheckin.java @@ -1,23 +1,6 @@ package org.bimserver.test.framework.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.FolderWalker; @@ -43,7 +26,7 @@ public static void main(String[] args) { testConfiguration.setStopNoVirtualUsers(false); // testConfiguration.setNrRunsPerVirtualUser(30); - testConfiguration.setHomeDir(new File("E:\\Testing")); + testConfiguration.setHomeDir(Paths.get("E:\\Testing")); testConfiguration.setActionFactory(new RandomActionFactory( new ActionCreater(){ public Action create() { @@ -78,9 +61,9 @@ public Action create() { )); // testConfiguration.setActionFactory(new AllActionsFactory(testFramework)); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.JSON)); - testConfiguration.setTestFileProvider(new FolderWalker(new File("E:\\Ifc Files"), testFramework)); + testConfiguration.setTestFileProvider(new FolderWalker(Paths.get("E:\\Ifc Files"), testFramework)); // testConfiguration.setTestFileProvider(new FolderWalker(new File("C:\\Users\\Ruben de Laat\\Documents\\My Dropbox\\Logic Labs\\Clients\\TNO\\ifc selected"))); - testConfiguration.setOutputFolder(new File("E:\\output")); + testConfiguration.setOutputFolder(Paths.get("E:\\output")); testConfiguration.setNrVirtualUsers(4); testFramework.start(); diff --git a/Tests/src/org/bimserver/test/framework/tests/TestCheckin2.java b/Tests/src/org/bimserver/test/framework/tests/TestCheckin2.java index d17c623c58..6134de2a5c 100644 --- a/Tests/src/org/bimserver/test/framework/tests/TestCheckin2.java +++ b/Tests/src/org/bimserver/test/framework/tests/TestCheckin2.java @@ -1,23 +1,6 @@ package org.bimserver.test.framework.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.FolderWalker; @@ -44,7 +27,7 @@ public static void main(String[] args) { testConfiguration.setStopNoVirtualUsers(false); // testConfiguration.setNrRunsPerVirtualUser(30); - testConfiguration.setHomeDir(new File("D:\\Testing")); + testConfiguration.setHomeDir(Paths.get("D:\\Testing")); testConfiguration.setActionFactory(new RandomActionFactory( new ActionCreater(){ public Action create() { @@ -84,9 +67,9 @@ public Action create() { )); // testConfiguration.setActionFactory(new AllActionsFactory(testFramework)); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.SOAP, Type.PROTOCOL_BUFFERS, Type.JSON)); - testConfiguration.setTestFileProvider(new FolderWalker(new File("D:\\ifc selected"), testFramework)); + testConfiguration.setTestFileProvider(new FolderWalker(Paths.get("D:\\ifc selected"), testFramework)); // testConfiguration.setTestFileProvider(new FolderWalker(new File("C:\\Users\\Ruben de Laat\\Documents\\My Dropbox\\Logic Labs\\Clients\\TNO\\ifc selected"))); - testConfiguration.setOutputFolder(new File("D:\\output")); + testConfiguration.setOutputFolder(Paths.get("D:\\output")); testConfiguration.setNrVirtualUsers(5); testFramework.start(); diff --git a/Tests/src/org/bimserver/test/framework/tests/TestCheckinAll.java b/Tests/src/org/bimserver/test/framework/tests/TestCheckinAll.java index 9fa1918af8..9c9863b038 100644 --- a/Tests/src/org/bimserver/test/framework/tests/TestCheckinAll.java +++ b/Tests/src/org/bimserver/test/framework/tests/TestCheckinAll.java @@ -1,23 +1,6 @@ package org.bimserver.test.framework.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.FolderWalker; @@ -32,11 +15,11 @@ public static void main(String[] args) { TestConfiguration testConfiguration = new TestConfiguration(); TestFramework testFramework = new TestFramework(testConfiguration, new OptionsParser(args).getPluginDirectories()); - testConfiguration.setHomeDir(new File("D:\\Test")); + testConfiguration.setHomeDir(Paths.get("D:\\Test")); testConfiguration.setActionFactory(new CheckinActionsFactory(testFramework)); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.JSON)); - testConfiguration.setTestFileProvider(new FolderWalker(new File("D:\\ifc selected"), testFramework)); - testConfiguration.setOutputFolder(new File("D:\\Output")); + testConfiguration.setTestFileProvider(new FolderWalker(Paths.get("D:\\ifc selected"), testFramework)); + testConfiguration.setOutputFolder(Paths.get("D:\\Output")); testConfiguration.setNrVirtualUsers(1); testFramework.start(); diff --git a/Tests/src/org/bimserver/test/framework/tests/TestCollada.java b/Tests/src/org/bimserver/test/framework/tests/TestCollada.java index bbb2130f18..2ef8ee4f8e 100644 --- a/Tests/src/org/bimserver/test/framework/tests/TestCollada.java +++ b/Tests/src/org/bimserver/test/framework/tests/TestCollada.java @@ -1,23 +1,6 @@ package org.bimserver.test.framework.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.RandomBimServerClientFactory; @@ -37,7 +20,7 @@ public static void main(String[] args) { testConfiguration.setStopOnServerException(true); testConfiguration.setStopOnUserException(false); // testConfiguration.setActionFactory(new RandomActionFactory(new CheckinAction(testFramework, new CheckinSettings()), new DownloadRevisionAction(testFramework, "Collada"))); - testConfiguration.setOutputFolder(new File("output")); + testConfiguration.setOutputFolder(Paths.get("output")); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.SOAP)); testFramework.start(); diff --git a/Tests/src/org/bimserver/test/framework/tests/TestJson.java b/Tests/src/org/bimserver/test/framework/tests/TestJson.java index e3339ae98f..8d9d115165 100644 --- a/Tests/src/org/bimserver/test/framework/tests/TestJson.java +++ b/Tests/src/org/bimserver/test/framework/tests/TestJson.java @@ -1,23 +1,6 @@ package org.bimserver.test.framework.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.FolderWalker; @@ -32,12 +15,12 @@ public static void main(String[] args) { TestConfiguration testConfiguration = new TestConfiguration(); TestFramework testFramework = new TestFramework(testConfiguration, new OptionsParser(args).getPluginDirectories()); - testConfiguration.setHomeDir(new File("G:\\Testing")); + testConfiguration.setHomeDir(Paths.get("G:\\Testing")); testConfiguration.setCleanEnvironmentFirst(true); testConfiguration.setActionFactory(new AllActionsFactory(testFramework)); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.JSON)); - testConfiguration.setTestFileProvider(new FolderWalker(new File("G:\\Ifc Files"), testFramework)); - testConfiguration.setOutputFolder(new File("G:\\Output")); + testConfiguration.setTestFileProvider(new FolderWalker(Paths.get("G:\\Ifc Files"), testFramework)); + testConfiguration.setOutputFolder(Paths.get("G:\\Output")); testConfiguration.setNrVirtualUsers(8); testFramework.start(); diff --git a/Tests/src/org/bimserver/test/framework/tests/TestProtocolBuffers.java b/Tests/src/org/bimserver/test/framework/tests/TestProtocolBuffers.java index 167156a79a..aa3a28f3b7 100644 --- a/Tests/src/org/bimserver/test/framework/tests/TestProtocolBuffers.java +++ b/Tests/src/org/bimserver/test/framework/tests/TestProtocolBuffers.java @@ -1,23 +1,7 @@ package org.bimserver.test.framework.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import org.bimserver.plugins.OptionsParser; import org.bimserver.test.framework.RandomBimServerClientFactory; @@ -33,17 +17,17 @@ public static void main(String[] args) { TestConfiguration testConfiguration = new TestConfiguration(); TestFramework testFramework = new TestFramework(testConfiguration, new OptionsParser(args).getPluginDirectories()); - testConfiguration.setHomeDir(new File("C:\\Test")); + testConfiguration.setHomeDir(Paths.get("C:\\Test")); testConfiguration.setActionFactory(new AllActionsFactory(testFramework)); testConfiguration.setBimServerClientFactory(new RandomBimServerClientFactory(testFramework, Type.PROTOCOL_BUFFERS)); testConfiguration.setTestFileProvider(new TestFileProvider() { @Override - public File getNewFile() { - return new File(TestFileConstants.DATA_FOLDER, "AC11-Institute-Var-2-IFC.ifc"); + public Path getNewFile() { + return TestFileConstants.DATA_FOLDER.resolve("AC11-Institute-Var-2-IFC.ifc") ; } }); - testConfiguration.setOutputFolder(new File("output")); + testConfiguration.setOutputFolder(Paths.get("output")); testConfiguration.setNrVirtualUsers(2); testFramework.start(); diff --git a/Tests/src/org/bimserver/tests/Bla.java b/Tests/src/org/bimserver/tests/Bla.java index 908b8db7b8..803c157c4e 100644 --- a/Tests/src/org/bimserver/tests/Bla.java +++ b/Tests/src/org/bimserver/tests/Bla.java @@ -18,11 +18,12 @@ *****************************************************************************/ import java.io.BufferedReader; -import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Set; import java.util.TreeSet; @@ -32,14 +33,14 @@ public static void main(String[] args) { } private void start() { - sortFile(TestFile.MERGE_TEST_SOURCE_FILE.getFile(), new File("1.ifc")); - sortFile(new File("in.ifc"), new File("2.ifc")); + sortFile(TestFile.MERGE_TEST_SOURCE_FILE.getFile(), Paths.get("1.ifc")); + sortFile(Paths.get("in.ifc"), Paths.get("2.ifc")); } - public static void sortFile(File sourceFile, File destFile) { + public static void sortFile(Path sourceFile, Path destFile) { try { System.out.println(sourceFile); - BufferedReader reader = new BufferedReader(new FileReader(sourceFile)); + BufferedReader reader = new BufferedReader(new FileReader(sourceFile.toFile())); String line = reader.readLine(); Set lines = new TreeSet(); while (line != null) { @@ -51,7 +52,7 @@ public static void sortFile(File sourceFile, File destFile) { line = reader.readLine(); } reader.close(); - PrintWriter out = new PrintWriter(destFile); + PrintWriter out = new PrintWriter(destFile.toFile()); for (String r : lines) { out.write(r + "\n"); } diff --git a/Tests/src/org/bimserver/tests/ChangeSetTest.java b/Tests/src/org/bimserver/tests/ChangeSetTest.java index fb1fb65f2f..73fdacdffa 100644 --- a/Tests/src/org/bimserver/tests/ChangeSetTest.java +++ b/Tests/src/org/bimserver/tests/ChangeSetTest.java @@ -59,7 +59,7 @@ // } // // private void start() { -// File dataDir = new File("../BimServer/database"); +// File dataDir = Paths.get("../BimServer/database"); // FileUtils.removeDir(dataDir); // BerkeleyColumnDatabase columnDatabase = new BerkeleyColumnDatabase(dataDir); // packages = new HashSet(); @@ -75,15 +75,15 @@ // Revision checkInModel = checkInModel(ModelConverter.newIfcModel(model), pid, uid, TestFile.WALL_ONLY.getFile().getName()); // check(1); // -// ChangeSetResult processChangeSet = processChangeSet(new File("ChangeSetAuto.xml")); +// ChangeSetResult processChangeSet = processChangeSet(Paths.get("ChangeSetAuto.xml")); // check(processChangeSet.getNewRevisionNr()); // } // // private void check(int rid) { -// File dataDir = new File("../BimServer/database"); +// File dataDir = Paths.get("../BimServer/database"); // BerkeleyColumnDatabase columnDatabase = new BerkeleyColumnDatabase(dataDir); // IfcModel newModel2 = downloadModel(pid, rid); -// writeToFile(ModelConverter.newIfcModel(newModel2), new File("files" + File.separator + "test." + rid + ".ifc")); +// writeToFile(ModelConverter.newIfcModel(newModel2), Paths.get("files" + File.separator + "test." + rid + ".ifc")); // } // // private void writeToFile(IfcModel newModel, File file) { diff --git a/Tests/src/org/bimserver/tests/CityGmlTest.java b/Tests/src/org/bimserver/tests/CityGmlTest.java index 3caf99912c..eff6f0c1a1 100644 --- a/Tests/src/org/bimserver/tests/CityGmlTest.java +++ b/Tests/src/org/bimserver/tests/CityGmlTest.java @@ -1,25 +1,8 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterface; @@ -36,7 +19,7 @@ public class CityGmlTest { public static void main(String[] args) { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.requireDeserializer("ifc"); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); @@ -44,7 +27,7 @@ public static void main(String[] args) { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.citygml.CityGmlSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), null, false); - FileOutputStream fos = new FileOutputStream(new File("out.gml")); + FileOutputStream fos = new FileOutputStream(Paths.get("out.gml").toFile()); serializer.writeToOutputStream(fos, null); fos.close(); } catch (PluginException e2) { diff --git a/Tests/src/org/bimserver/tests/ColladaTester.java b/Tests/src/org/bimserver/tests/ColladaTester.java index a2d65ed356..000e4050f1 100644 --- a/Tests/src/org/bimserver/tests/ColladaTester.java +++ b/Tests/src/org/bimserver/tests/ColladaTester.java @@ -42,14 +42,14 @@ // } // // private void start() { -// File ifcSchemaFile = new File("C:\\Users\\Ruben\\Workspaces\\BIMserver\\BimServer\\deploy\\shared\\IFC2X3_TC1.exp"); +// File ifcSchemaFile = Paths.get("C:\\Users\\Ruben\\Workspaces\\BIMserver\\BimServer\\deploy\\shared\\IFC2X3_TC1.exp"); // ExpressSchemaParser schemaParser = new ExpressSchemaParser(ifcSchemaFile); // schemaParser.parse(); // SchemaDefinition schema = schemaParser.getSchema(); // try { // new DerivedReader(ifcSchemaFile, schema); // FastIfcFileReader fastIfcFileReader = new FastIfcFileReader(schema); -// fastIfcFileReader.read(new File("C:\\Users\\Ruben\\Workspaces\\BIMserver\\TestData\\data\\AC11-Institute-Var-2-IFC.ifc")); +// fastIfcFileReader.read(Paths.get("C:\\Users\\Ruben\\Workspaces\\BIMserver\\TestData\\data\\AC11-Institute-Var-2-IFC.ifc")); // IfcModel model = fastIfcFileReader.getModel(); // LocalDevelopmentResourceFetcher resourceFetcher = new LocalDevelopmentResourceFetcher(); // Set packages = CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE); @@ -60,7 +60,7 @@ // for (int i=0; i<100; i++) { // System.out.println(i); // ColladaSerializer colladaSerializer = new ColladaSerializer("test", model, schema, fieldIgnoreMap, failSafeIfcEngine); -// colladaSerializer.writeToFile(new File("test" + i + ".collada")); +// colladaSerializer.writeToFile(Paths.get("test" + i + ".collada")); // } // } catch (FileNotFoundException e) { // e.printStackTrace(); diff --git a/Tests/src/org/bimserver/tests/CompareTest.java b/Tests/src/org/bimserver/tests/CompareTest.java index 58fe31e7aa..ab0ad19c59 100644 --- a/Tests/src/org/bimserver/tests/CompareTest.java +++ b/Tests/src/org/bimserver/tests/CompareTest.java @@ -18,6 +18,8 @@ *****************************************************************************/ import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -42,10 +44,10 @@ public static void main(String[] args) { @SuppressWarnings("rawtypes") private void start() { - File file1 = new File("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\_IFC revisies wozoco\\1407_WE_WOZOCO_versie_1_general_translator.ifc"); - File file2 = new File("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\_IFC revisies wozoco\\1407_WE_WOZOCO_versie_2_verplaatsen_binnenwandje.ifc"); + Path file1 = Paths.get("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\_IFC revisies wozoco\\1407_WE_WOZOCO_versie_1_general_translator.ifc"); + Path file2 = Paths.get("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\_IFC revisies wozoco\\1407_WE_WOZOCO_versie_2_verplaatsen_binnenwandje.ifc"); try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); IfcModelInterface model1 = readModel(file1, pluginManager); IfcModelInterface model2 = readModel(file2, pluginManager); @@ -127,7 +129,7 @@ private void dumpObject(IdEObject idEObject) { } } - private IfcModelInterface readModel(File file1, PluginManager pluginManager) throws DeserializeException, PluginException { + private IfcModelInterface readModel(Path file1, PluginManager pluginManager) throws DeserializeException, PluginException { Deserializer deserializer = pluginManager.requireDeserializer("ifc").createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); IfcModelInterface model1 = deserializer.read(file1); diff --git a/Tests/src/org/bimserver/tests/CreateRunTest.java b/Tests/src/org/bimserver/tests/CreateRunTest.java deleted file mode 100644 index 21a5a2aca7..0000000000 --- a/Tests/src/org/bimserver/tests/CreateRunTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.bimserver.tests; - -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; - -public class CreateRunTest { - public static void main(String[] args) { - new CreateRunTest().start(); - } - - private void start() { - try { - PrintWriter out = new PrintWriter(new File("runtest.sh")); - out.println("#!/bin/sh"); - addEclipseProject(out, new File("BimCombined")); - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void addEclipseProject(PrintWriter out, File projectFolder) { - } -} \ No newline at end of file diff --git a/Tests/src/org/bimserver/tests/DatabaseDebugger.java b/Tests/src/org/bimserver/tests/DatabaseDebugger.java index 6bc5173915..85733cdf19 100644 --- a/Tests/src/org/bimserver/tests/DatabaseDebugger.java +++ b/Tests/src/org/bimserver/tests/DatabaseDebugger.java @@ -77,12 +77,12 @@ // this.emfPackages.add(Ifc2x3tc1Package.eINSTANCE); // // try { -// fieldIgnoreMap = new FileFieldIgnoreMap(emfPackages, new File("../BimServer/www/WEB-INF/ignore.xml").toURI().toURL()); +// fieldIgnoreMap = new FileFieldIgnoreMap(emfPackages, Paths.get("../BimServer/www/WEB-INF/ignore.xml").toURI().toURL()); // } catch (MalformedURLException e1) { // e1.printStackTrace(); // } // -// columnDatabase = new BerkeleyColumnDatabase(new File("../BimServer/database")); +// columnDatabase = new BerkeleyColumnDatabase(Paths.get("../BimServer/database")); // initInternalStructure(); // // JPanel selectPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); diff --git a/Tests/src/org/bimserver/tests/DatabaseTester.java b/Tests/src/org/bimserver/tests/DatabaseTester.java index 4cfa4ae0d4..bf6f08a62a 100644 --- a/Tests/src/org/bimserver/tests/DatabaseTester.java +++ b/Tests/src/org/bimserver/tests/DatabaseTester.java @@ -55,7 +55,7 @@ // schemaParser.parse(); // schema = schemaParser.getSchema(); // -// File dataDir = new File("../BimServer/database"); +// File dataDir = Paths.get("../BimServer/database"); // FileUtils.removeDir(dataDir); // ColumnDatabase cdb = new BerkeleyColumnDatabase(dataDir); // HashSet packages = CollectionUtils.singleSet((EPackage) Ifc2x3tc1Package.eINSTANCE); @@ -202,7 +202,7 @@ //// //// IfcFileWriter writer = new IfcFileWriter(ModelConverter.newIfcModel(checkout), schema); //// try { -//// writer.write(new File("tmp" + revisionNr + ".ifc")); +//// writer.write(Paths.get("tmp" + revisionNr + ".ifc")); //// } catch (FileNotFoundException e) { //// e.printStackTrace(); //// } diff --git a/Tests/src/org/bimserver/tests/FileLoader.java b/Tests/src/org/bimserver/tests/FileLoader.java index f53122670c..cc17b9205b 100644 --- a/Tests/src/org/bimserver/tests/FileLoader.java +++ b/Tests/src/org/bimserver/tests/FileLoader.java @@ -1,24 +1,8 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.ThreadPoolExecutor; @@ -31,27 +15,28 @@ import org.bimserver.shared.PublicInterfaceNotFoundException; import org.bimserver.shared.exceptions.ServerException; import org.bimserver.shared.exceptions.UserException; +import org.bimserver.utils.PathUtils; public class FileLoader { public static void main(String[] args) { - new FileLoader().load(new File("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\LOD modellen")); + new FileLoader().load(Paths.get("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\LOD modellen")); } - private void load(File dir) { + private void load(Path dir) { // JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://sandbox.bimserver.org"); try { final BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080"); ExecutorService executorService = new ThreadPoolExecutor(1, 1, 1, TimeUnit.HOURS, new ArrayBlockingQueue(200)); - for (final File file : dir.listFiles()) { + for (final Path file : PathUtils.getDirectories(dir)) { executorService.submit(new Runnable(){ @Override public void run() { - System.out.println(file.getName()); + System.out.println(file.getFileName()); SProject project; try { - project = client.getBimsie1ServiceInterface().addProject(file.getName(), "ifc2x3tc1"); + project = client.getBimsie1ServiceInterface().addProject(file.getFileName().toString(), "ifc2x3tc1"); SDeserializerPluginConfiguration deserializer = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); - client.checkin(project.getOid(), file.getName(), deserializer.getOid(), false, true, file); + client.checkin(project.getOid(), file.getFileName().toString(), deserializer.getOid(), false, true, file); } catch (ServerException e) { e.printStackTrace(); } catch (UserException e) { @@ -67,6 +52,8 @@ public void run() { System.out.println("Done"); } catch (InterruptedException e) { e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } } } \ No newline at end of file diff --git a/Tests/src/org/bimserver/tests/GetLogs.java b/Tests/src/org/bimserver/tests/GetLogs.java index b5cf49b29c..21d48a8b4b 100644 --- a/Tests/src/org/bimserver/tests/GetLogs.java +++ b/Tests/src/org/bimserver/tests/GetLogs.java @@ -1,25 +1,9 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.HashMap; @@ -66,8 +50,8 @@ private void start() { try { client = factory.create(new UsernamePasswordAuthenticationInfo("[ADD]", "[ADD]")); List logs = client.getAdminInterface().getLogs(); - File file = new File("log.txt"); - writer = new PrintWriter(file); + Path file = Paths.get("log.txt"); + writer = new PrintWriter(file.toFile()); try { for (SLogAction sLogAction : logs) { if (sLogAction instanceof SDatabaseCreated) { diff --git a/Tests/src/org/bimserver/tests/GuidHighlighter.java b/Tests/src/org/bimserver/tests/GuidHighlighter.java index 2248b0d9fd..8429e2b562 100644 --- a/Tests/src/org/bimserver/tests/GuidHighlighter.java +++ b/Tests/src/org/bimserver/tests/GuidHighlighter.java @@ -1,23 +1,7 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashSet; import java.util.Set; @@ -47,9 +31,9 @@ import org.bimserver.plugins.serializers.SerializerPlugin; public class GuidHighlighter { - public GuidHighlighter(SchemaDefinition schema, IfcModelInterface model, File outputFile, Set highlightedGuids) { + public GuidHighlighter(SchemaDefinition schema, IfcModelInterface model, Path outputFile, Set highlightedGuids) { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); highlightGuids(model, highlightedGuids); SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); diff --git a/Tests/src/org/bimserver/tests/GuidHighlighterTester.java b/Tests/src/org/bimserver/tests/GuidHighlighterTester.java index c784e76d2a..c788768c99 100644 --- a/Tests/src/org/bimserver/tests/GuidHighlighterTester.java +++ b/Tests/src/org/bimserver/tests/GuidHighlighterTester.java @@ -23,6 +23,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.HashSet; import java.util.Set; @@ -69,10 +71,10 @@ public static Set readGuidsFromFile(File file) { return null; } - public IfcModelInterface readModel(File file) { + public IfcModelInterface readModel(Path file) { PluginManager pluginManager; try { - pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); @@ -89,11 +91,11 @@ public IfcModelInterface readModel(File file) { } private void start() { -// File lars = new File("C:\\Users\\Ruben\\Documents\\My Dropbox\\Logic Labs\\Projecten\\BIMserver\\Lars\\"); -// Set highlightedGuids = readGuidsFromFile(new File(lars, "missing.csv")); +// File lars = Paths.get("C:\\Users\\Ruben\\Documents\\My Dropbox\\Logic Labs\\Projecten\\BIMserver\\Lars\\"); +// Set highlightedGuids = readGuidsFromFile(Paths.get(lars, "missing.csv")); // System.out.println(highlightedGuids.size() + " GUIDs"); -// File inputFile1 = new File(lars, "2440_ARK_Alt4.ifc"); -// File inputFile2 = new File(lars, "612252_RIV_Alt4.ifc"); +// File inputFile1 = Paths.get(lars, "2440_ARK_Alt4.ifc"); +// File inputFile2 = Paths.get(lars, "612252_RIV_Alt4.ifc"); // ModelMerger merger = new IntelligentGuidBasedModelMerger(); // IfcModelInterface model1 = readModel(inputFile1); // IfcModelInterface model2 = readModel(inputFile2); @@ -102,7 +104,7 @@ private void start() { // IfcModelInterface mergedModel; // try { // mergedModel = merger.merge(null, modelSet); -// new GuidHighlighter(schema, mergedModel, new File(lars, "output.ifc"), highlightedGuids); +// new GuidHighlighter(schema, mergedModel, Paths.get(lars, "output.ifc"), highlightedGuids); // } catch (MergeException e) { // e.printStackTrace(); // } diff --git a/Tests/src/org/bimserver/tests/Ifc2CodbTest.java b/Tests/src/org/bimserver/tests/Ifc2CodbTest.java index ab1277abf9..c3cb9d87d3 100644 --- a/Tests/src/org/bimserver/tests/Ifc2CodbTest.java +++ b/Tests/src/org/bimserver/tests/Ifc2CodbTest.java @@ -52,7 +52,7 @@ // } // // private void start() { -// File dataDir = new File("../BimServer/database"); +// File dataDir = Paths.get("../BimServer/database"); // FileUtils.removeDir(dataDir); // BerkeleyColumnDatabase columnDatabase = new BerkeleyColumnDatabase(dataDir); // packages = new HashSet(); @@ -78,19 +78,19 @@ // // pid, uid, TestFile.HAUS_SOURCE_FILE.getFile().getName()); // // IfcModel newModel1 = downloadModel(revision1.getProject().getId(), // // revision1.getId()); -// // writeToFile(newModel1, new File("files" + File.separator + "test." + +// // writeToFile(newModel1, Paths.get("files" + File.separator + "test." + // // TestFile.HAUS_SOURCE_FILE.getFile().getName())); // // IfcModel newModel2 = downloadModel(revision2.getProject().getId(), // // revision2.getId()); -// // writeToFile(newModel2, new File("files" + File.separator + "test." + +// // writeToFile(newModel2, Paths.get("files" + File.separator + "test." + // // TestFile.MERGE_TEST_SOURCE_FILE.getFile().getName())); // // IfcModel newModel3 = downloadModel(revision3.getProject().getId(), // // revision3.getId()); -// // writeToFile(newModel3, new File("files" + File.separator + "test." + +// // writeToFile(newModel3, Paths.get("files" + File.separator + "test." + // // TestFile.NIEDRI.getFile().getName())); // // IfcModel newModel4 = downloadModel(revision4.getProject().getId(), // // revision4.getId()); -// // writeToFile(newModel4, new File("files" + File.separator + "test." + +// // writeToFile(newModel4, Paths.get("files" + File.separator + "test." + // // TestFile.HAUS_SOURCE_FILE.getFile().getName())); // // // pid = createProject("project"); @@ -108,11 +108,11 @@ // // uid, TestFile.EMPTY_TEST.getFile().getName()); // // IfcModel newModel1 = downloadModel(revision1.getProject().getId(), // // revision1.getId()); -// // writeToFile(newModel1, new File("files" + File.separator + "test." + +// // writeToFile(newModel1, Paths.get("files" + File.separator + "test." + // // TestFile.NIEDRI.getFile().getName())); // // IfcModel newModel2 = downloadModel(revision2.getProject().getId(), // // revision2.getId()); -// // writeToFile(newModel2, new File("files" + File.separator + "test." + +// // writeToFile(newModel2, Paths.get("files" + File.separator + "test." + // // TestFile.EMPTY_TEST.getFile().getName())); // // // int j=1; @@ -127,7 +127,7 @@ // model = null; // System.gc(); // IfcModel newModel = downloadModel(revision.getProject().getId(), revision.getId()); -// writeToFile(ModelConverter.newIfcModel(newModel), new File("files" + File.separator + "test." + testFile.getFile().getName())); +// writeToFile(ModelConverter.newIfcModel(newModel), Paths.get("files" + File.separator + "test." + testFile.getFile().getName())); // } // } // // writeToFile(newModel); @@ -142,11 +142,11 @@ // } // // private void check(Revision revision) { -// File dataDir = new File("../BimServer/database"); +// File dataDir = Paths.get("../BimServer/database"); // BerkeleyColumnDatabase columnDatabase = new BerkeleyColumnDatabase(dataDir); // database = new Database(packages, columnDatabase, new FieldIgnoreMap(packages)); // IfcModel newModel2 = downloadModel(revision.getProject().getId(), revision.getId()); -// writeToFile(ModelConverter.newIfcModel(newModel2), new File("files" + File.separator + "test." + revision.getId() + "." +// writeToFile(ModelConverter.newIfcModel(newModel2), Paths.get("files" + File.separator + "test." + revision.getId() + "." // + TestFile.EMPTY_TEST.getFile().getName())); // database.close(); // } diff --git a/Tests/src/org/bimserver/tests/IfcRioleringTest.java b/Tests/src/org/bimserver/tests/IfcRioleringTest.java index 287d3fdb39..6647875cf8 100644 --- a/Tests/src/org/bimserver/tests/IfcRioleringTest.java +++ b/Tests/src/org/bimserver/tests/IfcRioleringTest.java @@ -1,23 +1,7 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import org.bimserver.LocalDevPluginLoader; @@ -47,10 +31,10 @@ public static void main(String[] args) { } private void start() { - File src = TestFile.RIOLERING_TEST.getFile(); + Path src = TestFile.RIOLERING_TEST.getFile(); PluginManager pluginManager; try { - pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); diff --git a/Tests/src/org/bimserver/tests/IfcToBerkeleyAndBackTest.java b/Tests/src/org/bimserver/tests/IfcToBerkeleyAndBackTest.java index e871821f11..635c6d67c7 100644 --- a/Tests/src/org/bimserver/tests/IfcToBerkeleyAndBackTest.java +++ b/Tests/src/org/bimserver/tests/IfcToBerkeleyAndBackTest.java @@ -47,10 +47,10 @@ // // try { // File src = TestFileConstants.HITOS_SOURCE_FILE; -// File dest = new File("test.txt"); +// File dest = Paths.get("test.txt"); // // Map map = new IfcFileReader().read(schemaDefinition, src); -// database = new BerkeleyColumnDatabase(new File("bdb")); +// database = new BerkeleyColumnDatabase(Paths.get("bdb")); // Transaction writeTransaction = null;//database.startTransaction(); // try { // BerkeleyIfcWriter berkeleyIfcWriter = new BerkeleyIfcWriter(database); diff --git a/Tests/src/org/bimserver/tests/IfcToEmfAndBackTest.java b/Tests/src/org/bimserver/tests/IfcToEmfAndBackTest.java index e64ca435dd..55e08bf27b 100644 --- a/Tests/src/org/bimserver/tests/IfcToEmfAndBackTest.java +++ b/Tests/src/org/bimserver/tests/IfcToEmfAndBackTest.java @@ -41,7 +41,7 @@ //import org.bimserver.ifc.file.writer.IfcStepSerializer; // //public class IfcToEmfAndBackTest { -// private final HtmlWriter htmlWriter = new HtmlWriter(new File("result.html")); +// private final HtmlWriter htmlWriter = new HtmlWriter(Paths.get("result.html")); // // private class Result { // public Result(File sourceFile) { @@ -142,7 +142,7 @@ //// } //// }); //// } -//// File dir = new File("G:\\ifc selected"); +//// File dir = Paths.get("G:\\ifc selected"); //// for (final File file : dir.listFiles()) { //// if (file.getName().endsWith(".ifc")) { //// completionService.submit(new Callable() { @@ -175,11 +175,11 @@ // } // htmlWriter.endTable(); // htmlWriter.close(); -// // test(new File("G:\\ifc selected\\00000 test.ifc")); +// // test(Paths.get("G:\\ifc selected\\00000 test.ifc")); // } // // private Result test(File sourceFile) { -// File destFile = new File(sourceFile.getAbsolutePath() + ".dump"); +// File destFile = Paths.get(sourceFile.getAbsolutePath() + ".dump"); // Result result = new Result(sourceFile); // IfcModel model = null; // try { @@ -194,13 +194,13 @@ // } catch (InterruptedException e1) { // e1.printStackTrace(); // } -// sourceFile.renameTo(new File("incorrect\\" + sourceFile.getName())); +// sourceFile.renameTo(Paths.get("incorrect\\" + sourceFile.getName())); // return result; // } catch (Exception e) { // e.printStackTrace(); // result.setReadSuccess(false); // result.setReadError(e.getMessage()); -// sourceFile.renameTo(new File("incorrect\\" + sourceFile.getName())); +// sourceFile.renameTo(Paths.get("incorrect\\" + sourceFile.getName())); // return result; // } // result.setReadSuccess(true); @@ -218,10 +218,10 @@ // NewIfcFileCompare compare = new NewIfcFileCompare(sourceFile, destFile); // boolean compare2 = compare.compare(); // if (compare2) { -// sourceFile.renameTo(new File("oke\\" + sourceFile.getName())); +// sourceFile.renameTo(Paths.get("oke\\" + sourceFile.getName())); // } else { -// compare.dumpSource(new File("faults\\" + sourceFile.getName() + ".1")); -// compare.dumpGenerated(new File("faults\\" + sourceFile.getName() + ".2")); +// compare.dumpSource(Paths.get("faults\\" + sourceFile.getName() + ".1")); +// compare.dumpGenerated(Paths.get("faults\\" + sourceFile.getName() + ".2")); // } // result.setCompareResult(compare2); // } catch (Exception e) { diff --git a/Tests/src/org/bimserver/tests/IfcXmlReadTest.java b/Tests/src/org/bimserver/tests/IfcXmlReadTest.java index a26430f18a..2c7cef9209 100644 --- a/Tests/src/org/bimserver/tests/IfcXmlReadTest.java +++ b/Tests/src/org/bimserver/tests/IfcXmlReadTest.java @@ -1,25 +1,9 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.nio.file.Path; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterface; @@ -40,14 +24,14 @@ public static void main(String[] args) { private void start() { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifcxml", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); try { - File file = TestFile.AC11_XML.getFile(); - IfcModelInterface model = deserializer.read(new FileInputStream(file), "ac11.ifcxml", file.length()); + Path file = TestFile.AC11_XML.getFile(); + IfcModelInterface model = deserializer.read(new FileInputStream(file.toFile()), "ac11.ifcxml", file.toFile().length()); - File outFile = new File("out.ifc"); + Path outFile = Paths.get("out.ifc"); SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), null, false); diff --git a/Tests/src/org/bimserver/tests/LargeFileTest.java b/Tests/src/org/bimserver/tests/LargeFileTest.java index 79c0ee570e..6e9fc31cfa 100644 --- a/Tests/src/org/bimserver/tests/LargeFileTest.java +++ b/Tests/src/org/bimserver/tests/LargeFileTest.java @@ -1,23 +1,6 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import java.util.List; import org.bimserver.LocalDevPluginLoader; @@ -41,11 +24,11 @@ public static void main(String[] args) { private void start() { PluginManager pluginManager; try { - pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); - IfcModelInterface model = deserializer.read(new File("C:\\Users\\Ruben de Laat\\Documents\\My Dropbox\\Shared\\BIMserver\\arcadis\\KW02.ifc")); + IfcModelInterface model = deserializer.read(Paths.get("C:\\Users\\Ruben de Laat\\Documents\\My Dropbox\\Shared\\BIMserver\\arcadis\\KW02.ifc")); for (IdEObject idEObject : model.getValues()) { for (EStructuralFeature eStructuralFeature : idEObject.eClass().getEAllStructuralFeatures()) { if (eStructuralFeature.isMany()) { diff --git a/Tests/src/org/bimserver/tests/MergeTest.java b/Tests/src/org/bimserver/tests/MergeTest.java index c3ee4a0b92..a546c7d3f3 100644 --- a/Tests/src/org/bimserver/tests/MergeTest.java +++ b/Tests/src/org/bimserver/tests/MergeTest.java @@ -24,13 +24,13 @@ public static void main(String[] args) { private void start() { // try { -// PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); +// PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); // DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", true); // EmfDeserializer deserializer = deserializerPlugin.createDeserializer(); // deserializer.init(pluginManager.requireSchemaDefinition()); -//// File baseFolder = new File("C:\\Users\\Ruben de Laat\\Documents\\My Dropbox\\Logic Labs\\Projecten\\BIMserver\\IFCFiles"); -//// IfcModel model1 = deserializer.read(new File(baseFolder, "Constructiedeel.ifc")); -//// IfcModel model2 = deserializer.read(new File(baseFolder, "Installatiedeel.ifc")); +//// File baseFolder = Paths.get("C:\\Users\\Ruben de Laat\\Documents\\My Dropbox\\Logic Labs\\Projecten\\BIMserver\\IFCFiles"); +//// IfcModel model1 = deserializer.read(Paths.get(baseFolder, "Constructiedeel.ifc")); +//// IfcModel model2 = deserializer.read(Paths.get(baseFolder, "Installatiedeel.ifc")); // // IfcModelInterface model1 = deserializer.read(TestFile.EXPORT1.getFile(), true); // IfcModelInterface model2 = deserializer.read(TestFile.EXPORT1.getFile(), true); @@ -47,7 +47,7 @@ private void start() { // SerializerPlugin serializerPlugin = pluginManager.getFirstSerializerPlugin("application/ifc", true); // EmfSerializer serializer = serializerPlugin.createSerializer(); // serializer.init(merged, null, null, pluginManager.requireIfcEngine().createIfcEngine()); -// serializer.writeToFile(new File("merged.ifc")); +// serializer.writeToFile(Paths.get("merged.ifc")); // } catch (Exception e) { // e.printStackTrace(); // } diff --git a/Tests/src/org/bimserver/tests/NewDatabaseTester.java b/Tests/src/org/bimserver/tests/NewDatabaseTester.java index 93c9362745..b5477b927f 100644 --- a/Tests/src/org/bimserver/tests/NewDatabaseTester.java +++ b/Tests/src/org/bimserver/tests/NewDatabaseTester.java @@ -59,7 +59,7 @@ // @Override // public URL getResource(String name) { // try { -// File file = new File("C:\\Workspaces\\BimServer\\BimServer\\www\\WEB-INF\\" + name); +// File file = Paths.get("C:\\Workspaces\\BimServer\\BimServer\\www\\WEB-INF\\" + name); // if (file.exists()) { // return new URL("file:///" + file.getAbsolutePath()); // } else { @@ -70,7 +70,7 @@ // return null; // } // }; -// File schemaFile = new File("../BimServer/www/WEB-INF/IFC2x3_FINAL.exp"); +// File schemaFile = Paths.get("../BimServer/www/WEB-INF/IFC2x3_FINAL.exp"); // ExpressSchemaParser schemaParser = new ExpressSchemaParser(schemaFile); // schemaParser.parse(); // final SchemaDefinition schema = schemaParser.getSchema(); @@ -80,7 +80,7 @@ // e1.printStackTrace(); // } // final FileFieldIgnoreMap fieldIgnoreMap = new FileFieldIgnoreMap(packages, resourceFetcher); -// File databaseDir = new File("database"); +// File databaseDir = Paths.get("database"); // BerkeleyColumnDatabase columnDatabase; // try { // columnDatabase = new BerkeleyColumnDatabase(databaseDir); diff --git a/Tests/src/org/bimserver/tests/PerformanceTester.java b/Tests/src/org/bimserver/tests/PerformanceTester.java index 992dbd1ece..fcbf9a9ee7 100644 --- a/Tests/src/org/bimserver/tests/PerformanceTester.java +++ b/Tests/src/org/bimserver/tests/PerformanceTester.java @@ -66,7 +66,7 @@ // Set packages = CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE); // FieldIgnoreMap fieldIgnoreMap = new FileFieldIgnoreMap(packages, resourceFetcher); // try { -// File dataDir = new File("database_tmp"); +// File dataDir = Paths.get("database_tmp"); // BerkeleyColumnDatabase columnDatabase = new BerkeleyColumnDatabase(dataDir); // Database database = new Database(packages, columnDatabase, fieldIgnoreMap); // EmfSerializerFactory emfSerializerFactory = EmfSerializerFactory.getInstance(); @@ -74,13 +74,13 @@ // TokenManager tokenManager = new TokenManager(); // LongActionManager longActionManager = new LongActionManager(); // longActionManager.start(); -// File nativeFolder = new File("../IfcEngine/lib"); -// File schemaFile = new File("../BimServer/deploy/shared/IFC2X3_TC1.exp"); +// File nativeFolder = Paths.get("../IfcEngine/lib"); +// File schemaFile = Paths.get("../BimServer/deploy/shared/IFC2X3_TC1.exp"); // ExpressSchemaParser schemaParser = new ExpressSchemaParser(schemaFile); // schemaParser.parse(); // SchemaDefinition schema = schemaParser.getSchema(); // new DerivedReader(schemaFile, schema); -// ServerSettings.setSettings(Settings.readFromFile(new File("../BimServer/deploy/local/settings.xml"))); +// ServerSettings.setSettings(Settings.readFromFile(Paths.get("../BimServer/deploy/local/settings.xml"))); // FailSafeIfcEngine failSafeIfcEngine = new FailSafeIfcEngine(schemaFile, nativeFolder, resourceFetcher, true); // emfSerializerFactory.init(version, schema, fieldIgnoreMap, failSafeIfcEngine); // emfSerializerFactory.initSerializers(); diff --git a/Tests/src/org/bimserver/tests/ReadTest.java b/Tests/src/org/bimserver/tests/ReadTest.java index 4ffd190136..2e756dd667 100644 --- a/Tests/src/org/bimserver/tests/ReadTest.java +++ b/Tests/src/org/bimserver/tests/ReadTest.java @@ -1,26 +1,9 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -39,8 +22,8 @@ public Field(byte type, byte nrComponents) { public static void main(String[] args) { try { -// FileInputStream fis = new FileInputStream(new File("C:\\Documents and Settings\\Ruben de Laat\\My Documents\\index-buffers.bin")); - FileInputStream fis = new FileInputStream(new File("C:\\Workspaces\\BimServer\\BimServer\\www\\index-buffers.bin")); +// FileInputStream fis = new FileInputStream(Paths.get("C:\\Documents and Settings\\Ruben de Laat\\My Documents\\index-buffers.bin")); + FileInputStream fis = new FileInputStream(Paths.get("C:\\Workspaces\\BimServer\\BimServer\\www\\index-buffers.bin").toFile()); byte[] buffer = new byte[4]; fis.read(buffer); System.out.println("id: " + new String(buffer, "ASCII")); diff --git a/Tests/src/org/bimserver/tests/RevisionMergeTest.java b/Tests/src/org/bimserver/tests/RevisionMergeTest.java index 9cea57b76a..fe96979519 100644 --- a/Tests/src/org/bimserver/tests/RevisionMergeTest.java +++ b/Tests/src/org/bimserver/tests/RevisionMergeTest.java @@ -1,23 +1,6 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterface; @@ -39,7 +22,7 @@ public static void main(String[] args) { private void start() { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); @@ -54,7 +37,7 @@ private void start() { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); serializer.init(merged, null, null, pluginManager.requireRenderEngine(), null, false); - serializer.writeToFile(new File("merged.ifc"), null); + serializer.writeToFile(Paths.get("merged.ifc"), null); } catch (Exception e) { e.printStackTrace(); } diff --git a/Tests/src/org/bimserver/tests/RudeBackup.java b/Tests/src/org/bimserver/tests/RudeBackup.java index 1c1eb87464..9e6a5bb145 100644 --- a/Tests/src/org/bimserver/tests/RudeBackup.java +++ b/Tests/src/org/bimserver/tests/RudeBackup.java @@ -77,7 +77,7 @@ // } // CheckoutResult download = service.download(token, pid, lastRevision.getId(), ResultType.IFC); // InputStream inputStream = download.getFile().getInputStream(); -// FileOutputStream fos = new FileOutputStream(new File(subproject.getName() + ".ifc")); +// FileOutputStream fos = new FileOutputStream(Paths.get(subproject.getName() + ".ifc")); // IOUtils.copy(inputStream, fos); // fos.close(); // listSubProject(subproject, service, token); diff --git a/Tests/src/org/bimserver/tests/Search.java b/Tests/src/org/bimserver/tests/Search.java index 358ae0a04c..7e035e7d2e 100644 --- a/Tests/src/org/bimserver/tests/Search.java +++ b/Tests/src/org/bimserver/tests/Search.java @@ -1,30 +1,17 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Scanner; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; + +import org.bimserver.utils.PathUtils; public class Search { public static void main(String[] args) { @@ -32,27 +19,31 @@ public static void main(String[] args) { } private void start() { - File file = new File("C:\\Users\\Ruben de Laat\\Dropbox\\Logic Labs\\Clients\\TNO\\ifc selected"); + Path file = Paths.get("C:\\Users\\Ruben de Laat\\Dropbox\\Logic Labs\\Clients\\TNO\\ifc selected"); final BlockingQueue queue = new LinkedBlockingQueue(); ExecutorService executorService = new ThreadPoolExecutor(8, 8, 1000L, TimeUnit.MINUTES, queue); - for (final File f : file.listFiles()) { - Runnable runnable = new Runnable(){ - @Override - public void run() { - try { - Scanner scanner = new Scanner(f); - while (scanner.hasNextLine()) { - String line = scanner.nextLine(); - if (line.contains("SystemId")) { - System.out.println(line); + try { + for (final Path f : PathUtils.getDirectories(file)) { + Runnable runnable = new Runnable(){ + @Override + public void run() { + try { + Scanner scanner = new Scanner(f.toFile()); + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + if (line.contains("SystemId")) { + System.out.println(line); + } } + scanner.close(); + } catch (FileNotFoundException e) { + e.printStackTrace(); } - scanner.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - }}; - executorService.execute(runnable); + }}; + executorService.execute(runnable); + } + } catch (IOException e1) { + e1.printStackTrace(); } new Thread(){ public void run() { diff --git a/Tests/src/org/bimserver/tests/StructureAnalyzer.java b/Tests/src/org/bimserver/tests/StructureAnalyzer.java index e50e55fad5..d83967b3d4 100644 --- a/Tests/src/org/bimserver/tests/StructureAnalyzer.java +++ b/Tests/src/org/bimserver/tests/StructureAnalyzer.java @@ -1,25 +1,8 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileNotFoundException; import java.io.PrintWriter; +import java.nio.file.Paths; import java.util.ArrayList; import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Package; @@ -44,7 +27,7 @@ public static void main(String[] args) { private void start() { limit = 1000000; try { - out = new PrintWriter(new File("structure.txt")); + out = new PrintWriter(Paths.get("structure.txt").toFile()); } catch (FileNotFoundException e) { e.printStackTrace(); } @@ -56,7 +39,7 @@ private void start() { classifiers.add(Ifc2x3tc1Package.eINSTANCE.getEClassifier("IfcWall")); for (EClassifier ecl : classifiers) { try { - out2 = new PrintWriter(new File("structure/" + ecl.getName() + ".txt")); + out2 = new PrintWriter(Paths.get("structure/" + ecl.getName() + ".txt").toFile()); } catch (FileNotFoundException e) { e.printStackTrace(); } diff --git a/Tests/src/org/bimserver/tests/TestBimQlSoap.java b/Tests/src/org/bimserver/tests/TestBimQlSoap.java index 2a43315c26..5fb155c35b 100644 --- a/Tests/src/org/bimserver/tests/TestBimQlSoap.java +++ b/Tests/src/org/bimserver/tests/TestBimQlSoap.java @@ -1,26 +1,9 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Paths; import java.util.List; import javax.activation.DataHandler; @@ -58,7 +41,7 @@ public static void main(String[] args) { Long downloadId = bimServerClient.getBimsie1ServiceInterface().downloadQuery(revision.getOid(), queryEngine.getOid(), "Select $Var1Where $Var1.EntityType = IfcDoor", true, serializerPluginConfiguration.getOid()); SDownloadResult downloadData = bimServerClient.getBimsie1ServiceInterface().getDownloadData(downloadId); DataHandler dataHandler = downloadData.getFile(); - IOUtils.copy(dataHandler.getInputStream(), new FileOutputStream(new File("test.ifc"))); + IOUtils.copy(dataHandler.getInputStream(), new FileOutputStream(Paths.get("test.ifc").toFile())); } } } catch (ServerException e) { diff --git a/Tests/src/org/bimserver/tests/TestCityGML.java b/Tests/src/org/bimserver/tests/TestCityGML.java index ad72c210fd..23ac7b89d8 100644 --- a/Tests/src/org/bimserver/tests/TestCityGML.java +++ b/Tests/src/org/bimserver/tests/TestCityGML.java @@ -1,23 +1,5 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.nio.file.Paths; import java.util.Collection; @@ -48,9 +30,9 @@ private void start() { DeserializerPlugin deserializerPlugin = allDeserializerPlugins.iterator().next(); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); - IfcModelInterface model = deserializer.read(new File("C:\\Users\\Ruben de Laat\\Workspace\\BIMserver\\TestData\\data\\Eindhoven - TUe_model - RevitArch.ifc")); + IfcModelInterface model = deserializer.read(Paths.get("C:\\Users\\Ruben de Laat\\Workspace\\BIMserver\\TestData\\data\\Eindhoven - TUe_model - RevitArch.ifc")); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), null, false); - serializer.writeToFile(new File("output/ac11.gml"), null); + serializer.writeToFile(Paths.get("output/ac11.gml"), null); } } catch (PluginException e) { e.printStackTrace(); diff --git a/Tests/src/org/bimserver/tests/TestCollada.java b/Tests/src/org/bimserver/tests/TestCollada.java index 5d74dbf523..a6633411d9 100644 --- a/Tests/src/org/bimserver/tests/TestCollada.java +++ b/Tests/src/org/bimserver/tests/TestCollada.java @@ -1,23 +1,5 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.nio.file.Paths; import java.util.Collection; @@ -58,7 +40,7 @@ private void start() { // true); IfcModelInterface model = deserializer.read(TestFile.WALL_ONLY.getFile()); serializer.init(model, null, pluginManager, ifcEngine, null, false); - serializer.writeToFile(new File("output/ac11.dae"), null); + serializer.writeToFile(Paths.get("output/ac11.dae"), null); } } catch (PluginException e) { e.printStackTrace(); diff --git a/Tests/src/org/bimserver/tests/TestColladaSerializer.java b/Tests/src/org/bimserver/tests/TestColladaSerializer.java index e624839403..094d0dd8c5 100644 --- a/Tests/src/org/bimserver/tests/TestColladaSerializer.java +++ b/Tests/src/org/bimserver/tests/TestColladaSerializer.java @@ -1,23 +1,9 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterface; @@ -32,6 +18,7 @@ import org.bimserver.plugins.serializers.Serializer; import org.bimserver.plugins.serializers.SerializerException; import org.bimserver.plugins.serializers.SerializerPlugin; +import org.bimserver.utils.PathUtils; public class TestColladaSerializer { public static void main(String[] args) { @@ -40,16 +27,16 @@ public static void main(String[] args) { private void start() { try { - File testFiles = new File("../TestData/data"); - File output = new File("output"); - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + Path testFiles = Paths.get("../TestData/data"); + Path output = Paths.get("output"); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin ifcDeserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.collada.ColladaSerializerPlugin", true); - for (File file : testFiles.listFiles()) { - if (file.isFile() && file.getName().endsWith(".ifc") && file.getName().equals("Vogel_Gesamt.ifc")) { - System.out.println(file.getName()); + for (Path file : PathUtils.getDirectories(testFiles)) { + if (!Files.isDirectory(file) && file.getFileName().toString().endsWith(".ifc") && file.getFileName().toString().equals("Vogel_Gesamt.ifc")) { + System.out.println(file.getFileName().toString()); ProjectInfo projectInfo = new ProjectInfo(); projectInfo.setAuthorName("test"); projectInfo.setDescription(""); @@ -60,7 +47,7 @@ private void start() { Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); serializer.init(model, projectInfo, pluginManager, pluginManager.requireRenderEngine(), null, false); - serializer.writeToFile(new File(output, file.getName() + ".dae"), null); + serializer.writeToFile(output.resolve(file.getFileName().toString() + ".dae"), null); } } } catch (PluginException e) { @@ -69,6 +56,8 @@ private void start() { e.printStackTrace(); } catch (SerializerException e) { e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } } } diff --git a/Tests/src/org/bimserver/tests/TestColor.java b/Tests/src/org/bimserver/tests/TestColor.java index 45bbf77146..1a4ad81443 100644 --- a/Tests/src/org/bimserver/tests/TestColor.java +++ b/Tests/src/org/bimserver/tests/TestColor.java @@ -1,23 +1,5 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.nio.file.Paths; import java.util.Random; @@ -45,8 +27,8 @@ public static void main(String[] args) { DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); -// IfcModelInterface model = deserializer.read(new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); - IfcModelInterface model = deserializer.read(new File("D:\\Dropbox\\Shared\\BIMserver\\IFC modellen\\top secret statsbygg\\SB_11873_6_ARK_PNN_2012.02.13.ifc")); +// IfcModelInterface model = deserializer.read(Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); + IfcModelInterface model = deserializer.read(Paths.get("D:\\Dropbox\\Shared\\BIMserver\\IFC modellen\\top secret statsbygg\\SB_11873_6_ARK_PNN_2012.02.13.ifc")); model.fixOidCounter(); // ModelColorizer modelColorizer = new ModelColorizer(model); Random random = new Random(); @@ -76,7 +58,7 @@ public static void main(String[] args) { Serializer serializer = serializerPlugin.createSerializer(null); model.generateMinimalExpressIds(); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), null, false); - serializer.writeToFile(new File("color.ifc"), null); + serializer.writeToFile(Paths.get("color.ifc"), null); } catch (PluginException e1) { e1.printStackTrace(); } catch (DeserializeException e) { diff --git a/Tests/src/org/bimserver/tests/TestDatabase.java b/Tests/src/org/bimserver/tests/TestDatabase.java index c1f3630f37..05e01a49d8 100644 --- a/Tests/src/org/bimserver/tests/TestDatabase.java +++ b/Tests/src/org/bimserver/tests/TestDatabase.java @@ -1,24 +1,9 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import org.apache.commons.io.FileUtils; @@ -39,10 +24,11 @@ import org.bimserver.models.store.UserSettings; import org.bimserver.shared.exceptions.ServiceException; import org.bimserver.utils.CollectionUtils; +import org.bimserver.utils.PathUtils; public class TestDatabase { private Database database; - private File dataDir; + private Path dataDir; private KeyValueStore keyValueStore; private long poid; private long uoid; @@ -53,10 +39,10 @@ public static void main(String[] args) { private void start() { try { - dataDir = new File("database"); - if (dataDir.exists()) { - try { - FileUtils.deleteDirectory(dataDir); + dataDir = Paths.get("database"); + if (Files.exists(dataDir)) { + try { + PathUtils.removeDirectoryWithContent(dataDir); } catch (IOException e) { e.printStackTrace(); } diff --git a/Tests/src/org/bimserver/tests/TestDeserializer.java b/Tests/src/org/bimserver/tests/TestDeserializer.java index acf3e24487..e8bb65d0df 100644 --- a/Tests/src/org/bimserver/tests/TestDeserializer.java +++ b/Tests/src/org/bimserver/tests/TestDeserializer.java @@ -1,23 +1,5 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; @@ -43,7 +25,7 @@ private void start() { Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); - IfcModelInterface model = deserializer.read(new File("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\Atrium%20Offices%20-%20PROJETO_EXECUTIVO%20-%202012.05.03.ifc")); + IfcModelInterface model = deserializer.read(Paths.get("C:\\Users\\Ruben de Laat\\Dropbox\\Shared\\BIMserver\\Atrium%20Offices%20-%20PROJETO_EXECUTIVO%20-%202012.05.03.ifc")); for (IdEObject idEObject : model.getValues()) { System.out.println(idEObject); diff --git a/Tests/src/org/bimserver/tests/TestFile.java b/Tests/src/org/bimserver/tests/TestFile.java index 6f63010edf..72b559d23a 100644 --- a/Tests/src/org/bimserver/tests/TestFile.java +++ b/Tests/src/org/bimserver/tests/TestFile.java @@ -1,52 +1,35 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Path; public enum TestFile { - EXPORT1(new File(TestFileConstants.DATA_FOLDER, "export1.ifc")), - EXPORT3(new File(TestFileConstants.DATA_FOLDER, "export3.ifc")), - NIEDRI(new File(TestFileConstants.DATA_FOLDER, "Niedri_org.ifc")), - MERGE_TEST_SOURCE_FILE(new File(TestFileConstants.DATA_FOLDER, "MergeTest.ifc")), - HITOS_SOURCE_FILE(new File(TestFileConstants.DATA_FOLDER, "HITOS_070308.ifc")), - HAUS_SOURCE_FILE(new File(TestFileConstants.DATA_FOLDER, "AC9R1-Haus-G-H-Ver2-2x3.ifc")), - AC11_XML(new File(TestFileConstants.DATA_FOLDER, "AC11-Institute-Var-2-ifcXML.ifcxml")), - SIX_SPACES_XML(new File(TestFileConstants.DATA_FOLDER, "SixSpaces.ifcxml")), - RIOLERING_TEST(new File(TestFileConstants.DATA_FOLDER, "RioleringTestArkey.ifc")), - EMPTY_TEST(new File(TestFileConstants.DATA_FOLDER, "EmptyTest.ifc")), - WALL_ONLY(new File(TestFileConstants.DATA_FOLDER, "WallOnly.ifc")), - WALL_ONLY_ADDED_SPACE(new File(TestFileConstants.DATA_FOLDER, "WallOnlyAddedSpace.ifc")), - AC11(new File(TestFileConstants.DATA_FOLDER, "AC11-Institute-Var-2-IFC.ifc")), - REVIT_QUANTITIES(new File(TestFileConstants.DATA_FOLDER, "revit_quantities.ifc")), - BATHROOM(new File(TestFileConstants.DATA_FOLDER, "BathroomWindow.ifc")), - JASMIN(new File(TestFileConstants.DATA_FOLDER, "AC90R1-Jasmin-Sun-105-2x3.ifc")), - ADTHAUS(new File(TestFileConstants.DATA_FOLDER, "ADT-FZK-Haus-2005-2006.ifc")), - PAOLO(new File(TestFileConstants.DATA_FOLDER, "Paolo.ifc")), - HAUS_ALT_SOURCE_FILE(new File(TestFileConstants.DATA_FOLDER, "AC9R1-Haus-G-H-Ver2-2x3_ALT.ifc")); + EXPORT1(TestFileConstants.DATA_FOLDER.resolve("export1.ifc")), + EXPORT3(TestFileConstants.DATA_FOLDER.resolve("export3.ifc")), + NIEDRI(TestFileConstants.DATA_FOLDER.resolve("Niedri_org.ifc")), + MERGE_TEST_SOURCE_FILE(TestFileConstants.DATA_FOLDER.resolve("MergeTest.ifc")), + HITOS_SOURCE_FILE(TestFileConstants.DATA_FOLDER.resolve("HITOS_070308.ifc")), + HAUS_SOURCE_FILE(TestFileConstants.DATA_FOLDER.resolve("AC9R1-Haus-G-H-Ver2-2x3.ifc")), + AC11_XML(TestFileConstants.DATA_FOLDER.resolve("AC11-Institute-Var-2-ifcXML.ifcxml")), + SIX_SPACES_XML(TestFileConstants.DATA_FOLDER.resolve("SixSpaces.ifcxml")), + RIOLERING_TEST(TestFileConstants.DATA_FOLDER.resolve("RioleringTestArkey.ifc")), + EMPTY_TEST(TestFileConstants.DATA_FOLDER.resolve("EmptyTest.ifc")), + WALL_ONLY(TestFileConstants.DATA_FOLDER.resolve("WallOnly.ifc")), + WALL_ONLY_ADDED_SPACE(TestFileConstants.DATA_FOLDER.resolve("WallOnlyAddedSpace.ifc")), + AC11(TestFileConstants.DATA_FOLDER.resolve("AC11-Institute-Var-2-IFC.ifc")), + REVIT_QUANTITIES(TestFileConstants.DATA_FOLDER.resolve("revit_quantities.ifc")), + BATHROOM(TestFileConstants.DATA_FOLDER.resolve("BathroomWindow.ifc")), + JASMIN(TestFileConstants.DATA_FOLDER.resolve("AC90R1-Jasmin-Sun-105-2x3.ifc")), + ADTHAUS(TestFileConstants.DATA_FOLDER.resolve("ADT-FZK-Haus-2005-2006.ifc")), + PAOLO(TestFileConstants.DATA_FOLDER.resolve("Paolo.ifc")), + HAUS_ALT_SOURCE_FILE(TestFileConstants.DATA_FOLDER.resolve("AC9R1-Haus-G-H-Ver2-2x3_ALT.ifc")); - private final File file; + private final Path file; - TestFile(File file) { + TestFile(Path file) { this.file = file; } - public File getFile() { + public Path getFile() { return file; } } \ No newline at end of file diff --git a/Tests/src/org/bimserver/tests/TestFileConstants.java b/Tests/src/org/bimserver/tests/TestFileConstants.java index 87341d20bd..4050bebd10 100644 --- a/Tests/src/org/bimserver/tests/TestFileConstants.java +++ b/Tests/src/org/bimserver/tests/TestFileConstants.java @@ -18,7 +18,9 @@ *****************************************************************************/ import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; public class TestFileConstants { - public static final File DATA_FOLDER = new File(".." + File.separator + "TestData" + File.separator + "data"); + public static final Path DATA_FOLDER = Paths.get(".." + File.separator + "TestData" + File.separator + "data"); } \ No newline at end of file diff --git a/Tests/src/org/bimserver/tests/TestGen.java b/Tests/src/org/bimserver/tests/TestGen.java index db0bfc5413..82cfe65cf8 100644 --- a/Tests/src/org/bimserver/tests/TestGen.java +++ b/Tests/src/org/bimserver/tests/TestGen.java @@ -1,25 +1,8 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.emf.Schema; @@ -49,7 +32,7 @@ private void start(String[] args) { RenderEnginePlugin renderEnginePlugin = pluginManager.getRenderEngine("org.bimserver.ifcengine.JvmRenderEnginePlugin", true); RenderEngine renderEngine = renderEnginePlugin.createRenderEngine(null, "ifc2x3tc1"); renderEngine.init(); - RenderEngineModel renderEngineModel = renderEngine.openModel(new FileInputStream(new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"))); + RenderEngineModel renderEngineModel = renderEngine.openModel(new FileInputStream(Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc").toFile())); RenderEngineSettings settings = new RenderEngineSettings(); settings.setPrecision(Precision.SINGLE); settings.setIndexFormat(IndexFormat.AUTO_DETECT); diff --git a/Tests/src/org/bimserver/tests/TestGuid.java b/Tests/src/org/bimserver/tests/TestGuid.java index 6714256666..15c80edc11 100644 --- a/Tests/src/org/bimserver/tests/TestGuid.java +++ b/Tests/src/org/bimserver/tests/TestGuid.java @@ -1,24 +1,7 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import org.bimserver.LocalDevSetup; import org.bimserver.interfaces.objects.SProject; @@ -39,7 +22,7 @@ public static void main(String[] args) { Long roid = client.getBimsie1LowLevelInterface().commitTransaction(tid, "test commit"); SSerializerPluginConfiguration serializer = client.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc"); - client.download(roid, serializer.getOid(), new File("test2.ifc")); + client.download(roid, serializer.getOid(), Paths.get("test2.ifc")); } catch (ServerException | UserException | PublicInterfaceNotFoundException e) { e.printStackTrace(); } catch (IOException e) { diff --git a/Tests/src/org/bimserver/tests/TestIfcEngineEmbedded.java b/Tests/src/org/bimserver/tests/TestIfcEngineEmbedded.java index 68455c6d5a..580235809f 100644 --- a/Tests/src/org/bimserver/tests/TestIfcEngineEmbedded.java +++ b/Tests/src/org/bimserver/tests/TestIfcEngineEmbedded.java @@ -1,23 +1,5 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; @@ -90,7 +72,7 @@ public void run() { SProject project = client.getBimsie1ServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1"); // This is the test file - File testIfcFile = new File("../TestData/data/" + filename); + Path testIfcFile = Paths.get("../TestData/data/" + filename); // Checkin the file client.checkin(project.getOid(), "testing ifc engine", deserializer.getOid(), false, true, testIfcFile); @@ -102,7 +84,7 @@ public void run() { SSerializerPluginConfiguration serializer = client.getBimsie1ServiceInterface().getSerializerByContentType("application/collada"); // Download as collada - client.download(project.getLastRevisionId(), serializer.getOid(), new File(testIfcFile.getName() + ".dae")); + client.download(project.getLastRevisionId(), serializer.getOid(), Paths.get(testIfcFile.getFileName().toString() + ".dae")); } catch (Exception e) { exception = e; } finally { @@ -110,12 +92,9 @@ public void run() { client.disconnect(); } } - } - } - public static void main(String[] args) { // Create a config BimServerConfig config = new BimServerConfig(); @@ -133,7 +112,7 @@ public static void main(String[] args) { config.setHomeDir(home); config.setStartEmbeddedWebServer(true); config.setPort(8080); - config.setResourceFetcher(new LocalDevelopmentResourceFetcher(new File("../"))); + config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../"))); config.setClassPath(System.getProperty("java.class.path")); // Create a BIMserver diff --git a/Tests/src/org/bimserver/tests/TestIfcFile.java b/Tests/src/org/bimserver/tests/TestIfcFile.java index b0f88fdbea..d7271121f7 100644 --- a/Tests/src/org/bimserver/tests/TestIfcFile.java +++ b/Tests/src/org/bimserver/tests/TestIfcFile.java @@ -1,23 +1,6 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterface; @@ -39,7 +22,7 @@ public static void main(String[] args) { private void start() { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); @@ -47,7 +30,7 @@ private void start() { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), null, false); - serializer.writeToFile(new File("tes.ifc"), null); + serializer.writeToFile(Paths.get("tes.ifc"), null); } catch (PluginException e) { e.printStackTrace(); } catch (DeserializeException e) { diff --git a/Tests/src/org/bimserver/tests/TestInOut.java b/Tests/src/org/bimserver/tests/TestInOut.java index 04982564dc..e4f3b973d1 100644 --- a/Tests/src/org/bimserver/tests/TestInOut.java +++ b/Tests/src/org/bimserver/tests/TestInOut.java @@ -2,10 +2,12 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.security.NoSuchAlgorithmException; import java.util.concurrent.TimeUnit; -import org.apache.commons.io.FileUtils; import org.bimserver.BimServer; import org.bimserver.BimServerConfig; import org.bimserver.LocalDevPluginLoader; @@ -29,6 +31,7 @@ import org.bimserver.shared.interfaces.SettingsInterface; import org.bimserver.tests.diff.CompareException; import org.bimserver.tests.diff.Diff; +import org.bimserver.utils.PathUtils; import org.bimserver.webservices.authorization.SystemAuthorization; public class TestInOut { @@ -38,10 +41,10 @@ public static void main(String[] args) { private void start(String[] args) { BimServerConfig config = new BimServerConfig(); - File homeDir = new File("home"); + Path homeDir = Paths.get("home"); try { - if (homeDir.isDirectory()) { - FileUtils.forceDelete(homeDir); + if (Files.isDirectory(homeDir)) { + PathUtils.removeDirectoryWithContent(homeDir); } } catch (IOException e) { e.printStackTrace(); @@ -50,7 +53,7 @@ private void start(String[] args) { config.setHomeDir(homeDir); config.setPort(8080); config.setStartEmbeddedWebServer(true); - config.setResourceFetcher(new LocalDevelopmentResourceFetcher(new File("../"))); + config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../"))); BimServer bimServer = new BimServer(config); try { @@ -65,11 +68,11 @@ private void start(String[] args) { BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080"); SProject project = client.getBimsie1ServiceInterface().addProject("test", "ifc2x3tc1"); SDeserializerPluginConfiguration deserializer = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); - File inputFile = new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"); + Path inputFile = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"); client.checkin(project.getOid(), "test", deserializer.getOid(), false, true, inputFile); project = client.getBimsie1ServiceInterface().getProjectByPoid(project.getOid()); SSerializerPluginConfiguration serializer = client.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc"); - File outputFile = new File("output.ifc"); + Path outputFile = Paths.get("output.ifc"); client.download(project.getLastRevisionId(), serializer.getOid(), outputFile); Diff diff = new Diff(false, false, false, inputFile, outputFile); diff --git a/Tests/src/org/bimserver/tests/TestJsonSerializerMultipleRevisions.java b/Tests/src/org/bimserver/tests/TestJsonSerializerMultipleRevisions.java index 7356953bc3..34a28eb58f 100644 --- a/Tests/src/org/bimserver/tests/TestJsonSerializerMultipleRevisions.java +++ b/Tests/src/org/bimserver/tests/TestJsonSerializerMultipleRevisions.java @@ -1,26 +1,9 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Paths; import org.apache.commons.io.IOUtils; import org.bimserver.LocalDevSetup; @@ -41,11 +24,11 @@ public static void main(String[] args) { Long download1 = client.getBimsie1ServiceInterface().download(roid1, jsonSerializer.getOid(), true, true); InputStream downloadData1 = client.getDownloadData(download1, jsonSerializer.getOid()); - IOUtils.copy(downloadData1, new FileOutputStream(new File("roid1.json"))); + IOUtils.copy(downloadData1, new FileOutputStream(Paths.get("roid1.json").toFile())); Long download2 = client.getBimsie1ServiceInterface().download(roid2, jsonSerializer.getOid(), true, true); InputStream downloadData2 = client.getDownloadData(download2, jsonSerializer.getOid()); - IOUtils.copy(downloadData2, new FileOutputStream(new File("roid2.json"))); + IOUtils.copy(downloadData2, new FileOutputStream(Paths.get("roid2.json").toFile())); } catch (ServiceException e) { e.printStackTrace(); } catch (PublicInterfaceNotFoundException e) { diff --git a/Tests/src/org/bimserver/tests/TestKmz.java b/Tests/src/org/bimserver/tests/TestKmz.java index 137590781c..ddc0dd265f 100644 --- a/Tests/src/org/bimserver/tests/TestKmz.java +++ b/Tests/src/org/bimserver/tests/TestKmz.java @@ -1,23 +1,6 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Paths; import java.util.Collection; import org.bimserver.LocalDevPluginLoader; @@ -40,7 +23,7 @@ public static void main(String[] args) { private void start() { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); SerializerPlugin plugin = pluginManager.getSerializerPlugin("org.bimserver.collada.KmzSerializerPlugin", true); Serializer serializer = plugin.createSerializer(new PluginConfiguration()); Collection allDeserializerPlugins = pluginManager.getAllDeserializerPlugins("ifc", true); @@ -56,7 +39,7 @@ private void start() { // IfcModelInterface model = // deserializer.read(TestFile.ADTHAUS.getFile(), true); serializer.init(model, null, pluginManager, ifcEnginePlugin, null, false); - serializer.writeToFile(new File("output/ac11.kmz"), null); + serializer.writeToFile(Paths.get("output/ac11.kmz"), null); } } catch (PluginException e) { e.printStackTrace(); diff --git a/Tests/src/org/bimserver/tests/TestManyRevisions.java b/Tests/src/org/bimserver/tests/TestManyRevisions.java index 8b51ad8fee..261440af9c 100644 --- a/Tests/src/org/bimserver/tests/TestManyRevisions.java +++ b/Tests/src/org/bimserver/tests/TestManyRevisions.java @@ -1,7 +1,8 @@ package org.bimserver.tests; -import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.client.json.JsonBimServerClientFactory; @@ -23,18 +24,18 @@ public static void main(String[] args) { private void start(String[] args) { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); MetaDataManager metaDataManager = new MetaDataManager(pluginManager); pluginManager.setMetaDataManager(metaDataManager); BimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, "http://localhost:8080"); BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin")); try { SProject project = client.getBimsie1ServiceInterface().addProject("lots2", "ifc2x3tc1"); - File[] files = new File[]{new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"), new File("../TestData/data/AC11-FZK-Haus-IFC - Alt.ifc")}; + Path[] files = new Path[]{Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"), Paths.get("../TestData/data/AC11-FZK-Haus-IFC - Alt.ifc")}; SDeserializerPluginConfiguration deserializer = client.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); int fn = 0; for (int i=0; i<20; i++) { - System.out.println(i + ": " + files[fn].getName()); + System.out.println(i + ": " + files[fn].getFileName().toString()); client.checkin(project.getOid(), "comment" + i, deserializer.getOid(), false, true, files[fn]); fn = 1 - fn; } diff --git a/Tests/src/org/bimserver/tests/TestSceneJsDownload.java b/Tests/src/org/bimserver/tests/TestSceneJsDownload.java index f4eae365c0..46ee36889e 100644 --- a/Tests/src/org/bimserver/tests/TestSceneJsDownload.java +++ b/Tests/src/org/bimserver/tests/TestSceneJsDownload.java @@ -1,27 +1,10 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Paths; import java.util.List; import org.apache.commons.io.IOUtils; @@ -52,7 +35,7 @@ private void start() { System.out.println(((System.nanoTime() - start) / 1000000) + " ms"); start = System.nanoTime(); InputStream inputStream = bimServerClient.getDownloadData(download, serializerByContentType.getOid()); - FileOutputStream fileOutputStream = new FileOutputStream(new File("test.json")); + FileOutputStream fileOutputStream = new FileOutputStream(Paths.get("test.json").toFile()); IOUtils.copy(inputStream, fileOutputStream); fileOutputStream.close(); System.out.println(((System.nanoTime() - start) / 1000000) + " ms"); diff --git a/Tests/src/org/bimserver/tests/TestSimultaniousDownloadWithCaching.java b/Tests/src/org/bimserver/tests/TestSimultaniousDownloadWithCaching.java index 3c8a80ce5d..2b3e50e89d 100644 --- a/Tests/src/org/bimserver/tests/TestSimultaniousDownloadWithCaching.java +++ b/Tests/src/org/bimserver/tests/TestSimultaniousDownloadWithCaching.java @@ -18,9 +18,11 @@ *****************************************************************************/ import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -28,7 +30,6 @@ import javax.activation.DataHandler; import javax.activation.FileDataSource; -import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.bimserver.BimServer; import org.bimserver.BimServerConfig; @@ -53,6 +54,7 @@ import org.bimserver.shared.interfaces.ServiceInterface; import org.bimserver.shared.interfaces.SettingsInterface; import org.bimserver.shared.interfaces.bimsie1.Bimsie1AuthInterface; +import org.bimserver.utils.PathUtils; import org.bimserver.webservices.ServiceMap; public class TestSimultaniousDownloadWithCaching { @@ -62,10 +64,10 @@ public static void main(String[] args) { private void start() { BimServerConfig config = new BimServerConfig(); - File homeDir = new File("home"); + Path homeDir = Paths.get("home"); try { - if (homeDir.isDirectory()) { - FileUtils.forceDelete(homeDir); + if (Files.isDirectory(homeDir)) { + PathUtils.removeDirectoryWithContent(homeDir); } } catch (IOException e) { e.printStackTrace(); @@ -74,7 +76,7 @@ private void start() { config.setHomeDir(homeDir); config.setPort(8080); config.setStartEmbeddedWebServer(true); - config.setResourceFetcher(new LocalDevelopmentResourceFetcher(new File("../"))); + config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../"))); final BimServer bimServer = new BimServer(config); try { LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), null); @@ -106,8 +108,8 @@ private void start() { settingsInterface.setGenerateGeometryOnCheckin(false); final SProject project = serviceMap.getBimsie1ServiceInterface().addProject("test", "ifc2x3tc1"); SDeserializerPluginConfiguration deserializerByName = serviceMap.getBimsie1ServiceInterface().getDeserializerByName("IfcStepDeserializer"); - File file = new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"); - serviceInterface.checkin(project.getOid(), "test", deserializerByName.getOid(), file.length(), file.getName(), new DataHandler(new FileDataSource(file)), false, true); + Path file = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"); + serviceInterface.checkin(project.getOid(), "test", deserializerByName.getOid(), file.toFile().length(), file.getFileName().toString(), new DataHandler(new FileDataSource(file.toFile())), false, true); final SProject projectUpdate = serviceMap.getBimsie1ServiceInterface().getProjectByPoid(project.getOid()); ThreadPoolExecutor executor = new ThreadPoolExecutor(20, 20, 1, TimeUnit.HOURS, new ArrayBlockingQueue(1000)); for (int i=0; i<20; i++) { diff --git a/Tests/src/org/bimserver/tests/Visualise.java b/Tests/src/org/bimserver/tests/Visualise.java index 57246d7dd3..8b54b8b20c 100644 --- a/Tests/src/org/bimserver/tests/Visualise.java +++ b/Tests/src/org/bimserver/tests/Visualise.java @@ -18,7 +18,6 @@ *****************************************************************************/ import java.awt.BorderLayout; -import java.io.File; import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; @@ -79,7 +78,7 @@ public static void main(String[] args) { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); serializer.init(merged, null, null, pluginManager.requireRenderEngine(), null, false); - serializer.writeToFile(new File("merged.ifc"), null); + serializer.writeToFile(Paths.get("merged.ifc"), null); new Visualise().start(model1b, "Model 1"); new Visualise().start(model2b, "Model 2"); new Visualise().start(merged, "Merged"); diff --git a/Tests/src/org/bimserver/tests/WebserviceReadTest.java b/Tests/src/org/bimserver/tests/WebserviceReadTest.java index 97e55c1dd0..578fc5bb5f 100644 --- a/Tests/src/org/bimserver/tests/WebserviceReadTest.java +++ b/Tests/src/org/bimserver/tests/WebserviceReadTest.java @@ -65,7 +65,7 @@ // CheckoutResult download = client.download(token, project.getId(), revision.getId(), resultType); // String pathname = download.getProjectName() + download.getRevisionNr() + "." + resultType.getDefaultExtension(); // System.out.println("Downloading " + pathname); -// File file = new File("downloaded" + File.separator + pathname); +// File file = Paths.get("downloaded" + File.separator + pathname); // FileOutputStream out = new FileOutputStream(file); // IOUtils.copy(download.getFile().getInputStream(), out); // out.close(); diff --git a/Tests/src/org/bimserver/tests/WebserviceWriteTest.java b/Tests/src/org/bimserver/tests/WebserviceWriteTest.java index 2708499585..d5445e22ad 100644 --- a/Tests/src/org/bimserver/tests/WebserviceWriteTest.java +++ b/Tests/src/org/bimserver/tests/WebserviceWriteTest.java @@ -52,8 +52,8 @@ // @Override // public void run() { // Random random = new Random(); -//// File testFilesDir = new File("C:\\Documents and Settings\\Ruben de Laat\\My Documents\\ifc selected"); -// File testFilesDir = new File("G:\\ifc selected"); +//// File testFilesDir = Paths.get("C:\\Documents and Settings\\Ruben de Laat\\My Documents\\ifc selected"); +// File testFilesDir = Paths.get("G:\\ifc selected"); // File[] listFiles = testFilesDir.listFiles(); // for (File file : listFiles) { // System.out.println(file); diff --git a/Tests/src/org/bimserver/tests/XsltTest.java b/Tests/src/org/bimserver/tests/XsltTest.java index 90fce1d971..830ee16525 100644 --- a/Tests/src/org/bimserver/tests/XsltTest.java +++ b/Tests/src/org/bimserver/tests/XsltTest.java @@ -1,26 +1,10 @@ package org.bimserver.tests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.nio.file.Path; +import java.nio.file.Paths; import javax.xml.transform.ErrorListener; import javax.xml.transform.Transformer; @@ -36,10 +20,10 @@ public static void main(String[] args) { } private void start() { - File xslt = new File("../BimServer/xslt/_Report1.xhtml.xsl"); + Path xslt = Paths.get("../BimServer/xslt/_Report1.xhtml.xsl"); TransformerFactory factory = TransformerFactory.newInstance(); - StreamSource xslStream = new StreamSource(xslt); + StreamSource xslStream = new StreamSource(xslt.toFile()); try { Transformer transformer = factory.newTransformer(xslStream); transformer.setErrorListener(new ErrorListener() { @@ -60,8 +44,8 @@ public void error(TransformerException exception) throws TransformerException { } }); - StreamSource in = new StreamSource(new FileInputStream(TestFile.AC11_XML.getFile())); - StreamResult out = new StreamResult(new FileOutputStream(new File("test.txt"))); + StreamSource in = new StreamSource(new FileInputStream(TestFile.AC11_XML.getFile().toFile())); + StreamResult out = new StreamResult(new FileOutputStream(Paths.get("test.txt").toFile())); transformer.transform(in, out); } catch (TransformerConfigurationException e) { e.printStackTrace(); diff --git a/Tests/src/org/bimserver/tests/diff/Diff.java b/Tests/src/org/bimserver/tests/diff/Diff.java index 24fbd00e38..73fbf9195a 100644 --- a/Tests/src/org/bimserver/tests/diff/Diff.java +++ b/Tests/src/org/bimserver/tests/diff/Diff.java @@ -1,23 +1,7 @@ package org.bimserver.tests.diff; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.security.NoSuchAlgorithmException; import java.text.DecimalFormat; import java.util.ArrayList; @@ -46,12 +30,12 @@ public class Diff { private int addedByHashMatch = 0; private int valueMatches = 0; private int addedByGraphIsomorphing = 0; - private File file1; - private File file2; + private Path file1; + private Path file2; public static void main(String[] args) { try { - new Diff(false, false, false, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"), new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")).start(); + new Diff(false, false, false, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"), Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")).start(); } catch (CompareException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { @@ -59,7 +43,7 @@ public static void main(String[] args) { } } - public Diff(boolean ignoreIntegerZeroDollar, boolean ignoreDoubleZeroDollar, boolean ignoreListEmptyDollar, File file1, File file2) { + public Diff(boolean ignoreIntegerZeroDollar, boolean ignoreDoubleZeroDollar, boolean ignoreListEmptyDollar, Path file1, Path file2) { this.ignoreIntegerZeroDollar = ignoreIntegerZeroDollar; this.ignoreDoubleZeroDollar = ignoreDoubleZeroDollar; this.ignoreListEmptyDollar = ignoreListEmptyDollar; diff --git a/Tests/src/org/bimserver/tests/diff/DiffReader.java b/Tests/src/org/bimserver/tests/diff/DiffReader.java index 12a897465a..cd5bc6ab30 100644 --- a/Tests/src/org/bimserver/tests/diff/DiffReader.java +++ b/Tests/src/org/bimserver/tests/diff/DiffReader.java @@ -18,6 +18,7 @@ *****************************************************************************/ import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -28,7 +29,7 @@ import java.util.concurrent.CountDownLatch; public class DiffReader extends Thread { - private File file; + private Path file; private Diff diff; private Map> sizeMapped; private FullModel model; @@ -36,7 +37,7 @@ public class DiffReader extends Thread { private CountDownLatch countDownLatch; private int id; - public DiffReader(int id, Diff diff, CountDownLatch countDownLatch, File file) { + public DiffReader(int id, Diff diff, CountDownLatch countDownLatch, Path file) { this.id = id; this.diff = diff; this.countDownLatch = countDownLatch; diff --git a/Tests/src/org/bimserver/tests/diff/FullModel.java b/Tests/src/org/bimserver/tests/diff/FullModel.java index 1d31ee7c4e..857678c69a 100644 --- a/Tests/src/org/bimserver/tests/diff/FullModel.java +++ b/Tests/src/org/bimserver/tests/diff/FullModel.java @@ -18,10 +18,10 @@ *****************************************************************************/ import java.io.BufferedReader; -import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.nio.file.Path; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -34,11 +34,11 @@ public FullModel(Diff diff) { this.diff = diff; } - public FullModel(Diff diff, File file) throws CompareException { + public FullModel(Diff diff, Path file) throws CompareException { this.diff = diff; - System.out.println("Reading model " + file.getName()); + System.out.println("Reading model " + file.getFileName().toString()); try { - FileReader in = new FileReader(file); + FileReader in = new FileReader(file.toFile()); BufferedReader reader = new BufferedReader(in); String line = reader.readLine(); while (line != null) { @@ -49,7 +49,7 @@ public FullModel(Diff diff, File file) throws CompareException { line = reader.readLine(); } reader.close(); - in = new FileReader(file); + in = new FileReader(file.toFile()); reader = new BufferedReader(in); try { line = reader.readLine(); diff --git a/Tests/src/org/bimserver/unittests/PerformanceTestIfcStepSerializer.java b/Tests/src/org/bimserver/unittests/PerformanceTestIfcStepSerializer.java index 0c36f8f31b..681690bff4 100644 --- a/Tests/src/org/bimserver/unittests/PerformanceTestIfcStepSerializer.java +++ b/Tests/src/org/bimserver/unittests/PerformanceTestIfcStepSerializer.java @@ -19,7 +19,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import java.util.Random; import org.apache.commons.lang.RandomStringUtils; @@ -48,7 +48,7 @@ public class PerformanceTestIfcStepSerializer { @Test public void performanceTest() throws IfcModelInterfaceException { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); @@ -72,7 +72,7 @@ public void performanceTest() throws IfcModelInterfaceException { } serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), packageMetaData, false); long start = System.nanoTime(); - serializer.writeToFile(new File("output/test.ifc"), null); + serializer.writeToFile(Paths.get("output/test.ifc"), null); System.out.println("Serialize took: " + ((System.nanoTime() - start) / 1000000) + "ms"); } catch (PluginException e) { e.printStackTrace(); diff --git a/Tests/src/org/bimserver/unittests/TestClientEmfModelLocal.java b/Tests/src/org/bimserver/unittests/TestClientEmfModelLocal.java index ebda80508f..dea7f959e6 100644 --- a/Tests/src/org/bimserver/unittests/TestClientEmfModelLocal.java +++ b/Tests/src/org/bimserver/unittests/TestClientEmfModelLocal.java @@ -21,6 +21,9 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.List; import java.util.Random; @@ -133,11 +136,11 @@ private void dumpToFile(SProject project, long roid) throws SerializerException PackageMetaData packageMetaData = metaDataManager.getPackageMetaData("ifc2x3tc1"); serializer.init(model, null, bimServer.getPluginManager(), null, packageMetaData, false); - File output = new File("output"); - if (!output.exists()) { - output.mkdir(); + Path output = Paths.get("output"); + if (!Files.exists(output)) { + Files.createDirectory(output); } - serializer.writeToFile(new File(output, roid + ".ifc"), null); + serializer.writeToFile(output.resolve(roid + ".ifc"), null); } catch (BimServerClientException e) { e.printStackTrace(); } catch (UserException e) { @@ -146,6 +149,8 @@ private void dumpToFile(SProject project, long roid) throws SerializerException e.printStackTrace(); } catch (PublicInterfaceNotFoundException e) { e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } } diff --git a/Tests/src/org/bimserver/unittests/TestEmbeddedBimServer.java b/Tests/src/org/bimserver/unittests/TestEmbeddedBimServer.java index 61ac3b45c1..e5f33c9ab1 100644 --- a/Tests/src/org/bimserver/unittests/TestEmbeddedBimServer.java +++ b/Tests/src/org/bimserver/unittests/TestEmbeddedBimServer.java @@ -1,23 +1,9 @@ package org.bimserver.unittests; -/****************************************************************************** - * Copyright (C) 2009-2015 BIMserver.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *****************************************************************************/ - -import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Random; import javax.activation.DataHandler; @@ -69,8 +55,8 @@ public static void initClass() { try { // Create a BIMserver BimServerConfig config = new BimServerConfig(); - config.setHomeDir(new File("home")); - config.setResourceFetcher(new LocalDevelopmentResourceFetcher(new File("../"))); + config.setHomeDir(Paths.get("home")); + config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../"))); bimServer = new BimServer(config); // Load plugins @@ -133,10 +119,12 @@ public void testUpload() { ServiceInterface service = serviceMap.get(ServiceInterface.class); serviceMap.get(Bimsie1AuthInterface.class).login(username, password); SProject project = serviceMap.getBimsie1ServiceInterface().addProject("test " + new Random().nextInt(), "ifc4"); - File sourceFile = TestFile.AC11.getFile(); - service.checkin(project.getOid(), "test", -1L, sourceFile.length(), "test", new DataHandler(new FileDataSource(sourceFile)), false, true); // TODO + Path sourceFile = TestFile.AC11.getFile(); + service.checkin(project.getOid(), "test", -1L, Files.size(sourceFile), "test", new DataHandler(new FileDataSource(sourceFile.toFile())), false, true); // TODO } catch (ServiceException e) { e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } } diff --git a/Tests/src/org/bimserver/unittests/TestIfcSerializeDeserialize.java b/Tests/src/org/bimserver/unittests/TestIfcSerializeDeserialize.java index 80857a5712..6f0e5f2d3e 100644 --- a/Tests/src/org/bimserver/unittests/TestIfcSerializeDeserialize.java +++ b/Tests/src/org/bimserver/unittests/TestIfcSerializeDeserialize.java @@ -19,7 +19,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IdEObject; @@ -47,7 +47,7 @@ public class TestIfcSerializeDeserialize { @Test public void testSerializeDeserializer() throws IfcModelInterfaceException { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); MetaDataManager metaDataManager = new MetaDataManager(pluginManager); PackageMetaData packageMetaData = metaDataManager.getPackageMetaData("ifc2x3tc1"); SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); @@ -58,12 +58,12 @@ public void testSerializeDeserializer() throws IfcModelInterfaceException { IfcWall wall = model.create(Ifc2x3tc1Package.eINSTANCE.getIfcWall()); wall.setName("Test with 'quote and \\backslash"); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), packageMetaData, false); - serializer.writeToFile(new File("output/test.ifc"), null); + serializer.writeToFile(Paths.get("output/test.ifc"), null); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); deserializer.init(packageMetaData); - IfcModelInterface modelInterface = deserializer.read(new File("output/test.ifc")); + IfcModelInterface modelInterface = deserializer.read(Paths.get("output/test.ifc")); IdEObject object = modelInterface.iterator().next(); System.out.println(((IfcWall)object).getName()); diff --git a/Tests/src/org/bimserver/unittests/TestIfcStepDeserializer.java b/Tests/src/org/bimserver/unittests/TestIfcStepDeserializer.java index b229f6b98a..ee24750565 100644 --- a/Tests/src/org/bimserver/unittests/TestIfcStepDeserializer.java +++ b/Tests/src/org/bimserver/unittests/TestIfcStepDeserializer.java @@ -19,7 +19,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterface; @@ -42,7 +42,7 @@ public class TestIfcStepDeserializer { @Test public void testSpaceEndOfLineBeforeSemiColon() { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); @@ -55,7 +55,7 @@ public void testSpaceEndOfLineBeforeSemiColon() { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); serializer.init(modelInterface, null, pluginManager, pluginManager.requireRenderEngine(), packageMetaData, false); - serializer.writeToFile(new File("output/test.ifc"), null); + serializer.writeToFile(Paths.get("output/test.ifc"), null); } catch (PluginException e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/Tests/src/org/bimserver/unittests/TestIfcStepSerializer.java b/Tests/src/org/bimserver/unittests/TestIfcStepSerializer.java index b4f0b5277e..5b149169d9 100644 --- a/Tests/src/org/bimserver/unittests/TestIfcStepSerializer.java +++ b/Tests/src/org/bimserver/unittests/TestIfcStepSerializer.java @@ -19,7 +19,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; import org.bimserver.emf.IfcModelInterfaceException; @@ -41,7 +41,7 @@ public class TestIfcStepSerializer { @Test public void testSerializer() throws IfcModelInterfaceException { try { - PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home")); + PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home")); SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); @@ -52,7 +52,7 @@ public void testSerializer() throws IfcModelInterfaceException { IfcWall wall = model.create(Ifc2x3tc1Package.eINSTANCE.getIfcWall()); wall.setName("Test with 'quotes"); serializer.init(model, null, pluginManager, pluginManager.requireRenderEngine(), packageMetaData, false); - serializer.writeToFile(new File("output/test.ifc"), null); + serializer.writeToFile(Paths.get("output/test.ifc"), null); } catch (PluginException e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/Tests/src/org/bimserver/unittests/TestLowLevelChanges.java b/Tests/src/org/bimserver/unittests/TestLowLevelChanges.java index 4394e8e010..303297cdf7 100644 --- a/Tests/src/org/bimserver/unittests/TestLowLevelChanges.java +++ b/Tests/src/org/bimserver/unittests/TestLowLevelChanges.java @@ -91,7 +91,7 @@ public static void setup() { // Create a BIMserver BimServerConfig config = new BimServerConfig(); config.setHomeDir(Paths.get("home")); - config.setResourceFetcher(new LocalDevelopmentResourceFetcher(new File("../"))); + config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../"))); bimServer = new BimServer(config); // Load plugins diff --git a/Tests/test/org/bimserver/tests/AllTests.java b/Tests/test/org/bimserver/tests/AllTests.java index 508b3d7257..88aa724a72 100644 --- a/Tests/test/org/bimserver/tests/AllTests.java +++ b/Tests/test/org/bimserver/tests/AllTests.java @@ -2,12 +2,11 @@ import static org.junit.Assert.fail; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import org.apache.commons.io.FileUtils; import org.bimserver.BimServer; import org.bimserver.BimServerConfig; import org.bimserver.LocalDevPluginLoader; @@ -36,6 +35,7 @@ import org.bimserver.tests.serviceinterface.MultiCheckinAndDownload; import org.bimserver.tests.serviceinterface.SingleCheckinAndDownload; import org.bimserver.tests.serviceinterface.UpdateProject; +import org.bimserver.utils.PathUtils; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; @@ -80,9 +80,9 @@ private static void setup() { Path home = Paths.get("home"); // Remove the home dir if it's there - if (home.exists()) { + if (Files.exists(home)) { try { - FileUtils.deleteDirectory(home); + PathUtils.removeDirectoryWithContent(home); } catch (IOException e) { e.printStackTrace(); } @@ -92,7 +92,7 @@ private static void setup() { config.setHomeDir(home); config.setStartEmbeddedWebServer(true); config.setPort(8080); - config.setResourceFetcher(new LocalDevelopmentResourceFetcher(new File("../"))); + config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../"))); config.setClassPath(System.getProperty("java.class.path")); bimServer = new BimServer(config); diff --git a/Tests/test/org/bimserver/tests/emf/ContainedInStructure.java b/Tests/test/org/bimserver/tests/emf/ContainedInStructure.java index c67f5299d2..8a80ee0100 100644 --- a/Tests/test/org/bimserver/tests/emf/ContainedInStructure.java +++ b/Tests/test/org/bimserver/tests/emf/ContainedInStructure.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -32,7 +32,7 @@ public void test() { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); // Checkin the file - bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/AC11-FZK-Haus-IFC.ifc")); + bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc")); // Refresh project info newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); diff --git a/Tests/test/org/bimserver/tests/emf/CreateProperties.java b/Tests/test/org/bimserver/tests/emf/CreateProperties.java index b16eb24537..8b362000b3 100644 --- a/Tests/test/org/bimserver/tests/emf/CreateProperties.java +++ b/Tests/test/org/bimserver/tests/emf/CreateProperties.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import java.util.HashSet; import java.util.Set; @@ -41,7 +41,7 @@ public void test() { // Look for a deserializer SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); - bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); + bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); // Refresh project project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid()); diff --git a/Tests/test/org/bimserver/tests/emf/ListWalls.java b/Tests/test/org/bimserver/tests/emf/ListWalls.java index 07c124728a..074ef24391 100644 --- a/Tests/test/org/bimserver/tests/emf/ListWalls.java +++ b/Tests/test/org/bimserver/tests/emf/ListWalls.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -28,7 +28,7 @@ public void test() { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); // Checkin the file - bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/Jesse.1.ifc")); + bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/Jesse.1.ifc")); // Refresh project info newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); diff --git a/Tests/test/org/bimserver/tests/emf/LoadCompleteModel.java b/Tests/test/org/bimserver/tests/emf/LoadCompleteModel.java index 77594636bc..97727ec173 100644 --- a/Tests/test/org/bimserver/tests/emf/LoadCompleteModel.java +++ b/Tests/test/org/bimserver/tests/emf/LoadCompleteModel.java @@ -3,7 +3,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import java.util.List; import org.bimserver.emf.IfcModelInterface; @@ -31,7 +31,7 @@ public void start() { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); // Checkin file - bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); + bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); // Refresh project project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid()); diff --git a/Tests/test/org/bimserver/tests/emf/MoveObject.java b/Tests/test/org/bimserver/tests/emf/MoveObject.java index c3c0a347d7..8cd2ffba89 100644 --- a/Tests/test/org/bimserver/tests/emf/MoveObject.java +++ b/Tests/test/org/bimserver/tests/emf/MoveObject.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -33,7 +33,7 @@ public void test() { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); // Checkin the file - bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); + bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); // Refresh project info newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); @@ -57,7 +57,7 @@ public void test() { } long newRoid = model.commit("Moved all furniture 50 meters up"); SSerializerPluginConfiguration ifcSerializer = bimServerClient.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc"); - bimServerClient.download(newRoid, ifcSerializer.getOid(), new File("movedf.ifc")); + bimServerClient.download(newRoid, ifcSerializer.getOid(), Paths.get("movedf.ifc")); } catch (Throwable e) { e.printStackTrace(); if (e instanceof AssertionError) { diff --git a/Tests/test/org/bimserver/tests/emf/ReadProperties.java b/Tests/test/org/bimserver/tests/emf/ReadProperties.java index 31c437221a..269fe378a4 100644 --- a/Tests/test/org/bimserver/tests/emf/ReadProperties.java +++ b/Tests/test/org/bimserver/tests/emf/ReadProperties.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -37,7 +37,7 @@ public void test() { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); // Checkin file - bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); + bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); // Refresh project project = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(project.getOid()); diff --git a/Tests/test/org/bimserver/tests/emf/ReadTrim.java b/Tests/test/org/bimserver/tests/emf/ReadTrim.java index 2a3d44b8ca..e41e961720 100644 --- a/Tests/test/org/bimserver/tests/emf/ReadTrim.java +++ b/Tests/test/org/bimserver/tests/emf/ReadTrim.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -30,7 +30,7 @@ public void test() { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); // Checkin the file - bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/TST.ifc")); + bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/TST.ifc")); // Refresh project info newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); diff --git a/Tests/test/org/bimserver/tests/emf/RemoveReferenceList.java b/Tests/test/org/bimserver/tests/emf/RemoveReferenceList.java index ddef12ff1b..d8916dee41 100644 --- a/Tests/test/org/bimserver/tests/emf/RemoveReferenceList.java +++ b/Tests/test/org/bimserver/tests/emf/RemoveReferenceList.java @@ -1,9 +1,9 @@ package org.bimserver.tests.emf; -import static org.junit.Assert.fail; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SProject; @@ -50,7 +50,7 @@ public void test() { // refresh newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); - bimServerClient.download(newProject.getLastRevisionId(), bimServerClient.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc").getOid(), new File("testX.ifc")); + bimServerClient.download(newProject.getLastRevisionId(), bimServerClient.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc").getOid(), Paths.get("testX.ifc")); model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, true); for (IfcFurnishingElement ifcFurnishingElement : model.getAll(IfcFurnishingElement.class)) { diff --git a/Tests/test/org/bimserver/tests/ifc/TestJapaneseChars.java b/Tests/test/org/bimserver/tests/ifc/TestJapaneseChars.java index f6d9b15138..3c661c6c73 100644 --- a/Tests/test/org/bimserver/tests/ifc/TestJapaneseChars.java +++ b/Tests/test/org/bimserver/tests/ifc/TestJapaneseChars.java @@ -3,6 +3,7 @@ import static org.junit.Assert.fail; import java.io.File; +import java.nio.file.Paths; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; import org.bimserver.interfaces.objects.SProject; @@ -35,10 +36,10 @@ public void test() { }; for (File file : files) { - bimServerClient.checkin(newProject.getOid(), "initial", deserializer.getOid(), false, true, new File("../TestData/data/revit2013_unicode.ifc")); + bimServerClient.checkin(newProject.getOid(), "initial", deserializer.getOid(), false, true, Paths.get("../TestData/data/revit2013_unicode.ifc")); newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); SSerializerPluginConfiguration serializer = bimServerClient.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc"); - bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), new File("bimserver_" + file.getName())); + bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("bimserver_" + file.getName())); } } catch (Throwable e) { if (e instanceof AssertionError) { diff --git a/Tests/test/org/bimserver/tests/lowlevel/MoveFurniture.java b/Tests/test/org/bimserver/tests/lowlevel/MoveFurniture.java index dfaca0c14b..3e8f396f01 100644 --- a/Tests/test/org/bimserver/tests/lowlevel/MoveFurniture.java +++ b/Tests/test/org/bimserver/tests/lowlevel/MoveFurniture.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import java.util.List; import org.bimserver.interfaces.objects.SDataObject; @@ -31,7 +31,7 @@ public void test() { SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); // Checkin the file - bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); + bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc")); // Refresh project info newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); @@ -63,7 +63,7 @@ public void test() { System.out.println(lowLevelInterface.getDataObjectsByType(newRoid, "ifc2x3tc1", "IfcFurnishingElement", false).size()); SSerializerPluginConfiguration ifcSerializer = bimServerClient.getBimsie1ServiceInterface().getSerializerByContentType("application/ifc"); - bimServerClient.download(newRoid, ifcSerializer.getOid(), new File("movedf.ifc")); + bimServerClient.download(newRoid, ifcSerializer.getOid(), Paths.get("movedf.ifc")); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/Tests/test/org/bimserver/tests/lowlevel/RemoveObject2.java b/Tests/test/org/bimserver/tests/lowlevel/RemoveObject2.java index d8abb92d0e..5ff886715f 100644 --- a/Tests/test/org/bimserver/tests/lowlevel/RemoveObject2.java +++ b/Tests/test/org/bimserver/tests/lowlevel/RemoveObject2.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.interfaces.objects.SProject; import org.bimserver.interfaces.objects.SSerializerPluginConfiguration; @@ -39,14 +39,14 @@ public void test() { Long newRoid = lowLevelInterface.commitTransaction(tid, "Initial"); - bimServerClient.download(newRoid, serializer.getOid(), new File("test1.ifc")); + bimServerClient.download(newRoid, serializer.getOid(), Paths.get("test1.ifc")); tid = lowLevelInterface.startTransaction(newProject.getOid()); lowLevelInterface.removeObject(tid, ifcWallOid); lowLevelInterface.removeObject(tid, ifcRelContainedInSpatialStructureOid); newRoid = lowLevelInterface.commitTransaction(tid, "removed"); - bimServerClient.download(newRoid, serializer.getOid(), new File("test2.ifc")); + bimServerClient.download(newRoid, serializer.getOid(), Paths.get("test2.ifc")); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/Tests/test/org/bimserver/tests/lowlevel/SetString.java b/Tests/test/org/bimserver/tests/lowlevel/SetString.java index d88218f330..3a6928884f 100644 --- a/Tests/test/org/bimserver/tests/lowlevel/SetString.java +++ b/Tests/test/org/bimserver/tests/lowlevel/SetString.java @@ -2,7 +2,7 @@ import static org.junit.Assert.fail; -import java.io.File; +import java.nio.file.Paths; import org.bimserver.emf.IfcModelInterface; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -27,12 +27,12 @@ public void test() { SProject newProject = bimServerClient.getBimsie1ServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1"); SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); - bimServerClient.checkin(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, true, new File("../TestData/data/WallOnly.ifc")); + bimServerClient.checkin(newProject.getOid(), "initial", suggestedDeserializerForExtension.getOid(), false, true, Paths.get("../TestData/data/WallOnly.ifc")); newProject = bimServerClient.getBimsie1ServiceInterface().getProjectByPoid(newProject.getOid()); SSerializerPluginConfiguration serializer = bimServerClient.getBimsie1ServiceInterface().getSerializerByName("Ifc2x3"); - bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), new File("test1.ifc")); + bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test1.ifc")); IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, false); long tid = lowLevelInterface.startTransaction(newProject.getOid()); @@ -43,9 +43,9 @@ public void test() { long roid = lowLevelInterface.commitTransaction(tid, "v2"); - bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), new File("test2.ifc")); + bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("test2.ifc")); - bimServerClient.download(roid, serializer.getOid(), new File("test3.ifc")); + bimServerClient.download(roid, serializer.getOid(), Paths.get("test3.ifc")); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/Tests/test/org/bimserver/tests/serviceinterface/QueryJava.java b/Tests/test/org/bimserver/tests/serviceinterface/QueryJava.java index 12979487c4..f8f51f41c5 100644 --- a/Tests/test/org/bimserver/tests/serviceinterface/QueryJava.java +++ b/Tests/test/org/bimserver/tests/serviceinterface/QueryJava.java @@ -4,6 +4,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -32,7 +34,7 @@ public void test() throws ServiceException, ChannelConnectionException { try { newProject = bimServerClient.getBimsie1ServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1"); // This is the file we will be checking in - File ifcFile = new File("../TestData/data/AC11-FZK-Haus-IFC.ifc"); + Path ifcFile = Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"); // Find a deserializer to use SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); diff --git a/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownload.java b/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownload.java index 6ff2d33ade..88b8f2e4bf 100644 --- a/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownload.java +++ b/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownload.java @@ -3,8 +3,9 @@ import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; import javax.activation.DataHandler; import javax.activation.FileDataSource; @@ -36,7 +37,7 @@ public void test() { SProject newProject = bimServerClient.getBimsie1ServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1"); // This is the file we will be checking in - File ifcFile = new File("../TestData/data/AC11-FZK-Haus-IFC.ifc"); + Path ifcFile = Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"); // Find a deserializer to use SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); @@ -44,7 +45,7 @@ public void test() { // Checkin Long progressId = -1L; if (useChannel) { - progressId = bimServerClient.getBimsie1ServiceInterface().checkin(newProject.getOid(), "test", deserializer.getOid(), ifcFile.length(), ifcFile.getName(), new DataHandler(new FileDataSource(ifcFile)), true); + progressId = bimServerClient.getBimsie1ServiceInterface().checkin(newProject.getOid(), "test", deserializer.getOid(), ifcFile.toFile().length(), ifcFile.getFileName().toString(), new DataHandler(new FileDataSource(ifcFile.toFile())), true); } else { progressId = bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, true, ifcFile); } diff --git a/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownloadSimplified.java b/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownloadSimplified.java index 8aa067b77f..0caa81c645 100644 --- a/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownloadSimplified.java +++ b/Tests/test/org/bimserver/tests/serviceinterface/SingleCheckinAndDownloadSimplified.java @@ -3,8 +3,9 @@ import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.InputStream; +import java.nio.file.Path; +import java.nio.file.Paths; import org.apache.commons.io.IOUtils; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -27,7 +28,7 @@ public void test() { SProject newProject = bimServerClient.getBimsie1ServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1"); // This is the file we will be checking in - File ifcFile = new File("../TestData/data/AC11-FZK-Haus-IFC.ifc"); + Path ifcFile = Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"); // Find a deserializer to use SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid()); diff --git a/Tests/test/org/bimserver/tests/serviceinterface/SubProjects.java b/Tests/test/org/bimserver/tests/serviceinterface/SubProjects.java index 2910f40e08..18728882c4 100644 --- a/Tests/test/org/bimserver/tests/serviceinterface/SubProjects.java +++ b/Tests/test/org/bimserver/tests/serviceinterface/SubProjects.java @@ -4,6 +4,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Path; +import java.nio.file.Paths; import org.apache.commons.io.IOUtils; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; @@ -29,9 +31,9 @@ public void test() { SProject sub3 = bimServerClient.getBimsie1ServiceInterface().addProjectAsSubProject("Sub3" + Math.random(), mainProject.getOid(), "ifc2x3tc1"); // This is the file we will be checking in - File ifcFile1 = new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"); - File ifcFile2 = new File("../TestData/data/AC90R1-niedriha-V2-2x3.ifc"); - File ifcFile3 = new File("../TestData/data/AC11-FZK-Haus-IFC.ifc"); + Path ifcFile1 = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"); + Path ifcFile2 = Paths.get("../TestData/data/AC90R1-niedriha-V2-2x3.ifc"); + Path ifcFile3 = Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"); // Find a deserializer to use SDeserializerPluginConfiguration deserializer = bimServerClient.getBimsie1ServiceInterface().getSuggestedDeserializerForExtension("ifc", mainProject.getOid()); diff --git a/Tools/src/org/bimserver/download/DownloadLatestRevisions.java b/Tools/src/org/bimserver/download/DownloadLatestRevisions.java index 2fe0eb2b2d..e03e6f45b7 100644 --- a/Tools/src/org/bimserver/download/DownloadLatestRevisions.java +++ b/Tools/src/org/bimserver/download/DownloadLatestRevisions.java @@ -1,7 +1,8 @@ package org.bimserver.download; -import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; @@ -21,7 +22,7 @@ public class DownloadLatestRevisions { private BimServerClientInterface client; - private File toDir = new File("D:\\Dropbox\\Shared\\Elasstic Ifc Models"); + private Path toDir = Paths.get("D:\\Dropbox\\Shared\\Elasstic Ifc Models"); private SSerializerPluginConfiguration serializer; public static void main(String[] args) { @@ -46,16 +47,16 @@ private void start(String[] args) { } } - private void downloadProject(File baseDir, SProject project) throws ServerException, UserException, PublicInterfaceNotFoundException { - File projectDir = new File(baseDir, project.getName()); - projectDir.mkdir(); + private void downloadProject(Path baseDir, SProject project) throws ServerException, UserException, PublicInterfaceNotFoundException, IOException { + Path projectDir = baseDir.resolve(project.getName()); + Files.createDirectory(projectDir); if (!project.getRevisions().isEmpty()) { SRevision revision = client.getBimsie1ServiceInterface().getRevision(project.getLastRevisionId()); System.out.println(revision.getComment()); if (!revision.getComment().startsWith("generated")) { try { - client.download(project.getLastRevisionId(), serializer.getOid(), new File(projectDir, revision.getComment())); + client.download(project.getLastRevisionId(), serializer.getOid(), projectDir.resolve(revision.getComment())); } catch (IOException e) { e.printStackTrace(); } diff --git a/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemover.java b/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemover.java index 52a518b6c0..c0c0ed4b95 100644 --- a/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemover.java +++ b/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemover.java @@ -1,6 +1,7 @@ package org.bimserver.ifcgeometryremover; import java.io.File; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashSet; import java.util.Iterator; @@ -43,7 +44,7 @@ public IfcGeometryRemover() { } } - public void removeGeometry(File inputFile, File outputFile) { + public void removeGeometry(Path inputFile, Path outputFile) { IfcModelInterface model = readModel(inputFile); referenceCounter = new ReferenceCounter(model); @@ -84,7 +85,7 @@ private void remove(Iterator iterator, IfcModelInterface model) { } } - private void writeModel(IfcModelInterface model, File outFile) { + private void writeModel(IfcModelInterface model, Path outFile) { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); try { @@ -98,7 +99,7 @@ private void writeModel(IfcModelInterface model, File outFile) { } } - public IfcModelInterface readModel(File file) { + public IfcModelInterface readModel(Path file) { try { DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); deserializerPlugin.createDeserializer(new PluginConfiguration()); diff --git a/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemoverTest.java b/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemoverTest.java index 9113734583..dc0bf337c3 100644 --- a/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemoverTest.java +++ b/Tools/src/org/bimserver/ifcgeometryremover/IfcGeometryRemoverTest.java @@ -1,15 +1,19 @@ package org.bimserver.ifcgeometryremover; -import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.bimserver.utils.PathUtils; public class IfcGeometryRemoverTest { - public static void main(String[] args) { - File baseDir = new File("D:\\Dropbox\\Shared\\BIMserver\\IFC modellen\\simple changes"); + public static void main(String[] args) throws IOException { + Path baseDir = Paths.get("D:\\Dropbox\\Shared\\BIMserver\\IFC modellen\\simple changes"); IfcGeometryRemover ifcGeometryRemover = new IfcGeometryRemover(); - for (File inputFile : baseDir.listFiles()) { - if (inputFile.getName().endsWith(".ifc") && !inputFile.getName().startsWith("NOGEOM_")) { - System.out.println(inputFile.getName()); - ifcGeometryRemover.removeGeometry(inputFile, new File(inputFile.getParentFile(), "NOGEOM_" + inputFile.getName())); + for (Path inputFile : PathUtils.getDirectories(baseDir)) { + if (inputFile.getFileName().toString().endsWith(".ifc") && !inputFile.getFileName().toString().startsWith("NOGEOM_")) { + System.out.println(inputFile.getFileName().toString()); + ifcGeometryRemover.removeGeometry(inputFile, inputFile.getParent().resolve("NOGEOM_" + inputFile.getFileName().toString())); } } } diff --git a/Tools/src/org/bimserver/saapc/SurfaceAreaAndPeopleCalculator.java b/Tools/src/org/bimserver/saapc/SurfaceAreaAndPeopleCalculator.java index bd9e7ac4dd..e58d6123aa 100644 --- a/Tools/src/org/bimserver/saapc/SurfaceAreaAndPeopleCalculator.java +++ b/Tools/src/org/bimserver/saapc/SurfaceAreaAndPeopleCalculator.java @@ -1,6 +1,6 @@ package org.bimserver.saapc; -import java.io.File; +import java.io.IOException; import java.nio.file.Paths; import org.bimserver.LocalDevPluginLoader; @@ -12,6 +12,7 @@ import org.bimserver.plugins.deserializers.DeserializeException; import org.bimserver.plugins.deserializers.Deserializer; import org.bimserver.plugins.deserializers.DeserializerPlugin; +import org.bimserver.utils.PathUtils; public class SurfaceAreaAndPeopleCalculator { public static void main(String[] args) { @@ -24,18 +25,20 @@ private void start() { DeserializerPlugin ifcDeserializerPlugin = pluginManager.getDeserializerPlugin("org.bimserver.ifc.step.deserializer.Ifc2x3tc1StepDeserializerPlugin", true); Deserializer ifcDeserializer = ifcDeserializerPlugin.createDeserializer(null); ifcDeserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")); - File baseDirectory = new File("C:\\Arch"); - for (File originalIfcFile : baseDirectory.listFiles()) { + java.nio.file.Path baseDirectory = Paths.get("C:\\Arch"); + for (java.nio.file.Path originalIfcFile : PathUtils.getDirectories(baseDirectory)) { processFile(ifcDeserializer, originalIfcFile); } } catch (PluginException e) { e.printStackTrace(); } catch (DeserializeException e) { e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } } - private void processFile(Deserializer ifcDeserializer, File originalIfcFile) + private void processFile(Deserializer ifcDeserializer, java.nio.file.Path originalIfcFile) throws DeserializeException { IfcModelInterface model = ifcDeserializer.read(originalIfcFile); for (IfcSpace ifcSpace : model.getAllWithSubTypes(IfcSpace.class)) { diff --git a/Tools/src/org/bimserver/saapc/Test.java b/Tools/src/org/bimserver/saapc/Test.java index ce74a21772..4e4279231c 100644 --- a/Tools/src/org/bimserver/saapc/Test.java +++ b/Tools/src/org/bimserver/saapc/Test.java @@ -1,6 +1,6 @@ package org.bimserver.saapc; -import java.io.File; +import java.nio.file.Paths; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; @@ -27,7 +27,7 @@ private void start(String[] args) { Deserializer ifcDeserializer = ifcDeserializerPlugin.createDeserializer(null); PackageMetaData packageMetaData = pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"); ifcDeserializer.init(packageMetaData); - IfcModelInterface model = ifcDeserializer.read(new File("C:\\Arch\\2014-10-22-17-10-14-Archi_Elasstic_ribbon_2.ifc")); + IfcModelInterface model = ifcDeserializer.read(Paths.get("C:\\Arch\\2014-10-22-17-10-14-Archi_Elasstic_ribbon_2.ifc")); IfcRoot space = model.getByGuid("360RrcTsD148LBtQ0v7EoT"); IfcRoot window = model.getByGuid("34twxE9mT4pRJLS4Gz2YhE"); diff --git a/Tools/src/org/bimserver/tools/colorizer/Colorizer.java b/Tools/src/org/bimserver/tools/colorizer/Colorizer.java index ce3ca74e91..34f3bf64a9 100644 --- a/Tools/src/org/bimserver/tools/colorizer/Colorizer.java +++ b/Tools/src/org/bimserver/tools/colorizer/Colorizer.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; @@ -51,7 +52,7 @@ public class Colorizer { public static void main(String[] args) { try { Colorizer colorizer = new Colorizer(); - File baseDir = new File("D:\\Dropbox\\Shared\\BIMserver\\IFC modellen\\kleurtjes\\"); + Path baseDir = Paths.get("D:\\Dropbox\\Shared\\BIMserver\\IFC modellen\\kleurtjes\\"); // colorizer.colorize(new File(baseDir, "Compleet_Imro.ifc"), new File(baseDir, "Compleet_Imro-Colored.ifc")); // colorizer.colorize(new File(baseDir, "3D_Imro_new.ifc"), new File(baseDir, "3D_Imro_new-Colored.ifc")); // colorizer.colorize(new File(baseDir, "Compleet_Imro+Noise.ifc"), new File(baseDir, "Compleet_Imro+Noise-Colored.ifc")); @@ -60,7 +61,7 @@ public static void main(String[] args) { // colorizer.colorize(new File(baseDir, "NoiseContourFlat_06m.ifc"), new File(baseDir, "NoiseContourFlat_06m-Colored.ifc")); // colorizer.colorize(new File(baseDir, "NoiseContourFlat_09m.ifc"), new File(baseDir, "NoiseContourFlat_09m-Colored.ifc")); // colorizer.colorize(new File(baseDir, "NoiseContourFlat_12m.ifc"), new File(baseDir, "NoiseContourFlat_12m-Colored.ifc")); - colorizer.colorize(new File(baseDir, "3D_Imro_withId.ifc"), new File(baseDir, "3D_Imro_withId-Colored.ifc")); + colorizer.colorize(baseDir.resolve("3D_Imro_withId.ifc"), baseDir.resolve("3D_Imro_withId-Colored.ifc")); } catch (IfcModelInterfaceException e) { e.printStackTrace(); } @@ -131,7 +132,7 @@ public Colorizer() { } } - public IfcModelInterface readModel(File file) { + public IfcModelInterface readModel(Path file) { try { DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true); Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration()); @@ -146,7 +147,7 @@ public IfcModelInterface readModel(File file) { return null; } - private void colorize(File inFile, File outFile) throws IfcModelInterfaceException { + private void colorize(Path inFile, Path outFile) throws IfcModelInterfaceException { IfcModelInterface model = readModel(inFile); model.fixOidCounter(); for (IfcProduct ifcProduct : model.getAllWithSubTypes(IfcProduct.class)) { @@ -244,7 +245,7 @@ private void setColor(IfcColourRgb color, IfcSurfaceStyleRendering ifcSurfaceSty ifcSurfaceStyleRendering.setTransparency(alpha); } - private void writeModel(IfcModelInterface model, File outFile) { + private void writeModel(IfcModelInterface model, Path outFile) { SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true); Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration()); try {