cleanup
[taxeditor.git] / eu.etaxonomy.taxeditor.test / src / test / java / eu / etaxonomy / taxeditor / httpinvoker / HttpInvokerServicesTest.java
index 86ebe8b0daaffe0629ed957fff5f49d33676d6cc..45a58486350028c91ea2e972a48d28c4b95e8cfd 100644 (file)
@@ -8,37 +8,63 @@
  */
 package eu.etaxonomy.taxeditor.httpinvoker;
 
-import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
+import org.springframework.remoting.RemoteAccessException;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
 
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.api.service.ITestService;
 import eu.etaxonomy.cdm.config.CdmSourceException;
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
 
 /**
  * Class to test the HttpInvoker services exposed by the CDM Sever
- *
  */
 public class HttpInvokerServicesTest extends BaseRemotingTest {
     private static final Logger logger = Logger.getLogger(HttpInvokerServicesTest.class);
 
-    @BeforeClass
-    public static void initializeHttpInvokerServicesTest() {
-        logger.setLevel(Level.INFO);
-        //initializeController("default", "127.0.0.1", 8080, "", NomenclaturalCode.ICNAFP);
-    }
+    ITestService testService =  getRemoteApplicationController().getTestService();
 
     @Test
     public void whenCallingMethodsOnRemoteServicesThenSucceed() {
         try {
 
-            getRemoteApplicationController().getDatabaseService();
+            //getRemoteApplicationController().getDatabaseService();
             String dbSchemaVersion = getRemoteApplicationController().getDatabaseService().getDbSchemaVersion();
             logger.info("dbSchemaVersion is " + dbSchemaVersion);
         } catch (CdmSourceException e) {
             Assert.fail("pinging database service on active cdm server should not have thrown CdmSourceException");
         }
+
+        getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null);
+    }
+
+    @Ignore
+    @Test
+    public void whenCallingMethodsOnRemoteServicesThenFailIfNotAuthenticated() {
+
+        SecurityContext context = SecurityContextHolder.getContext();
+
+        CdmApplicationState.setCurrentSecurityContext(null);
+        try {
+            getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null);
+            Assert.fail("service call should fail as it is not authenticated");
+        }catch (RemoteAccessException rae) {
+
+        }
+
+        CdmApplicationState.setCurrentSecurityContext(context);
     }
 
+    // should be kept at ignore and only used for manual testing
+    // otherwise tests will take too much time
+    @Ignore
+    @Test
+    public void testDisableReadTimeout() throws InterruptedException  {
+        testService.waitFor((long) 120000.0);
+    }
 }