Search in sources :

Example 6 with org.apache.struts2.config

use of org.apache.struts2.config in project entando-core by entando.

the class ApsAdminBaseTestCase method setUp.

@Override
protected void setUp() throws Exception {
    boolean refresh = false;
    if (null == applicationContext) {
        // Link the servlet context and the Spring context
        servletContext = new MockServletContext("", new FileSystemResourceLoader());
        applicationContext = this.getConfigUtils().createApplicationContext(servletContext);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
    } else {
        refresh = true;
    }
    RequestContext reqCtx = BaseTestCase.createRequestContext(applicationContext, servletContext);
    this.request = new MockHttpServletRequest();
    this.request.setAttribute(RequestContext.REQCTX, reqCtx);
    this.response = new MockHttpServletResponse();
    this.request.setSession(new MockHttpSession(servletContext));
    if (refresh) {
        try {
            ApsWebApplicationUtils.executeSystemRefresh(this.request);
            this.waitNotifyingThread();
        } catch (Throwable e) {
        }
    }
    // Use spring as the object factory for Struts
    StrutsSpringObjectFactory ssf = new StrutsSpringObjectFactory(null, null, null, null, servletContext, null, this.createContainer());
    ssf.setApplicationContext(applicationContext);
    // Dispatcher is the guy that actually handles all requests.  Pass in
    // an empty Map as the parameters but if you want to change stuff like
    // what config files to read, you need to specify them here
    // (see Dispatcher's source code)
    java.net.URL url = ClassLoader.getSystemResource("struts.properties");
    Properties props = new Properties();
    props.load(url.openStream());
    this.setInitParameters(props);
    Map params = new HashMap(props);
    this.dispatcher = new Dispatcher(servletContext, params);
    this.dispatcher.init();
    Dispatcher.setInstance(this.dispatcher);
}
Also used : HashMap(java.util.HashMap) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) FileSystemResourceLoader(org.springframework.core.io.FileSystemResourceLoader) Properties(java.util.Properties) Dispatcher(org.apache.struts2.dispatcher.Dispatcher) MockServletContext(org.springframework.mock.web.MockServletContext) MockHttpSession(org.springframework.mock.web.MockHttpSession) StrutsSpringObjectFactory(org.apache.struts2.spring.StrutsSpringObjectFactory) RequestContext(com.agiletec.aps.system.RequestContext) HashMap(java.util.HashMap) Map(java.util.Map) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Example 7 with org.apache.struts2.config

use of org.apache.struts2.config in project entando-core by entando.

the class Struts2ServletDispatcher method init.

@Override
public void init(ServletConfig filterConfig) throws ServletException {
    InitOperations init = new InitOperations();
    Dispatcher dispatcher = null;
    try {
        ServletHostConfig config = new ServletHostConfig(filterConfig);
        init.initLogging(config);
        dispatcher = init.initDispatcher(config);
        init.initStaticContentLoader(config, dispatcher);
        prepare = new PrepareOperations(dispatcher);
        execute = new ExecuteOperations(dispatcher);
    } finally {
        if (dispatcher != null) {
            dispatcher.cleanUpAfterInit();
        }
        init.cleanup();
    }
}
Also used : PrepareOperations(com.agiletec.apsadmin.system.dispatcher.PrepareOperations) InitOperations(com.agiletec.apsadmin.system.dispatcher.InitOperations) ExecuteOperations(org.apache.struts2.dispatcher.ExecuteOperations) Dispatcher(org.apache.struts2.dispatcher.Dispatcher) ServletHostConfig(org.apache.struts2.dispatcher.servlet.ServletHostConfig)

Example 8 with org.apache.struts2.config

use of org.apache.struts2.config in project neo4j by neo4j.

the class BoltCausalClusteringIT method shouldPickANewServerToWriteToOnLeaderSwitch.

@Test
public void shouldPickANewServerToWriteToOnLeaderSwitch() throws Throwable {
    // given
    cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
    CoreClusterMember leader = cluster.awaitLeader();
    LeaderSwitcher leaderSwitcher = new LeaderSwitcher(cluster);
    Config config = Config.build().withLogging(new JULogging(Level.OFF)).toConfig();
    Set<BoltServerAddress> seenAddresses = new HashSet<>();
    try (Driver driver = GraphDatabase.driver(leader.routingURI(), AuthTokens.basic("neo4j", "neo4j"), config)) {
        boolean success = false;
        long deadline = System.currentTimeMillis() + (30 * 1000);
        while (!success) {
            if (System.currentTimeMillis() > deadline) {
                fail("Failed to write to the new leader in time. Addresses seen: " + seenAddresses);
            }
            try (Session session = driver.session(AccessMode.WRITE)) {
                BoltServerAddress boltServerAddress = ((RoutingNetworkSession) session).address();
                session.run("CREATE (p:Person)");
                seenAddresses.add(boltServerAddress);
                success = seenAddresses.size() >= 2;
            } catch (Exception e) {
                Thread.sleep(100);
            }
            /*
                 * Having the latch release here ensures that we've done at least one pass through the loop, which means
                 * we've completed a connection before the forced master switch.
                 */
            if (seenAddresses.size() >= 1) {
                leaderSwitcher.start();
            }
        }
    } finally {
        leaderSwitcher.stop();
        assertTrue(leaderSwitcher.hadLeaderSwitch());
        assertThat(seenAddresses.size(), greaterThanOrEqualTo(2));
    }
}
Also used : CoreClusterMember(org.neo4j.causalclustering.discovery.CoreClusterMember) Config(org.neo4j.driver.v1.Config) Driver(org.neo4j.driver.v1.Driver) TimeoutException(java.util.concurrent.TimeoutException) SessionExpiredException(org.neo4j.driver.v1.exceptions.SessionExpiredException) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException) IOException(java.io.IOException) ClientException(org.neo4j.driver.v1.exceptions.ClientException) BoltServerAddress(org.neo4j.driver.internal.net.BoltServerAddress) RoutingNetworkSession(org.neo4j.driver.internal.RoutingNetworkSession) JULogging(org.neo4j.driver.internal.logging.JULogging) HashSet(java.util.HashSet) Session(org.neo4j.driver.v1.Session) RoutingNetworkSession(org.neo4j.driver.internal.RoutingNetworkSession) Test(org.junit.Test)

Example 9 with org.apache.struts2.config

use of org.apache.struts2.config in project jdk8u_jdk by JetBrains.

the class EType method initStatic.

public static void initStatic() {
    boolean allowed = false;
    try {
        Config cfg = Config.getInstance();
        String temp = cfg.get("libdefaults", "allow_weak_crypto");
        if (temp != null && temp.equals("true"))
            allowed = true;
    } catch (Exception exc) {
        if (DEBUG) {
            System.out.println("Exception in getting allow_weak_crypto, " + "using default value " + exc.getMessage());
        }
    }
    allowWeakCrypto = allowed;
}
Also used : Config(sun.security.krb5.Config) KrbCryptoException(sun.security.krb5.KrbCryptoException) KrbException(sun.security.krb5.KrbException)

Example 10 with org.apache.struts2.config

use of org.apache.struts2.config in project jdk8u_jdk by JetBrains.

the class ParseConfig method main.

public static void main(String[] args) throws Exception {
    System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") + "/krb5.conf");
    Config config = Config.getInstance();
    config.listTable();
    String sample = "kdc.example.com kdc2.example.com";
    for (int i = 0; i < 4; i++) {
        String expected = config.getAll("realms", "EXAMPLE_" + i + ".COM", "kdc");
        if (!sample.equals(expected)) {
            throw new Exception("krb5.conf: unexpected kdc value \"" + expected + "\"");
        }
    }
    // JDK-8055045: IOOBE when reading an empty value
    config.get("empty1", "NOVAL.COM");
    config.get("empty2", "NOVAL.COM");
    config.get("quote1", "NOVAL.COM");
    config.get("quote2", "NOVAL.COM");
}
Also used : Config(sun.security.krb5.Config)

Aggregations

Config (sun.security.krb5.Config)8 Dispatcher (org.apache.struts2.dispatcher.Dispatcher)4 KrbException (sun.security.krb5.KrbException)3 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)2 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 org.apache.struts2.config (org.apache.struts2.config)2 ExecuteOperations (org.apache.struts2.dispatcher.ExecuteOperations)2 Test (org.junit.Test)2 RequestContext (com.agiletec.aps.system.RequestContext)1 InitOperations (com.agiletec.apsadmin.system.dispatcher.InitOperations)1 PrepareOperations (com.agiletec.apsadmin.system.dispatcher.PrepareOperations)1 ActionConfig (com.opensymphony.xwork2.config.entities.ActionConfig)1 ResultTypeConfig (com.opensymphony.xwork2.config.entities.ResultTypeConfig)1 PropertyVetoException (java.beans.PropertyVetoException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 Annotation (java.lang.annotation.Annotation)1