01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestDatabaseContentInfo.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.cmf.dam;
09:
10: import java.sql.Timestamp;
11:
12: import junit.framework.TestCase;
13:
14: import com.uwyn.rife.cmf.MimeType;
15: import com.uwyn.rife.cmf.dam.contentmanagers.DatabaseContentInfo;
16:
17: public class TestDatabaseContentInfo extends TestCase {
18: public TestDatabaseContentInfo(String name) {
19: super (name);
20: }
21:
22: public void testInstantiation() {
23: DatabaseContentInfo contentinfo = new DatabaseContentInfo();
24: assertNotNull(contentinfo);
25:
26: assertEquals(-1, contentinfo.getContentId());
27: assertNull(contentinfo.getPath());
28: assertEquals(-1, contentinfo.getVersion());
29: assertNull(contentinfo.getCreated());
30: assertNull(contentinfo.getMimeType());
31: assertFalse(contentinfo.isFragment());
32: assertFalse(contentinfo.hasName());
33: assertNull(contentinfo.getName());
34: assertNull(contentinfo.getAttributes());
35: assertFalse(contentinfo.hasAttributes());
36: assertFalse(contentinfo.hasAttribute("attr1"));
37: assertNull(contentinfo.getAttribute("attr1"));
38: assertEquals(-1, contentinfo.getSize());
39: assertFalse(contentinfo.hasProperties());
40: assertNull(contentinfo.getProperties());
41: assertFalse(contentinfo.hasProperty("some prop"));
42: assertNull(contentinfo.getProperty("some prop"));
43: }
44:
45: public void testContentId() {
46: DatabaseContentInfo contentinfo = new DatabaseContentInfo();
47: contentinfo.setContentId(12);
48: assertEquals(12, contentinfo.getContentId());
49: }
50:
51: public void testValidation() {
52: DatabaseContentInfo contentinfo = new DatabaseContentInfo();
53:
54: contentinfo.resetValidation();
55: assertFalse(contentinfo.validate());
56: assertFalse(contentinfo.isSubjectValid("contentId"));
57: assertFalse(contentinfo.isSubjectValid("path"));
58: assertFalse(contentinfo.isSubjectValid("mimeType"));
59: assertFalse(contentinfo.isSubjectValid("version"));
60: assertFalse(contentinfo.isSubjectValid("created"));
61:
62: contentinfo.resetValidation();
63: contentinfo.setPath("/some/other/path");
64: contentinfo.setMimeType(MimeType.APPLICATION_XHTML.toString());
65: contentinfo.setVersion(5);
66: contentinfo
67: .setCreated(new Timestamp(System.currentTimeMillis()));
68:
69: contentinfo.resetValidation();
70: contentinfo.setContentId(87);
71: assertTrue(contentinfo.validate());
72: assertTrue(contentinfo.isSubjectValid("contentId"));
73:
74: contentinfo.resetValidation();
75: assertTrue(contentinfo.validate());
76: assertTrue(contentinfo.isSubjectValid("contentId"));
77: assertTrue(contentinfo.isSubjectValid("path"));
78: assertTrue(contentinfo.isSubjectValid("mimeType"));
79: assertTrue(contentinfo.isSubjectValid("version"));
80: assertTrue(contentinfo.isSubjectValid("created"));
81: }
82: }
|