use of org.bimserver.client.DirectBimServerClientFactory in project BIMserver by opensourceBIM.
the class AllTests method setup.
private static void setup() {
// Create a config
Path home = Paths.get("tmptestdata/home-" + new Random().nextInt(1000000000));
// Remove the home dir if it's there
if (Files.exists(home)) {
try {
PathUtils.removeDirectoryWithContent(home);
} catch (IOException e) {
e.printStackTrace();
}
}
BimServerConfig config = new BimServerConfig();
config.setHomeDir(home);
config.setStartEmbeddedWebServer(true);
config.setPort(7010);
config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
config.setClassPath(System.getProperty("java.class.path"));
bimServer = new BimServer(config);
try {
bimServer.setEmbeddedWebServer(new EmbeddedWebServer(bimServer, null, false));
// CHANGE THESE TO MATCH YOUR CONFIGURATION
// Path[] pluginDirectories = new Path[]{Paths.get("C:\\Git\\IfcPlugins\\IfcPlugins"), Paths.get("C:\\Git\\IfcOpenShell-BIMserver-plugin")};
// Start it
bimServer.start();
// Load plugins
// LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), pluginDirectories);
// Get a client, not using any protocol (direct connection)
BimServerClientInterface client = bimServer.getBimServerClientFactory().create();
// Setup the server
client.getAdminInterface().setup("http://localhost:7010", "Test Name", "Test Description", "noicon", "Administrator", "admin@bimserver.org", "admin");
ServiceMap serviceMap = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL);
serviceMap.getSettingsInterface().setCacheOutputFiles(false);
((DirectBimServerClientFactory) bimServer.getBimServerClientFactory()).setBaseAddress("http://localhost:7010");
client.disconnect();
client = bimServer.getBimServerClientFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
String pluginsString = System.getProperty("plugins");
if (pluginsString != null) {
String[] plugins = pluginsString.split(";");
Path[] paths = new Path[plugins.length];
int i = 0;
for (String p : plugins) {
paths[i++] = Paths.get(p);
}
LocalDevPluginLoader.loadPlugins(bimServer.getPluginBundleManager(), paths);
} else {
LoggerFactory.getLogger(AllTests.class).info("Installing plugins");
client.getPluginInterface().installPluginBundle("https://repo1.maven.org/maven2/", "org.opensourcebim", "ifcplugins", null, null);
client.getPluginInterface().installPluginBundle("https://repo1.maven.org/maven2/", "org.opensourcebim", "binaryserializers", null, null);
client.getPluginInterface().installPluginBundle("https://repo1.maven.org/maven2/", "org.opensourcebim", "ifcopenshellplugin", null, null);
}
client.disconnect();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations