Clover Coverage Report - ARESTC 0.1.7-SNAPSHOT
Coverage timestamp: Fri Aug 27 2010 19:12:04 CEST
53   204   10   5.3
0   86   0.19   10
10     1  
1    
 
  StandardConnectorRequestTest       Line # 35 53 0% 10 0 100% 1.0
 
  (8)
 
1    /*
2    *
3    * (C)opyright 2010, Nikolaos Georgosopoulos
4    *
5    * This file is part of ARESTC.
6   
7    ARESTC is free software: you can redistribute it and/or modify
8    it under the terms of the Lesser General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11   
12    ARESTC is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15    GNU General Public License for more details.
16   
17    You should have received a copy of the Lesser General Public License
18    along with ARESTC. If not, see <http://www.gnu.org/licenses/>.
19   
20    */
21    package net.sf.arestc.core;
22   
23    import java.util.HashMap;
24    import java.util.Map;
25   
26   
27    import junit.framework.TestCase;
28   
29    // TODO: Auto-generated Javadoc
30    /**
31    * The Class StandardConnectorRequestTest.
32    *
33    * @author georgosn
34    */
 
35    public class StandardConnectorRequestTest extends TestCase {
36   
37    /** The request. */
38    private StandardConnectorRequest request;
39   
40    /** The my params. */
41    private Map<String, Object> myParams;
42   
43    /*
44    * (non-Javadoc)
45    *
46    * @see junit.framework.TestCase#setUp()
47    */
 
48  8 toggle @Override
49    protected void setUp() throws Exception {
50  8 super.setUp();
51  8 myParams = new HashMap<String, Object>();
52  8 myParams.put("store_type", "avm");
53  8 myParams.put("store_id", "1");
54  8 myParams.put("id", "1");
55  8 request = new StandardConnectorRequest("One", myParams);
56    }
57   
58    /*
59    * (non-Javadoc)
60    *
61    * @see junit.framework.TestCase#tearDown()
62    */
 
63  8 toggle @Override
64    protected void tearDown() throws Exception {
65  8 myParams = null;
66  8 request = null;
67  8 super.tearDown();
68    }
69   
70    /**
71    * Test method for.
72    *
73    * {@link net.sf.arestc.core.StandardConnectorRequest#equals(java.lang.Object)}
74    * .
75    */
 
76  1 toggle public void testEqualsObject() {
77    // check default request with itself
78  1 assertEquals(request, request);
79    // check default request with null, must be false
80  1 assertFalse(request.equals(null));
81    // check default request with other type of object, must be false
82  1 assertFalse(request.equals(myParams));
83    // check default request with an other identical request for an other
84    // service
85  1 final ConnectorRequest otheRequest = new StandardConnectorRequest(
86    "unknown", myParams);
87  1 assertFalse(request.equals(otheRequest));
88   
89    // check default request with a complitely different request
90  1 final Map<String, Object> altParams = new HashMap<String, Object>();
91  1 altParams.put("store_type", "dm");
92  1 altParams.put("store_id", "2");
93  1 altParams.put("id", "2");
94  1 ConnectorRequest altRequest = new StandardConnectorRequest("two",
95    altParams);
96  1 assertFalse(request.equals(altRequest));
97    // check the altRequest with the same params and same service, must be
98    // equal
99  1 altRequest = new StandardConnectorRequest("One", myParams);
100  1 assertTrue(request.equals(altRequest));
101    // check the altRequest with different params and same service, must be
102    // different
103  1 altRequest = new StandardConnectorRequest("One", altParams);
104  1 assertFalse(request.equals(altRequest));
105    // check the altRequest with same params and different service, must be
106    // different
107  1 altRequest = new StandardConnectorRequest("two", myParams);
108  1 assertFalse(request.equals(altRequest));
109   
110    }
111   
112    /**
113    * Test method for.
114    *
115    * {@link net.sf.arestc.core.StandardConnectorRequest#getEndLink()}.
116    */
 
117  1 toggle public void testGetEndLink() {
118  1 final ConnectorCommand command = new BaseCommand();
119  1 request.setEndLink(command);
120  1 assertEquals(command, request.getEndLink());
121    }
122   
123    /**
124    * Test get end transformer.
125    */
 
126  1 toggle public void testGetEndTransformer() {
127  1 final ConnectorCommand command = new BaseCommand();
128  1 request.setEndTransformer(command);
129  1 assertEquals(command, request.getEndTransformer());
130    }
131   
132    /**
133    * Test method for.
134    *
135    * {@link net.sf.arestc.core.StandardConnectorRequest#getParameters()}.
136    */
 
137  1 toggle public void testGetParameters() {
138  1 assertEquals(myParams, request.getParameters());
139    }
140   
141    /**
142    * Test method for.
143    *
144    * {@link net.sf.arestc.core.StandardConnectorRequest#getServiceName()}.
145    */
 
146  1 toggle public void testGetService() {
147  1 assertEquals("One", request.getServiceName());
148    }
149   
150    /**
151    * Test method for.
152    *
153    * {@link net.sf.arestc.core.StandardConnectorRequest#getStartLink()}.
154    */
 
155  1 toggle public void testGetStartLink() {
156  1 final ConnectorCommand command = new BaseCommand();
157  1 request.setStartLink(command);
158  1 assertEquals(command, request.getStartLink());
159    }
160   
161    /**
162    * Test method for.
163    *
164    * {@link net.sf.arestc.core.StandardConnectorRequest#getStartTransformer()}
165    * .
166    */
 
167  1 toggle public void testGetStartTransformer() {
168  1 final ConnectorCommand command = new BaseCommand();
169  1 request.setStartTransformer(command);
170  1 assertEquals(command, request.getStartTransformer());
171    }
172   
173    /**
174    * Test method for.
175    *
176    * {@link net.sf.arestc.core.StandardConnectorRequest#hashCode()}.
177    */
 
178  1 toggle public void testHashCode() {
179    // check the default request with itself, must have the same hashcode
180  1 assertTrue(request.hashCode() == request.hashCode());
181    // create a new request and compare the hash code with the default, must
182    // be different
183  1 final Map<String, Object> altParams = new HashMap<String, Object>();
184  1 altParams.put("store_type", "dm");
185  1 altParams.put("store_id", "2");
186  1 altParams.put("id", "2");
187  1 ConnectorRequest altRequest = new StandardConnectorRequest("two",
188    altParams);
189  1 assertFalse(request.hashCode() == altRequest.hashCode());
190    // check the altRequest with the same params and same service, must be
191    // equal
192  1 altRequest = new StandardConnectorRequest("One", myParams);
193  1 assertTrue(request.hashCode() == altRequest.hashCode());
194    // check the altRequest with different params and same service, must be
195    // different
196  1 altRequest = new StandardConnectorRequest("One", altParams);
197  1 assertFalse(request.hashCode() == altRequest.hashCode());
198    // check the altRequest with same params and different service, must be
199    // different
200  1 altRequest = new StandardConnectorRequest("two", myParams);
201  1 assertFalse(request.hashCode() == altRequest.hashCode());
202    }
203   
204    }