Merged WEBAPP-API (5.2.1) to 5.2.N (5.2.1)

135227 jkaabimofrad: APPSREPO-132: Make ClientAppConfig generic so it could be used by other V1 APIs.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@135564 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2017-03-03 11:41:47 +00:00
parent 38f96ce41b
commit 6cfc6a74d3
14 changed files with 224 additions and 151 deletions

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -269,7 +269,7 @@ public class Repository01TestSuite extends TestSuite
static void tests40(TestSuite suite)
{
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.quickshare.ClientAppConfigTest.class));
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.client.config.ClientAppConfigTest.class));
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.quickshare.QuickShareServiceIntegrationTest.class));
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.rating.RatingServiceIntegrationTest.class));
suite.addTest(new JUnit4TestAdapter(org.alfresco.repo.remotecredentials.RemoteCredentialsServicesTest.class));

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -24,18 +24,20 @@
* #L%
*/
package org.alfresco.repo.quickshare;
package org.alfresco.repo.client.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.alfresco.repo.quickshare.ClientAppConfig.ClientApp;
import org.alfresco.repo.client.config.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.Collections;
import java.util.Map;
/**
@@ -51,10 +53,10 @@ public class ClientAppConfigTest
@BeforeClass
public static void setUp() throws Exception
{
context = new ClassPathXmlApplicationContext(new String[] { "classpath:org/alfresco/repo/quickshare/test-quickshare-clients-context.xml" },
context = new ClassPathXmlApplicationContext(new String[] { "classpath:org/alfresco/repo/client/config/test-repo-clients-apps-context.xml" },
ApplicationContextHelper.getApplicationContext());
clientAppConfig = context.getBean("quickShareClientsConfigTest", ClientAppConfig.class);
clientAppConfig = context.getBean("clientAppConfigTest", ClientAppConfig.class);
}
@@ -69,33 +71,54 @@ public class ClientAppConfigTest
{
Map<String, ClientApp> clients = clientAppConfig.getClients();
assertNotNull(clients);
assertEquals("Incorrect number of clients", 3, clients.size());
assertEquals("Incorrect number of clients", 4, clients.size());
// loaded from org/alfresco/repo/quickshare/test-quickshare-clients-config.properties
// loaded from org/alfresco/repo/client/config/test-repo-clients-apps.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/o", client1.getProperty("sharedLinkBaseUrl"));
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
// loaded from org/alfresco/repo/client/config/test-repo-clients-apps.properties and overridden by
// org/alfresco/repo/client/config/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/t", client2.getProperty("sharedLinkBaseUrl"));
assertEquals("https://127.0.0.1:8082/test-client2", client2.getTemplateAssetsUrl());
// loaded from org/alfresco/repo/quickshare/test-global-properties.properties
// loaded from org/alfresco/repo/client/config/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());
assertEquals("http://localhost:8085/test-client5/f", client3.getProperty("myProp1"));
assertEquals("http://localhost:8085/test-client5", client3.getProperty("myProp2"));
assertEquals("test prop3", client3.getProperty("myProp3"));
assertEquals("test prop4", client3.getProperty("myProp4"));
assertEquals("test prop5", client3.getProperty("myProp5-with-hyphen"));
assertNull(client3.getTemplateAssetsUrl());
// loaded from org/alfresco/repo/client/config/test-global-properties.properties
ClientApp client4 = clientAppConfig.getClient("test-client11");
assertNotNull(client4);
assertEquals("test-client11", client4.getName());
assertEquals("http://localhost:8811/test-client11/t", client4.getProperty("myClientRequiredConfigUrl"));
assertNull(client4.getTemplateAssetsUrl());
// Try to add a property into an unmodifiable map
try
{
client4.getProperties().put("newProperty"," test value");
fail("Shouldn't be able to modify the client's processed properties.");
}
catch (UnsupportedOperationException ex)
{
// expected
}
// 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");
ClientApp newClient = new ClientApp("testClient" + System.currentTimeMillis(),
"http://localhost:8085/testclient", Collections.singletonMap("sharedLinkBaseUrl", "http://localhost:8085/test-client/s"));
try
{
clients.put(newClient.getName(), newClient);