Examples of HttpService


Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testGETResponseBinaryContent() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        byte[] content = generateRandomBinaryContent();

        BasicTestingServlet testServlet = new BasicTestingServlet( content, false );
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        client.connect();

        assertTrue( client.getResponseCode() == 200 );

        byte[] response = readInputAsByteArray( client.getInputStream() );

        printBytes( content );
        printBytes( response );
        assertTrue( content.length ==  response.length );
        for (int i = 0; i < content.length; ++i)
        {
            assertTrue( content[i] == response[i] );
        }

        httpService.unregister( "/test" );      
    }
View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testCanGetResource() throws NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        httpService.registerResources( "/", "/webroot/", null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/index.html", "GET" );
        client.connect();

        assertTrue( client.getResponseCode() == 200 );
View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws IOException
     * @throws NamespaceException
     */
    public void testCannotGetInvalidResource() throws IOException, NamespaceException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        httpService.registerResources( "/", "/webroot/", null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/index2.html", "GET" );
        client.connect();

        assertTrue( client.getResponseCode() == 404 );
View Full Code Here

Examples of org.osgi.service.http.HttpService

public class TestRequestPath extends AbstractHttpliteTestCase
{

    public void testSimpleRequestPath() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test/a/b/c", "GET" );

        client.connect();
        assertTrue( client.getResponseCode() == 200 );
View Full Code Here

Examples of org.osgi.service.http.HttpService

    }


    public void testMultipleSeperatorsRequestPath() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test/a/b//c", "GET" );

        client.connect();
        assertTrue( client.getResponseCode() == 200 );
View Full Code Here

Examples of org.osgi.service.http.HttpService

    super(context, HttpService.class.getName(), null);
  }
 
  @Override
  public Object addingService(ServiceReference reference) {
    HttpService httpService = (HttpService) context.getService(reference);
    try {
      httpService.registerResources("/VAADIN", "/VAADIN", new TargetBundleHttpContext(context, "com.vaadin"));
    } catch (NamespaceException e) {
      e.printStackTrace();
    }
    ApplicationFactoryTracker bridge = new ApplicationFactoryTracker(httpService, context);
    bridge.open();
View Full Code Here

Examples of org.osgi.service.http.HttpService

            LOG.warning("Remote address is unavailable");
            return null;
        }

        CXFNonSpringServlet cxf = new CXFNonSpringServlet();
        HttpService httpService = getHttpService();
        try {
            httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(), null);
            LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);
        } catch (Exception e) {
            throw new ServiceException("CXF DOSGi: problem registering CXF HTTP Servlet", e);
        }       
        Bus bus = cxf.getBus();
View Full Code Here

Examples of org.osgi.service.http.HttpService

public class HttpServiceConfigurationTypeHandlerTest extends TestCase {
    public void testServer() throws Exception {
        BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
        EasyMock.expect(dswContext.getProperty("org.osgi.service.http.port")).
            andReturn("1327").anyTimes();
        HttpService httpService = EasyMock.createNiceMock(HttpService.class);
        // expect that the cxf servlet is registered
        EasyMock.replay(httpService);
       
        ServiceReference httpSvcSR = EasyMock.createNiceMock(ServiceReference.class);
        EasyMock.replay(httpSvcSR);
View Full Code Here

Examples of org.osgi.service.http.HttpService

        assertEquals(expected, dp.getExposedProperties(sr));
    }
   
    public void testServerUsingDefaultAddress() throws Exception {
        BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
        HttpService httpService = EasyMock.createNiceMock(HttpService.class);
        // expect that the cxf servlet is registered
        EasyMock.replay(httpService);
       
        ServiceReference httpSvcSR = EasyMock.createNiceMock(ServiceReference.class);
        EasyMock.replay(httpSvcSR);
View Full Code Here

Examples of org.osgi.service.http.HttpService

        EasyMock.expect(dswContext.getProperty("org.osgi.service.http.secure.enabled")).
            andReturn("true").anyTimes();
        EasyMock.expect(dswContext.getProperty("org.osgi.service.http.port.secure")).
            andReturn("8432").anyTimes();
       
        HttpService httpService = EasyMock.createNiceMock(HttpService.class);
        // expect that the cxf servlet is registered
        EasyMock.replay(httpService);
       
        ServiceReference httpSvcSR = EasyMock.createNiceMock(ServiceReference.class);
        EasyMock.replay(httpSvcSR);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.