Want more features on Pastebin? Sign Up, it's FREE!
Guest

WebLogicDeployWarTest

By: vineet-reynolds on Oct 22nd, 2011  |  syntax: Java  |  size: 2.78 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * JBoss, Home of Professional Open Source
  3.  * Copyright 2011, Red Hat Middleware LLC, and individual contributors
  4.  * by the @authors tag. See the copyright.txt in the distribution for a
  5.  * full listing of individual contributors.
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  * http://www.apache.org/licenses/LICENSE-2.0
  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.  
  18. /**
  19.  *
  20.  * @author <a href="http://community.jboss.org/people/LightGuard">Jason Porter</a>
  21.  */
  22. package org.jboss.arquillian.container.wls.remote_103x;
  23.  
  24. import static org.hamcrest.core.IsEqual.equalTo;
  25. import static org.junit.Assert.assertThat;
  26.  
  27. import java.io.BufferedReader;
  28. import java.io.InputStreamReader;
  29. import java.net.URL;
  30. import java.net.URLConnection;
  31. import java.util.logging.Logger;
  32.  
  33. import org.jboss.arquillian.container.test.api.Deployment;
  34. import org.jboss.arquillian.junit.Arquillian;
  35. import org.jboss.arquillian.test.api.ArquillianResource;
  36. import org.jboss.shrinkwrap.api.ShrinkWrap;
  37. import org.jboss.shrinkwrap.api.asset.EmptyAsset;
  38. import org.jboss.shrinkwrap.api.spec.WebArchive;
  39. import org.junit.Test;
  40. import org.junit.runner.RunWith;
  41.  
  42. /**
  43.  * Verifies arquillian tests can run in container mode with a WebLogic container.
  44.  *
  45.  * @author <a href="http://community.jboss.org/people/aslak">Aslak Knutsen</a>
  46.  * @author <a href="http://community.jboss.org/people/LightGuard">Jason Porter</a>
  47.  * @author <a href="http://community.jboss.org/people/dan.j.allen">Dan Allen</a>
  48.  */
  49. @RunWith(Arquillian.class)
  50. public class WebLogicDeployWarTest {
  51.     private static final Logger log = Logger.getLogger(WebLogicDeployWarTest.class.getName());
  52.  
  53.     @Deployment
  54.     public static WebArchive getTestArchive() {
  55.         final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
  56.                 .addClasses(GreeterServlet.class, Greeter.class)
  57.                 .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
  58.         log.info(war.toString(true));
  59.         return war;
  60.     }
  61.  
  62.     @Test
  63.     public void assertWarDeployed(@ArquillianResource URL contextRoot) throws Exception {
  64.         final URLConnection response = new URL(contextRoot, "Test").openConnection();
  65.  
  66.         BufferedReader in = new BufferedReader(new InputStreamReader(response.getInputStream()));
  67.         final String result = in.readLine();
  68.  
  69.         assertThat(result, equalTo("Hello"));
  70.     }
  71.  
  72. }
clone this paste RAW Paste Data