2 * Copyright (C) 2012 Openismus GmbH
4 * This file is part of GWT-Glom.
6 * GWT-Glom is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
11 * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with GWT-Glom. If not, see <http://www.gnu.org/licenses/>.
20 package org.glom.web.server;
22 import static org.junit.Assert.*;
24 import java.beans.PropertyVetoException;
26 import java.util.List;
28 import junit.framework.Assert;
30 import org.apache.commons.lang3.StringUtils;
31 import org.glom.web.server.libglom.Document;
32 import org.glom.web.server.libglom.DocumentTest;
33 import org.glom.web.shared.DocumentInfo;
34 import org.glom.web.shared.Reports;
35 import org.glom.web.shared.libglom.layout.LayoutGroup;
36 import org.glom.web.shared.libglom.layout.LayoutItem;
37 import org.glom.web.shared.libglom.layout.LayoutItemField;
38 import org.junit.AfterClass;
39 import org.junit.BeforeClass;
40 import org.junit.Test;
43 * @author Murray Cumming <murrayc@openismus.com>
46 public class ConfiguredDocumentTest {
48 private static ConfiguredDocument configuredDoc;
49 private static Document document;
50 private static String defaultLocale = "";
51 private static String germanLocale = "de";
54 static public void setUp() throws PropertyVetoException {
55 URL url = DocumentTest.class.getResource("example_music_collection.glom");
56 assertTrue(url != null);
57 final String testUriMusicCollection = url.toString();
58 assertTrue(!StringUtils.isEmpty(testUriMusicCollection));
60 document = new Document();
61 document.setFileURI(testUriMusicCollection);
62 final boolean retval = document.load();
65 configuredDoc = new ConfiguredDocument(document);
69 static public void tearDown() {
73 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDocument()}.
76 public void testGetDocument() {
77 Assert.assertNotNull(configuredDoc.getDocument());
81 * Test method for {@link org.glom.web.server.ConfiguredDocument#isAuthenticated()}.
84 public void testIsAuthenticated() {
85 Assert.assertFalse(configuredDoc.isAuthenticated());
89 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDocumentID()}.
92 public void testGetDocumentID() {
93 //This is a simple setter/getter:
94 final String docID = "somethingOrOther";
95 configuredDoc.setDocumentID(docID);
96 Assert.assertEquals(docID, configuredDoc.getDocumentID());
100 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDefaultLocaleID()}.
103 public void testGetDefaultLocaleID() {
104 Assert.assertEquals("", configuredDoc.getDefaultLocaleID());
108 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDocumentInfo(java.lang.String)}.
111 public void testGetDocumentInfo() {
113 DocumentInfo docInfo = configuredDoc.getDocumentInfo(defaultLocale);
114 Assert.assertNotNull(docInfo);
115 Assert.assertEquals(docInfo.getTitle(), "Music Collection");
118 docInfo = configuredDoc.getDocumentInfo(germanLocale);
119 Assert.assertNotNull(docInfo);
120 Assert.assertEquals(docInfo.getTitle(), "Musiksammlung");
122 //Invalid locale, which should use the default one:
123 docInfo = configuredDoc.getDocumentInfo("someinvalidlocale");
124 Assert.assertNotNull(docInfo);
125 Assert.assertEquals(docInfo.getTitle(), "Music Collection");
129 * Test method for {@link org.glom.web.server.ConfiguredDocument#getSuitableRecordToViewDetails(java.lang.String, org.glom.web.shared.libglom.layout.LayoutItemPortal, org.glom.web.shared.TypedDataItem)}.
132 public void testGetSuitableRecordToViewDetails() {
133 //TODO: final NavigationRecord navRecord = configuredDoc.getSuitableRecordToViewDetails(tableName, portal, primaryKeyValue);
137 * Test method for {@link org.glom.web.server.ConfiguredDocument#getReports(java.lang.String, java.lang.String)}.
140 public void testGetReports() {
141 final Reports reports = configuredDoc.getReports("albums", defaultLocale);
142 Assert.assertNotNull(reports);
143 //TODO: test more details.