Package org.jboss.dna.graph.cache

Examples of org.jboss.dna.graph.cache.CachePolicy


        }
        return value;
    }

    protected static DateTime computeExpirationTime( CacheableRequest request ) {
        CachePolicy policy = request.getCachePolicy();
        return policy == null ? null : request.getTimeLoaded().plus(policy.getTimeToLive(), TimeUnit.MILLISECONDS);
    }
View Full Code Here


    @Test
    public void shouldConsiderWorkspacesEqualIfSameSourceNameAndSameWorkspaceNameAndSameProjections() {
        RepositoryContext otherReposContext = mock(RepositoryContext.class);
        stub(otherReposContext.getExecutionContext()).toReturn(context);
        CachePolicy otherPolicy = mock(CachePolicy.class);
        FederatedWorkspace other = new FederatedWorkspace(otherReposContext, sourceName, workspaceName, projections, otherPolicy);
        assertThat(workspace.equals(other), is(true));
    }
View Full Code Here

    @Test
    public void shouldConsiderWorkspacesNotEqualIfDifferentSourceName() {
        RepositoryContext otherReposContext = mock(RepositoryContext.class);
        stub(otherReposContext.getExecutionContext()).toReturn(context);
        CachePolicy otherPolicy = mock(CachePolicy.class);
        FederatedWorkspace other = new FederatedWorkspace(otherReposContext, "diff", workspaceName, projections, otherPolicy);
        assertThat(workspace.equals(other), is(false));
    }
View Full Code Here

    @Test
    public void shouldConsiderWorkspacesNotEqualIfDifferentWorkspaceName() {
        RepositoryContext otherReposContext = mock(RepositoryContext.class);
        stub(otherReposContext.getExecutionContext()).toReturn(context);
        CachePolicy otherPolicy = mock(CachePolicy.class);
        FederatedWorkspace other = new FederatedWorkspace(otherReposContext, sourceName, "diff", projections, otherPolicy);
        assertThat(workspace.equals(other), is(false));
    }
View Full Code Here

    @Test
    public void shouldConsiderWorkspacesNotEqualIfDifferentProjections() {
        RepositoryContext otherReposContext = mock(RepositoryContext.class);
        stub(otherReposContext.getExecutionContext()).toReturn(context);
        CachePolicy otherPolicy = mock(CachePolicy.class);
        FederatedWorkspace other = new FederatedWorkspace(otherReposContext, sourceName, workspaceName,
                                                          projections.subList(0, 3), otherPolicy);
        assertThat(workspace.equals(other), is(false));
    }
View Full Code Here

        if (workspaceNames != null && workspaceNames.length != 0) {
            ref.add(new StringRefAddr(PREDEFINED_WORKSPACE_NAMES, StringUtil.combineLines(workspaceNames)));
        }
        if (getDefaultCachePolicy() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            CachePolicy policy = getDefaultCachePolicy();
            try {
                ObjectOutputStream oos = new ObjectOutputStream(baos);
                oos.writeObject(policy);
                ref.add(new BinaryRefAddr(DEFAULT_CACHE_POLICY, baos.toByteArray()));
            } catch (IOException e) {
                I18n msg = InfinispanConnectorI18n.errorSerializingCachePolicyInSource;
                throw new RepositorySourceException(getName(), msg.text(policy.getClass().getName(), getName()), e);
            }
        }
        return ref;
    }
View Full Code Here

        assertThat(connection.getXAResource(), is(nullValue()));
    }

    @Test
    public void shouldGetDefaultCachePolicyFromRepository() {
        CachePolicy cachePolicy = mock(CachePolicy.class);
        stub(repository.getDefaultCachePolicy()).toReturn(cachePolicy);
        assertThat(connection.getDefaultCachePolicy(), is(cachePolicy));
        verify(repository, times(1)).getDefaultCachePolicy();
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.cache.CachePolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.