Search in sources :

Example 41 with RunAsClient

use of org.jboss.arquillian.container.test.api.RunAsClient in project wildfly by wildfly.

the class WSTrustTestCase method testNoSignatureUsername.

/**
     * No SIGNATURE_USERNAME is provided to the service.  Service will use the
     * client's keystore alias in its place.
     *
     * @throws Exception
     */
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testNoSignatureUsername() 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.setupWsseAndSTSClientNoSignatureUsername(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);
        assertEquals("WS-Trust Hello World!", proxy.sayHello());
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActAsServiceIface(org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface) ServiceIface(org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface) OnBehalfOfServiceIface(org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 42 with RunAsClient

use of org.jboss.arquillian.container.test.api.RunAsClient in project wildfly by wildfly.

the class ContainerInterceptorsTestCase method testDataPassingForContainerInterceptorsOnRemoteView.

/**
     * Tests that the container-interceptor(s) have access to the data that's passed by a remote client via the
     * {@link javax.interceptor.InvocationContext#getContextData()}
     */
@Test
// force real remote invocation so that the RemotingConnectionEJBReceiver is used instead of a LocalEJBReceiver
@RunAsClient
public void testDataPassingForContainerInterceptorsOnRemoteView() throws Exception {
    // create some data that the client side interceptor will pass along during the EJB invocation
    final Map<String, Object> interceptorData = new HashMap<String, Object>();
    interceptorData.put(FlowTrackingBean.CONTEXT_DATA_KEY, ContainerInterceptorOne.class.getName());
    final SimpleEJBClientInterceptor clientInterceptor = new SimpleEJBClientInterceptor(interceptorData);
    // get hold of the EJBClientContext and register the client side interceptor
    EJBClientContext ejbClientContext = EJBClientContext.getCurrent().withAddedInterceptors(clientInterceptor);
    final Hashtable<String, Object> jndiProps = new Hashtable<String, Object>();
    jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
    final Context jndiCtx = new InitialContext(jndiProps);
    ejbClientContext.runCallable(() -> {
        final FlowTracker bean = (FlowTracker) jndiCtx.lookup("ejb:/" + EJB_JAR_NAME + "/" + FlowTrackingBean.class.getSimpleName() + "!" + FlowTracker.class.getName());
        final String message = "foo";
        // we passed ContainerInterceptorOne as the value of the context data for the invocation, which means that we want the ContainerInterceptorOne
        // to be skipped, so except that interceptor, the rest should be invoked.
        final String expectedResultForFirstInvocation = NonContainerInterceptor.class.getName() + " " + FlowTrackingBean.class.getName() + " " + message;
        final String firstResult = bean.echo(message);
        Assert.assertEquals("Unexpected result invoking on bean when passing context data via EJB client interceptor", expectedResultForFirstInvocation, firstResult);
        // Now try another invocation, this time skip a different interceptor
        interceptorData.clear();
        interceptorData.put(FlowTrackingBean.CONTEXT_DATA_KEY, NonContainerInterceptor.class.getName());
        final String secondMessage = "bar";
        // we passed NonContainerInterceptor as the value of the context data for the invocation, which means that we want the NonContainerInterceptor
        // to be skipped, so except that interceptor, the rest should be invoked.
        final String expectedResultForSecondInvocation = ContainerInterceptorOne.class.getName() + " " + FlowTrackingBean.class.getName() + " " + secondMessage;
        final String secondResult = bean.echo(secondMessage);
        Assert.assertEquals("Unexpected result invoking on bean when passing context data via EJB client interceptor", expectedResultForSecondInvocation, secondResult);
        return null;
    });
}
Also used : InitialContext(javax.naming.InitialContext) Context(javax.naming.Context) EJBClientContext(org.jboss.ejb.client.EJBClientContext) HashMap(java.util.HashMap) Hashtable(java.util.Hashtable) EJBClientContext(org.jboss.ejb.client.EJBClientContext) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) InitialContext(javax.naming.InitialContext) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 43 with RunAsClient

use of org.jboss.arquillian.container.test.api.RunAsClient in project wildfly by wildfly.

the class TestsuiteSanityTestCase method testSystemPropertiesClient.

@Test
@RunAsClient
public void testSystemPropertiesClient() throws Exception {
    for (String var : EXPECTED_PROPS) {
        String path = System.getProperty(var);
        Assert.assertNotNull("Property " + var + " is not set (outside container).", path);
        File dir = new File(path);
        Assert.assertTrue("Directory " + dir.getAbsolutePath() + " doesn't exist, check Surefire's system property " + var, dir.exists());
    }
}
Also used : File(java.io.File) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 44 with RunAsClient

use of org.jboss.arquillian.container.test.api.RunAsClient in project wildfly by wildfly.

the class TwoModulesOfDifferentTypeTestCase method testConnection2.

/**
     * Tests connection in pool
     *
     * @throws Exception in case of error
     */
@Test
@RunAsClient
public void testConnection2() throws Exception {
    final ModelNode address1 = ModuleAcDeploymentTestCaseSetup.address1.clone();
    address1.add("connection-definitions", cf1);
    address1.protect();
    final ModelNode operation1 = new ModelNode();
    operation1.get(OP).set("test-connection-in-pool");
    operation1.get(OP_ADDR).set(address1);
    executeOperation(operation1);
}
Also used : ModelNode(org.jboss.dmr.ModelNode) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 45 with RunAsClient

use of org.jboss.arquillian.container.test.api.RunAsClient in project deltaspike by apache.

the class NavigationParameterTest method testNavigationActionIndex.

@Test
@RunAsClient
public void testNavigationActionIndex() throws MalformedURLException {
    driver.get(new URL(contextPath, "origin.xhtml").toString());
    WebElement button = driver.findElement(By.id("parameter:pb005Index"));
    button.click();
    Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("indexPage"), "You arrived at index page").apply(driver));
    System.out.println(driver.getCurrentUrl());
    Assert.assertTrue(driver.getCurrentUrl().contains("param1=staticValue2"));
}
Also used : WebElement(org.openqa.selenium.WebElement) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Aggregations

RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)65 Test (org.junit.Test)64 URL (java.net.URL)49 WebElement (org.openqa.selenium.WebElement)34 QName (javax.xml.namespace.QName)9 Service (javax.xml.ws.Service)9 Bus (org.apache.cxf.Bus)9 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 InSequence (org.jboss.arquillian.junit.InSequence)7 IOException (java.io.IOException)6 Response (javax.ws.rs.core.Response)6 ActAsServiceIface (org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface)6 Client (javax.ws.rs.client.Client)5 HttpResponse (org.apache.http.HttpResponse)5 HttpGet (org.apache.http.client.methods.HttpGet)5 ServiceIface (org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface)5 ModelNode (org.jboss.dmr.ModelNode)5 URI (java.net.URI)3