Package test.util

Examples of test.util.TestConfig


   protected void setUp() throws Exception
   {
      File dir = TestConfig.getTestDir("users");
      dir.delete();
     
      config = new TestConfig("users","localhost","localhost",8080);
      config.startServer();
      adminUserLoc = new Reference(config.getServerLocation().toString()+"admin/users/");
      adminUserLoc = adminUserLoc.normalize();
   }
View Full Code Here


   public void testBasics()
      throws Exception
   {
      File dir = TestConfig.getTestDir("test.app.introspection.basics");
      dir.delete();
      TestConfig config = new TestConfig("test.app.introspection.basics","localhost","localhost",8080);
      // Make sure we start clean
      System.out.println("Using database directory: "+config.getDatabaseDirectory());
     
      config.startServer();
     
      Reference introLoc = new Reference(config.getServerLocation());
     
      IntrospectionClient client = new IntrospectionClient(LOG,introLoc);
      client.setIdentity("admin","admin");
     
      final Slot<Integer> workspaceCount = new Slot<Integer>(0);
      final Slot<Integer> collectionCount = new Slot<Integer>(0);
      client.introspect(new IntrospectionClient.ServiceListener() {
         public void onStartWorkspace(String title) {
            workspaceCount.set(workspaceCount.get().intValue()+1);
         }
         public void onCollection(EntryCollection collection) {
            collectionCount.set(collectionCount.get().intValue()+1);
         }
         public void onEndWorkspace() {
         }
      });
      assertTrue(workspaceCount.get().intValue()==1);
      assertTrue(collectionCount.get().intValue()==0);
     
      config.stopServer();
   }
View Full Code Here

      throws Exception
   {
      File dir = TestConfig.getTestDir("test.app.feed.basics");
      dir.delete();
     
      TestConfig config = new TestConfig("test.app.feed.basics","localhost","localhost",8080);
      // Make sure we start clean
      System.out.println("Using database directory: "+config.getDatabaseDirectory());
     
      config.startServer();
     
      Client client = new Client(new Context(),config.getServerLocation().getSchemeProtocol()) {
         public void handle(Request request,Response response) {
            request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC,"admin","admin"));
            super.handle(request,response);
         }
      };
     
      Reference rootFeed = new Reference(config.getServerLocation()+"R/");
     
      Response response;
      Form headers;
      String entryLocation;
      Reference entryRef;

      response = client.handle(makeHead(rootFeed));
      System.out.println("Status: "+response.getStatus());
      switch (response.getStatus().getCode()) {
         case 404:
         {
            System.out.println("Creating feed.");
            response = client.handle(makePost(rootFeed,new StringRepresentation("<feed xmlns='http://www.w3.org/2005/Atom'><title>Root</title></feed>",MediaType.APPLICATION_ATOM)));
            System.out.println("Status: "+response.getStatus());
            response.getEntity().release();
            assertTrue(response.getStatus().isSuccess());
            break;
         }
         default:
            assertTrue(response.getStatus().isSuccess());
      }
     
      response = client.handle(makePost(rootFeed,new StringRepresentation("<entry xmlns='http://www.w3.org/2005/Atom'><title>Entry 1</title></entry>",MediaType.APPLICATION_ATOM)));
      System.out.println("Status: "+response.getStatus());
      assertTrue(response.getStatus().isSuccess());
      headers = (Form)response.getAttributes().get("org.restlet.http.headers");
      entryLocation = headers.getValues("Location");
      System.out.println("Entry: "+entryLocation);
      //System.out.println("Entry: "+response.getEntity().getText());
      response.getEntity().release();
     
      entryRef = new Reference(entryLocation);
      response = client.handle(makeGet(entryRef));
      System.out.println("Status: "+response.getStatus());
      response.getEntity().release();
      assertTrue(response.getStatus().isSuccess());
     
      response = client.handle(makePost(rootFeed,new StringRepresentation("<entry xmlns='http://www.w3.org/2005/Atom'><title>Entry 2</title></entry>",MediaType.APPLICATION_ATOM)));
      System.out.println("Status: "+response.getStatus());
      response.getEntity().release();
      assertTrue(response.getStatus().isSuccess());
      entryLocation = headers.getValues("Location");
      System.out.println("Entry: "+entryLocation);
      response.getEntity().release();
     
      entryRef = new Reference(entryLocation);
      response = client.handle(makeGet(entryRef));
      System.out.println("Status: "+response.getStatus());
      assertTrue(response.getStatus().isSuccess());
      response.getEntity().release();
     
      response = client.handle(makePut(rootFeed,new StringRepresentation("<feed xmlns='http://www.w3.org/2005/Atom'><title>Root</title><category term='test'/><category term='bingo'/></feed>",MediaType.APPLICATION_ATOM)));
      System.out.println("Status: "+response.getStatus());
      assertTrue(response.getStatus().isSuccess());
      response.getEntity().release();
     
      config.stopServer();
   }
View Full Code Here

   }
  
   public void testStress()
      throws Exception
   {
      config = new TestConfig("test.app.stress","localhost","localhost",8080);
      File dir = TestConfig.getTestDir("test.app.stress");
      TestConfig.deltree(dir);

      Logger log = Logger.getLogger(EntryTest.class.getName());
      // Make sure we start clean
View Full Code Here

TOP

Related Classes of test.util.TestConfig

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.