Files
alfresco-community-repo/source/test-java/org/alfresco/repo/quickshare/ClientAppConfigTest.java
Jamal Kaabi-Mofrad 57310498c9 Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
124623 jkaabimofrad: SFS-405, RA-778: Added tests and as the result did some minor modifications. Also, removed the ability to set or remove a client via JMX (Read only).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126573 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-05-10 11:35:15 +00:00

103 lines
4.0 KiB
Java

/*
* Copyright (C) 2005-2016 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.quickshare;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import org.alfresco.repo.quickshare.ClientAppConfig.ClientApp;
import org.alfresco.util.ApplicationContextHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.Map;
/**
* This class contains tests for the class {@link ClientAppConfig}
*
* @author Jamal Kaabi-Mofrad
*/
public class ClientAppConfigTest
{
private static ClassPathXmlApplicationContext context;
private static ClientAppConfig clientAppConfig;
@BeforeClass
public static void setUp() throws Exception
{
context = new ClassPathXmlApplicationContext(new String[] { "classpath:org/alfresco/repo/quickshare/test-quickshare-clients-context.xml" },
ApplicationContextHelper.getApplicationContext());
clientAppConfig = context.getBean("quickShareClientsConfigTest", ClientAppConfig.class);
}
@AfterClass
public static void tearDown() throws Exception
{
context.close();
}
@Test
public void testClients() throws Exception
{
Map<String, ClientApp> clients = clientAppConfig.getClients();
assertNotNull(clients);
assertEquals("Incorrect number of clients", 3, clients.size());
// loaded from org/alfresco/repo/quickshare/test-quickshare-clients-config.properties
ClientApp client1 = clientAppConfig.getClient("test-client1");
assertNotNull(client1);
assertEquals("test-client1", client1.getName());
assertEquals("http://localhost:8081/test-client1/o", client1.getSharedLinkBaseUrl());
assertEquals("http://localhost:8081/test-client1", client1.getTemplateAssetsUrl());
// loaded from org/alfresco/repo/quickshare/test-quickshare-clients-config.properties and overridden by
// org/alfresco/repo/quickshare/test-global-properties.properties
ClientApp client2 = clientAppConfig.getClient("test-client2");
assertNotNull(client2);
assertEquals("test-client2", client2.getName());
assertEquals("https://127.0.0.1:8082/test-client2/t", client2.getSharedLinkBaseUrl());
assertEquals("https://127.0.0.1:8082/test-client2", client2.getTemplateAssetsUrl());
// loaded from org/alfresco/repo/quickshare/test-global-properties.properties
ClientApp client3 = clientAppConfig.getClient("test-client5");
assertNotNull(client3);
assertEquals("test-client5", client3.getName());
assertEquals("http://localhost:8085/test-client5/f", client3.getSharedLinkBaseUrl());
assertEquals("http://localhost:8085/test-client5", client3.getTemplateAssetsUrl());
// Try to add a client into an unmodifiable map
ClientApp newClient = new ClientApp("testClient" + System.currentTimeMillis(), "http://localhost:8085/test-client/s",
"http://localhost:8085/testclient");
try
{
clients.put(newClient.getName(), newClient);
fail("Shouldn't be able to modify the clients map.");
}
catch (UnsupportedOperationException ex)
{
// expected
}
}
}