diff --git a/Kieker.WebGUI/.classpath b/Kieker.WebGUI/.classpath index 658fc2e33f882a2f1b05177d9bb85629cba1e55d..98730f54f55cf8f053c37280b0d4e3f4f06679f3 100644 --- a/Kieker.WebGUI/.classpath +++ b/Kieker.WebGUI/.classpath @@ -11,12 +11,7 @@ <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> + <classpathentry kind="src" path="src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> <attributes> <attribute name="maven.pomderived" value="true"/> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java index e1324891b380bcb24f4f1adc8b9a5590d629e892..c443809a9d6694fd1f9c2b89ada2dc2d752d9abd 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java @@ -220,10 +220,25 @@ public final class ClassAndMethodContainer { * This is the loadFromFile(File)-method of the class equivalence of {@link AnalysisController}. */ private final Method analysisControllerLoadFromFile; + /** + * This is the description()-method of the class equivalence of {@link Display}. + */ private final Method displayDescriptionMethod; + /** + * This is the dependencies()-method of the class equivalence of {@link Plugin}. + */ private final Method pluginDependenciesMethod; + /** + * This is the dependencies()-method of the class equivalence of {@link Repository}. + */ private final Method repositoryDependenciesMethod; + /** + * This is the programmaticOnly()-method of the class equivalence of {@link Plugin}. + */ private final Method pluginProgrammaticOnlyMethod; + /** + * This is the programmaticOnly()-method of the class equivalence of {@link Repository}. + */ private final Method repositoryProgrammaticOnlyMethod; private final Method logImplWebguiLoggingClassGetEntriesMethod; @@ -313,15 +328,19 @@ public final class ClassAndMethodContainer { // Now the constructors this.analysisControllerThreadConstructor = this.analysisControllerThreadClass.getConstructor(this.analysisControllerClass); } catch (final ClassNotFoundException ex) { + // Something went wrong. We can do nothing except throwing an exception ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); } catch (final NoSuchMethodException ex) { + // Something went wrong. We can do nothing except throwing an exception ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); } catch (final SecurityException ex) { + // Something went wrong. We can do nothing except throwing an exception ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); } catch (final ClassCastException ex) { + // Something went wrong. We can do nothing except throwing an exception ClassAndMethodContainer.LOG.error(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); throw new ProjectLoadException(ClassAndMethodContainer.MSG_LOAD_EXCEPTION, ex); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ComponentListContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java similarity index 98% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/ComponentListContainer.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java index a76e74b116dc41b42823de0ea3b94b63753728a7..0e5de46573ab8d9b0ab209d5c54a18c891fbb46c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ComponentListContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.domain; import java.util.List; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IComponentContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/IComponentContainer.java similarity index 97% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/IComponentContainer.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/domain/IComponentContainer.java index 9abf5a905c6bae75d96388f8e35a708cbc8fc753..bc1f14dd3fbfe01da1254361e6fbd44065d3ac0e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/IComponentContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/IComponentContainer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.domain; /** * This is the interface for component containers of different types (plugins and repositories). It exists to have a common base for the implementing classes. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/PluginContainer.java similarity index 99% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginContainer.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/domain/PluginContainer.java index 6bcfaff215b28f512052ce2410325809153e063d..cba5d0d4f94603274eef8f7b621789c380de7e13 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/PluginContainer.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.domain; import java.util.Map; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/RepositoryContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/RepositoryContainer.java similarity index 99% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/RepositoryContainer.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/domain/RepositoryContainer.java index 251d21a943cd7ebc3dac57e6798a997787c6909b..cc1ec6269cbff9907ec861f743b3f5e47cf9846e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/RepositoryContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/RepositoryContainer.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.domain; import java.util.Map; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java index 3931eafb0ca213a61d8263c05774ad757a5ece35..3ebe0855397f62324879fb9a15dca4608e7200da 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java @@ -15,6 +15,8 @@ ***************************************************************************/ /** + * This package contains domain specific classes. + * * @author Nils Christian Ehmke */ package kieker.webgui.domain; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java index b0612cbc61ec864a36716d0d0cdb66e264d88665..0a24f2e1019f4b6ee05fc791cad622d80b326061 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java @@ -25,10 +25,10 @@ import org.springframework.security.access.prepost.PreAuthorize; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.ComponentListContainer; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.ComponentListContainer; import org.primefaces.model.UploadedFile; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java index 0d61a84a6af00be7b313e2594e10a4b8b45e78e8..ac12208233bcb7b57aeb50a31f5f881220c5d71e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java @@ -27,7 +27,6 @@ import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.datasource.DataSourceUtils; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import kieker.common.logging.Log; @@ -64,7 +63,6 @@ public class DerbyUserDAOImpl implements IUserDAO { * @see kieker.webgui.persistence.IserDAO#addUser(user) */ @Override - @PreAuthorize("hasRole('Administrator')") public void addUser(final User user) throws DataAccessException { final Connection connection = DataSourceUtils.getConnection(this.dataSource); PreparedStatement userCmd = null; @@ -108,7 +106,6 @@ public class DerbyUserDAOImpl implements IUserDAO { * @see kieker.webgui.persistence.IserDAO#deleteUser(user) */ @Override - @PreAuthorize("hasRole('Administrator')") public void deleteUser(final User user) throws DataAccessException { final Connection connection = DataSourceUtils.getConnection(this.dataSource); PreparedStatement delCmd = null; @@ -145,7 +142,6 @@ public class DerbyUserDAOImpl implements IUserDAO { * @see kieker.webgui.persistence.IserDAO#editUser(user) */ @Override - @PreAuthorize("hasRole('Administrator')") public void editUser(final User user) throws DataAccessException { final Connection connection = DataSourceUtils.getConnection(this.dataSource); PreparedStatement updateCmd = null; @@ -196,7 +192,6 @@ public class DerbyUserDAOImpl implements IUserDAO { * @see List<User> kieker.webgui.persistence.getUsers() */ @Override - @PreAuthorize("hasRole('Administrator')") public List<User> getUsers() throws DataAccessException { final Connection connection = DataSourceUtils.getConnection(this.dataSource); final List<User> result = new ArrayList<User>(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java index d86c900ce495dc7290f4f4275de771f438ba6d1d..d9ccf5c136afbd5bc4875e711b28eaee62202811 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java @@ -73,13 +73,13 @@ import kieker.analysis.repository.AbstractRepository; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.ComponentListContainer; -import kieker.webgui.common.PluginContainer; -import kieker.webgui.common.RepositoryContainer; import kieker.webgui.common.exception.ComponentInitializationException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.ComponentListContainer; +import kieker.webgui.domain.PluginContainer; +import kieker.webgui.domain.RepositoryContainer; import kieker.webgui.persistence.IProjectDAO; import kieker.webgui.persistence.impl.util.CloseableURLClassLoader; import kieker.webgui.persistence.impl.util.PluginFinder; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..3ff2a9a4c122c665a7e16a7af8083a46cc415f60 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/package-info.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +/** + * This package contains the actual implementations of the persistence interfaces. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.persistence.impl; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/util/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/util/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..379dd6922ffabab16faf6d9155dbc6cba7cbc99c --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/util/package-info.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +/** + * This package contains classes used by the persistence implementation. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.persistence.impl.util; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..318bd0dfc3eb0906df8e2a1602a723c526a4bd3e --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +/** + * This package contains the interfaces to access the persistence. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.persistence; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java new file mode 100644 index 0000000000000000000000000000000000000000..8ab7dd2db774732697f7504ba5aab2d45df0b445 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.service; + +import org.springframework.security.access.prepost.PreAuthorize; + +import kieker.webgui.common.exception.InvalidInputSizeException; +import kieker.webgui.common.exception.UninitializedGraphException; + +/** + * An interface for a service providing a graph layouter. + * + * @author Nils Christian Ehmke + */ +public interface IGraphLayoutService { + + /** + * This method takes two Strings, describing some basic graph information, and constructs a KGraph, which is then layouted by a Kieler algorithm. + * + * @param nodes + * A String containing node dimensions. + * @param edges + * A String containing connection information of edges. + * @return A String of space separated node positions. + * + * @throws UninitializedGraphException + * If the graph has not been initialized yet. + * @throws InvalidInputSizeException + * If the input size is somehow invalid. + */ + @PreAuthorize("isAuthenticated()") + public String layoutGraph(String nodes, String edges) throws UninitializedGraphException, InvalidInputSizeException; + +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java index 7e4d7f9ecef8964ec330e98655223cae54df93b5..dc107b215d4260bdd8ccfe47b200d931f3330777 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java @@ -20,16 +20,18 @@ import java.io.IOException; import java.util.Collection; import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; + import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.ComponentListContainer; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.ComponentListContainer; import org.primefaces.model.UploadedFile; @@ -55,6 +57,7 @@ public interface IProjectService { * @throws IOException * If something went wrong during the creation of the project. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void addProject(final String projectName, final String username) throws ProjectAlreadyExistingException, IOException; /** @@ -72,6 +75,7 @@ public interface IProjectService { * @throws IOException * If something went wrong during the creation of the target-project or during the loading of the source-project. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void copyProject(final String originalProjectName, final String newProjectName) throws ProjectNotExistingException, ProjectAlreadyExistingException, IOException; @@ -86,6 +90,7 @@ public interface IProjectService { * @throws IOException * If something went wrong during the opening of the project. */ + @PreAuthorize("isAuthenticated()") public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException; /** @@ -103,6 +108,7 @@ public interface IProjectService { * @throws IOException * If something went wrong during the opening of the project. This can also mean that the given {@link ClassAndMethodContainer} is somehow invalid. */ + @PreAuthorize("isAuthenticated()") public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException; /** @@ -125,6 +131,7 @@ public interface IProjectService { * @throws NewerProjectException * If the project on the file system is newer and the overwriteNewerProject-flag has not been set. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void saveProject(final String projectName, final MIProject project, final long timeStamp, final boolean overwriteNewerProject) throws ProjectNotExistingException, IOException, NewerProjectException; @@ -137,6 +144,7 @@ public interface IProjectService { * @throws ProjectNotExistingException * If a project with the given name does not exist. */ + @PreAuthorize("isAuthenticated()") public long getCurrTimeStamp(final String projectName) throws ProjectNotExistingException; /** @@ -148,6 +156,7 @@ public interface IProjectService { * @throws ProjectNotExistingException * If a project with the given name does not exist. */ + @PreAuthorize("isAuthenticated()") public String getOwner(final String projectName) throws ProjectNotExistingException; /** @@ -162,6 +171,7 @@ public interface IProjectService { * @throws IOException * If something went wrong during the uploading. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void uploadLibrary(final UploadedFile file, final String projectName) throws ProjectNotExistingException, IOException; /** @@ -177,6 +187,7 @@ public interface IProjectService { * @throws IOException * If something went wrong during the initialization of the class loader. */ + @PreAuthorize("isAuthenticated()") public ClassLoader getClassLoader(final String projectName, final Object requester) throws ProjectNotExistingException, IOException; /** @@ -188,6 +199,7 @@ public interface IProjectService { * @throws ProjectNotExistingException * If a project with the given name does not exist. */ + @PreAuthorize("isAuthenticated()") public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException; /** @@ -197,6 +209,7 @@ public interface IProjectService { * The project whose components should be loaded. * @return An object containing the available components as model instances. */ + @PreAuthorize("isAuthenticated()") public abstract ComponentListContainer getAvailableComponents(String project); /** @@ -204,6 +217,7 @@ public interface IProjectService { * * @return A list containing all available project names. */ + @PreAuthorize("isAuthenticated()") public Collection<String> listAllProjects(); /** @@ -220,6 +234,7 @@ public interface IProjectService { * @throws AnalysisInitializationException * If an error occurred during the initialization of the analysis. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, AnalysisStateException, AnalysisInitializationException; @@ -233,6 +248,7 @@ public interface IProjectService { * @throws AnalysisStateException * If the analysis of the given project is in the wrong state to be cleaned. This means that it has not been terminated yet. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void cleanAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; /** @@ -245,6 +261,7 @@ public interface IProjectService { * @throws AnalysisStateException * If the analysis of the given project is in the wrong state to be started. This means that it has not been initialized yet. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; /** @@ -257,6 +274,7 @@ public interface IProjectService { * @throws AnalysisStateException * If the analysis of the given project is in the wrong state to be stopped. This means that it has not been started yet or is no longer running. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; /** @@ -275,6 +293,7 @@ public interface IProjectService { * @throws DisplayNotFoundException * If a view or a display within the given view does not exist. */ + @PreAuthorize("isAuthenticated()") public Object getDisplay(final String projectName, final String viewName, final String displayName) throws ProjectNotExistingException, DisplayNotFoundException; /** @@ -284,6 +303,7 @@ public interface IProjectService { * The name of the project whose state have to be returned. * @return The state of the given project, if available. {@code null} otherwise. */ + @PreAuthorize("isAuthenticated()") public STATE getCurrentState(final String projectName); /** @@ -295,6 +315,7 @@ public interface IProjectService { * @throws AnalysisStateException * If the analysis is in an invalid state to deliver the entries. */ + @PreAuthorize("isAuthenticated()") public Object[] getLogEntries(final String projectName) throws AnalysisStateException; /** @@ -308,5 +329,6 @@ public interface IProjectService { * @throws IOException * If something went wrong during the reloading of the components. */ + @PreAuthorize("hasAnyRole('User', 'Administrator')") public boolean deleteLibrary(String projectName, String libName) throws IOException; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/layout/GraphFlowLayouter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java similarity index 90% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/layout/GraphFlowLayouter.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java index c233fd10dfd60c12962705b4deba6accc09e6e02..86570b148d66f14a37158fc884d3f8f6900074a3 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/layout/GraphFlowLayouter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java @@ -14,13 +14,16 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common.layout; +package kieker.webgui.service.impl; import java.util.ArrayList; import java.util.List; +import org.springframework.stereotype.Service; + import kieker.webgui.common.exception.InvalidInputSizeException; import kieker.webgui.common.exception.UninitializedGraphException; +import kieker.webgui.service.IGraphLayoutService; import org.eclipse.emf.common.util.EList; @@ -47,12 +50,13 @@ import de.cau.cs.kieler.klay.layered.LayeredLayoutProvider; * * @author row, Nils Christian Ehmke */ -public final class GraphFlowLayouter { +@Service +public final class GraphLayoutServiceImpl implements IGraphLayoutService { /** - * Private constructor as this is a utility class. + * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> */ - private GraphFlowLayouter() { + public GraphLayoutServiceImpl() { // No code necessary } @@ -226,28 +230,18 @@ public final class GraphFlowLayouter { final List<KEdge> edges = new ArrayList<KEdge>(edgeInfo.length / 4); final LayoutInformation layoutInformation = new LayoutInformation(KimlUtil.createInitializedNode(), children, edges); - GraphFlowLayouter.addNodes(positions, layoutInformation); - GraphFlowLayouter.addEdges(edgeInfo, layoutInformation); + GraphLayoutServiceImpl.addNodes(positions, layoutInformation); + GraphLayoutServiceImpl.addEdges(edgeInfo, layoutInformation); return layoutInformation; } - /** - * This method takes two Strings, describing some basic graph information, and constructs a KGraph, which is then layouted by a Kieler algorithm. - * - * @param nodes - * A String containing node dimensions. - * @param edges - * A String containing connection information of edges. - * @return A String of space separated node positions. - * - * @throws UninitializedGraphException - * If the graph has not been initialized yet. - * @throws InvalidInputSizeException - * If the input size is somehow invalid. + /* (non-Javadoc) + * @see kieker.webgui.service.impl.IGraphLayoutService#layoutGraph(java.lang.String, java.lang.String) */ - public static String layoutGraph(final String nodes, final String edges) throws UninitializedGraphException, InvalidInputSizeException { - final LayoutInformation layoutInformation = GraphFlowLayouter.assembleLayoutInformation(nodes, edges); + @Override + public String layoutGraph(final String nodes, final String edges) throws UninitializedGraphException, InvalidInputSizeException { + final LayoutInformation layoutInformation = GraphLayoutServiceImpl.assembleLayoutInformation(nodes, edges); // Create a progress monitor final IKielerProgressMonitor progressMonitor = new BasicProgressMonitor(); @@ -259,8 +253,8 @@ public final class GraphFlowLayouter { layoutProvider.doLayout(layoutInformation.getGraph(), progressMonitor); // convert layouted graph positions to String - final String layoutedGraph = GraphFlowLayouter.getPositions(layoutInformation); - final String bendPoints = GraphFlowLayouter.getBendPoints(layoutInformation); + final String layoutedGraph = GraphLayoutServiceImpl.getPositions(layoutInformation); + final String bendPoints = GraphLayoutServiceImpl.getBendPoints(layoutInformation); return layoutedGraph + "#" + bendPoints; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java index 568abefd277f3268cd3de34ea7b1a8a90f0d1611..02c9e8f36bf23f5058c20f2cf5f7d1eb80bde645 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java @@ -27,13 +27,13 @@ import org.springframework.stereotype.Service; import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.webgui.common.ClassAndMethodContainer; -import kieker.webgui.common.ComponentListContainer; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.ComponentListContainer; import kieker.webgui.persistence.IProjectDAO; import kieker.webgui.service.IProjectService; import kieker.webgui.service.impl.util.ACManager; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java index 23ac51187abc4c73ef90e7ca95936d3c248cc676..7fbfc072510f1a23a1efdf198873a28be11ce7c1 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/UserServiceImpl.java @@ -18,7 +18,6 @@ package kieker.webgui.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import kieker.webgui.common.exception.DataAccessException; @@ -50,7 +49,6 @@ public class UserServiceImpl implements IUserService { * @see kieker.webgui.service.IUserService#addUser(kieker.webgui.domain.User) */ @Override - @PreAuthorize("hasRole('Administrator')") public void addUser(final User user) throws DataAccessException { this.userDAO.addUser(user); } @@ -61,7 +59,6 @@ public class UserServiceImpl implements IUserService { * @see kieker.webgui.service.IUserService#getUsers() */ @Override - @PreAuthorize("hasRole('Administrator')") public List<User> getUsers() throws DataAccessException { return this.userDAO.getUsers(); } @@ -72,7 +69,6 @@ public class UserServiceImpl implements IUserService { * @see kieker.webgui.service.IUserService#deleteUser(kieker.webgui.domain.User) */ @Override - @PreAuthorize("hasRole('Administrator')") public void deleteUser(final User user) throws DataAccessException { this.userDAO.deleteUser(user); } @@ -83,7 +79,6 @@ public class UserServiceImpl implements IUserService { * @see kieker.webgui.service.IUserService#editUser(kieker.webgui.domain.User) */ @Override - @PreAuthorize("hasRole('Administrator')") public void editUser(final User user) throws DataAccessException { this.userDAO.editUser(user); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java index 87c267d4af0b95ceab05df8d051e82f9b424fc5f..11adc57a07743740679b95e086d463c765b3b772 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/package-info.java @@ -15,6 +15,8 @@ ***************************************************************************/ /** + * This package contains the actual implementation of the services. + * * @author Nils Christian Ehmke */ package kieker.webgui.service.impl; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java index bf72d284ba58ad230aa1b15efe00cb9342111d4b..d375d08c40c222515acfde4c5062ef182a5f89f1 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java @@ -36,12 +36,15 @@ import kieker.webgui.common.exception.ProjectLoadException; * @author Nils Christian Ehmke */ public final class Analysis { + private static final Log LOG = LogFactory.getLog(Analysis.class); + private static final long MAX_THREAD_WAIT_TIME_MS = 1000; + private final ClassAndMethodContainer classAndMethodContainer; + private final UpdateDisplaysThread updateDisplaysThread; private final Object analysisController; private final Object analysisControllerThread; - private final UpdateDisplaysThread updateDisplaysThread; /** * Creates a new instance of this class using the given parameters. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java index 9ee712888aaf6dc7ee3545e92a6d676dfd75e2d6..53c03fde196b0fa5b8226a681209f5213f830c9e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/package-info.java @@ -15,6 +15,8 @@ ***************************************************************************/ /** + * This package contains classes used by the service implementation. + * * @author Nils Christian Ehmke */ package kieker.webgui.service.impl.util; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java index ee1129d260b3fc85d5b1b02ee6301e07f60c41f6..b5b19ce0a653723963bcd9aaf1d2dfa2eeb26f61 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java @@ -15,6 +15,8 @@ ***************************************************************************/ /** + * This package contains the interfaces to access the services. + * * @author Nils Christian Ehmke */ package kieker.webgui.service; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java index 6afa88c1ed5e67bbe8feeba5f854964df3581857..2b2f42e7ad40ebd37b78de6fe3e585e6bb81f413 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java @@ -44,7 +44,7 @@ import kieker.webgui.web.beans.view.CurrentProjectOverviewBean; * The {@link ProjectsBean} is a Spring managed bean to manage a list with all application wide available projects. It provides methods to receive this list as well * as methods to add, create, rename, open and copy projects. Furthermore the state of existing projects (like the timestamp or the state of the analysis) can be * received via this bean. In order to realize a good abstraction, this bean should be used for most accesses to the projects. The necessary synchronization is - * achieved in the {@link IProjectManager}.<br> + * achieved in the {@link IProjectService}.<br> * As this bean contains the whole list of the available projects, it is session scoped. There is no reason for multiple instances of this class. * * @author Nils Christian Ehmke @@ -150,7 +150,7 @@ public final class ProjectsBean { /** * This method can be used to open an already existing project. This means that the current state of the project on the file system is loaded into an instance of - * {@link MIProject}. This instance can be modified at will and for example later saved by the {@link IProjectManager}. + * {@link MIProject}. This instance can be modified at will and for example later saved by the {@link IProjectService}. * * @param project * The name of the project to be opened. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java index 768fbc7cd0a65aade07762d2652fc720ff32683a..22d813a1b6b3a802d42f7de750684732c3e1612f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java @@ -42,14 +42,14 @@ import kieker.analysis.model.analysisMetaModel.MIRepositoryConnector; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.ComponentListContainer; -import kieker.webgui.common.IComponentContainer; -import kieker.webgui.common.PluginContainer; -import kieker.webgui.common.RepositoryContainer; import kieker.webgui.common.exception.LibraryLoadException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.ComponentListContainer; +import kieker.webgui.domain.IComponentContainer; +import kieker.webgui.domain.PluginContainer; +import kieker.webgui.domain.RepositoryContainer; import kieker.webgui.service.IProjectService; import kieker.webgui.web.beans.application.GlobalPropertiesBean; import kieker.webgui.web.beans.application.ProjectsBean; @@ -72,8 +72,6 @@ import org.eclipse.emf.ecore.EObject; */ @Component @Scope("view") -// TODO Remove libraries in a clean way -// TODO Receive libraries once as MIDependencies instead of Strings public final class CurrentAnalysisEditorBean { private static final Log LOG = LogFactory.getLog(CurrentAnalysisEditorBean.class); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java index 39a9ae0b6269a1fed11462215c8d1c1ec571fcbf..e4ca8e11696b39bc1e65a7a0f20ed20668f33efc 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorGraphBean.java @@ -20,6 +20,7 @@ import java.util.Map; import javax.faces.context.FacesContext; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -36,7 +37,7 @@ import kieker.common.logging.LogFactory; import kieker.monitoring.core.registry.Registry; import kieker.webgui.common.exception.InvalidInputSizeException; import kieker.webgui.common.exception.UninitializedGraphException; -import kieker.webgui.common.layout.GraphFlowLayouter; +import kieker.webgui.service.IGraphLayoutService; import org.primefaces.context.RequestContext; @@ -160,6 +161,9 @@ public final class CurrentAnalysisEditorGraphBean { private boolean gridEnabled = false; // NOPMD (The field IS accessed later) private boolean snapEnabled = false; // NOPMD (The field IS accessed later) + @Autowired + private IGraphLayoutService layouter; + /** * This map contains all components (plugins, repositories and ports) within the graph to identify them with a unique ID. */ @@ -215,7 +219,7 @@ public final class CurrentAnalysisEditorGraphBean { final String edges = paramMap.get("edges"); // Calculate the layout - final String newLayout = GraphFlowLayouter.layoutGraph(nodes, edges); + final String newLayout = this.layouter.layoutGraph(nodes, edges); // Now use it RequestContext.getCurrentInstance().execute(String.format(CurrentAnalysisEditorGraphBean.JS_CMD_LOAD_FROM_LAYOUT, newLayout)); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java index d16f63c374f6519bb48d86d3cd140b8bcfeaca86..632cd5cc9c518402cecbb3f2cfe32201e0f245e1 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java @@ -60,16 +60,20 @@ public final class CurrentCockpitBean { private static final int NUMBER_COLUMNS = 2; private static final Log LOG = LogFactory.getLog(CurrentCockpitBean.class); - @Autowired - private IProjectService projectService; + private String projectName; private MIProject project; private MIView activeView; private ClassAndMethodContainer classAndMethodContainer; private Dashboard dashboard; private DashboardModel dashboardModel; + + @Autowired + private IProjectService projectService; @Autowired private ProjectsBean projectsBean; + @Autowired + private GlobalPropertiesBean globalPropertiesBean; /** * Creates a new instance of this class. <b>Do not call this constructor manually. It will only be accessed by Spring.</b> @@ -170,7 +174,6 @@ public final class CurrentCockpitBean { * Spring.</b> */ public synchronized void initalize() { - // TODO Replace the log messages with the localizes messages try { // Make sure that the initialization will only be done for the init request. if (!FacesContext.getCurrentInstance().isPostback()) { @@ -183,11 +186,11 @@ public final class CurrentCockpitBean { } } catch (final ProjectNotExistingException ex) { CurrentCockpitBean.LOG.error("An error occured while loading the project.", ex); - GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while loading the project."); + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, this.globalPropertiesBean.getMsgProjectLoadingException()); } catch (final NullPointerException ex) { // This exception occurs, when the projectsBean has not been initialized CurrentCockpitBean.LOG.error("An error occured while loading the project.", ex); - GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while loading the project."); + GlobalPropertiesBean.showMessage(FacesMessage.SEVERITY_ERROR, this.globalPropertiesBean.getMsgProjectLoadingException()); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java index ae1e9aa34dcf6de4842456af73e1420d0dc1ed0b..8253cddf2dcc2a5fdb9ad87f702d57592422f958 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitEditorBean.java @@ -39,12 +39,12 @@ import kieker.analysis.model.analysisMetaModel.MIView; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.ComponentListContainer; -import kieker.webgui.common.PluginContainer; -import kieker.webgui.common.RepositoryContainer; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectNotExistingException; +import kieker.webgui.domain.ComponentListContainer; +import kieker.webgui.domain.PluginContainer; +import kieker.webgui.domain.RepositoryContainer; import kieker.webgui.service.IProjectService; import kieker.webgui.web.beans.application.GlobalPropertiesBean; import kieker.webgui.web.beans.application.ProjectsBean; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/converter/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/converter/package-info.java index 1bfdcb1baeea3329b0bc445c00eb32036b6140c5..828c35051ee3effb48add46e91e077f0f39a1e07 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/converter/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/converter/package-info.java @@ -15,7 +15,8 @@ ***************************************************************************/ /** + * This package contains the JSF converters. + * * @author Nils Christian Ehmke - * */ package kieker.webgui.web.converter; \ No newline at end of file diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fe8e6bc524b079d2baaec27e535f0d32b8a0d508 --- /dev/null +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.common; + +import java.io.IOException; +import java.net.URL; + +import org.junit.Assert; +import org.junit.Test; + +import kieker.webgui.common.exception.ProjectLoadException; +import kieker.webgui.persistence.impl.util.CloseableURLClassLoader; + +/** + * Test class for {@link ClassAndMethodContainer}. + * + * @author Nils Christian Ehmke + */ +public class ClassAndMethodContainerTest { + + private static final String KIEKER_LIB = "kieker-1.7-SNAPSHOT_emf.jar"; + + /** + * Default constructor. <b>Do not use this constructor. This is just a test class and not to be used outside a JUnit test!</b> + */ + public ClassAndMethodContainerTest() { + // No code necessary + } + + /** + * A test of this test class. + */ + @Test + public void testKiekerAvailable() { + final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(ClassAndMethodContainerTest.KIEKER_LIB); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); + + // If this fails, we know that kieker is not available here + try { + new ClassAndMethodContainer(classLoader); + } catch (final ProjectLoadException ex) { + Assert.fail("Kieker dependency not available."); + } + + try { + classLoader.close(); + } catch (final IOException ex) { + Assert.fail("An exception occured while closing the classloader."); + } + } + +} diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/common/EnvironmentLoaderListenerTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/common/EnvironmentLoaderListenerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..723344f2f32a04581f9353c2190999a8534401c6 --- /dev/null +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/common/EnvironmentLoaderListenerTest.java @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.common; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Test class for {@link EnvironmentLoaderListener}. + * + * @author Nils Christian Ehmke + */ +public class EnvironmentLoaderListenerTest { + + /** + * Default constructor. <b>Do not use this constructor. This is just a test class and not to be used outside a JUnit test!</b> + */ + public EnvironmentLoaderListenerTest() { + // No code necessary + } + + /** + * A test of this test class. + */ + @Test + public void testSystemPropertySet() { + final EnvironmentLoaderListener listener = new EnvironmentLoaderListener(); + Assert.assertNull("System property already set.", System.getProperty("kieker.common.logging.Log")); + listener.contextInitialized(null); + Assert.assertEquals("System property not set.", "WEBGUI", System.getProperty("kieker.common.logging.Log")); + } + +} diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/util/PluginFinderTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/util/PluginFinderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..66eaa8ff00fc964f04461c501415700c5373dfc1 --- /dev/null +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/util/PluginFinderTest.java @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.persistence.impl.util; + +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; + +import kieker.analysis.plugin.AbstractPlugin; +import kieker.analysis.repository.AbstractRepository; +import kieker.webgui.common.ClassAndMethodContainer; + +/** + * Test class for {@link PluginFinder}. + * + * @author Nils Christian Ehmke + */ +public class PluginFinderTest { + + private static final String KIEKER_LIB = "kieker-1.7-SNAPSHOT_emf.jar"; + + /** + * Default constructor. <b>Do not use this constructor. This is just a test class and not to be used outside a JUnit test!</b> + */ + public PluginFinderTest() { + // No code necessary + } + + /** + * A test of this test class. + */ + @Test + public void testKiekerPlugins() { + final PluginFinder pluginFinder = new PluginFinder(); + final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(PluginFinderTest.KIEKER_LIB); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); + final ClassAndMethodContainer classAndMethodContainer = new ClassAndMethodContainer(classLoader); + + try { + final List<Class<AbstractPlugin>> plugins = pluginFinder.getAllPluginsWithinJar(kiekerURL, classLoader, classAndMethodContainer); + final List<Class<AbstractRepository>> repositories = pluginFinder.getAllRepositoriesWithinJar(kiekerURL, classLoader, classAndMethodContainer); + + // There should be at least one element of both types + Assert.assertFalse("No plugins found.", plugins.isEmpty()); + Assert.assertFalse("No repositories found.", repositories.isEmpty()); + + classLoader.close(); + } catch (final IOException ex) { + Assert.fail("An exception occured while testing the existence of plugins and repositories."); + } + } + +} diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/web/converter/RoleStringConverterTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/web/converter/RoleStringConverterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1b8ea30b4c8ddbb830c198b107a1085eccb84f5c --- /dev/null +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/web/converter/RoleStringConverterTest.java @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright 2012 Kieker Project (http://kieker-monitoring.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.web.converter; + +import org.junit.Assert; +import org.junit.Test; + +import kieker.webgui.domain.User.Role; + +/** + * Test class for {@link RoleStringConverter}. + * + * @author Nils Christian Ehmke + */ +public class RoleStringConverterTest { + + /** + * Default constructor. <b>Do not use this constructor. This is just a test class and not to be used outside a JUnit test!</b> + */ + public RoleStringConverterTest() { + // No code necessary + } + + /** + * A test of this test class. + */ + @Test + public void testEqualAsString() { + final RoleStringConverter converter = new RoleStringConverter(); + + Assert.assertEquals("Conversion failed.", Role.ROLE_ADMIN.toString(), converter.getAsString(null, null, Role.ROLE_ADMIN)); + Assert.assertEquals("Conversion failed.", Role.ROLE_GUEST.toString(), converter.getAsString(null, null, Role.ROLE_GUEST)); + Assert.assertEquals("Conversion failed.", Role.ROLE_USER.toString(), converter.getAsString(null, null, Role.ROLE_USER)); + } + + /** + * A test of this test class. + */ + @Test + public void testNotEqualAsString() { + final RoleStringConverter converter = new RoleStringConverter(); + + Assert.assertNotSame("Conversion failed.", Role.ROLE_ADMIN, converter.getAsString(null, null, Role.ROLE_USER)); + Assert.assertNotSame("Conversion failed.", Role.ROLE_ADMIN, converter.getAsString(null, null, Role.ROLE_GUEST)); + + Assert.assertNotSame("Conversion failed.", Role.ROLE_GUEST, converter.getAsString(null, null, Role.ROLE_ADMIN)); + Assert.assertNotSame("Conversion failed.", Role.ROLE_GUEST, converter.getAsString(null, null, Role.ROLE_USER)); + + Assert.assertNotSame("Conversion failed.", Role.ROLE_USER, converter.getAsString(null, null, Role.ROLE_GUEST)); + Assert.assertNotSame("Conversion failed.", Role.ROLE_USER, converter.getAsString(null, null, Role.ROLE_ADMIN)); + } + + /** + * A test of this test class. + */ + @Test + public void testEqualFromString() { + final RoleStringConverter converter = new RoleStringConverter(); + + Assert.assertEquals("Conversion failed.", Role.ROLE_ADMIN, converter.getAsObject(null, null, Role.ROLE_ADMIN.toString())); + Assert.assertEquals("Conversion failed.", Role.ROLE_GUEST, converter.getAsObject(null, null, Role.ROLE_GUEST.toString())); + Assert.assertEquals("Conversion failed.", Role.ROLE_USER, converter.getAsObject(null, null, Role.ROLE_USER.toString())); + } + + /** + * A test of this test class. + */ + @Test + public void testNotEqualFromString() { + final RoleStringConverter converter = new RoleStringConverter(); + + Assert.assertNotSame("Conversion failed.", Role.ROLE_ADMIN, converter.getAsObject(null, null, Role.ROLE_USER.toString())); + Assert.assertNotSame("Conversion failed.", Role.ROLE_ADMIN, converter.getAsObject(null, null, Role.ROLE_GUEST.toString())); + + Assert.assertNotSame("Conversion failed.", Role.ROLE_GUEST, converter.getAsObject(null, null, Role.ROLE_ADMIN.toString())); + Assert.assertNotSame("Conversion failed.", Role.ROLE_GUEST, converter.getAsObject(null, null, Role.ROLE_USER.toString())); + + Assert.assertNotSame("Conversion failed.", Role.ROLE_USER, converter.getAsObject(null, null, Role.ROLE_GUEST.toString())); + Assert.assertNotSame("Conversion failed.", Role.ROLE_USER, converter.getAsObject(null, null, Role.ROLE_ADMIN.toString())); + } +}