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.injection;
17:
18: import java.util.Properties;
19:
20: import javax.naming.Context;
21: import javax.naming.InitialContext;
22:
23: import junit.framework.TestCase;
24:
25: /**
26: * @version $Rev: 601953 $ $Date: 2007-12-06 17:09:47 -0800 $
27: */
28: public class PurchaseOrderBeanTest extends TestCase {
29:
30: private InitialContext initialContext;
31:
32: protected void setUp() throws Exception {
33: Properties properties = new Properties();
34: properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
35: "org.apache.openejb.client.LocalInitialContextFactory");
36:
37: initialContext = new InitialContext(properties);
38: }
39:
40: public void testAddLineItem() throws Exception {
41: PurchaseOrder order = (PurchaseOrder) initialContext
42: .lookup("PurchaseOrderBeanRemote");
43: assertNotNull(order);
44: LineItem item = new LineItem("ABC-1", "Test Item");
45:
46: try {
47: order.addLineItem(item);
48: } catch (TooManyItemsException tmie) {
49: fail("Test failed due to: " + tmie.getMessage());
50: }
51: }
52:
53: public void testGetMaxLineItems() throws Exception {
54: PurchaseOrder order = (PurchaseOrder) initialContext
55: .lookup("PurchaseOrderBeanRemote");
56: assertNotNull(order);
57:
58: int maxLineItems = order.getMaxLineItems();
59:
60: assertEquals(10, maxLineItems);
61: }
62: }
|