|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
DataSqueezerUtil.java | - | 100% | 100% | 100% |
|
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 class DataSqueezerUtil | |
28 | { | |
29 | ||
30 | /** | |
31 | * Returns a data squeezer with a set of basic adaptors, ready to be used by JUnit-tests. | |
32 | */ | |
33 | 56 | public static DataSqueezerImpl createUnitTestSqueezer(ClassResolver resolver) |
34 | { | |
35 | 56 | DataSqueezerImpl ds = new DataSqueezerImpl(); |
36 | ||
37 | 56 | ds.register(new BooleanAdaptor()); |
38 | 56 | ds.register(new ByteAdaptor()); |
39 | 56 | ds.register(new CharacterAdaptor()); |
40 | 56 | ds.register(new ComponentAddressAdaptor()); |
41 | 56 | ds.register(new DoubleAdaptor()); |
42 | 56 | ds.register(new FloatAdaptor()); |
43 | 56 | ds.register(new IntegerAdaptor()); |
44 | 56 | ds.register(new LongAdaptor()); |
45 | 56 | ds.register(new ShortAdaptor()); |
46 | 56 | ds.register(new StringAdaptor()); |
47 | ||
48 | 56 | SerializableAdaptor ser = new SerializableAdaptor(); |
49 | 56 | ser.setResolver(resolver); |
50 | ||
51 | 56 | ds.register(ser); |
52 | ||
53 | 56 | return ds; |
54 | } | |
55 | ||
56 | /** | |
57 | * Returns a data squeezer with a set of basic adaptors, ready to be used by JUnit-tests. | |
58 | */ | |
59 | ||
60 | 56 | public static DataSqueezerImpl createUnitTestSqueezer() |
61 | { | |
62 | 56 | return createUnitTestSqueezer(new DefaultClassResolver()); |
63 | } | |
64 | ||
65 | } |
|