Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blob Handle #4

Open
bleujin opened this issue Apr 26, 2013 · 1 comment
Open

blob Handle #4

bleujin opened this issue Apr 26, 2013 · 1 comment
Assignees

Comments

@bleujin
Copy link
Owner

bleujin commented Apr 26, 2013

No description provided.

@ghost ghost assigned bleujin Apr 28, 2013
@bleujin
Copy link
Owner Author

bleujin commented Jun 4, 2013

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())) ;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant