diff --git a/.metadata/.log b/.metadata/.log deleted file mode 100644 index 93d3e86a61..0000000000 --- a/.metadata/.log +++ /dev/null @@ -1,253 +0,0 @@ - -!ENTRY org.eclipse.core.resources 4 2 2014-10-16 20:42:46.953 -!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources". -!STACK 0 -java.lang.IllegalStateException: Registry Directory not available: /Users/Elena/tutorials/.metadata/.plugins/org.eclipse.pde.core/.p2/org.eclipse.equinox.p2.engine/profileRegistry. - at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.restore(SimpleProfileRegistry.java:480) - at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfileMap(SimpleProfileRegistry.java:338) - at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfiles(SimpleProfileRegistry.java:320) - at org.eclipse.pde.internal.core.target.P2TargetUtils.cleanOrphanedTargetDefinitionProfiles(P2TargetUtils.java:168) - at org.eclipse.pde.internal.core.PDECore$1.saving(PDECore.java:274) - at org.eclipse.core.internal.resources.SaveManager.executeLifecycle(SaveManager.java:383) - at org.eclipse.core.internal.resources.SaveManager$1.run(SaveManager.java:192) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.core.internal.resources.SaveManager.broadcastLifecycle(SaveManager.java:195) - at org.eclipse.core.internal.resources.SaveManager.save(SaveManager.java:1130) - at org.eclipse.core.internal.resources.Workspace.save(Workspace.java:2376) - at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor$5.run(IDEWorkbenchAdvisor.java:508) - at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) - -!ENTRY org.eclipse.ui.ide 4 4 2014-10-16 20:42:55.472 -!MESSAGE Problems saving workspace - -!ENTRY org.eclipse.ui.ide 4 1 2014-10-16 20:42:55.472 -!MESSAGE Problems occurred while trying to save the state of the workbench. -!SUBENTRY 1 org.eclipse.core.resources 4 568 2014-10-16 20:42:55.472 -!MESSAGE Could not write workspace metadata '/Users/Elena/tutorials/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree'. -!STACK 0 -java.io.FileNotFoundException: /Users/Elena/tutorials/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree (No such file or directory) - at java.io.FileOutputStream.open(Native Method) - at java.io.FileOutputStream.(FileOutputStream.java:213) - at java.io.FileOutputStream.(FileOutputStream.java:162) - at org.eclipse.core.internal.localstore.SafeFileOutputStream.(SafeFileOutputStream.java:51) - at org.eclipse.core.internal.resources.SaveManager.saveTree(SaveManager.java:1352) - at org.eclipse.core.internal.resources.SaveManager.save(SaveManager.java:1134) - at org.eclipse.core.internal.resources.Workspace.save(Workspace.java:2376) - at org.eclipse.ui.internal.ide.application.IDEWorkbenchAdvisor$5.run(IDEWorkbenchAdvisor.java:508) - at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121) -!SESSION 2014-10-16 20:43:17.092 ----------------------------------------------- -eclipse.buildId=4.3.2.M20140221-1700 -java.version=1.8.0_20 -java.vendor=Oracle Corporation -BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=es_ES -Framework arguments: -product org.eclipse.epp.package.standard.product -keyring /Users/Elena/.eclipse_keyring -showlocation -Command-line arguments: -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.standard.product -keyring /Users/Elena/.eclipse_keyring -showlocation - -!ENTRY org.eclipse.core.net 1 0 2014-10-16 20:43:52.743 -!MESSAGE System property http.nonProxyHosts has been set to local|*.local|169.254/16|*.169.254/16 by an external source. This value will be overwritten using the values from the preferences - -!ENTRY org.eclipse.jface 2 0 2014-10-16 20:43:53.942 -!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation. -!SUBENTRY 1 org.eclipse.jface 2 0 2014-10-16 20:43:53.943 -!MESSAGE A conflict occurred for COMMAND+SHIFT+F10: -Binding(COMMAND+SHIFT+F10, - ParameterizedCommand(Command(org.jboss.tools.common.ui.RegisterAsService,Register As Service, - Adds class name to META-INF/services/%serviceType% file after service type is selected in the dialog from types extended and implemented by the class., - Category(org.eclipse.ui.category.file,File,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@2df3545d, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -Binding(COMMAND+SHIFT+F10, - ParameterizedCommand(Command(org.eclipse.ui.window.showSystemMenu,Show System Menu, - Show the system menu, - Category(org.eclipse.ui.category.window,Window,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@75ad30c1, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,cocoa,system) -!SUBENTRY 1 org.eclipse.jface 2 0 2014-10-16 20:43:53.943 -!MESSAGE A conflict occurred for ALT+COMMAND+Z: -Binding(ALT+COMMAND+Z, - ParameterizedCommand(Command(org.jboss.tools.cdi.ui.open.namedBean,Open CDI Named Bean, - Open CDI Named Bean, - Category(org.eclipse.ui.category.navigate,Navigate,null,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@fe8aaeb, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,,system) -Binding(ALT+COMMAND+Z, - ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.surround.with.quickMenu,Surround With Quick Menu, - Shows the Surround With quick menu, - Category(org.eclipse.jdt.ui.category.source,Source,Java Source Actions,true), - org.eclipse.ui.internal.WorkbenchHandlerServiceHandler@6b9697ae, - ,,true),null), - org.eclipse.ui.defaultAcceleratorConfiguration, - org.eclipse.ui.contexts.window,,cocoa,system) - -!ENTRY com.android.ide.eclipse.adt 1 0 2014-10-16 20:44:03.016 -!MESSAGE No valid Android XML Editor Delegate found for file /handling-spring-static-resources/pom.xml [Res null, type null] - -!ENTRY org.eclipse.e4.ui.workbench 4 0 2014-10-16 20:44:06.875 -!MESSAGE -!STACK 0 -org.eclipse.core.runtime.AssertionFailedException: assertion failed: - at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110) - at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96) - at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1081) - at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:607) - at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:362) - at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:142) - at org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor.createPartControl(CompatibilityEditor.java:96) - at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:323) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) - at java.lang.reflect.Method.invoke(Method.java:483) - at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56) - at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:877) - at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:857) - at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:119) - at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333) - at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254) - at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162) - at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102) - at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71) - at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53) - at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer.showTab(StackRenderer.java:1147) - at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:96) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:649) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$6.run(PartRenderingEngine.java:526) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:511) - at org.eclipse.e4.ui.workbench.renderers.swt.ElementReferenceRenderer.createWidget(ElementReferenceRenderer.java:61) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) - at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer.processContents(PerspectiveRenderer.java:59) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:103) - at org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.postProcess(LazyStackRenderer.java:96) - at org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.postProcess(PerspectiveStackRenderer.java:77) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:649) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.workbench.renderers.swt.SWTPartRenderer.processContents(SWTPartRenderer.java:62) - at org.eclipse.e4.ui.workbench.renderers.swt.WBWRenderer.processContents(WBWRenderer.java:581) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:645) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:735) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.access$2(PartRenderingEngine.java:706) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$7.run(PartRenderingEngine.java:700) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:685) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1042) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) - at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140) - at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611) - at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) - at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) - at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) - at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) - at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) - at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) - at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) - at java.lang.reflect.Method.invoke(Method.java:483) - at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) - at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) - at org.eclipse.equinox.launcher.Main.run(Main.java:1450) - -!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2014-10-16 20:44:08.029 -!MESSAGE Could not load repository template extension contributed by org.eclipse.mylyn.bugzilla.ide with connectorKind bugzilla - -!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2014-10-16 20:44:08.029 -!MESSAGE Could not load repository template extension contributed by org.springsource.ide.eclipse.dashboard.ui with connectorKind jira - -!ENTRY org.eclipse.mylyn.tasks.ui 4 0 2014-10-16 20:44:08.030 -!MESSAGE Could not load repository template extension contributed by org.springsource.ide.eclipse.dashboard.ui with connectorKind jira - -!ENTRY org.eclipse.ui.workbench 4 2 2014-10-16 20:44:30.651 -!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench". -!STACK 0 -java.lang.NullPointerException - at org.springframework.ide.eclipse.maven.internal.legacyconversion.LegacyProjectChecker.earlyStartup(LegacyProjectChecker.java:36) - at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87) - at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:66) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2555) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) - -!ENTRY org.eclipse.ui 4 4 2014-10-16 20:44:30.663 -!MESSAGE Unhandled Exception - -!ENTRY org.springframework.ide.eclipse.maven 4 0 2014-10-16 20:44:30.663 -!MESSAGE Unable to execute early startup code for an extension -!STACK 0 -java.lang.NullPointerException - at org.springframework.ide.eclipse.maven.internal.legacyconversion.LegacyProjectChecker.earlyStartup(LegacyProjectChecker.java:36) - at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87) - at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:66) - at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) - at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2555) - at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) diff --git a/.metadata/.mylyn/.taskListIndex/segments.gen b/.metadata/.mylyn/.taskListIndex/segments.gen deleted file mode 100644 index 63a7ec9a3c..0000000000 Binary files a/.metadata/.mylyn/.taskListIndex/segments.gen and /dev/null differ diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 deleted file mode 100644 index 6b350b10f4..0000000000 Binary files a/.metadata/.mylyn/.taskListIndex/segments_1 and /dev/null differ diff --git a/.metadata/.mylyn/repositories.xml.zip b/.metadata/.mylyn/repositories.xml.zip deleted file mode 100644 index 0f05d185fc..0000000000 Binary files a/.metadata/.mylyn/repositories.xml.zip and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap deleted file mode 100644 index 91d6c54151..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap b/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap deleted file mode 100644 index 91d6c54151..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/RemoteSystemsTempFiles/.syncinfo.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.jdt.core/state.dat deleted file mode 100644 index 1b30d3ec25..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.jdt.core/state.dat and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.wst.jsdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.wst.jsdt.core/state.dat deleted file mode 100644 index ec85483841..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.projects/handling-spring-static-resources/org.eclipse.wst.jsdt.core/state.dat and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version deleted file mode 100644 index 25cb955ba2..0000000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index deleted file mode 100644 index 3931c81cf2..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version deleted file mode 100644 index 6b2aaa7640..0000000000 --- a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap b/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap deleted file mode 100644 index 91d6c54151..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/.markers.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree deleted file mode 100644 index 693f619ff9..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources deleted file mode 100644 index 4d3c581705..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.snap b/.metadata/.plugins/org.eclipse.core.resources/.snap deleted file mode 100644 index 156857881f..0000000000 Binary files a/.metadata/.plugins/org.eclipse.core.resources/.snap and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi deleted file mode 100644 index 6c1bf27179..0000000000 --- a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ /dev/null @@ -1,3889 +0,0 @@ - - - - activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration - ModelMigrationProcessor.001 - - - - - - topLevel - - - Minimized - MinimizedByZoom - - - persp.actionSet:ajrefactoring - persp.actionSet:org.eclipse.contribution.xref.ui.XRefActionSet - persp.actionSet:org.eclipse.mylyn.context.ui.actionSet - persp.actionSet:org.eclipse.mylyn.doc.actionSet - persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation - persp.actionSet:org.eclipse.ui.cheatsheets.actionSet - persp.actionSet:org.eclipse.rse.core.search.searchActionSet - persp.actionSet:org.eclipse.search.searchActionSet - persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation - persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation - persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo - persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet - persp.actionSet:org.eclipse.ui.actionSet.keyBindings - persp.actionSet:org.eclipse.ui.actionSet.openFiles - persp.actionSet:org.jboss.ide.eclipse.archives.ui.actions.Archives - persp.actionSet:org.jboss.tools.jst.web.ui.server.actionSet - persp.actionSet:org.jboss.tools.central - persp.actionSet:org.jboss.tools.common.model.ui.actionSet - persp.actionSet:org.springframework.ide.eclipse.aop.ui.ActionSet - persp.actionSet:org.springframework.ide.eclipse.aop.ui.matcher.actionSet - persp.actionSet:org.springframework.ide.eclipse.beans.ui.actionSet - persp.actionSet:org.springframework.ide.eclipse.beans.search.actionSet - persp.actionSet:org.springsource.ide.eclipse.quicksearch.actionSet - persp.actionSet:org.springsource.ide.eclipse.commons.launch.actionSet - persp.actionSet:com.springsource.sts.ide.ui.actionSet.workbench - persp.actionSet:org.eclipse.debug.ui.launchActionSet - persp.actionSet:org.eclipse.jdt.ui.JavaActionSet - persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet - persp.actionSet:org.eclipse.ui.NavigateActionSet - persp.viewSC:org.eclipse.jdt.ui.PackageExplorer - persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy - persp.viewSC:org.eclipse.jdt.ui.SourceView - persp.viewSC:org.eclipse.jdt.ui.JavadocView - persp.viewSC:org.eclipse.search.ui.views.SearchView - persp.viewSC:org.eclipse.ui.console.ConsoleView - persp.viewSC:org.eclipse.ui.views.ContentOutline - persp.viewSC:org.eclipse.ui.views.ProblemView - persp.viewSC:org.eclipse.ui.views.ResourceNavigator - persp.viewSC:org.eclipse.ui.views.TaskList - persp.viewSC:org.eclipse.ui.views.ProgressView - persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer - persp.viewSC:org.eclipse.ui.texteditor.TemplatesView - persp.viewSC:org.eclipse.pde.runtime.LogView - persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard - persp.newWizSC:org.eclipse.ui.wizards.new.folder - persp.newWizSC:org.eclipse.ui.wizards.new.file - persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard - persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective - persp.perspSC:org.eclipse.debug.ui.DebugPerspective - persp.newWizSC:com.android.ide.eclipse.adt.project.NewProjectWizard - persp.newWizSC:com.android.ide.eclipse.editors.wizards.NewXmlFileWizard - persp.actionSet:adt.actionSet.wizards - persp.actionSet:adt.actionSet.avdManager - persp.actionSet:adt.actionSet.lint - persp.actionSet:adt.actionSet.refactorings - persp.perspSC:com.android.ide.eclipse.ddms.Perspective - persp.perspSC:com.android.ide.eclipse.hierarchyviewer.PixelPerfectPespective - persp.perspSC:com.android.ide.eclipse.hierarchyviewer.TreeViewPerspective - persp.actionSet:ajelementCreation - persp.newWizSC:ajaspectwizard - persp.newWizSC:ajprojectwizard - persp.perspSC:org.eclipse.ajdt.ui.visualiser.AspectVisualizationPerspective - persp.viewSC:org.eclipse.ant.ui.views.AntView - persp.perspSC:org.eclipse.birt.report.designer.ui.ReportPerspective - persp.newWizSC:org.eclipse.birt.report.designer.ui.ide.wizards.NewReportWizard - persp.newWizSC:org.eclipse.birt.report.designer.ui.ide.wizards.NewTemplateWizard - persp.newWizSC:org.eclipse.birt.report.designer.ui.wizards.NewLibraryWizard - persp.showIn:org.eclipse.egit.ui.RepositoriesView - persp.actionSet:org.eclipse.debug.ui.breakpointActionSet - persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet - persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard - persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet - persp.showIn:org.eclipse.jdt.ui.PackageExplorer - persp.showIn:org.eclipse.team.ui.GenericHistoryView - persp.showIn:org.eclipse.ui.views.ResourceNavigator - persp.showIn:org.eclipse.ui.navigator.ProjectExplorer - persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks - persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task - persp.perspSC:org.eclipse.wst.jsdt.ui.JavaPerspective - persp.actionSet:org.hibernate.eclipse.launch.actionset - persp.showIn:org.jboss.tools.forge.ui.view - persp.perspSC:org.jboss.tools.jst.web.ui.WebDevelopmentPerspective - persp.viewSC:org.jboss.tools.common.model.ui.navigator.NavigatorViewPart - persp.viewSC:org.springframework.ide.eclipse.aop.ui.navigator.aopReferenceModelNavigator - persp.viewSC:org.springframework.ide.eclipse.aop.ui.tracing.eventTraceView - persp.newWizSC:org.springframework.ide.eclipse.beans.ui.wizards.newBeansConfig - persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard - persp.newWizSC:com.springsource.sts.roo.ui.wizard.newRooProjectWizard - persp.showIn:org.springframework.ide.eclipse.ui.navigator.springExplorer - persp.viewSC:org.springframework.ide.eclipse.ui.navigator.springExplorer - persp.newWizSC:org.springframework.ide.eclipse.webflow.ui.wizard.newWebflowConfigWizard - persp.newWizSC:com.springsource.sts.wizard.template - persp.newWizSC:org.springsource.ide.eclipse.commons.gettingstarted.wizard.boot.NewSpringBootWizard - persp.newWizSC:org.springsource.ide.eclipse.gettingstarted.wizards.import.generic.newalias - - - - newtablook - org.eclipse.e4.primaryNavigationStack - - - - - - - - newtablook - - - - - - - - - - newtablook - - - - - - newtablook - org.eclipse.e4.secondaryNavigationStack - - - - - - newtablook - - - - - newtablook - - - - - - newtablook - - - - - - newtablook - org.eclipse.e4.secondaryDataStack - - - - - - - - - - - - - - - - active - Maximized - - - - - - - View - categoryTag:Help - - - View - categoryTag:General - active - - ViewMenu - menuContribution:menu - - - - - View - categoryTag:Help - - - - newtablook - org.eclipse.e4.primaryDataStack - EditorStack - - - Editor - org.eclipse.wst.server.ui.editor - removeOnHide - - - - Editor - com.android.ide.eclipse.editors.CommonXmlEditor - removeOnHide - - - - Editor - com.android.ide.eclipse.editors.CommonXmlEditor - removeOnHide - - - - Editor - com.android.ide.eclipse.editors.CommonXmlEditor - removeOnHide - - - - Editor - com.android.ide.eclipse.editors.CommonXmlEditor - removeOnHide - - - - Editor - com.android.ide.eclipse.editors.CommonXmlEditor - removeOnHide - - - - Editor - com.android.ide.eclipse.editors.CommonXmlEditor - removeOnHide - - - - - - View - categoryTag:Java - - ViewMenu - menuContribution:menu - - - - - View - categoryTag:Java - - - View - categoryTag:General - - - View - categoryTag:General - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - View - categoryTag:Java - - - - View - categoryTag:Java - - ViewMenu - menuContribution:menu - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - View - categoryTag:General - - - View - categoryTag:General - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - View - categoryTag:General - - - View - categoryTag:Ant - - - View - categoryTag:AspectJ - - - View - categoryTag:Git - - - View - categoryTag:Java - - - - View - categoryTag:Mylyn - - ViewMenu - menuContribution:menu - - - - - View - categoryTag:Spring - - - - View - categoryTag:Spring - - ViewMenu - menuContribution:menu - - - - - - View - categoryTag:Server - - ViewMenu - menuContribution:menu - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - toolbarSeparator - - - - Draggable - - - - - - - - - - - - - - - toolbarSeparator - - - - Draggable - - - - - - Draggable - - - - - Draggable - - - - - Draggable - - - - - Draggable - - - - - - - - - - - Draggable - - - - - - - - Draggable - - - - - - - - Draggable - - - - - - - Draggable - - - - - - - - - - toolbarSeparator - - - - Draggable - - - - - - - - - - - - toolbarSeparator - - - - toolbarSeparator - - - - Draggable - - - - - - stretch - - - glue - - - - glue - - - Draggable - - - - - stretch - - - - Draggable - - - - - - TrimStack - - - - - - - - - - - - - platform:cocoa - - - - - - - - - - platform:cocoa - - - - - - - - - - - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - - - platform:cocoa - - - - - platform:cocoa - - - - - platform:cocoa - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - - - - - - - platform:cocoa - - - - - - - - - - - - platform:cocoa - - - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - - - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - - - - - - - - - - - - - - - - - - - - - platform:cocoa - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - - - platform:cocoa - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - - platform:cocoa - - - - - - - - - - platform:cocoa - - - - - platform:cocoa - - - - platform:cocoa - - - - - - - - - - - - platform:cocoa - - - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - platform:cocoa - - - - - - - - - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - - - - platform:cocoa - - - - - - - - - platform:cocoa - - - - - - - platform:cocoa - - - - platform:cocoa - - - - - - - - - - platform:cocoa - - - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - - - - - - - - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - - - platform:cocoa - - - - - platform:cocoa - - - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - - - - - platform:cocoa - - - - - platform:cocoa - - - - platform:cocoa - - - - - - - platform:cocoa - - - platform:cocoa - - - - - - - - - - - - - platform:cocoa - - - platform:cocoa - - - - - - - - - - - - - - - - - platform:cocoa - - - platform:cocoa - - - - - platform:cocoa - - - - platform:cocoa - - - - - - platform:cocoa - - - - platform:cocoa - - - - - - platform:cocoa - - - - - platform:cocoa - - - platform:cocoa - - - - - - - - platform:cocoa - - - - - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - - - - - - - - - - - platform:cocoa - - - - - - - platform:cocoa - - - - - - - - platform:cocoa - - - - - platform:cocoa - - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - platform:cocoa - - - - - platform:cocoa - - - - - platform:cocoa - - - - - platform:cocoa - - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - platform:cocoa - - - - - platform:cocoa - - - - - - - - platform:cocoa - - - - - - - - - - - - - - - - - - - - - - - - - - platform:cocoa - - - - - - - - - platform:cocoa - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - platform:cocoa - - - - platform:cocoa - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Editor - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Tracer for OpenGL ES - - - View - categoryTag:Tracer for OpenGL ES - - - View - categoryTag:Tracer for OpenGL ES - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:Android - - - View - categoryTag:AspectJ - - - View - categoryTag:Ant - - - View - categoryTag:Report Design - - - View - categoryTag:Report Design - - - View - categoryTag:Report Design - - - View - categoryTag:&C/C++ - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Make - - - View - categoryTag:&C/C++ - - - View - categoryTag:&C/C++ - - - View - categoryTag:&C/C++ - - - View - categoryTag:&C/C++ - - - View - categoryTag:&C/C++ - - - View - categoryTag:General - - - View - categoryTag:Visualiser - - - View - categoryTag:Visualiser - - - View - categoryTag:AspectJ - - - View - categoryTag:Data Management - - - View - categoryTag:Data Management - - - View - categoryTag:Data Management - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Debug - - - View - categoryTag:Git - - - View - categoryTag:Git - - - View - categoryTag:Git - - - View - categoryTag:Git - - - View - categoryTag:Git - - - View - categoryTag:General - - - View - categoryTag:Help - - - View - categoryTag:JPA - - - View - categoryTag:JPA - - - View - categoryTag:JavaServer Faces - - - View - categoryTag:JavaServer Faces - - - View - categoryTag:Maven - - - View - categoryTag:Maven - - - View - categoryTag:Mylyn - - - View - categoryTag:Mylyn - - - View - categoryTag:Mylyn - - - View - categoryTag:API Tools - - - View - categoryTag:Plug-in Development - - - View - categoryTag:Plug-in Development - - - View - categoryTag:Plug-in Development - - - View - categoryTag:Plug-in Development - - - View - categoryTag:Plug-in Development - - - View - categoryTag:Remote Systems - - - View - categoryTag:Remote Systems - - - View - categoryTag:Remote Systems - - - View - categoryTag:Remote Systems - - - View - categoryTag:Remote Systems - - - View - categoryTag:Remote Systems - - - View - categoryTag:Remote Systems - - - View - categoryTag:Remote Systems - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:CVS - - - View - categoryTag:CVS - - - View - categoryTag:Team - - - View - categoryTag:Team - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:Help - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:Debug - - - View - categoryTag:JavaScript - - - View - categoryTag:JavaScript - - - View - categoryTag:JavaScript - - - View - categoryTag:JavaScript - - - View - categoryTag:JavaScript - - - View - categoryTag:Server - - - View - categoryTag:XML - - - View - categoryTag:XML - - - View - categoryTag:Hibernate - - - View - categoryTag:Hibernate - - - View - categoryTag:Hibernate - - - View - categoryTag:Hibernate - - - View - categoryTag:JBoss Tools - - - View - categoryTag:Server - - - View - categoryTag:Forge - - - View - categoryTag:JMX - - - View - categoryTag:JBoss Tools Web - - - View - categoryTag:JBoss Tools Web - - - View - categoryTag:JBoss Tools Web - - - View - categoryTag:JBoss Tools - - - View - categoryTag:Seam - - - View - categoryTag:JBoss Tools Web Services - - - View - categoryTag:Spring - - - View - categoryTag:Spring - - - View - categoryTag:Spring - - - View - categoryTag:Spring - - - View - categoryTag:Spring - - - View - categoryTag:Spring - - - View - categoryTag:Spring - - - View - categoryTag:Debug - - - View - categoryTag:Java - - - View - categoryTag:Java - - - View - categoryTag:Java - - - View - categoryTag:Java Browsing - - - View - categoryTag:Java Browsing - - - View - categoryTag:Java Browsing - - - View - categoryTag:Java Browsing - - - View - categoryTag:Java - - - View - categoryTag:Java - - - View - categoryTag:Java - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache deleted file mode 100644 index dd4af88111..0000000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps b/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps deleted file mode 100644 index 80b5f91d54..0000000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt b/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt deleted file mode 100644 index 32e47edfaf..0000000000 --- a/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt +++ /dev/null @@ -1 +0,0 @@ -INDEX VERSION 1.127 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache b/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache deleted file mode 100644 index 593f4708db..0000000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/invalidArchivesCache and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt deleted file mode 100644 index 4644f71d79..0000000000 --- a/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt +++ /dev/null @@ -1,2 +0,0 @@ -aj -java \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache deleted file mode 100644 index d3473153f2..0000000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt deleted file mode 100644 index 3af5ad5b80..0000000000 --- a/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt +++ /dev/null @@ -1,23 +0,0 @@ -INDEX VERSION 1.127+/Users/Elena/tutorials/.metadata/.plugins/org.eclipse.jdt.core -4249315662.index -1271342938.index -272178059.index -3712507179.index -2996324989.index -1833648217.index -3302703152.index -450555687.index -4238209716.index -3954040986.index -1819685514.index -770573466.index -156905802.index -3004609673.index -2545238116.index -2326659272.index -3266567714.index -1384487945.index -84777399.index -3000285004.index -765977872.index -3321539481.index diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat deleted file mode 100644 index e91b239486..0000000000 Binary files a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml deleted file mode 100644 index 81c4e135f3..0000000000 --- a/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml deleted file mode 100644 index a4ee3cbc9a..0000000000 --- a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml deleted file mode 100644 index 9e390f501d..0000000000 --- a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml deleted file mode 100644 index a67b723f21..0000000000 --- a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml +++ /dev/null @@ -1,13 +0,0 @@ - -
-
- - - - - -
-
- -
-
diff --git a/.metadata/.plugins/org.eclipse.jst.jsp.core/taglibindex/2996324989.dat b/.metadata/.plugins/org.eclipse.jst.jsp.core/taglibindex/2996324989.dat deleted file mode 100644 index 9f3dde8c83..0000000000 Binary files a/.metadata/.plugins/org.eclipse.jst.jsp.core/taglibindex/2996324989.dat and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml deleted file mode 100644 index aa26784293..0000000000 --- a/.metadata/.plugins/org.eclipse.ltk.ui.refactoring/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser deleted file mode 100644 index a02fb4650f..0000000000 Binary files a/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties b/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties deleted file mode 100644 index b8528c313e..0000000000 --- a/.metadata/.plugins/org.eclipse.pde.core/.cache/clean-cache.properties +++ /dev/null @@ -1,2 +0,0 @@ -#Cached timestamps -#Thu Oct 16 20:42:58 PET 2014 diff --git a/.metadata/.plugins/org.eclipse.rse.core/.log b/.metadata/.plugins/org.eclipse.rse.core/.log deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark b/.metadata/.plugins/org.eclipse.rse.core/initializerMarks/org.eclipse.rse.internal.core.RSELocalConnectionInitializer.mark deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/FP.local.files_0/node.properties b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/FP.local.files_0/node.properties deleted file mode 100644 index 1fd82a90dd..0000000000 --- a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/FP.local.files_0/node.properties +++ /dev/null @@ -1,57 +0,0 @@ -# RSE DOM Node -00-name=MacBook-Pro-de-Elena-Garcia-Miro-P\:local.files -01-type=FilterPool -03-attr.default=true -03-attr.deletable=true -03-attr.id=local.files -03-attr.nonRenamable=false -03-attr.owningParentName=null -03-attr.release=200 -03-attr.singleFilterStringOnly=false -03-attr.singleFilterStringOnlyESet=false -03-attr.stringsCaseSensitive=true -03-attr.supportsDuplicateFilterStrings=false -03-attr.supportsNestedFilters=true -03-attr.type=default -06-child.00000.00-name=My Home -06-child.00000.01-type=Filter -06-child.00000.03-attr.default=false -06-child.00000.03-attr.filterType=default -06-child.00000.03-attr.id=My Home -06-child.00000.03-attr.nonChangable=false -06-child.00000.03-attr.nonDeletable=false -06-child.00000.03-attr.nonRenamable=false -06-child.00000.03-attr.promptable=false -06-child.00000.03-attr.relativeOrder=0 -06-child.00000.03-attr.release=200 -06-child.00000.03-attr.singleFilterStringOnly=false -06-child.00000.03-attr.stringsCaseSensitive=true -06-child.00000.03-attr.stringsNonChangable=false -06-child.00000.03-attr.supportsDuplicateFilterStrings=false -06-child.00000.03-attr.supportsNestedFilters=true -06-child.00000.06-child.00000.00-name=/Users/Elena/* -06-child.00000.06-child.00000.01-type=FilterString -06-child.00000.06-child.00000.03-attr.default=false -06-child.00000.06-child.00000.03-attr.string=/Users/Elena/* -06-child.00000.06-child.00000.03-attr.type=default -06-child.00001.00-name=Root -06-child.00001.01-type=Filter -06-child.00001.03-attr.default=false -06-child.00001.03-attr.filterType=default -06-child.00001.03-attr.id=Root -06-child.00001.03-attr.nonChangable=false -06-child.00001.03-attr.nonDeletable=false -06-child.00001.03-attr.nonRenamable=false -06-child.00001.03-attr.promptable=false -06-child.00001.03-attr.relativeOrder=0 -06-child.00001.03-attr.release=200 -06-child.00001.03-attr.singleFilterStringOnly=false -06-child.00001.03-attr.stringsCaseSensitive=true -06-child.00001.03-attr.stringsNonChangable=false -06-child.00001.03-attr.supportsDuplicateFilterStrings=false -06-child.00001.03-attr.supportsNestedFilters=true -06-child.00001.06-child.00000.00-name=/* -06-child.00001.06-child.00000.01-type=FilterString -06-child.00001.06-child.00000.03-attr.default=false -06-child.00001.06-child.00000.03-attr.string=/* -06-child.00001.06-child.00000.03-attr.type=default diff --git a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/H.local_16/node.properties b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/H.local_16/node.properties deleted file mode 100644 index 8adafb7810..0000000000 --- a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/H.local_16/node.properties +++ /dev/null @@ -1,25 +0,0 @@ -# RSE DOM Node -00-name=Local -01-type=Host -03-attr.description= -03-attr.hostname=LOCALHOST -03-attr.offline=false -03-attr.promptable=false -03-attr.systemType=org.eclipse.rse.systemtype.local -03-attr.type=Local -06-child.00000.00-name=Local Connector Service -06-child.00000.01-type=ConnectorService -06-child.00000.03-attr.group=Local Connector Service -06-child.00000.03-attr.port=0 -06-child.00000.03-attr.useSSL=false -06-child.00000.06-child.00000.00-name=Local Files -06-child.00000.06-child.00000.01-type=SubSystem -06-child.00000.06-child.00000.03-attr.hidden=false -06-child.00000.06-child.00000.03-attr.type=local.files -06-child.00000.06-child.00000.06-child.00000.00-name=MacBook-Pro-de-Elena-Garcia-Miro-P___MacBook-Pro-de-Elena-Garcia-Miro-P\:local.files -06-child.00000.06-child.00000.06-child.00000.01-type=FilterPoolReference -06-child.00000.06-child.00000.06-child.00000.03-attr.refID=local.files -06-child.00000.06-child.00001.00-name=Local Shells -06-child.00000.06-child.00001.01-type=SubSystem -06-child.00000.06-child.00001.03-attr.hidden=false -06-child.00000.06-child.00001.03-attr.type=local.shells diff --git a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/node.properties b/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/node.properties deleted file mode 100644 index ee267da8c7..0000000000 --- a/.metadata/.plugins/org.eclipse.rse.core/profiles/PRF.macbook-pro-de-elena-garcia-miro-p_9697497121/node.properties +++ /dev/null @@ -1,7 +0,0 @@ -# RSE DOM Node -00-name=MacBook-Pro-de-Elena-Garcia-Miro-P -01-type=Profile -03-attr.defaultPrivate=true -03-attr.isActive=true -05-ref.00000=FP.local.files_0 -05-ref.00001=H.local_16 diff --git a/.metadata/.plugins/org.eclipse.rse.ui/.log b/.metadata/.plugins/org.eclipse.rse.ui/.log deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/.metadata/.plugins/org.eclipse.search/dialog_settings.xml b/.metadata/.plugins/org.eclipse.search/dialog_settings.xml deleted file mode 100644 index d2bdd1e49c..0000000000 --- a/.metadata/.plugins/org.eclipse.search/dialog_settings.xml +++ /dev/null @@ -1,70 +0,0 @@ - -
-
- -
-
- -
-
- - - - - -
- -
-
- - - - - - - - - - -
-
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
-
- -
-
- - - - - -
-
diff --git a/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml deleted file mode 100644 index 50f1edb316..0000000000 --- a/.metadata/.plugins/org.eclipse.ui.editors/dialog_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
-
diff --git a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml deleted file mode 100644 index 24f718e1ca..0000000000 --- a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +++ /dev/null @@ -1,30 +0,0 @@ - -
-
- - - - - -
-
- - - - - - - - - - - -
- - - - - -
-
-
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml deleted file mode 100644 index b9f4ca805b..0000000000 --- a/.metadata/.plugins/org.eclipse.ui.workbench.texteditor/dialog_settings.xml +++ /dev/null @@ -1,23 +0,0 @@ - -
-
- - - - - - - - - - - -
-
- - - - - -
-
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml deleted file mode 100644 index 1ae420da85..0000000000 --- a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ /dev/null @@ -1,33 +0,0 @@ - -
-
- - - - - - - - - - -
-
- - - - -
-
- - - - - - - - - - -
-
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml deleted file mode 100644 index 61cd82aa2a..0000000000 --- a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui/dialog_settings.xml deleted file mode 100644 index 5ca0b77690..0000000000 --- a/.metadata/.plugins/org.eclipse.ui/dialog_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/.metadata/.plugins/org.eclipse.wst.internet.cache/cache.xml b/.metadata/.plugins/org.eclipse.wst.internet.cache/cache.xml deleted file mode 100644 index 1b1be0f54e..0000000000 --- a/.metadata/.plugins/org.eclipse.wst.internet.cache/cache.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.wst.jsdt.core/externalLibsTimeStamps b/.metadata/.plugins/org.eclipse.wst.jsdt.core/externalLibsTimeStamps deleted file mode 100644 index 35109d64d3..0000000000 Binary files a/.metadata/.plugins/org.eclipse.wst.jsdt.core/externalLibsTimeStamps and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat deleted file mode 100644 index ba9a8170ae..0000000000 Binary files a/.metadata/.plugins/org.eclipse.wst.jsdt.core/variablesAndContainers.dat and /dev/null differ diff --git a/.metadata/.plugins/org.eclipse.wst.jsdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.wst.jsdt.ui/OpenTypeHistory.xml deleted file mode 100644 index a4ee3cbc9a..0000000000 --- a/.metadata/.plugins/org.eclipse.wst.jsdt.ui/OpenTypeHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml deleted file mode 100644 index 9e390f501d..0000000000 --- a/.metadata/.plugins/org.eclipse.wst.jsdt.ui/QualifiedTypeNameHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/.metadata/.plugins/org.eclipse.wst.server.core/monitors.xml b/.metadata/.plugins/org.eclipse.wst.server.core/monitors.xml deleted file mode 100644 index 0bd2033fef..0000000000 --- a/.metadata/.plugins/org.eclipse.wst.server.core/monitors.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/.metadata/.plugins/org.eclipse.wst.sse.core/task-tags.properties b/.metadata/.plugins/org.eclipse.wst.sse.core/task-tags.properties deleted file mode 100644 index 4acf7ba3bc..0000000000 --- a/.metadata/.plugins/org.eclipse.wst.sse.core/task-tags.properties +++ /dev/null @@ -1,3 +0,0 @@ -# -#Thu Oct 16 20:44:26 PET 2014 -task-tag-projects-already-scanned= diff --git a/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml deleted file mode 100644 index 63fae25e8f..0000000000 --- a/.metadata/.plugins/org.eclipse.wst.sse.ui/dialog_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
-
diff --git a/.metadata/.plugins/org.jboss.tools.central/dialog_settings.xml b/.metadata/.plugins/org.jboss.tools.central/dialog_settings.xml deleted file mode 100644 index f977cc958a..0000000000 --- a/.metadata/.plugins/org.jboss.tools.central/dialog_settings.xml +++ /dev/null @@ -1,8 +0,0 @@ - -
-
- - - -
-
diff --git a/.metadata/.plugins/org.springframework.ide.eclipse.aop.core/.state b/.metadata/.plugins/org.springframework.ide.eclipse.aop.core/.state deleted file mode 100644 index 8a7bbde21f..0000000000 --- a/.metadata/.plugins/org.springframework.ide.eclipse.aop.core/.state +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/metadata/.state b/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/metadata/.state deleted file mode 100644 index 9fa791da42..0000000000 Binary files a/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/metadata/.state and /dev/null differ diff --git a/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/properties/.state b/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/properties/.state deleted file mode 100644 index 4e0dff42d9..0000000000 Binary files a/.metadata/.plugins/org.springframework.ide.eclipse.beans.core.metadata/properties/.state and /dev/null differ diff --git a/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.blogs/-549550714.xml b/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.blogs/-549550714.xml deleted file mode 100644 index ff2193fcc3..0000000000 --- a/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.blogs/-549550714.xml +++ /dev/null @@ -1,816 +0,0 @@ - - - Spring - - - http://spring.io/blog.atom - https://spring.io/favicon.ico - 2014-10-15T13:20:00Z - - Whats new in Spring Data Evans? - - - - Christoph Strobl - - tag:spring.io,2014-09-17:1764 - 2014-10-15T13:20:00Z - <p>Spring Data Release <a href="https://spring.io/blog/2014/09/09/spring-data-release-train-evans-goes-ga">Evans</a> has been around for a while and it's more than time to finally introduce you to the latest and greatest features we shipped with it.</p> - -<p>There's a lot to cover since major enhancements have gone into the commons module. Those changes already have made it into some store modules and will go on and sneak their way into others over time, too. All of them are already available for at least <a href="http://projects.spring.io/spring-data-jpa/">Spring Data JPA</a>. That said, lets jump right in.</p> - -<h2> -<a name="user-content-advanced-support-for-java-8" class="anchor" href="#advanced-support-for-java-8" aria-hidden="true"><span class="octicon octicon-link"></span></a>Advanced support for Java 8</h2> - -<p>Java8 has now been around for a while and previous Spring Data release trains already added fundamental support for some of those. With the Evans release train we extended the support significantly.</p> - -<p>Java 8's <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Optional.html"><code>Optional</code></a> has been a supported return since the <a href="https://spring.io/blog/2014/05/21/what-s-new-in-spring-data-dijkstra">Dijkstra release</a> freeing you of having <code>null</code> checks spread across your code. We simply wrap and unwrap values for you when used as return types with repositories.</p> - -<p>As of the Evans release <a href="http://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html">default methods</a> can be used in repository interfaces to e.g. forward parts of the parameters handed into the method to other query methods.</p> - -<div class="highlight highlight-java"><pre><span class="kd">interface</span> <span class="nc">PersonRepository</span> <span class="kd">extends</span> <span class="n">Repository</span><span class="o">&lt;</span><span class="n">Person</span><span class="o">,</span> <span class="n">Long</span><span class="o">&gt;</span> <span class="o">{</span> - - <span class="n">Optional</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">&gt;</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">String</span> <span class="n">lastname</span><span class="o">);</span> - - <span class="k">default</span> <span class="n">Optional</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">&gt;</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">Customer</span> <span class="n">customer</span><span class="o">)</span> <span class="o">{</span> - <span class="k">return</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">customer</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">?</span> <span class="kc">null</span> <span class="o">:</span> <span class="n">customer</span><span class="o">.</span><span class="na">getLastname</span><span class="o">());</span> - <span class="o">}</span> -<span class="o">}</span> -</pre></div> - -<h2> -<a name="user-content-enhanced-multi-store-support" class="anchor" href="#enhanced-multi-store-support" aria-hidden="true"><span class="octicon octicon-link"></span></a>Enhanced multi-store support</h2> - -<p>Configuring your application to make use of different Spring Data modules has not been without issues so far. E.g. you might want to combine JPA and MongoDB where <code>Customer</code> happens to be a JPA Entity while <code>Order</code> is a MongoDB Document both persisted via according repository interfaces.</p> - -<div class="highlight highlight-java"><pre><span class="nd">@Entity</span> -<span class="kd">class</span> <span class="nc">Customer</span> <span class="o">{</span> - - <span class="nd">@Id</span> <span class="nd">@GeneratedValue</span> <span class="n">Long</span> <span class="n">id</span><span class="o">;</span> - <span class="n">String</span> <span class="n">firstname</span><span class="o">,</span> <span class="n">lastname</span><span class="o">;</span> - <span class="c1">// ...</span> -<span class="o">}</span> - -<span class="nd">@Document</span> -<span class="kd">class</span> <span class="nc">Order</span> <span class="o">{</span> - - <span class="nd">@Id</span> <span class="n">String</span> <span class="n">id</span><span class="o">;</span> - <span class="n">Long</span> <span class="n">customerId</span><span class="o">;</span> - <span class="n">Date</span> <span class="n">orderDate</span><span class="o">;</span> - <span class="c1">// ...</span> -<span class="o">}</span> - -<span class="kd">interface</span> <span class="nc">CustomerRepository</span> <span class="kd">extends</span> <span class="n">CrudRepository</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">,</span> <span class="n">Long</span><span class="o">&gt;</span> <span class="o">{}</span> - -<span class="kd">interface</span> <span class="nc">OrderRepository</span> <span class="kd">extends</span> <span class="n">CrudRepository</span><span class="o">&lt;</span><span class="n">Order</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="o">{}</span> -</pre></div> - -<p>Until the Spring Data Evans release you had to manually configure the repository setup for MongoDB and JPA to mutually exclude the interfaces not relevant for the given store. Users usually used separate packages for that.</p> - -<p>Now the repository setup detects that multiple Spring Data modules are on the classpath, and automatically restricts the repository scanning and inspect the domain type used by a given repository for store specific annotations such as <code>@Entity</code> and <code>@Document</code> to determine the concrete implementation they belong to. E.g. the Spring Data MongoDB module would drop the (accidentally) detected <code>CustomerRepository</code> as we don't find an <code>@Document</code> annotation.</p> - -<h3> -<a name="user-content-statically-limiting-results" class="anchor" href="#statically-limiting-results" aria-hidden="true"><span class="octicon octicon-link"></span></a>Statically limiting results</h3> - -<p>Dynamically limiting results is no new concept since Spring Data has had <code>Pagable</code> as abstraction since its inception and I bet nearly every Spring Data user is already familiar with something like this:</p> - -<div class="highlight highlight-java"><pre><span class="n">List</span><span class="o">&lt;</span><span class="n">Person</span><span class="o">&gt;</span> <span class="nf">findByLastname</span><span class="o">(</span><span class="n">String</span> <span class="n">lastname</span><span class="o">,</span> <span class="n">Pageable</span> <span class="n">page</span><span class="o">)</span> -</pre></div> - -<p>This method declaration provides quite some flexibility: clients define the page number, size and a sort order of the elements they want to access. This is great if these values change dynamically (e.g. when you traverse the result set page by page).</p> - -<p>But what if you're always only interested in e.g. the first 10 results and you always want them to be ordered by lastname? This could've been achieved by statically defining a <code>PageRequest</code> and reusing that for every method invocation. However, that still required the client to hand in the special <code>PageRequest</code>. </p> - -<p>As of Spring Data Evans we now offer you a convenient way to explicitly limit the result set to a certain number of elements by using the keywords <code>top</code> and <code>first</code> followed by an optional positive numeric value (defaulting to 1).</p> - -<div class="highlight highlight-java"><pre><span class="n">List</span><span class="o">&lt;</span><span class="n">Person</span><span class="o">&gt;</span> <span class="nf">findTop10ByLastnameOrderByFirstnameDesc</span><span class="o">(</span><span class="n">String</span> <span class="n">lastname</span><span class="o">);</span> -</pre></div> - -<h2> -<a name="user-content-mongodb-full-text-search" class="anchor" href="#mongodb-full-text-search" aria-hidden="true"><span class="octicon octicon-link"></span></a>MongoDB Full Text Search</h2> - -<p>The Evans RC1 release introduced basic <a href="https://spring.io/blog/2014/07/17/text-search-your-documents-with-spring-data-mongodb">text index support</a> for MongoDB 2.6. Using <code>@TextIndexed</code> allows you to mark properties you want to have text search enabled for so that we can go on and create the index for you. Note, that placing <code>@TextIndexed</code> on properties referring to complex types will index all properties of that type. Since scoring is a fundamental part of full text search the <code>@TextScore</code> annotation will assert that any full text query returns the documents score allowing you to order them by relevance.</p> - -<div class="highlight highlight-java"><pre><span class="nd">@Document</span> -<span class="kd">class</span> <span class="nc">BlogPost</span> <span class="o">{</span> - - <span class="nd">@Id</span> <span class="n">String</span> <span class="n">id</span><span class="o">;</span> - <span class="nd">@TextIndexed</span><span class="o">(</span><span class="n">weight</span> <span class="o">=</span> <span class="mi">3</span><span class="o">)</span> <span class="n">String</span> <span class="n">title</span><span class="o">;</span> - <span class="nd">@TextIndexed</span><span class="o">(</span><span class="n">weight</span> <span class="o">=</span> <span class="mi">2</span><span class="o">)</span> <span class="n">String</span> <span class="n">content</span><span class="o">;</span> - <span class="nd">@TextIndexed</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">categories</span><span class="o">;</span> - <span class="nd">@TextScore</span> <span class="n">Float</span> <span class="n">score</span><span class="o">;</span> -<span class="o">}</span> -</pre></div> - -<p>That in place, we extended the repository support to accept a <code>TextCriteria</code> instance that will define detailed options about the text search that shall be executed: the terms to be searched for, language options etc.</p> - -<div class="highlight highlight-java"><pre><span class="kd">interface</span> <span class="nc">BlogPostRepository</span> <span class="kd">extends</span> <span class="n">CrudRepository</span><span class="o">&lt;</span><span class="n">BlogPost</span><span class="o">,</span> <span class="n">String</span><span class="o">&gt;</span> <span class="o">{</span> - - <span class="n">Page</span><span class="o">&lt;</span><span class="n">BlogPost</span><span class="o">&gt;</span> <span class="nf">findBy</span><span class="o">(</span><span class="n">TextCriteria</span> <span class="n">criteria</span><span class="o">,</span> <span class="n">Pageable</span> <span class="n">page</span><span class="o">);</span> - - <span class="n">List</span><span class="o">&lt;</span><span class="n">BlogPost</span><span class="o">&gt;</span> <span class="nf">findAllByOrderByScoreDesc</span><span class="o">(</span><span class="n">TextCriteria</span> <span class="n">criteria</span><span class="o">);</span> -<span class="o">}</span> -</pre></div> - -<p>The first query method is quite straight forward. It executes the given <code>TextCriteria</code> and pages the results. The second query method definition combines the given <code>TextCriteria</code> with a standard criteria definition derived from the method name. This shows that you can freely combine text search with standard query easily.</p> - -<h2> -<a name="user-content-mongodb-query-modifiers" class="anchor" href="#mongodb-query-modifiers" aria-hidden="true"><span class="octicon octicon-link"></span></a>MongoDB query modifiers</h2> - -<p>We added <code>@Meta</code> allowing you to define output and behavior of a query. By setting e.g. <code>maxExecutionTime</code> one can define the maximum duration a query may take (in milliseconds). Any execution that exceeds the limit will result in an error. You can also advice MongoDB to only scan through a maximum number of documents and return what has been found until reaching the limit by setting <code>maxScanDocuments</code>, while <code>comment</code> allows you to define text you can search for within the <code>system.profile</code> collection in case you got profiling enabled for your MongoDB instance. </p> - -<div class="highlight highlight-java"><pre><span class="nd">@Meta</span><span class="o">(</span><span class="n">maxExcecutionTime</span> <span class="o">=</span> <span class="mi">100</span><span class="o">,</span> <span class="n">comment</span> <span class="o">=</span> <span class="s">"onlyLimitedTime"</span><span class="o">)</span> -<span class="n">List</span><span class="o">&lt;</span><span class="n">Customer</span><span class="o">&gt;</span> <span class="nf">findByFirstname</span><span class="o">(</span><span class="n">String</span> <span class="n">firstname</span><span class="o">);</span> -</pre></div> - -<h2> -<a name="user-content-configuration-options-for-redis-sentinel" class="anchor" href="#configuration-options-for-redis-sentinel" aria-hidden="true"><span class="octicon octicon-link"></span></a>Configuration options for Redis Sentinel</h2> - -<p>Redis 2.8 introduced high-availability support know as <a href="http://redis.io/topics/sentinel">Sentinels</a>. The Redis module of Spring Data Evans adds support to easily configure connecting to a sentinel setup so that your client will be able to continue working in case of re-elections of master nodes in a Redis cluster.</p> - -<p><code>RedisSentinelConfiguration</code> defines where the Sentiels are located so that the <code>ConnectionFactory</code> can set up pooling accordingly. In case of Jedis it will create a <code>JedisSentinelPool</code> for automatic failover. This means that in case your master node goes down, you'll receive, as soon as the Sentinels agreed on a new master, a connection to the new master without the need of any further interaction. </p> - -<div class="highlight highlight-java"><pre><span class="nd">@Configuration</span> -<span class="kd">class</span> <span class="nc">RedisSentinelApplicationConfig</span> <span class="o">{</span> - - <span class="nd">@Bean</span> - <span class="n">RedisConnectionFactory</span> <span class="nf">connectionFactory</span><span class="o">()</span> <span class="o">{</span> - <span class="k">return</span> <span class="k">new</span> <span class="nf">JedisConnectionFactory</span><span class="o">(</span><span class="n">sentinelConfig</span><span class="o">());</span> - <span class="o">}</span> - - <span class="nd">@Bean</span> - <span class="n">RedisSentinelConfiguration</span> <span class="nf">sentinelConfig</span><span class="o">()</span> <span class="o">{</span> - <span class="k">return</span> <span class="k">new</span> <span class="nf">RedisSentinelConfiguration</span><span class="o">().</span><span class="na">master</span><span class="o">(</span><span class="s">"mymaster"</span><span class="o">)</span> - <span class="o">.</span><span class="na">sentinel</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">26379</span><span class="o">)</span> - <span class="o">.</span><span class="na">sentinel</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">26380</span><span class="o">)</span> - <span class="o">.</span><span class="na">sentinel</span><span class="o">(</span><span class="s">"localhost"</span><span class="o">,</span> <span class="mi">26381</span><span class="o">);</span> - <span class="o">}</span> -<span class="o">}</span> -</pre></div> - -<p>The upcoming Spring Boot 1.2, will even take this even further by automatically picking up the <code>RedisSentinelConfiguration</code> if present and initialize the <code>RedisConnectionFactory</code> accordingly.</p> - -<h2> -<a name="user-content-schema-support-for-solr" class="anchor" href="#schema-support-for-solr" aria-hidden="true"><span class="octicon octicon-link"></span></a>Schema support for Solr</h2> - -<p>Although the <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API">Solr Schema API</a> is not finished yet, we already try to support as much of it as possible. With the Evans release you can now dynamically add missing fields to an existing (managed) schema. To achieve this, we read the existing field definition and compare it against the one derived from the properties of the domain type. To do so we extended the <code>@Indexed</code> annotation a bit. It now allows some fine tuning of the fields to be created as values such as <code>indexed</code>, <code>stored</code> and <code>solrType</code> can be explicitly defined.</p> - -<div class="highlight highlight-java"><pre><span class="nd">@Configuration</span> -<span class="nd">@EnableSolrRepositories</span><span class="o">(</span><span class="n">schemaCreationSupport</span> <span class="o">=</span> <span class="kc">true</span><span class="o">)</span> -<span class="kd">class</span> <span class="nc">SolrConfiguration</span> <span class="o">{</span> - - <span class="nd">@Bean</span> - <span class="n">SolrServer</span> <span class="nf">solrServer</span><span class="o">()</span> <span class="o">{</span> - <span class="k">return</span> <span class="k">new</span> <span class="nf">HttpSolrServer</span><span class="o">(</span><span class="s">"http://localhost:8983/solr"</span><span class="o">);</span> - <span class="o">}</span> -<span class="o">}</span> - -<span class="nd">@SolrDocument</span><span class="o">(</span><span class="n">solrCoreName</span> <span class="o">=</span> <span class="s">"collection1"</span><span class="o">)</span> -<span class="kd">class</span> <span class="nc">ManagedProduct</span> <span class="o">{</span> - - <span class="nd">@Id</span> <span class="n">String</span> <span class="n">id</span><span class="o">;</span> - <span class="nd">@Indexed</span><span class="o">(</span><span class="n">type</span> <span class="o">=</span> <span class="s">"text_general"</span><span class="o">)</span> <span class="n">String</span> <span class="n">name</span><span class="o">;</span> - <span class="nd">@Indexed</span><span class="o">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">"cat"</span><span class="o">)</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">category</span><span class="o">;</span> -<span class="o">}</span> -</pre></div> - -<p>As always we are eager to hear from you! Reach out to us on <a href="https://twitter.com/SpringData">Twitter</a>, <a href="http://stackoverflow.com/tags/spring-data">Stackoverflow</a> or <a href="http://jira.spring.io">JIRA</a> to request new features, suggest improvements or report a bug.</p> - - - This Week in Spring - Tuesday October 14th, 2014 - - - - Josh Long - - tag:spring.io,2014-10-14:1789 - 2014-10-14T18:05:00Z - <p>Welcome to another installment of <em>This Week in Spring</em>! This week I've been at Silicon Valley Code Camp, JAX London and Geekout UK talking to developers about how to build scalable, microservice-centric <a href="http://start.spring.io">Spring Boot</a> applications on <a href="http://cloudfoundry.org/index.html">Cloud Foundry</a>. It's been a lot fun talking to enthusiastic developers (on both sides of the Atlantic!).</p> - -<p>Without further ado, let's get on with the roundup!</p> - -<ul> -<li>Spring Boot co-lead Phil Webb just announced the availability of <a href="https://spring.io/blog/2014/10/11/spring-boot-1-2-0-m2-available-now">Spring Boot 1.2.0.M2</a> which includes, among other things, auto-configuration for Jersey, log4j, <code>commons-dbcp</code> support, a smarter <em>disk usage</em> health indicator and improved RabbitMQ support</li> -<li>Spring and Groovy Tool Suite lead Martin Lippert <a href="https://spring.io/blog/2014/10/13/spring-tool-suite-and-groovy-grails-tool-suite-3-6-2-released">has just announced the latest and greatest release, 3.6.2</a>, which is a maintenance release that includes an update to the latest Eclipse Luna SR1 installation. </li> -<li>Also, Spring Boot co-lead <a href="https://spring.io/blog/2014/10/11/spring-boot-1-1-8-released">Phil Webb just announced the 1.1.8 release of the 1.1x line of Spring Boot</a> which includes a fix for the white-label error page cross-site scripting attack. </li> -<li>Federated security is an important part of any distributed, multi-client, (micro)service-oriented system. Spring Security and Spring Security OAuth, in particular, provide a compelling solution. Join the good Dr. Dave Syer for this <a href="https://spring.io/blog/2014/10/01/webinar-security-for-microservices-with-spring-and-oauth2">upcoming webinar on microservice security using OAuth2</a> -</li> -<li>Matt Stine will be doing a webinar introducing <a href="https://spring.io/blog/2014/10/01/webinar-architecting-for-continuous-delivery-microservices-with-pivotal-cf-and-spring-cloud">how Pivotal Cloud Foundry and Spring Cloud make for a natural solution to building microservices</a>. Don't miss this one!</li> -<li>Atlanta, GA, USA Tuesday Oct 21, Learn about Spring, Microservices, and Cloud Foundry at a <a href="http://www.pivotal.io/platform-as-a-service/cloud-platform-roadshow/atlanta#cities">one day roadshow event</a> at Cox communications.</li> -<li>Munich, Germany, GA, Thursday Oct 23, Learn about Spring, Microservices, and Cloud Foundry at a <a href="http://www.pivotal.io/platform-as-a-service/cloud-platform-roadshow/munich">one day roadshow event</a> at EMC's office in Ismaning, Germany. </li> -<li>I hope you'll join the Vaadin team and I on October 23rd for a <a href="http://spring.io/blog/2014/10/01/webinar-building-bootful-uis-with-spring-boot-and-vaadin">look how to build Spring Boot-powered Vaadin applications</a>.</li> -<li>The <em>Java et Moi</em> blog has a nice (French language) post <a href="http://javaetmoi.com/2014/10/annotation-sessionattributes-modelattribute-spring-mvc/">on using Spring MVC's <code>@SessionAttribute</code> annotation</a><br> -</li> -<li>I <em>really</em> enjoyed this <a href="http://altfatterz.blogspot.com/2014/10/software-configuration-with-spring-boot.html">very thorough look at contributing configuration property values</a> to a Spring Boot application (as <code>--D</code> arguments, environment variables, values in a property file, and values inside of JNDI)</li> -<li>Sudhir Dharmadhikari has done a <em>very</em> <a href="http://iwaow.blogspot.com/2014/10/jhipster-super-baby-in-springroos-pouch.html">nice job introducing the <code>yeoman</code> code-generator based JHipster</a>, which builds on top of <a href="http://spring.io/projects/spring-boot">Spring Boot</a>.</li> -<li>Our pal Miroslav Kopecky is back, this <a href="http://java.dzone.com/articles/scala-4-spring-mvc-without-0">time with a nice post on using Spring MVC (in Spring 4) using Java configuration</a> (through Scala!)</li> -<li> -<a href="http://antirez.com/news/79">Redis Cluster is no longer vaporware</a>! Check out the details.</li> -<li> Biju Kunjummen has put together <a href="http://java.dzone.com/articles/spring-configuration-and">a very nice post on the two styles of Java configuration</a>: one where you declare dependencies as parameters to the <code>@Bean</code>-annotated bean definition method, and one where you simply reference the other bean by calling a method.<br> -</li> -<li>Check out this post on <a href="http://architects.dzone.com/articles/using-log4j2-slf4j-spring-4">avoiding dependency conflicts between Log4j2 and SLF4J</a> in a Spring application.</li> -<li>Check out this post by Daniel Murygin which includes a detailed walk-through <a href="http://murygin.wordpress.com/2014/10/13/rest-web-service-file-uploads-spring-boot/">on building a fairly non-trivial REST service (that even handles file-uploads!) and client application using Spring Boot</a>?<br> -</li> -</ul> - - - Spring Tool Suite and Groovy/Grails Tool Suite 3.6.2 released - - - - Martin Lippert - - tag:spring.io,2014-10-13:1788 - 2014-10-13T14:20:11Z - <p>Dear Spring Community,</p> - -<p>I am happy to announce the new release of our Eclipse-based tooling today: -The Spring Tool Suite (STS) 3.6.2 and the Groovy/Grails Tool Suite (GGTS) 3.6.2.</p> - -<p>This is a maintenance release that updates STS/GGTS to the just released Eclipse Luna SR1 release. This includes a number of fixes across the various projects that are included in the STS distribution, together with fixes for the Java8 compiler and tooling in Eclipse.</p> - -<p>To download the distributions, please go visit:</p> - -<ul> -<li>Spring Tool Suite: <a href="https://spring.io/tools/sts/all">https://spring.io/tools/sts/all</a> -</li> -<li>Groovy/Grails Tool Suite: <a href="https://spring.io/tools/ggts/all">https://spring.io/tools/ggts/all</a> -</li> -</ul> - -<p>Detailed new and noteworthy notes can be found here: <a href="http://docs.spring.io/sts/nan/v362/NewAndNoteworthy.html">STS/GGTS 3.6.2 New &amp; Noteworthy</a>.</p> - -<p>NOTE: -Both tool suites ship on top of the latest Eclipse Luna 4.4 SR1 release as 64bit and 32bit based zip files only. There will be no native installers for STS/GGTS anymore.</p> - -<p>Since the 3.6.0 release we shifted towards a slightly changed release schedule, shipping minor releases more frequently. Therefore 3.6.3 is scheduled to ship in December, followed by 3.6.4 in early March 2015, shortly after the Eclipse Luna SR2 release.</p> - -<p>Enjoy!</p> - - - Spring Boot 1.2.0.M2 Available Now - - - - Phil Webb - - tag:spring.io,2014-10-11:1786 - 2014-10-11T03:55:53Z - <p>I am pleased to announce that Spring Boot 1.2.0.M2 is available now in the <a href="http://repo.springsource.org/milestone">Spring milestone repository</a>. This release adds a number of improvements and new features over <a href="https://spring.io/blog/2014/09/08/spring-boot-1-2-0-m1-available-now">M1</a>. Highlights include:</p> - -<ul> -<li>Full configuration of Jackson <code>ObjectMapper</code> features from your <code>application.properties</code> file.</li> -<li>Auto-configuration for Jersey.</li> -<li>Support for Log4j2.</li> -<li>Support for commons-dbcp2.</li> -<li>A new "disk usage" health indicator.</li> -<li>Improved RabbitMQ auto-configuration.</li> -</ul> - -<p>For a complete list of changes, and for upgrade instructions, see the <a href="http://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.2-Release-Notes">Spring Boot 1.2 Release Notes</a> on the WIKI. The <a href="http://docs.spring.io/spring-boot/docs/1.2.0.M2/reference/htmlsingle/">reference documentation</a> also continues to be updated to cover the new features.</p> - -<p>Thanks again to everyone that has contributed to the release! Please give it a go and report any problems using <a href="http://github.com/spring-projects/spring-boot/issues">the project Issue tracker</a> page.</p> - - - Spring Boot 1.1.8 released - - - - Phil Webb - - tag:spring.io,2014-10-11:1785 - 2014-10-11T00:37:52Z - <p>Spring Boot 1.1.8 has been released and is available now from <a href="http://repo.spring.io/release">repo.spring.io</a> and <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.springframework.boot%22">Maven Central</a>. </p> - -<p>This maintenance release includes a <a href="https://github.com/spring-projects/spring-boot/commit/3135c7f8aeb30b71eccc02bb0bb3817132c41060">security patch</a> to the "white label error" page which prevents potential cross-site scripting attacks; as such it is a recommended upgrade for all Spring Boot users. For a complete list of changes please refer to the <a href="https://github.com/spring-projects/spring-boot/issues?q=milestone%3A1.1.8">issue tracker</a>.</p> - -<p><a href="http://projects.spring.io/spring-boot/">Project Page</a> | <a href="https://github.com/spring-projects/spring-boot">GitHub</a> | <a href="https://github.com/spring-projects/spring-boot/issues">Issues</a> | <a href="http://docs.spring.io/spring-boot/docs/1.1.8.RELEASE/reference/htmlsingle">Documentation</a></p> - - - Pivotal at Silicon Valley Code Camp 2014 - - - - Pieter Humphrey - - tag:spring.io,2014-10-10:1784 - 2014-10-10T10:24:00Z - <p>Are you heading to Silicon Valley Code Camp 2014?   If you are, we invite all of the Java community members to stop by the Pivotal Booth and talk to Pivotal engineers about the latest innovations in Java SE, in Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Cloud Foundry and Hadoop. The exhibit space is open Saturday 8:00am – 5:00pm, and Saturday from 8:30am to 3:30pm, so there should be plenty of time to get your questions answered.  See below for details about our sessions and awesome giveaways - come find us! </p> - -<p><strong>SATURDAY - OCTOBER 11, 2014            </strong><br> -9:45 AM </p> - -<ul> - <li>Josh Long — Spring advocate at Pivotal</li> - <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/building-bootiful-applications-with-spring-boot" target="_blank">Building "Bootiful Applications with Spring Boot </a></li> - <li>Room: 8401</li> -</ul> - -<p>11:45 AM </p> - -<ul> - <li>John Hann, — Pivotal</li> - <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/introducing-ravejs-zero-config-javascript-applications" target="_blank">Introducing Rave.js: Zero-config JavaScript Applications</a></li> - <li>Room: 8401</li> -</ul> - -<p>1:45 PM </p> - -<ul> - <li>Ilayaperumal Gopinathan — Pivotal</li> - <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/simplifying-big-data-development-using-spring-xd" target="_blank">Simplifying Big Data development at Spring XD</a></li> - <li> Room: 8403</li> -</ul> - -<p><strong>SUNDAY - OCTOBER 12, 2014</strong></p> - -<p>9:15 AM </p> - -<ul> - <li>Cornelia Davis — Platform Engineer at Pivotal</li> - <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/the-self-healing-elastic-runtime-that-is-cloud-foundry">The Self-healing, Elastic Runtime that is Cloud Foundry</a></li> - <li>Room: Room: 4302</li> -</ul> - -<p>10:45 AM</p> - -<ul> - <li>Cornelia Davis — Platform Engineer at Pivotal</li> - <li><a href="http://www.siliconvalley-codecamp.com/Session/2014/running-your-spring-apps-in-the-cloud" target="_blank">Running Your Spring Apps in the Cloud</a></li> - <li>Room: 4302</li> -</ul> - -<p>Visit us at the Pivotal Code Camp booth for technical expert conversations on Cloud Foundry, Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Hadoop and much more. </p> - -<p>Also, don't miss the <a href="http://run.pivotal.io">Pivotal Web Services</a> Hoodie Push!  <a href="https://spring.io/guides/gs/rest-service/">Build a REST service with Spring Boot</a>, push it live to run.pivotal.io and get a hoodie!  You can do it ahead of time, and show it running to us, or use our laptops at the booth. </p> - -<p><a href="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" target="_blank"><img border="0" width="215" height="254" src="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" style="max-width:100%;"></a></p> - -<p> </p> - -<p> </p> - -<p>Save the date for SpringOne2GX 2015!  We hope you will mark your calendar and join us again! SpringOne2GX 2015 will be held September 14 - 17, 2015 at the Marriott Marquis in Washington DC.</p> - - - This Week in Spring - October 7th, 2014 - - - - Josh Long - - tag:spring.io,2014-10-08:1783 - 2014-10-08T03:49:00Z - <p>Welcome to another installment of <em>This Week in Spring</em>! This week, I've been at the Couchbase Connect conference talking to developers about Spring Data Couchbase (and Spring Boot, Spring XD, Spring Session, and more..). Fun show, fun crowd! Next week, I'll be at <a href="http://jaxlondon.com/2014/speakers/josh-long">JAX London</a> and <a href="http://uk.geekout.ee/speakers/josh-long/">Geekout UK</a>, so be sure to say hi if you're around. </p> - -<p>Now, with that, let's get on to the roundup..</p> - -<ol> -<li>The good Dr. Pollack just announced <a href="http://spring.io/blog/2014/10/02/spring-xd-1-0-1-released">the 1.0.1 release of Spring XD</a>, the easiest way to build data-integration and ingestion solutions. It may be only a 1.0.1 release, but make no mistake: there are some very cool features in this release, including improved administrative and administrative UI features. </li> -<li>Federated security is an important part of any distributed, multi-client, (micro)service-oriented system. Spring Security and Spring Security OAuth, in particular, provide a compelling solution. Join the good Dr. Dave Syer for this <a href="https://spring.io/blog/2014/10/01/webinar-security-for-microservices-with-spring-and-oauth2">upcoming webinar on microservice security using OAuth2</a> -</li> -<li>Matt Stine will be doing a webinar introducing <a href="https://spring.io/blog/2014/10/01/webinar-architecting-for-continuous-delivery-microservices-with-pivotal-cf-and-spring-cloud">how Pivotal Cloud Foundry and Spring Cloud make for a natural solution to building microservices</a>. Don't miss this one!</li> -<li> Spring and JavaScript ninja Brian Cavalier has written a <em>very</em> interesting post on some of <a href="http://github.com/spring-projects/spring-sync/">the work</a> we're doing towards enabling <a href="http://spring.io/blog/2014/10/08/streaming-json-patch-from-spring-to-a-react-ui">easier differential sync between JavaScript clients and services</a>. This post not only introduces all these exciting new stuff, but also builds on RaveJS, the Spring Boot-inspired approach to JavaScript.</li> -<li>I hope you'll join the Vaadin team and I on October 23rd for a <a href="http://spring.io/blog/2014/10/01/webinar-building-bootful-uis-with-spring-boot-and-vaadin">look how to build Spring Boot-powered Vaadin applications</a>.</li> -<li>Justin Lee Grant has put together <a href="http://www.justinleegrant.com/?p=489">a good introductory look at Spring Boot</a>.</li> -<li>Spring lead Juergen Hoeller just <a href="http://spring.io/blog/2014/10/01/spring-framework-4-1-1-released">announced the 4.1.1 release of Spring framework</a>. This release includes improved <code>Optional</code> handling, a Jackson <code>ObjectMapper</code> builder, some requested JDBC improvements, and much more. </li> -<li>The good Dr. Syer just announced <a href="http://spring.io/blog/2014/10/07/spring-cloud-1-0-0-m1-available-now">the first milestone release of the Spring Cloud project</a>. Spring Cloud provides primatives for building microservice and PaaS-centric applications. It builds on top of the Netflix OSS stack and Spring Boot.</li> -<li>Karthik Abram put together <a href="http://www.eclecticlogic.com/2014/09/01/classpath-scanning/">a nice post on a hidden gem in Spring: the <code>ClassPathScanningCandidateComponentProvider</code></a> class, which makes it easy to discover beans of a certain type. </li> -<li>Nicolas Lejeune has written up a fascinating look at how he managed <a href="http://labs.bsb.com/2014/09/turn-a-legacy-app-into-a-cf-service/">to convert a legacy application (it uses EJB3) and move it to a Cloud Foundry environment</a> </li> -<li>Our pal Toshiaki Maki put together <a href="http://github.com/making/spring-boot-blank">his ideal Spring Boot Maven archetype</a>, and <a href="http://twitter.com/making/status/519626091934134272">shared it</a>!<br> -</li> -<li>Are you a Groovy fan? (who isn't??) Check out Groovy project lead Guillaume LaForge's weekly roundup, <a href="http://t.co/AiDLC6novd"><em>This Week in Groovy</em></a>!</li> -<li>Do you want <a href="http://mikusa.blogspot.com/2014/08/debugging-java-applications-on.html">to debug applications deployed on Cloud Foundry</a>? Daniel Mikusa put together a very nice post explaining one approach. </li> -</ol> - - - Streaming JSON Patch from Spring to a React UI - - - - Brian Cavalier - - tag:spring.io,2014-10-07:1782 - 2014-10-08T01:47:03Z - <p>We're exploring ways to help developers create rich, modern front-ends that integrate easily with Spring back-ends. If you attended SpringOne this year, you've already seen some of the things we've been working on:</p> - -<ol> -<li> -<a href="https://speakerdeck.com/gregturn/springone2gx-2014-spring-data-rest-data-meets-hypermedia">Hypermedia support in Spring Data REST</a> presented by Greg Turnquist, Oliver Gierke, and Roy Clarkson</li> -<li> -<a href="http://www.slideshare.net/unscriptable/rave-js-springone-2gx-2014">RaveJS: Spring Boot concepts for JavaScript applications</a> by John Hann</li> -<li> -<a href="http://www.slideshare.net/briancavalier/differential-sync-and-json-patch-s2-gx-2014">Differential Synchronization and JSON Patch</a> by Craig Walls and me</li> -</ol><p>In short, We want to make it easy to communicate efficiently between a Spring back-end and a client and to easily integrate the best and most popular client-side technologies.</p> - -<h2> -<a name="user-content-react--streaming-updates" class="anchor" href="#react--streaming-updates" aria-hidden="true"><span class="octicon octicon-link"></span></a>React + streaming updates</h2> - -<p>JSON Patch is a format for sending incremental changes to structured data. I thought it would be interesting to try streaming updates in JSON Patch format via STOMP all the way out to a web UI.</p> - -<p>Craig Walls had already built a simple <a href="https://github.com/habuma/scores">football scores proof of concept</a>, using the new <a href="https://github.com/spring-projects/spring-sync/">Spring Sync</a> project to push score updates to a browser using JSON Patch over STOMP. I was able to take his POC, drop in RaveJS, add client-side reactive streams, and integrate the updates into a <a href="http://facebook.github.io/react/">React</a> UI component.</p> - -<p>You can find the <a href="https://github.com/briancavalier/scores">complete code on github in my rave-most-react branch</a>. The server is unchanged from Craig's original version. The <a href="https://github.com/briancavalier/scores/tree/rave-most-react/src/main/resources/public">web client</a> is where the action is. Have a look at the <a href="https://github.com/briancavalier/scores/blob/rave-most-react/src/main/resources/public/main.js">main.js to get an overall sense of the app</a> before we dive into some specifics.</p> - -<h2> -<a name="user-content-starting-out" class="anchor" href="#starting-out" aria-hidden="true"><span class="octicon octicon-link"></span></a>Starting out</h2> - -<p>I used <a href="https://github.com/RaveJS/rave">RaveJS</a> and npm to manage my client side dependencies, so my startup was simple:</p> - -<div class="highlight highlight-sh"><pre>&gt; <span class="nb">cd </span>src/main/resources/public - -&gt; npm init - -&lt;answer a few questions&gt; - -&gt; npm install --save rave most jiff react rave-load-jsx rave-node-process stompjs -</pre></div> - -<p>Then I just needed a single script tag in the existing HTML, and I was off to coding!</p> - -<div class="highlight highlight-html"><pre><span class="nt">&lt;script </span><span class="na">src=</span><span class="s">"node_modules/rave/rave.js"</span><span class="nt">&gt;&lt;/script&gt;</span> -</pre></div> - -<h2> -<a name="user-content-introducing-mostjs" class="anchor" href="#introducing-mostjs" aria-hidden="true"><span class="octicon octicon-link"></span></a>Introducing most.js</h2> - -<p>Thanks to Craig, I already had a stream of updates (in JSON Patch format) flowing to the client over STOMP. I decided that the nicest way to work with the stream of patches would be to (surprise!) <em>actually use a stream</em>.</p> - -<p><a href="https://github.com/cujojs/most">Most.js</a> is cujoJS's new JavaScript reactive streams package. It provides a small, but powerful set of APIs for creating, transforming, and consuming event streams. I used it to wrap up the stompjs API.</p> - -<p>It turns out that there were two STOMP subscriptions: one that carried an initial, complete copy of all the score data, and another that carried all the subsequent changes. I was able to wrap both subscriptions up into a single reactive stream representing "the latest set of scores" by using <a href="https://github.com/cujojs/jiff">jiff.js</a> to apply the JSON Patches as they arrived.</p> - -<p>This bit of code creates a stream from a STOMP subscription to the initial data, takes the first event (a complete snapshot of all scores), and combines it with a second stream containing only JSON Patch updates to produce a view of the scores that changes over time.</p> - -<div class="highlight highlight-js"><pre><span class="kd">function</span> <span class="nx">getScoresStream</span><span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> <span class="p">{</span> - <span class="c1">// Create a stream containing one full copy of the data, and</span> - <span class="c1">// flatMap that to a stream containing the time-varying</span> - <span class="c1">// current set of scores, by accumulating each patch</span> - <span class="c1">// and emitting the updated scores data.</span> - <span class="k">return</span> <span class="nx">getInitialDataStream</span><span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> - <span class="p">.</span><span class="nx">flatMap</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span> - <span class="k">return</span> <span class="nx">getUpdatesStream</span><span class="p">(</span><span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span> - <span class="p">});</span> -<span class="p">}</span> - -<span class="kd">function</span> <span class="nx">getInitialDataStream</span> <span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> <span class="p">{</span> - <span class="c1">// Await a copy of the data from the STOMP subscription</span> - <span class="c1">// that is sending the full scores data, then unsubscribe.</span> - <span class="k">return</span> <span class="nx">streamFromStompJson</span><span class="p">(</span><span class="nx">initDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> - <span class="p">.</span><span class="nx">take</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span> -<span class="p">}</span> - -<span class="kd">function</span> <span class="nx">getUpdatesStream</span> <span class="p">(</span><span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span> - <span class="c1">// Incrementally accumulate patches from the STOMP subscription</span> - <span class="c1">// that is carrying JSON Patches onto the scores data to produce</span> - <span class="c1">// an updated view of the scores.</span> - <span class="k">return</span> <span class="nx">streamFromStompJson</span><span class="p">(</span><span class="nx">updateDestination</span><span class="p">,</span> <span class="nx">client</span><span class="p">)</span> - <span class="p">.</span><span class="nx">startWith</span><span class="p">([])</span> - <span class="p">.</span><span class="nx">scan</span><span class="p">(</span><span class="nx">updateWithJsonPatch</span><span class="p">,</span> <span class="nx">data</span><span class="p">);</span> -<span class="p">}</span> -</pre></div> - -<p>Most.js also automatically cleans up underlying resources when streams end. It was easy to arrange to unsubscribe from the first subscription after an initial copy of the full scores data had arrived, leaving only one subscription: the changes.</p> - -<h2> -<a name="user-content-making-the-ui-with-react" class="anchor" href="#making-the-ui-with-react" aria-hidden="true"><span class="octicon octicon-link"></span></a>Making the UI with React</h2> - -<p>Now that I had a single most.js stream representing the latest scores, I created a <a href="https://github.com/briancavalier/scores/blob/rave-most-react/src/main/resources/public/Scoreboard.jsx">React component to display them</a>. I installed (see above) the <a href="https://github.com/KidkArolis/rave-load-jsx">rave-load-jsx extension</a>, a RaveJS extension created by a community member, which enables direct JSX component loading in RaveJS. All I had to do was create a Scoreboard.jsx file and start coding a simple React scoreboard component.</p> - -<p>React components have an internal <code>state</code> object containing the data that will be used to render the component. All I needed to do was pass the latest scores stream when creating the component, and then have the component observe the stream and update its <code>state</code>. The relevant bit of code is only a couple lines:</p> - -<div class="highlight highlight-js"><pre><span class="c1">// this.props.scores is the scores stream provided when the</span> -<span class="c1">// Scoreboard component is created</span> - -<span class="k">this</span><span class="p">.</span><span class="nx">props</span><span class="p">.</span><span class="nx">scores</span><span class="p">.</span><span class="nx">observe</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">scores</span><span class="p">)</span> <span class="p">{</span> - <span class="nx">self</span><span class="p">.</span><span class="nx">setState</span><span class="p">({</span> <span class="nx">scores</span><span class="o">:</span> <span class="nx">scores</span> <span class="p">});</span> -<span class="p">});</span> -</pre></div> - -<p>React took care of automatically keeping the DOM in sync with the <code>state</code>.</p> - -<h2> -<a name="user-content-from-bits-to-pixels" class="anchor" href="#from-bits-to-pixels" aria-hidden="true"><span class="octicon octicon-link"></span></a>From bits to pixels</h2> - -<p>This is admittedly a toy app. However, it shows quite a few powerful concepts working together in a very small space, with very little code: small, server-generated deltas flowing over STOMP + WebSocket, to a reactive stream on the client being observed by a React component. Changes are flowing from a Spring back-end through to the UI--bits to pixels, as it were.</p> - -<p>I hope this tiny app also provides a glimpse at the direction we're headed. We want to provide tools and client-side packages that help developers build rich, modern client applications that integrate with leading client-side technologies and Spring back-ends.</p> - - - Spring Cloud 1.0.0.M1 Available Now - - - - Dave Syer - - tag:spring.io,2014-10-07:1781 - 2014-10-07T13:25:00Z - <p><a href="http://projects.spring.io/spring-cloud">Spring Cloud</a> (the new umbrella project announced in September) has reached a milestone, its first, and fresh jars are available in the <a href="http://repo.spring.io/libs-milestone-local">repo.spring.io</a> repository. Spring Cloud is going to follow a "release train" model for releases, a bit like Spring Data, but we haven't got a cool name for this one yet, so it's just 1.0.0.M1. The modules that are part of this release are </p> - -<ul> -<li><p>Spring Cloud Config: Centralized external configuration management backed by a git repository. The configuration resources map directly to Spring <code>Environment</code> but could be used by non-Spring applications if desired.</p></li> -<li><p>Spring Cloud Netflix: Integration with various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.).</p></li> -<li><p>Spring Cloud Bus: An event bus for linking services and service instances together with distributed messaging. Useful for propagating state changes across a cluster (e.g. config change events).</p></li> -<li><p>Spring Cloud Security: A set of primitives for building secure applications and services with minimum fuss.</p></li> -<li><p>Spring Cloud CLI: Spring Boot CLI plugin for creating Spring Cloud component applications quickly in Groovy.</p></li> -<li><p>Spring Cloud Starters: Spring Boot-style starter projects to ease dependency management for consumers of Spring Cloud.</p></li> -</ul><p>All of the above have the 1.0.0.M1 release tag, so a good starting point to try it out would be to <a href="http://projects.spring.io/spring-cloud/spring-cloud.html#_installation">install the CLI</a> and run Config Server with this code:</p> - -<div class="highlight highlight-groovy"><pre><span class="nd">@EnableConfigServer</span> -<span class="kd">class</span> <span class="nc">ConfigServer</span> <span class="o">{</span> -<span class="o">}</span> -</pre></div> - -<p>then hit <code>http://localhost:8080/foo/default</code> to see some property sources.</p> - -<p>The <a href="https://github.com/spring-cloud">code</a> is hosted on github, and community contributions are extremely welcome, so get on over there are check it out. There are some neat samples in a separate organization: <a href="https://github.com/spring-cloud-samples">spring-cloud-samples</a>, including a "scripts" project that has git submodules and scripts to get a complete demo system up and running as quickly as possible.</p> - - - Spring XD 1.0.1 released - - - - Mark Pollack - - tag:spring.io,2014-10-02:1780 - 2014-10-02T22:49:48Z - <p>On behalf of the Spring XD team, I am very pleased to announce the general availability of Spring XD 1.0.1! </p> - -<p>This release includes <a href="https://jira.spring.io/secure/ReleaseNote.jspa?projectId=11401&amp;version=14685">bug fixes and enhancements</a> as well as some new features:</p> - -<ul> -<li> -<a href="https://github.com/spring-projects/spring-xd/wiki/Application-Configuration#enabling-https">HTTPS access</a> and <a href="https://github.com/spring-projects/spring-xd/wiki/Application-Configuration#enabling-authentication">Authentication</a> to Admin Server</li> -<li> -<a href="https://github.com/spring-projects/spring-xd/wiki/AdminUI#containers">Cluster</a> and <a href="https://github.com/spring-projects/spring-xd/wiki/AdminUI#streams">Stream</a> views in UI</li> -<li>Configure a <a href="https://github.com/spring-projects/spring-xd/wiki/Modules#custom-module-registry">location for custom modules</a> -</li> -<li><a href="https://github.com/spring-projects/spring-xd/wiki/Sinks#null-sink">Null sink</a></li> -</ul><p>You can <a href="http://repo.spring.io/release/org/springframework/xd/spring-xd/1.0.1.RELEASE/spring-xd-1.0.1.RELEASE-dist.zip">download the zip distribution</a> or install on OSX <a href="https://github.com/spring-projects/spring-xd/wiki/Getting-Started#osx-homebrew-installation">using homebrew</a>. On RHEL/CentOs you can <a href="https://github.com/spring-projects/spring-xd/wiki/Getting-Started#redhatcentos-installation">install using yum</a>.</p> - -<p>Feedback is very important, so please get in touch with questions and comments via</p> - -<ul> -<li> -<a href="http://stackoverflow.com/questions/tagged/spring-xd">StackOverflow</a> <code>spring-xd</code> tag</li> -<li> -<a href="https://jira.spring.io/browse/XD/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel">Spring JIRA</a> or <a href="https://github.com/spring-projects/spring-xd/issues">GitHub Issues</a> -</li> -</ul> - - - Spring Framework 4.1.1 released - - - - Juergen Hoeller - - tag:spring.io,2014-10-01:1779 - 2014-10-01T13:15:00Z - <p>Dear Spring community,</p> - -<p>I'm pleased to announce that Spring Framework 4.1.1 is available now. As the <b>first maintenance release in the 4.1 line</b>, this release contains a wide range of fixes for regressions and other issues reported against 4.1 GA. A big thank you to all the issue reporters out there!</p> - -<p>4.1.1 also comes with a <b>selection of minor enhancements</b>, for example: consistent handling of Java 8's Optional type, a Jackson ObjectMapper builder class with refined defaults, some requested JDBC refinements, as well as <b>specific performance improvements</b>.</p> - -<p><a href="https://jira.spring.io/issues/?jql=project%20%3D%20SPR%20AND%20fixVersion%20%3D%204.1.1%20ORDER%20BY%20issuetype%20ASC">-&gt; List of resolved JIRA issues for Spring Framework 4.1.1</a></p> - -<p>We strongly recommend an immediate upgrade to 4.1.1 for all 4.1 GA users. The Spring Framework team is now working towards <b>Spring Framework 4.1.2 at the end of October</b>, which will be the foundation for the upcoming Spring Boot 1.2 GA release.</p> - -<p>On a related note, along with 4.1.2, we are preparing <b>Spring Framework 4.0.8 as the last 4.0.x maintenance release</b>. If there is anything you'd like to get fixed in the 4.0.x branch still, now is the time to raise it! Otherwise, please upgrade to 4.1.x for ongoing active maintenance.</p> - -<p>Cheers,</p> - -<p>Juergen</p> - - - This Week in Spring - September 30, 2014 - - - - Josh Long - - tag:spring.io,2014-10-01:1774 - 2014-10-01T03:20:00Z - <p>Welcome to another installment of <em>This Week in Spring!</em> This week <a href="http://spring.io/blog/2014/09/26/pivotal-at-javaone-2014">the Spring team is at JavaOne</a>! There's been, and will be, <em>lots</em> to see! We're also hanging out at the booth, talking to as many users as possible. Check out the link I just give listing all the cool Pivotal (and non-Pivotal) talks at JavaOne. (Ahem. Naturally, I personally would <em>love</em> it if you made <a href="http://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3693&amp;tclass=popup">my talk - <em>Spring4TW!</em> - tomorrow morning at 8:30am at Parc 55, Cyril Magnin II/III</a>!).</p> - -<p></p><p><a href="https://raw.githubusercontent.com/joshlong/meh/master/javaone2014-boot-twis.jpg" target="_blank"><img src="https://raw.githubusercontent.com/joshlong/meh/master/javaone2014-boot-twis.jpg" style="max-width:100%;"></a></p><p>In addition to IoT, Big Data, and Microservice demos using <a href="http://projects.spring.io/spring-cloud/">NetFlixOSS on Spring</a>, students were doing the coding challenge to build a <a href="https://spring.io/guides/gs/rest-service/">REST service with Spring Boot</a> and pushed to <a href="http://run.pivotal.io">Pivotal Web Services</a> in &lt; 15 minutes to get the <a href="http://preshavedyak.com/">preshavedyak hoodie</a> from American Apparel, and learning about the best PaaS for Java available on the market today; Java 8 / Tomcat 8 support was released just days ago, and there is strong support for Spring, Groovy and Grails.</p><ul> -<li>I really liked Michael Plod's <a href="http://spring.io/blog/2014/09/26/webinar-replay-why-i-recommend-spring"><em>Why I Recommend Spring</em> webinar</a>, now available online as a replay</li> -<li>Last week, Activiti BPMN2 engine co-founder Joram Barrez and I gave a talk on <a href="http://spring.io/blog/2014/09/26/webinar-replay-process-driven-spring-applications-with-activiti">how to build process (read: workflow) centric Spring applications</a>, also now available online. </li> -<li>Tuesday, Oct 21st, 2014 join <a href="https://twitter.com/mstine">Matt Stine</a> for microservice architecture series #2: <a href="http://spring.io/blog/2014/10/01/webinar-architecting-for-continuous-delivery-microservices-with-pivotal-cf-and-spring-cloud">Architecting for Continuous Delivery: Microservices with Pivotal CF and Spring Cloud</a> -</li> -<li>Thursday, October 23, 2014, 2014 <a href="http://spring.io/blog/2014/10/01/webinar-building-bootful-uis-with-spring-boot-and-vaadin">Building “Bootful” UIs with Spring Boot and Vaadin</a> -</li> -<li>Tuesday, November 4, 2014 - microservice architecture series #3 - Join <a href="https://twitter.com/david_syer">Dr. Dave Syer</a> on <a href="http://spring.io/blog/2014/10/01/webinar-security-for-microservices-with-spring-and-oauth2">Security for Microservices with Spring and OAuth2</a> -</li> -<li>Missed microservice architecture #1? Catch the replay of <a href="http://spring.io/blog/2014/09/17/webinar-replay-building-bootiful-microservices-with-spring-boot">Building "Bootiful" Microservices with Spring Boot</a> on the Spring Developer Channel</li> -<li> -<a href="http://spring.io/blog/2014/09/26/spring-boot-1-1-7-released">Spring Boot 1.1.7 is now available</a>! </li> -<li> -<a href="http://raymondhlee.wordpress.com/2014/09/20/setup-spring-security-with-active-directory-ldap-in-spring-boot-web-application/">Setup Spring Security with Active Directory LDAP in Spring Boot Web Application</a> (I <em>just</em> got asked about this at the Spring BOF yesterday!)</li> -<li>There's been an interesting debate on microservices recently. <a href="http://blog.cleancoder.com/uncle-bob/2014/09/19/MicroServicesAndJars.html">"Uncle" Bob Martin has written up a post claiming that <code>.jar</code>s and Ruby <code>gem</code>s give you the same benefit of microservices</a>. There's a <a href="http://www.giorgiosironi.com/2014/09/microservices-are-not-jars.html">great rebuttal (which I happen to agree with..) by Giorgio Sironi on his blog</a>. There's even a nice wrapup of <a href="http://www.infoq.com/news/2014/09/microservices-shared-libraries?utm_source=infoq&amp;utm_medium=popular_links_homepage">the whole discussion on InfoQ</a>.</li> -<li>I really dig <a href="http://blog.pivotal.io/cloud-foundry-pivotal/case-studies-2/platform-wind-tunnel-part-i-heroku">Matt Stine's <em>wind tunnel</em> comparison of PaaSes</a>. Up first: Heroku. I can't wait to see subsequent posts in the series!</li> -<li>This post on using Spring Data Redis was published (and included in <em>TWiS</em>..) last year, <a href="http://www.ibm.com/developerworks/library/os-springredis/index.html">but it came up again and I still thnk it's a worthy read</a> </li> -<li>The eHarmony blog has a nice post on <a href="http://www.eharmony.com/engineering/spring-batch-admin-the-tricky-parts/#.VCtPFildUpg">how to setup Spring Batch Admin (the tricky parts..)</a> -</li> -<li>In the <em>you have to see it to beleive it</em> department, did you know there's a <a href="http://bitbucket.org/sglienke/spring4d">Spring for Delphi (Spring4D) project</a>? There are Spring-inspired C++, ColdFusion, JavaScript, .NET, Python, and numerous others. Cool to add this to the list.</li> -<li>The Intertech blog has <a href="http://www.intertech.com/Blog/spring-integration-tutorial-part-7-service-activators/">another installment on their <em>epic</em> Spring Integration tutorial</a>. This one's on <em>service activators</em> - basically the Spring Integration escape-hatch so you can call regular Java objects.</li> -<li>Benjamin Ball has a great <a href="http://java.dzone.com/articles/getting-started-rabbitmq-and">writeup on using RabbitMQ and Spring</a> </li> -<li>Yashwant Chavan has a nice post on building a simple <a href="http://www.technicalkeeda.com/spring/spring-boot-mvc-example">Spring Boot (with Spring MVC) example and editing it in Eclipse</a>. </li> -<li>Our pals at Codecentric are at it again! They've just released <a href="http://blog.codecentric.de/en/2014/09/spring-boot-admin-first-official-release/">their first cut of their <em>Spring Boot Admin</em></a>. This looks like something that would fit nicely in the <a href="http://github.com/spring-cloud/">Spring Cloud</a> project... </li> -<li> -<a href="http://prezi.com/ob4vxjmj_h1f/spring-boot/">This has to be one of the coolest Spring Boot presentations, ever</a>! Careful, I don't recommend watching it full-screen if you get motion sickness! :)</li> -<li>Are you stuck on Apache CXF but still want first-class security? This post <a href="http://java.dzone.com/articles/embedded-jetty-and-apache-cxf">looks at how to plugin Spring Security on top of CXF in minutes</a> </li> -<li>Biju Kunjummen did a nice job <a href="http://java.dzone.com/articles/spring-1">clarifying the differences between Spring's <code>WebApplicationInitializer</code> and <code>ApplicationContextInitializer</code></a> -</li> -</ul> - - - Webinar: Architecting for Continuous Delivery: Microservices with Pivotal CF and Spring Cloud - - - - Pieter Humphrey - - tag:spring.io,2014-10-01:1776 - 2014-10-01T02:20:00Z - <p>Speaker: Matt Stine, Pivotal </p> - -<p>Join Matt Stine to hear how you can architect systems that are optimized for continuous delivery, allowing you to innovate and deliver value faster and safer. Microservices, Pivotal CF, and Spring Cloud combine to create an operationalized architecture that enables enterprises to continuously deliver value at scale through rapid, iterative development, and to meet the needs of a mobile-first world.</p> - -<p>Tuesday, Oct 21st, 2014 3:00PM BST (London GMT+01:00) <a href="http://connect.pivotal.io/OSS_Webinar_MicroserviceswithPivotalCFandSpringCloud7AM_Register.html">Register</a></p> - -<p>Tuesday, Oct 21st, 2014 10:00AM PDT (San Francisco GMT-07:00) <a href="http://connect.pivotal.io/OSS_Webinar_MicroserviceswithPivotalCFandSpringCloud10AM_Register.html">Register</a></p> - - - Webinar: Building “Bootful” UIs with Spring Boot and Vaadin - - - - Pieter Humphrey - - tag:spring.io,2014-10-01:1777 - 2014-10-01T01:20:00Z - <p>Speaker: Josh Long, Pivotal and Vaadin</p> - -<p> It's been a long day, but you've done it: you've got a Spring Boot powered backend and now you need to build the UI that'll power the workforce and deliver next week. Vaadin, a UI framework that marries the ease of use of server-side Java and the rich, dynamic nature of client-side JavaScript, integrates well with Spring Boot and offers UI polish that would be hard to secure any other way. Join Spring developer advocate Josh Long and Vaadin evangelists for a look at how Vaadin and Spring Boot can get you to production quicker, and easier.</p> - -<p>Thursday, October 23, 2014, 2014 3:00PM BST (London GMT+01:00) <a href="http://connect.pivotal.io/OSS_Webinar_BuildingBootfulUIswithSpringBootandVaadin7AM_Register.html">Register</a></p> - -<p>Thursday, October 23, 2014 10:00AM PDT (San Francisco GMT-07:00) <a href="http://connect.pivotal.io/OSS_Webinar_BuildingBootfulUIswithSpringBootandVaadin10AM_Register.html">Register</a></p> - - - Webinar: Security for Microservices with Spring and OAuth2 - - - - Pieter Humphrey - - tag:spring.io,2014-10-01:1778 - 2014-10-01T01:10:00Z - <p>Speaker: Dave Syer</p> - -<p>Security for Microservices with Spring and OAuth2 OAuth2 is a lightweight security protocol that is well-suited for use with HTTP, the protocol at the heart of many modern architectures. Spring Security OAuth2 has a load of new features, not the least of which being the `@Configuration` support in version 2.0. Combine these with Spring Boot and you have a platform which can get you a secure HTTP service application in about 20 lines of code. This presentation shows how the combination of rapid development and production-ready features in the modern Spring stack are a perfect mixture for developing secure components in a system composed of microservices. We explore the new features in Spring OAuth2, guide you through the choice of which to use and when, and show how easy they are to enable quickly.</p> - -<p>Tuesday, November 4, 2014 3:00PM GMT (London GMT) <a href="http://connect.pivotal.io/OSS_Webinar_SecurityforMicroserviceswithSpringandOAuth2_7AM_Register.html">Register</a></p> - -<p>Tuesday, November 4, 2014 10:00AM PST (San Francisco GMT-08:00) <a href="http://connect.pivotal.io/OSS_Webinar_SecurityforMicroserviceswithSpringandOAuth2_10AM_Register.html">Register</a></p> - - - Webinar Replay: Why I Recommend Spring - - - - Pieter Humphrey - - tag:spring.io,2014-09-26:1773 - 2014-09-26T14:03:00Z - <p>Speaker: Michael Plod</p> - -<p>Slides: <a href="https://speakerdeck.com/mploed/pivotal-webinar-why-do-i-recommend-spring">https://speakerdeck.com/mploed/pivotal-webinar-why-do-i-recommend-spring</a></p> - -<p>Is Spring the new legacy as quite a few people tell you on their blogs? I disagree on many levels. Throughout this session I will holistically detail without any polemics why I do recommend using the Spring Framework and its ecosystem. Aspects that will be covered include: operational impacts, ecosystem, coding and road maps. This presentation is aimed at IT managers, Architects and Developers alike.</p> - -<p>Learn more about Spring IO: <a href="http://spring.io">http://spring.io</a></p> - -<p>Learn more about Spring IO Platform: <a href="http://spring.io/platform">http://spring.io/platform</a></p> - -<p></p><iframe width="420" height="315" src="//www.youtube.com/embed/z1rpWpSKtT8" frameborder="0" allowfullscreen></iframe> - - - Webinar Replay: Process Driven Spring Applications with Activiti - - - - Pieter Humphrey - - tag:spring.io,2014-09-26:1772 - 2014-09-26T13:56:00Z - <p>Speakers: Josh Long and Joram Barrez, Activiti </p> - -<p>Slides: <a href="https://speakerdeck.com/joshlong/process-driven-applications-with-spring-boot">https://speakerdeck.com/joshlong/process-driven-applications-with-spring-boot</a> </p> - -<p>Today's applications are complex, distributed systems that - taken together - produce results. Tracking the flow of work through that system, however, becomes increasingly more painful as automated- and human-driven tasks are integrated into business processes. Business can't react to what it can't see. Business can't measure what it can't see. "Workflow" describes the sequence of processes through which a piece of work passes from initiation to completion. Workflow systems, like Activiti, describe and then execute these processes. Activiti is an open-source, Apache 2-licensed workflow engine that works with Spring and Spring Boot. In this webinar, join Spring Developer Advocate Josh Long and Activiti-ninja Joram Barrez for a look at how to distill, describe and reuse complex business processes using Spring (and Spring Boot) and Activiti. </p> - -<p>Learn more about Spring Boot: <a href="http://projects.spring.io/spring-boot">http://projects.spring.io/spring-boot</a> </p> - -<p>Learn more about Activiti below! </p> - -<p>Activiti project page: <a href="http://activiti.org/">http://activiti.org/</a> </p> - -<p>Joram's blog: <a href="http://jorambarrez.com/blog">http://jorambarrez.com/blog</a> </p> - -<p>Activiti documentation: <a href="http://activiti.org/userguide/index.html">http://activiti.org/userguide/index.html</a> </p> - -<p>Activiti Github: <a href="https://github.com/Activiti/Activiti">https://github.com/Activiti/Activiti</a></p> - -<p></p><iframe width="420" height="315" src="//www.youtube.com/embed/0PV_8Lew3vg" frameborder="0" allowfullscreen></iframe> - - - Pivotal at JavaOne 2014 - - - - Pieter Humphrey - - tag:spring.io,2014-09-25:1770 - 2014-09-26T05:56:00Z - <p>Are you heading to JavaOne 2014?   If you are, we invite all of the Java community members to stop by the Pivotal Booth (Booth Number 5201) and talk to Pivotal engineers about the latest innovations in Java SE, in Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Cloud Foundry and Hadoop. The exhibit space is open Monday, Tuesday from 9:30am – 5:30pm, and Wednesday from 9:30am to 4:30pm, so there should be plenty of time to get your questions answered.  See below for a map and booth details about our giveaways - come find us!  Lots of great stuff at the booth.</p> - -<p>Pivotal technologists are also presenting a lot of sessions as well so be sure to add the following talks to your session builder and reserve a seat:<br> -            <br> -Josh Long — Spring advocate at Pivotal</p> -<ul> -<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3868&amp;tclass=popup" target="_blank">The Spring BOF [BOF3868]</a></li> - <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3693&amp;tclass=popup" target="_blank">Spring 4TW! [CON3693]</a></li> -</ul><p>Cornelia Davis — Platform Engineer at Pivotal</p> -<ul> -<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=4327&amp;tclass=popup" target="_blank">Running Your Spring Apps in the Cloud [CON4327]</a></li> -</ul><p>John Field — Solutions Architect at Pivotal</p> -<ul> -<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3478&amp;tclass=popup" target="_blank">Open Source Identity and Access Management Expert Panel, Part 3 [BOF3478]</a></li> - <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=3479&amp;tclass=popup" target="_blank">The Anatomy of a Secure Web Application Using Java [CON3479]</a></li> -</ul><p>Guillaume Laforge — Groovy project manager at Pivotal</p> -<ul> -<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=2939&amp;tclass=popup" target="_blank">Script Bowl 2014: The Battle Rages On [CON2939]</a></li> - <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=5996&amp;tclass=popup" target="_blank">Groovy in 2014 and Beyond [CON5996]</a></li> - <li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=5839&amp;tclass=popup" target="_blank">Groovy in the Light of Java 8 [CON5839]</a></li> -</ul><p>Martin Lippert - Principal Software Engineer at Pivotal</p> -<ul> -<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=1739&amp;tclass=popup" target="_blank">Connecting the Eclipse IDE to the Cloud-Based Era of Developer Tooling [CON1739]</a></li> -</ul><p>Oliver Gierke - Spring Data Project Lead at Pivotal</p> -<ul> -<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=6071&amp;tclass=popup" target="_blank">REST Assured: Hypermedia APIs with Spring MVC [CON6071]</a></li> -</ul><p>Cédric Champeau — Senior software engineer in the Groovy team at Pivotal</p> -<ul> -<li><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=2425&amp;tclass=popup" target="_blank">Rethinking API Design with Groovy Traits [CON2425]</a></li> -</ul><p>Interesting non-Pivotal Sessions</p> -<p><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=1764" target="_blank">Groovy and Grails Puzzlers: As Usual—Traps, Pitfalls, and End Cases[CON1764]</a> <br><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=4952" target="_blank">Microservices on the JVM: A Practical Overview [CON4952]</a></p> -<p><a href="https://oracleus.activeevents.com/2014/connect/sessionDetail.ww?SESSION_ID=9447" target="_blank">Use Java, the Spring Framework, and Oracle Tuxedo to Extend Existing C/C++/COBOL Apps[HOL9447]</a> <br></p><p>Visit us at the booth for technical expert conversations on Cloud Foundry, Spring, Groovy, Grails, Redis, RabbitMQ, Tomcat, Hadoop and much more. We'll have great demos in the booth about:</p> -<ul> -<li> Java EE and PaaS with <a href="http://www.pivotal.io/platform-as-a-service/pivotal-cf">Cloud Foundry</a> via JBoss and WebLogic Buildpack demos</li> - - <li>Internet of Things, Hadoop with <a href="http://projects.spring.io/spring-xd">Spring XD</a> Demos</li> - <li> -<a href="http://microservices.io">Microservice Architecture</a> and <a href="http://www.pivotal.io/platform-as-a-service/pivotal-cf">PaaS</a> with <a href="http://projects.spring.io/spring-boot">Spring Boot</a>, <a href="http://projects.spring.io/spring-cloud">Spring Cloud</a> Demos</li> -</ul><p><a href="http://run.pivotal.io">Pivotal Web Services</a> Hoodie Push!  <a href="https://spring.io/guides/gs/rest-service/">Build a REST service with Spring Boot</a>, push it live to run.pivotal.io and get a hoodie!  You can do it ahead of time, and show it running to us, or use our laptops at the booth. </p> -<p><a href="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" target="_blank"><img border="0" width="215" height="254" src="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/hoodie.PNG" style="max-width:100%;"></a></p> -<p> </p> -<p> </p> -<p>Save the date for SpringOne2GX 2015!  We hope you will mark your calendar and join us again! SpringOne2GX 2015 will be held September 14 - 17, 2015 at the Marriott Marquis in Washington DC.</p> -<p><a href="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/javaone_booth_pivotal.PNG" target="_blank"><img border="0" width="624" height="398" src="https://raw.githubusercontent.com/pieterhumphrey/springio_website_images/master/javaone_booth_pivotal.PNG" style="max-width:100%;"></a></p> -<p><a href="https://github.com/pieterhumphrey/springio_website_images/blob/master/javaone_booth_pivotal2.PNG" target="_blank"><img src="https://github.com/pieterhumphrey/springio_website_images/raw/master/javaone_booth_pivotal2.PNG" width="577" height="441" style="max-width:100%;"></a></p> -<p><br></p> - - - Spring Boot 1.1.7 released - - - - Phil Webb - - tag:spring.io,2014-09-26:1771 - 2014-09-26T04:56:15Z - <p>Spring Boot 1.1.7 has been released and is available now from <a href="http://repo.spring.io/release">repo.spring.io</a> and <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.springframework.boot%22">Maven Central</a>. </p> - -<p>This maintenance release is a recommended upgrade for all Spring Boot users. For a complete list of changes please refer to the <a href="https://github.com/spring-projects/spring-boot/issues?q=milestone%3A1.1.7">issue tracker</a>.</p> - -<p><a href="http://projects.spring.io/spring-boot/">Project Page</a> | <a href="https://github.com/spring-projects/spring-boot">GitHub</a> | <a href="https://github.com/spring-projects/spring-boot/issues">Issues</a> | <a href="http://docs.spring.io/spring-boot/docs/1.1.7.RELEASE/reference/htmlsingle">Documentation</a></p> - - - Demo: IoT Realized with Spring XD - The Connected Car - - - - Pieter Humphrey - - tag:spring.io,2014-09-25:1769 - 2014-09-24T20:59:00Z - <p>Speaker: Derek Beauregard -Contributors: Phil Berman, Darrel Sharpe, Michael Minella -In this demo we will explore the power of Spring XD in the context of the Internet of Things (IoT). We will look at a solution developed with Spring XD to stream real time analytics from a moving car using open standards. Ingestion of the real time data (location, speed, engine diagnostics, etc), analyzing it to provide highly accurate MPG and vehicle range prediction, as well as providing real time dashboards will all be covered. Watch this demo to get a sense of how Spring XD can serve as a critical building block for the IoT.</p> - -<iframe width="420" height="315" src="//www.youtube.com/embed/qkm2GV57hzY" frameborder="0" allowfullscreen></iframe> - - - diff --git a/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.update/623127801.xml b/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.update/623127801.xml deleted file mode 100644 index f87bdf6f7a..0000000000 --- a/.metadata/.plugins/org.springsource.ide.eclipse.dashboard.ui/feeds/dashboard.feeds.update/623127801.xml +++ /dev/null @@ -1,291 +0,0 @@ - - - - SpringSource Tool Suites Updates - http://www.springsource.com/products/sts - This feeds imforms about important updates relevant to users of STS. - Feeder 2.0.7(1195) http://reinventedsoftware.com/feeder/ - http://blogs.law.harvard.edu/tech/rss - en-us - sts@springsource.com - Mon, 13 Oct 2014 10:38:33 +0100 - Mon, 13 Oct 2014 10:38:33 +0100 - - - - - - Thanks for installing STS/GGTS 3.6.2 - http://spring.io/tools -

Pivotal has released an update to Spring Tool Suite (STS) and Groovy/Grails Tool Suite (GGTS), the best Eclipse-powered development environment for building Spring, Groovy, and Grails powered enterprise application.

-

Please review the following documents:

-
  • 3.6.2 New & Noteworthy
  • ]]>
    - Mon, 13 Oct 2014 12:13:33 +0100 - version=[3.6.2.201410090827-RELEASE,3.6.3) - - thanks-for-installing-sts-362 -
    - - - STS/GGTS 3.6.2 has been released - http://spring.io/tools -

    Pivotal has released an update to Spring Tool Suite (STS) and Groovy/Grails Tool Suite (GGTS), the best Eclipse-powered development environment for building Spring, Groovy, and Grails powered enterprise application.

    It is recommend to update as soon as possible.

    -

    Please review the following documents:

    -
  • 3.6.2 New & Noteworthy
  • ]]>
    - Mon, 13 Oct 2014 12:12:33 +0100 - version=[0,3.6.2.201410090827-RELEASE) - severity=important - sts-362-released -
    - - - - Cloud Foundry Eclipse 1.7.1 released - http://www.cloudfoundry.com -

    Pivotal has released Cloud Foundry Eclipse version 1.7.1 which features various application deployment and home page navigation improvements, and a new Cloud Routes wizard for browsing and deleting application routes. Java 7 is a required Execution Environment.

    ]]>
    - Tue, 16 Sep 2014 10:38:33 +0100 - - - bundle=!org.cloudfoundry.ide.eclipse.feature.group - cloud-foundry-integration-171-released -
    - - - - - - Patch released to fix a Xerces classloading issue - https://issuetracker.springsource.com/browse/STS-1672 -

    SpringSource has just published a patch to fix a severe issue in STS that causes parsing of Spring XML files to fail with a Xerces classloading issue.

    It is recommend to update as soon as possible. The feature patch is available from the STS Dashboard -> Extensions tab.

    -

    Get to get more details about the issue please read the following bug entries:

    -
  • Issue in the STS JIRA
  • -
  • Community forum discussion
  • We apologize that this patch did not make it into the 2.6.0 release of STS.

    ]]>
    - Mon, 21 Mar 2011 10:38:33 +0100 - version=[2.6.0.201103160035-RELEASE,2.7.0.201105101000-M1) - severity=important - bundle=!org.springframework.ide.eclipse.patch.feature.feature.group - patch-STS1672-released -
    - - - - - - - - - - -
    -
    diff --git a/.metadata/version.ini b/.metadata/version.ini deleted file mode 100644 index c51ff745b6..0000000000 --- a/.metadata/version.ini +++ /dev/null @@ -1 +0,0 @@ -org.eclipse.core.runtime=1 \ No newline at end of file diff --git a/README.md b/README.md index 25398d1d39..d94a786bc2 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,4 @@ Any IDE can be used to work with the projects, but if you're using Eclipse, cons CI - Jenkins ================================ -This tutorials project is being built **[>> HERE](https://rest-security.ci.cloudbees.com/job/github%20projects%20Jobs/job/tutorials/)** +This tutorials project is being built **[>> HERE](https://rest-security.ci.cloudbees.com/job/tutorials-unit/)** diff --git a/algorithms/README.md b/algorithms/README.md index 8cf4c35b68..b0c5ee9d77 100644 --- a/algorithms/README.md +++ b/algorithms/README.md @@ -3,9 +3,14 @@ - [Dijkstra Algorithm in Java](http://www.baeldung.com/java-dijkstra) - [Introduction to Cobertura](http://www.baeldung.com/cobertura) - [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization) -- [Validating Input With Finite Automata in Java](http://www.baeldung.com/finite-automata-java) +- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata) - [Introduction to Jenetics Library](http://www.baeldung.com/jenetics) - [Check If a Number Is Prime in Java](http://www.baeldung.com/java-prime-numbers) - [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm) - [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search) - [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms) +- [Test a Linked List for Cyclicity](http://www.baeldung.com/java-linked-list-cyclicity) +- [Binary Search Algorithm in Java](http://www.baeldung.com/java-binary-search) +- [Bubble Sort in Java](http://www.baeldung.com/java-bubble-sort) +- [Introduction to JGraphT](http://www.baeldung.com/jgrapht) +- [Introduction to Minimax Algorithm](http://www.baeldung.com/java-minimax-algorithm) diff --git a/algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java b/algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java new file mode 100644 index 0000000000..a561072b2e --- /dev/null +++ b/algorithms/src/main/java/com/baeldung/algorithms/bubblesort/BubbleSort.java @@ -0,0 +1,40 @@ +package com.baeldung.algorithms.bubblesort; + +import java.util.stream.IntStream; + +public class BubbleSort { + + void bubbleSort(Integer[] arr) { + int n = arr.length; + IntStream.range(0, n - 1) + .flatMap(i -> IntStream.range(i + 1, n - i)) + .forEach(j -> { + if (arr[j - 1] > arr[j]) { + int temp = arr[j]; + arr[j] = arr[j - 1]; + arr[j - 1] = temp; + } + }); + } + + void optimizedBubbleSort(Integer[] arr) { + int i = 0, n = arr.length; + + boolean swapNeeded = true; + while (i < n - 1 && swapNeeded) { + swapNeeded = false; + for (int j = 1; j < n - i; j++) { + if (arr[j - 1] > arr[j]) { + + int temp = arr[j - 1]; + arr[j - 1] = arr[j]; + arr[j] = temp; + swapNeeded = true; + } + } + if (!swapNeeded) + break; + i++; + } + } +} diff --git a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java b/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java new file mode 100644 index 0000000000..e884c576c1 --- /dev/null +++ b/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceBase.java @@ -0,0 +1,22 @@ +package com.baeldung.algorithms.editdistance; + +public class EditDistanceBase { + + public static int costOfSubstitution(char a, char b) { + if (a == b) { + return 0; + } + return 1; + } + + public static int min(int... numbers) { + int min = Integer.MAX_VALUE; + + for (int x : numbers) { + if (x < min) + min = x; + } + + return min; + } +} diff --git a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java b/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java new file mode 100644 index 0000000000..163714002b --- /dev/null +++ b/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceDynamicProgramming.java @@ -0,0 +1,25 @@ +package com.baeldung.algorithms.editdistance; + +public class EditDistanceDynamicProgramming extends EditDistanceBase { + + public static int calculate(String x, String y) { + int[][] dp = new int[x.length() + 1][y.length() + 1]; + + for (int i = 0; i <= x.length(); i++) { + for (int j = 0; j <= y.length(); j++) { + if (i == 0) + dp[i][j] = j; + + else if (j == 0) + dp[i][j] = i; + + else { + dp[i][j] = min(dp[i - 1][j - 1] + costOfSubstitution(x.charAt(i - 1), y.charAt(j - 1)), dp[i - 1][j] + 1, dp[i][j - 1] + 1); + } + } + } + + return dp[x.length()][y.length()]; + } + +} diff --git a/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java b/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java new file mode 100644 index 0000000000..68e470147e --- /dev/null +++ b/algorithms/src/main/java/com/baeldung/algorithms/editdistance/EditDistanceRecursive.java @@ -0,0 +1,20 @@ +package com.baeldung.algorithms.editdistance; + +public class EditDistanceRecursive extends EditDistanceBase { + + public static int calculate(String x, String y) { + + if (x.isEmpty()) + return y.length(); + + if (y.isEmpty()) + return x.length(); + + int substitution = calculate(x.substring(1), y.substring(1)) + costOfSubstitution(x.charAt(0), y.charAt(0)); + int insertion = calculate(x, y.substring(1)) + 1; + int deletion = calculate(x.substring(1), y) + 1; + + return min(substitution, insertion, deletion); + } + +} diff --git a/algorithms/src/test/java/algorithms/MCTSTest.java b/algorithms/src/test/java/algorithms/MCTSTest.java deleted file mode 100644 index f969c26311..0000000000 --- a/algorithms/src/test/java/algorithms/MCTSTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package algorithms; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import com.baeldung.algorithms.mcts.montecarlo.MonteCarloTreeSearch; -import com.baeldung.algorithms.mcts.montecarlo.State; -import com.baeldung.algorithms.mcts.montecarlo.UCT; -import com.baeldung.algorithms.mcts.tictactoe.Board; -import com.baeldung.algorithms.mcts.tictactoe.Position; -import com.baeldung.algorithms.mcts.tree.Tree; - -public class MCTSTest { - Tree gameTree; - MonteCarloTreeSearch mcts; - - @Before - public void initGameTree() { - gameTree = new Tree(); - mcts = new MonteCarloTreeSearch(); - } - - @Test - public void givenStats_whenGetUCTForNode_thenUCTMatchesWithManualData() { - double uctValue = 15.79; - assertEquals(UCT.uctValue(600, 300, 20), uctValue, 0.01); - } - - @Test - public void giveninitBoardState_whenGetAllPossibleStates_thenNonEmptyList() { - State initState = gameTree.getRoot().getState(); - List possibleStates = initState.getAllPossibleStates(); - assertTrue(possibleStates.size() > 0); - } - - @Test - public void givenEmptyBoard_whenPerformMove_thenLessAvailablePossitions() { - Board board = new Board(); - int initAvailablePositions = board.getEmptyPositions().size(); - board.performMove(Board.P1, new Position(1, 1)); - int availablePositions = board.getEmptyPositions().size(); - assertTrue(initAvailablePositions > availablePositions); - } - - @Test - public void givenEmptyBoard_whenSimulateInterAIPlay_thenGameDraw() { - Board board = new Board(); - - int player = Board.P1; - int totalMoves = Board.DEFAULT_BOARD_SIZE * Board.DEFAULT_BOARD_SIZE; - for (int i = 0; i < totalMoves; i++) { - board = mcts.findNextMove(board, player); - if (board.checkStatus() != -1) { - break; - } - player = 3 - player; - } - int winStatus = board.checkStatus(); - assertEquals(winStatus, Board.DRAW); - } - - @Test - public void givenEmptyBoard_whenLevel1VsLevel3_thenLevel3WinsOrDraw() { - Board board = new Board(); - MonteCarloTreeSearch mcts1 = new MonteCarloTreeSearch(); - mcts1.setLevel(1); - MonteCarloTreeSearch mcts3 = new MonteCarloTreeSearch(); - mcts3.setLevel(3); - - int player = Board.P1; - int totalMoves = Board.DEFAULT_BOARD_SIZE * Board.DEFAULT_BOARD_SIZE; - for (int i = 0; i < totalMoves; i++) { - if (player == Board.P1) - board = mcts3.findNextMove(board, player); - else - board = mcts1.findNextMove(board, player); - - if (board.checkStatus() != -1) { - break; - } - player = 3 - player; - } - int winStatus = board.checkStatus(); - assertTrue(winStatus == Board.DRAW || winStatus == Board.P1); - } - -} diff --git a/algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortTest.java b/algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortTest.java new file mode 100644 index 0000000000..7774eb3e67 --- /dev/null +++ b/algorithms/src/test/java/com/baeldung/algorithms/bubblesort/BubbleSortTest.java @@ -0,0 +1,26 @@ +package com.baeldung.algorithms.bubblesort; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class BubbleSortTest { + + @Test + public void givenIntegerArray_whenSortedWithBubbleSort_thenGetSortedArray() { + Integer[] array = { 2, 1, 4, 6, 3, 5 }; + Integer[] sortedArray = { 1, 2, 3, 4, 5, 6 }; + BubbleSort bubbleSort = new BubbleSort(); + bubbleSort.bubbleSort(array); + assertArrayEquals(array, sortedArray); + } + + @Test + public void givenIntegerArray_whenSortedWithOptimizedBubbleSort_thenGetSortedArray() { + Integer[] array = { 2, 1, 4, 6, 3, 5 }; + Integer[] sortedArray = { 1, 2, 3, 4, 5, 6 }; + BubbleSort bubbleSort = new BubbleSort(); + bubbleSort.optimizedBubbleSort(array); + assertArrayEquals(array, sortedArray); + } +} \ No newline at end of file diff --git a/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java b/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java new file mode 100644 index 0000000000..89bd871616 --- /dev/null +++ b/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceDataProvider.java @@ -0,0 +1,21 @@ +package com.baeldung.algorithms.editdistance; + +import org.junit.runners.Parameterized.Parameters; + +import java.util.Arrays; +import java.util.Collection; + +public class EditDistanceDataProvider { + + @Parameters + public static Collection getLists() { + return Arrays.asList(new Object[][] { + { "", "", 0 }, + { "ago", "", 3 }, + { "", "do", 2 }, + { "abc", "adc", 1 }, + { "peek", "pesek", 1 }, + { "sunday", "saturday", 3 } + }); + } +} diff --git a/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceTest.java b/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceTest.java new file mode 100644 index 0000000000..1594f73a73 --- /dev/null +++ b/algorithms/src/test/java/com/baeldung/algorithms/editdistance/EditDistanceTest.java @@ -0,0 +1,31 @@ +package com.baeldung.algorithms.editdistance; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class EditDistanceTest extends EditDistanceDataProvider { + + String x; + String y; + int result; + + public EditDistanceTest(String a, String b, int res) { + super(); + x = a; + y = b; + result = res; + } + + @Test + public void testEditDistance_RecursiveImplementation() { + Assert.assertEquals(result, EditDistanceRecursive.calculate(x, y)); + } + + @Test + public void testEditDistance_givenDynamicProgrammingImplementation() { + Assert.assertEquals(result, EditDistanceDynamicProgramming.calculate(x, y)); + } +} diff --git a/animal-sniffer-mvn-plugin/README.md b/animal-sniffer-mvn-plugin/README.md new file mode 100644 index 0000000000..4c7c381da4 --- /dev/null +++ b/animal-sniffer-mvn-plugin/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +[Introduction to Animal Sniffer Maven Plugin](http://www.baeldung.com/maven-animal-sniffer) diff --git a/apache-cayenne/README.md b/apache-cayenne/README.md new file mode 100644 index 0000000000..610d1233b7 --- /dev/null +++ b/apache-cayenne/README.md @@ -0,0 +1,4 @@ +## Relevant articles: + +- [Advanced Querying in Apache Cayenne](http://www.baeldung.com/apache-cayenne-query) +- [Introduction to Apache Cayenne ORM](http://www.baeldung.com/apache-cayenne-orm) diff --git a/apache-cxf/README.md b/apache-cxf/README.md index d8f1912070..1e66ce5da8 100644 --- a/apache-cxf/README.md +++ b/apache-cxf/README.md @@ -1,2 +1,5 @@ ## Relevant Articles: - [Introduction to Apache CXF Aegis Data Binding](http://www.baeldung.com/aegis-data-binding-in-apache-cxf) +- [Apache CXF Support for RESTful Web Services](http://www.baeldung.com/apache-cxf-rest-api) +- [A Guide to Apache CXF with Spring](http://www.baeldung.com/apache-cxf-with-spring) +- [Introduction to Apache CXF](http://www.baeldung.com/introduction-to-apache-cxf) diff --git a/apache-spark/pom.xml b/apache-spark/pom.xml new file mode 100644 index 0000000000..1f95150ee7 --- /dev/null +++ b/apache-spark/pom.xml @@ -0,0 +1,44 @@ + + 4.0.0 + + com.baeldung + apache-spark + 1.0-SNAPSHOT + jar + + apache-spark + http://maven.apache.org + + + UTF-8 + + + + + + org.apache.spark + spark-core_2.10 + 2.2.0 + + + junit + junit + 3.8.1 + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + + diff --git a/apache-spark/src/main/java/com/baeldung/WordCount.java b/apache-spark/src/main/java/com/baeldung/WordCount.java new file mode 100644 index 0000000000..ec1dedcb69 --- /dev/null +++ b/apache-spark/src/main/java/com/baeldung/WordCount.java @@ -0,0 +1,53 @@ +package com.baeldung; + +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +import org.apache.spark.SparkConf; +import org.apache.spark.api.java.JavaPairRDD; +import org.apache.spark.api.java.JavaRDD; +import org.apache.spark.api.java.JavaSparkContext; +import org.apache.spark.api.java.function.*; +import org.apache.spark.api.java.function.Function2; +import org.apache.spark.api.java.function.PairFunction; + +import scala.Tuple2; + +public class WordCount { + + private static final Pattern SPACE = Pattern.compile(" "); + + public static void main(String[] args) throws Exception { + if (args.length < 1) { + System.err.println("Usage: JavaWordCount "); + System.exit(1); + } + SparkConf sparkConf = new SparkConf().setAppName("JavaWordCount").setMaster("local"); + JavaSparkContext ctx = new JavaSparkContext(sparkConf); + JavaRDD lines = ctx.textFile(args[0], 1); + + JavaRDD words = lines.flatMap(s -> Arrays.asList(SPACE.split(s)).iterator()); + JavaPairRDD ones = words.mapToPair( + new PairFunction() { + @Override + public Tuple2 call(String s) { + return new Tuple2<>(s, 1); + } + }); + + JavaPairRDD counts = ones.reduceByKey( + new Function2() { + @Override + public Integer call(Integer i1, Integer i2) { + return i1 + i2; + } + }); + + List> output = counts.collect(); + for (Tuple2 tuple : output) { + System.out.println(tuple._1() + ": " + tuple._2()); + } + ctx.stop(); +} +} diff --git a/apache-spark/src/main/resources/spark_example.txt b/apache-spark/src/main/resources/spark_example.txt new file mode 100644 index 0000000000..10fd71dc31 --- /dev/null +++ b/apache-spark/src/main/resources/spark_example.txt @@ -0,0 +1,3 @@ +Hello from Baeldung +Keep Learning Spark +Bye from Baeldung \ No newline at end of file diff --git a/asm/README.md b/asm/README.md new file mode 100644 index 0000000000..50d9c34324 --- /dev/null +++ b/asm/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [A Guide to Java Bytecode Manipulation with ASM](http://www.baeldung.com/java-asm) diff --git a/asm/pom.xml b/asm/pom.xml new file mode 100644 index 0000000000..407ceab458 --- /dev/null +++ b/asm/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + com.baeldung.examples + asm + 1.0 + jar + + + org.ow2.asm + asm + 5.2 + + + org.ow2.asm + asm-util + 5.2 + + + + UTF-8 + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + + com.baeldung.examples.asm.instrumentation.Premain + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.9 + + -javaagent:"C:\asm-1.0.jar" + + + + + \ No newline at end of file diff --git a/asm/src/main/java/com/baeldung/examples/asm/CustomClassWriter.java b/asm/src/main/java/com/baeldung/examples/asm/CustomClassWriter.java new file mode 100644 index 0000000000..d41a1a16a3 --- /dev/null +++ b/asm/src/main/java/com/baeldung/examples/asm/CustomClassWriter.java @@ -0,0 +1,160 @@ +package com.baeldung.examples.asm; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodVisitor; +import static org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static org.objectweb.asm.Opcodes.ACC_STATIC; +import static org.objectweb.asm.Opcodes.ASM4; +import static org.objectweb.asm.Opcodes.V1_5; +import org.objectweb.asm.Type; +import org.objectweb.asm.util.TraceClassVisitor; + +/** + * + * @author baeldung + * @param + */ +public class CustomClassWriter { + + ClassReader reader; + ClassWriter writer; + AddFieldAdapter addFieldAdapter; + AddInterfaceAdapter addInterfaceAdapter; + PublicizeMethodAdapter pubMethAdapter; + final static String CLASSNAME = "java.lang.Integer"; + final static String CLONEABLE = "java/lang/Cloneable"; + + public CustomClassWriter() { + + try { + reader = new ClassReader(CLASSNAME); + writer = new ClassWriter(reader, 0); + + } catch (IOException ex) { + Logger.getLogger(CustomClassWriter.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public CustomClassWriter(byte[] contents) { + reader = new ClassReader(contents); + writer = new ClassWriter(reader, 0); + } + + public static void main(String[] args) { + CustomClassWriter ccw = new CustomClassWriter(); + ccw.publicizeMethod(); + } + + public byte[] addField() { + addFieldAdapter = new AddFieldAdapter("aNewBooleanField", org.objectweb.asm.Opcodes.ACC_PUBLIC, writer); + reader.accept(addFieldAdapter, 0); + return writer.toByteArray(); + } + + public byte[] publicizeMethod() { + pubMethAdapter = new PublicizeMethodAdapter(writer); + reader.accept(pubMethAdapter, 0); + return writer.toByteArray(); + } + + public byte[] addInterface() { + addInterfaceAdapter = new AddInterfaceAdapter(writer); + reader.accept(addInterfaceAdapter, 0); + return writer.toByteArray(); + } + + public class AddInterfaceAdapter extends ClassVisitor { + + public AddInterfaceAdapter(ClassVisitor cv) { + super(ASM4, cv); + } + + @Override + public void visit(int version, int access, String name, + String signature, String superName, String[] interfaces) { + String[] holding = new String[interfaces.length + 1]; + holding[holding.length - 1] = CLONEABLE; + System.arraycopy(interfaces, 0, holding, 0, interfaces.length); + + cv.visit(V1_5, access, name, signature, superName, holding); + } + + } + + public class PublicizeMethodAdapter extends ClassVisitor { + + final Logger logger = Logger.getLogger("PublicizeMethodAdapter"); + TraceClassVisitor tracer; + PrintWriter pw = new PrintWriter(System.out); + + public PublicizeMethodAdapter(ClassVisitor cv) { + super(ASM4, cv); + this.cv = cv; + tracer = new TraceClassVisitor(cv, pw); + } + + @Override + public MethodVisitor visitMethod(int access, + String name, + String desc, + String signature, + String[] exceptions) { + + if (name.equals("toUnsignedString0")) { + logger.info("Visiting unsigned method"); + return tracer.visitMethod(ACC_PUBLIC + ACC_STATIC, name, desc, signature, exceptions); + } + return tracer.visitMethod(access, name, desc, signature, exceptions); + + } + + public void visitEnd() { + tracer.visitEnd(); + System.out.println(tracer.p.getText()); + } + + } + + public class AddFieldAdapter extends ClassVisitor { + + String fieldName; + int access; + boolean isFieldPresent; + + public AddFieldAdapter(String fieldName, int access, ClassVisitor cv) { + super(ASM4, cv); + this.cv = cv; + this.access = access; + this.fieldName = fieldName; + } + + @Override + public FieldVisitor visitField(int access, String name, String desc, + String signature, Object value) { + if (name.equals(fieldName)) { + isFieldPresent = true; + } + return cv.visitField(access, name, desc, signature, value); + } + + @Override + public void visitEnd() { + if (!isFieldPresent) { + FieldVisitor fv = cv.visitField(access, fieldName, Type.BOOLEAN_TYPE.toString(), null, null); + if (fv != null) { + fv.visitEnd(); + } + } + cv.visitEnd(); + } + + } + +} diff --git a/asm/src/main/java/com/baeldung/examples/asm/instrumentation/Premain.java b/asm/src/main/java/com/baeldung/examples/asm/instrumentation/Premain.java new file mode 100644 index 0000000000..a3e69b6785 --- /dev/null +++ b/asm/src/main/java/com/baeldung/examples/asm/instrumentation/Premain.java @@ -0,0 +1,32 @@ +package com.baeldung.examples.asm.instrumentation; + +import com.baeldung.examples.asm.CustomClassWriter; +import java.lang.instrument.ClassFileTransformer; +import java.lang.instrument.IllegalClassFormatException; +import java.lang.instrument.Instrumentation; +import java.security.ProtectionDomain; + +/** + * + * @author baeldung + */ +public class Premain { + + public static void premain(String agentArgs, Instrumentation inst) { + inst.addTransformer(new ClassFileTransformer() { + + @Override + public byte[] transform(ClassLoader l, String name, Class c, + ProtectionDomain d, byte[] b) + throws IllegalClassFormatException { + + if (name.equals("java/lang/Integer")) { + CustomClassWriter cr = new CustomClassWriter(b); + return cr.addField(); + } + return b; + } + }); + } + +} diff --git a/atomix/README.md b/atomix/README.md new file mode 100644 index 0000000000..fb22eec8dc --- /dev/null +++ b/atomix/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Introduction to Atomix](http://www.baeldung.com/atomix) diff --git a/aws/README.md b/aws/README.md index 10db004765..b6d0b79d91 100644 --- a/aws/README.md +++ b/aws/README.md @@ -1,3 +1,6 @@ ### Relevant articles - [AWS Lambda Using DynamoDB With Java](http://www.baeldung.com/aws-lambda-dynamodb-java) +- [AWS S3 with Java](http://www.baeldung.com/aws-s3-java) +- [AWS Lambda With Java](http://www.baeldung.com/java-aws-lambda) + diff --git a/camel-api/README.md b/camel-api/README.md index fe8dadcfe1..0e85db4a7f 100644 --- a/camel-api/README.md +++ b/camel-api/README.md @@ -13,3 +13,7 @@ and a BODY Payload like {"id": 1,"name": "World"} and we will get a return code of 201 and the response: Hello, World - if the transform() method from Application class is uncommented and the process() method is commented or return code of 201 and the response: {"id": 10,"name": "Hello, World"} - if the transform() method from Application class is commented and the process() method is uncommented + +## Relevant articles: + +- [Apache Camel with Spring Boot](http://www.baeldung.com/apache-camel-spring-boot) diff --git a/cas-secured-app/.gitignore b/cas-secured-app/.gitignore new file mode 100644 index 0000000000..2af7cefb0a --- /dev/null +++ b/cas-secured-app/.gitignore @@ -0,0 +1,24 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ \ No newline at end of file diff --git a/cas-secured-app/.mvn/wrapper/maven-wrapper.jar b/cas-secured-app/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000..9cc84ea9b4 Binary files /dev/null and b/cas-secured-app/.mvn/wrapper/maven-wrapper.jar differ diff --git a/cas-secured-app/.mvn/wrapper/maven-wrapper.properties b/cas-secured-app/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000..c315043703 --- /dev/null +++ b/cas-secured-app/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/cas-secured-app/README.md b/cas-secured-app/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/cas-secured-app/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/cas-secured-app/mvnw b/cas-secured-app/mvnw new file mode 100644 index 0000000000..5bf251c077 --- /dev/null +++ b/cas-secured-app/mvnw @@ -0,0 +1,225 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +echo $MAVEN_PROJECTBASEDIR +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/cas-secured-app/mvnw.cmd b/cas-secured-app/mvnw.cmd new file mode 100644 index 0000000000..019bd74d76 --- /dev/null +++ b/cas-secured-app/mvnw.cmd @@ -0,0 +1,143 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" + +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/cas-secured-app/pom.xml b/cas-secured-app/pom.xml new file mode 100644 index 0000000000..f66d54ae67 --- /dev/null +++ b/cas-secured-app/pom.xml @@ -0,0 +1,110 @@ + + + 4.0.0 + + com.baeldung + cas-secured-app + 0.0.1-SNAPSHOT + jar + + cas-secured-app + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.0.BUILD-SNAPSHOT + + + + + UTF-8 + UTF-8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.security + spring-security-cas + + + org.springframework.boot + spring-boot-starter-freemarker + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + diff --git a/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/CasSecuredAppApplication.java b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/CasSecuredAppApplication.java new file mode 100644 index 0000000000..fc05e3b38f --- /dev/null +++ b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/CasSecuredAppApplication.java @@ -0,0 +1,91 @@ +package com.baeldung.cassecuredapp; + +import org.jasig.cas.client.session.SingleSignOutFilter; +import org.jasig.cas.client.session.SingleSignOutHttpSessionListener; +import org.jasig.cas.client.validation.Cas30ServiceTicketValidator; +import org.jasig.cas.client.validation.TicketValidator; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Primary; +import org.springframework.context.event.EventListener; +import org.springframework.security.cas.ServiceProperties; +import org.springframework.security.cas.authentication.CasAuthenticationProvider; +import org.springframework.security.cas.web.CasAuthenticationEntryPoint; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.authentication.logout.LogoutFilter; +import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; + +import javax.servlet.http.HttpSessionEvent; + +@SpringBootApplication +public class CasSecuredAppApplication { + + public static void main(String[] args) { + SpringApplication.run(CasSecuredAppApplication.class, args); + } + + @Bean + public ServiceProperties serviceProperties() { + ServiceProperties serviceProperties = new ServiceProperties(); + serviceProperties.setService("http://localhost:9000/login/cas"); + serviceProperties.setSendRenew(false); + return serviceProperties; + } + + @Bean + @Primary + public AuthenticationEntryPoint authenticationEntryPoint(ServiceProperties sP) { + CasAuthenticationEntryPoint entryPoint = new CasAuthenticationEntryPoint(); + entryPoint.setLoginUrl("https://localhost:8443/cas/login"); + entryPoint.setServiceProperties(sP); + return entryPoint; + } + + @Bean + public TicketValidator ticketValidator() { + return new Cas30ServiceTicketValidator("https://localhost:8443/cas"); + } + + @Bean + public CasAuthenticationProvider casAuthenticationProvider() { + CasAuthenticationProvider provider = new CasAuthenticationProvider(); + provider.setServiceProperties(serviceProperties()); + provider.setTicketValidator(ticketValidator()); + provider.setUserDetailsService((s) -> new User("test@test.com", "smatt", + true, true, true, true, + AuthorityUtils.createAuthorityList("ROLE_ADMIN"))); + provider.setKey("CAS_PROVIDER_LOCALHOST_9000"); + return provider; + } + + + @Bean + public SecurityContextLogoutHandler securityContextLogoutHandler() { + return new SecurityContextLogoutHandler(); + } + + @Bean + public LogoutFilter logoutFilter() { + LogoutFilter logoutFilter = new LogoutFilter( + "https://localhost:8443/cas/logout", securityContextLogoutHandler()); + logoutFilter.setFilterProcessesUrl("/logout/cas"); + return logoutFilter; + } + + @Bean + public SingleSignOutFilter singleSignOutFilter() { + SingleSignOutFilter singleSignOutFilter = new SingleSignOutFilter(); + singleSignOutFilter.setCasServerUrlPrefix("https://localhost:8443/cas"); + singleSignOutFilter.setIgnoreInitConfiguration(true); + return singleSignOutFilter; + } + + @EventListener + public SingleSignOutHttpSessionListener singleSignOutHttpSessionListener(HttpSessionEvent event) { + return new SingleSignOutHttpSessionListener(); + } +} diff --git a/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/config/SecurityConfig.java b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/config/SecurityConfig.java new file mode 100644 index 0000000000..2eabed49e1 --- /dev/null +++ b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/config/SecurityConfig.java @@ -0,0 +1,83 @@ +package com.baeldung.cassecuredapp.config; + +import org.jasig.cas.client.session.SingleSignOutFilter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.ProviderManager; +import org.springframework.security.cas.ServiceProperties; +import org.springframework.security.cas.authentication.CasAuthenticationProvider; +import org.springframework.security.cas.web.CasAuthenticationFilter; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.authentication.logout.LogoutFilter; + +import java.util.Arrays; + +@EnableWebSecurity +@Configuration +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + private AuthenticationProvider authenticationProvider; + private AuthenticationEntryPoint authenticationEntryPoint; + private SingleSignOutFilter singleSignOutFilter; + private LogoutFilter logoutFilter; + + @Autowired + public SecurityConfig(CasAuthenticationProvider casAuthenticationProvider, AuthenticationEntryPoint eP, + LogoutFilter lF + , SingleSignOutFilter ssF + ) { + this.authenticationProvider = casAuthenticationProvider; + this.authenticationEntryPoint = eP; + + this.logoutFilter = lF; + this.singleSignOutFilter = ssF; + + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .regexMatchers("/secured.*", "/login") + .authenticated() + .and() + .authorizeRequests() + .regexMatchers("/") + .permitAll() + .and() + .httpBasic() + .authenticationEntryPoint(authenticationEntryPoint) + .and() + .logout().logoutSuccessUrl("/logout") + .and() + .addFilterBefore(singleSignOutFilter, CasAuthenticationFilter.class) + .addFilterBefore(logoutFilter, LogoutFilter.class); + + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.authenticationProvider(authenticationProvider); + } + + @Override + protected AuthenticationManager authenticationManager() throws Exception { + return new ProviderManager(Arrays.asList(authenticationProvider)); + } + + @Bean + public CasAuthenticationFilter casAuthenticationFilter(ServiceProperties sP) throws Exception { + CasAuthenticationFilter filter = new CasAuthenticationFilter(); + filter.setServiceProperties(sP); + filter.setAuthenticationManager(authenticationManager()); + return filter; + } + +} diff --git a/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/AuthController.java b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/AuthController.java new file mode 100644 index 0000000000..703e6abf7a --- /dev/null +++ b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/AuthController.java @@ -0,0 +1,35 @@ +package com.baeldung.cassecuredapp.controllers; + +import org.apache.log4j.Logger; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.logout.CookieClearingLogoutHandler; +import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; +import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Controller +public class AuthController { + + private Logger logger = Logger.getLogger(AuthController.class); + + @GetMapping("/logout") + public String logout( + HttpServletRequest request, HttpServletResponse response, SecurityContextLogoutHandler logoutHandler) { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + logoutHandler.logout(request, response, auth ); + new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY).logout(request, response, auth); + return "auth/logout"; + } + + + @GetMapping("/login") + public String login() { + return "redirect:/secured"; + } + +} diff --git a/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/IndexController.java b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/IndexController.java new file mode 100644 index 0000000000..75956cf493 --- /dev/null +++ b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/IndexController.java @@ -0,0 +1,15 @@ +package com.baeldung.cassecuredapp.controllers; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + + +@Controller +public class IndexController { + + @GetMapping("/") + public String index() { + return "index"; + } +} diff --git a/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/SecuredPageController.java b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/SecuredPageController.java new file mode 100644 index 0000000000..9a872d1f40 --- /dev/null +++ b/cas-secured-app/src/main/java/com/baeldung/cassecuredapp/controllers/SecuredPageController.java @@ -0,0 +1,24 @@ +package com.baeldung.cassecuredapp.controllers; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping(value = "/secured") +public class SecuredPageController { + + @GetMapping + public String index(ModelMap modelMap) { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + if( auth != null && auth.getPrincipal() != null + && auth.getPrincipal() instanceof UserDetails) { + modelMap.put("username", ((UserDetails) auth.getPrincipal()).getUsername()); + } + return "secure/index"; + } +} diff --git a/cas-secured-app/src/main/resources/application.properties b/cas-secured-app/src/main/resources/application.properties new file mode 100644 index 0000000000..99802c632f --- /dev/null +++ b/cas-secured-app/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=9000 \ No newline at end of file diff --git a/cas-secured-app/src/main/resources/templates/auth/logout.ftl b/cas-secured-app/src/main/resources/templates/auth/logout.ftl new file mode 100644 index 0000000000..eac345ec33 --- /dev/null +++ b/cas-secured-app/src/main/resources/templates/auth/logout.ftl @@ -0,0 +1,10 @@ + + + Cas Secured App - Logout + + +

    You have logged out of Cas Secured Spring Boot App Successfully

    +
    +Log out of all other Services + + \ No newline at end of file diff --git a/cas-secured-app/src/main/resources/templates/index.ftl b/cas-secured-app/src/main/resources/templates/index.ftl new file mode 100644 index 0000000000..d407756044 --- /dev/null +++ b/cas-secured-app/src/main/resources/templates/index.ftl @@ -0,0 +1,11 @@ + + + Cas Secured App - Index + + +

    Welcome to Cas Secured Spring Boot App

    +

    This is a Public Page

    +
    +Login + + \ No newline at end of file diff --git a/cas-secured-app/src/main/resources/templates/secure/index.ftl b/cas-secured-app/src/main/resources/templates/secure/index.ftl new file mode 100644 index 0000000000..210ebecc7b --- /dev/null +++ b/cas-secured-app/src/main/resources/templates/secure/index.ftl @@ -0,0 +1,12 @@ + + + Cas Secured App - Secured + + +

    Welcome to Cas Secured Spring Boot App

    +

    This is a Secured Page

    +

    Welcome home ${username!""}

    +
    +Logout + + \ No newline at end of file diff --git a/cas-secured-app/src/test/java/com/baeldung/cassecuredapp/CasSecuredAppApplicationTests.java b/cas-secured-app/src/test/java/com/baeldung/cassecuredapp/CasSecuredAppApplicationTests.java new file mode 100644 index 0000000000..09dbaf0c61 --- /dev/null +++ b/cas-secured-app/src/test/java/com/baeldung/cassecuredapp/CasSecuredAppApplicationTests.java @@ -0,0 +1,16 @@ +package com.baeldung.cassecuredapp; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class CasSecuredAppApplicationTests { + + @Test + public void contextLoads() { + } + +} diff --git a/cas-server/.gitignore b/cas-server/.gitignore new file mode 100644 index 0000000000..5304519922 --- /dev/null +++ b/cas-server/.gitignore @@ -0,0 +1,14 @@ +.classpath +!/.project +.project +.settings +target/ +.idea/ +.DS_Store +.idea +overlays/ +.gradle/ +build/ +bin/ +*.iml +*.log diff --git a/cas-server/LICENSE.txt b/cas-server/LICENSE.txt new file mode 100644 index 0000000000..d645695673 --- /dev/null +++ b/cas-server/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/cas-server/README.md b/cas-server/README.md new file mode 100644 index 0000000000..bae8b648e5 --- /dev/null +++ b/cas-server/README.md @@ -0,0 +1,88 @@ +CAS Overlay Template +============================ + +Generic CAS WAR overlay to exercise the latest versions of CAS. This overlay could be freely used as a starting template for local CAS war overlays. The CAS services management overlay is available [here](https://github.com/apereo/cas-services-management-overlay). + +# Versions + +```xml +5.1.x +``` + +# Requirements +* JDK 1.8+ + +# Configuration + +The `etc` directory contains the configuration files and directories that need to be copied to `/etc/cas/config`. + +# Build + +To see what commands are available to the build script, run: + +```bash +./build.sh help +``` + +To package the final web application, run: + +```bash +./build.sh package +``` + +To update `SNAPSHOT` versions run: + +```bash +./build.sh package -U +``` + +# Deployment + +- Create a keystore file `thekeystore` under `/etc/cas`. Use the password `changeit` for both the keystore and the key/certificate entries. +- Ensure the keystore is loaded up with keys and certificates of the server. + +On a successful deployment via the following methods, CAS will be available at: + +* `http://cas.server.name:8080/cas` +* `https://cas.server.name:8443/cas` + +## Executable WAR + +Run the CAS web application as an executable WAR. + +```bash +./build.sh run +``` + +## Spring Boot + +Run the CAS web application as an executable WAR via Spring Boot. This is most useful during development and testing. + +```bash +./build.sh bootrun +``` + +### Warning! + +Be careful with this method of deployment. `bootRun` is not designed to work with already executable WAR artifacts such that CAS server web application. YMMV. Today, uses of this mode ONLY work when there is **NO OTHER** dependency added to the build script and the `cas-server-webapp` is the only present module. See [this issue](https://github.com/apereo/cas/issues/2334) and [this issue](https://github.com/spring-projects/spring-boot/issues/8320) for more info. + + +## Spring Boot App Server Selection +There is an app.server property in the pom.xml that can be used to select a spring boot application server. +It defaults to "-tomcat" but "-jetty" and "-undertow" are supported. +It can also be set to an empty value (nothing) if you want to deploy CAS to an external application server of your choice and you don't want the spring boot libraries included. + +```xml +-tomcat +``` + +## Windows Build +If you are building on windows, try build.cmd instead of build.sh. Arguments are similar but for usage, run: + +``` +build.cmd help +``` + +## External + +Deploy resultant `target/cas.war` to a servlet container of choice. diff --git a/cas-server/build.cmd b/cas-server/build.cmd new file mode 100644 index 0000000000..f907dcb388 --- /dev/null +++ b/cas-server/build.cmd @@ -0,0 +1,82 @@ +@echo off + +@set JAVA_ARGS=-Xms500m -Xmx1g +@set CAS_DIR=\etc\cas +@set CONFIG_DIR=\etc\cas\config + +@rem Call this script with DNAME and CERT_SUBJ_ALT_NAMES already set to override +@if "%DNAME%" == "" set DNAME=CN=cas.example.org,OU=Example,OU=Org,C=US +@rem List other host names or ip addresses you want in your certificate, may help with host name verification, +@rem if client apps make https connection for ticket validation and compare name in cert (include sub. alt. names) +@rem to name used to access CAS +@if "%CERT_SUBJ_ALT_NAMES%" == "" set CERT_SUBJ_ALT_NAMES=dns:example.org,dns:localhost,dns:%COMPUTERNAME%,ip:127.0.0.1 + +@rem Check for mvn in path, use it if found, otherwise use maven wrapper +@set MAVEN_CMD=mvn +@where /q mvn +@if %ERRORLEVEL% neq 0 set MAVEN_CMD=.\mvnw.bat + +@if "%1" == "" call:help +@if "%1" == "copy" call:copy +@if "%1" == "clean" call:clean %2 %3 %4 +@if "%1" == "package" call:package %2 %3 %4 +@if "%1" == "bootrun" call:bootrun %2 %3 %4 +@if "%1" == "debug" call:debug %2 %3 %4 +@if "%1" == "run" call:run %2 %3 %4 +@if "%1" == "help" call:help +@if "%1" == "gencert" call:gencert + +@rem function section starts here +@goto:eof + +:copy + @echo "Creating configuration directory under %CONFIG_DIR%" + if not exist %CONFIG_DIR% mkdir %CONFIG_DIR% + + @echo "Copying configuration files from etc/cas to /etc/cas" + xcopy /S /Y etc\cas\* \etc\cas +@goto:eof + +:help + @echo "Usage: build.bat [copy|clean|package|run|debug|bootrun|gencert] [optional extra args for maven]" + @echo "To get started on a clean system, run "build.bat copy" and "build.bat gencert", then "build.bat run" + @echo "Note that using the copy or gencert arguments will create and/or overwrite the %CAS_DIR% which is outside this project" +@goto:eof + +:clean + call %MAVEN_CMD% clean %1 %2 %3 + exit /B %ERRORLEVEL% +@goto:eof + +:package + call %MAVEN_CMD% clean package -T 5 %1 %2 %3 + exit /B %ERRORLEVEL% +@goto:eof + +:bootrun + call %MAVEN_CMD% clean package spring-boot:run -T 5 %1 %2 %3 + exit /B %ERRORLEVEL% +@goto:eof + +:debug + call:package %1 %2 %3 & java %JAVA_ARGS% -Xdebug -Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n -jar target/cas.war +@goto:eof + +:run + call:package %1 %2 %3 & java %JAVA_ARGS% -jar target/cas.war +@goto:eof + +:gencert + where /q keytool + if ERRORLEVEL 1 ( + @echo Java keytool.exe not found in path. + exit /b 1 + ) else ( + if not exist %CAS_DIR% mkdir %CAS_DIR% + @echo on + @echo Generating self-signed SSL cert for %DNAME% in %CAS_DIR%\thekeystore + keytool -genkeypair -alias cas -keyalg RSA -keypass changeit -storepass changeit -keystore %CAS_DIR%\thekeystore -dname %DNAME% -ext SAN=%CERT_SUBJ_ALT_NAMES% + @echo Exporting cert for use in trust store (used by cas clients) + keytool -exportcert -alias cas -storepass changeit -keystore %CAS_DIR%\thekeystore -file %CAS_DIR%\cas.cer + ) +@goto:eof diff --git a/cas-server/build.sh b/cas-server/build.sh new file mode 100644 index 0000000000..e33f7de854 --- /dev/null +++ b/cas-server/build.sh @@ -0,0 +1,97 @@ +#!/bin/bash + + +function copy() { + echo -e "Creating configuration directory under /etc/cas" + mkdir -p /etc/cas/config + + echo -e "Copying configuration files from etc/cas to /etc/cas" + cp -rfv etc/cas/* /etc/cas +} + +function help() { + echo "Usage: build.sh [copy|clean|package|run|debug|bootrun|gencert]" + echo " copy: Copy config from ./etc/cas/config to /etc/cas/config" + echo " clean: Clean Maven build directory" + echo " package: Clean and build CAS war, also call copy" + echo " run: Build and run CAS.war via spring boot (java -jar target/cas.war)" + echo " debug: Run CAS.war and listen for Java debugger on port 5000" + echo " bootrun: Run with maven spring boot plugin, doesn't work with multiple dependencies" + echo " gencert: Create keystore with SSL certificate in location where CAS looks by default" +} + +function clean() { + ./mvnw clean "$@" +} + +function package() { + ./mvnw clean package -T 5 "$@" + copy +} + +function bootrun() { + ./mvnw clean package spring-boot:run -T 5 "$@" +} + +function debug() { + package && java -Xdebug -Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n -jar target/cas.war +} + +function run() { + package && java -jar target/cas.war +} + +function gencert() { + if [[ ! -d /etc/cas ]] ; then + copy + fi + which keytool + if [[ $? -ne 0 ]] ; then + echo Error: Java JDK \'keytool\' is not installed or is not in the path + exit 1 + fi + # override DNAME and CERT_SUBJ_ALT_NAMES before calling or use dummy values + DNAME="${DNAME:-CN=cas.example.org,OU=Example,OU=Org,C=US}" + CERT_SUBJ_ALT_NAMES="${CERT_SUBJ_ALT_NAMES:-dns:example.org,dns:localhost,ip:127.0.0.1}" + echo "Generating keystore for CAS with DN ${DNAME}" + keytool -genkeypair -alias cas -keyalg RSA -keypass changeit -storepass changeit -keystore /etc/cas/thekeystore -dname ${DNAME} -ext SAN=${CERT_SUBJ_ALT_NAMES} + keytool -exportcert -alias cas -storepass changeit -keystore /etc/cas/thekeystore -file /etc/cas/cas.cer +} + +if [ $# -eq 0 ]; then + echo -e "No commands provided. Defaulting to [run]\n" + run + exit 0 +fi + + +case "$1" in +"copy") + copy + ;; +"clean") + shift + clean "$@" + ;; +"package") + shift + package "$@" + ;; +"bootrun") + shift + bootrun "$@" + ;; +"debug") + debug "$@" + ;; +"run") + run "$@" + ;; +"gencert") + gencert "$@" + ;; +*) + help + ;; +esac + diff --git a/cas-server/etc/cas/config/application.yml b/cas-server/etc/cas/config/application.yml new file mode 100644 index 0000000000..be1f7c3edd --- /dev/null +++ b/cas-server/etc/cas/config/application.yml @@ -0,0 +1,2 @@ +info: + description: CAS Configuration \ No newline at end of file diff --git a/cas-server/etc/cas/config/cas.properties b/cas-server/etc/cas/config/cas.properties new file mode 100644 index 0000000000..47a1477308 --- /dev/null +++ b/cas-server/etc/cas/config/cas.properties @@ -0,0 +1,7 @@ +cas.server.name: https://cas.example.org:8443 +cas.server.prefix: https://cas.example.org:8443/cas + +cas.adminPagesSecurity.ip=127\.0\.0\.1 + +logging.config: file:/etc/cas/config/log4j2.xml +# cas.serviceRegistry.config.location: classpath:/services diff --git a/cas-server/etc/cas/config/log4j2.xml b/cas-server/etc/cas/config/log4j2.xml new file mode 100644 index 0000000000..53b30b4228 --- /dev/null +++ b/cas-server/etc/cas/config/log4j2.xml @@ -0,0 +1,117 @@ + + + + + + . + + warn + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cas-server/etc/cas/thekeystore b/cas-server/etc/cas/thekeystore new file mode 100644 index 0000000000..15f9af2dae Binary files /dev/null and b/cas-server/etc/cas/thekeystore differ diff --git a/cas-server/etc/cas/thekeystore.crt b/cas-server/etc/cas/thekeystore.crt new file mode 100644 index 0000000000..5c7543f0c6 Binary files /dev/null and b/cas-server/etc/cas/thekeystore.crt differ diff --git a/cas-server/maven/maven-wrapper.properties b/cas-server/maven/maven-wrapper.properties new file mode 100644 index 0000000000..b368e4609a --- /dev/null +++ b/cas-server/maven/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https\://repository.apache.org/content/repositories/releases/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip diff --git a/cas-server/mvnw b/cas-server/mvnw new file mode 100644 index 0000000000..2275ac7647 --- /dev/null +++ b/cas-server/mvnw @@ -0,0 +1,234 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # + # Look for the Apple JDKs first to preserve the existing behaviour, and then look + # for the new JDKs provided by Oracle. + # + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then + # + # Apple JDKs + # + export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then + # + # Oracle JDKs + # + export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home + fi + + if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then + # + # Apple JDKs + # + export JAVA_HOME=`/usr/libexec/java_home` + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Migwn, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" + # TODO classpath? +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + local basedir=$(pwd) + local wdir=$(pwd) + while [ "$wdir" != '/' ] ; do + wdir=$(cd "$wdir/.."; pwd) + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER="org.apache.maven.wrapper.MavenWrapperMain" + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + -classpath \ +"$MAVEN_PROJECTBASEDIR/maven/maven-wrapper.jar" \ + ${WRAPPER_LAUNCHER} "$@" diff --git a/cas-server/mvnw.bat b/cas-server/mvnw.bat new file mode 100644 index 0000000000..d391151aa7 --- /dev/null +++ b/cas-server/mvnw.bat @@ -0,0 +1,174 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven2 Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:chkMHome +if not "%M2_HOME%"=="" goto valMHome + +SET "M2_HOME=%~dp0.." +if not "%M2_HOME%"=="" goto valMHome + +echo. +echo Error: M2_HOME not found in your environment. >&2 +echo Please set the M2_HOME variable in your environment to match the >&2 +echo location of the Maven installation. >&2 +echo. +goto error + +:valMHome + +:stripMHome +if not "_%M2_HOME:~-1%"=="_\" goto checkMCmd +set "M2_HOME=%M2_HOME:~0,-1%" +goto stripMHome + +:checkMCmd +if exist "%M2_HOME%\bin\mvn.cmd" goto init + +echo. +echo Error: M2_HOME is set to an invalid directory. >&2 +echo M2_HOME = "%M2_HOME%" >&2 +echo Please set the M2_HOME variable in your environment to match the >&2 +echo location of the Maven installation >&2 +echo. +goto error +@REM ==== END VALIDATION ==== + +:init + +set MAVEN_CMD_LINE_ARGS=%* + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\maven\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% + +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/cas-server/pom.xml b/cas-server/pom.xml new file mode 100644 index 0000000000..e8625b48f7 --- /dev/null +++ b/cas-server/pom.xml @@ -0,0 +1,158 @@ + + + 4.0.0 + com.baeldung + cas-server + war + 1.0 + + + + + com.rimerosolutions.maven.plugins + wrapper-maven-plugin + 0.0.4 + + true + MD5 + + + + org.springframework.boot + spring-boot-maven-plugin + ${springboot.version} + + org.springframework.boot.loader.WarLauncher + true + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + cas + false + false + + false + ${project.build.directory}/war/work/org.apereo.cas/cas-server-webapp${app.server}/META-INF/MANIFEST.MF + + + + + org.apereo.cas + cas-server-webapp${app.server} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + + cas + + + + + org.apereo.cas + cas-server-webapp${app.server} + ${cas.version} + war + runtime + + + org.apereo.cas + cas-server-support-json-service-registry + ${cas.version} + + + org.apereo.cas + cas-server-support-jdbc + ${cas.version} + + + org.apereo.cas + cas-server-support-jdbc-drivers + ${cas.version} + + + + + 5.1.4 + 1.5.3.RELEASE + + -tomcat + 1.8 + 1.8 + UTF-8 + + + + + sonatype-releases + http://oss.sonatype.org/content/repositories/releases/ + + false + + + true + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + true + + + false + + + + shibboleth-releases + https://build.shibboleth.net/nexus/content/repositories/releases + + + spring-milestones + https://repo.spring.io/milestone + + + + + + + false + + pgp + + + + com.github.s4u.plugins + pgpverify-maven-plugin + 1.1.0 + + + + check + + + + + hkp://pool.sks-keyservers.net + ${settings.localRepository}/pgpkeys-cache + test + true + false + + + + + + + diff --git a/cas-server/src/main/resources/application.properties b/cas-server/src/main/resources/application.properties new file mode 100644 index 0000000000..2d5e9a7277 --- /dev/null +++ b/cas-server/src/main/resources/application.properties @@ -0,0 +1,126 @@ +## +# CAS Server Context Configuration +# +server.context-path=/cas +server.port=8443 + +server.ssl.key-store=file:/etc/cas/thekeystore +server.ssl.key-store-password=changeit +server.ssl.key-password=changeit +# server.ssl.ciphers= +# server.ssl.client-auth= +# server.ssl.enabled= +# server.ssl.key-alias= +# server.ssl.key-store-provider= +# server.ssl.key-store-type= +# server.ssl.protocol= +# server.ssl.trust-store= +# server.ssl.trust-store-password= +# server.ssl.trust-store-provider= +# server.ssl.trust-store-type= + +server.max-http-header-size=2097152 +server.use-forward-headers=true +server.connection-timeout=20000 +server.error.include-stacktrace=NEVER + +server.tomcat.max-http-post-size=2097152 +server.tomcat.basedir=build/tomcat +server.tomcat.accesslog.enabled=true +server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms) +server.tomcat.accesslog.suffix=.log +server.tomcat.max-threads=10 +server.tomcat.port-header=X-Forwarded-Port +server.tomcat.protocol-header=X-Forwarded-Proto +server.tomcat.protocol-header-https-value=https +server.tomcat.remote-ip-header=X-FORWARDED-FOR +server.tomcat.uri-encoding=UTF-8 + +spring.http.encoding.charset=UTF-8 +spring.http.encoding.enabled=true +spring.http.encoding.force=true + +## +# CAS Cloud Bus Configuration +# +spring.cloud.bus.enabled=false +# spring.cloud.bus.refresh.enabled=true +# spring.cloud.bus.env.enabled=true +# spring.cloud.bus.destination=CasCloudBus +# spring.cloud.bus.ack.enabled=true + +endpoints.enabled=false +endpoints.sensitive=true + +endpoints.restart.enabled=false +endpoints.shutdown.enabled=false + +management.security.enabled=true +management.security.roles=ACTUATOR,ADMIN +management.security.sessions=if_required +management.context-path=/status +management.add-application-context-header=false + +security.basic.authorize-mode=role +security.basic.enabled=false +security.basic.path=/cas/status/** + +## +# CAS Web Application Session Configuration +# +server.session.timeout=300 +server.session.cookie.http-only=true +server.session.tracking-modes=COOKIE + +## +# CAS Thymeleaf View Configuration +# +spring.thymeleaf.encoding=UTF-8 +spring.thymeleaf.cache=true +spring.thymeleaf.mode=HTML +## +# CAS Log4j Configuration +# +# logging.config=file:/etc/cas/log4j2.xml +server.context-parameters.isLog4jAutoInitializationDisabled=true + +## +# CAS AspectJ Configuration +# +spring.aop.auto=true +spring.aop.proxy-target-class=true + +## +# CAS Authentication Credentials +# +#cas.authn.accept.users=casuser::Mellon +cas.authn.accept.users= +cas.authn.accept.name= + +#CAS Database Authentication Property +cas.authn.jdbc.query[0].sql=SELECT * FROM users WHERE email = ? +cas.authn.jdbc.query[0].url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC +cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect +cas.authn.jdbc.query[0].user=root +cas.authn.jdbc.query[0].password= +cas.authn.jdbc.query[0].ddlAuto=none +cas.authn.jdbc.query[0].driverClass=com.mysql.jdbc.Driver +cas.authn.jdbc.query[0].fieldPassword=password +cas.authn.jdbc.query[0].passwordEncoder.type=BCRYPT + + +## +# CAS Delegated Authentication +# +cas.authn.pac4j.bitbucket.clientName=Bitbucket +cas.authn.pac4j.dropbox.clientName=Dropbox +cas.authn.pac4j.facebook.clientName=Facebook +cas.authn.pac4j.foursquare.clientName=Foursquare +cas.authn.pac4j.github.clientName=Github +cas.authn.pac4j.google.clientName=Google +cas.authn.pac4j.linkedIn.clientName=LinkedIn +cas.authn.pac4j.paypal.clientName=PayPal +cas.authn.pac4j.twitter.clientName=Twitter +cas.authn.pac4j.yahoo.clientName=Yahoo +cas.authn.pac4j.windowsLive.clientName=Windows Live +cas.authn.pac4j.wordpress.clientName=WordPress diff --git a/cas-server/src/main/resources/cas.properties b/cas-server/src/main/resources/cas.properties new file mode 100644 index 0000000000..be2babcd14 --- /dev/null +++ b/cas-server/src/main/resources/cas.properties @@ -0,0 +1,41 @@ +cas.server.name: https://localhost:8443 +cas.server.prefix: https://localhost:8443/cas + +cas.adminPagesSecurity.ip=127\.0\.0\.1 + +logging.config: file:/etc/cas/config/log4j2.xml + +cas.serviceRegistry.initFromJson=true +cas.serviceRegistry.config.location=classpath:/services + +cas.authn.accept.users= +cas.authn.accept.name= + +#CAS Database Authentication Property + +# cas.authn.jdbc.query[0].healthQuery= +# cas.authn.jdbc.query[0].isolateInternalQueries=false +# cas.authn.jdbc.query[0].failFast=true +# cas.authn.jdbc.query[0].isolationLevelName=ISOLATION_READ_COMMITTED +# cas.authn.jdbc.query[0].leakThreshold=10 +# cas.authn.jdbc.query[0].propagationBehaviorName=PROPAGATION_REQUIRED +# cas.authn.jdbc.query[0].batchSize=1 +# cas.authn.jdbc.query[0].maxAgeDays=180 +# cas.authn.jdbc.query[0].autocommit=false +# cas.authn.jdbc.query[0].idleTimeout=5000 +# cas.authn.jdbc.query[0].credentialCriteria= +# cas.authn.jdbc.query[0].name= +# cas.authn.jdbc.query[0].order=0 +# cas.authn.jdbc.query[0].dataSourceName= +# cas.authn.jdbc.query[0].dataSourceProxy=false +# cas.authn.jdbc.query[0].fieldExpired= +# cas.authn.jdbc.query[0].fieldDisabled= +# cas.authn.jdbc.query[0].principalAttributeList=sn,cn:commonName,givenName +# cas.authn.jdbc.query[0].passwordEncoder.type=NONE|DEFAULT|STANDARD|BCRYPT|SCRYPT|PBKDF2|com.example.CustomPasswordEncoder +# cas.authn.jdbc.query[0].passwordEncoder.characterEncoding= +# cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm= +# cas.authn.jdbc.query[0].passwordEncoder.secret= +# cas.authn.jdbc.query[0].passwordEncoder.strength=16 +# cas.authn.jdbc.query[0].principalTransformation.suffix= +# cas.authn.jdbc.query[0].principalTransformation.caseConversion=NONE|UPPERCASE|LOWERCASE +# cas.authn.jdbc.query[0].principalTransformation.prefix= \ No newline at end of file diff --git a/cas-server/src/main/resources/services/casSecuredApp.json b/cas-server/src/main/resources/services/casSecuredApp.json new file mode 100644 index 0000000000..336007e484 --- /dev/null +++ b/cas-server/src/main/resources/services/casSecuredApp.json @@ -0,0 +1,8 @@ +{ + "@class" : "org.apereo.cas.services.RegexRegisteredService", + "serviceId" : "^http://localhost:9000/login/cas", + "name" : "CAS Spring Secured App", + "description": "This is a Spring App that usses the CAS Server for it's authentication", + "id" : 19991, + "evaluationOrder" : 1 +} \ No newline at end of file diff --git a/core-java-8/README.md b/core-java-8/README.md index 4610b3c86d..690bd48ed5 100644 --- a/core-java-8/README.md +++ b/core-java-8/README.md @@ -28,5 +28,5 @@ - [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max) - [Java Base64 Encoding and Decoding](http://www.baeldung.com/java-base64-encode-and-decode) - [The Difference Between map() and flatMap()](http://www.baeldung.com/java-difference-map-and-flatmap) - -- [Merging Streams in Java](http://www.baeldung.com/java-merge-streams) \ No newline at end of file +- [Merging Streams in Java](http://www.baeldung.com/java-merge-streams) +- [“Stream has already been operated upon or closed” Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception) diff --git a/core-java-9/README.md b/core-java-9/README.md index f0b2e3f206..98c855caea 100644 --- a/core-java-9/README.md +++ b/core-java-9/README.md @@ -17,3 +17,4 @@ - [Java 9 Reactive Streams](http://www.baeldung.com/java-9-reactive-streams) - [How to Get All Dates Between Two Dates?](http://www.baeldung.com/java-between-dates) - [Java 9 java.util.Objects Additions](http://www.baeldung.com/java-9-objects-new) +- [Compact Strings in Java 9](http://www.baeldung.com/java-9-compact-string) diff --git a/core-java/README.md b/core-java/README.md index a251de1daa..b4b8d9062e 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -106,4 +106,12 @@ - [Converting a List to String in Java](http://www.baeldung.com/java-list-to-string) - [CharSequence vs. String in Java](http://www.baeldung.com/java-char-sequence-string) - [Period and Duration in Java](http://www.baeldung.com/java-period-duration) -- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator) \ No newline at end of file +- [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator) +- [Singletons in Java](http://www.baeldung.com/java-singleton) +- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws) +- [OutOfMemoryError: GC Overhead Limit Exceeded](http://www.baeldung.com/java-gc-overhead-limit-exceeded) +- [How to Iterate Over a Stream With Indices](http://www.baeldung.com/java-stream-indices) +- [StringBuilder and StringBuffer in Java](http://www.baeldung.com/java-string-builder-string-buffer) +- [Number of Digits in an Integer in Java](http://www.baeldung.com/java-number-of-digits-in-int) +- [Proxy, Decorator, Adapter and Bridge Patterns](http://www.baeldung.com/java-structural-design-patterns) + diff --git a/core-java/src/main/java/com/baeldung/staticdemo/Car.java b/core-java/src/main/java/com/baeldung/staticdemo/Car.java new file mode 100644 index 0000000000..cdb3806c35 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/staticdemo/Car.java @@ -0,0 +1,48 @@ +package com.baeldung.staticdemo; + +/** + * This class demonstrates the use of static fields and static methods + * the instance variables engine and displacement are distinct for + * each and every object whereas static/class variable numberOfCars + * is unique and is shared across all objects of this class. + * + * @author baeldung + * + */ +public class Car { + private String name; + private String engine; + + public static int numberOfCars; + + public Car(String name, String engine) { + this.name = name; + this.engine = engine; + numberOfCars++; + } + + //getters and setters + public static int getNumberOfCars() { + return numberOfCars; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEngine() { + return engine; + } + + public void setEngine(String engine) { + this.engine = engine; + } + + public static void setNumberOfCars(int numberOfCars) { + Car.numberOfCars = numberOfCars; + } +} diff --git a/core-java/src/main/java/com/baeldung/staticdemo/Singleton.java b/core-java/src/main/java/com/baeldung/staticdemo/Singleton.java new file mode 100644 index 0000000000..de75af9d9d --- /dev/null +++ b/core-java/src/main/java/com/baeldung/staticdemo/Singleton.java @@ -0,0 +1,13 @@ +package com.baeldung.staticdemo; + +public class Singleton { + private Singleton() {} + + private static class SingletonHolder { + public static final Singleton instance = new Singleton(); + } + + public static Singleton getInstance() { + return SingletonHolder.instance; + } +} \ No newline at end of file diff --git a/core-java/src/main/java/com/baeldung/staticdemo/StaticBlock.java b/core-java/src/main/java/com/baeldung/staticdemo/StaticBlock.java new file mode 100644 index 0000000000..fde7afb090 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/staticdemo/StaticBlock.java @@ -0,0 +1,28 @@ +package com.baeldung.staticdemo; + +import java.util.LinkedList; +import java.util.List; + +public class StaticBlock { + private static List ranks = new LinkedList<>(); + + static { + ranks.add("Lieutenant"); + ranks.add("Captain"); + ranks.add("Major"); + } + + static { + ranks.add("Colonel"); + ranks.add("General"); + } + + //getters and setters + public static List getRanks() { + return ranks; + } + + public static void setRanks(List ranks) { + StaticBlock.ranks = ranks; + } +} diff --git a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/URIvsURLUnitTest.java b/core-java/src/test/java/com/baeldung/javanetworking/uriurl/URIvsURLUnitTest.java index ed36951f73..8837dc5556 100644 --- a/core-java/src/test/java/com/baeldung/javanetworking/uriurl/URIvsURLUnitTest.java +++ b/core-java/src/test/java/com/baeldung/javanetworking/uriurl/URIvsURLUnitTest.java @@ -71,8 +71,5 @@ public class URIvsURLUnitTest { URL url = new URL("http://courses.baeldung.com"); String contents = IOUtils.toString(url.openStream()); - - assertTrue(contents.contains("")); - } - + } } diff --git a/core-java/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java b/core-java/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java new file mode 100644 index 0000000000..3150627269 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java @@ -0,0 +1,14 @@ +package com.baeldung.staticdemo; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class CarIntegrationTest { + @Test + public void whenNumberOfCarObjectsInitialized_thenStaticCounterIncreases() { + new Car("Jaguar", "V8"); + new Car("Bugatti", "W16"); + assertEquals(2, Car.numberOfCars); + } +} diff --git a/core-java/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java b/core-java/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java new file mode 100644 index 0000000000..28d864073a --- /dev/null +++ b/core-java/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java @@ -0,0 +1,15 @@ +package com.baeldung.staticdemo; + +import org.junit.Assert; +import org.junit.Test; + +public class SingletonIntegrationTest { + + @Test + public void givenStaticInnerClass_whenMultipleTimesInstanceCalled_thenOnlyOneTimeInitialized() { + Singleton object1 = Singleton.getInstance(); + Singleton object2 = Singleton.getInstance(); + + Assert.assertSame(object1, object2); + } +} diff --git a/core-java/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java b/core-java/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java new file mode 100644 index 0000000000..f98e3e14db --- /dev/null +++ b/core-java/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java @@ -0,0 +1,17 @@ +package com.baeldung.staticdemo; + +import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.junit.Assert.assertThat; + +import java.util.List; + +import org.junit.Test; + +public class StaticBlockIntegrationTest { + + @Test + public void whenAddedListElementsThroughStaticBlock_thenEnsureCorrectOrder() { + List actualList = StaticBlock.getRanks(); + assertThat(actualList, contains("Lieutenant", "Captain", "Major", "Colonel", "General")); + } +} diff --git a/core-java/src/test/java/com/baeldung/string/StringTest.java b/core-java/src/test/java/com/baeldung/string/StringTest.java index fd83c903a3..0e325950b0 100644 --- a/core-java/src/test/java/com/baeldung/string/StringTest.java +++ b/core-java/src/test/java/com/baeldung/string/StringTest.java @@ -2,6 +2,12 @@ package com.baeldung.string; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.nio.charset.StandardCharsets; +import java.util.IllegalFormatException; +import java.util.regex.PatternSyntaxException; import org.junit.Test; @@ -12,6 +18,11 @@ public class StringTest { assertEquals(97, "abcd".codePointAt(0)); } + @Test(expected = StringIndexOutOfBoundsException.class) + public void whenPassNonExistingIndex_thenExceptionThrown() { + int a = "abcd".codePointAt(4); + } + @Test public void whenCallConcat_thenCorrect() { assertEquals("elephant", "elep".concat("hant")); @@ -21,6 +32,187 @@ public class StringTest { public void whenGetBytes_thenCorrect() { byte[] byteArray = "abcd".getBytes(); byte[] expected = new byte[] { 97, 98, 99, 100 }; + assertArrayEquals(expected, byteArray); } + + @Test + public void whenGetBytesUsingASCII_thenCorrect() { + byte[] byteArray = "efgh".getBytes(StandardCharsets.US_ASCII); + byte[] expected = new byte[] { 101, 102, 103, 104 }; + + assertArrayEquals(expected, byteArray); + } + + @Test + public void whenCreateStringUsingByteArray_thenCorrect() { + byte[] array = new byte[] { 97, 98, 99, 100 }; + String s = new String(array); + + assertEquals("abcd", s); + } + + @Test + public void whenCallCharAt_thenCorrect() { + assertEquals('P', "Paul".charAt(0)); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void whenCharAtOnNonExistingIndex_thenIndexOutOfBoundsExceptionThrown() { + char character = "Paul".charAt(4); + } + + @Test + public void whenCallCodePointCount_thenCorrect() { + assertEquals(2, "abcd".codePointCount(0, 2)); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void whenSecondIndexEqualToLengthOfString_thenIndexOutOfBoundsExceptionThrown() { + char character = "Paul".charAt(4); + } + + @Test + public void whenCallContains_thenCorrect() { + String s = "abcd"; + + assertTrue(s.contains("abc")); + assertFalse(s.contains("cde")); + } + + @Test + public void whenCallCopyValueOf_thenStringConstructed() { + char[] array = new char[] { 'a', 'b', 'c', 'd' }; + + assertEquals("abcd", String.copyValueOf(array)); + } + + @Test + public void whenCallEndsWith_thenCorrect() { + String s1 = "test"; + + assertTrue(s1.endsWith("t")); + } + + @Test + public void whenFormat_thenCorrect() { + String value = "Baeldung"; + String formatted = String.format("Welcome to %s!", value); + + assertEquals("Welcome to Baeldung!", formatted); + } + + @Test(expected = IllegalFormatException.class) + public void whenInvalidFormatSyntax_thenIllegalFormatExceptionThrown() { + String value = "Baeldung"; + String formatted = String.format("Welcome to %x!", value); + } + + @Test + public void whenCallIndexOf_thenCorrect() { + assertEquals(1, "foo".indexOf("o")); + } + + @Test + public void whenCallIsEmpty_thenCorrect() { + String s1 = ""; + + assertTrue(s1.isEmpty()); + } + + @Test + public void whenCallLastIndexOf_thenCorrect() { + assertEquals(2, "foo".lastIndexOf("o")); + } + + @Test + public void whenCallRegionMatches_thenCorrect() { + assertTrue("welcome to baeldung".regionMatches(false, 11, "baeldung", 0, 8)); + } + + @Test + public void whenCallStartsWith_thenCorrect() { + assertTrue("foo".startsWith("f")); + } + + @Test + public void whenTrim_thenCorrect() { + assertEquals("foo", " foo ".trim()); + } + + @Test + public void whenSplit_thenCorrect() { + String s = "Welcome to Baeldung"; + String[] array = new String[] { "Welcome", "to", "Baeldung" }; + + assertArrayEquals(array, s.split(" ")); + } + + @Test(expected = PatternSyntaxException.class) + public void whenPassInvalidParameterToSplit_thenPatternSyntaxExceptionThrown() { + String s = "Welcome*to Baeldung"; + + String[] result = s.split("*"); + } + + @Test + public void whenCallSubSequence_thenCorrect() { + String s = "Welcome to Baeldung"; + + assertEquals("Welcome", s.subSequence(0, 7)); + } + + @Test + public void whenCallSubstring_thenCorrect() { + String s = "Welcome to Baeldung"; + + assertEquals("Welcome", s.substring(0, 7)); + } + + @Test(expected = IndexOutOfBoundsException.class) + public void whenSecondIndexEqualToLengthOfString_thenCorrect() { + String s = "Welcome to Baeldung"; + + String sub = s.substring(0, 20); + } + + @Test + public void whenConvertToUpperCase_thenCorrect() { + String s = "Welcome to Baeldung!"; + + assertEquals("WELCOME TO BAELDUNG!", s.toUpperCase()); + } + + @Test + public void whenConvertToLowerCase_thenCorrect() { + String s = "WELCOME to BAELDUNG!"; + + assertEquals("welcome to baeldung!", s.toLowerCase()); + } + + @Test + public void whenCallReplace_thenCorrect() { + String s = "I learn Spanish"; + + assertEquals("I learn French", s.replaceAll("Spanish", "French")); + } + + @Test + public void whenIntern_thenCorrect() { + String s1 = "abc"; + String s2 = new String("abc"); + String s3 = new String("foo"); + String s4 = s1.intern(); + String s5 = s2.intern(); + + assertFalse(s3 == s4); + assertTrue(s1 == s5); + } + + @Test + public void whenCallValueOf_thenCorrect() { + long l = 200L; + + assertEquals("200", String.valueOf(l)); + } } diff --git a/core-kotlin/pom.xml b/core-kotlin/pom.xml index 856a37ded0..e795d1e042 100644 --- a/core-kotlin/pom.xml +++ b/core-kotlin/pom.xml @@ -5,6 +5,7 @@ core-kotlin 1.0-SNAPSHOT + jar com.baeldung @@ -20,6 +21,24 @@ + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + test + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + junit + junit + ${junit4.version} + test + org.jetbrains.kotlin kotlin-stdlib @@ -116,16 +135,51 @@ + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + maven-failsafe-plugin + 2.19.1 + + + org.junit.platform + junit-platform-surefire-provider + ${junit.platform.version} + + + + + junit5 + + integration-test + verify + + + + **/*Test5.java + + + + + + UTF-8 1.1.2 1.1.2 1.1.2 1.1.2 0.15 1.5.0 + + 5.0.0 + 1.0.0 + 4.12.0 + 4.12 - \ No newline at end of file + diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt new file mode 100644 index 0000000000..1b61c05887 --- /dev/null +++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt @@ -0,0 +1,17 @@ +package com.baeldung.kotlin.junit5 + +class Calculator { + fun add(a: Int, b: Int) = a + b + + fun divide(a: Int, b: Int) = if (b == 0) { + throw DivideByZeroException(a) + } else { + a / b + } + + fun square(a: Int) = a * a + + fun squareRoot(a: Int) = Math.sqrt(a.toDouble()) + + fun log(base: Int, value: Int) = Math.log(value.toDouble()) / Math.log(base.toDouble()) +} diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt new file mode 100644 index 0000000000..dd35805044 --- /dev/null +++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt @@ -0,0 +1,82 @@ +package com.baeldung.kotlin.junit5 + +import org.junit.jupiter.api.* +import org.junit.jupiter.api.function.Executable + +class CalculatorTest5 { + private val calculator = Calculator() + + @Test + fun testAddition() { + Assertions.assertEquals(4, calculator.add(1, 3)) + } + + @Test + fun testDivideByZero() { + val exception = Assertions.assertThrows(DivideByZeroException::class.java) { + calculator.divide(5, 0) + } + + Assertions.assertEquals(5, exception.numerator) + } + + @Test + fun testSquares() { + Assertions.assertAll( + Executable { Assertions.assertEquals(1, calculator.square(1)) }, + Executable { Assertions.assertEquals(4, calculator.square(2)) }, + Executable { Assertions.assertEquals(9, calculator.square(3)) } + ) + } + + @TestFactory + fun testSquaresFactory() = listOf( + DynamicTest.dynamicTest("1 squared") { Assertions.assertEquals(1,calculator.square(1))}, + DynamicTest.dynamicTest("2 squared") { Assertions.assertEquals(4,calculator.square(2))}, + DynamicTest.dynamicTest("3 squared") { Assertions.assertEquals(9,calculator.square(3))} + ) + + @TestFactory + fun testSquaresFactory2() = listOf( + 1 to 1, + 2 to 4, + 3 to 9, + 4 to 16, + 5 to 25) + .map { (input, expected) -> + DynamicTest.dynamicTest("$input squared") { + Assertions.assertEquals(expected, calculator.square(input)) + } + } + + private val squaresTestData = listOf( + 1 to 1, + 2 to 4, + 3 to 9, + 4 to 16, + 5 to 25) + + @TestFactory + fun testSquaresFactory3() = squaresTestData + .map { (input, expected) -> + DynamicTest.dynamicTest("$input squared") { + Assertions.assertEquals(expected, calculator.square(input)) + } + } + @TestFactory + fun testSquareRootsFactory3() = squaresTestData + .map { (expected, input) -> + DynamicTest.dynamicTest("Square root of $input") { + Assertions.assertEquals(expected.toDouble(), calculator.squareRoot(input)) + } + } + + @Tags( + Tag("slow"), + Tag("logarithms") + ) + @Test + fun testLogarithms() { + Assertions.assertEquals(3.0, calculator.log(2, 8)) + } +} diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt new file mode 100644 index 0000000000..60bc4e2944 --- /dev/null +++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt @@ -0,0 +1,3 @@ +package com.baeldung.kotlin.junit5 + +class DivideByZeroException(val numerator: Int) : Exception() diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt new file mode 100644 index 0000000000..c04ab568f7 --- /dev/null +++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt @@ -0,0 +1,21 @@ +package com.baeldung.kotlin.junit5 + +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +class SimpleTest5 { + @Test + fun testEmpty() { + val list = listOf() + Assertions.assertTrue(list::isEmpty) + } + + @Test + @Disabled + fun testMessage() { + Assertions.assertEquals(3, 4) { + "Three does not equal four" + } + } +} diff --git a/deltaspike/README.md b/deltaspike/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/deltaspike/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/drools/README.MD b/drools/README.MD index 4ece7608fc..e3f00f5047 100644 --- a/drools/README.MD +++ b/drools/README.MD @@ -1,3 +1,4 @@ ### Relevant Articles: -[Introduction to Drools](http://www.baeldung.com/drools) -[Drools Using Rules from Excel Files](http://www.baeldung.com/drools-excel) +- [Introduction to Drools](http://www.baeldung.com/drools) +- [Drools Using Rules from Excel Files](http://www.baeldung.com/drools-excel) +- [Drools Using Rules from Excel Files](http://www.baeldung.com/drools-excel) diff --git a/drools/backward-chaining/pom.xml b/drools/backward-chaining/pom.xml new file mode 100644 index 0000000000..bda0cf2abc --- /dev/null +++ b/drools/backward-chaining/pom.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + + drools-backward-chaining + 1.0 + drools-backward-chaining + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + 6.4.0.Final + + + + + org.kie + kie-api + ${runtime.version} + + + org.drools + drools-core + ${runtime.version} + + + org.drools + drools-decisiontables + ${runtime.version} + + + diff --git a/drools/backward-chaining/src/main/java/com/baeldung/BackwardChainingBeatles.java b/drools/backward-chaining/src/main/java/com/baeldung/BackwardChainingBeatles.java new file mode 100644 index 0000000000..7fc5bd3685 --- /dev/null +++ b/drools/backward-chaining/src/main/java/com/baeldung/BackwardChainingBeatles.java @@ -0,0 +1,28 @@ +package com.baeldung; + +import org.kie.api.KieServices; +import org.kie.api.runtime.KieContainer; +import org.kie.api.runtime.KieSession; + +import com.baeldung.model.Beatle; + +public class BackwardChainingBeatles { + public static void main(String[] args) { + + KieServices ks = KieServices.Factory.get(); + KieContainer kContainer = ks.getKieClasspathContainer(); + KieSession kSession = kContainer.newKieSession("ksession-backward-chaining"); + // drools session base on the xml configuration (kmodule.xml) + + // graph population + kSession.insert(new Beatle("Starr", "drums")); + kSession.insert(new Beatle("McCartney", "bass")); + kSession.insert(new Beatle("Lennon", "guitar")); + kSession.insert(new Beatle("Harrison", "guitar")); + + kSession.insert("Ringo"); // invoke the rule that calls the query implentation of backward chaining + kSession.fireAllRules(); // invoke all the rules + + } + +} \ No newline at end of file diff --git a/drools/backward-chaining/src/main/java/com/baeldung/model/Beatle.java b/drools/backward-chaining/src/main/java/com/baeldung/model/Beatle.java new file mode 100644 index 0000000000..4b219b3a69 --- /dev/null +++ b/drools/backward-chaining/src/main/java/com/baeldung/model/Beatle.java @@ -0,0 +1,33 @@ +package com.baeldung.model; + +import org.kie.api.definition.type.Position; + +public class Beatle { + + @Position(0) + private String lastName; + @Position(1) + private String instrument; + + public Beatle(String lastName, String instrument) { + this.lastName = lastName; + this.instrument = instrument; + } + + public String getInstrument() { + return instrument; + } + + public void setInstrument(String instrument) { + this.instrument = instrument; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + +} \ No newline at end of file diff --git a/drools/backward-chaining/src/main/resources/META-INF/kmodule.xml b/drools/backward-chaining/src/main/resources/META-INF/kmodule.xml new file mode 100644 index 0000000000..6498e26343 --- /dev/null +++ b/drools/backward-chaining/src/main/resources/META-INF/kmodule.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/drools/backward-chaining/src/main/resources/backward_chaining/Beatles.drl b/drools/backward-chaining/src/main/resources/backward_chaining/Beatles.drl new file mode 100644 index 0000000000..8d0d06a79e --- /dev/null +++ b/drools/backward-chaining/src/main/resources/backward_chaining/Beatles.drl @@ -0,0 +1,44 @@ +package com.baeldung + +import com.baeldung.model.Beatle; + + +query whichBeatle(String lastName, String instrument) + Beatle(lastName, instrument;) + or + (Beatle(lastName, null;) + and + whichBeatle(null, instrument;)) //recursive call to the function that allows to search in a derivation tree structure +end + +rule "Ringo" + when + String(this == "Ringo") + whichBeatle("Starr", "drums";) + then + System.out.println("The beatle is Ringo Starr"); +end + +rule "Paul" + when + String(this == "Paul") + whichBeatle("McCartney", "bass";) + then + System.out.println("The beatle is Paul McCartney"); +end + +rule "John" + when + String(this == "John") + whichBeatle("Lennon", "guitar";) + then + System.out.println("The beatle is John Lennon"); +end + +rule "George" + when + String(this == "George") + whichBeatle("Harrison", "guitar";) + then + System.out.println("The beatle is George Harrison"); +end diff --git a/eclipse/README.md b/eclipse/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/eclipse/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/ejb/README.md b/ejb/README.md index 3b729318d4..994781b064 100644 --- a/ejb/README.md +++ b/ejb/README.md @@ -2,3 +2,4 @@ - [Guide to EJB Set-up](http://www.baeldung.com/ejb-intro) - [Java EE Session Beans](http://www.baeldung.com/ejb-session-beans) +- [Introduction to EJB JNDI Lookup on WildFly Application Server](http://www.baeldung.com/wildfly-ejb-jndi) diff --git a/ejb/wildfly/pom.xml b/ejb/wildfly/pom.xml new file mode 100644 index 0000000000..d4843f9fc9 --- /dev/null +++ b/ejb/wildfly/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + com.baeldung.wildfly + wildfly-example + 0.0.1-SNAPSHOT + pom + + + 1.8 + 1.8 + UTF-8 + + + widlfly-web + wildfly-ear + wildfly-jpa + wildfly-ejb-interfaces + wildfly-ejb + + + + + + + + javax + javaee-api + 7.0 + provided + + + + org.wildfly.bom + wildfly-javaee7 + 10.1.0.Final + import + pom + + + + org.hibernate + hibernate-core + 5.2.3.Final + provided + + + + com.baeldung.wildfly + wildlfy-ear + 0.0.1-SNAPSHOT + ear + + + + com.baeldung.wildfly + wildlfy-web + 0.0.1-SNAPSHOT + war + + + + com.baeldung.wildfly + wildlfy-jpa + 0.0.1-SNAPSHOT + + + + com.baeldung.wildfly + wildfly-ejb + 0.0.1-SNAPSHOT + + + + com.baeldung.wildfly + wildfly-ejb-interfaces + 0.0.1-SNAPSHOT + + + + \ No newline at end of file diff --git a/ejb/wildfly/widlfly-web/pom.xml b/ejb/wildfly/widlfly-web/pom.xml new file mode 100644 index 0000000000..2e316dedd9 --- /dev/null +++ b/ejb/wildfly/widlfly-web/pom.xml @@ -0,0 +1,39 @@ + + 4.0.0 + + com.baeldung.wildfly + wildfly-example + 0.0.1-SNAPSHOT + + widlfly-web + war + + + + + javax + javaee-api + 7.0 + provided + + + + com.baeldung.wildfly + wildfly-jpa + 0.0.1-SNAPSHOT + + + + com.baeldung.wildfly + wildfly-ejb-interfaces + 0.0.1-SNAPSHOT + + + + com.baeldung.wildfly + wildfly-ejb + 0.0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/ejb/wildfly/widlfly-web/src/main/java/TestEJBServlet.java b/ejb/wildfly/widlfly-web/src/main/java/TestEJBServlet.java new file mode 100644 index 0000000000..62feb6b4b9 --- /dev/null +++ b/ejb/wildfly/widlfly-web/src/main/java/TestEJBServlet.java @@ -0,0 +1,33 @@ + +import java.io.IOException; +import java.util.List; + +import javax.ejb.EJB; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import model.User; +import wildfly.beans.UserBeanLocal; + +/** + * Servlet implementation class TestEJBServlet + */ +public class TestEJBServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + + @EJB + private UserBeanLocal userBean; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + List users = userBean.getUsers(); + + response.getWriter() + .append("The number of users is: " + users.size()); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doGet(request, response); + } +} diff --git a/ejb/wildfly/widlfly-web/src/main/java/TestJPAServlet.java b/ejb/wildfly/widlfly-web/src/main/java/TestJPAServlet.java new file mode 100644 index 0000000000..609366c53a --- /dev/null +++ b/ejb/wildfly/widlfly-web/src/main/java/TestJPAServlet.java @@ -0,0 +1,54 @@ + +import java.io.IOException; +import java.util.List; + +import javax.annotation.Resource; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.transaction.UserTransaction; + +import model.User; + +/** + * Servlet implementation class TestJPAServlet + */ +public class TestJPAServlet extends HttpServlet { + private static final long serialVersionUID = 1L; + @PersistenceContext(unitName = "wildfly-jpa") + EntityManager em; + + @Resource + UserTransaction tx; + + /** + * @see HttpServlet#HttpServlet() + */ + public TestJPAServlet() { + super(); + // TODO Auto-generated constructor stub + } + + /** + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + Query q = em.createNamedQuery("User.findAll"); + List users = q.getResultList(); + response.getWriter() + .append("JPA users returned: " + users.size()); + } + + /** + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO Auto-generated method stub + doGet(request, response); + } + +} diff --git a/ejb/wildfly/widlfly-web/src/main/webapp/WEB-INF/web.xml b/ejb/wildfly/widlfly-web/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..5b3f664443 --- /dev/null +++ b/ejb/wildfly/widlfly-web/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,35 @@ + + + widlfly-web + + index.html + index.htm + index.jsp + default.html + default.htm + default.jsp + + + + TestJPAServlet + TestJPAServlet + TestJPAServlet + + + TestJPAServlet + /TestJPAServlet + + + + TestEJBServlet + TestEJBServlet + TestEJBServlet + + + TestEJBServlet + /TestEJBServlet + + \ No newline at end of file diff --git a/ejb/wildfly/wildfly-ear/pom.xml b/ejb/wildfly/wildfly-ear/pom.xml new file mode 100644 index 0000000000..6beb387227 --- /dev/null +++ b/ejb/wildfly/wildfly-ear/pom.xml @@ -0,0 +1,62 @@ + + 4.0.0 + + com.baeldung.wildfly + wildfly-example + 0.0.1-SNAPSHOT + + wildfly-ear + ear + + + + + com.baeldung.wildfly + widlfly-web + 0.0.1-SNAPSHOT + war + + + + com.baeldung.wildfly + wildfly-jpa + 0.0.1-SNAPSHOT + + + + com.baeldung.wildfly + wildfly-ejb + + + + com.baeldung.wildfly + wildfly-ejb-interfaces + + + + + + + maven-ear-plugin + 2.10.1 + + lib/ + 7 + + + com.baeldung.wildfly + widlfly-web + /wildfly + + + + + + org.wildfly.plugins + wildfly-maven-plugin + 1.2.0.Final + + + + \ No newline at end of file diff --git a/ejb/wildfly/wildfly-ejb-interfaces/pom.xml b/ejb/wildfly/wildfly-ejb-interfaces/pom.xml new file mode 100644 index 0000000000..e4d2eee0c6 --- /dev/null +++ b/ejb/wildfly/wildfly-ejb-interfaces/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + + com.baeldung.wildfly + wildfly-example + 0.0.1-SNAPSHOT + + wildfly-ejb-interfaces + + + + + javax.ejb + javax.ejb-api + 3.2 + provided + + + + com.baeldung.wildfly + wildfly-jpa + 0.0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/ejb/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanLocal.java b/ejb/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanLocal.java new file mode 100644 index 0000000000..16930cb5b9 --- /dev/null +++ b/ejb/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanLocal.java @@ -0,0 +1,13 @@ +package wildfly.beans; + +import java.util.List; + +import javax.ejb.Local; + +import model.User; + +@Local +public interface UserBeanLocal { + + List getUsers(); +} diff --git a/ejb/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanRemote.java b/ejb/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanRemote.java new file mode 100644 index 0000000000..5b57d4283f --- /dev/null +++ b/ejb/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanRemote.java @@ -0,0 +1,13 @@ +package wildfly.beans; + +import java.util.List; + +import javax.ejb.Remote; + +import model.User; + +@Remote +public interface UserBeanRemote { + + List getUsers(); +} diff --git a/ejb/wildfly/wildfly-ejb/pom.xml b/ejb/wildfly/wildfly-ejb/pom.xml new file mode 100644 index 0000000000..9d4464dafa --- /dev/null +++ b/ejb/wildfly/wildfly-ejb/pom.xml @@ -0,0 +1,49 @@ + + 4.0.0 + + com.baeldung.wildfly + wildfly-example + 0.0.1-SNAPSHOT + + wildfly-ejb + ejb + + + + + javax.ejb + javax.ejb-api + 3.2 + provided + + + + javax + javaee-api + provided + + + + org.hibernate + hibernate-core + + + + com.baeldung.wildfly + wildfly-ejb-interfaces + + + + + + + org.apache.maven.plugins + maven-ejb-plugin + + 3.2 + + + + + \ No newline at end of file diff --git a/ejb/wildfly/wildfly-ejb/src/main/java/wildfly/beans/UserBean.java b/ejb/wildfly/wildfly-ejb/src/main/java/wildfly/beans/UserBean.java new file mode 100644 index 0000000000..07e3cbcb32 --- /dev/null +++ b/ejb/wildfly/wildfly-ejb/src/main/java/wildfly/beans/UserBean.java @@ -0,0 +1,24 @@ +package wildfly.beans; + +import java.util.List; + +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import model.User; + +/** + * Session Bean implementation class UserBean + */ +@Stateless +public class UserBean implements UserBeanRemote, UserBeanLocal { + @PersistenceContext(unitName = "wildfly-jpa") + private EntityManager em; + + @Override + public List getUsers() { + return em.createNamedQuery("User.findAll") + .getResultList(); + } +} diff --git a/ejb/wildfly/wildfly-jpa/pom.xml b/ejb/wildfly/wildfly-jpa/pom.xml new file mode 100644 index 0000000000..e6f8b32e17 --- /dev/null +++ b/ejb/wildfly/wildfly-jpa/pom.xml @@ -0,0 +1,20 @@ + + 4.0.0 + + com.baeldung.wildfly + wildfly-example + 0.0.1-SNAPSHOT + + wildfly-jpa + + + + + + org.hibernate + hibernate-core + provided + + + \ No newline at end of file diff --git a/ejb/wildfly/wildfly-jpa/src/main/java/model/User.java b/ejb/wildfly/wildfly-jpa/src/main/java/model/User.java new file mode 100644 index 0000000000..3a3f95bf8c --- /dev/null +++ b/ejb/wildfly/wildfly-jpa/src/main/java/model/User.java @@ -0,0 +1,51 @@ +package model; + +import java.io.Serializable; +import javax.persistence.*; + +/** + * The persistent class for the users database table. + * + */ +@Entity +@Table(name = "users") +@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u") +public class User implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + private String username; + + private String email; + + @Column(name = "postal_number") + private Integer postalNumber; + + public User() { + } + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Integer getPostalNumber() { + return this.postalNumber; + } + + public void setPostalNumber(Integer postalNumber) { + this.postalNumber = postalNumber; + } + +} \ No newline at end of file diff --git a/ejb/wildfly/wildfly-jpa/src/main/resources/META-INF/persistence.xml b/ejb/wildfly/wildfly-jpa/src/main/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..1a3fc32381 --- /dev/null +++ b/ejb/wildfly/wildfly-jpa/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,9 @@ + + + + java:/PostgresDS + model.User + + diff --git a/enterprise-patterns/README.md b/enterprise-patterns/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/enterprise-patterns/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/ethereumj/README.md b/ethereumj/README.md index 54da91b4f7..d2e2753438 100644 --- a/ethereumj/README.md +++ b/ethereumj/README.md @@ -1,4 +1,4 @@ ## EthereumJ ### Relevant Articles: -- [Introduction to EthereumJ](http://www.baeldung.com/intro-to-ethereumj) \ No newline at end of file +- [Introduction to EthereumJ](http://www.baeldung.com/ethereumj) diff --git a/events/README.md b/events/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/events/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/feign/README.md b/feign/README.md index 4d6964a73a..da04c40cdc 100644 --- a/feign/README.md +++ b/feign/README.md @@ -5,4 +5,6 @@ This is the implementation of a [spring-hypermedia-api][1] client using Feign. [1]: https://github.com/eugenp/spring-hypermedia-api ### Relevant Articles: + - [Intro to Feign](http://www.baeldung.com/intro-to-feign) +- [Introduction to SLF4J](http://www.baeldung.com/slf4j-with-log4j2-logback) diff --git a/gradle/README.md b/gradle/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/gradle/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/graphql/graphql-java/README.md b/graphql/graphql-java/README.md new file mode 100644 index 0000000000..0033524209 --- /dev/null +++ b/graphql/graphql-java/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Introduction to GraphQL](http://www.baeldung.com/graphql) diff --git a/guava21/README.md b/guava21/README.md index 2a54416e41..68c1ac4a8e 100644 --- a/guava21/README.md +++ b/guava21/README.md @@ -1,3 +1,4 @@ ### Relevant articles: - [New Stream, Comparator and Collector Functionality in Guava 21](http://www.baeldung.com/guava-21-new) - [New in Guava 21 common.util.concurrent](http://www.baeldung.com/guava-21-util-concurrent) +- [Zipping Collections in Java](http://www.baeldung.com/java-collections-zip) diff --git a/guest/README.md b/guest/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/guest/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/guest/spring-mvc/pom.xml b/guest/spring-mvc/pom.xml new file mode 100644 index 0000000000..9974a76e8a --- /dev/null +++ b/guest/spring-mvc/pom.xml @@ -0,0 +1,59 @@ + + + 4.0.0 + + com.forketyfork.guest + spring-mvc + 0.0.1-SNAPSHOT + jar + + spring-mvc + Spring MVC sample project + + + org.springframework.boot + spring-boot-starter-parent + 2.0.0.M5 + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + UTF-8 + UTF-8 + 1.8 + + + diff --git a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/Spring5Application.java b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/Spring5Application.java new file mode 100644 index 0000000000..d9af7c8ac9 --- /dev/null +++ b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/Spring5Application.java @@ -0,0 +1,15 @@ +package com.forketyfork.guest.springmvc; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.boot.SpringApplication; + +@SpringBootApplication +@ComponentScan(basePackages = {"com.forketyfork.guest.springmvc"}) +public class Spring5Application { + + public static void main(String[] args) { + SpringApplication.run(Spring5Application.class, args); + } + +} diff --git a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/model/LoginData.java b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/model/LoginData.java new file mode 100644 index 0000000000..a9140da4f9 --- /dev/null +++ b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/model/LoginData.java @@ -0,0 +1,27 @@ +package com.forketyfork.guest.springmvc.model; + +public class LoginData { + + private String login; + + private String password; + + public LoginData() { + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/InternalsController.java b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/InternalsController.java new file mode 100644 index 0000000000..c39da4e3e5 --- /dev/null +++ b/guest/spring-mvc/src/main/java/com/forketyfork/guest/springmvc/web/InternalsController.java @@ -0,0 +1,31 @@ +package com.forketyfork.guest.springmvc.web; + +import com.forketyfork.guest.springmvc.model.LoginData; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.servlet.ModelAndView; + +import java.util.Collections; + +@Controller +public class InternalsController { + + private static final String LOGIN = "jack"; + private static final String PASSWORD = "halloween"; + + @GetMapping("/") + public String hello() { + return "login"; + } + + @PostMapping("/login") + public ModelAndView login(LoginData loginData) { + if (LOGIN.equals(loginData.getLogin()) && PASSWORD.equals(loginData.getPassword())) { + return new ModelAndView("success", Collections.singletonMap("login", loginData.getLogin())); + } else { + return new ModelAndView("failure", Collections.singletonMap("login", loginData.getLogin())); + } + } + +} diff --git a/guest/spring-mvc/src/main/resources/templates/failure.html b/guest/spring-mvc/src/main/resources/templates/failure.html new file mode 100644 index 0000000000..f319652ede --- /dev/null +++ b/guest/spring-mvc/src/main/resources/templates/failure.html @@ -0,0 +1,10 @@ + + + + Login Failure + +

    + User with login not found, please try again. +

    + \ No newline at end of file diff --git a/guest/spring-mvc/src/main/resources/templates/login.html b/guest/spring-mvc/src/main/resources/templates/login.html new file mode 100644 index 0000000000..d031ac8825 --- /dev/null +++ b/guest/spring-mvc/src/main/resources/templates/login.html @@ -0,0 +1,13 @@ + + +Login Form + + +
    + + + +
    + + + \ No newline at end of file diff --git a/guest/spring-mvc/src/main/resources/templates/success.html b/guest/spring-mvc/src/main/resources/templates/success.html new file mode 100644 index 0000000000..6966385f2e --- /dev/null +++ b/guest/spring-mvc/src/main/resources/templates/success.html @@ -0,0 +1,10 @@ + + + + Login Success + +

    + Hello, ! +

    + \ No newline at end of file diff --git a/handling-spring-static-resources/README.md b/handling-spring-static-resources/README.md index d8f64bc427..c12e0272d4 100644 --- a/handling-spring-static-resources/README.md +++ b/handling-spring-static-resources/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Cachable Static Assets with Spring MVC](http://www.baeldung.com/cachable-static-assets-with-spring-mvc) - [Minification of JS and CSS Assets with Maven](http://www.baeldung.com/maven-minification-of-js-and-css-assets) +- [Serve Static Resources with Spring](http://www.baeldung.com/spring-mvc-static-resources) diff --git a/hibernate5/README.md b/hibernate5/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/hibernate5/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/httpclient/README.md b/httpclient/README.md index 2a98c2feac..93e0f3c9e1 100644 --- a/httpclient/README.md +++ b/httpclient/README.md @@ -20,3 +20,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [HttpAsyncClient Tutorial](http://www.baeldung.com/httpasyncclient-tutorial) - [HttpClient 4 Tutorial](http://www.baeldung.com/httpclient-guide) - [Advanced HttpClient Configuration](http://www.baeldung.com/httpclient-advanced-config) +- [HttpClient 4 – Do Not Follow Redirects](http://www.baeldung.com/httpclient-stop-follow-redirect) +- [HttpClient 4 – Setting a Custom User-Agent](http://www.baeldung.com/httpclient-user-agent-header) diff --git a/hystrix/pom.xml b/hystrix/pom.xml index 7e9a217dba..58e09816ea 100644 --- a/hystrix/pom.xml +++ b/hystrix/pom.xml @@ -2,7 +2,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - com.baeldung hystrix 1.0 hystrix diff --git a/hystrix/src/test/java/com/baeldung/hystrix/HystrixTimeoutIntegrationTest.java b/hystrix/src/test/java/com/baeldung/hystrix/HystrixTimeoutManualTest.java similarity index 72% rename from hystrix/src/test/java/com/baeldung/hystrix/HystrixTimeoutIntegrationTest.java rename to hystrix/src/test/java/com/baeldung/hystrix/HystrixTimeoutManualTest.java index bf0c542980..ed89104c05 100644 --- a/hystrix/src/test/java/com/baeldung/hystrix/HystrixTimeoutIntegrationTest.java +++ b/hystrix/src/test/java/com/baeldung/hystrix/HystrixTimeoutManualTest.java @@ -10,53 +10,53 @@ import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -public class HystrixTimeoutIntegrationTest { +public class HystrixTimeoutManualTest { @Test - public void givenInputBobAndDefaultSettings_whenCommandExecuted_thenReturnHelloBob(){ + public void givenInputBobAndDefaultSettings_whenCommandExecuted_thenReturnHelloBob() { assertThat(new CommandHelloWorld("Bob").execute(), equalTo("Hello Bob!")); } @Test public void givenSvcTimeoutOf100AndDefaultSettings_whenRemoteSvcExecuted_thenReturnSuccess() - throws InterruptedException { + throws InterruptedException { HystrixCommand.Setter config = HystrixCommand - .Setter - .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroup2")); + .Setter + .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroup2")); assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(100)).execute(), - equalTo("Success")); + equalTo("Success")); } @Test(expected = HystrixRuntimeException.class) public void givenSvcTimeoutOf10000AndDefaultSettings__whenRemoteSvcExecuted_thenExpectHRE() throws InterruptedException { HystrixCommand.Setter config = HystrixCommand - .Setter - .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest3")); + .Setter + .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest3")); new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(10_000)).execute(); } @Test public void givenSvcTimeoutOf5000AndExecTimeoutOf10000_whenRemoteSvcExecuted_thenReturnSuccess() - throws InterruptedException { + throws InterruptedException { HystrixCommand.Setter config = HystrixCommand - .Setter - .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest4")); + .Setter + .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest4")); HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter(); commandProperties.withExecutionTimeoutInMilliseconds(10_000); config.andCommandPropertiesDefaults(commandProperties); assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(500)).execute(), - equalTo("Success")); + equalTo("Success")); } @Test(expected = HystrixRuntimeException.class) public void givenSvcTimeoutOf15000AndExecTimeoutOf5000__whenExecuted_thenExpectHRE() - throws InterruptedException { + throws InterruptedException { HystrixCommand.Setter config = HystrixCommand - .Setter - .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest5")); + .Setter + .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupTest5")); HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter(); commandProperties.withExecutionTimeoutInMilliseconds(5_000); config.andCommandPropertiesDefaults(commandProperties); @@ -65,45 +65,45 @@ public class HystrixTimeoutIntegrationTest { @Test public void givenSvcTimeoutOf500AndExecTimeoutOf10000AndThreadPool__whenExecuted_thenReturnSuccess() - throws InterruptedException { + throws InterruptedException { HystrixCommand.Setter config = HystrixCommand - .Setter - .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupThreadPool")); + .Setter + .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupThreadPool")); HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter(); commandProperties.withExecutionTimeoutInMilliseconds(10_000); config.andCommandPropertiesDefaults(commandProperties); config.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter() - .withMaxQueueSize(10) - .withCoreSize(3) - .withQueueSizeRejectionThreshold(10)); + .withMaxQueueSize(10) + .withCoreSize(3) + .withQueueSizeRejectionThreshold(10)); assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(500)).execute(), - equalTo("Success")); + equalTo("Success")); } @Test public void givenCircuitBreakerSetup__whenRemoteSvcCmdExecuted_thenReturnSuccess() - throws InterruptedException { + throws InterruptedException { HystrixCommand.Setter config = HystrixCommand - .Setter - .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupCircuitBreaker")); + .Setter + .withGroupKey(HystrixCommandGroupKey.Factory.asKey("RemoteServiceGroupCircuitBreaker")); HystrixCommandProperties.Setter properties = HystrixCommandProperties.Setter(); properties.withExecutionTimeoutInMilliseconds(1000); properties.withCircuitBreakerSleepWindowInMilliseconds(4000); properties.withExecutionIsolationStrategy( - HystrixCommandProperties.ExecutionIsolationStrategy.THREAD); + HystrixCommandProperties.ExecutionIsolationStrategy.THREAD); properties.withCircuitBreakerEnabled(true); properties.withCircuitBreakerRequestVolumeThreshold(1); config.andCommandPropertiesDefaults(properties); config.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter() - .withMaxQueueSize(1) - .withCoreSize(1) - .withQueueSizeRejectionThreshold(1)); + .withMaxQueueSize(1) + .withCoreSize(1) + .withQueueSizeRejectionThreshold(1)); assertThat(this.invokeRemoteService(config, 10_000), equalTo(null)); assertThat(this.invokeRemoteService(config, 10_000), equalTo(null)); @@ -111,19 +111,19 @@ public class HystrixTimeoutIntegrationTest { Thread.sleep(5000); assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(500)).execute(), - equalTo("Success")); + equalTo("Success")); assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(500)).execute(), - equalTo("Success")); + equalTo("Success")); assertThat(new RemoteServiceTestCommand(config, new RemoteServiceTestSimulator(500)).execute(), - equalTo("Success")); + equalTo("Success")); } public String invokeRemoteService(HystrixCommand.Setter config, int timeout) - throws InterruptedException { + throws InterruptedException { String response = null; try { response = new RemoteServiceTestCommand(config, - new RemoteServiceTestSimulator(timeout)).execute(); + new RemoteServiceTestSimulator(timeout)).execute(); } catch (HystrixRuntimeException ex) { System.out.println("ex = " + ex); } diff --git a/intelliJ/README.md b/intelliJ/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/intelliJ/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/jackson/README.md b/jackson/README.md index 51919f6769..a710a1689e 100644 --- a/jackson/README.md +++ b/jackson/README.md @@ -28,3 +28,10 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [A Guide to Optional with Jackson](http://www.baeldung.com/jackson-optional) - [Map Serialization and Deserialization with Jackson](http://www.baeldung.com/jackson-map) - [Jackson Streaming API](http://www.baeldung.com/jackson-streaming-api) +- [Jackson – JsonMappingException (No serializer found for class)](http://www.baeldung.com/jackson-jsonmappingexception) +- [How To Serialize Enums as JSON Objects with Jackson](http://www.baeldung.com/jackson-serialize-enums) +- [Jackson – Marshall String to JsonNode](http://www.baeldung.com/jackson-json-to-jsonnode) +- [Ignore Null Fields with Jackson](http://www.baeldung.com/jackson-ignore-null-fields) +- [Jackson – Unmarshall to Collection/Array](http://www.baeldung.com/jackson-collection-array) +- [Jackson – Change Name of Field](http://www.baeldung.com/jackson-name-of-property) +- [Serialize Only Fields that meet a Custom Criteria with Jackson](http://www.baeldung.com/jackson-serialize-field-custom-criteria) diff --git a/jackson/pom.xml b/jackson/pom.xml index f970b6a68c..001fde5021 100644 --- a/jackson/pom.xml +++ b/jackson/pom.xml @@ -129,7 +129,7 @@ - 2.9.0 + 2.9.2 19.0 diff --git a/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/DeserializeWithNestedPropertiesUnitTest.java b/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/DeserializeWithNestedPropertiesUnitTest.java new file mode 100644 index 0000000000..037bc7e880 --- /dev/null +++ b/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/DeserializeWithNestedPropertiesUnitTest.java @@ -0,0 +1,70 @@ +package com.baeldung.jackson.deserialization.nested; + +import static org.junit.Assert.*; + +import java.io.IOException; + +import org.junit.Test; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.module.SimpleModule; + +public class DeserializeWithNestedPropertiesUnitTest { + + private String SOURCE_JSON = "{\"id\":\"957c43f2-fa2e-42f9-bf75-6e3d5bb6960a\",\"name\":\"The Best Product\",\"brand\":{\"id\":\"9bcd817d-0141-42e6-8f04-e5aaab0980b6\",\"name\":\"ACME Products\",\"owner\":{\"id\":\"b21a80b1-0c09-4be3-9ebd-ea3653511c13\",\"name\":\"Ultimate Corp, Inc.\"}}}"; + + @Test + public void whenUsingAnnotations_thenOk() throws IOException { + Product product = new ObjectMapper().readerFor(Product.class) + .readValue(SOURCE_JSON); + + assertEquals(product.getName(), "The Best Product"); + assertEquals(product.getBrandName(), "ACME Products"); + assertEquals(product.getOwnerName(), "Ultimate Corp, Inc."); + } + + @Test + public void whenUsingJsonNode_thenOk() throws IOException { + JsonNode productNode = new ObjectMapper().readTree(SOURCE_JSON); + + Product product = new Product(); + product.setId(productNode.get("id") + .textValue()); + product.setName(productNode.get("name") + .textValue()); + product.setBrandName(productNode.get("brand") + .get("name") + .textValue()); + product.setOwnerName(productNode.get("brand") + .get("owner") + .get("name") + .textValue()); + + assertEquals(product.getName(), "The Best Product"); + assertEquals(product.getBrandName(), "ACME Products"); + assertEquals(product.getOwnerName(), "Ultimate Corp, Inc."); + } + + @Test + public void whenUsingDeserializerManuallyRegistered_thenOk() throws IOException { + ObjectMapper mapper = new ObjectMapper(); + SimpleModule module = new SimpleModule(); + module.addDeserializer(Product.class, new ProductDeserializer()); + mapper.registerModule(module); + + Product product = mapper.readValue(SOURCE_JSON, Product.class); + assertEquals(product.getName(), "The Best Product"); + assertEquals(product.getBrandName(), "ACME Products"); + assertEquals(product.getOwnerName(), "Ultimate Corp, Inc."); + } + + @Test + public void whenUsingDeserializerAutoRegistered_thenOk() throws IOException { + ObjectMapper mapper = new ObjectMapper(); + Product product = mapper.readValue(SOURCE_JSON, Product.class); + assertEquals(product.getName(), "The Best Product"); + assertEquals(product.getBrandName(), "ACME Products"); + assertEquals(product.getOwnerName(), "Ultimate Corp, Inc."); + } +} diff --git a/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/Product.java b/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/Product.java new file mode 100644 index 0000000000..0020afea0f --- /dev/null +++ b/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/Product.java @@ -0,0 +1,55 @@ +package com.baeldung.jackson.deserialization.nested; + +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = ProductDeserializer.class) +public class Product { + + private String id; + private String name; + private String brandName; + private String ownerName; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getBrandName() { + return brandName; + } + + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + public String getOwnerName() { + return ownerName; + } + + public void setOwnerName(String ownerName) { + this.ownerName = ownerName; + } + + @SuppressWarnings("unchecked") + @JsonProperty("brand") + private void unpackNested(Map brand) { + this.brandName = (String) brand.get("name"); + Map owner = (Map) brand.get("owner"); + this.ownerName = owner.get("name"); + } +} \ No newline at end of file diff --git a/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/ProductDeserializer.java b/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/ProductDeserializer.java new file mode 100644 index 0000000000..daabae6cda --- /dev/null +++ b/jackson/src/test/java/com/baeldung/jackson/deserialization/nested/ProductDeserializer.java @@ -0,0 +1,40 @@ +package com.baeldung.jackson.deserialization.nested; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +@SuppressWarnings("serial") +public class ProductDeserializer extends StdDeserializer { + + public ProductDeserializer() { + this(null); + } + + public ProductDeserializer(Class vc) { + super(vc); + } + + @Override + public Product deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode productNode = jp.getCodec() + .readTree(jp); + Product product = new Product(); + product.setId(productNode.get("id") + .textValue()); + product.setName(productNode.get("name") + .textValue()); + product.setBrandName(productNode.get("brand") + .get("name") + .textValue()); + product.setOwnerName(productNode.get("brand") + .get("owner") + .get("name") + .textValue()); + return product; + } +} diff --git a/javaxval/README.md b/javaxval/README.md index b5001789f1..c6a6eb7345 100644 --- a/javaxval/README.md +++ b/javaxval/README.md @@ -7,3 +7,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Java Bean Validation Basics](http://www.baeldung.com/javax-validation) +- [Validating Container Elements with Bean Validation 2.0](http://www.baeldung.com/bean-validation-container-elements) diff --git a/jhipster/README.md b/jhipster/README.md new file mode 100644 index 0000000000..f3655f8ec1 --- /dev/null +++ b/jhipster/README.md @@ -0,0 +1,4 @@ +## Relevant articles: + +- [JHipster with a Microservice Architecture](http://www.baeldung.com/jhipster-microservices) +- [Intro to JHipster](http://www.baeldung.com/jhipster) diff --git a/jjwt/README.md b/jjwt/README.md index 47b51038a8..54a5226056 100644 --- a/jjwt/README.md +++ b/jjwt/README.md @@ -42,4 +42,8 @@ Available commands (assumes httpie - https://github.com/jkbrzt/httpie): Parse passed in JWT enforcing the 'iss' registered claim and the 'hasMotorcycle' custom claim ``` -The Baeldung post that compliments this repo can be found [here](http://www.baeldung.com/) \ No newline at end of file +The Baeldung post that compliments this repo can be found [here](http://www.baeldung.com/) + +## Relevant articles: + +- [Supercharge Java Authentication with JSON Web Tokens (JWTs)](http://www.baeldung.com/java-json-web-tokens-jjwt) diff --git a/jmh/README.md b/jmh/README.md new file mode 100644 index 0000000000..2a2c6a173a --- /dev/null +++ b/jmh/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Microbenchmarking with Java](http://www.baeldung.com/java-microbenchmark-harness) diff --git a/jooby/README.md b/jooby/README.md new file mode 100644 index 0000000000..032e595354 --- /dev/null +++ b/jooby/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Introduction to Jooby Project](http://www.baeldung.com/jooby) diff --git a/json-path/README.md b/json-path/README.md new file mode 100644 index 0000000000..3563dcf880 --- /dev/null +++ b/json-path/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Introduction to JsonPath](http://www.baeldung.com/guide-to-jayway-jsonpath) diff --git a/libraries-data/README.md b/libraries-data/README.md index ca70c61146..ceb0a1d5f7 100644 --- a/libraries-data/README.md +++ b/libraries-data/README.md @@ -1,2 +1,4 @@ ### Relevant articles - [Introduction to Reladomo](http://www.baeldung.com/reladomo) +- [Introduction to ORMLite](http://www.baeldung.com/ormlite) +- [Introduction To Kryo](http://www.baeldung.com/kryo) diff --git a/libraries-data/src/test/java/com/baeldung/ormlite/ORMLiteTest.java b/libraries-data/src/test/java/com/baeldung/ormlite/ORMLiteTest.java index eaa21b6eaf..26eb481286 100644 --- a/libraries-data/src/test/java/com/baeldung/ormlite/ORMLiteTest.java +++ b/libraries-data/src/test/java/com/baeldung/ormlite/ORMLiteTest.java @@ -76,13 +76,10 @@ public class ORMLiteTest { library2.setName("My Other Library"); libraryDao.create(library2); - CloseableWrappedIterable wrappedIterable = libraryDao.getWrappedIterable(); - try { + try (CloseableWrappedIterable wrappedIterable = libraryDao.getWrappedIterable()) { wrappedIterable.forEach(lib -> { System.out.println(lib.getName()); }); - } finally { - wrappedIterable.close(); } } diff --git a/libraries/README.md b/libraries/README.md index 7214cd278c..c6bbb5634c 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -8,9 +8,9 @@ - [Embedded Jetty Server in Java](http://www.baeldung.com/jetty-embedded) - [Introduction to Apache Flink with Java](http://www.baeldung.com/apache-flink) - [Introduction to JSONassert](http://www.baeldung.com/jsonassert) -- [Intro to JaVer](http://www.baeldung.com/javers) +- [Intro to JaVers](http://www.baeldung.com/javers) - [Introduction to Apache Commons Math](http://www.baeldung.com/apache-commons-math) -- [Intro to JaVer](http://www.baeldung.com/serenity-bdd) +- [Intro to Serenity BDD](http://www.baeldung.com/serenity-bdd) - [Introduction to Netty](http://www.baeldung.com/netty) - [Merging Streams in Java](http://www.baeldung.com/java-merge-streams) - [Serenity BDD and Screenplay](http://www.baeldung.com/serenity-screenplay) @@ -42,6 +42,18 @@ - [Introduction to FunctionalJava](http://www.baeldung.com/functional-java) - [Apache Commons IO](http://www.baeldung.com/apache-commons-io) - [Introduction to Conflict-Free Replicated Data Types](http://www.baeldung.com/java-conflict-free-replicated-data-types) +- [Introduction to javax.measure](http://www.baeldung.com/javax-measure) +- [Spring Yarg Integration](http://www.baeldung.com/spring-yarg) +- [Delete a Directory Recursively in Java](http://www.baeldung.com/java-delete-directory) +- [Guide to JDeferred](http://www.baeldung.com/jdeferred) +- [Integrating Retrofit with RxJava](http://www.baeldung.com/retrofit-rxjava) +- [Introduction to MBassador](http://www.baeldung.com/mbassador) +- [Introduction to JCache](http://www.baeldung.com/jcache) +- [Introduction to Retrofit](http://www.baeldung.com/retrofit) +- [Using Pairs in Java](http://www.baeldung.com/java-pairs) +- [Apache Commons Collections Bag](http://www.baeldung.com/apache-commons-bag) +- [Introduction to Caffeine](http://www.baeldung.com/java-caching-caffeine) ++-[Introduction to Chronicle Queue](http://www.baeldung.com/java-chronicle-queue) The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own. diff --git a/libraries/pom.xml b/libraries/pom.xml index c7c5da95a6..b519b9cd53 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -575,22 +575,6 @@ hazelcast ${hazelcast.version}
    - - com.atlassian.jira - jira-rest-java-client-core - 4.0.0 - - - com.atlassian.fugue - fugue - 2.6.1 - - - org.jgrapht jgrapht-core @@ -606,11 +590,16 @@ docx4j 3.3.5 - - javax.xml.bind - jaxb-api - 2.1 - + + javax.xml.bind + jaxb-api + 2.1 + + + com.github.ben-manes.caffeine + caffeine + ${caffeine.version} +
    @@ -626,10 +615,6 @@ bintray http://dl.bintray.com/cuba-platform/main - - atlassian-public - https://packages.atlassian.com/maven/repository/public - 0.1.0 @@ -686,5 +671,6 @@ 1.0.3 1.0.0 3.8.4 + 2.5.5 diff --git a/libraries/src/main/java/com/baeldung/caffeine/DataObject.java b/libraries/src/main/java/com/baeldung/caffeine/DataObject.java new file mode 100644 index 0000000000..a90b3e9f21 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/caffeine/DataObject.java @@ -0,0 +1,32 @@ +package com.baeldung.caffeine; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +final class DataObject { + private final String data; + + private static int objectCounter = 0; + private static final Logger log = LoggerFactory.getLogger(DataObject.class); + + private DataObject(String data) { + this.data = data; + } + + public String getData() { + return data; + } + + @Override + public String toString() { + return "DataObject{" + + "data='" + data + '\'' + + '}'; + } + + public static DataObject get(String data) { + objectCounter++; + log.info("Init DataObject#{} with '{}'", objectCounter, data); + return new DataObject(data); + } +} diff --git a/libraries/src/main/java/com/baeldung/streamex/Role.java b/libraries/src/main/java/com/baeldung/streamex/Role.java new file mode 100644 index 0000000000..5709ca61f8 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/streamex/Role.java @@ -0,0 +1,5 @@ +package com.baeldung.streamex; + +public class Role { + +} diff --git a/libraries/src/main/java/com/baeldung/streamex/StreamEX.java b/libraries/src/main/java/com/baeldung/streamex/StreamEX.java new file mode 100644 index 0000000000..7cbfec4421 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/streamex/StreamEX.java @@ -0,0 +1,84 @@ +package com.baeldung.streamex; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import one.util.streamex.DoubleStreamEx; +import one.util.streamex.EntryStream; +import one.util.streamex.IntStreamEx; +import one.util.streamex.StreamEx; + +public class StreamEX { + + public static void main(String[] args) { + //Collector shortcut methods (toList, toSet, groupingBy, joining, etc.) + List users = Arrays.asList( + new User("name"), new User(), new User()); + users.stream() + .map(User::getName) + .collect(Collectors.toList()); + List userNames = StreamEx.of(users) + .map(User::getName) + .toList(); + Map> role2users = StreamEx.of(users) + .groupingBy(User::getRole); + StreamEx.of(1, 2, 3).joining("; "); // "1; 2; 3" + //Selecting stream elements of specific type + List usersAndRoles = Arrays.asList(new User(), new Role()); + List roles = IntStreamEx.range(usersAndRoles.size()) + .mapToObj(usersAndRoles::get) + .select(Role.class) + .toList(); + System.out.println(roles); + //adding elements to Stream + List appendedUsers = StreamEx.of(users) + .map(User::getName) + .prepend("(none)") + .append("LAST") + .toList(); + System.out.println(appendedUsers); + //Removing unwanted elements and using the stream as Iterable: + for (String line : StreamEx.of(users).map(User::getName) + .nonNull()) { + System.out.println(line); + } + //Selecting map keys by value predicate: + Map nameToRole = new HashMap<>(); + nameToRole.put("first", new Role()); + nameToRole.put("second", null); + Set nonNullRoles = StreamEx. + ofKeys(nameToRole, Objects::nonNull) + .toSet(); + System.out.println(nonNullRoles); + //Operating on key-value pairs: + Map> users2roles = transformMap(role2users); + Map mapToString = EntryStream.of(users2roles) + .mapKeys(String::valueOf) + .mapValues(String::valueOf) + .toMap(); + //Support of byte/char/short/float types: + short[] src = {1, 2, 3}; + char[] output = IntStreamEx.of(src) + .map(x -> x * 5) + .toCharArray(); + } + + public double[] getDiffBetweenPairs(double... numbers) { + return DoubleStreamEx.of(numbers) + .pairMap((a, b) -> b - a).toArray(); + } + + public static Map> transformMap( + Map> role2users) { + Map> users2roles = EntryStream.of(role2users) + .flatMapValues(List::stream) + .invert() + .grouping(); + return users2roles; + } + +} diff --git a/libraries/src/main/java/com/baeldung/streamex/User.java b/libraries/src/main/java/com/baeldung/streamex/User.java new file mode 100644 index 0000000000..e37eb014c5 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/streamex/User.java @@ -0,0 +1,40 @@ +package com.baeldung.streamex; + +public class User { + + int id; + String name; + Role role = new Role(); + + public User() { + } + + public User(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } + +} diff --git a/libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java b/libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java new file mode 100644 index 0000000000..56dbda5974 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java @@ -0,0 +1,174 @@ +package com.baeldung.caffeine; + +import static org.junit.Assert.*; + +import java.util.Arrays; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import javax.annotation.Nonnull; + +import org.junit.Test; + +import com.github.benmanes.caffeine.cache.*; + +public class CaffeineUnitTest { + + @Test + public void givenCache_whenPopulate_thenValueStored() { + Cache cache = Caffeine.newBuilder() + .expireAfterWrite(1, TimeUnit.MINUTES) + .maximumSize(100) + .build(); + + String key = "A"; + DataObject dataObject = cache.getIfPresent(key); + + assertNull(dataObject); + + dataObject = cache.get(key, k -> DataObject.get("Data for A")); + + assertNotNull(dataObject); + assertEquals("Data for A", dataObject.getData()); + + cache.put(key, dataObject); + dataObject = cache.getIfPresent(key); + + assertNotNull(dataObject); + + cache.invalidate(key); + dataObject = cache.getIfPresent(key); + + assertNull(dataObject); + } + + @Test + public void givenLoadingCache_whenGet_thenValuePopulated() { + LoadingCache cache = Caffeine.newBuilder() + .maximumSize(100) + .expireAfterWrite(1, TimeUnit.MINUTES) + .build(k -> DataObject.get("Data for " + k)); + String key = "A"; + + DataObject dataObject = cache.get(key); + + assertNotNull(dataObject); + assertEquals("Data for " + key, dataObject.getData()); + + Map dataObjectMap = cache.getAll(Arrays.asList("A", "B", "C")); + + assertEquals(3, dataObjectMap.size()); + } + + @Test + public void givenAsyncLoadingCache_whenGet_thenValuePopulated() { + + AsyncLoadingCache cache = Caffeine.newBuilder() + .maximumSize(100) + .expireAfterWrite(1, TimeUnit.MINUTES) + .buildAsync(k -> DataObject.get("Data for " + k)); + String key = "A"; + + cache.get(key).thenAccept(dataObject -> { + assertNotNull(dataObject); + assertEquals("Data for " + key, dataObject.getData()); + }); + + cache.getAll(Arrays.asList("A", "B", "C")) + .thenAccept(dataObjectMap -> assertEquals(3, dataObjectMap.size())); + } + + @Test + public void givenLoadingCacheWithSmallSize_whenPut_thenSizeIsConstant() { + LoadingCache cache = Caffeine.newBuilder() + .maximumSize(1) + .refreshAfterWrite(10, TimeUnit.MINUTES) + .build(k -> DataObject.get("Data for " + k)); + + assertEquals(0, cache.estimatedSize()); + + cache.get("A"); + + assertEquals(1, cache.estimatedSize()); + + cache.get("B"); + cache.cleanUp(); + + assertEquals(1, cache.estimatedSize()); + } + + @Test + public void givenLoadingCacheWithWeigher_whenPut_thenSizeIsConstant() { + LoadingCache cache = Caffeine.newBuilder() + .maximumWeight(10) + .weigher((k,v) -> 5) + .build(k -> DataObject.get("Data for " + k)); + + assertEquals(0, cache.estimatedSize()); + + cache.get("A"); + + assertEquals(1, cache.estimatedSize()); + + cache.get("B"); + + assertEquals(2, cache.estimatedSize()); + + cache.get("C"); + cache.cleanUp(); + + assertEquals(2, cache.estimatedSize()); + } + + @Test + public void givenTimeEvictionCache_whenTimeLeft_thenValueEvicted() { + LoadingCache cache = Caffeine.newBuilder() + .expireAfterAccess(5, TimeUnit.MINUTES) + .build(k -> DataObject.get("Data for " + k)); + + cache = Caffeine.newBuilder() + .expireAfterWrite(10, TimeUnit.SECONDS) + .weakKeys() + .weakValues() + .build(k -> DataObject.get("Data for " + k)); + + cache = Caffeine.newBuilder() + .expireAfterWrite(10, TimeUnit.SECONDS) + .softValues() + .build(k -> DataObject.get("Data for " + k)); + + cache = Caffeine.newBuilder().expireAfter(new Expiry() { + @Override + public long expireAfterCreate(@Nonnull String key, @Nonnull DataObject value, long currentTime) { + return value.getData().length() * 1000; + } + + @Override + public long expireAfterUpdate(@Nonnull String key, @Nonnull DataObject value, long currentTime, long currentDuration) { + return currentDuration; + } + + @Override + public long expireAfterRead(@Nonnull String key, @Nonnull DataObject value, long currentTime, long currentDuration) { + return currentDuration; + } + }).build(k -> DataObject.get("Data for " + k)); + + cache = Caffeine.newBuilder() + .refreshAfterWrite(1, TimeUnit.MINUTES) + .build(k -> DataObject.get("Data for " + k)); + } + + @Test + public void givenCache_whenStatsEnabled_thenStatsRecorded() { + LoadingCache cache = Caffeine.newBuilder() + .maximumSize(100) + .recordStats() + .build(k -> DataObject.get("Data for " + k)); + cache.get("A"); + cache.get("A"); + + assertEquals(1, cache.stats().hitCount()); + assertEquals(1, cache.stats().missCount()); + } +} \ No newline at end of file diff --git a/linkrest/README.md b/linkrest/README.md new file mode 100644 index 0000000000..33cf930b18 --- /dev/null +++ b/linkrest/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Guide to LinkRest](http://www.baeldung.com/linkrest) diff --git a/metrics/pom.xml b/metrics/pom.xml index 574c1ac132..25ce452d7a 100644 --- a/metrics/pom.xml +++ b/metrics/pom.xml @@ -16,6 +16,8 @@ 3.1.2 3.1.0 0.12.17 + 0.12.0.RELEASE + 2.0.0.M5 @@ -57,12 +59,64 @@ ${netflix.servo.ver} test + + + io.micrometer + micrometer-registry-atlas + ${micrometer.ver} + + + + io.micrometer + micrometer-spring-legacy + ${micrometer.ver} + + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.ver} + + + + com.fasterxml.jackson.core + jackson-databind + 2.9.1 + com.fasterxml.jackson.dataformat jackson-dataformat-smile - 2.8.9 - test + 2.9.1 + + + + com.netflix.spectator + spectator-api + 0.57.1 + + + + org.springframework.boot + spring-boot-dependencies + pom + import + ${spring.boot.ver} + + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/libs-milestone + + false + + + + diff --git a/metrics/src/main/java/com/baeldung/metrics/micrometer/MicrometerApp.java b/metrics/src/main/java/com/baeldung/metrics/micrometer/MicrometerApp.java new file mode 100644 index 0000000000..cf818f6600 --- /dev/null +++ b/metrics/src/main/java/com/baeldung/metrics/micrometer/MicrometerApp.java @@ -0,0 +1,20 @@ +package com.baeldung.metrics.micrometer; + +import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class MicrometerApp { + + @Bean + JvmThreadMetrics threadMetrics() { + return new JvmThreadMetrics(); + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(MicrometerApp.class, args); + } + +} diff --git a/metrics/src/main/java/com/baeldung/metrics/micrometer/PeopleController.java b/metrics/src/main/java/com/baeldung/metrics/micrometer/PeopleController.java new file mode 100644 index 0000000000..789e975a7f --- /dev/null +++ b/metrics/src/main/java/com/baeldung/metrics/micrometer/PeopleController.java @@ -0,0 +1,54 @@ +package com.baeldung.metrics.micrometer; + +import io.micrometer.core.annotation.Timed; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.security.SecureRandom; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * @author aiet + */ +@RestController +@Timed("people") +public class PeopleController { + + private static final SecureRandom SECURE_RANDOM = new SecureRandom(); + + @GetMapping("/people") + @Timed(value = "people.all", longTask = true) + public List listPeople() throws InterruptedException { + int seconds2Sleep = SECURE_RANDOM.nextInt(500); + System.out.println(seconds2Sleep); + TimeUnit.MILLISECONDS.sleep(seconds2Sleep); + return Arrays.asList("Jim", "Tom", "Tim"); + } + + @PostMapping("/people") + @Timed(value = "people.update", longTask = true) + public List putPeople() throws InterruptedException { + int seconds2Sleep = SECURE_RANDOM.nextInt(1000); + System.out.println(seconds2Sleep); + TimeUnit.MILLISECONDS.sleep(seconds2Sleep); + return Arrays.asList("Jim", "Tom", "Tim"); + } + + @GetMapping("/asset") + @Timed(value = "people.asset", longTask = true) + public void test() throws Exception { + throw new Exception("error!"); + } + + @GetMapping("/property") + @Timed(value = "people.property", longTask = true) + public void property(HttpServletResponse response) throws IOException { + response.sendRedirect("/asset"); + } + +} diff --git a/metrics/src/test/java/com/baeldung/metrics/micrometer/MicrometerAtlasTest.java b/metrics/src/test/java/com/baeldung/metrics/micrometer/MicrometerAtlasTest.java new file mode 100644 index 0000000000..826e06d598 --- /dev/null +++ b/metrics/src/test/java/com/baeldung/metrics/micrometer/MicrometerAtlasTest.java @@ -0,0 +1,275 @@ +package com.baeldung.metrics.micrometer; + +import com.netflix.spectator.atlas.AtlasConfig; +import io.micrometer.atlas.AtlasMeterRegistry; +import io.micrometer.core.instrument.*; +import io.micrometer.core.instrument.Timer; +import io.micrometer.core.instrument.composite.CompositeMeterRegistry; +import io.micrometer.core.instrument.simple.SimpleMeterRegistry; +import io.micrometer.core.instrument.stats.hist.Histogram; +import io.micrometer.core.instrument.stats.quantile.WindowSketchQuantiles; +import org.junit.Before; +import org.junit.Test; + +import java.time.Duration; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import static io.micrometer.core.instrument.Meter.Type; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.collection.IsMapContaining.hasEntry; +import static org.hamcrest.core.IsCollectionContaining.hasItems; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +/** + * @author aiet + */ +public class MicrometerAtlasTest { + + private AtlasConfig atlasConfig; + + @Before + public void init() { + atlasConfig = new AtlasConfig() { + + @Override + public Duration step() { + return Duration.ofSeconds(1); + } + + @Override + public String get(String k) { + return null; + } + }; + } + + @Test + public void givenCompositeRegistries_whenRecordMeter_thenAllRegistriesRecorded() { + CompositeMeterRegistry compositeRegistry = new CompositeMeterRegistry(); + + SimpleMeterRegistry oneSimpleMeter = new SimpleMeterRegistry(); + AtlasMeterRegistry atlasMeterRegistry = new AtlasMeterRegistry(atlasConfig, Clock.SYSTEM); + + compositeRegistry.add(oneSimpleMeter); + compositeRegistry.add(atlasMeterRegistry); + + compositeRegistry.gauge("baeldung.heat", 90); + + Optional oneGauge = oneSimpleMeter + .find("baeldung.heat") + .gauge(); + assertTrue(oneGauge.isPresent()); + Iterator measurements = oneGauge + .get() + .measure() + .iterator(); + + assertTrue(measurements.hasNext()); + assertThat(measurements + .next() + .getValue(), equalTo(90.00)); + + Optional atlasGauge = atlasMeterRegistry + .find("baeldung.heat") + .gauge(); + assertTrue(atlasGauge.isPresent()); + Iterator anotherMeasurements = atlasGauge + .get() + .measure() + .iterator(); + + assertTrue(anotherMeasurements.hasNext()); + assertThat(anotherMeasurements + .next() + .getValue(), equalTo(90.00)); + } + + @Test + public void givenGlobalRegistry_whenIncrementAnywhere_thenCounted() { + class CountedObject { + private CountedObject() { + Metrics + .counter("objects.instance") + .increment(1.0); + } + } + Metrics.addRegistry(new SimpleMeterRegistry()); + + Metrics + .counter("objects.instance") + .increment(); + new CountedObject(); + + Optional counterOptional = Metrics.globalRegistry + .find("objects.instance") + .counter(); + + assertTrue(counterOptional.isPresent()); + assertTrue(counterOptional + .get() + .count() == 2.0); + } + + @Test + public void givenCounter_whenIncrement_thenValueChanged() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + Counter counter = Counter + .builder("objects.instance") + .description("indicates instance count of the object") + .tags("dev", "performance") + .register(registry); + + counter.increment(2.0); + assertTrue(counter.count() == 2); + + counter.increment(-1); + assertTrue(counter.count() == 2); + } + + @Test + public void givenTimer_whenWrapTasks_thenTimeRecorded() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + Timer timer = registry.timer("app.event"); + timer.record(() -> { + try { + TimeUnit.MILLISECONDS.sleep(1500); + } catch (InterruptedException ignored) { + } + }); + + timer.record(3000, TimeUnit.MILLISECONDS); + + assertTrue(2 == timer.count()); + assertTrue(4510 > timer.totalTime(TimeUnit.MILLISECONDS) && 4500 <= timer.totalTime(TimeUnit.MILLISECONDS)); + } + + @Test + public void givenLongTimer_whenRunTasks_thenTimerRecorded() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + LongTaskTimer longTaskTimer = LongTaskTimer + .builder("3rdPartyService") + .register(registry); + + long currentTaskId = longTaskTimer.start(); + try { + TimeUnit.SECONDS.sleep(2); + } catch (InterruptedException ignored) { + } + long timeElapsed = longTaskTimer.stop(currentTaskId); + + assertTrue(timeElapsed / (int) 1e9 == 2); + } + + @Test + public void givenGauge_whenMeterListSize_thenCurrentSizeMonitored() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + List list = new ArrayList<>(4); + Gauge gauge = Gauge + .builder("cache.size", list, List::size) + .register(registry); + + assertTrue(gauge.value() == 0.0); + + list.add("1"); + assertTrue(gauge.value() == 1.0); + } + + @Test + public void givenDistributionSummary_whenRecord_thenSummarized() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + DistributionSummary distributionSummary = DistributionSummary + .builder("request.size") + .baseUnit("bytes") + .register(registry); + distributionSummary.record(3); + distributionSummary.record(4); + distributionSummary.record(5); + + assertTrue(3 == distributionSummary.count()); + assertTrue(12 == distributionSummary.totalAmount()); + } + + @Test + public void givenTimer_whenEnrichWithQuantile_thenQuantilesComputed() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + Timer timer = Timer + .builder("test.timer") + .quantiles(WindowSketchQuantiles + .quantiles(0.3, 0.5, 0.95) + .create()) + .register(registry); + + timer.record(2, TimeUnit.SECONDS); + timer.record(2, TimeUnit.SECONDS); + timer.record(3, TimeUnit.SECONDS); + timer.record(4, TimeUnit.SECONDS); + timer.record(8, TimeUnit.SECONDS); + timer.record(13, TimeUnit.SECONDS); + + Map quantileMap = extractTagValueMap(registry, Type.Gauge, 1e9); + assertThat(quantileMap, allOf(hasEntry("quantile=0.3", 2), hasEntry("quantile=0.5", 3), hasEntry("quantile=0.95", 8))); + } + + private Map extractTagValueMap(MeterRegistry registry, Type meterType, double valueDivisor) { + return registry + .getMeters() + .stream() + .filter(meter -> meter.getType() == meterType) + .collect(Collectors.toMap(meter -> { + Tag tag = meter + .getId() + .getTags() + .iterator() + .next(); + return tag.getKey() + "=" + tag.getValue(); + }, meter -> (int) (meter + .measure() + .iterator() + .next() + .getValue() / valueDivisor))); + } + + @Test + public void givenDistributionSummary_whenEnrichWithHistograms_thenDataAggregated() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + DistributionSummary hist = DistributionSummary + .builder("summary") + .histogram(Histogram.linear(0, 10, 5)) + .register(registry); + + hist.record(3); + hist.record(8); + hist.record(20); + hist.record(40); + hist.record(13); + hist.record(26); + + Map histograms = extractTagValueMap(registry, Type.Counter, 1.0); + + assertThat(histograms, allOf(hasEntry("bucket=0.0", 0), hasEntry("bucket=10.0", 2), hasEntry("bucket=20.0", 2), hasEntry("bucket=30.0", 1), hasEntry("bucket=40.0", 1), hasEntry("bucket=Infinity", 0))); + } + + @Test + public void givenTimer_whenEnrichWithTimescaleHistogram_thenTimeScaleDataCollected() { + SimpleMeterRegistry registry = new SimpleMeterRegistry(); + Timer timer = Timer + .builder("timer") + .histogram(Histogram.linearTime(TimeUnit.MILLISECONDS, 0, 200, 3)) + .register(registry); + + timer.record(1000, TimeUnit.MILLISECONDS); + timer.record(23, TimeUnit.MILLISECONDS); + timer.record(450, TimeUnit.MILLISECONDS); + timer.record(341, TimeUnit.MILLISECONDS); + timer.record(500, TimeUnit.MILLISECONDS); + + Map histograms = extractTagValueMap(registry, Type.Counter, 1.0); + + assertThat(histograms, allOf(hasEntry("bucket=0.0", 0), hasEntry("bucket=2.0E8", 1), hasEntry("bucket=4.0E8", 1), hasEntry("bucket=Infinity", 3))); + + } + +} diff --git a/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java b/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java new file mode 100644 index 0000000000..cfe406c112 --- /dev/null +++ b/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGenerator.java @@ -0,0 +1,28 @@ +package com.baeldung.powermockito.introduction; + +class LuckyNumberGenerator { + + public int getLuckyNumber(String name) { + + saveIntoDatabase(name); + + if (name == null) { + return getDefaultLuckyNumber(); + } + + return getComputedLuckyNumber(name.length()); + } + + private void saveIntoDatabase(String name) { + // Save the name into the database + } + + private int getDefaultLuckyNumber() { + return 100; + } + + private int getComputedLuckyNumber(int length) { + return length < 5 ? 5 : 10000; + } + +} diff --git a/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorTest.java b/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorTest.java new file mode 100644 index 0000000000..2836bcd317 --- /dev/null +++ b/mockito/src/test/java/com/baeldung/powermockito/introduction/LuckyNumberGeneratorTest.java @@ -0,0 +1,51 @@ +package com.baeldung.powermockito.introduction; + +import static org.junit.Assert.assertEquals; +import static org.powermock.api.mockito.PowerMockito.doReturn; +import static org.powermock.api.mockito.PowerMockito.spy; +import static org.powermock.api.mockito.PowerMockito.verifyPrivate; +import static org.powermock.api.mockito.PowerMockito.when; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(fullyQualifiedNames = "com.baeldung.powermockito.introduction.LuckyNumberGenerator") +public class LuckyNumberGeneratorTest { + + @Test + public final void givenPrivateMethodWithReturn_whenUsingPowerMockito_thenCorrect() throws Exception { + LuckyNumberGenerator mock = spy(new LuckyNumberGenerator()); + + when(mock, "getDefaultLuckyNumber").thenReturn(300); + + int result = mock.getLuckyNumber(null); + + assertEquals(300, result); + } + + @Test + public final void givenPrivateMethodWithArgumentAndReturn_whenUsingPowerMockito_thenCorrect() throws Exception { + LuckyNumberGenerator mock = spy(new LuckyNumberGenerator()); + + doReturn(1).when(mock, "getComputedLuckyNumber", ArgumentMatchers.anyInt()); + + int result = mock.getLuckyNumber("Jack"); + + assertEquals(1, result); + } + + @Test + public final void givenPrivateMethodWithNoArgumentAndReturn_whenUsingPowerMockito_thenCorrect() throws Exception { + LuckyNumberGenerator mock = spy(new LuckyNumberGenerator()); + + int result = mock.getLuckyNumber("Tyranosorous"); + + verifyPrivate(mock).invoke("saveIntoDatabase", ArgumentMatchers.anyString()); + assertEquals(10000, result); + } + +} diff --git a/mocks/README.md b/mocks/README.md new file mode 100644 index 0000000000..15370b812b --- /dev/null +++ b/mocks/README.md @@ -0,0 +1,7 @@ +## Relevant articles: + +- [Introduction to MockServer](http://www.baeldung.com/mockserver) +- [JMockit Advanced Usage](http://www.baeldung.com/jmockit-advanced-usage) +- [A Guide to JMockit Expectations](http://www.baeldung.com/jmockit-expectations) +- [JMockit 101](http://www.baeldung.com/jmockit-101) +- [Mockito vs EasyMock vs JMockit](http://www.baeldung.com/mockito-vs-easymock-vs-jmockit) diff --git a/mockserver/README.md b/mockserver/README.md new file mode 100644 index 0000000000..a8bc5cfc98 --- /dev/null +++ b/mockserver/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Introduction to MockServer](http://www.baeldung.com/mockserver) diff --git a/mustache/README.md b/mustache/README.md index b616b2df8a..fa41eb4f4d 100644 --- a/mustache/README.md +++ b/mustache/README.md @@ -1,2 +1,3 @@ ### Relevant Articles: -[Introduction to Mustache](http://www.baeldung.com/mustache) +- [Introduction to Mustache](http://www.baeldung.com/mustache) +- [Guide to Mustache with Spring Boot](http://www.baeldung.com/spring-boot-mustache) diff --git a/parent-boot-4/README.md b/parent-boot-4/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/parent-boot-4/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/parent-boot-5/README.md b/parent-boot-5/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/parent-boot-5/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/pom.xml b/pom.xml index c3915e4fce..3d28707b5f 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ + asm atomix apache-cayenne aws @@ -48,6 +49,8 @@ core-java-8 core-java-concurrency couchbase + cas-server + cas-secured-app deltaspike dozer @@ -248,6 +251,7 @@ mockserver undertow vertx-and-rxjava + saas deeplearning4j diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java index 13ba3ccac9..1b691414db 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java @@ -1,55 +1,53 @@ package com.baeldung.restassured; +import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static io.restassured.RestAssured.get; import static org.hamcrest.Matchers.hasItems; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static io.restassured.RestAssured.get; - -import com.github.tomakehurst.wiremock.WireMockServer; - public class RestAssured2IntegrationTest { - private WireMockServer wireMockServer = new WireMockServer(); + private static final int PORT = 8084; + private static WireMockServer wireMockServer = new WireMockServer(PORT); - private static final String EVENTS_PATH = "/odds"; - private static final String APPLICATION_JSON = "application/json"; - private static final String ODDS = getJson(); + private static final String EVENTS_PATH = "/odds"; + private static final String APPLICATION_JSON = "application/json"; + private static final String ODDS = getJson(); - @Before - public void before() throws Exception { - System.out.println("Setting up!"); - wireMockServer.start(); - configureFor("localhost", 8080); - stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( - aResponse().withStatus(200) - .withHeader("Content-Type", APPLICATION_JSON) - .withBody(ODDS))); - } + @BeforeClass + public static void before() throws Exception { + System.out.println("Setting up!"); + wireMockServer.start(); + configureFor("localhost", PORT); + RestAssured.port = PORT; + stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( + aResponse().withStatus(200) + .withHeader("Content-Type", APPLICATION_JSON) + .withBody(ODDS))); + } - @Test - public void givenUrl_whenVerifiesOddPricesAccuratelyByStatus_thenCorrect() { - get("/odds").then().body("odds.findAll { it.status > 0 }.price", - hasItems(5.25f, 1.2f)); - } + @Test + public void givenUrl_whenVerifiesOddPricesAccuratelyByStatus_thenCorrect() { + get("/odds").then().body("odds.findAll { it.status > 0 }.price", + hasItems(5.25f, 1.2f)); + } - private static String getJson() { - - return Util.inputStreamToString(new RestAssured2IntegrationTest().getClass() - .getResourceAsStream("/odds.json")); - - } - - @After - public void after() throws Exception { - System.out.println("Running: tearDown"); - wireMockServer.stop(); - } + private static String getJson() { + return Util.inputStreamToString(RestAssured2IntegrationTest.class + .getResourceAsStream("/odds.json")); + } + @AfterClass + public static void after() throws Exception { + System.out.println("Running: tearDown"); + wireMockServer.stop(); + } } diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java index f14d9920b6..4ad3cea22c 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java @@ -1,5 +1,14 @@ package com.baeldung.restassured; +import com.github.fge.jsonschema.SchemaVersion; +import com.github.fge.jsonschema.cfg.ValidationConfiguration; +import com.github.fge.jsonschema.main.JsonSchemaFactory; +import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; import static com.github.tomakehurst.wiremock.client.WireMock.get; @@ -11,96 +20,86 @@ import static io.restassured.module.jsv.JsonSchemaValidatorSettings.settings; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItems; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.github.fge.jsonschema.SchemaVersion; -import com.github.fge.jsonschema.cfg.ValidationConfiguration; -import com.github.fge.jsonschema.main.JsonSchemaFactory; -import com.github.tomakehurst.wiremock.WireMockServer; - public class RestAssuredIntegrationTest { + private static final int PORT = 8083; + private static WireMockServer wireMockServer = new WireMockServer(PORT); - private WireMockServer wireMockServer = new WireMockServer(); - private static final String EVENTS_PATH = "/events?id=390"; - private static final String APPLICATION_JSON = "application/json"; - private static final String GAME_ODDS = getEventJson(); + private static final String EVENTS_PATH = "/events?id=390"; + private static final String APPLICATION_JSON = "application/json"; + private static final String GAME_ODDS = getEventJson(); - @Before - public void before() throws Exception { - System.out.println("Setting up!"); - wireMockServer.start(); - configureFor("localhost", 8080); - stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( - aResponse().withStatus(200) - .withHeader("Content-Type", APPLICATION_JSON) - .withBody(GAME_ODDS))); - } + @BeforeClass + public static void before() throws Exception { + System.out.println("Setting up!"); + wireMockServer.start(); + RestAssured.port = PORT; + configureFor("localhost", PORT); + stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( + aResponse().withStatus(200) + .withHeader("Content-Type", APPLICATION_JSON) + .withBody(GAME_ODDS))); + } - @Test - public void givenUrl_whenCheckingFloatValuePasses_thenCorrect() { - get("/events?id=390").then().assertThat() - .body("odd.ck", equalTo(12.2f)); - } + @Test + public void givenUrl_whenCheckingFloatValuePasses_thenCorrect() { + get("/events?id=390").then().assertThat() + .body("odd.ck", equalTo(12.2f)); + } - @Test - public void givenUrl_whenSuccessOnGetsResponseAndJsonHasRequiredKV_thenCorrect() { + @Test + public void givenUrl_whenSuccessOnGetsResponseAndJsonHasRequiredKV_thenCorrect() { - get("/events?id=390").then().statusCode(200).assertThat() - .body("id", equalTo("390")); + get("/events?id=390").then().statusCode(200).assertThat() + .body("id", equalTo("390")); + } - } + @Test + public void givenUrl_whenJsonResponseHasArrayWithGivenValuesUnderKey_thenCorrect() { + get("/events?id=390").then().assertThat() + .body("odds.price", hasItems("1.30", "5.25", "2.70", "1.20")); + } - @Test - public void givenUrl_whenJsonResponseHasArrayWithGivenValuesUnderKey_thenCorrect() { - get("/events?id=390").then().assertThat() - .body("odds.price", hasItems("1.30", "5.25", "2.70", "1.20")); - } + @Test + public void givenUrl_whenJsonResponseConformsToSchema_thenCorrect() { - @Test - public void givenUrl_whenJsonResponseConformsToSchema_thenCorrect() { + get("/events?id=390").then().assertThat() + .body(matchesJsonSchemaInClasspath("event_0.json")); + } - get("/events?id=390").then().assertThat() - .body(matchesJsonSchemaInClasspath("event_0.json")); - } + @Test + public void givenUrl_whenValidatesResponseWithInstanceSettings_thenCorrect() { + JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory + .newBuilder() + .setValidationConfiguration( + ValidationConfiguration.newBuilder() + .setDefaultVersion(SchemaVersion.DRAFTV4) + .freeze()).freeze(); - @Test - public void givenUrl_whenValidatesResponseWithInstanceSettings_thenCorrect() { - JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory - .newBuilder() - .setValidationConfiguration( - ValidationConfiguration.newBuilder() - .setDefaultVersion(SchemaVersion.DRAFTV4) - .freeze()).freeze(); + get("/events?id=390") + .then() + .assertThat() + .body(matchesJsonSchemaInClasspath("event_0.json").using( + jsonSchemaFactory)); + } - get("/events?id=390") - .then() - .assertThat() - .body(matchesJsonSchemaInClasspath("event_0.json").using( - jsonSchemaFactory)); + @Test + public void givenUrl_whenValidatesResponseWithStaticSettings_thenCorrect() { - } + get("/events?id=390") + .then() + .assertThat() + .body(matchesJsonSchemaInClasspath("event_0.json").using( + settings().with().checkedValidation(false))); + } - @Test - public void givenUrl_whenValidatesResponseWithStaticSettings_thenCorrect() { - - get("/events?id=390") - .then() - .assertThat() - .body(matchesJsonSchemaInClasspath("event_0.json").using( - settings().with().checkedValidation(false))); - } - - @After - public void after() throws Exception { - System.out.println("Running: tearDown"); - wireMockServer.stop(); - } - - private static String getEventJson() { - return Util.inputStreamToString(RestAssuredIntegrationTest.class - .getResourceAsStream("/event_0.json")); - } + @AfterClass + public static void after() throws Exception { + System.out.println("Running: tearDown"); + wireMockServer.stop(); + } + private static String getEventJson() { + return Util.inputStreamToString(RestAssuredIntegrationTest.class + .getResourceAsStream("/event_0.json")); + } } diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java index b77f24b15f..4a29d8832f 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java @@ -1,54 +1,55 @@ package com.baeldung.restassured; +import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static io.restassured.RestAssured.get; import static org.hamcrest.Matchers.hasItems; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static io.restassured.RestAssured.get; - -import com.github.tomakehurst.wiremock.WireMockServer; - public class RestAssuredXML2IntegrationTest { - private WireMockServer wireMockServer = new WireMockServer(); + private static final int PORT = 8082; + private static WireMockServer wireMockServer = new WireMockServer(PORT); - private static final String EVENTS_PATH = "/teachers"; - private static final String APPLICATION_XML = "application/xml"; - private static final String TEACHERS = getXml(); + private static final String EVENTS_PATH = "/teachers"; + private static final String APPLICATION_XML = "application/xml"; + private static final String TEACHERS = getXml(); - @Before - public void before() throws Exception { - System.out.println("Setting up!"); - wireMockServer.start(); - configureFor("localhost", 8080); - stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( - aResponse().withStatus(200) - .withHeader("Content-Type", APPLICATION_XML) - .withBody(TEACHERS))); - } - @Test - public void givenUrl_whenVerifiesScienceTeacherFromXml_thenCorrect() { - get("/teachers") - .then() - .body("teachers.teacher.find { it.@department == 'science' }.subject", - hasItems("math", "physics")); - } - private static String getXml() { - - return Util - .inputStreamToString(new RestAssuredXML2IntegrationTest().getClass().getResourceAsStream("/teachers.xml")); - -} - @After -public void after() throws Exception { - System.out.println("Running: tearDown"); - wireMockServer.stop(); -} + @BeforeClass + public static void before() throws Exception { + System.out.println("Setting up!"); + wireMockServer.start(); + RestAssured.port = PORT; + configureFor("localhost", PORT); + stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( + aResponse().withStatus(200) + .withHeader("Content-Type", APPLICATION_XML) + .withBody(TEACHERS))); + } + @Test + public void givenUrl_whenVerifiesScienceTeacherFromXml_thenCorrect() { + get("/teachers") + .then() + .body("teachers.teacher.find { it.@department == 'science' }.subject", + hasItems("math", "physics")); + } + + private static String getXml() { + return Util.inputStreamToString(RestAssuredXML2IntegrationTest.class + .getResourceAsStream("/teachers.xml")); + } + + @AfterClass + public static void after() throws Exception { + System.out.println("Running: tearDown"); + wireMockServer.stop(); + } } diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java index 10aef63cdb..f1a22831f4 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java @@ -1,99 +1,90 @@ package com.baeldung.restassured; +import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.configureFor; -import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.post; import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static io.restassured.RestAssured.post; -import static io.restassured.RestAssured.get; -import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; -import static io.restassured.module.jsv.JsonSchemaValidatorSettings.settings; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.xml.HasXPath.hasXPath; -import java.io.FileNotFoundException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.github.fge.jsonschema.SchemaVersion; -import com.github.fge.jsonschema.cfg.ValidationConfiguration; -import com.github.fge.jsonschema.main.JsonSchemaFactory; -import com.github.tomakehurst.wiremock.WireMockServer; public class RestAssuredXMLIntegrationTest { - private WireMockServer wireMockServer = new WireMockServer(); - private static final String EVENTS_PATH = "/employees"; - private static final String APPLICATION_XML = "application/xml"; - private static final String EMPLOYEES = getXml(); + private static final int PORT = 8081; + private static WireMockServer wireMockServer = new WireMockServer(PORT); - @Before - public void before() throws Exception { - System.out.println("Setting up!"); - wireMockServer.start(); - configureFor("localhost", 8080); - stubFor(post(urlEqualTo(EVENTS_PATH)).willReturn( - aResponse().withStatus(200) - .withHeader("Content-Type", APPLICATION_XML) - .withBody(EMPLOYEES))); - } - @Test - public void givenUrl_whenXmlResponseValueTestsEqual_thenCorrect() { - post("/employees").then().assertThat() - .body("employees.employee.first-name", equalTo("Jane")); - } + private static final String EVENTS_PATH = "/employees"; + private static final String APPLICATION_XML = "application/xml"; + private static final String EMPLOYEES = getXml(); - @Test - public void givenUrl_whenMultipleXmlValuesTestEqual_thenCorrect() { - post("/employees").then().assertThat() - .body("employees.employee.first-name", equalTo("Jane")) - .body("employees.employee.last-name", equalTo("Daisy")) - .body("employees.employee.sex", equalTo("f")); - } + @BeforeClass + public static void before() throws Exception { + System.out.println("Setting up!"); + wireMockServer.start(); + configureFor("localhost", PORT); + RestAssured.port = PORT; + stubFor(post(urlEqualTo(EVENTS_PATH)).willReturn( + aResponse().withStatus(200) + .withHeader("Content-Type", APPLICATION_XML) + .withBody(EMPLOYEES))); + } - @Test - public void givenUrl_whenMultipleXmlValuesTestEqualInShortHand_thenCorrect() { - post("/employees") - .then() - .assertThat() - .body("employees.employee.first-name", equalTo("Jane"), - "employees.employee.last-name", equalTo("Daisy"), - "employees.employee.sex", equalTo("f")); - } + @Test + public void givenUrl_whenXmlResponseValueTestsEqual_thenCorrect() { + post("/employees").then().assertThat() + .body("employees.employee.first-name", equalTo("Jane")); + } - @Test - public void givenUrl_whenValidatesXmlUsingXpath_thenCorrect() { - post("/employees") - .then() - .assertThat() - .body(hasXPath("/employees/employee/first-name", - containsString("Ja"))); + @Test + public void givenUrl_whenMultipleXmlValuesTestEqual_thenCorrect() { + post("/employees").then().assertThat() + .body("employees.employee.first-name", equalTo("Jane")) + .body("employees.employee.last-name", equalTo("Daisy")) + .body("employees.employee.sex", equalTo("f")); + } - } + @Test + public void givenUrl_whenMultipleXmlValuesTestEqualInShortHand_thenCorrect() { + post("/employees") + .then() + .assertThat() + .body("employees.employee.first-name", equalTo("Jane"), + "employees.employee.last-name", equalTo("Daisy"), + "employees.employee.sex", equalTo("f")); + } - @Test - public void givenUrl_whenValidatesXmlUsingXpath2_thenCorrect() { - post("/employees") - .then() - .assertThat() - .body(hasXPath("/employees/employee/first-name[text()='Jane']")); + @Test + public void givenUrl_whenValidatesXmlUsingXpath_thenCorrect() { + post("/employees") + .then() + .assertThat() + .body(hasXPath("/employees/employee/first-name", + containsString("Ja"))); + } - } + @Test + public void givenUrl_whenValidatesXmlUsingXpath2_thenCorrect() { + post("/employees") + .then() + .assertThat() + .body(hasXPath("/employees/employee/first-name[text()='Jane']")); + } + private static String getXml() { + return Util + .inputStreamToString(RestAssuredXMLIntegrationTest.class.getResourceAsStream("/employees.xml")); + } - private static String getXml() { - - return Util - .inputStreamToString(new RestAssuredXMLIntegrationTest().getClass().getResourceAsStream("/employees.xml")); - -} - @After -public void after() throws Exception { - System.out.println("Running: tearDown"); - wireMockServer.stop(); -} + @AfterClass + public static void after() throws Exception { + System.out.println("Running: tearDown"); + wireMockServer.stop(); + } } diff --git a/rest-assured/src/test/java/com/baeldung/restassured/Util.java b/rest-assured/src/test/java/com/baeldung/restassured/Util.java index c75c52eb34..02dec87927 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/Util.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/Util.java @@ -1,36 +1,15 @@ package com.baeldung.restassured; -import java.io.BufferedReader; -import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; +import java.util.Scanner; -public class Util { - public static String inputStreamToString(InputStream is) { - BufferedReader br = null; - StringBuilder sb = new StringBuilder(); +final class Util { - String line; - try { + private Util() { + } - br = new BufferedReader(new InputStreamReader(is)); - while ((line = br.readLine()) != null) { - sb.append(line); - } - - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - return sb.toString(); - - } + static String inputStreamToString(InputStream is) { + Scanner s = new Scanner(is).useDelimiter("\\A"); + return s.hasNext() ? s.next() : ""; + } } diff --git a/rest-with-spark-java/README.md b/rest-with-spark-java/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/rest-with-spark-java/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/rmi/README.md b/rmi/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/rmi/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/rmi/client.policy b/rmi/client.policy new file mode 100644 index 0000000000..5d74bde76d --- /dev/null +++ b/rmi/client.policy @@ -0,0 +1,3 @@ +grant { + permission java.security.AllPermission; +}; \ No newline at end of file diff --git a/rmi/server.policy b/rmi/server.policy new file mode 100644 index 0000000000..5d74bde76d --- /dev/null +++ b/rmi/server.policy @@ -0,0 +1,3 @@ +grant { + permission java.security.AllPermission; +}; \ No newline at end of file diff --git a/rmi/src/org/baeldung/Client.java b/rmi/src/org/baeldung/Client.java new file mode 100644 index 0000000000..0376952bab --- /dev/null +++ b/rmi/src/org/baeldung/Client.java @@ -0,0 +1,20 @@ +package org.baeldung; + +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +public class Client { + public static void main(String[] args) throws RemoteException, NotBoundException { + System.setProperty("java.security.policy", "file:./client.policy"); + if (System.getSecurityManager() == null) { + System.setSecurityManager(new SecurityManager()); + } + String name = "RandomNumberGenerator"; + Registry registry = LocateRegistry.getRegistry(); + RandomNumberGenerator randomNumberGenerator = (RandomNumberGenerator) registry.lookup(name); + int number = randomNumberGenerator.get(); + System.out.println("Received random number:" + number); + } +} diff --git a/rmi/src/org/baeldung/RandomNumberGenerator.java b/rmi/src/org/baeldung/RandomNumberGenerator.java new file mode 100644 index 0000000000..50e49d2652 --- /dev/null +++ b/rmi/src/org/baeldung/RandomNumberGenerator.java @@ -0,0 +1,8 @@ +package org.baeldung; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +public interface RandomNumberGenerator extends Remote{ + int get() throws RemoteException; +} diff --git a/rmi/src/org/baeldung/RandomNumberGeneratorEngine.java b/rmi/src/org/baeldung/RandomNumberGeneratorEngine.java new file mode 100644 index 0000000000..04d90b2ff9 --- /dev/null +++ b/rmi/src/org/baeldung/RandomNumberGeneratorEngine.java @@ -0,0 +1,10 @@ +package org.baeldung; + +import java.rmi.RemoteException; + +public class RandomNumberGeneratorEngine implements RandomNumberGenerator { + @Override + public int get() throws RemoteException { + return (int) (100 * Math.random()); + } +} diff --git a/rmi/src/org/baeldung/Server.java b/rmi/src/org/baeldung/Server.java new file mode 100644 index 0000000000..8e613cb6bb --- /dev/null +++ b/rmi/src/org/baeldung/Server.java @@ -0,0 +1,22 @@ +package org.baeldung; + +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; + +public class Server { + public static void main(String[] args) throws RemoteException { + System.setProperty("java.security.policy", "file:./server.policy"); + if (System.getSecurityManager() == null) { + System.setSecurityManager(new SecurityManager()); + } + String name = "RandomNumberGenerator"; + RandomNumberGenerator randomNumberGenerator = new RandomNumberGeneratorEngine(); + RandomNumberGenerator stub = + (RandomNumberGenerator) UnicastRemoteObject.exportObject(randomNumberGenerator, 0); + Registry registry = LocateRegistry.getRegistry(); + registry.rebind(name, stub); + System.out.println("RandomNumberGenerator bound"); + } +} diff --git a/rule-engines/README.md b/rule-engines/README.md new file mode 100644 index 0000000000..6d3c0e93b4 --- /dev/null +++ b/rule-engines/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [List of Rules Engines in Java](http://www.baeldung.com/java-rule-engines) diff --git a/rxjava/README.md b/rxjava/README.md index c7fd0c595d..71231cc391 100644 --- a/rxjava/README.md +++ b/rxjava/README.md @@ -3,3 +3,8 @@ - [Dealing with Backpressure with RxJava](http://www.baeldung.com/rxjava-backpressure) - [How to Test RxJava?](http://www.baeldung.com/rxjava-testing) - [Implementing Custom Operators in RxJava](http://www.baeldung.com/rxjava-custom-operators) +- [Introduction to RxJava](http://www.baeldung.com/rx-java) +- [RxJava and Error Handling](http://www.baeldung.com/rxjava-error-handling) +- [Observable Utility Operators in RxJava](http://www.baeldung.com/rxjava-observable-operators) +- [Introduction to rxjava-jdbc](http://www.baeldung.com/rxjava-jdbc) +- [Schedulers in RxJava](http://www.baeldung.com/rxjava-schedulers) diff --git a/rxjava/pom.xml b/rxjava/pom.xml index 783833243b..0f950914ff 100644 --- a/rxjava/pom.xml +++ b/rxjava/pom.xml @@ -25,6 +25,12 @@ 2.1.3 + + io.reactivex + rxjava-math + 1.0.0 + + com.jayway.awaitility awaitility diff --git a/rxjava/src/main/java/com/baelding/rxjava/ComputeFunction.java b/rxjava/src/main/java/com/baeldung/rxjava/ComputeFunction.java similarity index 97% rename from rxjava/src/main/java/com/baelding/rxjava/ComputeFunction.java rename to rxjava/src/main/java/com/baeldung/rxjava/ComputeFunction.java index 924862ab37..7f9787a9d5 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/ComputeFunction.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/ComputeFunction.java @@ -1,4 +1,4 @@ -package com.baelding.rxjava; +package com.baeldung.rxjava; import rx.Observable; diff --git a/rxjava/src/main/java/com/baelding/rxjava/ConnectableObservableImpl.java b/rxjava/src/main/java/com/baeldung/rxjava/ConnectableObservableImpl.java similarity index 94% rename from rxjava/src/main/java/com/baelding/rxjava/ConnectableObservableImpl.java rename to rxjava/src/main/java/com/baeldung/rxjava/ConnectableObservableImpl.java index 005487dae8..a3e20a33f0 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/ConnectableObservableImpl.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/ConnectableObservableImpl.java @@ -1,4 +1,4 @@ -package com.baelding.rxjava; +package com.baeldung.rxjava; import rx.Observable; import rx.observables.ConnectableObservable; diff --git a/rxjava/src/main/java/com/baelding/rxjava/ObservableImpl.java b/rxjava/src/main/java/com/baeldung/rxjava/ObservableImpl.java similarity index 87% rename from rxjava/src/main/java/com/baelding/rxjava/ObservableImpl.java rename to rxjava/src/main/java/com/baeldung/rxjava/ObservableImpl.java index 9ab0d0e1e6..305aba6381 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/ObservableImpl.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/ObservableImpl.java @@ -1,4 +1,4 @@ -package com.baelding.rxjava; +package com.baeldung.rxjava; import rx.Observable; import rx.observables.BlockingObservable; @@ -8,13 +8,13 @@ import java.util.List; public class ObservableImpl { - static Integer[] numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + private static Integer[] numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - static String[] letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i"}; - static String[] titles = {"title"}; - public static List titleList = Arrays.asList(titles); + private static String[] letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i"}; + private static String[] titles = {"title"}; + private static List titleList = Arrays.asList(titles); - public static Observable getTitle() { + static Observable getTitle() { return Observable.from(titleList); } diff --git a/rxjava/src/main/java/com/baelding/rxjava/ResourceManagement.java b/rxjava/src/main/java/com/baeldung/rxjava/ResourceManagement.java similarity index 95% rename from rxjava/src/main/java/com/baelding/rxjava/ResourceManagement.java rename to rxjava/src/main/java/com/baeldung/rxjava/ResourceManagement.java index 44bbd7edda..272442098f 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/ResourceManagement.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/ResourceManagement.java @@ -1,4 +1,4 @@ -package com.baelding.rxjava; +package com.baeldung.rxjava; import rx.Observable; diff --git a/rxjava/src/main/java/com/baelding/rxjava/SingleImpl.java b/rxjava/src/main/java/com/baeldung/rxjava/SingleImpl.java similarity index 92% rename from rxjava/src/main/java/com/baelding/rxjava/SingleImpl.java rename to rxjava/src/main/java/com/baeldung/rxjava/SingleImpl.java index f625ab6b44..f0fda5d4df 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/SingleImpl.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/SingleImpl.java @@ -1,4 +1,4 @@ -package com.baelding.rxjava; +package com.baeldung.rxjava; import rx.Observable; import rx.Single; diff --git a/rxjava/src/main/java/com/baelding/rxjava/SubjectImpl.java b/rxjava/src/main/java/com/baeldung/rxjava/SubjectImpl.java similarity index 85% rename from rxjava/src/main/java/com/baelding/rxjava/SubjectImpl.java rename to rxjava/src/main/java/com/baeldung/rxjava/SubjectImpl.java index aac9b4454a..ceef3ab5f3 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/SubjectImpl.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/SubjectImpl.java @@ -1,14 +1,14 @@ -package com.baelding.rxjava; +package com.baeldung.rxjava; import rx.Observer; import rx.subjects.PublishSubject; public class SubjectImpl { - public static Integer subscriber1 = 0; - public static Integer subscriber2 = 0; + static Integer subscriber1 = 0; + static Integer subscriber2 = 0; - public static Integer subjectMethod() { + private static Integer subjectMethod() { PublishSubject subject = PublishSubject.create(); subject.subscribe(getFirstObserver()); @@ -25,7 +25,7 @@ public class SubjectImpl { } - public static Observer getFirstObserver() { + static Observer getFirstObserver() { return new Observer() { @Override @@ -46,7 +46,7 @@ public class SubjectImpl { }; } - public static Observer getSecondObserver() { + static Observer getSecondObserver() { return new Observer() { @Override diff --git a/rxjava/src/main/java/com/baeldung/rxjava/jdbc/Connector.java b/rxjava/src/main/java/com/baeldung/rxjava/jdbc/Connector.java index b7416e471a..25cd0bde83 100644 --- a/rxjava/src/main/java/com/baeldung/rxjava/jdbc/Connector.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/jdbc/Connector.java @@ -5,9 +5,9 @@ import com.github.davidmoten.rx.jdbc.ConnectionProviderFromUrl; class Connector { - static final String DB_CONNECTION = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"; - static final String DB_USER = ""; - static final String DB_PASSWORD = ""; + private static final String DB_CONNECTION = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"; + private static final String DB_USER = ""; + private static final String DB_PASSWORD = ""; static final ConnectionProvider connectionProvider = new ConnectionProviderFromUrl(DB_CONNECTION, DB_USER, DB_PASSWORD); } diff --git a/rxjava/src/main/java/com/baelding/rxjava/operator/ToCleanString.java b/rxjava/src/main/java/com/baeldung/rxjava/operator/ToCleanString.java similarity index 96% rename from rxjava/src/main/java/com/baelding/rxjava/operator/ToCleanString.java rename to rxjava/src/main/java/com/baeldung/rxjava/operator/ToCleanString.java index 32db92c8fe..708f7e9b86 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/operator/ToCleanString.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/operator/ToCleanString.java @@ -1,4 +1,4 @@ -package com.baelding.rxjava.operator; +package com.baeldung.rxjava.operator; import rx.Observable.Operator; import rx.Subscriber; diff --git a/rxjava/src/main/java/com/baelding/rxjava/operator/ToLength.java b/rxjava/src/main/java/com/baeldung/rxjava/operator/ToLength.java similarity index 90% rename from rxjava/src/main/java/com/baelding/rxjava/operator/ToLength.java rename to rxjava/src/main/java/com/baeldung/rxjava/operator/ToLength.java index 006d59de36..70ba8b8ca9 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/operator/ToLength.java +++ b/rxjava/src/main/java/com/baeldung/rxjava/operator/ToLength.java @@ -1,4 +1,4 @@ -package com.baelding.rxjava.operator; +package com.baeldung.rxjava.operator; import rx.Observable; import rx.Observable.Transformer; diff --git a/rxjava/src/test/java/com/baeldung/rxjava/ObservableTest.java b/rxjava/src/test/java/com/baeldung/rxjava/ObservableTest.java index 3d3bb021d2..beb2cbeed3 100644 --- a/rxjava/src/test/java/com/baeldung/rxjava/ObservableTest.java +++ b/rxjava/src/test/java/com/baeldung/rxjava/ObservableTest.java @@ -3,7 +3,7 @@ package com.baeldung.rxjava; import org.junit.Test; import rx.Observable; -import static com.baelding.rxjava.ObservableImpl.getTitle; +import static com.baeldung.rxjava.ObservableImpl.getTitle; import static junit.framework.Assert.assertTrue; public class ObservableTest { diff --git a/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java b/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java index bba891da88..414d951b86 100644 --- a/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java +++ b/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java @@ -10,8 +10,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static com.baelding.rxjava.operator.ToCleanString.toCleanString; -import static com.baelding.rxjava.operator.ToLength.toLength; +import static com.baeldung.rxjava.operator.ToCleanString.toCleanString; +import static com.baeldung.rxjava.operator.ToLength.toLength; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.notNullValue; diff --git a/rxjava/src/test/java/com/baeldung/rxjava/SchedulersTest.java b/rxjava/src/test/java/com/baeldung/rxjava/SchedulersLiveTest.java similarity index 99% rename from rxjava/src/test/java/com/baeldung/rxjava/SchedulersTest.java rename to rxjava/src/test/java/com/baeldung/rxjava/SchedulersLiveTest.java index 05b86e52b9..712f07324c 100644 --- a/rxjava/src/test/java/com/baeldung/rxjava/SchedulersTest.java +++ b/rxjava/src/test/java/com/baeldung/rxjava/SchedulersLiveTest.java @@ -21,7 +21,7 @@ import static org.hamcrest.Matchers.hasItems; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -public class SchedulersTest { +public class SchedulersLiveTest { private String result = ""; private String result1 = ""; private String result2 = ""; diff --git a/rxjava/src/test/java/com/baeldung/rxjava/SubjectTest.java b/rxjava/src/test/java/com/baeldung/rxjava/SubjectTest.java index 210ceaa636..628b1e5476 100644 --- a/rxjava/src/test/java/com/baeldung/rxjava/SubjectTest.java +++ b/rxjava/src/test/java/com/baeldung/rxjava/SubjectTest.java @@ -1,6 +1,5 @@ package com.baeldung.rxjava; -import com.baelding.rxjava.SubjectImpl; import org.junit.Test; import rx.subjects.PublishSubject; diff --git a/rxjava/src/test/java/com/baeldung/rxjava/jdbc/BasicQueryTypesIntegrationTest.java b/rxjava/src/test/java/com/baeldung/rxjava/jdbc/BasicQueryTypesIntegrationTest.java index c2fb2c32e3..5f445234d7 100644 --- a/rxjava/src/test/java/com/baeldung/rxjava/jdbc/BasicQueryTypesIntegrationTest.java +++ b/rxjava/src/test/java/com/baeldung/rxjava/jdbc/BasicQueryTypesIntegrationTest.java @@ -18,25 +18,25 @@ public class BasicQueryTypesIntegrationTest { private ConnectionProvider connectionProvider = Connector.connectionProvider; private Database db = Database.from(connectionProvider); - private Observable create, insert1, insert2, insert3, update, delete = null; + private Observable create; @Test public void whenCreateTableAndInsertRecords_thenCorrect() { create = db.update("CREATE TABLE IF NOT EXISTS EMPLOYEE(id int primary key, name varchar(255))") .count(); - insert1 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(1, 'John')") + Observable insert1 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(1, 'John')") .dependsOn(create) .count(); - update = db.update("UPDATE EMPLOYEE SET name = 'Alan' WHERE id = 1") + Observable update = db.update("UPDATE EMPLOYEE SET name = 'Alan' WHERE id = 1") .dependsOn(create) .count(); - insert2 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(2, 'Sarah')") + Observable insert2 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(2, 'Sarah')") .dependsOn(create) .count(); - insert3 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(3, 'Mike')") + Observable insert3 = db.update("INSERT INTO EMPLOYEE(id, name) VALUES(3, 'Mike')") .dependsOn(create) .count(); - delete = db.update("DELETE FROM EMPLOYEE WHERE id = 2") + Observable delete = db.update("DELETE FROM EMPLOYEE WHERE id = 2") .dependsOn(create) .count(); List names = db.select("select name from EMPLOYEE where id < ?") diff --git a/rxjava/src/test/java/com/baeldung/rxjava/operators/RxAggregateOperatorsTest.java b/rxjava/src/test/java/com/baeldung/rxjava/operators/RxAggregateOperatorsTest.java new file mode 100644 index 0000000000..6733aa08c5 --- /dev/null +++ b/rxjava/src/test/java/com/baeldung/rxjava/operators/RxAggregateOperatorsTest.java @@ -0,0 +1,221 @@ +package com.baeldung.rxjava.operators; + +import org.junit.Test; +import rx.Observable; +import rx.observers.TestSubscriber; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +public class RxAggregateOperatorsTest { + + @Test + public void givenTwoObservable_whenConcatenatingThem_thenSuccessfull() { + // given + List listOne = Arrays.asList(1, 2, 3, 4); + Observable observableOne = Observable.from(listOne); + + List listTwo = Arrays.asList(5, 6, 7, 8); + Observable observableTwo = Observable.from(listTwo); + + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable concatObservable = observableOne.concatWith(observableTwo); + + concatObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(8); + subscriber.assertValues(1, 2, 3, 4, 5, 6, 7, 8); + } + + @Test + public void givenObservable_whenCounting_thenObtainingNumberOfElements() { + // given + List lettersList = Arrays.asList("A", "B", "C", "D", "E", "F", "G"); + + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable sourceObservable = Observable.from(lettersList) + .count(); + sourceObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(7); + } + + @Test + public void givenObservable_whenReducing_thenObtainingInvertedConcatenatedString() { + // given + List list = Arrays.asList("A", "B", "C", "D", "E", "F", "G"); + + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable reduceObservable = Observable.from(list) + .reduce((letter1, letter2) -> letter2 + letter1); + reduceObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue("GFEDCBA"); + } + + @Test + public void givenObservable_whenCollecting_thenObtainingASet() { + // given + List list = Arrays.asList("A", "B", "C", "B", "B", "A", "D"); + + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable> reduceListObservable = Observable.from(list) + .collect(HashSet::new, HashSet::add); + reduceListObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValues(new HashSet<>(list)); + } + + @Test + public void givenObservable_whenUsingToList_thenObtainedAList() { + // given + Observable sourceObservable = Observable.range(1, 5); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable> listObservable = sourceObservable.toList(); + listObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(Arrays.asList(1, 2, 3, 4, 5)); + } + + @Test + public void givenObservable_whenUsingToSortedList_thenObtainedASortedList() { + // given + Observable sourceObservable = Observable.range(10, 5); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable> listObservable = sourceObservable.toSortedList(); + listObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(Arrays.asList(10, 11, 12, 13, 14)); + } + + @Test + public void givenObservable_whenUsingToSortedListWithComparator_thenObtainedAnInverseSortedList() { + // given + Observable sourceObservable = Observable.range(10, 5); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable> listObservable = sourceObservable.toSortedList((int1, int2) -> int2 - int1); + listObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(Arrays.asList(14, 13, 12, 11, 10)); + } + + @Test + public void givenObservable_whenUsingToMap_thenObtainedAMap() { + // given + Observable bookObservable = Observable + .just( + new Book("The North Water", 2016), + new Book("Origin", 2017), + new Book("Sleeping Beauties", 2017)); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable> mapObservable = bookObservable + .toMap(Book::getTitle, Book::getYear, HashMap::new); + + mapObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(new HashMap() { + { + put("The North Water", 2016); + put("Origin", 2017); + put("Sleeping Beauties", 2017); + } + }); + } + + @Test + public void givenObservable_whenUsingToMultiMap_thenObtainedAMultiMap() { + // given + Observable bookObservable = Observable + .just( + new Book("The North Water", 2016), + new Book("Origin", 2017), + new Book("Sleeping Beauties", 2017)); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + Observable multiMapObservable = bookObservable + .toMultimap(Book::getYear, Book::getTitle, () -> new HashMap<>(), (key) -> new ArrayList<>()); + + multiMapObservable.subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(new HashMap() { + { + put(2016, Arrays.asList("The North Water")); + put(2017, Arrays.asList("Origin", "Sleeping Beauties")); + } + }); + } + + class Book { + private String title; + private Integer year; + + public Book(String title, Integer year) { + this.title = title; + this.year = year; + } + + public String getTitle() { + return title; + } + + public Integer getYear() { + return year; + } + } +} diff --git a/rxjava/src/test/java/com/baeldung/rxjava/operators/RxMathematicalOperatorsTest.java b/rxjava/src/test/java/com/baeldung/rxjava/operators/RxMathematicalOperatorsTest.java new file mode 100644 index 0000000000..cd212a2e18 --- /dev/null +++ b/rxjava/src/test/java/com/baeldung/rxjava/operators/RxMathematicalOperatorsTest.java @@ -0,0 +1,139 @@ +package com.baeldung.rxjava.operators; + +import org.junit.Test; +import rx.Observable; +import rx.observables.MathObservable; +import rx.observers.TestSubscriber; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +public class RxMathematicalOperatorsTest { + + @Test + public void givenRangeNumericObservable_whenCalculatingAverage_ThenSuccessfull() { + // given + Observable sourceObservable = Observable.range(1, 20); + + TestSubscriber subscriber = TestSubscriber.create(); + + // when + MathObservable.averageInteger(sourceObservable) + .subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(10); + } + + @Test + public void givenRangeNumericObservable_whenCalculatingSum_ThenSuccessfull() { + // given + Observable sourceObservable = Observable.range(1, 20); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + MathObservable.sumInteger(sourceObservable) + .subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(210); + + } + + @Test + public void givenRangeNumericObservable_whenCalculatingMax_ThenSuccessfullObtainingMaxValue() { + // given + Observable sourceObservable = Observable.range(1, 20); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + MathObservable.max(sourceObservable) + .subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(20); + } + + @Test + public void givenRangeNumericObservable_whenCalculatingMin_ThenSuccessfullObtainingMinValue() { + // given + Observable sourceObservable = Observable.range(1, 20); + TestSubscriber subscriber = TestSubscriber.create(); + + // when + MathObservable.min(sourceObservable) + .subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(1); + } + + @Test + public void givenItemObservable_whenCalculatingMaxWithComparator_ThenSuccessfullObtainingMaxItem() { + // given + Item five = new Item(5); + List list = Arrays.asList(new Item(1), new Item(2), new Item(3), new Item(4), five); + Observable itemObservable = Observable.from(list); + + TestSubscriber subscriber = TestSubscriber.create(); + + // when + MathObservable.from(itemObservable) + .max(Comparator.comparing(Item::getId)) + .subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(five); + + } + + @Test + public void givenItemObservable_whenCalculatingMinWithComparator_ThenSuccessfullObtainingMinItem() { + // given + Item one = new Item(1); + List list = Arrays.asList(one, new Item(2), new Item(3), new Item(4), new Item(5)); + TestSubscriber subscriber = TestSubscriber.create(); + Observable itemObservable = Observable.from(list); + + // when + MathObservable.from(itemObservable) + .min(Comparator.comparing(Item::getId)) + .subscribe(subscriber); + + // then + subscriber.assertCompleted(); + subscriber.assertNoErrors(); + subscriber.assertValueCount(1); + subscriber.assertValue(one); + + } + + class Item { + private Integer id; + + public Item(Integer id) { + this.id = id; + } + + public Integer getId() { + return id; + } + + } +} diff --git a/saas/.gitignore b/saas/.gitignore new file mode 100644 index 0000000000..3de4cc647e --- /dev/null +++ b/saas/.gitignore @@ -0,0 +1,26 @@ +*.class + +0.* + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* +.resourceCache + +# Packaged files # +*.jar +*.war +*.ear + +# Files generated by integration tests +*.txt +backup-pom.xml +/bin/ +/temp + +#IntelliJ specific +.idea/ +*.iml \ No newline at end of file diff --git a/saas/README.md b/saas/README.md new file mode 100644 index 0000000000..4e0eeea974 --- /dev/null +++ b/saas/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [JIRA REST API Integration](http://www.baeldung.com/jira-rest-api) diff --git a/saas/pom.xml b/saas/pom.xml new file mode 100644 index 0000000000..7c8745910f --- /dev/null +++ b/saas/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + com.baeldung + saas + 0.1.0-SNAPSHOT + jar + saas + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + com.atlassian.jira + jira-rest-java-client-core + 4.0.0 + + + com.atlassian.fugue + fugue + 2.6.1 + + + com.google.guava + guava + 19.0 + + + + + + saas + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + java + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + -Xmx300m + -XX:+UseParallelGC + -classpath + + com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed + + + + + + + + + atlassian-public + https://packages.atlassian.com/maven/repository/public + + + + + 3.6.0 + + \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/jira/MyJiraClient.java b/saas/src/main/java/com/baeldung/saas/jira/MyJiraClient.java similarity index 99% rename from libraries/src/main/java/com/baeldung/jira/MyJiraClient.java rename to saas/src/main/java/com/baeldung/saas/jira/MyJiraClient.java index ea1d73f52a..ff1de5a6d0 100644 --- a/libraries/src/main/java/com/baeldung/jira/MyJiraClient.java +++ b/saas/src/main/java/com/baeldung/saas/jira/MyJiraClient.java @@ -1,4 +1,4 @@ -package com.baeldung.jira; +package com.baeldung.saas.jira; import com.atlassian.jira.rest.client.api.IssueRestClient; import com.atlassian.jira.rest.client.api.JiraRestClient; diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 1ecb824c40..6615e1d6cd 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -195,7 +195,11 @@ spring-core ${org.springframework.version} - + + + org.springframework.boot + spring-boot-starter-thymeleaf + @@ -280,4 +284,4 @@ - \ No newline at end of file + diff --git a/spring-all/src/main/webapp/WEB-INF/view/viewPage.html b/spring-all/src/main/webapp/WEB-INF/view/viewPage.html new file mode 100644 index 0000000000..71f766407e --- /dev/null +++ b/spring-all/src/main/webapp/WEB-INF/view/viewPage.html @@ -0,0 +1,9 @@ + + + + Title + + +
    Web Application. Passed parameter : th:text="${message}"
    + + diff --git a/spring-all/src/main/webapp/WEB-INF/view/viewPage.jsp b/spring-all/src/main/webapp/WEB-INF/view/viewPage.jsp deleted file mode 100644 index ca638b33f5..0000000000 --- a/spring-all/src/main/webapp/WEB-INF/view/viewPage.jsp +++ /dev/null @@ -1,11 +0,0 @@ -<%@ page contentType="text/html;charset=UTF-8" language="java" %> - - - Title - - -
    - Web Application. Passed parameter : ${message} -
    - - diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterAspect.java b/spring-aop/src/main/java/org/baeldung/logger/AdderAfterAspect.java new file mode 100644 index 0000000000..59afa38f06 --- /dev/null +++ b/spring-aop/src/main/java/org/baeldung/logger/AdderAfterAspect.java @@ -0,0 +1,13 @@ +package org.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAfterAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void afterAdvice() throws Throwable { + logger.info("I'm done calling the method"); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterReturnAspect.java b/spring-aop/src/main/java/org/baeldung/logger/AdderAfterReturnAspect.java new file mode 100644 index 0000000000..a2b1959374 --- /dev/null +++ b/spring-aop/src/main/java/org/baeldung/logger/AdderAfterReturnAspect.java @@ -0,0 +1,13 @@ +package org.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAfterReturnAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void afterReturn(final Object returnValue) throws Throwable { + logger.info("value return was {}", returnValue); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAfterThrowAspect.java b/spring-aop/src/main/java/org/baeldung/logger/AdderAfterThrowAspect.java new file mode 100644 index 0000000000..1f19af05e4 --- /dev/null +++ b/spring-aop/src/main/java/org/baeldung/logger/AdderAfterThrowAspect.java @@ -0,0 +1,13 @@ +package org.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAfterThrowAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void afterThrow(final Exception exception) throws Throwable { + logger.info("Exception thrown was {}", exception.getMessage()); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderAroundAspect.java b/spring-aop/src/main/java/org/baeldung/logger/AdderAroundAspect.java new file mode 100644 index 0000000000..fceba87d15 --- /dev/null +++ b/spring-aop/src/main/java/org/baeldung/logger/AdderAroundAspect.java @@ -0,0 +1,18 @@ +package org.baeldung.logger; + +import java.util.Arrays; +import org.aspectj.lang.ProceedingJoinPoint; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderAroundAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public Object aroundAdvice(final ProceedingJoinPoint joinPoint) throws Throwable { + logger.info("Arguments passed to method are: " + Arrays.toString(joinPoint.getArgs())); + final Object result = joinPoint.proceed(); + logger.info("Result from method is: " + result); + return result; + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/AdderBeforeAspect.java b/spring-aop/src/main/java/org/baeldung/logger/AdderBeforeAspect.java new file mode 100644 index 0000000000..750e7ba122 --- /dev/null +++ b/spring-aop/src/main/java/org/baeldung/logger/AdderBeforeAspect.java @@ -0,0 +1,13 @@ +package org.baeldung.logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdderBeforeAspect { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public void beforeAdvice() throws Throwable { + logger.info("I would be executed just before method starts"); + } +} diff --git a/spring-aop/src/main/java/org/baeldung/logger/SampleAdder.java b/spring-aop/src/main/java/org/baeldung/logger/SampleAdder.java new file mode 100644 index 0000000000..96fda1b0b9 --- /dev/null +++ b/spring-aop/src/main/java/org/baeldung/logger/SampleAdder.java @@ -0,0 +1,12 @@ +package org.baeldung.logger; + +public class SampleAdder { + + public int add(int a, int b) { + if (a < 0 || b < 0) { + throw new IllegalArgumentException("Make sure all the arguments are greater than zero."); + } + return a + b; + } + +} diff --git a/spring-aop/src/main/resources/org.baeldung.logger/springAop-applicationContext.xml b/spring-aop/src/main/resources/org.baeldung.logger/springAop-applicationContext.xml new file mode 100644 index 0000000000..058beaa7a1 --- /dev/null +++ b/spring-aop/src/main/resources/org.baeldung.logger/springAop-applicationContext.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-aop/src/test/java/org/baeldung/logger/CalculatorTest.java b/spring-aop/src/test/java/org/baeldung/logger/CalculatorTest.java new file mode 100644 index 0000000000..b1c88c67df --- /dev/null +++ b/spring-aop/src/test/java/org/baeldung/logger/CalculatorTest.java @@ -0,0 +1,29 @@ +package org.baeldung.logger; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(value = {"classpath:springAop-applicationContext.xml"}) +public class CalculatorTest { + + @Autowired + private SampleAdder sampleAdder; + + @Test + public void whenAddValidValues_returnsSucessfully() { + final int addedValue = sampleAdder.add(12, 12); + + assertEquals(24, addedValue); + } + + @Test (expected = IllegalArgumentException.class) + public void whenAddInValidValues_throwsException() { + sampleAdder.add(12, -12); + } + +} diff --git a/spring-aop/src/test/resources/springAop-applicationContext.xml b/spring-aop/src/test/resources/springAop-applicationContext.xml new file mode 100644 index 0000000000..4d88bd3711 --- /dev/null +++ b/spring-aop/src/test/resources/springAop-applicationContext.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-actuator/.gitignore b/spring-boot-actuator/.gitignore new file mode 100644 index 0000000000..60be5b80aa --- /dev/null +++ b/spring-boot-actuator/.gitignore @@ -0,0 +1,4 @@ +/target/ +.settings/ +.classpath +.project diff --git a/.metadata/.lock b/spring-boot-actuator/README.MD similarity index 100% rename from .metadata/.lock rename to spring-boot-actuator/README.MD diff --git a/spring-boot-actuator/pom.xml b/spring-boot-actuator/pom.xml new file mode 100644 index 0000000000..bec126a247 --- /dev/null +++ b/spring-boot-actuator/pom.xml @@ -0,0 +1,121 @@ + + 4.0.0 + com.baeldung + spring-boot-actuator + 0.0.1-SNAPSHOT + jar + spring-boot + This is simple boot application for Spring boot actuator test + + + + org.springframework.boot + spring-boot-starter-parent + 1.5.2.RELEASE + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + spring-boot-actuator + + + src/main/resources + true + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + + + + org.baeldung.MainApplication + UTF-8 + 1.8 + + + diff --git a/spring-boot-actuator/src/main/java/org/baeldung/MainApplication.java b/spring-boot-actuator/src/main/java/org/baeldung/MainApplication.java new file mode 100644 index 0000000000..7c9054dbf8 --- /dev/null +++ b/spring-boot-actuator/src/main/java/org/baeldung/MainApplication.java @@ -0,0 +1,13 @@ +package org.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.baeldung.config.MainConfig; + +@SpringBootApplication +public class MainApplication { + + public static void main(String args[]) { + SpringApplication.run(MainConfig.class, args); + } +} diff --git a/spring-boot-actuator/src/main/java/org/baeldung/config/MainConfig.java b/spring-boot-actuator/src/main/java/org/baeldung/config/MainConfig.java new file mode 100644 index 0000000000..27c97cc006 --- /dev/null +++ b/spring-boot-actuator/src/main/java/org/baeldung/config/MainConfig.java @@ -0,0 +1,17 @@ +package org.baeldung.config; + +import java.util.Collections; +import org.springframework.boot.actuate.info.InfoContributor; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.Bean; + +@EnableAutoConfiguration +public class MainConfig { + + public MainConfig() {} + + @Bean + public InfoContributor getInfoContributor() { + return (infoBuilder) -> infoBuilder.withDetail("applicationInfo", Collections.singletonMap("ActiveUserCount", "10")); + } +} diff --git a/spring-boot-actuator/src/main/resources/application.properties b/spring-boot-actuator/src/main/resources/application.properties new file mode 100644 index 0000000000..835c78eda2 --- /dev/null +++ b/spring-boot-actuator/src/main/resources/application.properties @@ -0,0 +1 @@ +info.app.name=Sample application \ No newline at end of file diff --git a/spring-boot-actuator/src/test/java/org/baeldung/config/ActuatorInfoIntegrationTest.java b/spring-boot-actuator/src/test/java/org/baeldung/config/ActuatorInfoIntegrationTest.java new file mode 100644 index 0000000000..0b5e3b3eef --- /dev/null +++ b/spring-boot-actuator/src/test/java/org/baeldung/config/ActuatorInfoIntegrationTest.java @@ -0,0 +1,32 @@ +package org.baeldung.config; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import static org.junit.Assert.*; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = MainConfig.class) +@TestPropertySource(properties = { "security.basic.enabled=false" }) +public class ActuatorInfoIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Test + public void whenGetInfo_thenAdditionalInfoReturned() throws IOException { + final String expectedResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/expectedResponse.json"))); + final ResponseEntity responseEntity = this.restTemplate.getForEntity("/info", String.class); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + assertEquals(expectedResponse, responseEntity.getBody()); + } +} \ No newline at end of file diff --git a/spring-boot-actuator/src/test/resources/expectedResponse.json b/spring-boot-actuator/src/test/resources/expectedResponse.json new file mode 100644 index 0000000000..caa0bdbbf8 --- /dev/null +++ b/spring-boot-actuator/src/test/resources/expectedResponse.json @@ -0,0 +1 @@ +{"app":{"name":"Sample application"},"applicationInfo":{"ActiveUserCount":"10"}} \ No newline at end of file diff --git a/spring-cloud-cli/README.md b/spring-cloud-cli/README.md new file mode 100644 index 0000000000..5f83ab06fa --- /dev/null +++ b/spring-cloud-cli/README.md @@ -0,0 +1,6 @@ +========= + +## Spring Cloud CLI + +### Relevant Articles: +- [Introduction to Spring Cloud CLI](http://www.baeldung.com/introduction-to-spring-cloud-cli/) \ No newline at end of file diff --git a/spring-cloud-cli/decrypt.sh b/spring-cloud-cli/decrypt.sh new file mode 100644 index 0000000000..450ac156bc --- /dev/null +++ b/spring-cloud-cli/decrypt.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +echo Decrypting my_value as key my_key +spring decrypt --key my_key +echo +echo You should see: \"my_value\" +echo \ No newline at end of file diff --git a/spring-cloud-cli/encrypt.sh b/spring-cloud-cli/encrypt.sh new file mode 100644 index 0000000000..a5ea678952 --- /dev/null +++ b/spring-cloud-cli/encrypt.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +echo Encrypting my_value as key my_key +spring encrypt my_value --key my_key +echo +echo You should see something like: c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b +echo +echo You can use: \"{cipher}c93cb36ce1d09d7d62dffd156ef742faaa56f97f135ebd05e90355f80290ce6b\" in your configuration files +echo \ No newline at end of file diff --git a/spring-cloud-cli/groovy.sh b/spring-cloud-cli/groovy.sh new file mode 100644 index 0000000000..19f785989b --- /dev/null +++ b/spring-cloud-cli/groovy.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +echo "Run Groovy Rest API Server" +echo "spring run restapi.groovy" +echo "http://localhost:8080/api/get" +spring run restapi.groovy +echo +echo "Run Groovy Eureka Server" +echo "spring run eureka.groovy" +echo "http://localhost:8761" +spring run eureka.groovy +echo \ No newline at end of file diff --git a/spring-cloud-cli/groovy/eureka.groovy b/spring-cloud-cli/groovy/eureka.groovy new file mode 100644 index 0000000000..9f7acdd769 --- /dev/null +++ b/spring-cloud-cli/groovy/eureka.groovy @@ -0,0 +1,2 @@ +@EnableEurekaServer +class Eureka {} \ No newline at end of file diff --git a/spring-cloud-cli/groovy/restapi.groovy b/spring-cloud-cli/groovy/restapi.groovy new file mode 100644 index 0000000000..1526f7f825 --- /dev/null +++ b/spring-cloud-cli/groovy/restapi.groovy @@ -0,0 +1,6 @@ +@RestController +@RequestMapping('/api') +class api { + @GetMapping('/get') + def get() { [message: 'Hello'] } +} \ No newline at end of file diff --git a/spring-cloud-cli/install.sh b/spring-cloud-cli/install.sh new file mode 100644 index 0000000000..e01a8fc22e --- /dev/null +++ b/spring-cloud-cli/install.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +echo See: https://howtoprogram.xyz/2016/08/28/install-spring-boot-command-line-interface-on-linux/ +echo + +echo "Setting up Java JDK 8" +echo See: http://tipsonubuntu.com/2016/07/31/install-oracle-java-8-9-ubuntu-16-04-linux-mint-18/ +sudo add-apt-repository ppa:webupd8team/java +sudo apt-get update +sudo apt-get install oracle-java8-set-default +echo + +echo "Downloading Spring Boot CLI 1.5.7" +wget http://repo.spring.io/release/org/springframework/boot/spring-boot-cli/1.5.7.RELEASE/spring-boot-cli-1.5.7.RELEASE-bin.tar.gz +echo + +echo "Extracting and Installing" +sudo mkdir /opt/spring-boot +sudo tar xzf spring-boot-cli-1.5.7.RELEASE-bin.tar.gz -C /opt/spring-boot +export SPRING_HOME=/opt/spring-boot/spring-1.5.7.RELEASE +export PATH=$SPRING_HOME/bin:$PATH +source /etc/profile +echo + +echo "Verifying Install of Spring CLI" +spring --version +echo + +echo "Maven Install" +sudo apt-get install maven +echo + +echo "Installing JCE" +sudo apt-get install p7zip-full +echo please go to: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html +echo Download the jce_policy-8.zip after you agree to the terms +sleep 25 +sudo 7z x jce_policy-8.zip +sudo mv /usr/lib/jvm/java-8-oracle/jre/lib/security/local_policy.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/local_policy.jar.backup +sudo mv /usr/lib/jvm/java-8-oracle/jre/lib/security/US_export_policy.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/US_export_policy.jar.backup +sudo mv UnlimitedJCEPolicyJDK8/*.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/ +echo + +echo "Installing Spring Cloud CLI" +sudo mkdir /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext +sudo chown -R $USER:$USER /opt/spring-boot/spring-1.5.7.RELEASE/lib/ext +echo see: https://repo.spring.io/snapshot/org/springframework/cloud/spring-cloud-cli/ if manual install required +spring install org.springframework.cloud:spring-cloud-cli:1.3.2.RELEASE +echo + +echo "Verify Installation" +spring cloud --version +echo \ No newline at end of file diff --git a/spring-cloud-cli/spring-cli-cmds.sh b/spring-cloud-cli/spring-cli-cmds.sh new file mode 100644 index 0000000000..6947122a18 --- /dev/null +++ b/spring-cloud-cli/spring-cli-cmds.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +echo "Run Config Server" +echo "spring cloud configserver" +echo "http://localhost:8888" +spring cloud configserver +echo +echo "Run Eureka Server" +echo "spring cloud eureka" +echo "http://localhost:8761" +spring cloud eureka +echo +echo "Run H2 Server" +echo "spring cloud h2" +echo "http://localhost:9095" +spring cloud h2 +echo +echo "Run Kafka Server" +echo "spring cloud kafka" +echo "http://localhost:9091" +spring cloud kafka +echo +echo "Run Zipkin Server" +echo "spring cloud zipkin" +echo "http://localhost:9411" +spring cloud zipkin +echo +echo "Run Dataflow Server" +echo "spring cloud dataflow" +echo "http://localhost:9393" +spring cloud dataflow +echo +echo "Run Hystrixdashboard Server" +echo "spring cloud hystrixdashboard" +echo "http://localhost:7979" +spring cloud hystrixdashboard +echo +echo "List Services" +echo "spring cloud --list" +spring cloud --list +echo \ No newline at end of file diff --git a/spring-cloud-cli/yml/configserver.yml b/spring-cloud-cli/yml/configserver.yml new file mode 100644 index 0000000000..2932bddcbf --- /dev/null +++ b/spring-cloud-cli/yml/configserver.yml @@ -0,0 +1,4 @@ +spring: + profiles: + active: git + cloud.config.server.git.uri: https://github.com/spring-cloud/spring-cloud-cli/tree/master/spring-cloud-launcher/spring-cloud-launcher-configserver \ No newline at end of file diff --git a/spring-cloud-cli/yml/eureka.yml b/spring-cloud-cli/yml/eureka.yml new file mode 100644 index 0000000000..9a21c1ce1c --- /dev/null +++ b/spring-cloud-cli/yml/eureka.yml @@ -0,0 +1,8 @@ +spring: + profiles: + active: git + cloud: + config: + server: + git: + uri: https://github.com/spring-cloud/spring-cloud-cli/tree/master/spring-cloud-launcher/spring-cloud-launcher-eureka \ No newline at end of file diff --git a/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java b/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java index 8e87ed3028..e74e773106 100644 --- a/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java +++ b/spring-cucumber/src/main/java/com/baeldung/BaeldungController.java @@ -1,22 +1,21 @@ package com.baeldung; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletResponse; + @RestController public class BaeldungController { - @RequestMapping(method = { RequestMethod.GET }, value = { "/hello" }) + @GetMapping("/hello") public String sayHello(HttpServletResponse response) { return "hello"; } - @RequestMapping(method = { RequestMethod.POST }, value = { "/baeldung" }) + @PostMapping("/baeldung") public String sayHelloPost(HttpServletResponse response) { return "hello"; } - } diff --git a/spring-cucumber/src/main/java/com/baeldung/SpringDemoApplication.java b/spring-cucumber/src/main/java/com/baeldung/SpringDemoApplication.java index 820e7e8004..ff9b12ad85 100644 --- a/spring-cucumber/src/main/java/com/baeldung/SpringDemoApplication.java +++ b/spring-cucumber/src/main/java/com/baeldung/SpringDemoApplication.java @@ -2,23 +2,16 @@ package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; import org.springframework.web.client.RestTemplate; @SpringBootApplication -public class SpringDemoApplication extends SpringBootServletInitializer { +public class SpringDemoApplication { public static void main(String[] args) { SpringApplication.run(SpringDemoApplication.class, args); } - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(SpringDemoApplication.class); - } - @Bean public RestTemplate getRestTemplate() { return new RestTemplate(); diff --git a/spring-cucumber/src/main/resources/application.properties b/spring-cucumber/src/main/resources/application.properties index e69de29bb2..8d51d0c619 100644 --- a/spring-cucumber/src/main/resources/application.properties +++ b/spring-cucumber/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8082 \ No newline at end of file diff --git a/spring-cucumber/src/test/java/com/baeldung/OtherDefsIntegrationTest.java b/spring-cucumber/src/test/java/com/baeldung/OtherDefsIntegrationTest.java deleted file mode 100644 index 17f298c3fb..0000000000 --- a/spring-cucumber/src/test/java/com/baeldung/OtherDefsIntegrationTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung; - -import cucumber.api.java.en.Given; -import cucumber.api.java.en.When; - -public class OtherDefsIntegrationTest extends SpringIntegrationTest { - @When("^the client calls /baeldung$") - public void the_client_issues_POST_hello() throws Throwable { - executePost("http://localhost:8080/baeldung"); - } - - @Given("^the client calls /hello$") - public void the_client_issues_GET_hello() throws Throwable { - executeGet("http://localhost:8080/hello"); - } -} \ No newline at end of file diff --git a/spring-cucumber/src/test/java/com/baeldung/ResponseResults.java b/spring-cucumber/src/test/java/com/baeldung/ResponseResults.java index 4c0125e9b4..0f5bcbb824 100644 --- a/spring-cucumber/src/test/java/com/baeldung/ResponseResults.java +++ b/spring-cucumber/src/test/java/com/baeldung/ResponseResults.java @@ -11,23 +11,19 @@ public class ResponseResults { private final ClientHttpResponse theResponse; private final String body; - protected ResponseResults(final ClientHttpResponse response) throws IOException { + ResponseResults(final ClientHttpResponse response) throws IOException { this.theResponse = response; final InputStream bodyInputStream = response.getBody(); - if (null == bodyInputStream) { - this.body = "{}"; - } else { - final StringWriter stringWriter = new StringWriter(); - IOUtils.copy(bodyInputStream, stringWriter); - this.body = stringWriter.toString(); - } + final StringWriter stringWriter = new StringWriter(); + IOUtils.copy(bodyInputStream, stringWriter); + this.body = stringWriter.toString(); } - protected ClientHttpResponse getTheResponse() { + ClientHttpResponse getTheResponse() { return theResponse; } - protected String getBody() { + String getBody() { return body; } } \ No newline at end of file diff --git a/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java b/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java index 34efff63fb..9fbaeb348d 100644 --- a/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java +++ b/spring-cucumber/src/test/java/com/baeldung/SpringIntegrationTest.java @@ -1,9 +1,5 @@ package com.baeldung; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.IntegrationTest; import org.springframework.boot.test.SpringApplicationContextLoader; @@ -12,40 +8,39 @@ import org.springframework.http.client.ClientHttpResponse; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.client.ResponseErrorHandler; -import org.springframework.web.client.ResponseExtractor; import org.springframework.web.client.RestTemplate; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + //@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = SpringDemoApplication.class, loader = SpringApplicationContextLoader.class) @WebAppConfiguration @IntegrationTest public class SpringIntegrationTest { - protected static ResponseResults latestResponse = null; + static ResponseResults latestResponse = null; @Autowired protected RestTemplate restTemplate; - protected void executeGet(String url) throws IOException { + void executeGet(String url) throws IOException { final Map headers = new HashMap<>(); headers.put("Accept", "application/json"); final HeaderSettingRequestCallback requestCallback = new HeaderSettingRequestCallback(headers); final ResponseResultErrorHandler errorHandler = new ResponseResultErrorHandler(); restTemplate.setErrorHandler(errorHandler); - latestResponse = restTemplate.execute(url, HttpMethod.GET, requestCallback, new ResponseExtractor() { - @Override - public ResponseResults extractData(ClientHttpResponse response) throws IOException { - if (errorHandler.hadError) { - return (errorHandler.getResults()); - } else { - return (new ResponseResults(response)); - } + latestResponse = restTemplate.execute(url, HttpMethod.GET, requestCallback, response -> { + if (errorHandler.hadError) { + return (errorHandler.getResults()); + } else { + return (new ResponseResults(response)); } }); - } - protected void executePost(String url) throws IOException { + void executePost() throws IOException { final Map headers = new HashMap<>(); headers.put("Accept", "application/json"); final HeaderSettingRequestCallback requestCallback = new HeaderSettingRequestCallback(headers); @@ -56,17 +51,14 @@ public class SpringIntegrationTest { } restTemplate.setErrorHandler(errorHandler); - latestResponse = restTemplate.execute(url, HttpMethod.POST, requestCallback, new ResponseExtractor() { - @Override - public ResponseResults extractData(ClientHttpResponse response) throws IOException { - if (errorHandler.hadError) { - return (errorHandler.getResults()); - } else { - return (new ResponseResults(response)); - } - } - }); - + latestResponse = restTemplate + .execute("http://localhost:8082/baeldung", HttpMethod.POST, requestCallback, response -> { + if (errorHandler.hadError) { + return (errorHandler.getResults()); + } else { + return (new ResponseResults(response)); + } + }); } private class ResponseResultErrorHandler implements ResponseErrorHandler { diff --git a/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java b/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java index 8220d5e861..e1b6e370c7 100644 --- a/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java +++ b/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java @@ -3,6 +3,7 @@ package com.baeldung; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import cucumber.api.java.en.Given; import org.springframework.http.HttpStatus; import cucumber.api.java.en.And; @@ -11,9 +12,19 @@ import cucumber.api.java.en.When; public class StepDefsIntegrationTest extends SpringIntegrationTest { + @When("^the client calls /baeldung$") + public void the_client_issues_POST_hello() throws Throwable { + executePost(); + } + + @Given("^the client calls /hello$") + public void the_client_issues_GET_hello() throws Throwable { + executeGet("http://localhost:8082/hello"); + } + @When("^the client calls /version$") public void the_client_issues_GET_version() throws Throwable { - executeGet("http://localhost:8080/version"); + executeGet("http://localhost:8082/version"); } @Then("^the client receives status code of (\\d+)$") diff --git a/spring-drools/README.md b/spring-drools/README.md new file mode 100644 index 0000000000..00b35a4624 --- /dev/null +++ b/spring-drools/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Drools Spring Integration](http://www.baeldung.com/drools-spring-integration) diff --git a/spring-groovy/README.md b/spring-groovy/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/spring-groovy/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/spring-hibernate5/README.md b/spring-hibernate5/README.md index fd539fdcb6..01a1ad7121 100644 --- a/spring-hibernate5/README.md +++ b/spring-hibernate5/README.md @@ -1,3 +1,4 @@ ### Relevant articles - [Guide to @Immutable Annotation in Hibernate](http://www.baeldung.com/hibernate-immutable) +- [Hibernate Many to Many Annotation Tutorial](http://www.baeldung.com/hibernate-many-to-many) diff --git a/spring-hibernate5/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java b/spring-hibernate5/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java index b8cc3dc1a6..d6ecdb29d6 100644 --- a/spring-hibernate5/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java +++ b/spring-hibernate5/src/test/java/com/baeldung/hibernate/immutable/HibernateImmutableIntegrationTest.java @@ -23,11 +23,8 @@ public class HibernateImmutableIntegrationTest { @Before public void before() { - session = HibernateUtil.getSessionFactory().getCurrentSession(); + session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); - createEvent(); - createEventGenerated(); - session.setCacheMode(CacheMode.REFRESH); } @BeforeClass @@ -40,8 +37,6 @@ public class HibernateImmutableIntegrationTest { HibernateUtil.getSessionFactory().close(); } - // - @Test public void addEvent() { Event event = new Event(); @@ -49,15 +44,18 @@ public class HibernateImmutableIntegrationTest { event.setTitle("Public Event"); session.save(event); session.getTransaction().commit(); + session.close(); } @Test public void updateEvent() { + createEvent(); Event event = (Event) session.createQuery("FROM Event WHERE title='New Event'").list().get(0); event.setTitle("Private Event"); session.update(event); session.flush(); session.refresh(event); + session.close(); assertThat(event.getTitle(), equalTo("New Event")); assertThat(event.getId(), equalTo(5L)); @@ -65,13 +63,16 @@ public class HibernateImmutableIntegrationTest { @Test public void deleteEvent() { + createEvent(); Event event = (Event) session.createQuery("FROM Event WHERE title='New Event'").list().get(0); session.delete(event); session.getTransaction().commit(); + session.close(); } @Test public void addGuest() { + createEvent(); Event event = (Event) session.createQuery("FROM Event WHERE title='New Event'").list().get(0); String newGuest = "Sara"; event.getGuestList().add(newGuest); @@ -79,6 +80,7 @@ public class HibernateImmutableIntegrationTest { exception.expect(PersistenceException.class); session.save(event); session.getTransaction().commit(); + session.close(); } @Test @@ -94,18 +96,18 @@ public class HibernateImmutableIntegrationTest { @Test public void updateEventGenerated() { + createEventGenerated(); EventGeneratedId eventGeneratedId = (EventGeneratedId) session.createQuery("FROM EventGeneratedId WHERE name LIKE '%John%'").list().get(0); eventGeneratedId.setName("Mike"); session.update(eventGeneratedId); session.flush(); session.refresh(eventGeneratedId); + session.close(); assertThat(eventGeneratedId.getName(), equalTo("John")); assertThat(eventGeneratedId.getId(), equalTo(1L)); } - // - private static void createEvent() { Event event = new Event(5L, "New Event", Sets.newHashSet("guest")); session.save(event); diff --git a/spring-jpa/pom.xml b/spring-jpa/pom.xml index 6a67d44b48..960dcbc588 100644 --- a/spring-jpa/pom.xml +++ b/spring-jpa/pom.xml @@ -113,6 +113,11 @@ guava ${guava.version} + + org.assertj + assertj-core + ${assertj.version} + @@ -180,6 +185,7 @@ 21.0 3.5 + 3.8.0 4.4.5 4.5.2 diff --git a/spring-jpa/src/main/java/org/baeldung/config/StudentJPAH2Config.java b/spring-jpa/src/main/java/org/baeldung/config/StudentJPAH2Config.java new file mode 100644 index 0000000000..439c6cb602 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/config/StudentJPAH2Config.java @@ -0,0 +1,69 @@ +package org.baeldung.config; + +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.baeldung.extended.persistence.dao.ExtendedRepositoryImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableJpaRepositories(basePackages = "org.baeldung.extended.persistence.dao", repositoryBaseClass = ExtendedRepositoryImpl.class) +@PropertySource("persistence-student-h2.properties") +@EnableTransactionManagement +public class StudentJPAH2Config { + + @Autowired + private Environment env; + + @Bean + public DataSource dataSource() { + final DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName")); + dataSource.setUrl(env.getProperty("jdbc.url")); + dataSource.setUsername(env.getProperty("jdbc.user")); + dataSource.setPassword(env.getProperty("jdbc.pass")); + + return dataSource; + } + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "org.baeldung.inmemory.persistence.model" }); + em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); + em.setJpaProperties(additionalProperties()); + return em; + } + + @Bean + JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) { + JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory); + return transactionManager; + } + + final Properties additionalProperties() { + final Properties hibernateProperties = new Properties(); + + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + hibernateProperties.setProperty("hibernate.show_sql", env.getProperty("hibernate.show_sql")); + hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", env.getProperty("hibernate.cache.use_second_level_cache")); + hibernateProperties.setProperty("hibernate.cache.use_query_cache", env.getProperty("hibernate.cache.use_query_cache")); + + return hibernateProperties; + } +} diff --git a/spring-jpa/src/main/java/org/baeldung/config/StudentJpaConfig.java b/spring-jpa/src/main/java/org/baeldung/config/StudentJpaConfig.java index a40f180a62..8021691716 100644 --- a/spring-jpa/src/main/java/org/baeldung/config/StudentJpaConfig.java +++ b/spring-jpa/src/main/java/org/baeldung/config/StudentJpaConfig.java @@ -18,7 +18,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration -@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") +@EnableJpaRepositories(basePackages = "org.baeldung.inmemory.persistence.dao") @PropertySource("persistence-student.properties") @EnableTransactionManagement public class StudentJpaConfig { @@ -41,7 +41,7 @@ public class StudentJpaConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); + em.setPackagesToScan(new String[] { "org.baeldung.inmemory.persistence.model" }); em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); em.setJpaProperties(additionalProperties()); return em; diff --git a/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedRepository.java b/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedRepository.java new file mode 100644 index 0000000000..9c9c12029a --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedRepository.java @@ -0,0 +1,12 @@ +package org.baeldung.extended.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.NoRepositoryBean; + +@NoRepositoryBean +public interface ExtendedRepository extends JpaRepository { + public List findByAttributeContainsText(String attributeName, String text); +} diff --git a/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedRepositoryImpl.java b/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedRepositoryImpl.java new file mode 100644 index 0000000000..0dd32757d7 --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedRepositoryImpl.java @@ -0,0 +1,36 @@ +package org.baeldung.extended.persistence.dao; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; + +import org.springframework.data.jpa.repository.support.JpaEntityInformation; +import org.springframework.data.jpa.repository.support.SimpleJpaRepository; + +public class ExtendedRepositoryImpl extends SimpleJpaRepository implements ExtendedRepository { + + private EntityManager entityManager; + + public ExtendedRepositoryImpl(JpaEntityInformation entityInformation, EntityManager entityManager) { + super(entityInformation, entityManager); + this.entityManager = entityManager; + } + + @Transactional + public List findByAttributeContainsText(String attributeName, String text) { + CriteriaBuilder builder = entityManager.getCriteriaBuilder(); + CriteriaQuery query = builder.createQuery(getDomainClass()); + Root root = query.from(getDomainClass()); + query.select(root) + .where(builder.like(root. get(attributeName), "%" + text + "%")); + TypedQuery q = entityManager.createQuery(query); + return q.getResultList(); + } + +} diff --git a/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedStudentRepository.java b/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedStudentRepository.java new file mode 100644 index 0000000000..7e2efc72bc --- /dev/null +++ b/spring-jpa/src/main/java/org/baeldung/extended/persistence/dao/ExtendedStudentRepository.java @@ -0,0 +1,6 @@ +package org.baeldung.extended.persistence.dao; + +import org.baeldung.inmemory.persistence.model.Student; + +public interface ExtendedStudentRepository extends ExtendedRepository { +} diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/dao/StudentRepository.java b/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/StudentRepository.java similarity index 57% rename from spring-jpa/src/main/java/org/baeldung/persistence/dao/StudentRepository.java rename to spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/StudentRepository.java index af484b442c..bfcf6f5cdc 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/dao/StudentRepository.java +++ b/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/dao/StudentRepository.java @@ -1,8 +1,7 @@ -package org.baeldung.persistence.dao; +package org.baeldung.inmemory.persistence.dao; +import org.baeldung.inmemory.persistence.model.Student; import org.springframework.data.jpa.repository.JpaRepository; -import org.baeldung.persistence.model.Student; - public interface StudentRepository extends JpaRepository { } diff --git a/spring-jpa/src/main/java/org/baeldung/persistence/model/Student.java b/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/Student.java similarity index 91% rename from spring-jpa/src/main/java/org/baeldung/persistence/model/Student.java rename to spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/Student.java index 437eeac5bb..b50fe9122e 100644 --- a/spring-jpa/src/main/java/org/baeldung/persistence/model/Student.java +++ b/spring-jpa/src/main/java/org/baeldung/inmemory/persistence/model/Student.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.model; +package org.baeldung.inmemory.persistence.model; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/spring-jpa/src/main/resources/persistence-student-h2.properties b/spring-jpa/src/main/resources/persistence-student-h2.properties new file mode 100644 index 0000000000..e1d6bfa45a --- /dev/null +++ b/spring-jpa/src/main/resources/persistence-student-h2.properties @@ -0,0 +1,12 @@ +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +jdbc.user=sa +# jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=true +hibernate.hbm2ddl.auto=create-drop +hibernate.cache.use_second_level_cache=false +hibernate.cache.use_query_cache=false \ No newline at end of file diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/repository/ExtendedStudentRepositoryIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/repository/ExtendedStudentRepositoryIntegrationTest.java new file mode 100644 index 0000000000..0970daa0ee --- /dev/null +++ b/spring-jpa/src/test/java/org/baeldung/persistence/repository/ExtendedStudentRepositoryIntegrationTest.java @@ -0,0 +1,39 @@ +package org.baeldung.persistence.repository; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import javax.annotation.Resource; + +import org.baeldung.config.StudentJPAH2Config; +import org.baeldung.extended.persistence.dao.ExtendedStudentRepository; +import org.baeldung.inmemory.persistence.model.Student; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { StudentJPAH2Config.class}) +public class ExtendedStudentRepositoryIntegrationTest { + @Resource + private ExtendedStudentRepository extendedStudentRepository; + + @Before + public void setup(){ + Student student = new Student(1, "john"); + extendedStudentRepository.save(student); + Student student2 = new Student(2, "johnson"); + extendedStudentRepository.save(student2); + Student student3 = new Student(3, "tom"); + extendedStudentRepository.save(student3); + } + + @Test + public void givenStudents_whenFindByName_thenGetOk(){ + List students = extendedStudentRepository.findByAttributeContainsText("name", "john"); + assertThat(students.size()).isEqualTo(2); + } +} diff --git a/spring-jpa/src/test/java/org/baeldung/persistence/repository/InMemoryDBIntegrationTest.java b/spring-jpa/src/test/java/org/baeldung/persistence/repository/InMemoryDBIntegrationTest.java index 1fcc4be45d..8380ab5434 100644 --- a/spring-jpa/src/test/java/org/baeldung/persistence/repository/InMemoryDBIntegrationTest.java +++ b/spring-jpa/src/test/java/org/baeldung/persistence/repository/InMemoryDBIntegrationTest.java @@ -1,8 +1,8 @@ package org.baeldung.persistence.repository; import org.baeldung.config.StudentJpaConfig; -import org.baeldung.persistence.dao.StudentRepository; -import org.baeldung.persistence.model.Student; +import org.baeldung.inmemory.persistence.dao.StudentRepository; +import org.baeldung.inmemory.persistence.model.Student; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; diff --git a/spring-mustache/README.md b/spring-mustache/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/spring-mustache/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/spring-mvc-kotlin/README.md b/spring-mvc-kotlin/README.md new file mode 100644 index 0000000000..c9bb78b6d8 --- /dev/null +++ b/spring-mvc-kotlin/README.md @@ -0,0 +1,2 @@ +### Relevant articles +- [Spring MVC Setup with Kotlin](http://www.baeldung.com/spring-mvc-kotlin) diff --git a/spring-mybatis/README.md b/spring-mybatis/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/spring-mybatis/README.md @@ -0,0 +1 @@ +## Relevant articles: diff --git a/spring-rest-angular/README.md b/spring-rest-angular/README.md index 3c1b418d95..dcbbd048ba 100644 --- a/spring-rest-angular/README.md +++ b/spring-rest-angular/README.md @@ -2,3 +2,4 @@ ### Relevant Articles: +- [Spring’s RequestBody and ResponseBody Annotations](http://www.baeldung.com/spring-request-response-body) diff --git a/spring-rest-simple/README.md b/spring-rest-simple/README.md new file mode 100644 index 0000000000..916676feb5 --- /dev/null +++ b/spring-rest-simple/README.md @@ -0,0 +1,7 @@ +## Relevant articles: + +- [Guide to UriComponentsBuilder in Spring](http://www.baeldung.com/spring-uricomponentsbuilder) +- [Returning Custom Status Codes from Spring Controllers](http://www.baeldung.com/spring-mvc-controller-custom-http-status-code) +- [The Guide to RestTemplate](http://www.baeldung.com/rest-template) +- [Spring RequestMapping](http://www.baeldung.com/spring-requestmapping) +- [ETags for REST with Spring](http://www.baeldung.com/etags-for-rest-with-spring) diff --git a/spring-security-mvc-custom/README.md b/spring-security-mvc-custom/README.md index 14bac6c454..2c0be4768e 100644 --- a/spring-security-mvc-custom/README.md +++ b/spring-security-mvc-custom/README.md @@ -8,7 +8,10 @@ The "REST With Spring" Classes: http://github.learnspringsecurity.com ### Relevant Articles: - [Spring Security Remember Me](http://www.baeldung.com/spring-security-remember-me) - [Redirect to different pages after Login with Spring Security](http://www.baeldung.com/spring_redirect_after_login) - +- [Changing Spring Model Parameters with Handler Interceptor](http://www.baeldung.com/spring-model-parameters-with-handler-interceptor) +- [Introduction to Spring MVC HandlerInterceptor](http://www.baeldung.com/spring-mvc-handlerinterceptor) +- [Using a Custom Spring MVC’s Handler Interceptor to Manage Sessions](http://www.baeldung.com/spring-mvc-custom-handler-interceptor) +- [A Guide to CSRF Protection in Spring Security](http://www.baeldung.com/spring-security-csrf) ### Build the Project ``` diff --git a/spring-security-mvc-custom/pom.xml b/spring-security-mvc-custom/pom.xml index 4a7e9419cc..805792b795 100644 --- a/spring-security-mvc-custom/pom.xml +++ b/spring-security-mvc-custom/pom.xml @@ -113,6 +113,40 @@ + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-databind.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + com.google.guava + guava + ${guava.version} + + + + + + org.springframework + spring-test + ${org.springframework.version} + test + + + + org.springframework.security + spring-security-test + ${org.springframework.security.version} + test + @@ -174,7 +208,8 @@ 19.0 3.5 - + 2.9.1 + 4.5.2 4.4.5 diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java index 2229516633..3b97afc22d 100644 --- a/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/spring/MvcConfig.java @@ -1,9 +1,14 @@ package org.baeldung.spring; +import org.baeldung.web.interceptor.LoggerInterceptor; +import org.baeldung.web.interceptor.SessionTimerInterceptor; +import org.baeldung.web.interceptor.UserInterceptor; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.view.InternalResourceViewResolver; @@ -11,6 +16,7 @@ import org.springframework.web.servlet.view.JstlView; @EnableWebMvc @Configuration +@ComponentScan("org.baeldung.web.controller") public class MvcConfig extends WebMvcConfigurerAdapter { public MvcConfig() { @@ -28,6 +34,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter { registry.addViewController("/login.html"); registry.addViewController("/homepage.html"); registry.addViewController("/console.html"); + registry.addViewController("/csrfHome.html"); } @Bean @@ -40,4 +47,11 @@ public class MvcConfig extends WebMvcConfigurerAdapter { return bean; } + + @Override + public void addInterceptors(final InterceptorRegistry registry) { + registry.addInterceptor(new LoggerInterceptor()); + registry.addInterceptor(new UserInterceptor()); + registry.addInterceptor(new SessionTimerInterceptor()); + } } \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/BankController.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/BankController.java similarity index 97% rename from spring-security-rest-full/src/main/java/org/baeldung/web/controller/BankController.java rename to spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/BankController.java index e87d5f3dd4..1a4322c611 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/BankController.java +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/BankController.java @@ -12,7 +12,6 @@ import org.springframework.web.bind.annotation.ResponseStatus; // to test csrf @Controller -@RequestMapping(value = "/auth/") public class BankController { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/FooController.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/FooController.java new file mode 100644 index 0000000000..5a3c85d220 --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/web/controller/FooController.java @@ -0,0 +1,59 @@ +package org.baeldung.web.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; + +import java.util.Arrays; +import java.util.List; + +import javax.servlet.http.HttpServletResponse; + +import org.baeldung.web.dto.Foo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.util.UriComponentsBuilder; + +@Controller +@RequestMapping(value = "/auth/foos") +public class FooController { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + public FooController() { + super(); + } + + // API + + // read - single + + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + @ResponseBody + public Foo findById(@PathVariable("id") final Long id, final UriComponentsBuilder uriBuilder, final HttpServletResponse response) { + return new Foo(randomAlphabetic(6)); + } + + // read - multiple + + @RequestMapping(method = RequestMethod.GET) + @ResponseBody + public List findAll() { + return Arrays.asList(new Foo(randomAlphabetic(6))); + } + + // write - just for test + @RequestMapping(method = RequestMethod.POST) + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + public Foo create(@RequestBody final Foo foo) { + return foo; + } +} \ No newline at end of file diff --git a/spring-security-mvc-custom/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/dto/Foo.java new file mode 100644 index 0000000000..02283e7df9 --- /dev/null +++ b/spring-security-mvc-custom/src/main/java/org/baeldung/web/dto/Foo.java @@ -0,0 +1,80 @@ +package org.baeldung.web.dto; + +import java.io.Serializable; + +public class Foo implements Serializable { + + private long id; + + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + + this.name = name; + } + + // API + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + // + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=") + .append(name) + .append("]"); + return builder.toString(); + } + +} \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/LoggerInterceptor.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/interceptor/LoggerInterceptor.java similarity index 100% rename from spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/LoggerInterceptor.java rename to spring-security-mvc-custom/src/main/java/org/baeldung/web/interceptor/LoggerInterceptor.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/SessionTimerInterceptor.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/interceptor/SessionTimerInterceptor.java similarity index 100% rename from spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/SessionTimerInterceptor.java rename to spring-security-mvc-custom/src/main/java/org/baeldung/web/interceptor/SessionTimerInterceptor.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/UserInterceptor.java b/spring-security-mvc-custom/src/main/java/org/baeldung/web/interceptor/UserInterceptor.java similarity index 100% rename from spring-security-rest-full/src/main/java/org/baeldung/web/interceptor/UserInterceptor.java rename to spring-security-mvc-custom/src/main/java/org/baeldung/web/interceptor/UserInterceptor.java diff --git a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml index f31f36655c..f2ecaba5c8 100644 --- a/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml +++ b/spring-security-mvc-custom/src/main/resources/webSecurityConfig.xml @@ -33,4 +33,8 @@ + + \ No newline at end of file diff --git a/spring-security-rest-full/src/main/webapp/WEB-INF/view/csrfHome.jsp b/spring-security-mvc-custom/src/main/webapp/WEB-INF/view/csrfHome.jsp similarity index 100% rename from spring-security-rest-full/src/main/webapp/WEB-INF/view/csrfHome.jsp rename to spring-security-mvc-custom/src/main/webapp/WEB-INF/view/csrfHome.jsp diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java b/spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java similarity index 93% rename from spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java rename to spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java index 6e70f979c8..44424bf7f9 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfAbstractIntegrationTest.java @@ -5,7 +5,7 @@ import static org.springframework.security.test.web.servlet.request.SecurityMock import javax.servlet.Filter; -import org.baeldung.persistence.model.Foo; +import org.baeldung.web.dto.Foo; import org.junit.Before; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -14,15 +14,15 @@ import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.RequestPostProcessor; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.WebApplicationContext; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; + + @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@Transactional public abstract class CsrfAbstractIntegrationTest { @Autowired diff --git a/spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfDisabledIntegrationTest.java b/spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfDisabledIntegrationTest.java new file mode 100644 index 0000000000..1d16e08514 --- /dev/null +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfDisabledIntegrationTest.java @@ -0,0 +1,25 @@ +package org.baeldung.security.csrf; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.baeldung.security.spring.SecurityWithoutCsrfConfig; +import org.baeldung.spring.MvcConfig; +import org.junit.Test; +import org.springframework.http.MediaType; +import org.springframework.test.context.ContextConfiguration; + +@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, MvcConfig.class }) +public class CsrfDisabledIntegrationTest extends CsrfAbstractIntegrationTest { + + @Test + public void givenNotAuth_whenAddFoo_thenUnauthorized() throws Exception { + mvc.perform(post("/auth/foos").contentType(MediaType.APPLICATION_JSON).content(createFoo())).andExpect(status().isUnauthorized()); + } + + @Test + public void givenAuth_whenAddFoo_thenCreated() throws Exception { + mvc.perform(post("/auth/foos").contentType(MediaType.APPLICATION_JSON).content(createFoo()).with(testUser())).andExpect(status().isCreated()); + } + +} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java b/spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java similarity index 90% rename from spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java rename to spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java index 939b745de8..9d882973bd 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/security/csrf/CsrfEnabledIntegrationTest.java @@ -5,13 +5,12 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.baeldung.security.spring.SecurityWithCsrfConfig; -import org.baeldung.spring.PersistenceConfig; -import org.baeldung.spring.WebConfig; +import org.baeldung.spring.MvcConfig; import org.junit.Test; import org.springframework.http.MediaType; import org.springframework.test.context.ContextConfiguration; -@ContextConfiguration(classes = { SecurityWithCsrfConfig.class, PersistenceConfig.class, WebConfig.class }) +@ContextConfiguration(classes = { SecurityWithCsrfConfig.class, MvcConfig.class }) public class CsrfEnabledIntegrationTest extends CsrfAbstractIntegrationTest { @Test diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/spring/SecurityWithCsrfConfig.java b/spring-security-mvc-custom/src/test/java/org/baeldung/security/spring/SecurityWithCsrfConfig.java similarity index 82% rename from spring-security-rest-full/src/test/java/org/baeldung/security/spring/SecurityWithCsrfConfig.java rename to spring-security-mvc-custom/src/test/java/org/baeldung/security/spring/SecurityWithCsrfConfig.java index 97ae1f1dd2..9600977e37 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/security/spring/SecurityWithCsrfConfig.java +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/security/spring/SecurityWithCsrfConfig.java @@ -1,8 +1,5 @@ package org.baeldung.security.spring; -import org.baeldung.web.error.CustomAccessDeniedHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; @@ -12,14 +9,10 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @Configuration -@EnableAutoConfiguration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityWithCsrfConfig extends WebSecurityConfigurerAdapter { - @Autowired - private CustomAccessDeniedHandler accessDeniedHandler; - public SecurityWithCsrfConfig() { super(); } @@ -46,8 +39,6 @@ public class SecurityWithCsrfConfig extends WebSecurityConfigurerAdapter { .and() .httpBasic() .and() - .exceptionHandling().accessDeniedHandler(accessDeniedHandler) - .and() .headers().cacheControl().disable() ; // @formatter:on diff --git a/spring-security-rest-full/src/main/java/org/baeldung/security/spring/SecurityWithoutCsrfConfig.java b/spring-security-mvc-custom/src/test/java/org/baeldung/security/spring/SecurityWithoutCsrfConfig.java similarity index 72% rename from spring-security-rest-full/src/main/java/org/baeldung/security/spring/SecurityWithoutCsrfConfig.java rename to spring-security-mvc-custom/src/test/java/org/baeldung/security/spring/SecurityWithoutCsrfConfig.java index f1a78d1472..f7dbd5b42c 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/security/spring/SecurityWithoutCsrfConfig.java +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/security/spring/SecurityWithoutCsrfConfig.java @@ -1,8 +1,5 @@ package org.baeldung.security.spring; -import org.baeldung.web.error.CustomAccessDeniedHandler; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; @@ -12,16 +9,10 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @Configuration -@EnableAutoConfiguration -// @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) -// @ImportResource({ "classpath:webSecurityConfig.xml" }) public class SecurityWithoutCsrfConfig extends WebSecurityConfigurerAdapter { - @Autowired - private CustomAccessDeniedHandler accessDeniedHandler; - public SecurityWithoutCsrfConfig() { super(); } @@ -42,18 +33,15 @@ public class SecurityWithoutCsrfConfig extends WebSecurityConfigurerAdapter { protected void configure(final HttpSecurity http) throws Exception { // @formatter:off http - .csrf().disable() .authorizeRequests() - .antMatchers("/auth/admin/*").hasRole("ADMIN") - .antMatchers("/auth/*").hasAnyRole("ADMIN","USER") - .antMatchers("/*").permitAll() + .antMatchers("/auth/admin/*").hasAnyRole("ROLE_ADMIN") + .anyRequest().authenticated() .and() .httpBasic() .and() - // .exceptionHandling().accessDeniedPage("/my-error-page") - .exceptionHandling().accessDeniedHandler(accessDeniedHandler) - .and() .headers().cacheControl().disable() + .and() + .csrf().disable() ; // @formatter:on } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java b/spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java similarity index 83% rename from spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java rename to spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java index 44dc860e62..c33c9a04e8 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/LoggerInterceptorIntegrationTest.java @@ -4,8 +4,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.baeldung.security.spring.SecurityWithoutCsrfConfig; -import org.baeldung.spring.PersistenceConfig; -import org.baeldung.spring.WebConfig; +import org.baeldung.spring.MvcConfig; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,13 +15,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@Transactional -@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, PersistenceConfig.class, WebConfig.class }) +@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, MvcConfig.class }) public class LoggerInterceptorIntegrationTest { @Autowired @@ -46,7 +43,8 @@ public class LoggerInterceptorIntegrationTest { */ @Test public void testInterceptors() throws Exception { - mockMvc.perform(get("/graph.html")).andExpect(status().isOk()); + mockMvc.perform(get("/login.html")) + .andExpect(status().isOk()); } } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorIntegrationTest.java b/spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorIntegrationTest.java similarity index 78% rename from spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorIntegrationTest.java rename to spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorIntegrationTest.java index d62fab0670..bdc1be2c44 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorIntegrationTest.java +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/SessionTimerInterceptorIntegrationTest.java @@ -6,8 +6,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import javax.servlet.http.HttpSession; import org.baeldung.security.spring.SecurityWithoutCsrfConfig; -import org.baeldung.spring.PersistenceConfig; -import org.baeldung.spring.WebConfig; +import org.baeldung.spring.MvcConfig; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,13 +19,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@Transactional -@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, PersistenceConfig.class, WebConfig.class }) +@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, MvcConfig.class }) @WithMockUser(username = "admin", roles = { "USER", "ADMIN" }) public class SessionTimerInterceptorIntegrationTest { @@ -47,9 +44,14 @@ public class SessionTimerInterceptorIntegrationTest { */ @Test public void testInterceptors() throws Exception { - HttpSession session = mockMvc.perform(get("/auth/admin")).andExpect(status().is2xxSuccessful()).andReturn().getRequest().getSession(); + HttpSession session = mockMvc.perform(get("/auth/foos")) + .andExpect(status().is2xxSuccessful()) + .andReturn() + .getRequest() + .getSession(); Thread.sleep(51000); - mockMvc.perform(get("/auth/admin").session((MockHttpSession) session)).andExpect(status().is2xxSuccessful()); + mockMvc.perform(get("/auth/foos").session((MockHttpSession) session)) + .andExpect(status().is2xxSuccessful()); } } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/UserInterceptorIntegrationTest.java b/spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/UserInterceptorIntegrationTest.java similarity index 84% rename from spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/UserInterceptorIntegrationTest.java rename to spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/UserInterceptorIntegrationTest.java index f995f86145..a85fd999a6 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/interceptor/UserInterceptorIntegrationTest.java +++ b/spring-security-mvc-custom/src/test/java/org/baeldung/web/interceptor/UserInterceptorIntegrationTest.java @@ -1,8 +1,10 @@ package org.baeldung.web.interceptor; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + import org.baeldung.security.spring.SecurityWithoutCsrfConfig; -import org.baeldung.spring.PersistenceConfig; -import org.baeldung.spring.WebConfig; +import org.baeldung.spring.MvcConfig; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,16 +16,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.WebApplicationContext; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@Transactional -@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, PersistenceConfig.class, WebConfig.class }) +@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, MvcConfig.class }) @WithMockUser(username = "admin", roles = { "USER", "ADMIN" }) public class UserInterceptorIntegrationTest { @@ -46,7 +43,8 @@ public class UserInterceptorIntegrationTest { */ @Test public void testInterceptors() throws Exception { - mockMvc.perform(get("/auth/admin")).andExpect(status().is2xxSuccessful()); + mockMvc.perform(get("/auth/foos")) + .andExpect(status().is2xxSuccessful()); } } diff --git a/spring-security-rest-full/.springBeans b/spring-security-rest-full/.springBeans index f100c6afbe..b01040d91b 100644 --- a/spring-security-rest-full/.springBeans +++ b/spring-security-rest-full/.springBeans @@ -1,18 +1,16 @@ 1 - + - java:org.baeldung.security.spring.SecurityWithoutCsrfConfig src/main/webapp/WEB-INF/api-servlet.xml java:org.baeldung.spring.Application - java:org.baeldung.security.spring.SecurityWithCsrfConfig diff --git a/spring-security-rest-full/README.md b/spring-security-rest-full/README.md index d5bd8be52b..2737bd5465 100644 --- a/spring-security-rest-full/README.md +++ b/spring-security-rest-full/README.md @@ -8,12 +8,10 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring The "Learn Spring Security" Classes: http://github.learnspringsecurity.com ### Relevant Articles: -- [Spring Security Expressions - hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) - [REST Pagination in Spring](http://www.baeldung.com/2012/01/18/rest-pagination-in-spring/) - [HATEOAS for a Spring REST Service](http://www.baeldung.com/2011/11/13/rest-service-discoverability-with-spring-part-5/) - [REST API Discoverability and HATEOAS](http://www.baeldung.com/2011/11/06/restful-web-service-discoverability-part-4/) - [ETags for REST with Spring](http://www.baeldung.com/2013/01/11/etags-for-rest-with-spring/) -- [Error Handling for REST with Spring 3](http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/) - [Integration Testing with the Maven Cargo plugin](http://www.baeldung.com/2011/10/16/how-to-set-up-integration-testing-with-the-maven-cargo-plugin/) - [Introduction to Spring Data JPA](http://www.baeldung.com/2011/12/22/the-persistence-layer-with-spring-data-jpa/) - [Project Configuration with Spring](http://www.baeldung.com/2012/03/12/project-configuration-with-spring/) @@ -24,11 +22,6 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [Metrics for your Spring REST API](http://www.baeldung.com/spring-rest-api-metrics) - [REST Query Language with RSQL](http://www.baeldung.com/rest-api-search-language-rsql-fiql) - [Spring RestTemplate Tutorial](http://www.baeldung.com/rest-template) -- [A Guide to CSRF Protection in Spring Security](http://www.baeldung.com/spring-security-csrf) -- [Intro to Spring Security Expressions](http://www.baeldung.com/spring-security-expressions) -- [Changing Spring Model Parameters with Handler Interceptor](http://www.baeldung.com/spring-model-parameters-with-handler-interceptor) -- [Introduction to Spring MVC HandlerInterceptor](http://www.baeldung.com/spring-mvc-handlerinterceptor) -- [Using a Custom Spring MVC’s Handler Interceptor to Manage Sessions](http://www.baeldung.com/spring-mvc-custom-handler-interceptor) - [Bootstrap a Web Application with Spring 4](http://www.baeldung.com/bootstraping-a-web-application-with-spring-and-java-based-configuration) - [REST Query Language – Implementing OR Operation](http://www.baeldung.com/rest-api-query-search-or-operation) diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index 2b559ddefc..12a611431e 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -38,17 +38,6 @@ provided - - - - org.springframework.security - spring-security-web - - - org.springframework.security - spring-security-config - - @@ -220,10 +209,6 @@ test - - org.springframework.security - spring-security-test - diff --git a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java index 49f9ec7e97..376082b2d5 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/persistence/service/impl/FooService.java @@ -10,7 +10,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -36,6 +35,7 @@ public class FooService extends AbstractService implements IFooService { // custom methods + @Override public Foo retrieveByName(final String name) { return dao.retrieveByName(name); } @@ -44,7 +44,6 @@ public class FooService extends AbstractService implements IFooService { @Override @Transactional(readOnly = true) - @PreAuthorize("hasRole('ROLE_ADMIN')") public List findAll() { return Lists.newArrayList(getDao().findAll()); } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java index efdb2bc8d4..86cb93175a 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/WebConfig.java @@ -1,14 +1,10 @@ package org.baeldung.spring; -import org.baeldung.web.interceptor.LoggerInterceptor; -import org.baeldung.web.interceptor.SessionTimerInterceptor; -import org.baeldung.web.interceptor.UserInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.view.InternalResourceViewResolver; @@ -35,15 +31,7 @@ public class WebConfig extends WebMvcConfigurerAdapter { public void addViewControllers(final ViewControllerRegistry registry) { super.addViewControllers(registry); registry.addViewController("/graph.html"); - registry.addViewController("/csrfHome.html"); registry.addViewController("/homepage.html"); } - @Override - public void addInterceptors(final InterceptorRegistry registry) { - registry.addInterceptor(new LoggerInterceptor()); - registry.addInterceptor(new UserInterceptor()); - registry.addInterceptor(new SessionTimerInterceptor()); - } - } \ No newline at end of file diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java index 8b63275b66..e23da6420d 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/controller/RootController.java @@ -11,7 +11,6 @@ import org.baeldung.web.metric.IMetricService; import org.baeldung.web.util.LinkUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -53,7 +52,6 @@ public class RootController { return metricService.getFullMetric(); } - @PreAuthorize("hasRole('ROLE_ADMIN')") @RequestMapping(value = "/status-metric", method = RequestMethod.GET) @ResponseBody public Map getStatusMetric() { @@ -70,16 +68,5 @@ public class RootController { return result; } - @RequestMapping(value = "/admin/x", method = RequestMethod.GET) - @ResponseBody - public String sampleAdminPage() { - return "Hello"; - } - - @RequestMapping(value = "/my-error-page", method = RequestMethod.GET) - @ResponseBody - public String sampleErrorPage() { - return "Error Occurred"; - } } diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java index e9d34aa9cf..b593116c4a 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -11,13 +11,11 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.security.access.AccessDeniedException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; -//import org.springframework.security.access.AccessDeniedException; @ControllerAdvice public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { @@ -55,12 +53,6 @@ public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionH return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); } - // 403 - @ExceptionHandler({ AccessDeniedException.class }) - public ResponseEntity handleAccessDeniedException(final Exception ex, final WebRequest request) { - System.out.println("request" + request.getUserPrincipal()); - return new ResponseEntity("Access denied message here", new HttpHeaders(), HttpStatus.FORBIDDEN); - } // 404 diff --git a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml b/spring-security-rest-full/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index be6b4d0c27..0000000000 --- a/spring-security-rest-full/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-rest-full/src/test/java/org/baeldung/TestSuite.java b/spring-security-rest-full/src/test/java/org/baeldung/TestSuite.java index 52e3607b12..cd5fa4661f 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/TestSuite.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/TestSuite.java @@ -1,7 +1,6 @@ package org.baeldung; import org.baeldung.persistence.PersistenceTestSuite; -import org.baeldung.security.SecurityTestSuite; import org.baeldung.web.LiveTestSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -10,7 +9,6 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ // @formatter:off PersistenceTestSuite.class - ,SecurityTestSuite.class ,LiveTestSuite.class }) // public class TestSuite { diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/SecurityTestSuite.java b/spring-security-rest-full/src/test/java/org/baeldung/security/SecurityTestSuite.java deleted file mode 100644 index 8b754a03ff..0000000000 --- a/spring-security-rest-full/src/test/java/org/baeldung/security/SecurityTestSuite.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.baeldung.security; - -import org.baeldung.security.csrf.CsrfDisabledIntegrationTest; -import org.baeldung.security.csrf.CsrfEnabledIntegrationTest; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ - // @formatter:off - CsrfEnabledIntegrationTest.class - ,CsrfDisabledIntegrationTest.class -}) // -public class SecurityTestSuite { - -} diff --git a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfDisabledIntegrationTest.java b/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfDisabledIntegrationTest.java deleted file mode 100644 index e06461fc2c..0000000000 --- a/spring-security-rest-full/src/test/java/org/baeldung/security/csrf/CsrfDisabledIntegrationTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.baeldung.security.csrf; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import org.baeldung.security.spring.SecurityWithoutCsrfConfig; -import org.baeldung.spring.PersistenceConfig; -import org.baeldung.spring.WebConfig; -import org.junit.Test; -import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; - -@ContextConfiguration(classes = { SecurityWithoutCsrfConfig.class, PersistenceConfig.class, WebConfig.class }) -public class CsrfDisabledIntegrationTest extends CsrfAbstractIntegrationTest { - - @Test - public void givenNotAuth_whenAddFoo_thenUnauthorized() throws Exception { - mvc.perform(post("/auth/foos").contentType(MediaType.APPLICATION_JSON).content(createFoo())).andExpect(status().isUnauthorized()); - } - - @Test - public void givenAuth_whenAddFoo_thenCreated() throws Exception { - mvc.perform(post("/auth/foos").contentType(MediaType.APPLICATION_JSON).content(createFoo()).with(testUser())).andExpect(status().isCreated()); - } - - @Test - public void accessMainPageWithoutAuthorization() throws Exception { - mvc.perform(get("/graph.html").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()); - } - - @Test - public void accessOtherPages() throws Exception { - mvc.perform(get("/auth/transfer").contentType(MediaType.APPLICATION_JSON).param("accountNo", "1").param("amount", "100")).andExpect(status().isUnauthorized()); // without authorization - mvc.perform(get("/auth/transfer").contentType(MediaType.APPLICATION_JSON).param("accountNo", "1").param("amount", "100").with(testUser())).andExpect(status().isOk()); // with authorization - } - - @Test - public void accessAdminPage() throws Exception { - mvc.perform(get("/auth/admin/x").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isUnauthorized()); // without authorization - mvc.perform(get("/auth/admin/x").contentType(MediaType.APPLICATION_JSON).with(testAdmin())).andExpect(status().isOk()); // with authorization - } - -} diff --git a/spring-security-rest/README.md b/spring-security-rest/README.md index 92b759a66a..5898ba248e 100644 --- a/spring-security-rest/README.md +++ b/spring-security-rest/README.md @@ -14,3 +14,6 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [An Intro to Spring HATEOAS](http://www.baeldung.com/spring-hateoas-tutorial) - [Spring Security Context Propagation with @Async](http://www.baeldung.com/spring-security-async-principal-propagation) - [Servlet 3 Async Support with Spring MVC and Spring Security](http://www.baeldung.com/spring-mvc-async-security) +- [Intro to Spring Security Expressions](http://www.baeldung.com/spring-security-expressions) +- [Spring Security Expressions - hasRole Example](http://www.baeldung.com/spring-security-expressions-basic) +- [Error Handling for REST with Spring 3](http://www.baeldung.com/2013/01/31/exception-handling-for-rest-with-spring-3-2/) diff --git a/spring-security-rest/pom.xml b/spring-security-rest/pom.xml index 13db431ae3..e4bb071a6a 100644 --- a/spring-security-rest/pom.xml +++ b/spring-security-rest/pom.xml @@ -28,7 +28,7 @@ spring-security-config ${org.springframework.security.version} - + diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java index 2dbc9b8f08..c3e738297a 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/SecurityJavaConfig.java @@ -1,10 +1,13 @@ package org.baeldung.spring; import org.baeldung.security.MySavedRequestAwareAuthenticationSuccessHandler; +import org.baeldung.web.error.CustomAccessDeniedHandler; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @@ -13,9 +16,13 @@ import org.springframework.security.web.authentication.SimpleUrlAuthenticationFa @Configuration @EnableWebSecurity +@EnableGlobalMethodSecurity(prePostEnabled = true) @ComponentScan("org.baeldung.security") public class SecurityJavaConfig extends WebSecurityConfigurerAdapter { + @Autowired + private CustomAccessDeniedHandler accessDeniedHandler; + // @Autowired // private RestAuthenticationEntryPoint restAuthenticationEntryPoint; @@ -40,14 +47,15 @@ public class SecurityJavaConfig extends WebSecurityConfigurerAdapter { .csrf().disable() .authorizeRequests() .and() - .exceptionHandling() -// .authenticationEntryPoint(restAuthenticationEntryPoint) + .exceptionHandling().accessDeniedHandler(accessDeniedHandler) + // .authenticationEntryPoint(restAuthenticationEntryPoint) .and() .authorizeRequests() .antMatchers("/api/csrfAttacker*").permitAll() .antMatchers("/api/customer/**").permitAll() .antMatchers("/api/foos/**").authenticated() .antMatchers("/api/async/**").permitAll() + .antMatchers("/api/admin/**").hasRole("ADMIN") .and() .httpBasic() // .and() diff --git a/spring-security-rest/src/main/java/org/baeldung/spring/SwaggerConfig.java b/spring-security-rest/src/main/java/org/baeldung/spring/SwaggerConfig.java index 00ccb36666..bcf6657eee 100644 --- a/spring-security-rest/src/main/java/org/baeldung/spring/SwaggerConfig.java +++ b/spring-security-rest/src/main/java/org/baeldung/spring/SwaggerConfig.java @@ -1,19 +1,23 @@ package org.baeldung.spring; +import static com.google.common.collect.Lists.newArrayList; + +import java.util.Collections; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.bind.annotation.RequestMethod; + import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.ResponseMessageBuilder; import springfox.documentation.schema.ModelRef; import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; -import static com.google.common.collect.Lists.newArrayList; - @Configuration @EnableSwagger2 public class SwaggerConfig { @@ -25,7 +29,7 @@ public class SwaggerConfig { } private ApiInfo apiInfo() { - ApiInfo apiInfo = new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", "myeaddress@company.com", "License of API", "API license URL"); + ApiInfo apiInfo = new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", new Contact("John Doe", "www.example.com", "myeaddress@company.com"), "License of API", "API license URL", Collections.emptyList()); return apiInfo; } } diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/RootController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/RootController.java new file mode 100644 index 0000000000..4253ed7a59 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/RootController.java @@ -0,0 +1,30 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class RootController { + + public RootController() { + super(); + } + + // API + + @RequestMapping(value = "/admin/x", method = RequestMethod.GET) + @ResponseBody + public String sampleAdminPage() { + return "Hello"; + } + + + @RequestMapping(value = "/my-error-page", method = RequestMethod.GET) + @ResponseBody + public String sampleErrorPage() { + return "Error Occurred"; + } + +} diff --git a/spring-security-rest-full/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java b/spring-security-rest/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java similarity index 100% rename from spring-security-rest-full/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java rename to spring-security-rest/src/main/java/org/baeldung/web/error/CustomAccessDeniedHandler.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-security-rest/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java new file mode 100644 index 0000000000..9ff4f040fe --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/error/RestResponseEntityExceptionHandler.java @@ -0,0 +1,74 @@ +package org.baeldung.web.error; + +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.InvalidDataAccessApiUsageException; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.context.request.WebRequest; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +//import org.springframework.security.access.AccessDeniedException; + +@ControllerAdvice +public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { + + public RestResponseEntityExceptionHandler() { + super(); + } + + // API + + // 400 + + @ExceptionHandler({ DataIntegrityViolationException.class }) + public ResponseEntity handleBadRequest(final DataIntegrityViolationException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.BAD_REQUEST, request); + } + + @Override + protected ResponseEntity handleHttpMessageNotReadable(final HttpMessageNotReadableException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + // ex.getCause() instanceof JsonMappingException, JsonParseException // for additional information later on + return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); + } + + @Override + protected ResponseEntity handleMethodArgumentNotValid(final MethodArgumentNotValidException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, headers, HttpStatus.BAD_REQUEST, request); + } + + // 403 + @ExceptionHandler({ AccessDeniedException.class }) + public ResponseEntity handleAccessDeniedException(final Exception ex, final WebRequest request) { + System.out.println("request" + request.getUserPrincipal()); + return new ResponseEntity("Access denied message here", new HttpHeaders(), HttpStatus.FORBIDDEN); + } + + // 409 + + @ExceptionHandler({ InvalidDataAccessApiUsageException.class, DataAccessException.class }) + protected ResponseEntity handleConflict(final RuntimeException ex, final WebRequest request) { + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.CONFLICT, request); + } + + // 412 + + // 500 + + @ExceptionHandler({ NullPointerException.class, IllegalArgumentException.class, IllegalStateException.class }) + /*500*/public ResponseEntity handleInternal(final RuntimeException ex, final WebRequest request) { + logger.error("500 Status Code", ex); + final String bodyOfResponse = "This should be application specific"; + return handleExceptionInternal(ex, bodyOfResponse, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR, request); + } + +} diff --git a/spring-security-rest/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java b/spring-security-rest/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java new file mode 100644 index 0000000000..14b61f9832 --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/exception/MyResourceNotFoundException.java @@ -0,0 +1,21 @@ +package org.baeldung.web.exception; + +public final class MyResourceNotFoundException extends RuntimeException { + + public MyResourceNotFoundException() { + super(); + } + + public MyResourceNotFoundException(final String message, final Throwable cause) { + super(message, cause); + } + + public MyResourceNotFoundException(final String message) { + super(message); + } + + public MyResourceNotFoundException(final Throwable cause) { + super(cause); + } + +} diff --git a/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-rest/src/main/resources/webSecurityConfig.xml index a260460d76..4bb208a195 100644 --- a/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -10,6 +10,8 @@ http://www.springframework.org/schema/beans/spring-beans-4.2.xsd"> + + @@ -17,6 +19,11 @@ + + + + + @@ -30,8 +37,12 @@ + + + + \ No newline at end of file diff --git a/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java b/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java index 0ef50f745a..0a53da674a 100644 --- a/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java +++ b/spring-security-rest/src/test/java/org/baeldung/web/FooLiveTest.java @@ -17,17 +17,20 @@ import com.jayway.restassured.specification.RequestSpecification; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { TestConfig.class }, loader = AnnotationConfigContextLoader.class) public class FooLiveTest { - private static final String URL_PREFIX = "http://localhost:8082/spring-security-rest"; + private static final String URL_PREFIX = "http://localhost:8080/spring-security-rest"; // private FormAuthConfig formConfig = new FormAuthConfig(URL_PREFIX + "/login", "temporary", "temporary"); private String cookie; private RequestSpecification givenAuth() { // return RestAssured.given().auth().form("user", "userPass", formConfig); - if (cookie == null) { - cookie = RestAssured.given().contentType("application/x-www-form-urlencoded").formParam("password", "userPass").formParam("username", "user").post(URL_PREFIX + "/login").getCookie("JSESSIONID"); - } - return RestAssured.given().cookie("JSESSIONID", cookie); + // if (cookie == null) { + // cookie = RestAssured.given().contentType("application/x-www-form-urlencoded").formParam("password", "userPass").formParam("username", "user").post(URL_PREFIX + "/login").getCookie("JSESSIONID"); + // } + // return RestAssured.given().cookie("JSESSIONID", cookie); + return RestAssured.given() + .auth() + .basic("user", "userPass"); } @Test diff --git a/spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java b/spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java index cf1516f8e1..792b3e28ce 100644 --- a/spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java +++ b/spring-security-rest/src/test/java/org/baeldung/web/SwaggerLiveTest.java @@ -8,7 +8,7 @@ import com.jayway.restassured.RestAssured; import com.jayway.restassured.response.Response; public class SwaggerLiveTest { - private static final String URL_PREFIX = "http://localhost:8082/spring-security-rest/api"; + private static final String URL_PREFIX = "http://localhost:8080/spring-security-rest/api"; @Test public void whenVerifySpringFoxIsWorking_thenOK() { diff --git a/spring-swagger-codegen/README.md b/spring-swagger-codegen/README.md new file mode 100644 index 0000000000..ee6b240c30 --- /dev/null +++ b/spring-swagger-codegen/README.md @@ -0,0 +1,3 @@ +### Relevant articles + +- [Generate Spring Boot REST Client with Swagger](http://www.baeldung.com/spring-boot-rest-client-swagger-codegen) diff --git a/testing/README.md b/testing/README.md index 3171b67b60..889f6706d4 100644 --- a/testing/README.md +++ b/testing/README.md @@ -14,4 +14,4 @@ - [Introduction to JUnitParams](http://www.baeldung.com/junit-params) - [Cucumber Java 8 Support](http://www.baeldung.com/cucumber-java-8-support) - [Introduction to Lambda Behave](http://www.baeldung.com/lambda-behave) - +- [Introduction to Jukito](http://www.baeldung.com/jukito) diff --git a/vaadin/README.md b/vaadin/README.md new file mode 100644 index 0000000000..0dfeea8996 --- /dev/null +++ b/vaadin/README.md @@ -0,0 +1,3 @@ +## Relevant articles: + +- [Introduction to Vaadin](http://www.baeldung.com/vaadin) diff --git a/vavr/README.md b/vavr/README.md index 24b8c5a615..4361363fbd 100644 --- a/vavr/README.md +++ b/vavr/README.md @@ -5,4 +5,6 @@ - [Property Testing Example With Vavr](http://www.baeldung.com/javaslang-property-testing) - [Exceptions in Lambda Expression Using Vavr](http://www.baeldung.com/exceptions-using-vavr) - [Vavr (ex-Javaslang) Support in Spring Data](http://www.baeldung.com/spring-vavr) +- [Introduction to Vavr’s Validation API](http://www.baeldung.com/vavr-validation-api) +- [Guide to Collections API in Vavr](http://www.baeldung.com/vavr-collections) - [Collection Factory Methods for Vavr](http://www.baeldung.com/vavr-collection-factory-methods) diff --git a/vertx-and-rxjava/README.md b/vertx-and-rxjava/README.md new file mode 100644 index 0000000000..ccd4ce3457 --- /dev/null +++ b/vertx-and-rxjava/README.md @@ -0,0 +1,2 @@ +### Relevant articles +- [Example of Vertx and RxJava Integration](http://www.baeldung.com/vertx-rx-java) diff --git a/video-tutorials/README.md b/video-tutorials/README.md new file mode 100644 index 0000000000..ff12555376 --- /dev/null +++ b/video-tutorials/README.md @@ -0,0 +1 @@ +## Relevant articles: