1
2
3
4
5
6
7 package com.atlassian.plugin;
8
9 import junit.framework.TestCase;
10
11 public class TestModuleCompleteKey extends TestCase
12 {
13 public void testWorkingKey()
14 {
15 ModuleCompleteKey key = new ModuleCompleteKey("foo:bar");
16 assertEquals("foo", key.getPluginKey());
17 assertEquals("bar", key.getModuleKey());
18 assertEquals("foo:bar", key.getCompleteKey());
19 }
20
21 public void testBadKey()
22 {
23 assertKeyFails("foo");
24 assertKeyFails("foo:");
25 assertKeyFails(":foo");
26 assertKeyFails("");
27 assertKeyFails(null);
28 }
29
30 private void assertKeyFails(String completeKey)
31 {
32 try
33 {
34 new ModuleCompleteKey(completeKey);
35 fail("Should have thrown IAE");
36 }
37 catch (IllegalArgumentException e)
38 {
39 return;
40 }
41 }
42 }