KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > adl > conform > TestArguments


1 /***
2  * Fractal ADL Parser
3  * Copyright (C) 2002-2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.adl.conform;
25
26 import java.util.Map JavaDoc;
27 import java.util.HashMap JavaDoc;
28
29 import org.objectweb.fractal.adl.ADLException;
30 import org.objectweb.fractal.adl.Definition;
31 import org.objectweb.fractal.adl.Loader;
32 import org.objectweb.fractal.adl.arguments.ArgumentLoader;
33 import org.objectweb.fractal.adl.arguments.ArgumentComponentLoader;
34 import org.objectweb.fractal.adl.attributes.AttributeLoader;
35 import org.objectweb.fractal.adl.bindings.TypeBindingLoader;
36 import org.objectweb.fractal.adl.implementations.ImplementationLoader;
37 import org.objectweb.fractal.adl.interfaces.InterfaceLoader;
38 import org.objectweb.fractal.adl.types.TypeLoader;
39 import org.objectweb.fractal.adl.xml.XMLLoader;
40
41 public class TestArguments extends Test {
42   
43   public Loader l;
44   
45   public Map JavaDoc context;
46   
47   public TestArguments (final String JavaDoc name) {
48     super(name);
49   }
50   
51   protected void setUp () {
52     context = new HashMap JavaDoc();
53     
54     ArgumentLoader pv = new ArgumentLoader();
55     InterfaceLoader iv = new InterfaceLoader();
56     TypeLoader tv = new TypeLoader();
57     ImplementationLoader impv = new ImplementationLoader();
58     AttributeLoader attrv1 = new AttributeLoader();
59     ArgumentComponentLoader compv = new ArgumentComponentLoader();
60     TypeBindingLoader bindv = new TypeBindingLoader();
61     AttributeLoader attrv2 = new AttributeLoader();
62     
63     pv.clientLoader = new XMLLoader(false);
64     iv.clientLoader = pv;
65     tv.clientLoader = iv;
66     impv.clientLoader = tv;
67     attrv1.clientLoader = impv;
68     compv.clientLoader = attrv1;
69     bindv.clientLoader = compv;
70     attrv2.clientLoader = bindv;
71     l = attrv2;
72   }
73   
74   public void test1 () throws ADLException {
75     context.put("p", "org.objectweb.fractal.adl.conform.components.IImpl");
76     Definition d1 = l.load("ARG1", context);
77     Definition d2 = l.load("ARG2", null);
78     compare(d1, d2);
79   }
80   
81   public void test2 () {
82     try {
83       l.load("ARG1", context);
84       fail();
85     } catch (ADLException e) {
86     }
87   }
88   
89   public void test3 () throws ADLException {
90     context.put("p", "org.objectweb.fractal.adl.conform.components.IImpl");
91     context.put("q", "ARG1");
92     context.put("r", "primitive");
93     Definition d1 = l.load("ARG3", context);
94     Definition d2 = l.load("ARG4", null);
95     compare(d1, d2);
96   }
97   
98   public void test4 () throws ADLException {
99     context.put("p", "org.objectweb.fractal.adl.conform.components.IImpl");
100     context.put("q", "org.objectweb.fractal.adl.conform.components.IImpl");
101     Definition d1 = l.load("ARG5", context);
102     Definition d2 = l.load("ARG6", null);
103     compare(d1, d2);
104   }
105   
106   public void test5 () throws ADLException {
107     context.put("u1", "org.objectweb.fractal.adl.conform.components.IImpl");
108     context.put("v1", "org.objectweb.fractal.adl.conform.components.IImpl");
109     context.put("u2", "org.objectweb.fractal.adl.conform.components.IImpl");
110     context.put("v2", "org.objectweb.fractal.adl.conform.components.IImpl");
111     Definition d1 = l.load("ARG7", context);
112     Definition d2 = l.load("ARG8", null);
113     compare(d1, d2);
114   }
115   
116   public void test6 () {
117     try {
118       context.put("u", "org.objectweb.fractal.adl.conform.components.IImpl");
119       l.load("ARG9", context);
120       fail();
121     } catch (ADLException e) {
122     }
123   }
124   
125   public void test7 () {
126     try {
127       context.put("u", "org.objectweb.fractal.adl.conform.components.IImpl");
128       l.load("ARG10", context);
129       fail();
130     } catch (ADLException e) {
131     }
132   }
133 }
134
Popular Tags