Open bleujin opened 11 years ago
private RepositoryImpl r; private ReadSession session; @Override protected void setUp() throws Exception { super.setUp(); this.r = RepositoryImpl.create() ; r.defineConfig("test.node", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC).invocationBatching().enable().clustering() .sync().replTimeout(20000) .loaders().preload(true).shared(false).passivation(false).addCacheLoader().cacheLoader(new FastFileCacheStore()).addProperty("location","./resource/store/test") .purgeOnStartup(false).ignoreModifications(false).fetchPersistentState(true).async().enabled(false).build()) ; r.defineConfig("test.blobdata", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC) .sync().replTimeout(20000) .loaders().preload(true).shared(false).passivation(false).addCacheLoader().cacheLoader(new FastFileCacheStore()).addProperty("location","./resource/store/test") .purgeOnStartup(false).ignoreModifications(false).fetchPersistentState(true).async().enabled(false).build()) ; r.defineConfig("test.blobmeta", new ConfigurationBuilder().clustering().cacheMode(CacheMode.REPL_SYNC) .sync().replTimeout(20000) .loaders().preload(true).shared(false).passivation(false).addCacheLoader().cacheLoader(new FastFileCacheStore()).addProperty("location","./resource/store/test") .purgeOnStartup(false).ignoreModifications(false).fetchPersistentState(true).async().enabled(false).build()) ; this.session = r.testLogin("test") ; } @Override protected void tearDown() throws Exception { r.shutdown() ; super.tearDown(); } public void testSave() throws Exception { session.tranSync(new TransactionJob<Void>() { @Override public Void handle(WriteSession wsession) { WriteNode bleujin = wsession.pathBy("/bleujin").blob("config", new File("./resource/config/server-simple.xml")); Debug.line(bleujin.property("config").asBlob().toFile()) ; return null; } }) ; Debug.line(session.pathBy("/bleujin").property("config").asBlob().toFile()) ; } public void testRead() throws Exception { final PropertyValue property = session.pathBy("/bleujin").property("config"); Debug.line(property.stringValue()) ; final BlobValue blob = property.asBlob(); final File file = blob.toFile(); Debug.line(file, file.getParentFile(), file.isDirectory()) ; // Debug.debug(IOUtil.toString(blob.toInputStream())) ; } }