Search in sources :

Example 26 with ProjectAdapter

use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.

the class JcrNodeCreationTest method createFullCoverageNodeUnderPartialCoverageNode.

@Test
public void createFullCoverageNodeUnderPartialCoverageNode() throws Exception {
    IProject project = projectRule.getProject();
    new ProjectAdapter(project).createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/holder/.content.xml"), getClass().getResourceAsStream("nt-unstructured-nodetype.xml"));
    JcrNode contentNode = syncDirNode.getNode("/content/test-root/holder");
    contentNode.createChild("org.apache.sling.SomeComponent", "sling:OsgiConfig");
    assertThat(project, hasFile("/jcr_root/content/test-root/holder/org.apache.sling.SomeComponent.xml"));
}
Also used : JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 27 with ProjectAdapter

use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.

the class JcrNodeCreationTest method prepareProjectAndContent.

@Before
public void prepareProjectAndContent() throws Exception {
    wstServer.waitForServerToStart();
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    // install content facet
    project.installFacet("sling.content", "1.0");
    ServerAdapter server = new ServerAdapter(wstServer.getServer());
    server.installModule(contentProject);
    // create .content.xml structure
    InputStream contentXml = getClass().getResourceAsStream("content-nested-structure.xml");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/test-root/en.xml"), contentXml);
    // directly create the root node
    syncDirNode = new SyncDir((IFolder) contentProject.findMember("jcr_root"));
}
Also used : ServerAdapter(org.apache.sling.ide.test.impl.helpers.ServerAdapter) InputStream(java.io.InputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) SyncDir(org.apache.sling.ide.eclipse.ui.nav.model.SyncDir) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Before(org.junit.Before)

Example 28 with ProjectAdapter

use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.

the class SightlyNatureTesterTest method prepare.

@Before
public void prepare() throws Exception {
    final IProject project = projectRule.getProject();
    projectAdapter = new ProjectAdapter(project);
    projectAdapter.addNatures("org.eclipse.wst.common.project.facet.core.nature");
    projectAdapter.installFacet("sling.content", "1.0");
    tester = new SightlyNatureTester();
}
Also used : SightlyNatureTester(org.apache.sling.ide.eclipse.sightly.internal.SightlyNatureTester) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) IProject(org.eclipse.core.resources.IProject) Before(org.junit.Before)

Example 29 with ProjectAdapter

use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.

the class SlingContentModuleAdapterTest method projectMembersContainContentXmlFirst.

@Test
public void projectMembersContainContentXmlFirst() throws Exception {
    // create faceted project
    IProject contentProject = projectRule.getProject();
    ProjectAdapter project = new ProjectAdapter(contentProject);
    project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
    // install bundle facet
    project.installFacet("sling.content", "1.0");
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/1_file.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/2_folder/filler.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/3_file.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/4_folder/filler.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/5_file.txt"), new ByteArrayInputStream(new byte[0]));
    project.createOrUpdateFile(Path.fromPortableString("jcr_root/content/.content.xml"), new ByteArrayInputStream(new byte[0]));
    IModule module = ServerUtil.getModule(contentProject);
    SlingContentModuleFactory moduleFactory = new SlingContentModuleFactory();
    ModuleDelegate moduleDelegate = moduleFactory.getModuleDelegate(module);
    IModuleResource[] members = moduleDelegate.members();
    assertThat("members[0].path", members[0].getModuleRelativePath().toPortableString(), equalTo(""));
    assertThat("members[1].path", members[1].getModuleRelativePath().toPortableString(), equalTo("content"));
    assertThat("members[2].path", members[2].getModuleRelativePath().toPortableString(), equalTo("content/.content.xml"));
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) ByteArrayInputStream(java.io.ByteArrayInputStream) ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) ModuleDelegate(org.eclipse.wst.server.core.model.ModuleDelegate) IProject(org.eclipse.core.resources.IProject) SlingContentModuleFactory(org.apache.sling.ide.eclipse.core.internal.SlingContentModuleFactory) Test(org.junit.Test)

Example 30 with ProjectAdapter

use of org.apache.sling.ide.test.impl.helpers.ProjectAdapter in project sling by apache.

the class ServiceComponentHeaderValidatorTest method createJavaProject.

private void createJavaProject(String serviceComponentHeader) throws CoreException, IOException, InterruptedException {
    project = new ProjectAdapter(projectRule.getProject());
    project.addNatures(JavaCore.NATURE_ID);
    project.configureAsJavaProject();
    OsgiBundleManifest mf = new OsgiBundleManifest("com.example.bundle001").version("1.0.0").serviceComponent(serviceComponentHeader);
    project.createOsgiBundleManifest(mf);
    poller = new Poller();
    poller.pollUntil(new Callable<IProject>() {

        @Override
        public IProject call() throws Exception {
            return projectRule.getProject();
        }
    }, hasFile("bin/META-INF/MANIFEST.MF"));
}
Also used : ProjectAdapter(org.apache.sling.ide.test.impl.helpers.ProjectAdapter) OsgiBundleManifest(org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest) Poller(org.apache.sling.ide.test.impl.helpers.Poller) IProject(org.eclipse.core.resources.IProject) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ProjectAdapter (org.apache.sling.ide.test.impl.helpers.ProjectAdapter)48 IProject (org.eclipse.core.resources.IProject)45 Test (org.junit.Test)40 ByteArrayInputStream (java.io.ByteArrayInputStream)28 ServerAdapter (org.apache.sling.ide.test.impl.helpers.ServerAdapter)28 RepositoryAccessor (org.apache.sling.ide.test.impl.helpers.RepositoryAccessor)27 Poller (org.apache.sling.ide.test.impl.helpers.Poller)19 RepositoryException (javax.jcr.RepositoryException)16 Node (javax.jcr.Node)15 InputStream (java.io.InputStream)11 Before (org.junit.Before)5 ContentResourceTester (org.apache.sling.ide.eclipse.core.internal.ContentResourceTester)4 IOException (java.io.IOException)3 Session (javax.jcr.Session)3 HttpException (org.apache.commons.httpclient.HttpException)2 SlingContentModuleFactory (org.apache.sling.ide.eclipse.core.internal.SlingContentModuleFactory)2 OsgiBundleManifest (org.apache.sling.ide.test.impl.helpers.OsgiBundleManifest)2 IPath (org.eclipse.core.runtime.IPath)2 IModule (org.eclipse.wst.server.core.IModule)2 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)2