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 org.apache.commons.lang3.StringUtils;
27 import org.glom.web.server.libglom.Document;
28 import org.glom.web.server.libglom.DocumentTest;
29 import org.glom.web.shared.DocumentInfo;
30 import org.glom.web.shared.Reports;
31 import org.junit.AfterClass;
32 import org.junit.BeforeClass;
33 import org.junit.Test;
36 * @author Murray Cumming <murrayc@openismus.com>
39 public class ConfiguredDocumentTest {
41 private static ConfiguredDocument configuredDoc;
42 private static Document document;
43 private static String defaultLocale = "";
44 private static String germanLocale = "de";
47 static public void setUp() throws PropertyVetoException {
48 URL url = DocumentTest.class.getResource("example_music_collection.glom");
50 final String testUriMusicCollection = url.toString();
51 assertTrue(!StringUtils.isEmpty(testUriMusicCollection));
53 document = new Document();
54 document.setFileURI(testUriMusicCollection);
55 final boolean retval = document.load();
58 configuredDoc = new ConfiguredDocument(document);
62 static public void tearDown() {
66 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDocument()}.
69 public void testGetDocument() {
70 assertNotNull(configuredDoc.getDocument());
74 * Test method for {@link org.glom.web.server.ConfiguredDocument#isAuthenticated()}.
77 public void testIsAuthenticated() {
78 assertFalse(configuredDoc.isAuthenticated());
82 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDocumentID()}.
85 public void testGetDocumentID() {
86 //This is a simple setter/getter:
87 final String docID = "somethingOrOther";
88 configuredDoc.setDocumentID(docID);
89 assertEquals(docID, configuredDoc.getDocumentID());
93 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDefaultLocaleID()}.
96 public void testGetDefaultLocaleID() {
97 assertEquals("", configuredDoc.getDefaultLocaleID());
101 * Test method for {@link org.glom.web.server.ConfiguredDocument#getDocumentInfo(java.lang.String)}.
104 public void testGetDocumentInfo() {
106 DocumentInfo docInfo = configuredDoc.getDocumentInfo(defaultLocale);
107 assertNotNull(docInfo);
108 assertEquals(docInfo.getTitle(), "Music Collection");
111 docInfo = configuredDoc.getDocumentInfo(germanLocale);
112 assertNotNull(docInfo);
113 assertEquals(docInfo.getTitle(), "Musiksammlung");
115 //Invalid locale, which should use the default one:
116 docInfo = configuredDoc.getDocumentInfo("someinvalidlocale");
117 assertNotNull(docInfo);
118 assertEquals(docInfo.getTitle(), "Music Collection");
122 * 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)}.
125 public void testGetSuitableRecordToViewDetails() {
126 //TODO: final NavigationRecord navRecord = configuredDoc.getSuitableRecordToViewDetails(tableName, portal, primaryKeyValue);
130 * Test method for {@link org.glom.web.server.ConfiguredDocument#getReports(java.lang.String, java.lang.String)}.
133 public void testGetReports() {
134 final Reports reports = configuredDoc.getReports("albums", defaultLocale);
135 assertNotNull(reports);
136 //TODO: test more details.