diff --git a/Tests/src/org/bimserver/test/GetAllAccounts.java b/Tests/src/org/bimserver/test/GetAllAccounts.java index a90a94ced3..95607c6468 100644 --- a/Tests/src/org/bimserver/test/GetAllAccounts.java +++ b/Tests/src/org/bimserver/test/GetAllAccounts.java @@ -17,36 +17,59 @@ * along with this program. If not, see {@literal}. *****************************************************************************/ -import org.bimserver.LocalDevSetup; +import org.apache.commons.lang.RandomStringUtils; import org.bimserver.client.json.JsonBimServerClientFactory; import org.bimserver.interfaces.objects.SUser; +import org.bimserver.interfaces.objects.SUserType; import org.bimserver.plugins.services.BimServerClientInterface; import org.bimserver.shared.BimServerClientFactory; import org.bimserver.shared.UsernamePasswordAuthenticationInfo; import org.bimserver.shared.exceptions.BimServerClientException; import org.bimserver.shared.exceptions.PublicInterfaceNotFoundException; import org.bimserver.shared.exceptions.ServiceException; - -public class GetAllAccounts { - public static void main(String[] args) { - new GetAllAccounts().start(args); - } - - private void start(String[] args) { - try (BimServerClientFactory factory = new JsonBimServerClientFactory(args[0])){ - try (BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo(args[1], args[2]))) { - for (SUser user : client.getServiceInterface().getAllUsers()) { - System.out.println(user.getUsername()); +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; + +import static org.junit.Assert.fail; + +public class GetAllAccounts { + + private static final Logger LOGGER = LoggerFactory.getLogger(GetAllAccounts.class); + public static void main(String[] args){ + new GetAllAccounts().start(); + } + + private void start() { + try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")){ + try (BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) { + ArrayList users = new ArrayList<>(); + //if the server already has users + for (SUser user : client.getServiceInterface().getAllUsers()) { + users.add(user.getUsername().toLowerCase()); + } + for (int i = 0; i < 20; i++) { + String username = RandomStringUtils.randomAlphanumeric(5) + "@bimserver.org"; + String password = RandomStringUtils.randomAlphanumeric(5); + users.add(username.toLowerCase()); + client.getServiceInterface().addUserWithPassword(username,password,username, SUserType.USER,false, "https://bimserver.org"); + } + for (SUser user : client.getServiceInterface().getAllUsers()) { + if (!users.contains(user.getUsername().toLowerCase())) { + fail("User " + user.getUsername() + " not found"); + } } - } - } catch (ServiceException e) { - e.printStackTrace(); - } catch (PublicInterfaceNotFoundException e) { - e.printStackTrace(); + System.out.println("done"); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (PublicInterfaceNotFoundException e) { + e.printStackTrace(); } catch (BimServerClientException e1) { e1.printStackTrace(); } catch (Exception e1) { e1.printStackTrace(); - } - } -} + } + } +} diff --git a/Tests/src/org/bimserver/test/TestUploadSameModelALot.java b/Tests/src/org/bimserver/test/TestUploadSameModelALot.java index 28b69a0157..37a3ef7838 100644 --- a/Tests/src/org/bimserver/test/TestUploadSameModelALot.java +++ b/Tests/src/org/bimserver/test/TestUploadSameModelALot.java @@ -20,36 +20,45 @@ import java.io.IOException; import java.nio.file.Paths; +import org.apache.commons.lang.RandomStringUtils; import org.bimserver.LocalDevSetup; +import org.bimserver.client.BimServerClient; +import org.bimserver.client.json.JsonBimServerClientFactory; import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; import org.bimserver.interfaces.objects.SProject; import org.bimserver.plugins.services.BimServerClientInterface; import org.bimserver.plugins.services.Flow; +import org.bimserver.shared.UsernamePasswordAuthenticationInfo; +import org.bimserver.shared.exceptions.BimServerClientException; import org.bimserver.shared.exceptions.PublicInterfaceNotFoundException; import org.bimserver.shared.exceptions.ServiceException; - -public class TestUploadSameModelALot { - - public static void main(String[] args) { - new TestUploadSameModelALot().start(); - } - - private void start() { - try { - BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080"); - client.getSettingsInterface().setGenerateGeometryOnCheckin(false); - for (int i=0; i<20; i++) { - SProject project = client.getServiceInterface().addProject("P" + i, "ifc2x3tc1"); - SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); - System.out.println(i); - client.checkinSync(project.getOid(), "C" + i, deserializerForExtension.getOid(), false, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc")); - } - } catch (ServiceException e) { - e.printStackTrace(); - } catch (PublicInterfaceNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } + +public class TestUploadSameModelALot { + + public static void main(String[] args) throws BimServerClientException { + new TestUploadSameModelALot().start(); + } + + private void start() throws BimServerClientException { + try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) { + try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) { + client.getSettingsInterface().setGenerateGeometryOnCheckin(false); + String name = RandomStringUtils.randomAlphabetic(10) + ": "; + for (int i = 0; i < 20; i++) { + SProject project = client.getServiceInterface().addProject(name + i, "ifc2x3tc1"); + SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid()); + System.out.println(i); + client.checkinSync(project.getOid(), "C" + i, deserializerForExtension.getOid(), false, Paths.get("../TestFiles/TestData/data/export1.ifc")); + } + } catch (ServiceException e) { + e.printStackTrace(); + } catch (PublicInterfaceNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } } \ No newline at end of file diff --git a/Tests/test/org/bimserver/tests/lowlevel/TestCreateUnknownType.java b/Tests/test/org/bimserver/tests/lowlevel/TestCreateUnknownType.java index 71d2c716d2..039ea236f8 100644 --- a/Tests/test/org/bimserver/tests/lowlevel/TestCreateUnknownType.java +++ b/Tests/test/org/bimserver/tests/lowlevel/TestCreateUnknownType.java @@ -22,10 +22,13 @@ import org.bimserver.shared.ChannelConnectionException; import org.bimserver.shared.UsernamePasswordAuthenticationInfo; import org.bimserver.shared.exceptions.ServiceException; +import org.bimserver.shared.exceptions.UserException; import org.bimserver.shared.interfaces.LowLevelInterface; import org.bimserver.test.TestWithEmbeddedServer; import org.junit.Test; +import static org.junit.Assert.assertThrows; + public class TestCreateUnknownType extends TestWithEmbeddedServer { @Test @@ -41,7 +44,7 @@ public void test() throws ServiceException, ChannelConnectionException { // Start a transaction Long tid = lowLevelInterface.startTransaction(newProject.getOid()); - lowLevelInterface.createObject(tid, "IfcCartesionPoint", true); // IfcCartesi(O)nPoint + assertThrows(UserException.class, () -> lowLevelInterface.createObject(tid, "IfcCartesionPoint", true)); // IfcCartesi(O)nPoint // Commit the transaction lowLevelInterface.commitTransaction(tid, "test", false);