Package org.drools.guvnor.server

Examples of org.drools.guvnor.server.ServiceImplementation


*/
public class EventsTest extends TestCase {
    public void testLoadSave() throws Exception {
        System.setProperty("guvnor.saveEventListener", "org.drools.guvnor.server.repository.SampleSaveEvent");

        ServiceImplementation impl = getService();

        PackageItem pkg = impl.getRulesRepository().createPackage("testLoadSaveEvents", "");
        AssetItem asset = pkg.addAsset("testLoadSaveEvent", "");
        asset.updateFormat(AssetFormats.BUSINESS_RULE);

        RuleModel m = new RuleModel();
        m.name = "mrhoden";
View Full Code Here


    }


    private ServiceImplementation getService() throws Exception {
    ServiceImplementation impl = new ServiceImplementation();

    impl.repository = new RulesRepository(TestEnvironmentSessionHelper
        .getSession());
    return impl;
  }
View Full Code Here

    private ServiceImplementation serviceImplementation;
    private PackageItem           packageItem;

    @Before
    public void setUp() throws Exception {
        serviceImplementation = new ServiceImplementation();

        serviceImplementation.repository = new RulesRepository( TestEnvironmentSessionHelper.getSession() );

        packageItem = serviceImplementation.getRulesRepository().createPackage( "VerifierRunnerTest",
                                                                                "" );
View Full Code Here

    }

    public void testGetPackageBinaryAndSource() throws Exception {

        RulesRepository repo = new RulesRepository( session );
        ServiceImplementation impl = new ServiceImplementation();
        impl.repository = repo;

        long before = System.currentTimeMillis();
        Thread.sleep( 20 );
        FileManagerUtils uploadHelper = new FileManagerUtils();

        uploadHelper.setRepository( repo );
        PackageItem pkg = repo.createPackage( "testGetBinaryPackageServlet",
                                              "" );
        ServiceImplementation.updateDroolsHeader( "import java.util.List",
                                                  pkg );
        pkg.updateCompiledPackage( new ByteArrayInputStream( "foo".getBytes() ) );
        pkg.checkin( "" );

        assertTrue( before < uploadHelper.getLastModified( pkg.getName(),
                                                           "LATEST" ) );

        impl.createPackageSnapshot( pkg.getName(),
                                    "SNAPPY 1",
                                    false,
                                    "" );

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        String fileName = uploadHelper.loadBinaryPackage( pkg.getName(),
                                                          Snapshot.LATEST_SNAPSHOT,
                                                          true,
                                                          out );
        assertEquals( "testGetBinaryPackageServlet.pkg",
                      fileName );
        byte[] file = out.toByteArray();
        assertNotNull( file );
        assertEquals( "foo",
                      new String( file ) );

        out = new ByteArrayOutputStream();
        String drlName = uploadHelper.loadSourcePackage( pkg.getName(),
                                                         Snapshot.LATEST_SNAPSHOT,
                                                         true,
                                                         out );
        String drl = new String( out.toByteArray() );
        assertEquals( pkg.getName() + ".drl",
                      drlName );
        assertNotNull( drl );
        assertTrue( drl.indexOf( "import java.util.List" ) > -1 );

        out = new ByteArrayOutputStream();
        fileName = uploadHelper.loadBinaryPackage( pkg.getName(),
                                                   "SNAPPY 1",
                                                   false,
                                                   out );
        assertEquals( "testGetBinaryPackageServlet_SNAPPY+1.pkg",
                      fileName );
        file = out.toByteArray();
        assertNotNull( file );
        assertEquals( "foo",
                      new String( file ) );

        out = new ByteArrayOutputStream();
        fileName = uploadHelper.loadSourcePackage( pkg.getName(),
                                                   "SNAPPY 1",
                                                   false,
                                                   out );
        assertEquals( "testGetBinaryPackageServlet_SNAPPY+1.drl",
                      fileName );
        drl = new String( out.toByteArray() );
        assertTrue( drl.indexOf( "import java.util.List" ) > -1 );

        Thread.sleep( 100 );
        impl.createPackageSnapshot( pkg.getName(),
                                    "SNAPX",
                                    false,
                                    "" );

        long lastMod = uploadHelper.getLastModified( pkg.getName(),
                                                     "SNAPPY 1" );
        assertTrue( pkg.getLastModified().getTimeInMillis() < lastMod );

        Thread.sleep( 100 );

        impl.createPackageSnapshot( pkg.getName(),
                                    "SNAPX",
                                    true,
                                    "yeah" );

        long lastMod2 = uploadHelper.getLastModified( pkg.getName(),
View Full Code Here

    assertTrue(selector6.isAssetAllowed(item3));
    assertTrue(selector6.isAssetAllowed(item4));  
    }
   
  private ServiceImplementation getService() throws Exception {
    ServiceImplementation impl = new ServiceImplementation();
    impl.repository = new RulesRepository(TestEnvironmentSessionHelper
        .getSession());


    return impl;
View Full Code Here

import junit.framework.TestCase;

public class BuiltInSelectorTest extends TestCase {

    public void testBuiltInSelector() throws Exception {
    ServiceImplementation impl = getService();
    impl.repository.loadDefaultPackage();
    impl.repository.createPackage("testBuiltInSelectorPackage", "woot");
    impl.repository.createState("Dev");
    impl.repository.createState("QA");
   
    CategoryItem cat = impl.repository.loadCategory("/");
    cat.addCategory("testBuiltInSelectorCat1", "yeah");
    cat.addCategory("testBuiltInSelectorCat2", "yeah");

    String uuid1 = impl.createNewRule("test AddRule1", "a description",
        "testBuiltInSelectorCat1", "testBuiltInSelectorPackage", "txt");
    AssetItem item1 = impl.repository.loadAssetByUUID(uuid1);   
    item1.updateState("Dev");
    String uuid2 = impl.createNewRule("test AddRule2", "a description",
        "testBuiltInSelectorCat1", "testBuiltInSelectorPackage", "txt");
    AssetItem item2 = impl.repository.loadAssetByUUID(uuid2);     
    item2.updateState("QA");
    String uuid3 = impl.createNewRule("test AddRule3", "a description",
        "testBuiltInSelectorCat2", "testBuiltInSelectorPackage", "txt");
    AssetItem item3 = impl.repository.loadAssetByUUID(uuid3);     
    item3.updateState("Dev");
    String uuid4 = impl.createNewRule("test AddRule4", "a description",
        "testBuiltInSelectorCat2", "testBuiltInSelectorPackage", "txt");
    AssetItem item4 = impl.repository.loadAssetByUUID(uuid4);     
    item4.updateState("QA");
   
    //Select asset using "category ="
View Full Code Here

        PackageItem pkg = repo.createPackage("testDiscussionFeed", "");
        AssetItem asset = pkg.addAsset("asset1", "desc");
        asset.updateFormat("drl");
        asset.checkin("");

        ServiceImplementation impl = new ServiceImplementation();
        impl.repository = repo;
        impl.addToDiscussionForAsset(asset.getUUID(), "This is a comment");
        impl.addToDiscussionForAsset(asset.getUUID(), "This is another comment");

        Map<String, String> headers = new HashMap<String, String>() {
            {
                put("Irrelevant", "garbage");
            }
View Full Code Here

    @Test
    public void testCategoryBasedPermissionAnalyst() throws Exception {
        //NOTE: Have to have this call, otherwise this test will fail others tests. Seems to be related to
        //how Seam context initializes the JCR repository, but dont know the exact cause yet.
        ServiceImplementation impl = getServiceImplementation();

        String package1Name = "testCategoryBasedPermissionAnalystPackageName1";
        String package2Name = "testCategoryBasedPermissionAnalystPackageName2";

        List<RoleBasedPermission> pbps = new ArrayList<RoleBasedPermission>();
View Full Code Here

    @Test
    public void testLoadSave() throws Exception {
        System.setProperty( "guvnor.saveEventListener",
                            "org.drools.guvnor.server.repository.SampleSaveEvent" );

        ServiceImplementation impl = getServiceImplementation();

        PackageItem pkg = impl.getRulesRepository().createPackage( "testLoadSaveEvents",
                                                                   "" );
        AssetItem asset = pkg.addAsset( "testLoadSaveEvent",
                                        "" );
        asset.updateFormat( AssetFormats.BUSINESS_RULE );
View Full Code Here

     * files.
     */
    @Test
    public void testPackageConfigWithErrors() throws Exception {
        //test the config, no rule assets yet
        ServiceImplementation serviceImplementation = getServiceImplementation();
        PackageItem pkg = serviceImplementation.getRulesRepository().createPackage("testBuilderPackageConfig",
                "x");
        DroolsHeader.updateDroolsHeader("import java.util.List",
                pkg);
        AssetItem func = pkg.addAsset("func1",
                "a function");
        func.updateFormat(AssetFormats.FUNCTION);
        func.updateContent("function void doSomething() { \n System.err.println(List.class.toString()); }");
        func.checkin("yeah");

        func = pkg.addAsset("func2",
                "q");
        func.updateFormat(AssetFormats.FUNCTION);
        func.updateContent("function void foo() { \nSystem.err.println(42); \n}");
        func.checkin("");

        AssetItem ass = pkg.addAsset("dsl",
                "m");
        ass.updateFormat(AssetFormats.DSL);
        ass.updateContent("[when]Foo bar=String()");
        ass.checkin("");
        serviceImplementation.getRulesRepository().save();

        //now lets light it up
        PackageAssembler assembler = new PackageAssembler(pkg);
        assembler.compile();
        assertFalse(assembler.hasErrors());
View Full Code Here

TOP

Related Classes of org.drools.guvnor.server.ServiceImplementation

Copyright © 2018 www.massapicom. 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.