खोज…


परिचय

पैक्स परीक्षा एक OSGi कंटेनर (जैसे AEM, Apache Karaf) के भीतर बंडलों के परीक्षण की अनुमति देता है। पैक्स परीक्षा आमतौर पर JUnit के साथ संयोजन में उपयोग की जाती है।

शुरू करना

यहाँ पैक्स परीक्षा का उपयोग कर एक परीक्षा का एक उदाहरण है।

package com.example.project.test;

import static org.junit.Assert.*;
import static org.ops4j.pax.exam.CoreOptions.*;
 
import javax.inject.Inject;
 
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.regression.pde.HelloService;
import org.ops4j.pax.exam.spi.reactors.*;
  
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class SampleTest {
 
    @Inject
    private HelloService helloService;
 
    @Configuration
    public Option[] config() {
 
        return options(
            mavenBundle("com.example.myproject", "myproject-api", "1.0.0-SNAPSHOT"),
            bundle("http://www.example.com/repository/foo-1.2.3.jar"),
            junitBundles()
            );
    }
 
    @Test
    public void getHelloService() {
        assertNotNull(helloService);
        assertEquals("Hello Pax!", helloService.getMessage());
    }
}

कोड पैक्स परीक्षा 4 पेज से है



Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow