Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
DataSqueezerUtil |
|
| 1.0;1 |
1 | // Copyright 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry.util.io; |
|
16 | ||
17 | import org.apache.hivemind.ClassResolver; |
|
18 | import org.apache.hivemind.impl.DefaultClassResolver; |
|
19 | ||
20 | /** |
|
21 | * Utility methods used when testing code that uses a |
|
22 | * {@link org.apache.tapestry.services.DataSqueezer}. |
|
23 | * |
|
24 | * @author Howard Lewis Ship |
|
25 | * @since 4.0 |
|
26 | */ |
|
27 | public final class DataSqueezerUtil |
|
28 | { |
|
29 | /* defeat instantiation */ |
|
30 | 0 | private DataSqueezerUtil() { } |
31 | ||
32 | /** |
|
33 | * Returns a data squeezer with a set of basic adaptors, ready to be used by JUnit-tests. |
|
34 | */ |
|
35 | public static DataSqueezerImpl createUnitTestSqueezer(ClassResolver resolver) |
|
36 | { |
|
37 | 7 | DataSqueezerImpl ds = new DataSqueezerImpl(); |
38 | ||
39 | 7 | ds.register(new BooleanAdaptor()); |
40 | 7 | ds.register(new ByteAdaptor()); |
41 | 7 | ds.register(new CharacterAdaptor()); |
42 | 7 | ds.register(new ComponentAddressAdaptor()); |
43 | 7 | ds.register(new DoubleAdaptor()); |
44 | 7 | ds.register(new FloatAdaptor()); |
45 | 7 | ds.register(new IntegerAdaptor()); |
46 | 7 | ds.register(new LongAdaptor()); |
47 | 7 | ds.register(new ShortAdaptor()); |
48 | 7 | ds.register(new StringAdaptor()); |
49 | ||
50 | 7 | SerializableAdaptor ser = new SerializableAdaptor(); |
51 | 7 | ser.setResolver(resolver); |
52 | ||
53 | 7 | ds.register(ser); |
54 | ||
55 | 7 | return ds; |
56 | } |
|
57 | ||
58 | /** |
|
59 | * Returns a data squeezer with a set of basic adaptors, ready to be used by JUnit-tests. |
|
60 | */ |
|
61 | ||
62 | public static DataSqueezerImpl createUnitTestSqueezer() |
|
63 | { |
|
64 | 7 | return createUnitTestSqueezer(new DefaultClassResolver()); |
65 | } |
|
66 | ||
67 | } |