Storage { static Storage create(DriverConfiguration configuration) { final String type = configuration.getProperty(JenaConfigParam.STORAGE_TYPE, JenaOntoDriverProperties.IN_MEMORY); final Storage storage; switch (type) { case JenaOntoDriverProperties.IN_MEMORY: storage = new MemoryStorage(configuration); break; case JenaOntoDriverProperties.FILE: storage = new FileStorage(configuration); break; case JenaOntoDriverProperties.TDB: storage = new TDBStorage(configuration); break; case JenaOntoDriverProperties.SDB: throw new UnsupportedOperationException("Not implemented, yet."); default: throw new OntoDriverInitializationException("Unsupported storage type \'" + type + "\'."); } storage.initialize(); return storage; } Storage(DriverConfiguration configuration);   }
@Test public void createInitializesFileStorageForFileConfiguration() throws Exception { final File file = Files.createTempFile("jena-onto", ".ttl").toFile(); file.deleteOnExit(); final DriverConfiguration config = createConfiguration(file.getAbsolutePath()); config.setProperty(JenaConfigParam.STORAGE_TYPE, JenaOntoDriverProperties.FILE); final Storage result = Storage.create(config); assertNotNull(result); assertTrue(result instanceof FileStorage); }
@Test public void createThrowsInitializationExceptionForUnknownStorageType() { thrown.expect(OntoDriverInitializationException.class); thrown.expectMessage(containsString("Unsupported storage type")); final DriverConfiguration config = createConfiguration("test:uri"); config.setProperty(JenaConfigParam.STORAGE_TYPE, "dontKnowThisOne"); Storage.create(config); }
@Test public void createCreatesInMemoryByDefault() { final DriverConfiguration config = createConfiguration("test:uri"); final Storage result = Storage.create(config); assertNotNull(result); assertTrue(result instanceof MemoryStorage); }