@@ -0,0 +1,2032 @@
+/*%0A * Copyright 2008 Arne Limburg%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions%0A * and limitations under the License.%0A */%0Apackage net.sf.jpasecurity.persistence;%0A%0Aimport javax.persistence.EntityManager;%0Aimport javax.persistence.EntityManagerFactory;%0Aimport javax.persistence.Persistence;%0A%0Aimport junit.framework.TestCase;%0Aimport net.sf.jpasecurity.security.authentication.TestAuthenticationProvider;%0A%0A/**%0A * @author Arne Limburg%0A * @author Johannes Siemer%0A */%0Apublic class JpqlQueryParserTest extends TestCase %7B%0A%0A    public static final String USER1 = %22user1%22;%0A%0A    public void testCount() %7B%0A        executeQuery(%22SELECT COUNT(tb) FROM FieldAccessAnnotationTestBean tb%22);%0A    %7D%0A%0A    public void testDistinct() %7B%0A        executeQuery(%22SELECT DISTINCT tb FROM FieldAccessAnnotationTestBean tb%22);%0A    %7D%0A%0A    public void testExists() %7B%0A        executeQuery(%0A            %22SELECT tb FROM FieldAccessAnnotationTestBean tb WHERE EXISTS(SELECT tb2 FROM FieldAccessAnnotationTestBean tb2)%22);%0A    %7D%0A%0A    private void executeQuery(String query) %7B%0A        TestAuthenticationProvider.authenticate(USER1);%0A        EntityManagerFactory factory = Persistence.createEntityManagerFactory(%22annotation-based-field-access%22);%0A        EntityManager entityManager = factory.createEntityManager();%0A        entityManager.getTransaction().begin();%0A        entityManager.createQuery(query).getResultList();%0A        entityManager.getTransaction().rollback();%0A        entityManager.close();%0A    %7D%0A%0A    public void tearDown() %7B%0A        TestAuthenticationProvider.authenticate(null);%0A    %7D%0A%7D

Test demonstrating a bug handling COUNT-Queries