01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.superbiz.enventries;
17:
18: import static java.util.Arrays.asList;
19:
20: import junit.framework.TestCase;
21:
22: import javax.naming.InitialContext;
23: import javax.naming.Context;
24:
25: import java.util.Locale;
26: import java.util.Properties;
27: import java.util.Date;
28: import java.util.LinkedList;
29: import java.util.List;
30: import java.util.Map;
31: import java.util.LinkedHashMap;
32: import java.util.HashMap;
33: import java.util.ArrayList;
34: import java.util.Collections;
35: import java.util.Arrays;
36: import java.io.File;
37: import java.net.URI;
38: import java.net.URL;
39: import java.net.InetAddress;
40: import java.text.DateFormat;
41:
42: /**
43: * @version $Rev: 636457 $ $Date: 2008-03-12 12:08:26 -0700 $
44: */
45: //START SNIPPET: code
46: public class StratocasterTest extends TestCase {
47:
48: private InitialContext initialContext;
49:
50: protected void setUp() throws Exception {
51: Properties properties = new Properties();
52: properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
53: "org.apache.openejb.client.LocalInitialContextFactory");
54:
55: initialContext = new InitialContext(properties);
56: }
57:
58: public void test() throws Exception {
59: Stratocaster strat = (Stratocaster) initialContext
60: .lookup("StratocasterImplLocal");
61:
62: Date date = DateFormat.getDateInstance(DateFormat.MEDIUM,
63: Locale.US).parse("Mar 1, 1962");
64: assertEquals("Strat.getDateCreated()", date, strat
65: .getDateCreated());
66:
67: List<Pickup> pickups = asList(Pickup.SINGLE_COIL,
68: Pickup.SINGLE_COIL, Pickup.SINGLE_COIL);
69: assertEquals("Strat.getPickups()", pickups, strat.getPickups());
70:
71: assertEquals("Strat.getStyle()", Style.VINTAGE, strat
72: .getStyle());
73:
74: assertEquals("Strat.getStringGuage(\"E1\")", 0.052F, strat
75: .getStringGuage("E1"));
76: assertEquals("Strat.getStringGuage(\"A\")", 0.042F, strat
77: .getStringGuage("A"));
78: assertEquals("Strat.getStringGuage(\"D\")", 0.030F, strat
79: .getStringGuage("D"));
80: assertEquals("Strat.getStringGuage(\"G\")", 0.017F, strat
81: .getStringGuage("G"));
82: assertEquals("Strat.getStringGuage(\"B\")", 0.013F, strat
83: .getStringGuage("B"));
84: assertEquals("Strat.getStringGuage(\"E\")", 0.010F, strat
85: .getStringGuage("E"));
86:
87: File file = new File("/tmp/strat-certificate.txt");
88: assertEquals("Strat.getCertificateOfAuthenticity()", file,
89: strat.getCertificateOfAuthenticity());
90:
91: }
92: }
93: //END SNIPPET: code
|