#5297 Add remoting progress monitoring
[taxeditor.git] / eu.etaxonomy.taxeditor.test / src / test / java / eu / etaxonomy / taxeditor / httpinvoker / HttpInvokerServicesTest.java
1 /**
2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.httpinvoker;
10
11 import org.apache.log4j.Logger;
12 import org.junit.Assert;
13 import org.junit.Ignore;
14 import org.junit.Test;
15 import org.springframework.remoting.RemoteAccessException;
16 import org.springframework.security.core.context.SecurityContext;
17 import org.springframework.security.core.context.SecurityContextHolder;
18
19 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
20 import eu.etaxonomy.cdm.api.service.ITestService;
21 import eu.etaxonomy.cdm.config.CdmSourceException;
22 import eu.etaxonomy.cdm.model.description.PolytomousKey;
23
24 /**
25 * Class to test the HttpInvoker services exposed by the CDM Sever
26 *
27 */
28 public class HttpInvokerServicesTest extends BaseRemotingTest {
29 private static final Logger logger = Logger.getLogger(HttpInvokerServicesTest.class);
30
31 ITestService testService = getRemoteApplicationController().getTestService();
32
33 @Test
34 public void whenCallingMethodsOnRemoteServicesThenSucceed() {
35 try {
36
37 //getRemoteApplicationController().getDatabaseService();
38 String dbSchemaVersion = getRemoteApplicationController().getDatabaseService().getDbSchemaVersion();
39 logger.info("dbSchemaVersion is " + dbSchemaVersion);
40
41
42 } catch (CdmSourceException e) {
43 Assert.fail("pinging database service on active cdm server should not have thrown CdmSourceException");
44 }
45
46 getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null);
47
48 }
49
50 @Ignore
51 @Test
52 public void whenCallingMethodsOnRemoteServicesThenFailIfNotAuthenticated() {
53
54 SecurityContext context = SecurityContextHolder.getContext();
55
56 CdmApplicationState.setCurrentSecurityContext(null);
57 try {
58 getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null);
59 Assert.fail("service call should fail as it is not authenticated");
60 }catch (RemoteAccessException rae) {
61
62 }
63
64 CdmApplicationState.setCurrentSecurityContext(context);
65
66 }
67
68 // should be kept at ignore and only used for manual testing
69 // otherwise tests will take too much time
70 @Ignore
71 @Test
72 public void testDisableReadTimeout() throws InterruptedException {
73 testService.waitFor((long) 120000.0);
74 }
75
76
77
78 }