01: package org.drools.brms.client.packages;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import junit.framework.TestCase;
20:
21: import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
22:
23: import com.google.gwt.user.client.Command;
24:
25: public class SuggestionCompletionCacheTest extends TestCase {
26:
27: private boolean executed;
28: private boolean loaded;
29:
30: protected void setUp() throws Exception {
31: super .setUp();
32: executed = false;
33: loaded = false;
34: }
35:
36: public void testCache() {
37: SuggestionCompletionCache cache1 = SuggestionCompletionCache
38: .getInstance();
39: assertSame(cache1, SuggestionCompletionCache.getInstance());
40:
41: final SuggestionCompletionCache cache = new SuggestionCompletionCache() {
42:
43: void loadPackage(String packageName, Command command) {
44: loaded = true;
45:
46: }
47: };
48:
49: cache.doAction("xyz", new Command() {
50: public void execute() {
51: }
52: });
53: assertTrue(loaded);
54: SuggestionCompletionEngine eng = new SuggestionCompletionEngine();
55: cache.cache.put("foo", eng);
56:
57: cache.doAction("foo", new Command() {
58:
59: public void execute() {
60: executed = true;
61: }
62:
63: });
64:
65: assertTrue(executed);
66:
67: assertNotNull(cache.getEngineFromCache("foo"));
68:
69: cache.refreshPackage("foo", new Command() {
70:
71: public void execute() {
72:
73: }
74:
75: });
76:
77: }
78:
79: }
|