JAVA   43
RestaurantTest java
Guest on 14th August 2022 06:30:58 AM


  1. /**
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *     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.  */
  17. package org.superbiz.cdi.applicationscope;
  18.  
  19. import org.junit.After;
  20. import org.junit.Before;
  21. import org.junit.Test;
  22.  
  23. import javax.ejb.EJB;
  24. import javax.ejb.embeddable.EJBContainer;
  25.  
  26. import static org.junit.Assert.assertEquals;
  27.  
  28. public class RestaurantTest {
  29.  
  30.     private static String TOMATO_SOUP = "Tomato Soup";
  31.     private EJBContainer container;
  32.  
  33.     @EJB
  34.     private Waiter joe;
  35.  
  36.     @Before
  37.     public void startContainer() throws Exception {
  38.         container = EJBContainer.createEJBContainer();
  39.         container.getContext().bind("inject", this);
  40.     }
  41.  
  42.     @Test
  43.     public void orderSoup() {
  44.         String someSoup = joe.orderSoup(TOMATO_SOUP);
  45.         assertEquals(TOMATO_SOUP, someSoup);
  46.  
  47.         String sameSoup = joe.orderWhatTheOtherGuyHad();
  48.         assertEquals(TOMATO_SOUP, sameSoup);
  49.     }
  50.  
  51.     @After
  52.     public void closeContainer() throws Exception {
  53.         container.close();
  54.     }
  55. }

Raw Paste

Login or Register to edit or fork this paste. It's free.