@@ -0,0 +1,2773 @@
+package org.nuxeo.ecm.platform.publisher.impl.service;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport org.nuxeo.ecm.core.api.CoreSession;%0Aimport org.nuxeo.ecm.core.api.DocumentModelList;%0Aimport org.nuxeo.ecm.core.storage.sql.SQLRepositoryTestCase;%0Aimport org.nuxeo.ecm.platform.publisher.impl.finder.DefaultRootSectionsFinder;%0A%0A/*%0A * (C) Copyright 2012 Nuxeo SAS (http://nuxeo.com/) and contributors.%0A *%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the GNU Lesser General Public License%0A * (LGPL) version 2.1 which accompanies this distribution, and is available at%0A * http://www.gnu.org/licenses/lgpl.html%0A *%0A * This library is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU%0A * Lesser General Public License for more details.%0A *%0A * Contributors:%0A *     tmartins - test methods for DefaultRootSectionsFinder%0A */%0A%0A%0Apublic class TestRootSectionFinder extends SQLRepositoryTestCase %7B%0A%0A    Set%3CString%3E sectionRootTypes = new HashSet%3CString%3E();%0A%0A    Set%3CString%3E sectionTypes = new HashSet%3CString%3E();%0A%0A    @Override%0A    public void setUp() throws Exception %7B%0A        super.setUp();%0A        openSession();%0A    %7D%0A%0A    public void testBuildQuery() throws Exception %7B%0A        sectionTypes.add(%22Sections%22);%0A        RootSectionsFinderForTest rsf = new RootSectionsFinderForTest(session);%0A%0A        rsf.setSectionTypes();%0A%0A        String path;%0A        String query;%0A%0A        path = %22/default-domain/workspaces/space%22;%0A        query = rsf.buildQuery(path);%0A        assertEquals(%22SELECT * FROM Document WHERE ecm:path STARTSWITH '/default-domain/workspaces/space' and ( ecm:primaryType = 'Section' ) order by ecm:path %22, query);%0A%0A        path = %22/default-domain/workspaces/thierry's space%22;%0A        query = rsf.buildQuery(path);%0A        assertEquals(%22SELECT * FROM Document WHERE ecm:path STARTSWITH '/default-domain/workspaces/thierry%5C%5C's space' and ( ecm:primaryType = 'Section' ) order by ecm:path %22, query);%0A%0A        // test if query is valid%0A        DocumentModelList dml = session.query(query);%0A        assertEquals(0, dml.size());%0A%0A    %7D%0A%0A    /**%0A     * test class to call protected method%0A     * @author tmartins%0A     *%0A     */%0A    private class RootSectionsFinderForTest extends DefaultRootSectionsFinder %7B%0A%0A        public RootSectionsFinderForTest(CoreSession userSession) %7B%0A            super(userSession);%0A        %7D%0A%0A        public String buildQuery(String path) %7B%0A            return super.buildQuery(path);%0A        %7D%0A%0A        public void setSectionTypes() %7B%0A            sectionTypes = new HashSet%3CString%3E();%0A            sectionTypes.add(%22Section%22);%0A        %7D%0A%0A    %7D%0A%7D%0A

add unit test to check buildQuery method