KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > jcr > api > namespaces > PrefixesTicketTest


1 /*
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  */

5
6 package org.exoplatform.services.jcr.api.namespaces;
7
8
9 import javax.jcr.NamespaceRegistry;
10 import javax.jcr.NamespaceException;
11
12 import org.apache.commons.lang.ArrayUtils;
13 import org.exoplatform.services.jcr.BaseTest;
14
15 /**
16  * Created y the eXo platform team
17  * User: Benjamin Mestrallet
18  * Date: 14 ao�t 2004
19  */

20 public class PrefixesTicketTest extends BaseTest {
21
22   private NamespaceRegistry namespaceRegistry;
23
24   public void init() throws Exception JavaDoc {
25     workspace = ticket.getWorkspace();
26     namespaceRegistry = workspace.getNamespaceRegistry();
27   }
28
29   public void testSetPrefix() throws NamespaceException {
30     try {
31       ticket.setPrefix("exo2", "http://dummy.com");
32       fail("exception should have been thrown");
33     } catch (NamespaceException e) {
34     }
35
36     ticket.setPrefix("exo2", "http://www.exoplatform.com/jcr/exo/1.0");
37     assertEquals("http://www.exoplatform.com/jcr/exo/1.0", ticket.getURI("exo2"));
38     assertNull(ticket.getURI("exo"));
39
40     assertEquals("http://www.jcp.org/jcr/1.0", ticket.getURI("jcr"));
41   }
42
43   public void testGetPrefixes() throws NamespaceException {
44     String JavaDoc[] protectedNamespaces = {"jcr", "nt", "mix","pt", "sv", "exo2"};
45     ticket.setPrefix("exo2", "http://www.exoplatform.com/jcr/exo/1.0");
46     String JavaDoc[] prefixes = ticket.getPrefixes();
47     assertEquals(prefixes.length, protectedNamespaces.length);
48     for (int i = 0; i < prefixes.length; i++) {
49       String JavaDoc prefix = prefixes[i];
50       assertTrue(ArrayUtils.contains(protectedNamespaces, prefix));
51     }
52   }
53
54   public void testGetURI() throws NamespaceException {
55     ticket.setPrefix("exo2", "http://www.exoplatform.com/jcr/exo/1.0");
56     assertEquals("http://www.exoplatform.com/jcr/exo/1.0", ticket.getURI("exo2"));
57     assertNull(ticket.getURI("exo"));
58     assertEquals("http://www.jcp.org/jcr/1.0", ticket.getURI("jcr"));
59   }
60
61
62 }
63
Popular Tags