Package org.wymiwyg.wrhapi

Examples of org.wymiwyg.wrhapi.ServerBinding


  public void start() {
    Graph trustedGraph = store.getGraphOverTime(trustedSources).getGraph(new Date());
    Model trustedModel = JenaUtil.getModelFromGraph(trustedGraph);
    final Resource configRes = trustedModel.getResource(configuration.getURIRef());
    try {
      GVSServerLauncher.launchGVSServer(store, new ServerBinding() {
        public InetAddress getInetAddress() {
          Statement nicStatement = configRes.getProperty(HTTPLISTENER.networkInterface);
          if (nicStatement != null) {
            try {
              return InetAddress.getByName(nicStatement.getString());
View Full Code Here


*
*/
public class GVSServerLauncherTest extends TestCase {

  public void testFileRetrieval() throws Exception {
    ServerBinding serverBinding = new ServerBinding() {

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

      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);
    Source source = new SourceImpl("http://example.org/graph-source");
    NamedNode config = new NamedNodeImpl("http://example.org/config#");
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, null, Collections.singleton(source), config);
    URL serverURL = new URL("http://"+serverBinding.getInetAddress().getHostAddress()+":"+serverBinding.getPort()+"/application/test-dir/test-data");
    InputStream remoteStream = serverURL.openStream();
    InputStream resourceStream = ApplicationServerHandler.class.getResourceAsStream("/META-INF/web/application/test-dir/test-data.txt");
    for (int i = resourceStream.read(); i > -1; i = resourceStream.read()) {
      assertEquals(i, remoteStream.read());
    }
    //same with URL-extension
    serverURL = new URL("http://"+serverBinding.getInetAddress().getHostAddress()+":"+serverBinding.getPort()+"/application/test-dir/test-data.txt");
    remoteStream = serverURL.openStream();
    resourceStream = ApplicationServerHandler.class.getResourceAsStream("/META-INF/web/application/test-dir/test-data.txt");
    for (int i = resourceStream.read(); i > -1; i = resourceStream.read()) {
      assertEquals(i, remoteStream.read());
    }
View Full Code Here

  }

  public void testContentTypeResponseHeader() throws Exception {
    WebServerFactory webServerFactory = WebServerFactory.newInstance();
    ServerBinding serverBinding = new ServerBinding() {

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

      public int getPort() {
        return 8989;
      }

    };
    URL basePathURL = GVSServerLauncher.class
        .getResource("/META-INF/web/application/");
    PathNode rootNode = PathNodeFactory.getPathNode(basePathURL);
    WebServer webServer = webServerFactory.startNewWebServer(
        new ApplicationServerHandler(rootNode, "/application"),
        serverBinding);
    URL serverURL = new URL("http://"
        + serverBinding.getInetAddress().getHostAddress() + ":"
        + serverBinding.getPort() + "/application/test-dir/test-data");
    URLConnection connection = serverURL.openConnection();
    String contentType = connection.getHeaderField("Content-Type");
    assertEquals("text/plain", contentType);
    webServer.stop();
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");
        } catch (UnknownHostException e) {
          throw new RuntimeException(e);
        }
      }

      public int getPort() {
        return 8686;
      }

    };

    Source identity =new SourceImpl("http://example.org/tests/identity");
    Set<Source> trustedSources  = new HashSet<Source>();
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/identity");;
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
    model.read(new File("testdata/danbri-20060920123618661.rdf").toURL()
        .toString());
    URL serverURL = new URL("http://"
        + serverBinding.getInetAddress().getHostName() + ":"
        + serverBinding.getPort() + "/danbri");
    HttpURLConnection connection = (HttpURLConnection) serverURL
        .openConnection();
    connection.setDoOutput(true);
    connection.setRequestMethod("PUT");
    OutputStream out = connection.getOutputStream();
View Full Code Here

    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();
View Full Code Here

  }
 
  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();
View Full Code Here

    });
  }

  private void testWithCannedData(RetrievalTest retrievalTest)
      throws Exception {
    ServerBinding serverBinding = new ServerBinding() {

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

      public int getPort() {
        return 8686;
      }

    };
    Store store = new MemoryStoreImpl();
    File directory = new File("testdata");
    String baseURLString = "http://"
        + serverBinding.getInetAddress().getHostName() + ":"
        + serverBinding.getPort() + "/";
    CannedDataReader.readCannedData(store, directory, baseURLString);
    WebServerFactory webServerFactory = WebServerFactory.newInstance();
   
    WebServer webServer = webServerFactory.startNewWebServer(
        new GraphHandlerAdaptor(new GVSGraphHandler(store, null)),
View Full Code Here

*/
public class ApplicationServerHandlerTest extends TestCase {

  public void testFileRetrieval() throws Exception {
    WebServerFactory webServerFactory = WebServerFactory.newInstance();
    ServerBinding serverBinding = new ServerBinding() {

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

      public int getPort() {
        return 8989;
      }

    };
    URL basePathURL = GVSServerLauncher.class
        .getResource("/META-INF/web/application/");
    PathNode rootNode = PathNodeFactory.getPathNode(basePathURL);
    WebServer webServer = webServerFactory.startNewWebServer(
        new ApplicationServerHandler(rootNode, "/application"),
        serverBinding);
    try {
      URL serverURL = new URL("http://"
          + serverBinding.getInetAddress().getHostAddress() + ":"
          + serverBinding.getPort()
          + "/application/test-dir/test-data");
      InputStream remoteStream = serverURL.openStream();
      InputStream resourceStream = ApplicationServerHandler.class
          .getResourceAsStream("/META-INF/web/application/test-dir/test-data.txt");
      for (int i = resourceStream.read(); i < -1; i = resourceStream
          .read()) {
        assertEquals(i, remoteStream.read());
      }
      // same with URL-extension
      serverURL = new URL("http://"
          + serverBinding.getInetAddress().getHostAddress() + ":"
          + serverBinding.getPort()
          + "/application/test-dir/test-data.txt");
      remoteStream = serverURL.openStream();
      resourceStream = ApplicationServerHandler.class
          .getResourceAsStream("/META-INF/web/application/test-dir/test-data.txt");
      for (int i = resourceStream.read(); i > -1; i = resourceStream
View Full Code Here

  }

  public void testFileRetrievalWithQuery() throws Exception {
    WebServerFactory webServerFactory = WebServerFactory.newInstance();
    ServerBinding serverBinding = new ServerBinding() {

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

      public int getPort() {
        return 8989;
      }

    };
    URL basePathURL = GVSServerLauncher.class
        .getResource("/META-INF/web/application/");
    PathNode rootNode = PathNodeFactory.getPathNode(basePathURL);
    WebServer webServer = webServerFactory.startNewWebServer(
        new ApplicationServerHandler(rootNode, "/application"),
        serverBinding);
    try {
      URL serverURL = new URL("http://"
          + serverBinding.getInetAddress().getHostAddress() + ":"
          + serverBinding.getPort()
          + "/application/test-dir/test-data?bar.html");
      InputStream remoteStream = serverURL.openStream();
      InputStream resourceStream = ApplicationServerHandler.class
          .getResourceAsStream("/META-INF/web/application/test-dir/test-data.txt");
      for (int i = resourceStream.read(); i < -1; i = resourceStream
          .read()) {
        assertEquals(i, remoteStream.read());
      }
      // same with URL-extension
      serverURL = new URL("http://"
          + serverBinding.getInetAddress().getHostAddress() + ":"
          + serverBinding.getPort()
          + "/application/test-dir/test-data.txt?bar.html");
      remoteStream = serverURL.openStream();
      resourceStream = ApplicationServerHandler.class
          .getResourceAsStream("/META-INF/web/application/test-dir/test-data.txt");
      for (int i = resourceStream.read(); i > -1; i = resourceStream
View Full Code Here

          registerApplicationConfig(application, "");
        }
      };
      while (true) {

        ServerBinding serverBinding = new ServerBinding() {

          @Override
          public int getPort() {
            return port;
          }
View Full Code Here

TOP

Related Classes of org.wymiwyg.wrhapi.ServerBinding

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.