2 * Copyright (C) 2014 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.httpinvoker
;
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
;
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
;
25 * Class to test the HttpInvoker services exposed by the CDM Sever
27 public class HttpInvokerServicesTest
extends BaseRemotingTest
{
28 private static final Logger logger
= Logger
.getLogger(HttpInvokerServicesTest
.class);
30 ITestService testService
= getRemoteApplicationController().getTestService();
33 public void whenCallingMethodsOnRemoteServicesThenSucceed() {
36 //getRemoteApplicationController().getDatabaseService();
37 String dbSchemaVersion
= getRemoteApplicationController().getDatabaseService().getDbSchemaVersion();
38 logger
.info("dbSchemaVersion is " + dbSchemaVersion
);
39 } catch (CdmSourceException e
) {
40 Assert
.fail("pinging database service on active cdm server should not have thrown CdmSourceException");
43 getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey
.class, null, null, null, null);
48 public void whenCallingMethodsOnRemoteServicesThenFailIfNotAuthenticated() {
50 SecurityContext context
= SecurityContextHolder
.getContext();
52 CdmApplicationState
.setCurrentSecurityContext(null);
54 getRemoteApplicationController().getPolytomousKeyService().list(PolytomousKey
.class, null, null, null, null);
55 Assert
.fail("service call should fail as it is not authenticated");
56 }catch (RemoteAccessException rae
) {
60 CdmApplicationState
.setCurrentSecurityContext(context
);
63 // should be kept at ignore and only used for manual testing
64 // otherwise tests will take too much time
67 public void testDisableReadTimeout() throws InterruptedException
{
68 testService
.waitFor((long) 120000.0);