Search in sources :

Example 1 with ListenerProvider

use of com.google.security.zynamics.zylib.general.ListenerProvider in project binnavi by google.

the class CPostgreSQLModuleContentTest method testCModuleContentConstructor.

@Test
public void testCModuleContentConstructor() throws LoadCancelledException, CouldntLoadDataException {
    final CModule module = (CModule) getDatabase().getContent().getModules().get(0);
    module.load();
    final ListenerProvider<IModuleListener> listeners = new ListenerProvider<IModuleListener>();
    final CCallgraph callgraph = module.getContent().getNativeCallgraph();
    final IFilledList<INaviFunction> functions = new FilledList<INaviFunction>();
    functions.add(module.getContent().getFunctionContainer().getFunctions().get(0));
    final ICallgraphView nativeCallgraph = module.getContent().getViewContainer().getNativeCallgraphView();
    final ImmutableList<IFlowgraphView> nativeFlowgraphs = module.getContent().getViewContainer().getNativeFlowgraphViews();
    final List<INaviView> customViews = new ArrayList<INaviView>();
    final ImmutableBiMap<INaviView, INaviFunction> viewFunctionMap = new ImmutableBiMap.Builder<INaviView, INaviFunction>().build();
    new Pair<HashMap<INaviView, INaviFunction>, HashMap<INaviFunction, INaviView>>(null, null);
    final IFilledList<TraceList> traces = new FilledList<TraceList>();
    final SectionContainer sections = new SectionContainer(new SectionContainerBackend(getProvider(), module));
    final TypeInstanceContainer instances = new TypeInstanceContainer(new TypeInstanceContainerBackend(getProvider(), module, module.getTypeManager(), sections), getProvider());
    final CModuleContent moduleContent1 = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, traces, sections, instances);
    assertNotNull(moduleContent1);
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(null, null, null, null, null, null, null, null, null, null, sections, instances);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, null, null, null, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), null, null, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, null, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, null, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, null, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, null, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, null, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, null, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, null, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
    try {
        @SuppressWarnings("unused") final CModuleContent moduleContent = new CModuleContent(module, getProvider(), listeners, callgraph, functions, nativeCallgraph, nativeFlowgraphs, customViews, viewFunctionMap, traces, null, null);
        fail();
    } catch (final NullPointerException e) {
    }
}
Also used : IFlowgraphView(com.google.security.zynamics.binnavi.disassembly.IFlowgraphView) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) IFilledList(com.google.security.zynamics.zylib.types.lists.IFilledList) ArrayList(java.util.ArrayList) TypeInstanceContainerBackend(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainerBackend) Pair(com.google.security.zynamics.zylib.general.Pair) SectionContainerBackend(com.google.security.zynamics.binnavi.disassembly.types.SectionContainerBackend) CCallgraph(com.google.security.zynamics.binnavi.disassembly.CCallgraph) ICallgraphView(com.google.security.zynamics.binnavi.disassembly.ICallgraphView) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) SectionContainer(com.google.security.zynamics.binnavi.disassembly.types.SectionContainer) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) ListenerProvider(com.google.security.zynamics.zylib.general.ListenerProvider) TypeInstanceContainer(com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) ExpensiveBaseTest(com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest) Test(org.junit.Test)

Example 2 with ListenerProvider

use of com.google.security.zynamics.zylib.general.ListenerProvider in project binnavi by google.

the class CDatabaseSettingsPanel method testConnection.

/**
 * Tries to establish a connection to the database.
 */
public void testConnection() {
    testButton.setEnabled(false);
    if (databaseIdentityField.getText().isEmpty() || databaseIdentityField.getText() == null) {
        CMessageBox.showInformation(SwingUtilities.getWindowAncestor(CDatabaseSettingsPanel.this), "Could not test the connection to the database because the identity name is not set.");
        testButton.setEnabled(true);
        return;
    }
    if (databaseUserField.getText().isEmpty() || databaseUserField.getText() == null) {
        CMessageBox.showInformation(SwingUtilities.getWindowAncestor(CDatabaseSettingsPanel.this), "Could not test the connection to the database because the user name is not set.");
        testButton.setEnabled(true);
        return;
    }
    if (new String(passwordField.getPassword()).isEmpty()) {
        CMessageBox.showInformation(SwingUtilities.getWindowAncestor(CDatabaseSettingsPanel.this), "Could not test the connection to the database because the password is not set.");
        testButton.setEnabled(true);
        return;
    }
    new Thread() {

        @Override
        public void run() {
            final CProgressPanel panel = new CProgressPanel("Testing database connection", true, false, false);
            final IProgressOperation operation = new IProgressOperation() {

                @Override
                public String getDescription() {
                    return "Testing DB Connection";
                }

                @Override
                public CProgressPanel getProgressPanel() {
                    return panel;
                }
            };
            CGlobalProgressManager.instance().add(operation);
            panel.start();
            final CDatabaseConfiguration configuration = new CDatabaseConfiguration(database, new ListenerProvider<IDatabaseListener>(), "CONNECTION TEST", database.getConfiguration().getDriver(), databaseHostField.getText(), databaseNameField.getText(), databaseUserField.getText(), new String(passwordField.getPassword()), databaseIdentityField.getText(), false, false);
            CDatabaseConnector.testConnection(SwingUtilities.getWindowAncestor(CDatabaseSettingsPanel.this), configuration);
            CGlobalProgressManager.instance().remove(operation);
            testButton.setEnabled(true);
        }
    }.start();
}
Also used : CDatabaseConfiguration(com.google.security.zynamics.binnavi.Database.CDatabaseConfiguration) IProgressOperation(com.google.security.zynamics.binnavi.Gui.Progress.IProgressOperation) CProgressPanel(com.google.security.zynamics.zylib.gui.ProgressDialogs.CProgressPanel) ListenerProvider(com.google.security.zynamics.zylib.general.ListenerProvider)

Aggregations

ListenerProvider (com.google.security.zynamics.zylib.general.ListenerProvider)2 ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 CDatabaseConfiguration (com.google.security.zynamics.binnavi.Database.CDatabaseConfiguration)1 IProgressOperation (com.google.security.zynamics.binnavi.Gui.Progress.IProgressOperation)1 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)1 CCallgraph (com.google.security.zynamics.binnavi.disassembly.CCallgraph)1 ICallgraphView (com.google.security.zynamics.binnavi.disassembly.ICallgraphView)1 IFlowgraphView (com.google.security.zynamics.binnavi.disassembly.IFlowgraphView)1 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)1 ExpensiveBaseTest (com.google.security.zynamics.binnavi.disassembly.types.ExpensiveBaseTest)1 SectionContainer (com.google.security.zynamics.binnavi.disassembly.types.SectionContainer)1 SectionContainerBackend (com.google.security.zynamics.binnavi.disassembly.types.SectionContainerBackend)1 TypeInstanceContainer (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainer)1 TypeInstanceContainerBackend (com.google.security.zynamics.binnavi.disassembly.types.TypeInstanceContainerBackend)1 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)1 Pair (com.google.security.zynamics.zylib.general.Pair)1 CProgressPanel (com.google.security.zynamics.zylib.gui.ProgressDialogs.CProgressPanel)1 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)1 IFilledList (com.google.security.zynamics.zylib.types.lists.IFilledList)1 ArrayList (java.util.ArrayList)1