cleanup
[taxeditor.git] / eu.etaxonomy.taxeditor.test / src / test / java / eu / etaxonomy / taxeditor / httpinvoker / HttpInvokerServicesTest.java
index 4c2d51e651dd1fd4af1bb1a6df37c4d5cb50c6ff..45a58486350028c91ea2e972a48d28c4b95e8cfd 100644 (file)
@@ -10,18 +10,24 @@ package eu.etaxonomy.taxeditor.httpinvoker;
 
 import org.apache.log4j.Logger;
 import org.junit.Assert;
+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);
 
+    ITestService testService =  getRemoteApplicationController().getTestService();
 
     @Test
     public void whenCallingMethodsOnRemoteServicesThenSucceed() {
@@ -30,8 +36,6 @@ public class HttpInvokerServicesTest extends BaseRemotingTest {
             //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");
         }
@@ -39,4 +43,28 @@ public class HttpInvokerServicesTest extends BaseRemotingTest {
         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);
+    }
 }