Package com.hp.hpl.jena.gvs.impl.memory

Examples of com.hp.hpl.jena.gvs.impl.memory.MemoryStoreImpl


   *
   */
  private void initControl() {
    Model authenticationModel = createAuthenticationModel();
   
    Store store = new MemoryStoreImpl();
    Source authenticationSource = new SourceImpl("http://localhost/authentication-master#");
    store.assertGraph(authenticationSource, new FCAGraphImpl(authenticationModel));
   
    Model authorizationModel = createAuthorizationModel();
    Source authorizationSource = new SourceImpl("http://localhost/authorization-master#");
    store.assertGraph(authorizationSource, new FCAGraphImpl(authorizationModel));
   
    Set<Source> sources = new HashSet<Source>();
    sources.add(authenticationSource);
    sources.add(authorizationSource);
    GraphOverTime configGOT = store.getGraphOverTime(sources );
    //JenaUtil.getModelFromGraph(configGOT.getGraph(new Date())).write(System.out);
    Configuration.setConfiguration(new GVSConfiguration(configGOT,
        "gvs"));
    Policy.setPolicy(new DefaultPolicy(configGOT));
  }
View Full Code Here


   * the SecurityConstants.DO_AS_PRIVILEGED_PERMISSION the user still has.
   *
   */
  public void notYetTestChangeUser() {
    final boolean[] exceptionCatched = new boolean[1];
    final Store store = new MemoryStoreImpl();
    Subject subject = new Subject();
    System.setSecurityManager(new SecurityManager());
    try {
      Subject.doAsPrivileged(subject, new PrivilegedExceptionAction() {
        public Object run() throws Exception {
          Source source = new SourceImpl("http://example.org/graph-source");
          Subject subject2 = new Subject();
          try {
            Subject.doAsPrivileged(null, new PrivilegedExceptionAction() {
              public Object run() throws Exception {
                Source source = new SourceImpl("http://example.org/graph-source");
                try {
                  store.assertGraph(source, new FCAGraphImpl(new SimpleGraph()));
                } catch (AccessControlException ex) {
                  exceptionCatched[0] = true;
                }
                return null;
              }
View Full Code Here

      // performTestsWithGraphs(graphs);
    }
  }

  protected Store getStoreImpl(Clock clock) {
    store = new MemoryStoreImpl(clock);
    return store;
  }
View Full Code Here

      public int getPort() {
        return 8989;
      }
     
    };
    Store store = new MemoryStoreImpl();
    File directory = new File("testdata");
    String baseURLString = "http://"
        + serverBinding.getInetAddress().getHostName() + ":"
        + serverBinding.getPort() + "/";
    CannedDataReader.readCannedData(store, directory, baseURLString);
View Full Code Here

  /**
   * @param data
   *
   */
  private static void action(SortedSet<Assertion> assertions) {
    Store store = new MemoryStoreImpl();
    CannedDataReader.addToStrore(store, assertions);
    GraphOverTime got = store.getGraphOverTime(Collections
        .singleton((Source) new SourceImpl(baseURLString + "danbri")));
    got.getGraph(new Date());
  }
View Full Code Here

*
*/
public class SecurityTest extends TestCase {

  public void testUnauthorizedPut() throws Exception {
    Store store = new MemoryStoreImpl();
    ServerBinding serverBinding = new ServerBinding() {

      public InetAddress getInetAddress() {
        try {
          return InetAddress.getByName("localhost");
View Full Code Here

  }
 
  public void testAuthorizedPut() throws Exception {
    //testing
    GraphOverTime trustedGOT = new MemoryStoreImpl().getGraphOverTime(new HashSet<Source>());
    Policy orig = Policy.getPolicy();
    Policy.setPolicy(new DefaultPolicy(trustedGOT));
    //Policy.setPolicy(orig);
    Policy.setPolicy(null);
    Policy.setPolicy(new NoRestrictionsPolicy());

    //
    Store store = new MemoryStoreImpl();
    ServerBinding serverBinding = new ServerBinding() {

      public InetAddress getInetAddress() {
        try {
          return InetAddress.getByName("localhost");
        } catch (UnknownHostException e) {
          throw new RuntimeException(e);
        }
      }

      public int getPort() {
        return 8686;
      }

    };
    URL sourceURL = new URL("http://"
        + serverBinding.getInetAddress().getHostName() + ":"
        + serverBinding.getPort() + "/danbri");
    Source identity = new SourceImpl("http://example.org/tests/identity");
    Set<Source> trustedSources  = new HashSet<Source>();
    trustedSources.add(identity);
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/configuration#");
    Model authorizationModel = ModelFactory.createDefaultModel();
    Resource user = authorizationModel.createResource(FOAF.Agent);
    user.addProperty(ACCOUNTMANAGER.userName, "beta");
    user.addProperty(ACCOUNTMANAGER.passwordSha1, Util.sha1("tester"));
    user.addProperty(AUTHORIZATION.mayImpersonate, authorizationModel.createResource(sourceURL.toString()));
    store.assertGraph(identity, new FCAGraphImpl(authorizationModel));
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
    model.read(new File("testdata/danbri-20060920123618661.rdf").toURL()
View Full Code Here

    webServer.stop();

  }
 
  public void testWrongPasswordPut() throws Exception {
    Store store = new MemoryStoreImpl();
    ServerBinding serverBinding = new ServerBinding() {

      public InetAddress getInetAddress() {
        try {
          return InetAddress.getByName("localhost");
        } catch (UnknownHostException e) {
          throw new RuntimeException(e);
        }
      }

      public int getPort() {
        return 8686;
      }

    };
    URL sourceURL = new URL("http://"
        + serverBinding.getInetAddress().getHostName() + ":"
        + serverBinding.getPort() + "/danbri");
    Source identity = new SourceImpl("http://example.org/tests/identity");
    Set<Source> trustedSources  = new HashSet<Source>();
    trustedSources.add(identity);
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/configuration#");
    Model authorizationModel = ModelFactory.createDefaultModel();
    Resource user = authorizationModel.createResource(FOAF.Agent);
    user.addProperty(ACCOUNTMANAGER.userName, "beta");
    user.addProperty(ACCOUNTMANAGER.passwordSha1, Util.sha1("tester"));
    user.addProperty(AUTHORIZATION.mayImpersonate, authorizationModel.createResource(sourceURL.toString()));
    store.assertGraph(identity, new FCAGraphImpl(authorizationModel));
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
    model.read(new File("testdata/danbri-20060920123618661.rdf").toURL()
View Full Code Here

   */
  public boolean performTest(FCAGraph[] graphs) {
    try {
      for (int k = 0; k < 10; k++) {
        ToyClock clock = new ToyClock();
        Store store = new MemoryStoreImpl(clock);
        Source source = new SourceImpl(
            "http://example.org/graph-source");
        for (int i = 0; i < graphs.length; i++) {
          //TODO leanify on dec
          graphs[i] = new FCAGraphImpl(MoleculeBasedLeanifier
              .getLeanVersionOf(graphs[i]));
        }
        TimedGraphSequence tgs = TimedGraphSequence
            .getSequenceWithRandomDates(graphs);
        for (int i = 0; i < tgs.getSize(); i++) {
          clock.setTime(tgs.getDate(i));
          store.updateGraph(source, tgs.getGraph(i));
        }
        if (!StoreTest.compareAllVersions(store, source, tgs)) {
          return false;
        }
        // tgs.write(System.out);
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {;
    MemoryStoreImpl store = new MemoryStoreImpl();
    readCannedData(store, new File("testdata"), "http://localhost:8181/");
    // store.getGraphOverTime(sources)
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.gvs.impl.memory.MemoryStoreImpl

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.