Package org.springframework.context.support

Examples of org.springframework.context.support.ClassPathXmlApplicationContext


    public static class Server extends AbstractBusTestServerBase {
   
        protected void run()  {
            // create the application context
            ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("org/apache/cxf/systest/jms/tx/jms_server_config.xml");
            context.start();
           
            EndpointImpl endpoint = new EndpointImpl(new GreeterImplWithTransaction());
            endpoint.setAddress("jms://");
            JMSConfiguration jmsConfig = new JMSConfiguration();
   
            ConnectionFactory connectionFactory
                = context.getBean("jmsConnectionFactory", ConnectionFactory.class);
            jmsConfig.setConnectionFactory(connectionFactory);
            jmsConfig.setTargetDestination("greeter.queue.noaop");
            jmsConfig.setSessionTransacted(true);
            jmsConfig.setPubSubDomain(false);
            jmsConfig.setUseJms11(true);
View Full Code Here


    @Test
    public void testConnectionsWithinSpring() throws Exception {
        BusFactory.setDefaultBus(null);
        BusFactory.setThreadDefaultBus(null);
       
        ClassPathXmlApplicationContext ctx =
            new ClassPathXmlApplicationContext(
                new String[] {"/org/apache/cxf/systest/jms/JMSClients.xml"});
        String wsdlString2 = "classpath:wsdl/jms_test.wsdl";
        broker.updateWsdl((Bus)ctx.getBean("cxf"), wsdlString2);
        HelloWorldPortType greeter = (HelloWorldPortType)ctx.getBean("jmsRPCClient");
        assertNotNull(greeter);
       
        String response1 = new String("Hello Milestone-");
        String response2 = new String("Bonjour");
        try {
           
            for (int idx = 0; idx < 5; idx++) {
                String greeting = greeter.greetMe("Milestone-" + idx);
                assertNotNull("no response received from service", greeting);
                String exResponse = response1 + idx;
                assertEquals(exResponse, greeting);

                String reply = greeter.sayHi();
                assertNotNull("no response received from service", reply);
                assertEquals(response2, reply);
               
                try {
                    greeter.testRpcLitFault("BadRecordLitFault");
                    fail("Should have thrown BadRecoedLitFault");
                } catch (BadRecordLitFault ex) {
                    assertNotNull(ex.getFaultInfo());
                }
               
                try {
                    greeter.testRpcLitFault("NoSuchCodeLitFault");
                    fail("Should have thrown NoSuchCodeLitFault exception");
                } catch (NoSuchCodeLitFault nslf) {
                    assertNotNull(nslf.getFaultInfo());
                    assertNotNull(nslf.getFaultInfo().getCode());
                }
            }
        } catch (UndeclaredThrowableException ex) {
            throw (Exception)ex.getCause();
        }
       
        HelloWorldOneWayPort greeter1 = (HelloWorldOneWayPort)ctx.getBean("jmsQueueOneWayServiceClient");
        assertNotNull(greeter1);
        try {
            greeter1.greetMeOneWay("hello");
        } catch (Exception ex) {
            fail("There should not throw the exception" + ex);
        }
        ctx.close();
        BusFactory.setDefaultBus(getBus());
        BusFactory.setThreadDefaultBus(getBus());
    }
View Full Code Here

    protected static ClassPathXmlApplicationContext ctx;

    @BeforeClass
    public static void initialize() {
        ctx = new ClassPathXmlApplicationContext(new String[] {"classpath:oauth-beans.xml"});
    }
View Full Code Here

public class ResourcesServiceImplTest {

  @Test
  public void test() {
            ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-*.xml")
            ResourcesServiceImpl bean = (ResourcesServiceImpl)ctx.getBean("resourcesService");
            bean.findAll();
            bean.getById("1");
            bean.getUserResources("1");
  }
View Full Code Here

   }
  
   public void setUp(String applicationContextFilename) throws Exception
   {

      ctx = new ClassPathXmlApplicationContext(applicationContextFilename, getClass());
      ctx.registerShutdownHook();       
     
      Sender lsender = (Sender)ctx.getBean("sender");
      sender = lsender;
     
View Full Code Here

      overflowHandler = (MyOverflowHandler)ctx.getBean("testOverflowHandler");
   }

   public void setUp2(String applicationContextFilename) throws Exception
   {
      ctx = new ClassPathXmlApplicationContext(applicationContextFilename, getClass());
      ctx.registerShutdownHook();       
     
      SenderFactory lsender = (SenderFactory)ctx.getBean("senderFactory");
      senderFactory = lsender;
      destinationFactory = (BlockingQueueAdaptor)ctx.getBean("adaptor");
View Full Code Here

                           }

                           String[] ctx = { dempsyConfig, clusterManager, transport, serializer, "testDempsy/" + applicationContext };

                           logger.debug("Starting up the appliction context ...");
                           ClassPathXmlApplicationContext actx = new ClassPathXmlApplicationContext(ctx);
                           actx.registerShutdownHook();

                           Dempsy dempsy = (Dempsy)actx.getBean("dempsy");

                           assertTrue(pass,TestUtils.waitForClustersToBeInitialized(baseTimeoutMillis, dempsy));

                           WaitForShutdown waitingForShutdown = new WaitForShutdown(dempsy);
                           Thread waitingForShutdownThread = new Thread(waitingForShutdown,"Waiting For Shutdown");
                           waitingForShutdownThread.start();
                           Thread.yield();
                          
                           logger.debug("Running test ...");
                           if (checker != null)
                              checker.check(actx);
                           logger.debug("Done with test, stopping the application context ...");

                           actx.stop();
                           actx.destroy();

                           assertTrue(waitingForShutdown.waitForShutdownDoneLatch.await(baseTimeoutMillis, TimeUnit.MILLISECONDS));
                           assertTrue(waitingForShutdown.shutdown);

                           logger.debug("Finished this pass.");
View Full Code Here

   }
  
   @Test
   public void testIndividualClusterStart() throws Throwable
   {
      ClassPathXmlApplicationContext actx = new ClassPathXmlApplicationContext(
            "testDempsy/Dempsy-IndividualClusterStart.xml",
            "testDempsy/Transport-PassthroughActx.xml",
            "testDempsy/ClusterInfo-LocalActx.xml",
            "testDempsy/Serializer-KryoActx.xml",
            "testDempsy/SimpleMultistageApplicationActx.xml"
            );
      actx.registerShutdownHook();
     
      Dempsy dempsy = (Dempsy)actx.getBean("dempsy");
      assertNotNull(dempsy);
     
      Dempsy.Application.Cluster cluster = dempsy.getCluster(new ClusterId("test-app", "test-cluster0"));
      assertNull(cluster);

      cluster = dempsy.getCluster(new ClusterId("test-app", "test-cluster1"));
      assertNull(cluster);

      cluster = dempsy.getCluster(new ClusterId("test-app", "test-cluster2"));
      assertNotNull(cluster);
      assertEquals(1,cluster.getNodes().size());

      cluster = dempsy.getCluster(new ClusterId("test-app", "test-cluster3"));
      assertNull(cluster);

      cluster = dempsy.getCluster(new ClusterId("test-app", "test-cluster4"));
      assertNull(cluster);

      actx.stop();
      actx.destroy();
   }
View Full Code Here

   }

   @Test(expected=BeanCreationException.class)
   public void testInValidClusterStart() throws Throwable
   {
      new ClassPathXmlApplicationContext(
            "testDempsy/Dempsy-InValidClusterStart.xml",
            "testDempsy/Transport-PassthroughActx.xml",
            "testDempsy/ClusterInfo-LocalActx.xml",
            "testDempsy/Serializer-KryoActx.xml",
            "testDempsy/SimpleMultistageApplicationActx.xml"
View Full Code Here

   }
  
   @Test
   public void testTcpTransportExecutorConfigurationThroughApplication() throws Throwable
   {
      ClassPathXmlApplicationContext actx = null;
      DefaultDempsyExecutor executor = null;
      try
      {
         actx = new ClassPathXmlApplicationContext(
               "testDempsy/Dempsy-IndividualClusterStart.xml",
               "testDempsy/Transport-TcpNoBatchingActx.xml",
               "testDempsy/ClusterInfo-LocalActx.xml",
               "testDempsy/Serializer-KryoActx.xml",
               "testDempsy/SimpleMultistageApplicationWithExecutorActx.xml"
               );
         actx.registerShutdownHook();

         Dempsy dempsy = (Dempsy)actx.getBean("dempsy");
         for (Dempsy.Application.Cluster cluster : dempsy.applications.get(0).appClusters)
         {
            // get the receiver from the node
            TcpReceiver r = (TcpReceiver)cluster.getNodes().get(0).receiver;
            executor = (DefaultDempsyExecutor)TcpReceiverAccess.getExecutor(r);
            assertEquals(123456,executor.getMaxNumberOfQueuedLimitedTasks());
            assertTrue(executor.isRunning());
         }
      }
      finally
      {
         try { actx.stop(); } catch (Throwable th) {}
         try { actx.destroy(); } catch(Throwable th) {}
      }
     
      assertNotNull(executor);
      assertTrue(!executor.isRunning());
   }
View Full Code Here

TOP

Related Classes of org.springframework.context.support.ClassPathXmlApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.