Package com.volantis.mcs.repository.jdbc

Examples of com.volantis.mcs.repository.jdbc.InternalJDBCRepository


        DeviceRepositoryLocation location = new DeviceRepositoryLocationImpl(
                configuration.getDefaultProject());

        try {
            // Create the JBDC repository.
            InternalJDBCRepository repository = (InternalJDBCRepository)                
                    factory.createJDBCRepository(repositoryConfiguration);

            // Create the JDBC accessor.
            DeviceRepositoryAccessor accessor =
                    new JDBCDeviceRepositoryAccessor(repository, location);
View Full Code Here


        if (factory == null) {
            throw new JDBCRepositoryException(EXCEPTION_LOCALIZER.format(
                    "jdbc-unknown-vendor", vendor));
        }

        InternalJDBCRepository repository =
                factory.createRepository(
                        (InternalJDBCRepositoryConfiguration) configuration);

        JDBCRepositoryConnection connection = null;
        try {
            connection = (JDBCRepositoryConnection) repository.connect();
            connection.getConnection();

        } finally {
            connection.disconnect();
        }
View Full Code Here

                jdbcFactory.createJDBCRepositoryConfiguration();
        jdbcConfiguration.setDataSource(dataSource);
        jdbcConfiguration.setUsername("geoff");
        jdbcConfiguration.setPassword("geoff");

        InternalJDBCRepository repository = (InternalJDBCRepository)
                jdbcFactory.createJDBCRepository(jdbcConfiguration);

        LockManager manager = repository.getLockManager("project");

        String command = args[0];
        if (command.equals("lock")) {

            if (args.length != 3) {
View Full Code Here

    /**
     * Test the retrieval of policy descriptors.
     */
    public void testRetrievePolicyDescriptor() throws Exception {
        try {
            InternalJDBCRepository repository = createRepository(defaultProject);
            JDBCDeviceRepositoryAccessor accessor =
                    new JDBCDeviceRepositoryAccessor(repository, location);
            Locale locale = new Locale("en", "GB");

            PolicyDescriptor policyDescriptor;
View Full Code Here

    /**
     * Test the enumeration of policy names with a category name.
     */
    public void testRetrieveCategoryDescriptor() throws Exception {
        try {
            final InternalJDBCRepository repository = createRepository(defaultProject);
            final JDBCDeviceRepositoryAccessor accessor =
                new JDBCDeviceRepositoryAccessor(repository, location);
            final Locale locale = Locale.getDefault();
            CategoryDescriptor descriptor = accessor.
                retrieveCategoryDescriptor(connection, "unknown", locale);
View Full Code Here

    /**
     * Test the enumeration of policy names with a category name.
     */
    public void testEnumerateCategoryNames() throws Exception {
        try {
            final InternalJDBCRepository repository = createRepository(defaultProject);
            final JDBCDeviceRepositoryAccessor accessor =
                new JDBCDeviceRepositoryAccessor(repository, location);
            RepositoryEnumeration enumeration =
                accessor.enumerateCategoryNames(connection);
            assertFalse("Should find nothing", enumeration.hasNext());
View Full Code Here

    /**
     * Test the enumeration of policy names.
     */
    public void testEnumeratePolicyNames() throws Exception {
        try {
            InternalJDBCRepository repository = createRepository(defaultProject);
            JDBCDeviceRepositoryAccessor accessor =
                    new JDBCDeviceRepositoryAccessor(repository, location);
            RepositoryEnumeration repositoryEnumeration =
                    accessor.enumeratePolicyNames(connection);
            assertNotNull("Repository enumeration expected", repositoryEnumeration);
View Full Code Here

    /**
     * Test the enumeration of policy names with a category name.
     */
    public void testEnumeratePolicyNamesWithCategory() throws Exception {
        try {
            InternalJDBCRepository repository = createRepository(defaultProject);
            JDBCDeviceRepositoryAccessor accessor =
                    new JDBCDeviceRepositoryAccessor(repository, location);
            RepositoryEnumeration repositoryEnumeration =
                    accessor.enumeratePolicyNames(connection, "unknown");
            assertNotNull("Repository enumeration expected", repositoryEnumeration);
View Full Code Here

    /**
     * Build a JDBC repository
     */
    private InternalJDBCRepository createRepository(String project) throws Exception {
        InternalJDBCRepository repository = null;

        Class.forName("org.hsqldb.jdbcDriver");

        Connection conn = null;
        try {

            HashMap properties = new HashMap();
            properties.put(JDBCRepository.VENDOR_PROPERTY,
                    JDBCRepository.VENDOR_HYPERSONIC);
            properties.put(JDBCRepository.SOURCE_PROPERTY,
                    HypersonicManager.IN_MEMORY_SOURCE);
            properties.put(JDBCRepository.USERNAME_PROPERTY,
                    HypersonicManager.DEFAULT_USERNAME);
            properties.put(JDBCRepository.PASSWORD_PROPERTY,
                    HypersonicManager.DEFAULT_PASSWORD);
            properties.put(JDBCRepository.DEFAULT_PROJECT_NAME_PROPERTY,
                    project);
            properties.put(JDBCRepository.STANDARD_DEVICE_PROJECT_NAME_PROPERTY,
                    project);

            repository = (InternalJDBCRepository)
                    JDBCRepository.createRepository(properties)
                    .getLocalRepository();
            connection = repository.connect();

            JDBCRepositoryConnection jdbcConnection =
                    (JDBCRepositoryConnection) connection;

            conn = jdbcConnection.getConnection();
View Full Code Here

        // Use the in-memory hypersonic db - no background threads!
        final HypersonicManager hypersonicMgr = new HypersonicManager(
                HypersonicManager.IN_MEMORY_SOURCE);
        hypersonicMgr.useCleanupWith(new Executor() {
            public void execute() throws Exception {
                InternalJDBCRepository repository = createRepository(
                        hypersonicMgr.getSource(), null, "#dp");
                JDBCRepositoryConnection connection =
                        (JDBCRepositoryConnection) repository.connect();
                JDBCDeviceRepositoryAccessor accessor =
                        new JDBCDeviceRepositoryAccessor(repository, location);

                Connection conn = connection.getConnection();
                createTables(conn);

                DefaultPolicyDescriptor descriptor =
                        new DefaultPolicyDescriptor();
                descriptor.setCategory("category");
                PolicyType type = new DefaultBooleanPolicyType();
                descriptor.setPolicyType(type);

                accessor.addPolicyDescriptor(connection, "boolean", descriptor);

                // Check the database contents
                checkPolicyTypeRow(conn, null, "boolean", 0, 0);
                checkTypesRow(conn, null, 0, 0);
                checkCategoryRow(conn, null, 0, "category");

                connection.disconnect();
                repository.terminate();
            }
        });
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.repository.jdbc.InternalJDBCRepository

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.