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);
}
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();
}
}
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));
}
}
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;
}
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");
}
Aggregations