private DriverDeploymentInfo findDeploymentInfo(String deploymentId, DriverDef driverDef) throws Exception { for (DriverDeploymentInfo deploymentInfo : getDeploymentsInfo()) { if (deploymentInfo.getDeploymentId().equals(deploymentId) || deploymentInfo.getDeploymentId().startsWith(deploymentId + "_" + driverDef.getDriverClass())) { return deploymentInfo; } } return null; }
private void validateDriver(DriverDef driverDef) throws Exception { final URI uri = artifactResolver.resolve(driverDef.getGroupId(), driverDef.getArtifactId(), driverDef.getVersion()); if (uri == null) { throw new Exception("maven artifact was not found: " + driverDef.getGroupId() + ":" + driverDef.getArtifactId() + ":" + driverDef.getVersion()); } final URL[] urls = {uri.toURL()}; final URLClassLoader classLoader = new URLClassLoader(urls); try { Class driverClass = classLoader.loadClass(driverDef.getDriverClass()); if (!Driver.class.isAssignableFrom(driverClass)) { throw new Exception("class: " + driverDef.getDriverClass() + " do not extend from: " + Driver.class.getName()); } } catch (ClassNotFoundException e) { throw new Exception("driver class: " + driverDef.getDriverClass() + " was not found in current gav"); } } }
@Override public DriverDeploymentInfo resync(DriverDef driverDef, DriverDeploymentInfo deploymentInfo) throws Exception { String deploymentId = DeploymentIdGenerator.generateDeploymentId(driverDef); DriverDeploymentInfo currentDeploymentInfo = findDeploymentInfo(deploymentId, driverDef); DriverDeploymentInfo result = new DriverDeploymentInfo(deploymentId, currentDeploymentInfo.getDriverDeploymentId(), true, driverDef.getUuid(), driverDef.getDriverClass()); managedDrivers.put(result.getDeploymentId(), result); return result; }
driverDef.getDriverClass(), dataSourceDef.getConnectionURL(), properties);
@Test public void testLoadFileSuccessFul() { prepareLoadFileSuccessful(); //verifies the content was properly loaded and properly set on the UI verify( view, times( 1 ) ).showLoading(); verify( view, times( 1 ) ).hideBusyIndicator(); assertEquals( content, editor.getContent() ); verify( mainPanelView, times( 1 ) ).setName( content.getDef().getName() ); verify( mainPanelView, times( 1 ) ).setGroupId( content.getDef().getGroupId() ); verify( mainPanelView, times( 1 ) ).setArtifactId( content.getDef().getArtifactId() ); verify( mainPanelView, times( 1 ) ).setVersion( content.getDef().getVersion() ); verify( mainPanelView, times( 1 ) ).setDriverClass( content.getDef().getDriverClass() ); }
private void testDriverClassChange( boolean isValid ) { if ( isValid ) { when( mainPanel.getDriverClass() ).thenReturn( DRIVER_CLASS ); } else { when( mainPanel.getDriverClass() ).thenReturn( INVALID_DRIVER_CLASS ); } when( translationService.getTranslation( DataSourceManagementConstants.DriverDefEditor_InvalidDriverClassMessage ) ).thenReturn( ERROR ); //emulates the helper receiving the change event editorHelper.onDriverClassChange(); if ( isValid ) { assertTrue( editorHelper.isDriverClassValid() ); assertEquals( DRIVER_CLASS, driverDef.getDriverClass() ); verify( mainPanel, times( 1 ) ).clearDriverClassErrorMessage(); } else { assertFalse( editorHelper.isDriverClassValid() ); assertEquals( INVALID_DRIVER_CLASS, driverDef.getDriverClass() ); verify( mainPanel, times( 1 ) ).setDriverClassErrorMessage( ERROR ); } verify( handler, times( 1 ) ).onDriverClassChange(); } }
@Before public void setup() { clientValidationService = new ClientValidationServiceMock(); editorHelper = new DriverDefEditorHelper( translationService, clientValidationService ); editorHelper.setHandler( handler ); editorHelper.init( mainPanel ); driverDef = new DriverDef(); editorHelper.setDriverDef( driverDef ); verify( mainPanel, times( 1 ) ).clear(); verify( mainPanel, times( 1 ) ).setName( driverDef.getName() ); verify( mainPanel, times( 1 ) ).setDriverClass( driverDef.getDriverClass() ); verify( mainPanel, times( 1 ) ).setGroupId( driverDef.getGroupId() ); verify( mainPanel, times( 1 ) ).setArtifactId( driverDef.getArtifactId() ); verify( mainPanel, times( 1 ) ).setVersion( driverDef.getVersion() ); }
/** * Deploys a driver definition on the Wildfly server. * @param driverDef A driver definition to be deployed. * @return The deployment information for the just deployed driver. * @throws Exception exceptions may be thrown if was not possible to deploy the driver. */ public DriverDeploymentInfo deploy(final DriverDef driverDef) throws Exception { final URI uri = artifactResolver.resolve(driverDef.getGroupId(), driverDef.getArtifactId(), driverDef.getVersion()); if (uri == null) { throw new Exception("Unable to get driver library artifact for driver: " + driverDef); } String deploymentId = DeploymentIdGenerator.generateDeploymentId(driverDef); driverMgmtClient.deploy(deploymentId, uri); DriverDeploymentInfo generatedDeploymentInfo = findDeploymentInfo(deploymentId, driverDef); DriverDeploymentInfo deploymentInfo = new DriverDeploymentInfo(deploymentId, generatedDeploymentInfo.getDeploymentId(), true, driverDef.getUuid(), driverDef.getDriverClass()); managedDrivers.put(deploymentInfo.getDeploymentId(), deploymentInfo); return deploymentInfo; }
public void setDriverDef( DriverDef driverDef ) { this.driverDef = driverDef; mainPanel.clear(); mainPanel.setName( driverDef.getName() ); mainPanel.setDriverClass( driverDef.getDriverClass() ); mainPanel.setGroupId( driverDef.getGroupId() ); mainPanel.setArtifactId( driverDef.getArtifactId() ); mainPanel.setVersion( driverDef.getVersion() ); }
public boolean validate( DriverDef driverDef ) { return hasValue( driverDef.getUuid( ) ) && hasValue( driverDef.getName( ) ) && hasValue( driverDef.getDriverClass( ) ) && hasValue( driverDef.getArtifactId( ) ) && hasValue( driverDef.getGroupId( ) ) && hasValue( driverDef.getVersion( ) ); }
/** * Tests the case where the user completes the page by entering correct values. */ @Test public void testValidCompletion() { //emulates the user completing the page by typing valid values in all fields. completeValidDefPage(); //modification event should have been fired. verify( statusChangeEvent, times( 5 ) ).fire( any( WizardPageStatusChangeEvent.class ) ); //the DriverDef should have been populated assertEquals( NAME, driverDef.getName() ); assertEquals( GROUP_ID, driverDef.getGroupId() ); assertEquals( ARTIFACT_ID, driverDef.getArtifactId() ); assertEquals( VERSION, driverDef.getVersion() ); assertEquals( DRIVER_CLASS, driverDef.getDriverClass() ); //the page should be in completed state. defPage.isComplete( new Callback<Boolean>() { @Override public void callback( Boolean result ) { assertTrue( result ); } } ); }
@Test public void testEditorChanges() { //open the editor with a valid content. prepareLoadFileSuccessful(); //emulates some valid changes in the editor. when( mainPanelView.getName() ).thenReturn( NAME_2 ); when( mainPanelView.getDriverClass() ).thenReturn( DRIVER_CLASS_2 ); when( mainPanelView.getGroupId() ).thenReturn( GROUP_ID_2 ); when( mainPanelView.getArtifactId() ).thenReturn( ARTIFACT_ID_2 ); when( mainPanelView.getVersion() ).thenReturn( VERSION_2 ); mainPanel.onNameChange(); mainPanel.onDriverClassChange(); mainPanel.onGroupIdChange(); mainPanel.onArtifactIdChange(); mainPanel.onVersionChange(); //the content of the editor should have been properly modified. assertEquals( NAME_2, editor.getContent().getDef().getName() ); assertEquals( GROUP_ID_2, editor.getContent().getDef().getGroupId() ); assertEquals( ARTIFACT_ID_2, editor.getContent().getDef().getArtifactId() ); assertEquals( VERSION_2, editor.getContent().getDef().getVersion() ); assertEquals( DRIVER_CLASS_2, editor.getContent().getDef().getDriverClass() ); }