本文整理汇总了Java中org.jboss.arquillian.container.test.api.OperateOnDeployment类的典型用法代码示例。如果您正苦于以下问题:Java OperateOnDeployment类的具体用法?Java OperateOnDeployment怎么用?Java OperateOnDeployment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OperateOnDeployment类属于org.jboss.arquillian.container.test.api包,在下文中一共展示了OperateOnDeployment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTestMethod
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
public void startTestMethod(@Observes(precedence = Integer.MAX_VALUE) Before event) {
Method testMethod = event.getTestMethod();
boolean runAsClient = event.getTestMethod().isAnnotationPresent(RunAsClient.class);
String deploymentName = "_DEFAULT_";
if (event.getTestMethod().isAnnotationPresent(OperateOnDeployment.class)) {
deploymentName = event.getTestMethod().getAnnotation(OperateOnDeployment.class).value();
}
Reporter
.createReport(new TestMethodReport(testMethod.getName()))
.addKeyValueEntry(TEST_METHOD_OPERATES_ON_DEPLOYMENT, deploymentName)
.addKeyValueEntry(TEST_METHOD_RUNS_AS_CLIENT, runAsClient)
.inSection(new TestMethodSection(testMethod))
.fire(sectionEvent);
}
示例2: testSessionRemoveAttributes
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@RunAsClient
@Test
@OperateOnDeployment("session-operations")
public void testSessionRemoveAttributes(@ArquillianResource URL baseURL) throws IOException {
URL url = url(baseURL, "TestServlet", "testSessionRemoveAttributes");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
assertThat(connection, matchLines("Previous value of attribute: null", "New value of attribute: B"));
url = url(baseURL, "RemoveAttributeServlet", "testSessionRemoveAttributes");
System.out.println("COOKIES:" + cookies);
connection = (HttpURLConnection) url.openConnection();
setSessionCookie(connection, cookies);
assertThat(connection, matchLines("Previous value of attribute: B", "New value of attribute: null"));
}
示例3: testSessionGetAttributes
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@RunAsClient
@Test
@OperateOnDeployment("session-operations")
public void testSessionGetAttributes(@ArquillianResource URL baseURL) throws IOException {
URL url = url(baseURL, "TestServlet", "testSessionGetAttributes");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
assertThat(connection, matchLines("Previous value of attribute: null", "New value of attribute: B"));
url = url(baseURL, "GetAllAttributes", "testSessionGetAttributes");
connection = (HttpURLConnection) url.openConnection();
setSessionCookie(connection, cookies);
assertThat(connection, matchLines("Attributes in session: [A]"));
url = url(baseURL, "AddAttributeServlet", "testSessionGetAttributes");
connection = (HttpURLConnection) url.openConnection();
setSessionCookie(connection, cookies);
assertThat(connection, matchLines("Previous value of attribute B: null", "New value of attribute B: D"));
url = url(baseURL, "GetAllAttributes", "testSessionGetAttributes");
connection = (HttpURLConnection) url.openConnection();
setSessionCookie(connection, cookies);
assertThat(connection, matchLines("Attributes in session: [A, B]"));
}
示例4: testDefaultSessionDoesNotExpireIn2Seconds
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@RunAsClient
@Test
@OperateOnDeployment("no-settings")
public void testDefaultSessionDoesNotExpireIn2Seconds(@ArquillianResource URL baseURL) throws IOException, InterruptedException {
URL urlTest = url(baseURL, "TestServlet", "testDefaultSessionDoesNotExpireIn2Seconds");
String originalCookie = callWebapp(urlTest);
await(1000);
HttpURLConnection connection = (HttpURLConnection) urlTest.openConnection();
setSessionCookie(connection, originalCookie);
connection.connect();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
assertFirstLineEquals(connection, "Previous value of attribute: B");
assertThat(cookies, hasItem(originalCookie));
await(2100);
connection = (HttpURLConnection) urlTest.openConnection();
setSessionCookie(connection, originalCookie);
connection.connect();
cookies = connection.getHeaderFields().get("Set-Cookie");
assertFirstLineEquals(connection, "Previous value of attribute: B");
assertThat(cookies, hasItem(originalCookie));
}
示例5: testWhenSessionNeverExpires
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@RunAsClient
@Test
@OperateOnDeployment("never-expires")
public void testWhenSessionNeverExpires(@ArquillianResource URL baseURL) throws IOException, InterruptedException {
URL urlTest = url(baseURL, "TestServlet", "testWhenSessionNeverExpires");
String originalCookie = callWebapp(urlTest);
await(1000);
HttpURLConnection connection = (HttpURLConnection) urlTest.openConnection();
setSessionCookie(connection, originalCookie);
connection.connect();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
assertFirstLineEquals(connection, "Previous value of attribute: B");
assertThat(cookies, hasItem(originalCookie));
await(2100);
connection = (HttpURLConnection) urlTest.openConnection();
setSessionCookie(connection, originalCookie);
connection.connect();
cookies = connection.getHeaderFields().get("Set-Cookie");
assertFirstLineEquals(connection, "Previous value of attribute: B");
assertThat(cookies, hasItem(originalCookie));
}
示例6: testSessionIdIsUuid
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@RunAsClient
@Test
@OperateOnDeployment("uuid")
public void testSessionIdIsUuid(@ArquillianResource URL baseURL) throws IOException {
URL urlTest = url(baseURL, "TestServlet", "testSessionIdIsUuid");
String originalCookie = callWebapp(urlTest);
String justCookie = originalCookie.split(";", 2)[0];
assertThat(justCookie, containsString("-"));
assertThat(justCookie, startsWith("JSESSIONID="));
try {
UUID.fromString(justCookie.substring("JSESSIONID=".length()));
} catch (Exception e) {
fail("Invalid format of UUID " + justCookie);
}
HttpURLConnection connection = (HttpURLConnection)urlTest.openConnection();
setSessionCookie(connection, originalCookie);
assertFirstLineEquals(connection, "Previous value of attribute: B");
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
assertThat(cookies, hasItem(originalCookie));
}
示例7: testSessionNotPropagatedToOtherWebapp
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@RunAsClient
@Test
@OperateOnDeployment(FIRST_WEBAPP)
public void testSessionNotPropagatedToOtherWebapp(@ArquillianResource @OperateOnDeployment(FIRST_WEBAPP) URL firstURL,
@ArquillianResource @OperateOnDeployment(SECOND_WEBAPP) URL secondURL) throws IOException {
URL urlTestFirst = url(firstURL, "TestServlet", "testSessionNotPropagatedToOtherWebapp");
URL urlTestSecond = url(secondURL, "SecondServlet", "testSessionNotPropagatedToOtherWebapp");
String originalCookie = callWebapp(urlTestFirst);
System.out.println("First app cookies: " + originalCookie);
String secondCookie = callSecondWebApp(urlTestSecond, originalCookie);
// Call again first webapp with cookie from first webapp, it works
HttpURLConnection connection = (HttpURLConnection) urlTestFirst.openConnection();
setSessionCookie(connection, originalCookie);
connection.connect();
assertFirstLineEquals(connection, "Previous value of attribute: B");
// Call again first webapp with cookie from second webapp, it creates new
// session
connection = (HttpURLConnection) urlTestFirst.openConnection();
setSessionCookie(connection, secondCookie);
connection.connect();
String newCookie = connection.getHeaderFields().get("Set-Cookie").get(0);
Assert.assertFalse(originalCookie.equals(newCookie));
assertFirstLineEquals(connection, "Previous value of attribute: null");
}
示例8: testEJBClient
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@Test
@RunAsClient
@OperateOnDeployment("jaxws-samples-serviceref")
public void testEJBClient() throws Exception
{
InitialContext iniCtx = null;
try
{
iniCtx = getServerInitialContext();
EJBRemote ejbRemote = (EJBRemote)iniCtx.lookup("jaxws-samples-serviceref-ejbclient//EJBClient!" + EJBRemote.class.getName());
String helloWorld = "Hello World!";
Object retObj = ejbRemote.echo(helloWorld);
assertEquals(helloWorld, retObj);
}
finally
{
if (iniCtx != null)
{
iniCtx.close();
}
}
}
示例9: test
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@Test
@RunAsClient
@OperateOnDeployment(DEP)
public void test() throws Exception
{
URL wsdlURL = new URL(baseURL + "/JBWS3792WSService?wsdl");
QName qname = new QName("http://test.jbws3792/", "JBWS3792WSService");
Service service = Service.create(wsdlURL, qname);
Iterator<QName> it = service.getPorts();
int cnt = 0;
while (it.hasNext()) {
cnt++;
QName qn = (QName)it.next();
assertTrue("qname: " + qn.toString(), "{http://test.jbws3792/}JBWS3792WSPort".equals(qn.toString()));
}
assertTrue("Expected cnt to be 1 but cnt is " + cnt, cnt == 1);
}
示例10: iocInCacheTest
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 11)
@OperateOnDeployment("ear")
@RunAsClient
public void iocInCacheTest(@ArquillianResource URL context) throws Exception {
WebClient webClient = new WebClient();
WebRequest requestSettings = new WebRequest(new URL(context + "rest/blacklist/record/phishing.ru"), HttpMethod.GET);
requestSettings.setAdditionalHeader("Content-Type", "application/json");
requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
Page page = webClient.getPage(requestSettings);
assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
String responseBody = page.getWebResponse().getContentAsString();
LOGGER.info("iocInCacheTest Response:" + responseBody);
String expected = "\"black_listed_domain_or_i_p\":\"926dab5157943daed27851a34f30b701\""; // md5 of phishing.ru
assertTrue(responseBody.contains(expected), "IoC response should have contained " + expected + ", but got:" + responseBody);
expected = "\"sources\":{\"integrationTest\":{\"a\":\"phishing\",\"b\":\"";
assertTrue(responseBody.contains(expected), "IoC should have contained " + expected + ", but got: " + responseBody);
}
示例11: cleanElasticTest
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
/**
* Not test exactly, just cleaning old data in elastic DNS event logs
*
* @param context
* @throws Exception
*/
@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 17)
@OperateOnDeployment("ear")
@RunAsClient
public void cleanElasticTest(@ArquillianResource URL context) throws Exception {
String index = IoCFactory.getLogIndex();
WebClient webClient = new WebClient();
WebRequest requestSettings = new WebRequest(
new URL("http://" + System.getenv("SINKIT_ELASTIC_HOST") + ":" + System.getenv("SINKIT_ELASTIC_PORT") +
"/" + index + "/"), HttpMethod.DELETE);
Page page;
try {
page = webClient.getPage(requestSettings);
assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
} catch (FailingHttpStatusCodeException ex) {
//NO-OP index does not exist yet, but it's ok
}
}
示例12: shouldFindTimerTicks
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@Test
@OperateOnDeployment("FunctionalIT-shouldFindTimerTicks")
public void shouldFindTimerTicks(@ArquillianResource @OperateOnDeployment("FunctionalIT-shouldFindTimerTicks")
URL deployment)
throws InterruptedException {
LOG.info(deployment.toExternalForm());
MILLISECONDS.sleep(1500);
Collection<MyEntity> results =
em.createQuery("select e from MyEntity e", MyEntity.class)
.getResultList();
assertThat(results, hasSize(greaterThan(0)));
}
示例13: cleanElasticTest
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
/**
* Not test exactly, just cleaning old data in elastic
*
* @param context
* @throws Exception
*/
@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 8)
@OperateOnDeployment("ear")
@RunAsClient
public void cleanElasticTest(@ArquillianResource URL context) throws Exception {
WebClient webClient = new WebClient();
WebRequest requestSettings = new WebRequest(
new URL("http://" + System.getenv("SINKIT_ELASTIC_HOST") + ":" + System.getenv("SINKIT_ELASTIC_PORT") +
"/" + ArchiveServiceEJB.ELASTIC_IOC_INDEX + "/"), HttpMethod.DELETE);
Page page;
try {
page = webClient.getPage(requestSettings);
assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
} catch (FailingHttpStatusCodeException ex) {
//NO-OP index does not exist yet, but it's ok
}
}
示例14: testWSDLAccess
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
@Test
@RunAsClient
@OperateOnDeployment(DEP)
public void testWSDLAccess() throws Exception
{
URL wsdlURL = new URL(baseURL + "/jaxws-cxf-jaxbintros/EndpointService?wsdl");
Element wsdl = DOMUtils.parse(wsdlURL.openStream());
assertNotNull(wsdl);
Iterator<Element> it = DOMUtils.getChildElements(wsdl, new QName("http://www.w3.org/2001/XMLSchema","attribute"), true);
boolean attributeFound = false;
while (it.hasNext())
{
Element el = it.next();
if ("string".equals(el.getAttribute("name")))
{
attributeFound = true;
}
}
assertTrue("<xs:attribute name=\"string\" ..> not found in wsdl", attributeFound);
}
示例15: testNoClientCallback
import org.jboss.arquillian.container.test.api.OperateOnDeployment; //导入依赖的package包/类
/**
* No CallbackHandler is provided in STSCLient. Username and password provided instead.
*
* @throws Exception
*/
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testNoClientCallback() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
try {
BusFactory.setThreadDefaultBus(bus);
final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService");
final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port");
URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl");
WSTrustTestUtils.setupWsseAndSTSClientNoCallbackHandler(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);
assertEquals("WS-Trust Hello World!", proxy.sayHello());
} finally {
bus.shutdown(true);
}
}