Search in sources :

Example 16 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class PostgreSQLProviderTest method testSetNameAddressSpace3.

@Test(expected = NullPointerException.class)
public void testSetNameAddressSpace3() throws CouldntSaveDataException, CouldntLoadDataException {
    final INaviProject project = getProvider().loadProjects().get(0);
    getProvider().setName(getProvider().loadAddressSpaces(project).get(0), null);
}
Also used : INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 17 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class PostgreSQLProviderTest method testTraceFunctionsCreateTrace2.

@Test
public void testTraceFunctionsCreateTrace2() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final CProject project = getProvider().createProject("SOME_NEW_PROJECT");
    getProvider().createTrace(project, "SOME_TRACE_NAME", "SOME_TRACE_DESCRIPTION");
    project.load();
    final String name = "Very new name";
    final String description = "Super cool description";
    final int projectTraceCount = project.getContent().getTraceCount();
    PostgreSQLTraceFunctions.createTrace((AbstractSQLProvider) getProvider(), project, name, description);
    project.close();
    final List<INaviProject> projects = getProvider().loadProjects();
    INaviProject project2 = null;
    for (final INaviProject cProject : projects) {
        if (project.getConfiguration().getId() == cProject.getConfiguration().getId()) {
            project2 = cProject;
        }
    }
    project2.load();
    assertEquals(projectTraceCount + 1, project2.getContent().getTraceCount());
    assertEquals(description, project2.getContent().getTraces().get(project2.getContent().getTraces().size() - 1).getDescription());
}
Also used : CProject(com.google.security.zynamics.binnavi.disassembly.CProject) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 18 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class PostgreSQLProviderTest method testCSettingsFunctionsWriteSettings23.

@Test(expected = NullPointerException.class)
public void testCSettingsFunctionsWriteSettings23() throws CouldntLoadDataException, CouldntSaveDataException {
    final INaviProject project = getProvider().loadProjects().get(0);
    PostgreSQLSettingsFunctions.writeSetting((AbstractSQLProvider) getProvider(), project, null, null);
}
Also used : INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 19 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class PostgreSQLProviderTest method testSetDescription1.

@Test
public void testSetDescription1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
    final INaviProject project = getProvider().loadProjects().get(0);
    final CAddressSpace addressSpace = getProvider().createAddressSpace(project, "SOME_OTHER_ADDRESS_SPACE");
    final INaviModule module = getProvider().loadModules().get(0);
    module.load();
    final CFunction function = (CFunction) module.getContent().getFunctionContainer().getFunctions().get(0);
    final CView view = (CView) module.getContent().getViewContainer().getViews().get(0);
    final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
    final ITreeNode<CTag> tag = tagManager.getRootTag().getChildren().get(0);
    getProvider().setDescription(addressSpace, "New Description");
    getProvider().setDescription(function, "New Description");
    getProvider().setDescription(module, "New Description");
    getProvider().setDescription(project, "New Description");
    getProvider().setDescription(tag.getObject(), "New Description");
    getProvider().setDescription(module.getContent().getTraceContainer().getTraces().get(0), "New Description");
    getProvider().setDescription(view, "New Description");
}
Also used : CView(com.google.security.zynamics.binnavi.disassembly.views.CView) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CFunction(com.google.security.zynamics.binnavi.disassembly.CFunction) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) CAddressSpace(com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 20 with INaviProject

use of com.google.security.zynamics.binnavi.disassembly.INaviProject in project binnavi by google.

the class CDatabase method load.

@Override
public void load() throws CouldntLoadDataException, InvalidDatabaseVersionException, LoadCancelledException {
    Preconditions.checkArgument(isConnected(), "IE00686: Not connected to the database");
    try {
        if (!loadReporter.report(LoadEvents.LOADING_DATABASE)) {
            throw new LoadCancelledException();
        }
        if (!loadReporter.report(LoadEvents.DETERMINING_DATABASE_VERSION)) {
            throw new LoadCancelledException();
        }
        final DatabaseVersion databaseVersion = provider.getDatabaseVersion();
        final DatabaseVersion currentVersion = new DatabaseVersion(Constants.PROJECT_VERSION);
        if ((databaseVersion.compareTo(currentVersion) != 0) && currentVersion.needsUpgrading(databaseVersion)) {
            throw new InvalidDatabaseVersionException(databaseVersion);
        }
        if (!loadReporter.report(LoadEvents.LOADING_USERS)) {
            throw new LoadCancelledException();
        }
        loadUserManager();
        if (!loadReporter.report(LoadEvents.LOADING_VIEW_TAGS)) {
            throw new LoadCancelledException();
        }
        final CTagManager viewTagManager = loadViewTagManager();
        if (!loadReporter.report(LoadEvents.LOADING_NODE_TAGS)) {
            throw new LoadCancelledException();
        }
        final CTagManager nodeTagManager = loadNodeTagManager();
        if (!loadReporter.report(LoadEvents.LOADING_DEBUGGERS)) {
            throw new LoadCancelledException();
        }
        final DebuggerTemplateManager debuggerDescriptionManager = provider.loadDebuggers();
        if (!loadReporter.report(LoadEvents.LOADING_PROJECTS)) {
            throw new LoadCancelledException();
        }
        final List<INaviProject> projects = provider.loadProjects();
        if (!loadReporter.report(LoadEvents.LOADING_RAW_MODULES)) {
            throw new LoadCancelledException();
        }
        final List<INaviRawModule> rawModules = provider.loadRawModules();
        if (!loadReporter.report(LoadEvents.LOADING_MODULES)) {
            throw new LoadCancelledException();
        }
        final List<INaviModule> modules = provider.loadModules();
        debuggerDescriptionManager.addListener(internalDebuggerTemplateListener);
        content = new CDatabaseContent(provider, this, listeners, projects, modules, rawModules, viewTagManager, nodeTagManager, debuggerDescriptionManager);
    } catch (final CouldntLoadDataException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        close();
        throw exception;
    } catch (final InvalidDatabaseVersionException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        throw exception;
    } catch (final LoadCancelledException exception) {
        loadReporter.report(LoadEvents.LOADING_FINISHED);
        close();
        throw exception;
    } finally {
        isLoading = false;
    }
    content.initializeRawModules(content.getModules(), content.getRawModules());
    for (final IDatabaseListener listener : listeners) {
        try {
            listener.loadedDatabase(this);
        } catch (final Exception exception) {
            CUtilityFunctions.logException(exception);
        }
    }
    loadReporter.report(LoadEvents.LOADING_FINISHED);
}
Also used : InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) DebuggerTemplateManager(com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplateManager) IDatabaseListener(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabaseListener) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException) CouldntInitializeDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException) CouldntLoadDriverException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException) InvalidExporterDatabaseFormatException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidExporterDatabaseFormatException) SQLException(java.sql.SQLException) InvalidDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseException) CouldntConnectException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) CouldntUpdateDatabaseException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntUpdateDatabaseException) InvalidDatabaseVersionException(com.google.security.zynamics.binnavi.Database.Exceptions.InvalidDatabaseVersionException) INaviRawModule(com.google.security.zynamics.binnavi.disassembly.INaviRawModule) INaviProject(com.google.security.zynamics.binnavi.disassembly.INaviProject) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) LoadCancelledException(com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)

Aggregations

INaviProject (com.google.security.zynamics.binnavi.disassembly.INaviProject)45 Test (org.junit.Test)31 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)27 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)6 ViewNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.ViewNotificationContainer)5 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)4 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)4 PostgreSQLViewNotificationParser (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.parsers.PostgreSQLViewNotificationParser)4 CProject (com.google.security.zynamics.binnavi.disassembly.CProject)4 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)4 MockProject (com.google.security.zynamics.binnavi.disassembly.MockProject)4 LoadCancelledException (com.google.security.zynamics.binnavi.Database.Exceptions.LoadCancelledException)3 CAddressSpace (com.google.security.zynamics.binnavi.disassembly.AddressSpaces.CAddressSpace)3 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)3 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)3 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 CouldntConnectException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntConnectException)2 CouldntInitializeDatabaseException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntInitializeDatabaseException)2 CouldntLoadDriverException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDriverException)2