当前位置: 首页>>代码示例>>Java>>正文


Java EventContext.getEvent方法代码示例

本文整理汇总了Java中org.jboss.arquillian.core.spi.EventContext.getEvent方法的典型用法代码示例。如果您正苦于以下问题:Java EventContext.getEvent方法的具体用法?Java EventContext.getEvent怎么用?Java EventContext.getEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.arquillian.core.spi.EventContext的用法示例。


在下文中一共展示了EventContext.getEvent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPact

import org.jboss.arquillian.core.spi.EventContext; //导入方法依赖的package包/类
public void testPact(@Observes EventContext<Test> testEventContext) throws Throwable {

        final Test event = testEventContext.getEvent();
        final TestClass testClass = event.getTestClass();

        final PactVerification pactVerification = event.getTestMethod().getAnnotation(PactVerification.class);

        if (pactVerification == null) {
            logger.log(Level.INFO,
                String.format(
                    "Method %s is not annotated with %s annotation and it is going to be executed as normal junit test.",
                    event.getTestMethod().getName(), PactVerification.class.getName()));
            testEventContext.proceed();
            return;
        }

        executeConsumerTest(testEventContext, testClass, pactVerification);
    }
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:19,代码来源:StandaloneConsumerPactTest.java

示例2: testPact

import org.jboss.arquillian.core.spi.EventContext; //导入方法依赖的package包/类
public void testPact(@Observes(precedence = -50) EventContext<Test> testEventContext, Deployment deployment)
    throws Throwable {

    final Test event = testEventContext.getEvent();
    final TestClass testClass = event.getTestClass();

    // We need to check this because in case of embedded containers this class is executed too
    if (RunModeUtils.isRunAsClient(deployment, testClass, event.getTestMethod())) {

        final PactVerification pactVerification = event.getTestMethod().getAnnotation(PactVerification.class);

        if (pactVerification == null) {
            logger.log(Level.INFO,
                String.format(
                    "Method %s is not annotated with %s annotation and it is going to be executed as normal junit test.",
                    event.getTestMethod().getName(), PactVerification.class.getName()));
            testEventContext.proceed();
            return;
        }

        executeConsumerTest(testEventContext, testClass, pactVerification);
    } else {
        // We are in container and this class is executed in client side so we should only pass the execution and incontainer class will do the job
        testEventContext.proceed();
    }
}
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:27,代码来源:ConsumerPactTest.java

示例3: testPact

import org.jboss.arquillian.core.spi.EventContext; //导入方法依赖的package包/类
public void testPact(@Observes(precedence = -50) EventContext<Test> testEventContext) throws Throwable {

        final Test event = testEventContext.getEvent();
        final TestClass testClass = event.getTestClass();

        final PactVerification pactVerification = event.getTestMethod().getAnnotation(PactVerification.class);

        if (pactVerification == null) {
            logger.log(Level.INFO,
                String.format(
                    "Method %s is not annotated with %s annotation and it is going to be executed as normal junit test.",
                    event.getTestMethod().getName(), PactVerification.class.getName()));
            testEventContext.proceed();
            return;
        }

        final ConsumerProviderPair consumerProviderPair =
            executeConsumerTest(testEventContext, testClass, pactVerification);

        // Send results back to client
        final String filename = getFilename(consumerProviderPair);
        final byte[] content = loadPact(filename);

        getCommandService().execute(new PactFilesCommand(filename, content));
    }
 
开发者ID:arquillian,项目名称:arquillian-algeron,代码行数:26,代码来源:RemoteConsumerPactTest.java

示例4: execute

import org.jboss.arquillian.core.spi.EventContext; //导入方法依赖的package包/类
public void execute(@Observes EventContext<Test> context) {
    Test event = context.getEvent();

    Method testMethod = event.getTestMethod();
    WithinNamespace ns = testMethod.getAnnotation(WithinNamespace.class);
    if (ns == null) {
        ns = event.getTestClass().getAnnotation(WithinNamespace.class);
        if (ns == null) {
            Class<?> testClass = event.getTestClass().getJavaClass();
            ns = testClass.getPackage().getAnnotation(WithinNamespace.class);
        }
    }

    if (ns != null) {
        runWithinNamespaces(context, ns.value());
    } else {
        context.proceed();
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:20,代码来源:NamespaceExtensionContainer.java

示例5: update

import org.jboss.arquillian.core.spi.EventContext; //导入方法依赖的package包/类
public void update(@Observes EventContext<ProtocolMetaData> eventContext, Container container,
    CubeRegistry registry) {

    ProtocolMetaData originalMetaData = eventContext.getEvent();
    ProtocolMetaData updatedMetaData = new ProtocolMetaData();
    boolean updated = false;

    try {
        Cube<?> cube = registry.getCube(ContainerUtil.getCubeIDForContainer(container));
        if (cube == null) {
            return;
        }
        HasPortBindings portBindings = cube.getMetadata(HasPortBindings.class);
        if (portBindings == null) {
            return;
        }
        for (Object contextObj : originalMetaData.getContexts()) {
            if (contextObj instanceof HTTPContext) {
                HTTPContext context = (HTTPContext) contextObj;
                String ip = context.getHost();
                int port = context.getPort();
                final PortAddress mappedPort = portBindings.getMappedAddress(port);
                final String bindingIp;
                final Integer bindingPort;
                if (mappedPort != null) {
                    bindingIp = mappedPort.getIP();
                    bindingPort = mappedPort.getPort();
                } else {
                    continue;
                }
                if (bindingPort != null && port != bindingPort) {
                    updated = true;
                    port = bindingPort;
                }
                if (bindingIp != null && !bindingIp.equals(ip)) {
                    updated = true;
                    ip = bindingIp;
                }
                if (updated) {
                    HTTPContext newContext = new HTTPContext(ip, port);
                    for (Servlet servlet : context.getServlets()) {
                        newContext.add(servlet);
                    }
                    updatedMetaData.addContext(newContext);
                }
            } else {
                updatedMetaData.addContext(contextObj);
            }
        }
    } finally {
        if (updated) {
            protocolMetaDataProducer.set(updatedMetaData);
        } else {
            eventContext.proceed();
        }
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:58,代码来源:ProtocolMetadataUpdater.java

示例6: login

import org.jboss.arquillian.core.spi.EventContext; //导入方法依赖的package包/类
public void login(@Observes EventContext<Before> event) throws Exception {
    Before before = event.getEvent();

    UserIsLoggedIn userIsLoggedIn = null;
    if (before.getTestMethod().isAnnotationPresent(UserIsLoggedIn.class)) {
        userIsLoggedIn = before.getTestMethod().getAnnotation(UserIsLoggedIn.class);
    } else if (before.getTestClass().isAnnotationPresent(UserIsLoggedIn.class)) {
        userIsLoggedIn = before.getTestClass().getAnnotation(UserIsLoggedIn.class);
    }

    if (userIsLoggedIn != null) {
        final LoginContext context = new UserLoginContext(userIsLoggedIn);

        log.info(String.format("Found @UserIsLoggedIn: %s [%s]", context.getEmail(), userIsLoggedIn.location()));

        final URI baseUri = getBaseURI(before.getTestMethod());
        final WebDriver driver = createWebDriver();
        try {
            driver.manage().deleteAllCookies();

            driver.navigate().to(baseUri + USER_LOGIN_SERVLET_PATH + "?location=" + URLEncoder.encode(userIsLoggedIn.location(), "UTF-8"));

            // did we navigate to this requested page, or did we get redirected/forwarded to login already
            List<WebElement> loginUrlElts = driver.findElements(By.id("login-url"));
            if (loginUrlElts.size() > 0) {
                String loginURL = loginUrlElts.get(0).getText();

                // check
                if (isInternalLink(loginURL)) {
                    loginURL = baseUri + loginURL;
                }

                // go-to login page
                driver.navigate().to(loginURL);
            }

            // find custom login handler, if exists
            LoginHandler loginHandler = TestBase.instance(getClass(), LoginHandler.class);
            if (loginHandler == null) {
                loginHandler = new DefaultLoginHandler();
            }
            loginHandler.login(driver, context);
            log.info("Logged-in: " + context.getEmail());
            // copy cookies
            Set<Cookie> cookies = driver.manage().getCookies();
            for (Cookie cookie : cookies) {
                ModulesApi.addCookie(cookie.getName(), cookie.getValue());
            }
        } finally {
            driver.close();
        }
    }

    event.proceed();
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:56,代码来源:UserLogin.java


注:本文中的org.jboss.arquillian.core.spi.EventContext.getEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。