/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = (prime * result) + ((this.sensor == null) ? 0 : this.sensor.hashCode()); return result; }
/** * {@inheritDoc} */ @Override public boolean isExceptionSensorActivated() throws StorageException { ensureConfigurationExists(); return null != agentConfiguration.getExceptionSensorTypeConfig(); }
/** * Copies all the class/method information from the {@link MethodInstrumentationConfig} to the * {@link AbstractSensorConfig}. * * @param asc * {@link AbstractSensorConfig} * @param config * {@link MethodInstrumentationConfig} */ private void copyInfo(AbstractSensorConfig asc, MethodInstrumentationConfig config) { asc.setTargetClassFqn(config.getTargetClassFqn()); asc.setTargetMethodName(config.getTargetMethodName()); asc.setReturnType(config.getReturnType()); asc.setParameterTypes(config.getParameterTypes()); }
@Test public void resetNotAllowed() throws StorageException { configurationStorage.setRepository("localhost", 1099); configurationStorage.setRepository("localhost1", 1200); String host = configurationStorage.getRepositoryConfig().getHost(); int port = configurationStorage.getRepositoryConfig().getPort(); assertThat(host, is(equalTo("localhost"))); assertThat(port, is(equalTo(1099))); } }
/** * Establish the connection to the server. * * @exception ConnectException * Throws a ConnectException if there was a problem connecting to the repository. */ private void connect() throws ConnectException { RepositoryConfig repositoryConfig = configurationStorage.getRepositoryConfig(); connection.connect(repositoryConfig.getHost(), repositoryConfig.getPort()); }
@Test public void readFieldPersonObject() throws PropertyAccessException { Person person = new Person(); person.setName("Dirk"); PropertyPathStart start = new PropertyPathStart(); start.setName("this"); start.setContentType(ParameterContentType.FIELD); String result = propertyAccessor.getPropertyContent(start, person, null, resultValueMock, false); assertThat(result, is("Dirk")); Mockito.verifyZeroInteractions(resultValueMock); }
@Test public void analyzeReturnValueVoidMethod() throws PropertyAccessException { // create initial object relation Person peter = new Person("Peter"); // valid PropertyPathStart start = new PropertyPathStart(); start.setName("setName"); start.setContentType(ParameterContentType.RETURN); String result = propertyAccessor.getPropertyContent(start, null, null, peter, false); assertThat(result, is("Peter")); }
/** * {@inheritDoc} */ @Override public boolean isEnhancedExceptionSensorActivated() throws StorageException { ensureConfigurationExists(); if (isExceptionSensorActivated()) { return agentConfiguration.getExceptionSensorTypeConfig().isEnhanced(); } return false; }
@Test(expectedExceptions = { StorageException.class }) public void setNullHost() throws StorageException { configurationStorage.setRepository(null, 1099); }
@Test(expectedExceptions = { StorageException.class }) public void setNullName() throws StorageException { configurationStorage.setAgentName(null); }
@Test(expectedExceptions = { PropertyAccessException.class }) public void nullStartPath() throws PropertyAccessException { propertyAccessor.getPropertyContent(null, null, null, null, false); }
@Test public void check() throws StorageException { configurationStorage.setRepository("localhost", 1099); String host = configurationStorage.getRepositoryConfig().getHost(); int port = configurationStorage.getRepositoryConfig().getPort(); assertThat(host, is(equalTo("localhost"))); assertThat(port, is(equalTo(1099))); }
@Test(expectedExceptions = { PropertyAccessException.class }) public void invokeForbiddenMethod() throws PropertyAccessException { // create initial object relation Person peter = new Person("Peter"); PropertyPathStart start = new PropertyPathStart(); start.setName("this"); start.setContentType(ParameterContentType.FIELD); PropertyPath path = new PropertyPath(); path.setName("getName()"); start.setPathToContinue(path); propertyAccessor.getPropertyContent(start, peter, null, resultValueMock, false); Mockito.verifyZeroInteractions(resultValueMock); }
@Test(expectedExceptions = { StorageException.class }) public void setEmptyHost() throws StorageException { configurationStorage.setRepository("", 1099); }
@Test(expectedExceptions = { StorageException.class }) public void setEmptyName() throws StorageException { configurationStorage.setAgentName(""); }
/** * {@inheritDoc} */ @Override public Map<Collection<String>, InstrumentationDefinition> getInitialInstrumentationResults() throws StorageException { ensureConfigurationExists(); return agentConfiguration.getInitialInstrumentationResults(); }
/** * {@inheritDoc} */ @Override public boolean isClassCacheExistsOnCmr() throws StorageException { ensureConfigurationExists(); return agentConfiguration.isClassCacheExistsOnCmr(); }
/** * {@inheritDoc} */ @Override public RetransformationStrategy getRetransformStrategy() throws StorageException { ensureConfigurationExists(); return agentConfiguration.getRetransformationStrategy(); }
/** * {@inheritDoc} */ @Override public ExceptionSensorTypeConfig getExceptionSensorType() throws StorageException { ensureConfigurationExists(); return agentConfiguration.getExceptionSensorTypeConfig(); }
/** * {@inheritDoc} */ @Override public AgentEndUserMonitoringConfig getEndUserMonitoringConfig() throws StorageException { ensureConfigurationExists(); return agentConfiguration.getEumConfig(); }