Java Code Examples for org.springframework.context.support.ClassPathXmlApplicationContext

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project arquillian-extension-spring, under directory /arquillian-service-integration-spring/src/test/java/org/jboss/arquillian/spring/integration/enricher/.

Source file: AbstractSpringInjectionEnricherTestCase.java

  32 
vote

/** 
 * <p>Sets up the test environment.</p>
 */
@Before public void setUp(){
  ClassPathXmlApplicationContext applicationContext=new ClassPathXmlApplicationContext("testApplicationContext.xml");
  TestScopeApplicationContext testScopeApplicationContext=new TestScopeApplicationContext(applicationContext,true);
  instance=new MockAbstractSpringInjectionEnricher();
  ((MockAbstractSpringInjectionEnricher)instance).setTestScopeApplicationContext(testScopeApplicationContext);
}
 

Example 2

From project cas, under directory /cas-server-integration-jboss/src/test/java/org/jasig/cas/ticket/registry/.

Source file: JBossCacheTicketRegistryTests.java

  32 
vote

public TicketRegistry getNewTicketRegistry() throws Exception {
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(APPLICATION_CONTEXT_FILE_NAME);
  this.registry=(JBossCacheTicketRegistry)context.getBean(APPLICATION_CONTEXT_CACHE_BEAN_NAME);
  this.treeCache=(Cache<String,Ticket>)context.getBean("cache");
  this.treeCache.removeNode("/ticket");
  return this.registry;
}
 

Example 3

From project Dempsy, under directory /lib-dempsyimpl/src/test/java/com/nokia/dempsy/cluster/.

Source file: TestAllClusterImpls.java

  32 
vote

private <T,N>void runAllCombinations(Checker checker) throws Throwable {
  for (  String clusterManager : clusterManagers) {
    ClassPathXmlApplicationContext actx=new ClassPathXmlApplicationContext(clusterManager);
    actx.registerShutdownHook();
    ClusterInfoSessionFactory factory=(ClusterInfoSessionFactory)actx.getBean("clusterSessionFactory");
    if (checker != null)     checker.check("pass for:" + clusterManager,factory);
    actx.stop();
    actx.destroy();
  }
}
 

Example 4

From project droolsjbpm-integration, under directory /drools-camel-server-example/src/test/java/org/drools/server/.

Source file: CamelServerApp.java

  32 
vote

public String send(String msg){
  ClassPathXmlApplicationContext springContext=new ClassPathXmlApplicationContext("classpath:/camel-client.xml");
  String batch="";
  batch+="<batch-execution lookup=\"ksession1\">\n";
  batch+="  <insert out-identifier=\"message\">\n";
  batch+="      <org.test.Message>\n";
  batch+="         <text>" + msg + "</text>\n";
  batch+="      </org.test.Message>\n";
  batch+="   </insert>\n";
  batch+="</batch-execution>\n";
  CamelServerApp test=new CamelServerApp();
  String response=test.execute(batch,(CamelContext)springContext.getBean("camel"));
  return response;
}
 

Example 5

From project examples-cxf-camel-soabpmdays, under directory /camel-example-cxf/src/main/java/com/example/customerservice/client/.

Source file: CustomerServiceSpringClient.java

  32 
vote

public static void main(String args[]) throws Exception {
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"classpath:client-applicationContext.xml"});
  CustomerServiceTester client=(CustomerServiceTester)context.getBean("tester");
  client.testCustomerService();
  System.exit(0);
}
 

Example 6

From project fire-samples, under directory /cache-demo/src/main/java/demo/vmware/app/.

Source file: Client.java

  32 
vote

public static void main(String[] args) throws Exception {
  String resource[]={"spring-cache-client-core.xml","spring-cache-client-region-only.xml","spring-cache-templates.xml","spring-command-processor.xml","spring-datasync.xml"};
  ClassPathXmlApplicationContext mainContext=new ClassPathXmlApplicationContext(resource,false);
  mainContext.setValidating(true);
  mainContext.refresh();
  ICommandProcessor cp=mainContext.getBean(ICommandProcessor.DEFAULT_PROCESSOR_NAME,ICommandProcessor.class);
  cp.run(mainContext);
}
 

Example 7

From project java-cas-client, under directory /cas-client-core/src/test/java/org/jasig/cas/client/validation/.

Source file: Cas20ProxyTicketValidatorTests.java

  32 
vote

@Test public void testConstructionFromSpringBean() throws TicketValidationException, UnsupportedEncodingException {
  final ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("classpath:cas20ProxyTicketValidator.xml");
  final Cas20ProxyTicketValidator v=(Cas20ProxyTicketValidator)context.getBean("proxyTicketValidator");
  final String USERNAME="username";
  final String RESPONSE="<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'><cas:authenticationSuccess><cas:user>username</cas:user><cas:proxyGrantingTicket>PGTIOU-84678-8a9d...</cas:proxyGrantingTicket><cas:proxies><cas:proxy>proxy1</cas:proxy><cas:proxy>proxy2</cas:proxy><cas:proxy>proxy3</cas:proxy></cas:proxies></cas:authenticationSuccess></cas:serviceResponse>";
  server.content=RESPONSE.getBytes(server.encoding);
  final Assertion assertion=v.validate("test","test");
  assertEquals(USERNAME,assertion.getPrincipal().getName());
}
 

Example 8

From project JCL, under directory /JCL2/spring/src/test/java/org/xeustechnologies/jcl/spring/.

Source file: SpringTest.java

  32 
vote

@Test public void testWithSpring() throws ClassNotFoundException, IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  ClassPathXmlApplicationContext appContext=new ClassPathXmlApplicationContext("classpath:spring-test.xml");
  Object test1=appContext.getBean("test1");
  Object test2=appContext.getBean("test2");
  assertEquals("org.xeustechnologies.jcl.JarClassLoader",test1.getClass().getClassLoader().getClass().getName());
  assertEquals("sun.misc.Launcher$AppClassLoader",test2.getClass().getClassLoader().getClass().getName());
}
 

Example 9

From project litle-sdk-for-java, under directory /lib/apache-cxf-2.5.2/samples/groovy_spring_support/src/main/java/demo/spring/client/.

Source file: Client.java

  32 
vote

public static void main(String args[]) throws Exception {
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"client-beans.xml"});
  HelloWorld client=(HelloWorld)context.getBean("client");
  String response=client.sayHi("Joe");
  System.out.println("Response: " + response);
  System.exit(0);
}
 

Example 10

From project miso-lims, under directory /analysis-server/src/main/java/uk/ac/bbsrc/tgac/miso/analysis/.

Source file: AnalysisServer.java

  32 
vote

public static void main(String[] args){
  log.info("Starting Analysis Server...");
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("/analysis-server.xml");
  AnalysisRequestManager manager=(AnalysisRequestManager)context.getBean("analysisManager");
  log.info("READY: " + manager.getConanTaskService().getTasks().toString());
}
 

Example 11

From project rave, under directory /rave-components/rave-commons/src/test/java/org/apache/rave/util/.

Source file: OverridablePropertyPlaceholderConfigurerTest.java

  32 
vote

@Test public void setLocation(){
  System.setProperty("portal.override.properties","classpath:portal-test.properties");
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("applicationContext-test.xml");
  final StringBuffer testBean=(StringBuffer)context.getBean("testBean");
  assertEquals("Dummy value",testBean.toString());
}
 

Example 12

From project s12gx.2011, under directory /src/test/java/org/springone/timebasedaggregator/.

Source file: TimeBasedAggregationDemo.java

  32 
vote

/** 
 * @param args
 */
public static void main(String[] args) throws Exception {
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("aggregator-config.xml",TimeBasedAggregationDemo.class);
  MessageChannel inChannel=context.getBean("inChannel",MessageChannel.class);
  Random random=new Random();
  while (true) {
    inChannel.send(MessageBuilder.withPayload("VMW").setHeader("price",95 + random.nextDouble()).build());
    Thread.sleep(random.nextInt(687));
  }
}
 

Example 13

From project samolisov-demo, under directory /Spring/spring-hibernate-annotations/src/main/java/ru/naumen/demo/.

Source file: Main.java

  32 
vote

public static void main(String[] args){
  ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
  IMyEntityService service=(IMyEntityService)ctx.getBean("entityService");
  MyEntity entity=new MyEntity();
  entity.setName("Pavel");
  service.saveEntity(entity);
}
 

Example 14

From project shiro, under directory /support/spring/src/test/java/org/apache/shiro/spring/web/.

Source file: ShiroFilterFactoryBeanTest.java

  32 
vote

@Test public void testFilterDefinition(){
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("org/apache/shiro/spring/web/ShiroFilterFactoryBeanTest.xml");
  AbstractShiroFilter shiroFilter=(AbstractShiroFilter)context.getBean("shiroFilter");
  PathMatchingFilterChainResolver resolver=(PathMatchingFilterChainResolver)shiroFilter.getFilterChainResolver();
  DefaultFilterChainManager fcManager=(DefaultFilterChainManager)resolver.getFilterChainManager();
  NamedFilterList chain=fcManager.getChain("/test");
  assertNotNull(chain);
  assertEquals(chain.size(),2);
  Filter[] filters=new Filter[chain.size()];
  filters=chain.toArray(filters);
  assertTrue(filters[0] instanceof DummyFilter);
  assertTrue(filters[1] instanceof FormAuthenticationFilter);
}
 

Example 15

From project spring-amqp-samples, under directory /stocks/src/test/java/org/springframework/amqp/rabbit/stocks/web/.

Source file: ServletConfigurationTests.java

  32 
vote

@Test public void testContext() throws Exception {
  ClassPathXmlApplicationContext parent=new ClassPathXmlApplicationContext("classpath:/server-bootstrap-config.xml");
  try {
    ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"classpath:/servlet-config.xml"},parent);
    context.close();
  }
  finally {
    parent.close();
  }
}
 

Example 16

From project spring-data-graph, under directory /spring-data-neo4j/src/test/java/org/springframework/data/neo4j/config/.

Source file: DataGraphNamespaceHandlerTest.java

  32 
vote

private Config assertInjected(String testCase){
  ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("classpath:org/springframework/data/neo4j/config/DataGraphNamespaceHandlerTest" + testCase + "-context.xml");
  Config config=ctx.getBean("config",Config.class);
  GraphDatabaseContext graphDatabaseContext=config.graphDatabaseContext;
  Assert.assertNotNull("graphDatabaseContext",graphDatabaseContext);
  EmbeddedGraphDatabase graphDatabaseService=(EmbeddedGraphDatabase)graphDatabaseContext.getGraphDatabaseService();
  Assert.assertEquals("store-dir","target/config-test",graphDatabaseService.getStoreDir());
  Assert.assertNotNull("graphRepositoryFactory",config.graphRepositoryFactory);
  Assert.assertNotNull("graphDatabaseService",config.graphDatabaseService);
  Assert.assertNotNull("transactionManager",config.transactionManager);
  config.graphDatabaseService.shutdown();
  return config;
}
 

Example 17

From project spring-data-mongodb, under directory /spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/event/.

Source file: AbstractMongoEventListenerUnitTests.java

  32 
vote

@Test public void dropsEventIfNotForCorrectDomainType(){
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext();
  context.refresh();
  SamplePersonEventListener listener=new SamplePersonEventListener();
  context.addApplicationListener(listener);
  context.publishEvent(new BeforeConvertEvent<Person>(new Person("Dave","Matthews")));
  assertThat(listener.invokedOnBeforeConvert,is(true));
  listener.invokedOnBeforeConvert=false;
  context.publishEvent(new BeforeConvertEvent<String>("Test"));
  assertThat(listener.invokedOnBeforeConvert,is(false));
}
 

Example 18

From project ANNIS, under directory /annis-service/src/test/java/annis/test/.

Source file: SpringSyntaxTreeExamplesSupplier.java

  31 
vote

@Override public List<PotentialAssignment> getValueSources(ParameterSignature signature){
  SpringSyntaxTreeExamples annotation=signature.getAnnotation(SpringSyntaxTreeExamples.class);
  ApplicationContext ctx=new ClassPathXmlApplicationContext(annotation.contextLocation());
  @SuppressWarnings("unchecked") Map<String,String> exampleMap=(Map<String,String>)ctx.getBean(annotation.exampleMap());
  List<PotentialAssignment> examples=new ArrayList<PotentialAssignment>();
  for (  Entry<String,String> exampleEntry : exampleMap.entrySet()) {
    SyntaxTreeExample example=new SyntaxTreeExample();
    example.setQuery(exampleEntry.getKey());
    example.setSyntaxTree(exampleEntry.getValue().trim());
    examples.add(example);
  }
  return examples;
}
 

Example 19

From project ATHENA, under directory /components/payments/src/test/java/org/fracturedatlas/athena/payments/web/resource/.

Source file: BasePaymentsTest.java

  31 
vote

public BasePaymentsTest(){
  super(new WebAppDescriptor.Builder("org.fracturedatlas.athena.web.resource").contextPath("payments").contextParam("contextConfigLocation","classpath:testApplicationContext.xml").servletClass(SpringServlet.class).contextListenerClass(ContextLoaderListener.class).contextParam("javax.ws.rs.Application","org.fracturedatlas.athena.payments.web.config.PaymentsConfig").build());
  ClientConfig cc=new DefaultClientConfig();
  Client c=Client.create(cc);
  webResource=c.resource(BASE_URI);
  webResource.addFilter(new LoggingFilter());
  payments=new AthenaPayments(webResource);
  ApplicationContext context=new ClassPathXmlApplicationContext("testApplicationContext.xml");
}
 

Example 20

From project banshun, under directory /banshun/core/src/test/java/com/griddynamics/banshun/analyzer/.

Source file: ContextAnalyzerTest.java

  31 
vote

/** 
 * This test checks whether the exceptions will happen during instantiation of cont
 */
@Test public void testNested(){
  ApplicationContext context=new ClassPathXmlApplicationContext("com/griddynamics/banshun/analyzer/root-context.xml");
  Registry registry=(Registry)context.getBean("root");
  SuperInterface first=registry.lookup("firstObject",SuperInterface.class);
  SubInterface second=registry.lookup("secondObject",SubInterface.class);
  assertNotNull(first);
  assertNotNull(second);
}
 

Example 21

From project catalog-api-client, under directory /client/src/main/java/com/shopzilla/api/driver/.

Source file: ProductClientDriver.java

  31 
vote

public static void main(String[] args){
  ApplicationContext applicationContext=new ClassPathXmlApplicationContext("classpath:applicationContext-client.xml");
  ProductClient client=applicationContext.getBean("productClient",ProductClient.class);
  credentialFactory=applicationContext.getBean("credentialFactory",CredentialFactory.class);
  apiKey=credentialFactory.getPublisherApiKey();
  publisherId=credentialFactory.getPublisherId();
  client.doProductSearch(apiKey,publisherId,keyword,10);
}
 

Example 22

From project cometd, under directory /cometd-java/cometd-java-annotations/src/test/java/org/cometd/annotation/spring/.

Source file: SpringAnnotationTest.java

  31 
vote

@Test public void testSpringWiringOfCometDServices() throws Exception {
  ClassPathXmlApplicationContext applicationContext=new ClassPathXmlApplicationContext();
  applicationContext.setConfigLocation("classpath:applicationContext.xml");
  applicationContext.refresh();
  String beanName=Introspector.decapitalize(SpringBayeuxService.class.getSimpleName());
  String[] beanNames=applicationContext.getBeanDefinitionNames();
  assertTrue(Arrays.asList(beanNames).contains(beanName));
  SpringBayeuxService service=(SpringBayeuxService)applicationContext.getBean(beanName);
  assertNotNull(service);
  assertNotNull(service.dependency);
  assertNotNull(service.bayeuxServer);
  assertNotNull(service.serverSession);
  assertTrue(service.active);
  assertEquals(1,service.bayeuxServer.getChannel(SpringBayeuxService.CHANNEL).getSubscribers().size());
  applicationContext.close();
  assertFalse(service.active);
}
 

Example 23

From project constretto-core, under directory /constretto-spring/src/test/java/org/constretto/spring/namespacehandler/.

Source file: ImportWithSpecifiedResolverTest.java

  31 
vote

@Test public void givenDevelopmentEnvironmentTheCorrectImportsAreProcessed(){
  ApplicationContext ctx=new ClassPathXmlApplicationContext("org/constretto/spring/namespacehandler/ImportWithSpecifiedResolverTest-context.xml");
  Assert.assertTrue(ctx.containsBean("inMainConfig"));
  Assert.assertFalse(ctx.containsBean("inJunitConfig"));
  Assert.assertTrue(ctx.containsBean("inDevelopmentConfig"));
}
 

Example 24

From project drools-mas, under directory /drools-mas-agent-web-archetype/src/main/resources/archetype-resources/src/test/java/.

Source file: KnowledgeResourcesCompilationTest.java

  31 
vote

@Test public void compilationTest(){
  ApplicationContext context=new ClassPathXmlApplicationContext("META-INF/applicationContext.xml");
  DroolsAgent agent=(DroolsAgent)context.getBean("agent");
  assertNotNull(agent);
  agent.dispose();
}
 

Example 25

From project GNDMS, under directory /dspace/test-src/de/zib/gndms/dspace/service/test/.

Source file: DSpaceServiceTest.java

  31 
vote

@BeforeClass(dependsOnGroups={"dspaceActionTests"},dependsOnMethods={"init"}) private void initContext(){
  context=new ClassPathXmlApplicationContext("classpath:META-INF/00_system.xml");
  final Properties map=new Properties();
  map.put("openjpa.Id",getDbName());
  map.put("openjpa.ConnectionURL","jdbc:derby:" + getDbPath() + ";create=true");
  final EntityManagerFactory emf=Persistence.createEntityManagerFactory(getDbName(),map);
  setEntityManagerFactory(emf);
}
 

Example 26

From project hdiv, under directory /hdiv-config/src/test/java/org/hdiv/config/xml/.

Source file: CustomSchemaTest.java

  31 
vote

public void testSchema(){
  ApplicationContext context=new ClassPathXmlApplicationContext("org/hdiv/config/xml/hdiv-config-test-schema.xml");
  Validation validation=(Validation)context.getBean("id1");
  assertNotNull(validation);
  System.out.println(validation.toString());
  System.out.println("-----------------------");
  HDIVConfig hdivConfig=(HDIVConfig)context.getBean("config");
  assertNotNull(hdivConfig);
  System.out.println(hdivConfig.toString());
  System.out.println("-----------------------");
  HDIVValidations validations=(HDIVValidations)context.getBean("editableParametersValidations");
  assertNotNull(validations);
  System.out.println(validations.toString());
}
 

Example 27

From project hqapi, under directory /hqapi1-tools/src/main/java/tools/.

Source file: Shell.java

  31 
vote

public static void main(String[] args) throws Exception {
  try {
    initConnectionProperties(args);
  }
 catch (  Exception e) {
    System.err.println("Error parsing command line connection properties.  Cause: " + e.getMessage());
    e.printStackTrace(System.err);
    System.exit(1);
  }
  final ClassPathXmlApplicationContext applicationContext=new ClassPathXmlApplicationContext(new String[]{"classpath:/META-INF/spring/hqapi-context.xml","classpath*:/META-INF/**/*commands-context.xml"});
  try {
    final int exitCode=((Shell)applicationContext.getBean("commandDispatcher")).dispatchCommand(args);
    System.exit(exitCode);
  }
 catch (  Exception e) {
    System.err.println("Error running command: " + e.getMessage());
    e.printStackTrace(System.err);
    System.exit(1);
  }
}
 

Example 28

From project jagger, under directory /chassis/core/src/test/java/com/griddynamics/jagger/util/.

Source file: PropertiesResolverTest.java

  31 
vote

@Test public void testPropertiesResolver() throws MalformedURLException {
  ApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"spring/test-properties-resolver.xml"});
  Assert.assertEquals(context.getBean("stringA"),"x-override");
  Assert.assertEquals(context.getBean("stringB"),"x-override/ex");
  Assert.assertEquals(context.getBean("stringC"),"x-override/y-default/ex");
  Assert.assertEquals(context.getBean("stringD"),"x-override+y-default");
}
 

Example 29

From project java-maven-tests, under directory /src/aop-set-prop/src/main/java/com/mysite/aopsetprop/.

Source file: App.java

  31 
vote

public static void main(String[] args){
  final AbstractApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"application-context.xml"});
  println("Context created.");
  final Person person1=(Person)context.getBean("person");
  final BlogPost post1=(BlogPost)context.getBean("blogPost");
  person1.setAge(19);
  post1.setContent("Sample content");
  context.close();
  println("End.");
}
 

Example 30

From project lilith, under directory /tracing/src/test/java/de/huxhorn/lilith/tracing/.

Source file: TracingAspectTest.java

  31 
vote

@Test public void defaultTracing(){
  ApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"defaultTracing.xml"});
  TracingAspect tracingAspect=(TracingAspect)context.getBean("tracingAspect");
  if (logger.isInfoEnabled())   logger.info("Using tracingAspect {}",tracingAspect);
  ExampleServiceIfc exampleService=(ExampleServiceIfc)context.getBean("exampleService");
  callExampleService(exampleService);
}
 

Example 31

From project mapfish-print, under directory /src/main/java/org/mapfish/print/.

Source file: ShellMapPrinter.java

  31 
vote

public ShellMapPrinter(String[] args) throws IOException {
  try {
    GetOptions.parse(args,this);
  }
 catch (  InvalidOption invalidOption) {
    help(invalidOption.getMessage());
  }
  configureLogs();
  this.context=new ClassPathXmlApplicationContext(DEFAULT_SPRING_CONTEXT);
  if (springConfig != null) {
    this.context=new FileSystemXmlApplicationContext(new String[]{"classpath:/" + DEFAULT_SPRING_CONTEXT,springConfig});
  }
}
 

Example 32

From project milton, under directory /milton/milton-servlet/src/main/java/com/bradmcevoy/http/.

Source file: SpringAwareMiltonServlet.java

  31 
vote

@Override public void init(ServletConfig config) throws ServletException {
  try {
    this.config=config;
    servletContext=config.getServletContext();
    context=new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
    httpManager=(HttpManager)context.getBean("milton.http.manager");
  }
 catch (  Throwable ex) {
    log.error("Exception starting milton servlet",ex);
    throw new RuntimeException(ex);
  }
}
 

Example 33

From project milton2, under directory /milton-server/src/main/java/io/milton/servlet/.

Source file: SpringAwareMiltonServlet.java

  31 
vote

@Override public void init(ServletConfig config) throws ServletException {
  try {
    this.config=config;
    servletContext=config.getServletContext();
    context=new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
    httpManager=(HttpManager)context.getBean("milton.http.manager");
  }
 catch (  Throwable ex) {
    log.error("Exception starting milton servlet",ex);
    throw new RuntimeException(ex);
  }
}
 

Example 34

From project OpenMEAP, under directory /server-side/openmeap-admin-web/test/com/openmeap/admin/web/.

Source file: AdminTestHelper.java

  31 
vote

public ModelManager getModelManager(){
  if (persistenceBeans == null) {
    persistenceBeans=new ClassPathXmlApplicationContext(new String[]{"/META-INF/persistenceContext.xml","/META-INF/test/persistenceContext.xml"});
  }
  return (ModelManager)persistenceBeans.getBean("modelManager");
}
 

Example 35

From project qcadoo, under directory /qcadoo-model/src/test/java/com/qcadoo/model/integration/.

Source file: IntegrationTest.java

  31 
vote

@BeforeClass public static void classInit() throws Exception {
  MultiTenantUtil multiTenantUtil=new MultiTenantUtil();
  ReflectionTestUtils.setField(multiTenantUtil,"multiTenantService",new DefaultMultiTenantService());
  multiTenantUtil.init();
  applicationContext=new ClassPathXmlApplicationContext();
  applicationContext.getEnvironment().setActiveProfiles("standalone");
  applicationContext.setConfigLocation("spring.xml");
  applicationContext.refresh();
  dataDefinitionService=applicationContext.getBean(InternalDataDefinitionService.class);
  sessionFactory=applicationContext.getBean("sessionFactory",SessionFactory.class);
  jdbcTemplate=applicationContext.getBean(JdbcTemplate.class);
  verifyHooks=applicationContext.getBean(VerifyHooks.class);
}
 

Example 36

From project randi2, under directory /src/test/java/de/randi2/testUtility/utility/.

Source file: Bootstrap.java

  31 
vote

public Bootstrap() throws ServiceException {
  ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("classpath:/META-INF/spring-bootstrap.xml");
  rolesAndRights=(RolesAndRights)ctx.getBean("rolesAndRights");
  entityManager=(((EntityManagerFactory)ctx.getBean("entityManagerFactory")).createEntityManager());
  passwordEncoder=(PasswordEncoder)ctx.getBean("passwordEncoder");
  saltSourceUser=(ReflectionSaltSource)ctx.getBean("saltSourceUser");
  saltSourceTrialSite=(SystemWideSaltSource)ctx.getBean("saltSourceTrialSite");
  trialService=(TrialService)ctx.getBean("trialService");
  trialSiteService=(TrialSiteService)ctx.getBean("trialSiteService");
  userService=(UserService)ctx.getBean("userService");
  dataSource=(DataSource)ctx.getBean("dataSource");
  init();
  try {
    IDatabaseConnection conn=new DatabaseConnection(dataSource.getConnection());
    ITableFilter filter=new DatabaseSequenceFilter(conn);
    IDataSet dataset=new FilteredDataSet(filter,conn.createDataSet());
    FlatXmlDataSet.write(dataset,new FileWriter(new File("testDBUNIT.xml")));
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 37

From project Red5, under directory /test/org/red5/spring/.

Source file: ExtendedPropertyPlaceholderConfigurerTest.java

  31 
vote

@Before public void loadSpringContext() throws IOException {
  context=new ClassPathXmlApplicationContext("/org/red5/spring/placeholder_context.xml");
  testProperties=new Properties();
  testProperties.load(this.getClass().getResourceAsStream("/org/red5/spring/test.properties"));
  testAProperties=new Properties();
  testAProperties.load(this.getClass().getResourceAsStream("/org/red5/spring/test_a.properties"));
  testBProperties=new Properties();
  testBProperties.load(this.getClass().getResourceAsStream("/org/red5/spring/test_b.properties"));
}
 

Example 38

From project red5-mavenized, under directory /red5_base/src/test/java/org/red5/server/.

Source file: ContextLoaderTest.java

  31 
vote

@Before public void buildContextLoader(){
  loader=new ContextLoader();
  loader.setApplicationContext(new ClassPathXmlApplicationContext("/org/red5/server/parent_context_loader_test.xml"));
  loader.setParentContext(new ClassPathXmlApplicationContext("/org/red5/server/parent_context_loader_test.xml"));
  loader.setContextsConfig("classpath:/org/red5/server/classpath_context_loader_test.properties");
}
 

Example 39

From project red5-server, under directory /test/org/red5/spring/.

Source file: ExtendedPropertyPlaceholderConfigurerTest.java

  31 
vote

@Before public void loadSpringContext() throws IOException {
  context=new ClassPathXmlApplicationContext("/org/red5/spring/placeholder_context.xml");
  testProperties=new Properties();
  testProperties.load(this.getClass().getResourceAsStream("/org/red5/spring/test.properties"));
  testAProperties=new Properties();
  testAProperties.load(this.getClass().getResourceAsStream("/org/red5/spring/test_a.properties"));
  testBProperties=new Properties();
  testBProperties.load(this.getClass().getResourceAsStream("/org/red5/spring/test_b.properties"));
}
 

Example 40

From project rocksteady, under directory /src/main/java/com/admob/rocksteady/router/.

Source file: SpringManager.java

  31 
vote

public void initialize(){
  logger.info("Initializing service " + getDescription());
  applicationContext=new ClassPathXmlApplicationContext(new String[]{DefaultConfig.SPRING_CONTEXT_FILE});
  applicationContext.registerShutdownHook();
  initialized=true;
  logger.info(getDescription() + " initialized successfully");
}
 

Example 41

From project rocksteady_1, under directory /src/main/java/com/admob/rocksteady/router/.

Source file: SpringManager.java

  31 
vote

public void initialize(){
  logger.info("Initializing service " + getDescription());
  applicationContext=new ClassPathXmlApplicationContext(new String[]{DefaultConfig.SPRING_CONTEXT_FILE});
  applicationContext.registerShutdownHook();
  initialized=true;
  logger.info(getDescription() + " initialized successfully");
}
 

Example 42

From project sandbox_2, under directory /wicket-iolite/src/main/resources/archetype-resources/web/src/test/java/.

Source file: BaseTest.java

  31 
vote

private void readyStuff(){
  ApplicationContext appcxt=new ClassPathXmlApplicationContext("AllInOneRepositoryContext.xml");
  generalRepository=(GeneralRepository)appcxt.getBean("generalRepository");
  AnnotApplicationContextMock appctx=new AnnotApplicationContextMock();
  appctx.putBean("generalRepository",generalRepository);
  WicketApplication wicketPersistanceApplication=new WicketApplication();
  wicketPersistanceApplication.setSpringComponentInjector(new SpringComponentInjector(wicketPersistanceApplication,appctx));
  wicketTester=new WicketTester(wicketPersistanceApplication);
}
 

Example 43

From project sched-assist, under directory /sched-assist-spi/src/main/java/org/jasig/schedassist/impl/owner/.

Source file: ScheduleOwnerAuditor.java

  31 
vote

/** 
 * Depends on the presence of a Spring  {@link ApplicationContext} at the locationon the classpath defined by the  {@link #CONFIG_SYSTEM_PROPERTY} System property.
 * @param args
 */
public static void main(String[] args){
  ApplicationContext context=new ClassPathXmlApplicationContext(CONFIG);
  ScheduleOwnerAuditor auditor=(ScheduleOwnerAuditor)context.getBean("scheduleOwnerAuditor");
  List<PersistenceScheduleOwner> allOwnerRecords=auditor.gatherAllScheduleOwnerRecords();
  for (  PersistenceScheduleOwner owner : allOwnerRecords) {
    auditor.auditRecord(owner);
  }
}
 

Example 44

From project sensei, under directory /sensei-federated-broker/src/test/java/com/senseidb/federated/broker/.

Source file: FederatedBrokerIntegrationTest.java

  31 
vote

@Override protected void setUp() throws Exception {
  SingleNodeStarter.start("conf",15000);
  brokerContext=new ClassPathXmlApplicationContext("federatedBroker-context.xml");
  federatedBroker=(FederatedBroker)brokerContext.getBean("federatedBroker",FederatedBroker.class);
  storeClient=(StoreClient<String,String>)brokerContext.getBean("storeClient");
  senseiProxy=(BrokerProxy)brokerContext.getBean("senseiProxy");
  JSONArray arr=readCarDocs();
  storeClient.put("test",arr.toString());
}
 

Example 45

From project server-main, under directory /src/main/java/org/powertac/server/.

Source file: PowerTacServer.java

  31 
vote

/** 
 * Sets up the container, sets up logging, and starts the CompetitionControl service. <p> A simple script file can be used in lieu of a web interface to configure and run games. Each line in the file must be in one of two forms:<br/> <code>&nbsp;&nbsp;bootstrap [--config boot-config]</code><br/> <code>&nbsp;&nbsp;sim [--config sim-config] broker1 broker2 ...</code><br/> where  <dl> <dt><code>boot-config</code></dt> <dd>is the optional name of a properties file that specifies the bootstrap setup. If not provided, then the default server.properties will be used.</dd> <dt><code>sim-config</code></dt> <dd>is the optional name of a properties file that specifies the simulation setup. If not provided, then the default server.properties file will be used. It is possible for the sim-config to be different from the boot-config that produced the bootstrap data file used in the sim, but many properties will be carried over from the bootstrap session regardless of the contents of sim-config.</dd> <dt><code>brokern</code></dt> <dd>are the broker usernames of the brokers that will be logged in before the simulation starts. They must attempt to log in after the server starts.</dd> </dl> To use a configuration file, simply give the filename as a command-line argument.
 */
public static void main(String[] args){
  AbstractApplicationContext context=new ClassPathXmlApplicationContext("powertac.xml");
  context.registerShutdownHook();
  css=(CompetitionSetupService)context.getBeansOfType(CompetitionSetupService.class).values().toArray()[0];
  css.processCmdLine(args);
  System.exit(0);
}
 

Example 46

From project servicemix4-features, under directory /camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/.

Source file: SmxToCxfTest.java

  31 
vote

protected ClassPathXmlApplicationContext createApplicationContext(){
  return new ClassPathXmlApplicationContext("org/apache/servicemix/camel/spring/DummyBean.xml"){
    @Override public <T>T getBean(    String name,    Class<T> requiredType) throws BeansException {
      if (BUS_BEAN_NAME.equals(name)) {
        return requiredType.cast(bus);
      }
      return super.getBean(name,requiredType);
    }
  }
;
}
 

Example 47

From project spring-activiti-sandbox, under directory /src/test/java/org/activiti/spring/test/autodeployment/.

Source file: SpringAutoDeployTest.java

  31 
vote

public void testNoRedeploymentForSpringContainerRestart() throws Exception {
  createAppContext(CTX_PATH);
  DeploymentQuery deploymentQuery=repositoryService.createDeploymentQuery();
  assertEquals(1,deploymentQuery.count());
  ProcessDefinitionQuery processDefinitionQuery=repositoryService.createProcessDefinitionQuery();
  assertEquals(3,processDefinitionQuery.count());
  new ClassPathXmlApplicationContext(CTX_NO_DROP_PATH);
  assertEquals(1,deploymentQuery.count());
  assertEquals(3,processDefinitionQuery.count());
}
 

Example 48

From project spring-amqp, under directory /spring-rabbit/src/test/java/org/springframework/amqp/rabbit/config/.

Source file: ListenerContainerParserTests.java

  31 
vote

@Test public void testIncompatibleTxAtts(){
  try {
    new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-fail-context.xml",getClass());
    fail("Parse exception exptected");
  }
 catch (  BeanDefinitionParsingException e) {
    assertTrue(e.getMessage().startsWith("Configuration problem: Listener Container - cannot set channel-transacted with acknowledge='NONE'"));
  }
}
 

Example 49

From project spring-batch-admin, under directory /spring-batch-admin-sample/src/test/java/org/springframework/batch/admin/sample/.

Source file: BootstrapTests.java

  31 
vote

@Test public void testServletConfiguration() throws Exception {
  ClassPathXmlApplicationContext parent=new ClassPathXmlApplicationContext("classpath:/org/springframework/batch/admin/web/resources/webapp-config.xml");
  ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"classpath:/org/springframework/batch/admin/web/resources/servlet-config.xml"},parent);
  assertTrue(context.containsBean("jobRepository"));
  String[] beanNames=BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context.getBeanFactory(),JobController.class);
  assertEquals(1,beanNames.length);
  Job job=context.getBean(JobRegistry.class).getJob("job1");
  final JobExecution jobExecution=parent.getBean(JobLauncher.class).run(job,new JobParametersBuilder().addString("fail","false").toJobParameters());
  new DirectPoller<BatchStatus>(100).poll(new Callable<BatchStatus>(){
    public BatchStatus call() throws Exception {
      BatchStatus status=jobExecution.getStatus();
      if (status.isLessThan(BatchStatus.STOPPED) && status != BatchStatus.COMPLETED) {
        return null;
      }
      return status;
    }
  }
).get(2000,TimeUnit.MILLISECONDS);
  context.close();
  parent.close();
  assertEquals(BatchStatus.COMPLETED,jobExecution.getStatus());
}
 

Example 50

From project spring-batch-examples, under directory /playground/src/test/java/de/langmi/spring/batch/examples/playground/.

Source file: SimpleJobConfigurationManualTest.java

  31 
vote

/** 
 * Launch Test. 
 */
@Test public void launchJob() throws Exception {
  ConfigurableApplicationContext context=new ClassPathXmlApplicationContext("spring/batch/job/in-memory-job.xml","spring/batch/setup/job-context.xml","spring/batch/setup/job-database.xml");
  Job job=(Job)context.getBean("inMemoryJob");
  JobLauncher launcher=(JobLauncher)context.getBean("jobLauncher");
  Map<String,JobParameter> jobParametersMap=new HashMap<String,JobParameter>();
  jobParametersMap.put("time",new JobParameter(System.currentTimeMillis()));
  jobParametersMap.put("input.file",new JobParameter("file:src/test/resources/input/input.txt"));
  jobParametersMap.put("output.file",new JobParameter("file:target/test-outputs/simple/output.txt"));
  JobExecution jobExecution=launcher.run(job,new JobParameters(jobParametersMap));
  assertEquals(BatchStatus.COMPLETED,jobExecution.getStatus());
}
 

Example 51

From project spring-data-book, under directory /hadoop/batch-extract/src/main/java/com/manning/sbia/ch01/launch/.

Source file: LaunchExportProductsJob.java

  31 
vote

/** 
 * @param args
 */
public static void main(String[] args) throws Exception {
  ApplicationContext ctx=new ClassPathXmlApplicationContext("classpath*:/META-INF/spring/*.xml");
  JobLauncher jobLauncher=ctx.getBean(JobLauncher.class);
  Job job=ctx.getBean(Job.class);
  jobLauncher.run(job,new JobParametersBuilder().addString("hdfsSourceDirectory","/data/analysis/results/part-*").addDate("date",new Date()).toJobParameters());
}
 

Example 52

From project spring-data-document-examples, under directory /mongodb-hello/src/main/java/org/springframework/data/mongodb/examples/hello/.

Source file: App.java

  31 
vote

public static void main(String[] args){
  System.out.println("Bootstrapping HelloMongo");
  ConfigurableApplicationContext context=null;
  context=new ClassPathXmlApplicationContext("META-INF/spring/bootstrap.xml");
  HelloMongo hello=context.getBean(HelloMongo.class);
  hello.run();
  System.out.println("DONE!");
}
 

Example 53

From project androidpn, under directory /androidpn-server-bin-tomcat/src/org/androidpn/server/xmpp/.

Source file: XmppServer.java

  30 
vote

/** 
 * Starts the server using Spring configuration.
 */
public void start(){
  try {
    if (isStandAlone()) {
      Runtime.getRuntime().addShutdownHook(new ShutdownHookThread());
    }
    serverName=Config.getString("xmpp.domain","127.0.0.1").toLowerCase();
    context=new ClassPathXmlApplicationContext("spring-config.xml");
    log.info("Spring Configuration loaded.");
    log.info("XmppServer started: " + serverName);
    log.info("Androidpn Server v" + version);
  }
 catch (  Exception e) {
    e.printStackTrace();
    shutdownServer();
  }
}
 

Example 54

From project Betfair-Trickle, under directory /src/test/java/uk/co/onehp/trickle/dao/.

Source file: HibernateBetDaoCustomT.java

  30 
vote

@Ignore public static void main(final String[] args){
  final ApplicationContext applicationContext=new ClassPathXmlApplicationContext("classpath:/spring-trickle.xml");
  final BetDao betDao=(BetDao)applicationContext.getBean("betDao");
  final RaceDao raceDao=(RaceDao)applicationContext.getBean("raceDao");
  final Race race=new Race(867,"Race",new LocalDateTime(2012,2,22,19,19,0),"meeting");
  final Horse horse=new Horse();
  horse.setRunnerId(441);
  horse.setRaceId(867);
  horse.setRace(race);
  race.addHorse(horse);
  final Strategy strategy1=new Strategy();
  strategy1.setBetSecondsBeforeStartTime(Lists.newArrayList(120,270,600));
  final Strategy strategy2=new Strategy();
  strategy2.setBetSecondsBeforeStartTime(Lists.newArrayList(120,270,700));
  raceDao.saveOrUpdate(race);
  final Bet bet1=new Bet(horse,strategy1);
  betDao.saveOrUpdate(bet1);
  final Bet bet2=new Bet(horse,strategy2);
  betDao.saveOrUpdate(bet2);
  System.out.println(betDao.getBetsToPlace());
}
 

Example 55

From project Carolina-Digital-Repository, under directory /solr-ingest/src/main/java/edu/unc/lib/dl/data/ingest/solr/.

Source file: UpdateDocTransformer.java

  30 
vote

/** 
 * Initializes the transformer by retrieving the XSLT document to use and building a transformer from it. 
 * @throws Exception
 */
public void init() throws Exception {
  ApplicationContext ctx=new ClassPathXmlApplicationContext();
  Resource res=ctx.getResource("classpath:/transform/" + xslName);
  Source transformSource=new StreamSource(res.getInputStream());
  TransformerFactory factory=TransformerFactory.newInstance();
  factory.setURIResolver(new URIResolver(){
    public Source resolve(    String href,    String base) throws TransformerException {
      Source result=null;
      if (href.startsWith("/"))       result=new StreamSource(UpdateDocTransformer.class.getResourceAsStream(href));
 else       result=new StreamSource(UpdateDocTransformer.class.getResourceAsStream("/transform/" + href));
      return result;
    }
  }
);
  Templates transformTemplate=factory.newTemplates(transformSource);
  transformer=transformTemplate.newTransformer();
}
 

Example 56

From project HippoCocoonToolkit, under directory /core/src/main/java/net/tirasa/hct/repository/.

Source file: HCTConnManager.java

  30 
vote

private HCTConnManager(final String componentName){
  if (!HstServices.isAvailable()) {
    throw new SetupException("HstServices not available");
  }
  final Credentials credentials=HstServices.getComponentManager().getComponent(componentName);
  repository=HstServices.getComponentManager().getComponent(Repository.class.getName());
  try {
    session=repository.login(credentials);
  }
 catch (  RepositoryException e) {
    throw new SetupException("While log in to the Hippo repository",e);
  }
  final MetadataReaderClasspathResourceScanner scanner=new MetadataReaderClasspathResourceScanner();
  scanner.setResourceLoader(new ClassPathXmlApplicationContext());
  try {
    final String[] fallbackNodeTypes=(String[])ArrayUtils.add(ObjectConverterUtils.getDefaultFallbackNodeTypes(),"hippo:compound");
    objConv=ObjectConverterUtils.createObjectConverter(ObjectConverterUtils.getAnnotatedClasses(scanner,"classpath*:net/tirasa/hct/hstbeans/**/*.class"),(Class<? extends HippoBean>[])Constants.DEFAULT_BUILT_IN_MAPPING_CLASSES,fallbackNodeTypes,false);
    objMan=new ObjectBeanManagerImpl(session,objConv);
  }
 catch (  Exception e) {
    throw new SetupException("While creating HST ObjectManager",e);
  }
}
 

Example 57

From project huahin-manager, under directory /src/main/java/org/huahinframework/manager/.

Source file: Runner.java

  30 
vote

/** 
 * @param war
 * @param port
 */
public void start(String war,int port){
  log.info("huahin-manager start");
  ConfigurableApplicationContext applicationContext=null;
  try {
    applicationContext=new ClassPathXmlApplicationContext("huahinManagerProperties.xml");
    Properties properties=(Properties)applicationContext.getBean("properties");
    QueueManager queueManager=new QueueManager(properties);
    RunnableFuture<Void> queueManagerThread=new FutureTask<Void>(queueManager);
    new Thread(queueManagerThread).start();
    SelectChannelConnector connector=new SelectChannelConnector();
    connector.setPort(port);
    Server server=new Server();
    server.setConnectors(new Connector[]{connector});
    WebAppContext web=new WebAppContext();
    web.setContextPath("/");
    web.setWar(war);
    server.addHandler(web);
    server.start();
    server.join();
    queueManagerThread.get();
  }
 catch (  Exception e) {
    log.error("huahin-manager aborted",e);
    System.exit(-1);
  }
 finally {
    if (applicationContext != null) {
      applicationContext.close();
    }
  }
  log.info("huahin-manager end");
}
 

Example 58

From project pegadi, under directory /client/src/main/java/org/pegadi/client/.

Source file: ApplicationLauncher.java

  30 
vote

public static void main(String[] args){
  com.sun.net.ssl.internal.ssl.Provider provider=new com.sun.net.ssl.internal.ssl.Provider();
  java.security.Security.addProvider(provider);
  setAllPermissions();
  if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) {
    System.setProperty("apple.laf.useScreenMenuBar","true");
  }
  Logger log=LoggerFactory.getLogger(ApplicationLauncher.class);
  if (!UIManager.getLookAndFeel().getName().equals(UIManager.getSystemLookAndFeelClassName())) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
 catch (    Exception e) {
      log.warn("Unable to change L&F to System",e);
    }
  }
  long start=System.currentTimeMillis();
  Splash splash=new Splash("/images/splash.png");
  splash.setVisible(true);
  splash.setCursor(new Cursor(Cursor.WAIT_CURSOR));
  if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
  }
  new ClassPathXmlApplicationContext("org/pegadi/client/client-context.xml");
  long timeToLogin=System.currentTimeMillis() - start;
  log.info("Connected OK after {} ms",timeToLogin);
  log.info("Java Version {}",System.getProperty("java.version"));
  splash.dispose();
}
 

Example 59

From project security_2, under directory /web-nutsNbolts/src/main/java/org/intalio/tempo/web/.

Source file: SysPropApplicationContextLoader.java

  30 
vote

public void loadAppContext(String appContextFile,boolean loadDefinitionOnStartup){
  if (appContextFile == null) {
    throw new IllegalArgumentException("Argument 'contextFile' is null");
  }
  _appContextFile=SystemPropertyUtils.resolvePlaceholders(appContextFile);
  if (loadDefinitionOnStartup) {
    _beanFactory=new ClassPathXmlApplicationContext(_appContextFile);
  }
 else {
    if (_appContextFile.startsWith(FILE_PREFIX)) {
      _appContextFile=_appContextFile.substring(FILE_PREFIX.length());
    }
    Resource configResource=new FileSystemResource(_appContextFile);
    _beanFactory=new XmlBeanFactory(configResource);
  }
}