-/**
- * This document is a part of the source code and related artifacts for
- * CollectionSpace, an open source collections management system for museums and
- * related institutions:
- *
- * http://www.collectionspace.org http://wiki.collectionspace.org
- *
- * Copyright (c) 2012 Regents of the University of California
- *
- * Licensed under the Educational Community License (ECL), Version 2.0. You may
- * not use this file except in compliance with this License.
- *
- * You may obtain a copy of the ECL 2.0 License at
- * https://source.collectionspace.org/collection-space/LICENSE.txt
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.collectionspace.services.common.test;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.collectionspace.services.common.ServiceMain;
-import org.collectionspace.services.common.StoredValuesUriTemplate;
-import org.collectionspace.services.common.UriTemplateFactory;
-import org.collectionspace.services.common.UriTemplateRegistry;
-import org.collectionspace.services.common.UriTemplateRegistryKey;
-import org.collectionspace.services.common.api.Tools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Test;
-
-public class UriTemplateRegistryTest {
-
- private static final Logger logger = LoggerFactory.getLogger(UriTemplateRegistryTest.class);
- UriTemplateRegistry registry;
- final static String TEST_TENANT_ID = "1";
- final static String TEST_DOCTYPE_NAME = "Doctype";
- final static String TEST_TEMPATE = "/doctypes";
- final static UriTemplateFactory.UriTemplateType TEST_URI_TEMPLATE_TYPE =
- UriTemplateFactory.RESOURCE;
-
- private void testBanner(String msg) {
- String BANNER = "-------------------------------------------------------";
- logger.debug("\r" + BANNER + "\r\n" + this.getClass().getName() + "\r\n" + msg + "\r\n" + BANNER);
- }
-
- /**
- * Create a test entry in the registry.
- */
- @BeforeSuite
- private void setUp() {
- UriTemplateRegistryKey key = new UriTemplateRegistryKey(TEST_TENANT_ID, TEST_DOCTYPE_NAME);
- Map<String,String> storedValues = new HashMap<String,String>();
- StoredValuesUriTemplate template = new StoredValuesUriTemplate(TEST_URI_TEMPLATE_TYPE, TEST_TEMPATE, storedValues);
- registry = new UriTemplateRegistry();
- registry.put(key, template);
- }
-
- @Test
- public void registryContainsEntries() {
- testBanner("registryContainsEntries");
- Assert.assertNotNull(registry);
- Assert.assertFalse(registry.isEmpty());
- }
-
- /**
- * Identify a valid entry in the registry, then use its key to successfully
- * retrieve the entry once again.
- */
- @Test(dependsOnMethods = {"registryContainsEntries"})
- public void getRegistryEntryByKey() {
- testBanner("getRegistryEntryByKey");
- UriTemplateRegistryKey key;
- StoredValuesUriTemplate template;
- boolean hasValidKey = false;
- boolean hasValidTemplate = false;
- for (Map.Entry<UriTemplateRegistryKey, StoredValuesUriTemplate> entry : registry.entrySet()) {
- key = entry.getKey();
- template = entry.getValue();
- if (key != null && Tools.notBlank(key.getTenantId()) && Tools.notBlank(key.getDocType())) {
- hasValidKey = true;
- }
- if (template != null && template.getUriTemplateType() != null && Tools.notBlank(template.toString())) {
- hasValidTemplate = true;
- }
- if (hasValidKey && hasValidTemplate) {
- break;
- }
- Assert.assertTrue(hasValidKey && hasValidTemplate);
- StoredValuesUriTemplate retrievedTemplate = registry.get(key);
- Assert.assertNotNull(retrievedTemplate);
- Assert.assertEquals(template.toString(), retrievedTemplate.toString());
-
- }
- }
-}
+/**\r
+ * This document is a part of the source code and related artifacts for\r
+ * CollectionSpace, an open source collections management system for museums and\r
+ * related institutions:\r
+ *\r
+ * http://www.collectionspace.org http://wiki.collectionspace.org\r
+ *\r
+ * Copyright (c) 2012 Regents of the University of California\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0. You may\r
+ * not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r
+ * License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ */\r
+package org.collectionspace.services.common.test;\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+import org.collectionspace.services.common.ServiceMain;\r
+import org.collectionspace.services.common.StoredValuesUriTemplate;\r
+import org.collectionspace.services.common.UriTemplateFactory;\r
+import org.collectionspace.services.common.UriTemplateRegistry;\r
+import org.collectionspace.services.common.UriTemplateRegistryKey;\r
+import org.collectionspace.services.common.api.Tools;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.testng.Assert;\r
+import org.testng.annotations.BeforeSuite;\r
+import org.testng.annotations.Test;\r
+\r
+public class UriTemplateRegistryTest {\r
+\r
+ private static final Logger logger = LoggerFactory.getLogger(UriTemplateRegistryTest.class);\r
+ UriTemplateRegistry registry;\r
+ final static String TEST_TENANT_ID = "1";\r
+ final static String TEST_DOCTYPE_NAME = "Doctype";\r
+ final static String TEST_TEMPATE = "/doctypes";\r
+ final static UriTemplateFactory.UriTemplateType TEST_URI_TEMPLATE_TYPE =\r
+ UriTemplateFactory.RESOURCE;\r
+\r
+ private void testBanner(String msg) {\r
+ String BANNER = "-------------------------------------------------------";\r
+ logger.debug("\r" + BANNER + "\r\n" + this.getClass().getName() + "\r\n" + msg + "\r\n" + BANNER);\r
+ }\r
+\r
+ /**\r
+ * Create a test entry in the registry.\r
+ */\r
+ @BeforeSuite\r
+ private void setUp() {\r
+ UriTemplateRegistryKey key = new UriTemplateRegistryKey(TEST_TENANT_ID, TEST_DOCTYPE_NAME);\r
+ Map<String,String> storedValues = new HashMap<String,String>();\r
+ StoredValuesUriTemplate template = new StoredValuesUriTemplate(TEST_URI_TEMPLATE_TYPE, TEST_TEMPATE, storedValues);\r
+ registry = new UriTemplateRegistry();\r
+ registry.put(key, template);\r
+ }\r
+\r
+ @Test\r
+ public void registryContainsEntries() {\r
+ testBanner("registryContainsEntries");\r
+ Assert.assertNotNull(registry);\r
+ Assert.assertFalse(registry.isEmpty());\r
+ }\r
+\r
+ /**\r
+ * Identify a valid entry in the registry, then use its key to successfully\r
+ * retrieve the entry once again.\r
+ */\r
+ @Test(dependsOnMethods = {"registryContainsEntries"})\r
+ public void getRegistryEntryByKey() {\r
+ testBanner("getRegistryEntryByKey");\r
+ UriTemplateRegistryKey key;\r
+ StoredValuesUriTemplate template;\r
+ boolean hasValidKey = false;\r
+ boolean hasValidTemplate = false;\r
+ for (Map.Entry<UriTemplateRegistryKey, StoredValuesUriTemplate> entry : registry.entrySet()) {\r
+ key = entry.getKey();\r
+ template = entry.getValue();\r
+ if (key != null && Tools.notBlank(key.getTenantId()) && Tools.notBlank(key.getDocType())) {\r
+ hasValidKey = true;\r
+ }\r
+ if (template != null && template.getUriTemplateType() != null && Tools.notBlank(template.toString())) {\r
+ hasValidTemplate = true;\r
+ }\r
+ if (hasValidKey && hasValidTemplate) {\r
+ break;\r
+ }\r
+ Assert.assertTrue(hasValidKey && hasValidTemplate);\r
+ StoredValuesUriTemplate retrievedTemplate = registry.get(key);\r
+ Assert.assertNotNull(retrievedTemplate);\r
+ Assert.assertEquals(template.toString(), retrievedTemplate.toString());\r
+\r
+ }\r
+ }\r
+}\r