Repository: Dierk/GroovyInAction Branch: master Commit: 7affde058fa9 Files: 719 Total size: 676.3 KB Directory structure: gitextract_qrfoz67k/ ├── .idea/ │ └── vcs.xml ├── LICENSE ├── README.md ├── alltests.groovy ├── listings/ │ ├── allsources.txt │ ├── appD/ │ │ ├── Listing_D_01_GStrings.groovy │ │ ├── Listing_D_02_Lists.groovy │ │ ├── Listing_D_03_Closures.groovy │ │ ├── Listing_D_04_Regex.groovy │ │ └── Listing_D_05_GPath.groovy │ ├── chap01/ │ │ ├── Listing_01_01_Gold.groovy │ │ ├── customers.xml │ │ ├── data.txt │ │ ├── groovysh.txt │ │ ├── snippet0101_customers.groovy │ │ ├── snippet0101_fileLineNumbers.groovy │ │ ├── snippet0101_newDates.txt │ │ ├── snippet0101_printPackageNames.groovy │ │ ├── snippet0101_printPackageNamesGpath.groovy │ │ ├── snippet0102_printGroovyWebSiteCount.groovy │ │ └── snippet0103_googleIpAdr.groovy │ ├── chap02/ │ │ ├── Book.groovy │ │ ├── Listing_02_01_Assertions.groovy │ │ ├── Listing_02_02_Book.txt │ │ ├── Listing_02_03_BookScript.groovy │ │ ├── Listing_02_04_BookBean.groovy │ │ ├── Listing_02_05_ImmutableBook.groovy │ │ ├── Listing_02_06_Grab.groovy │ │ ├── Listing_02_07_Clinks.groovy │ │ ├── Listing_02_08_ControlStructures.groovy │ │ ├── snippet0201_comments.groovy │ │ ├── snippet0202_failing_assert.groovy │ │ ├── snippet0202_failing_assertion_error.txt │ │ ├── snippet0203_clinks_java.groovy │ │ ├── snippet0203_gstring.groovy │ │ ├── snippet0203_int_usage.groovy │ │ ├── snippet0203_map_usage.groovy │ │ ├── snippet0203_range_usage.groovy │ │ ├── snippet0203_roman.groovy │ │ ├── snippet0204_evaluate_jdk7_only.groovy │ │ ├── snippet0204_evaluate_jdk8_only.groovy │ │ └── snippet0204_failing_typechecked.groovy │ ├── chap03/ │ │ ├── ArrayListSummer.java │ │ ├── Listing_03_01_PrimitiveMethodsObjectOperators.groovy │ │ ├── Listing_03_02_ListMapCast.groovy │ │ ├── Listing_03_03_DefiningOperators.groovy │ │ ├── Listing_03_04_DefiningGStrings.groovy │ │ ├── Listing_03_05_StringOperations.groovy │ │ ├── Listing_03_06_RegexGStrings.groovy │ │ ├── Listing_03_07_RegularExpressions.groovy │ │ ├── Listing_03_08_EachMatch.groovy │ │ ├── Listing_03_09_PatternReuse.groovy │ │ ├── Listing_03_10_PatternsClassification.groovy │ │ ├── Listing_03_11_NumberMethodsGDK.groovy │ │ ├── extra_escaped_characters_table36.groovy │ │ ├── extra_method_operators_table34.groovy │ │ ├── extra_numeric_literals_table32.groovy │ │ ├── extra_numerical_coercion_table310.groovy │ │ ├── extra_optional_typing_table33.groovy │ │ ├── extra_primitive_values_table31.groovy │ │ ├── regex_dgm.txt │ │ ├── snippet0301_autoboxing.groovy │ │ ├── snippet0304_GString_internals.groovy │ │ ├── snippet0304_stringbuffer.groovy │ │ ├── snippet0305_matcher_each_group.groovy │ │ ├── snippet0305_matcher_groups.groovy │ │ ├── snippet0305_matcher_parallel_assignment.groovy │ │ ├── snippet0305_matcher_plain.groovy │ │ └── snippet0306_GDK_methods_for_numbers.groovy │ ├── chap04/ │ │ ├── Listing_04_01_range_declarations.groovy │ │ ├── Listing_04_02_ranges_are_objects.groovy │ │ ├── Listing_04_03_custom_ranges.groovy │ │ ├── Listing_04_04_list_declarations.groovy │ │ ├── Listing_04_05_list_subscript_operator.groovy │ │ ├── Listing_04_06_list_add_remove.groovy │ │ ├── Listing_04_07_lists_control_structures.groovy │ │ ├── Listing_04_08_list_content_manipulation.groovy │ │ ├── Listing_04_09_list_other_methods.groovy │ │ ├── Listing_04_10_list_quicksort.groovy │ │ ├── Listing_04_11_list_mapreduce.groovy │ │ ├── Listing_04_12_map_declarations.groovy │ │ ├── Listing_04_13_map_accessors.groovy │ │ ├── Listing_04_14_map_query_methods.groovy │ │ ├── Listing_04_15_map_iteration.groovy │ │ ├── Listing_04_16_map_content.groovy │ │ ├── Listing_04_17_map_example.groovy │ │ ├── extra_EnumRange.groovy │ │ ├── extra_ListCast.groovy │ │ ├── extra_ListTable.groovy │ │ ├── extra_Map_as.groovy │ │ ├── extra_Map_group.groovy │ │ ├── extra_MaxMinSum.groovy │ │ ├── extra_SplitList.groovy │ │ ├── snippet0402_ListAsSet.groovy │ │ ├── snippet0402_ListRemoveNulls.groovy │ │ ├── snippet0402_ListStreams_jdk8_plus.groovy │ │ ├── snippet0403_Map_Ctor_Expression.groovy │ │ ├── snippet0403_Map_Ctor_Unquoted.groovy │ │ ├── snippet0403_Map_MapReduce.groovy │ │ └── snippet0403_Map_String_accessors.groovy │ ├── chap05/ │ │ ├── Listing_05_01_closure_simple_declaration.groovy │ │ ├── Listing_05_02_simple_method_closure.groovy │ │ ├── Listing_05_03_multi_method_closure.groovy │ │ ├── Listing_05_04_closure_all_declarations.groovy │ │ ├── Listing_05_05_simple_closure_calling.groovy │ │ ├── Listing_05_06_calling_closures.groovy │ │ ├── Listing_05_07_simple_currying.groovy │ │ ├── Listing_05_08_logging_curry_example.groovy │ │ ├── Listing_05_09_closure_scope.groovy │ │ ├── Listing_05_10_closure_accumulator.groovy │ │ ├── Listing_05_11_visitor_pattern.groovy │ │ ├── extra_ClosureProperty.groovy │ │ ├── extra_Closure_delegate.groovy │ │ ├── extra_Closure_myWith.groovy │ │ ├── snippet0501_envelope.groovy.txt │ │ ├── snippet0504_closure_default_params.groovy │ │ ├── snippet0504_closure_isCase.groovy │ │ ├── snippet0504_closure_paramcount.groovy │ │ ├── snippet0505_map_with.groovy │ │ ├── snippet0505_scoping.groovy │ │ ├── snippet0506_closure_return.groovy │ │ ├── snippet0507_closure_composition.groovy │ │ ├── snippet0508_memoize.groovy │ │ └── snippet0509_trampoline.groovy │ ├── chap06/ │ │ ├── Listing_06_01_groovy_truth.groovy │ │ ├── Listing_06_02_assignment_bug.groovy │ │ ├── Listing_06_03_if_then_else.groovy │ │ ├── Listing_06_04_conditional_operator.groovy │ │ ├── Listing_06_05_switch_basic.groovy │ │ ├── Listing_06_06_switch_advanced.groovy │ │ ├── Listing_06_07_assert_host.groovy │ │ ├── Listing_06_08_while.groovy │ │ ├── Listing_06_09_for.groovy │ │ ├── Listing_06_10_break_continue.groovy │ │ ├── Listing_06_11_exception_example.groovy │ │ ├── extra_if_return.groovy │ │ ├── extra_in_operator.groovy │ │ ├── extra_switch_return.groovy │ │ ├── myFileName.txt │ │ ├── snippet0602_bad_file_read.groovy │ │ ├── snippet0602_bad_file_read_with_message.groovy │ │ ├── snippet0602_failing_assert.groovy │ │ ├── snippet0603_each_loop_iterate.groovy │ │ ├── snippet0603_file_iterate_lines.groovy │ │ ├── snippet0603_for_loop_iterate.groovy │ │ ├── snippet0603_null_iterate.groovy │ │ ├── snippet0603_object_iterate.groovy │ │ ├── snippet0603_regex_iterate_match.groovy │ │ └── snippet0604_multicatch.groovy │ ├── chap07/ │ │ ├── Listing_07_01_Declaring_Variables.groovy │ │ ├── Listing_07_02_TypeBreaking_Assignment.groovy │ │ ├── Listing_07_03_Referencing_Fields.groovy │ │ ├── Listing_07_04_Overriding_Field_Access.groovy │ │ ├── Listing_07_05_Declaring_Methods.groovy │ │ ├── Listing_07_06_Declaring_Parameters.groovy │ │ ├── Listing_07_07_Parameter_Usages.groovy │ │ ├── Listing_07_08_Safe_Dereferencing.groovy │ │ ├── Listing_07_09_Instantiation.groovy │ │ ├── Listing_07_10_Instantiation_Named.groovy │ │ ├── Listing_07_11_Classes.groovy │ │ ├── Listing_07_13_Import.groovy │ │ ├── Listing_07_14_Import_As_BugFix.groovy │ │ ├── Listing_07_15_Import_As_NameClash.groovy │ │ ├── Listing_07_16_Multimethods.groovy │ │ ├── Listing_07_17_MultiEquals.groovy │ │ ├── Listing_07_18_Traits.groovy │ │ ├── Listing_07_19_Declaring_Beans.groovy │ │ ├── Listing_07_20_Calling_Beans.groovy │ │ ├── Listing_07_21_Calling_Beans_Advanced.groovy │ │ ├── Listing_07_22_Property_Methods.groovy │ │ ├── Listing_07_23_Expando.groovy │ │ ├── Listing_07_24_GPath.groovy │ │ ├── business/ │ │ │ └── Vendor.groovy │ │ ├── snippet0703_Implicit_Closure_To_SAM.groovy │ │ ├── snippet0705_Spread_List.groovy │ │ ├── snippet0705_Spread_Map.groovy │ │ ├── snippet0705_Spread_Range.groovy │ │ ├── thirdparty/ │ │ │ └── MathLib.groovy │ │ └── thirdparty2/ │ │ └── MathLib.groovy │ ├── chap08/ │ │ ├── Listing_08_01_method_missing.groovy │ │ ├── Listing_08_02_mini_gorm.groovy │ │ ├── Listing_08_03_property_missing.groovy │ │ ├── Listing_08_04_bin_property.groovy │ │ ├── Listing_08_05_closure_dynamic.groovy │ │ ├── Listing_08_06_property_method.groovy │ │ ├── Listing_08_07_MetaClass_jdk7_only.groovy │ │ ├── Listing_08_07_MetaClass_jdk8_plus.groovy │ │ ├── Listing_08_08_ProxyMetaClass.groovy │ │ ├── Listing_08_09_Expando.groovy │ │ ├── Listing_08_10_EMC.groovy │ │ ├── Listing_08_11_EMC_Groovy_Class.groovy │ │ ├── Listing_08_12_EMC_Groovy_Object.groovy │ │ ├── Listing_08_13_EMC_Java_Object.groovy │ │ ├── Listing_08_14_EMC_Builder.groovy │ │ ├── Listing_08_15_EMC_static.groovy │ │ ├── Listing_08_16_EMC_super.groovy │ │ ├── Listing_08_17_EMC_hooks.groovy │ │ ├── Listing_08_18_Existing_Categories.groovy │ │ ├── Listing_08_19_Marshal.groovy │ │ ├── Listing_08_20_MarshalCategory.groovy │ │ ├── Listing_08_21_Test_Mixin.groovy │ │ ├── Listing_08_22_Sieve_Mixin.groovy │ │ ├── Listing_08_23_Millimeter.groovy │ │ ├── Listing_08_24_create_factory.groovy │ │ ├── Listing_08_25_fake_assign.groovy │ │ ├── Listing_08_26_restore_emc.groovy │ │ ├── Listing_08_27_intercept_cache_invoke.groovy │ │ ├── custom/ │ │ │ ├── Custom.groovy │ │ │ └── useCustom.groovy │ │ ├── failing_Listing_08_15_EMC_static.groovy │ │ ├── failing_Listing_08_16_EMC_super.groovy │ │ ├── groovy/ │ │ │ └── runtime/ │ │ │ └── metaclass/ │ │ │ └── custom/ │ │ │ └── CustomMetaClass.groovy │ │ └── markup.html │ ├── chap09/ │ │ ├── .gradle/ │ │ │ └── 2.2.1/ │ │ │ └── taskArtifacts/ │ │ │ └── cache.properties │ │ ├── Listing_09_01_ToStringDetective.groovy │ │ ├── Listing_09_02_ToStringSleuth.groovy │ │ ├── Listing_09_03_EqualsAndHashCode.groovy │ │ ├── Listing_09_04_TupleConstructor.groovy │ │ ├── Listing_09_05_Lazy.groovy │ │ ├── Listing_09_06_IndexedProperty.groovy │ │ ├── Listing_09_07_InheritConstructors.groovy │ │ ├── Listing_09_08_Sortable.groovy │ │ ├── Listing_09_09_Builder.groovy │ │ ├── Listing_09_10_Canonical.groovy │ │ ├── Listing_09_11_Immutable.groovy │ │ ├── Listing_09_12_Delegate.groovy │ │ ├── Listing_09_13_Singleton.groovy │ │ ├── Listing_09_14_Memoized.groovy │ │ ├── Listing_09_15_TailRecursive.groovy │ │ ├── Listing_09_16_Log.groovy │ │ ├── Listing_09_17_Synchronized.groovy │ │ ├── Listing_09_18_SynchronizedCustomLock.groovy │ │ ├── Listing_09_19_ReadWriteLock.groovy │ │ ├── Listing_09_20_AutoClone.groovy │ │ ├── Listing_09_21_AutoCloneCopyConstructor.groovy │ │ ├── Listing_09_22_AutoExternalize.groovy │ │ ├── Listing_09_23_TimedInterrupt.groovy │ │ ├── Listing_09_24_ThreadInterrupt.groovy │ │ ├── Listing_09_25_ConditionalInterrupt.groovy │ │ ├── Listing_09_26_Field.groovy │ │ ├── Listing_09_27_BaseScript.groovy │ │ ├── Listing_09_28_AstByHand.groovy │ │ ├── Listing_09_29_AstByHandWithUtils.groovy │ │ ├── Listing_09_30_AstBuildFromSpec.groovy │ │ ├── Listing_09_31_AstBuildFromString.groovy │ │ ├── Listing_09_32_AstBuildFromStringMixed.groovy │ │ ├── Listing_09_33_AstBuildFromCode.groovy │ │ ├── Listing_09_34_GreeterMainTransform.groovy │ │ ├── Listing_09_35_GreeterMainTransform2.groovy │ │ ├── Listing_09_38_AstTesting1.groovy │ │ ├── Listing_09_39_AstTesting2.groovy │ │ ├── Listing_09_40_AstTesting3.groovy │ │ ├── Listing_09_41_AstTesting4.groovy │ │ ├── Listing_09_42_AstTesting5.groovy │ │ ├── Listings.txt │ │ ├── build/ │ │ │ ├── reports/ │ │ │ │ └── tests/ │ │ │ │ ├── classes/ │ │ │ │ │ └── regina.CompiledAtASTTransformationTest.html │ │ │ │ ├── css/ │ │ │ │ │ ├── base-style.css │ │ │ │ │ └── style.css │ │ │ │ ├── index.html │ │ │ │ ├── js/ │ │ │ │ │ └── report.js │ │ │ │ └── packages/ │ │ │ │ └── regina.html │ │ │ ├── resources/ │ │ │ │ └── main/ │ │ │ │ └── META-INF/ │ │ │ │ └── services/ │ │ │ │ └── org.codehaus.groovy.transform.ASTTransformation │ │ │ └── test-results/ │ │ │ ├── TEST-regina.CompiledAtASTTransformationTest.xml │ │ │ └── binary/ │ │ │ └── test/ │ │ │ └── output.bin.idx │ │ ├── build.gradle │ │ ├── gradle/ │ │ │ └── wrapper/ │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ │ ├── gradle.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── settings.gradle │ │ ├── snippet0902_autoCloneDefault.txt │ │ ├── snippet0902_autoCloneSerialization.txt │ │ ├── snippet0902_autoExternalize.txt │ │ ├── snippet0902_fieldEquivalent.txt │ │ ├── snippet0902_mapCreation.txt │ │ ├── snippet0902_noisySetDelegateByHand.txt │ │ ├── snippet0902_noisySetInheritance.txt │ │ ├── snippet0902_nonTailCallReverseList.txt │ │ ├── snippet0902_readWriteByHand.txt │ │ ├── snippet0902_readWriteLock.txt │ │ ├── snippet0902_singletonByHand.txt │ │ ├── snippet0902_toStringEquivalent.txt │ │ ├── snippet0903_greeterExpanded.txt │ │ ├── snippet0903_greeterScript.txt │ │ ├── snippet0903_localMain.txt │ │ ├── snippet0903_localMainTransformation.txt │ │ ├── snippet0905_GetCompiledTimeScript.txt │ │ └── src/ │ │ ├── main/ │ │ │ ├── groovy/ │ │ │ │ └── regina/ │ │ │ │ └── CompiledAtASTTransformation.groovy │ │ │ └── resources/ │ │ │ └── META-INF/ │ │ │ └── services/ │ │ │ └── org.codehaus.groovy.transform.ASTTransformation │ │ └── test/ │ │ └── groovy/ │ │ └── regina/ │ │ └── CompiledAtASTTransformationTest.groovy │ ├── chap10/ │ │ ├── Greeter.java │ │ ├── Listing_10_01_Duck.groovy │ │ ├── Listing_10_02_failing_Typo.groovy │ │ ├── Listing_10_03_ClassTC.groovy │ │ ├── Listing_10_04_OneMethodTC.groovy │ │ ├── Listing_10_05_CompileTimeTypo.groovy │ │ ├── Listing_10_06_MethodNameTypo.groovy │ │ ├── Listing_10_07_MethodArgsFlipped.groovy │ │ ├── Listing_10_08_InvalidAssignments.groovy │ │ ├── Listing_10_09_AssignmentsWithCoercion.groovy │ │ ├── Listing_10_10_DefField.groovy │ │ ├── Listing_10_11_InPlaceList.groovy │ │ ├── Listing_10_12_Generics.groovy │ │ ├── Listing_10_13_ListStyleCtorRuntime.groovy │ │ ├── Listing_10_14_ListStyleCtorTC.groovy │ │ ├── Listing_10_15_MapStyleCtorBad.groovy │ │ ├── Listing_10_16_ListStyleCtor.groovy │ │ ├── Listing_10_17_ListStyleCtorFixed.groovy │ │ ├── Listing_10_18_CodeAsData.groovy │ │ ├── Listing_10_19_ClosuresBadReturnType.groovy │ │ ├── Listing_10_20_UserValidation.groovy │ │ ├── Listing_10_21_UserValidationTC.groovy │ │ ├── Listing_10_22_UserValidation_ExplicitTypes.groovy │ │ ├── Listing_10_23_UserValidation_SAM.groovy │ │ ├── Listing_10_24_UserValidation_ClosureParams.groovy │ │ ├── Listing_10_25_UserValidation_DSL.groovy │ │ ├── Listing_10_26_UserValidation_DelegatesTo.groovy │ │ ├── Listing_10_27_UserValidation_DelegatesToTarget.groovy │ │ ├── Listing_10_28_Category.groovy │ │ ├── Listing_10_29_EMC.groovy │ │ ├── Listing_10_30_Builder.groovy │ │ ├── Listing_10_31_MixedTypeChecking.groovy │ │ ├── Listing_10_32_Skip.groovy │ │ ├── Listing_10_33_FlowTyping.groovy │ │ ├── Listing_10_34_FlowTypingOk.groovy │ │ ├── Listing_10_35_LUB.groovy │ │ ├── Listing_10_36_Condition.groovy │ │ ├── Listing_10_37_ClosureSharedVar.groovy │ │ ├── Listing_10_38_LubError.groovy │ │ ├── Listing_10_39_LubOk.groovy │ │ ├── Listing_10_40_FibBench.groovy │ │ ├── Listing_10_41_JavaGreeter.txt │ │ ├── Listing_10_42_StaticCompileDispatch.groovy │ │ ├── Listing_10_43_MonkeyPatching.groovy │ │ ├── Listing_10_44_BookingDSL.groovy │ │ ├── Listing_10_45_MultiValidation.groovy │ │ ├── Listing_10_46_RobotExtension.groovy │ │ ├── Listing_10_47_SQLExtension.groovy │ │ ├── User.groovy │ │ ├── extra1004_JavaDispatch.java │ │ ├── extra1004_RuntimeGroovyDispatch.groovy │ │ ├── markup.html │ │ ├── snippet1003_GroovyGreeter.groovy │ │ ├── snippet1005_RobotMainTC.groovy │ │ └── snippet1005_SqlMainTC.groovy │ ├── chap11/ │ │ ├── Listing_11_01_SquaresFactors.xml │ │ ├── Listing_11_02_SquaresFactors.java │ │ ├── Listing_11_03_MarkupBuilderPlain.groovy │ │ ├── Listing_11_04_NodeBuilder.groovy │ │ ├── Listing_11_05_NodeBuilderLogic.groovy │ │ ├── Listing_11_06_MarkupBuilderLogic.groovy │ │ ├── Listing_11_07_MarkupBuilderHtml.groovy │ │ ├── Listing_11_08_StreamingMarkupBuilderLogic.groovy │ │ ├── Listing_11_09_ExampleBuild.xml │ │ ├── Listing_11_10_PW_SwingBuilder.groovy │ │ ├── Listing_11_11_Swing_Widgets.groovy │ │ ├── Listing_11_12_Swing_Layout.groovy │ │ ├── Listing_11_13_Table_Demo.groovy │ │ ├── Listing_11_14_Binding.groovy │ │ ├── Listing_11_15_Plotter.groovy │ │ ├── Listing_11_16_Groovyfx.groovy │ │ ├── Listing_11_17_CalorieCounterBuilderSupport.groovy │ │ ├── Listing_11_18_CalorieCounterFactoryBuilderSupport.groovy │ │ ├── Listing_11_19_CalorieCounterByHand.groovy │ │ ├── markup.html │ │ ├── snippet1103_MarkupBuilderOutput.html │ │ ├── snippet1103_MarkupWithHyphen.groovy │ │ ├── snippet1106_AntBuilderIf.groovy │ │ ├── snippet1106_AntIf.xml │ │ ├── snippet1107_Printer.groovy │ │ └── snippet1107_binding.txt │ ├── chap12/ │ │ ├── Listing_12_01_info_jdk6_only.groovy │ │ ├── Listing_12_01_info_jdk7_only.groovy │ │ ├── Listing_12_01_info_jdk8_plus.groovy │ │ ├── Listing_12_02_properties.groovy │ │ ├── Listing_12_03_File_Iteration.groovy │ │ ├── Listing_12_04_Filesystem.groovy │ │ ├── Listing_12_05_Traversal.groovy │ │ ├── Listing_12_06_File_Read.groovy │ │ ├── Listing_12_07_File_Write.groovy │ │ ├── Listing_12_08_Writer_LeftShift.groovy │ │ ├── Listing_12_09_File_Transform_jdk7_plus.groovy │ │ ├── Listing_12_10_File_ObjectStreams.groovy │ │ ├── Listing_12_11_Temp_Dir.groovy │ │ ├── Listing_12_12_Threads.groovy │ │ ├── Listing_12_13_Processes_UnixCommands.groovy │ │ ├── Listing_12_14_Processes_ZipUnzip.groovy │ │ ├── Listing_12_15_SimpleTemplateEngine.groovy │ │ ├── Listing_12_16_GroovletExample.groovy │ │ ├── Listing_12_17_HelloWorldGroovlet.groovy │ │ ├── Listing_12_19_InspectGroovlet.groovy │ │ ├── Listing_12_20_HiLowGame.groovy │ │ ├── Listing_12_21_NumberTemplate.txt │ │ ├── Listing_12_22_TemplateGroovlet.groovy │ │ ├── Number.template.html │ │ ├── data/ │ │ │ └── example.txt │ │ ├── objects.dta │ │ ├── snippet1201_SlowTyping.groovy │ │ ├── snippet1201_UseCategory.groovy │ │ ├── snippet1202_base64.groovy │ │ └── web.xml │ ├── chap13/ │ │ ├── Listing_13_01_Connecting.groovy │ │ ├── Listing_13_02_ConnectingDataSource.groovy │ │ ├── Listing_13_03_Creating.groovy │ │ ├── Listing_13_04_DbUtilClass.txt │ │ ├── Listing_13_05_Inserting.groovy │ │ ├── Listing_13_06_Reading.groovy │ │ ├── Listing_13_07_Updating.groovy │ │ ├── Listing_13_08_Delete.groovy │ │ ├── Listing_13_09_Transactions.groovy │ │ ├── Listing_13_10_Batching.groovy │ │ ├── Listing_13_11_Paging.groovy │ │ ├── Listing_13_12_Metadata.groovy │ │ ├── Listing_13_13_MoreMetadata.groovy │ │ ├── Listing_13_14_NamedOrdinal.groovy │ │ ├── Listing_13_15_StoredProcBasic.groovy │ │ ├── Listing_13_16_StoredProcParam.groovy │ │ ├── Listing_13_17_StoredProcInOut.groovy │ │ ├── Listing_13_18_DataSetBasics.groovy │ │ ├── Listing_13_19_DataSetFiltering.groovy │ │ ├── Listing_13_20_DataSetViews.groovy │ │ ├── Listing_13_21_DbHelper.txt │ │ ├── Listing_13_22_DataAccessObject.txt │ │ ├── Listing_13_23_AthleteDAO.txt │ │ ├── Listing_13_24_AthleteApplication.txt │ │ ├── Listing_13_25_AthleteAppMain.groovy │ │ ├── Listing_13_26_AthleteAppTest.groovy │ │ ├── Listing_13_27_MongoAthletes.groovy │ │ ├── Listing_13_28_NeoAthletes.groovy │ │ ├── Listing_13_29_NeoGremlin.groovy │ │ ├── extra_NeoGremlinGraph.groovy │ │ ├── layering/ │ │ │ ├── AthleteApplication.groovy │ │ │ ├── AthleteDAO.groovy │ │ │ ├── DataAccessObject.groovy │ │ │ └── DbHelper.groovy │ │ ├── marathon/ │ │ │ ├── active_tx_log │ │ │ ├── index/ │ │ │ │ ├── lucene.log.active │ │ │ │ ├── lucene.log.v0 │ │ │ │ ├── lucene.log.v1 │ │ │ │ ├── lucene.log.v2 │ │ │ │ ├── lucene.log.v3 │ │ │ │ ├── lucene.log.v4 │ │ │ │ ├── lucene.log.v5 │ │ │ │ ├── lucene.log.v6 │ │ │ │ ├── lucene.log.v7 │ │ │ │ └── lucene.log.v8 │ │ │ ├── messages.log │ │ │ ├── neostore │ │ │ ├── neostore.id │ │ │ ├── neostore.labeltokenstore.db.id │ │ │ ├── neostore.labeltokenstore.db.names │ │ │ ├── neostore.labeltokenstore.db.names.id │ │ │ ├── neostore.nodestore.db.id │ │ │ ├── neostore.nodestore.db.labels │ │ │ ├── neostore.nodestore.db.labels.id │ │ │ ├── neostore.propertystore.db.arrays │ │ │ ├── neostore.propertystore.db.arrays.id │ │ │ ├── neostore.propertystore.db.id │ │ │ ├── neostore.propertystore.db.index │ │ │ ├── neostore.propertystore.db.index.id │ │ │ ├── neostore.propertystore.db.index.keys │ │ │ ├── neostore.propertystore.db.index.keys.id │ │ │ ├── neostore.propertystore.db.strings │ │ │ ├── neostore.propertystore.db.strings.id │ │ │ ├── neostore.relationshipgroupstore.db.id │ │ │ ├── neostore.relationshipstore.db.id │ │ │ ├── neostore.relationshiptypestore.db.id │ │ │ ├── neostore.relationshiptypestore.db.names │ │ │ ├── neostore.relationshiptypestore.db.names.id │ │ │ ├── neostore.schemastore.db.id │ │ │ ├── nioneo_logical.log.active │ │ │ ├── nioneo_logical.log.v6 │ │ │ ├── nioneo_logical.log.v7 │ │ │ ├── nioneo_logical.log.v8 │ │ │ ├── schema/ │ │ │ │ └── label/ │ │ │ │ └── lucene/ │ │ │ │ ├── segments.gen │ │ │ │ └── segments_1 │ │ │ ├── store_lock │ │ │ └── tm_tx_log.1 │ │ ├── snippet1301_ConnectingWithGrab.groovy │ │ ├── snippet1301_ConnectingWithInstance.groovy │ │ ├── snippet1301_ConnectingWithMap.groovy │ │ ├── snippet1301_ReadEachRow.groovy │ │ ├── snippet1301_ReadEachRowList.groovy │ │ ├── snippet1301_ReadQuery.groovy │ │ ├── snippet1301_ReadRows.groovy │ │ └── util/ │ │ ├── DbUtil.groovy │ │ ├── MarathonRelationships.groovy │ │ └── Neo4jUtil.groovy │ ├── chap14/ │ │ ├── Listing_14_01_Plan.txt │ │ ├── Listing_14_02_DOM.groovy │ │ ├── Listing_14_03_DOM_Category.groovy │ │ ├── Listing_14_04_XmlParser.groovy │ │ ├── Listing_14_05_XmlSlurper.groovy │ │ ├── Listing_14_06_SAX.groovy │ │ ├── Listing_14_07_StAX.groovy │ │ ├── Listing_14_08_XmlBoiler.groovy │ │ ├── Listing_14_09_XmlStreamer.groovy │ │ ├── Listing_14_10_StreamedHtml.groovy │ │ ├── Listing_14_11_UpdateDomCategory.groovy │ │ ├── Listing_14_12_UpdateParser.groovy │ │ ├── Listing_14_13_UpdateSlurper.groovy │ │ ├── Listing_14_14_XPath.groovy │ │ ├── Listing_14_15_GroovyPlansTemplate.txt │ │ ├── Listing_14_16_XPathTemplate.groovy │ │ ├── Listing_14_17_JsonParser.groovy │ │ ├── Listing_14_18_JsonBuilder.groovy │ │ ├── Listing_14_19_JsonBuilderLogic.groovy │ │ ├── Listing_14_20_JsonOutputAthlete.groovy │ │ ├── UpdateChecker.groovy │ │ ├── data/ │ │ │ ├── GroovyPlans.html │ │ │ ├── GroovyPlans.template.html │ │ │ ├── StreamedGroovyPlans.html │ │ │ ├── XPathGroovyPlans.html │ │ │ ├── plan.json │ │ │ ├── plan.xml │ │ │ └── style.css │ │ └── log4j.xml │ ├── chap15/ │ │ ├── Listing_15_01_RSS_bbcnews.groovy │ │ ├── Listing_15_02_ATOM_devworks.groovy │ │ ├── Listing_15_03_REST_jira_url.groovy │ │ ├── Listing_15_04_REST_jira_httpb_get.groovy │ │ ├── Listing_15_05_REST_currency_httpb_get.groovy │ │ ├── Listing_15_06_REST_currency_httpb_post.groovy │ │ ├── Listing_15_07_REST_currency_jaxrs.groovy │ │ ├── Listing_15_08_REST_currency_jaxrs_proxy.groovy │ │ ├── Listing_15_09_XMLRPC_echo.groovy │ │ ├── Listing_15_10_XMLRPC_jira.groovy │ │ ├── Listing_15_11_SOAP_wsdl.groovy │ │ ├── Listing_15_12_SOAP11_currency_url.groovy │ │ ├── Listing_15_13_SOAP12_currency_httpb.groovy │ │ ├── Listing_15_14_SOAP11_currency_wslite.groovy │ │ ├── Listing_15_15_SOAP12_currency_wslite.groovy │ │ └── data/ │ │ └── conv.templ.xml │ ├── chap16/ │ │ ├── HelloIntegrationWorld.java │ │ ├── Listing_16_01_HelloIntegration.groovy │ │ ├── Listing_16_02_HelloIntegrationJava.txt │ │ ├── Listing_16_03_MultilineScript.groovy │ │ ├── Listing_16_04_UsingEval.groovy │ │ ├── Listing_16_05_Binding.groovy │ │ ├── Listing_16_06_BindingTwoWay.groovy │ │ ├── Listing_16_07_ClassInScript.groovy │ │ ├── Listing_16_08_Payment_calculator.groovy │ │ ├── Listing_16_09_MethodsInBinding.groovy │ │ ├── Listing_16_10_ShapeInfoMain.txt │ │ ├── Listing_16_11_SpringConfig.txt │ │ ├── Listing_16_12_BeanToString.groovy │ │ ├── shapes/ │ │ │ ├── Circle.groovy │ │ │ ├── MaxAreaInfo.groovy │ │ │ ├── MaxPerimeterInfo.java │ │ │ ├── Shape.java │ │ │ ├── ShapeInfo.java │ │ │ ├── ShapeInfoMain.java │ │ │ └── Square.java │ │ └── spring/ │ │ ├── common/ │ │ │ ├── Shape.java │ │ │ └── ShapeInfo.java │ │ ├── groovy/ │ │ │ ├── Circle.groovy │ │ │ └── MaxAreaInfo.groovy │ │ ├── java/ │ │ │ ├── MaxPerimeterInfo.java │ │ │ ├── ShapeInfoFactoryMain.java │ │ │ ├── ShapeInfoMain.java │ │ │ ├── ShapeInfoSpringMain.java │ │ │ └── Square.java │ │ ├── lib/ │ │ │ ├── commons-logging.jar │ │ │ ├── spring-beans.jar │ │ │ ├── spring-core.jar │ │ │ └── spring.jar │ │ └── resources/ │ │ └── beans.xml │ ├── chap17/ │ │ ├── .classpath │ │ ├── .project │ │ ├── Converter.groovy │ │ ├── Counter.groovy │ │ ├── Farm.groovy │ │ ├── Listing_17_01_Celsius.groovy │ │ ├── Listing_17_02_CounterTest.groovy │ │ ├── Listing_17_03_HashMapTest.groovy │ │ ├── Listing_17_04_GroovyTestSuite.groovy │ │ ├── Listing_17_05_AllTestSuite.groovy │ │ ├── Listing_17_06_DataDrivenJUnitTest.groovy │ │ ├── Listing_17_07_PropertyBased.groovy │ │ ├── Listing_17_08_Balancer.groovy │ │ ├── Listing_17_09_BalancerStub.groovy │ │ ├── Listing_17_10_BalancerMock.groovy │ │ ├── Listing_17_11_LoggingCounterTest.groovy │ │ ├── Listing_17_12_JUnitPerf.groovy │ │ ├── Listing_17_13_SpockSimple.groovy │ │ ├── Listing_17_14_SpockMock.groovy │ │ ├── Listing_17_15_SpockMockWildcards.groovy │ │ ├── Listing_17_16_SpockMockClosureChecks.groovy │ │ ├── Listing_17_17_SpockDataDriven.groovy │ │ ├── LoggingCounter.groovy │ │ ├── MovieTheater.groovy │ │ ├── Purchase.groovy │ │ ├── automation/ │ │ │ ├── build.gradle │ │ │ ├── gradle/ │ │ │ │ └── wrapper/ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── gradlew │ │ │ ├── gradlew.bat │ │ │ ├── pom.xml │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ └── groovy/ │ │ │ │ └── Calculator.groovy │ │ │ └── test/ │ │ │ └── groovy/ │ │ │ └── CalculatorTest.groovy │ │ ├── cobertura/ │ │ │ ├── build.gradle │ │ │ ├── gradle/ │ │ │ │ └── wrapper/ │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ │ ├── gradlew │ │ │ ├── gradlew.bat │ │ │ └── src/ │ │ │ ├── main/ │ │ │ │ └── groovy/ │ │ │ │ ├── BiggestPairCalc.groovy │ │ │ │ └── BiggestPairCalcFixed.groovy │ │ │ └── test/ │ │ │ └── groovy/ │ │ │ └── BiggestPairCalcTest.groovy │ │ ├── extra_ParameterizedTestNG.groovy │ │ ├── extra_TestNG.groovy │ │ ├── snippet1701_JUnit4.groovy │ │ ├── snippet1704_listPropertyCheck.groovy │ │ └── test-output/ │ │ ├── Command line suite/ │ │ │ ├── Command line test.html │ │ │ └── Command line test.xml │ │ ├── emailable-report.html │ │ ├── index.html │ │ ├── junitreports/ │ │ │ ├── TEST-extra_ParameterizedTestNG.xml │ │ │ └── TEST-extra_TestNG.xml │ │ ├── old/ │ │ │ ├── Command line suite/ │ │ │ │ ├── Command line test.properties │ │ │ │ ├── classes.html │ │ │ │ ├── groups.html │ │ │ │ ├── index.html │ │ │ │ ├── main.html │ │ │ │ ├── methods-alphabetical.html │ │ │ │ ├── methods-not-run.html │ │ │ │ ├── methods.html │ │ │ │ ├── reporter-output.html │ │ │ │ ├── testng.xml.html │ │ │ │ └── toc.html │ │ │ └── index.html │ │ ├── testng-reports.css │ │ ├── testng-reports.js │ │ ├── testng-results.xml │ │ └── testng.css │ ├── chap18/ │ │ ├── Listing_18_01_ConcurrentSquares.groovy │ │ ├── Listing_18_02_ConcurrentSquaresTransparent.groovy │ │ ├── Listing_18_03_ConcurrentSquaresTransitive.groovy │ │ ├── Listing_18_04_MapFilterReduce.groovy │ │ ├── Listing_18_05_SquaresMapReduce.groovy │ │ ├── Listing_18_06_Dataflow.groovy │ │ ├── Listing_18_07_DataflowStreams.groovy │ │ ├── Listing_18_08_Actors.groovy │ │ ├── Listing_18_09_ActorsLifecycle.groovy │ │ ├── Listing_18_10_ActorsMessageAware.groovy │ │ ├── Listing_18_11_Agent.groovy │ │ ├── Listing_18_12.txt │ │ ├── Listing_18_13_YahooForkJoin.groovy │ │ ├── Listing_18_14_YahooMapReduce.groovy │ │ ├── Listing_18_15_YahooDataflow.groovy │ │ ├── YahooService.groovy │ │ ├── snippet1801_startThread.groovy │ │ ├── snippet1803_java_parallel_streams_jdk8_only.groovy │ │ ├── snippet1804_deadlock.groovy │ │ └── snippet1804_nondeterministic.groovy │ ├── chap19/ │ │ ├── FetchOptions.groovy │ │ ├── FetchOptionsBuilder.groovy │ │ ├── Listing_19_06_Binding.groovy │ │ ├── Listing_19_29_OrderDSL.groovy │ │ ├── Listing_19_30_WhenIfControlStructure.groovy │ │ ├── Listing_19_31_Until_failing_.groovy │ │ ├── Listing_19_32_UntilControlStructure.groovy │ │ ├── Listing_19_39_GivenWhenThen.groovy │ │ ├── Listing_19_43_FetchOptionsScript.groovy │ │ ├── Listing_19_44_RubyStyleNewify.groovy │ │ ├── Listing_19_45_PythonStyleNewify.groovy │ │ ├── Listing_19_46_Terms.groovy │ │ ├── Listing_19_47_NewifyInjected.txt │ │ ├── Listing_19_48_No_IO.groovy │ │ ├── Listing_19_49_ArithmeticShell.groovy │ │ ├── Listing_19_50_TimedInterrupt.groovy │ │ ├── Listing_19_51_SystemExitGuard.groovy │ │ ├── Listing_19_53_QueryCustomizer.groovy │ │ ├── Listings.txt │ │ ├── Query.groovy │ │ ├── extra_FetchOptions_traditional.groovy │ │ ├── v01/ │ │ │ └── Listing_19_01_SelfContainedScript.groovy │ │ ├── v02/ │ │ │ ├── Listing_19_04_MainSimple.groovy │ │ │ ├── Listing_19_05_MainGroovyShell.groovy │ │ │ ├── Listing_19_07_MainBinding.groovy │ │ │ ├── Listing_19_08_MainDirectionConstants.groovy │ │ │ ├── Listing_19_09_MainDirectionsSpread.groovy │ │ │ ├── Listing_19_10_MainImplicitMethod.groovy │ │ │ ├── Listing_19_12_MainBaseScript.groovy │ │ │ ├── Listing_19_13_MainImportCustomizer.groovy │ │ │ ├── Listing_19_14_MainCustomBaseScriptClass.groovy │ │ │ ├── Listing_19_16_MainMethodClosure.groovy │ │ │ ├── Listing_19_19_MainLowerCase.groovy │ │ │ ├── integration/ │ │ │ │ ├── CaseRobotBaseScript.groovy │ │ │ │ ├── CustomBinding.groovy │ │ │ │ └── RobotBaseScript.groovy │ │ │ ├── model/ │ │ │ │ ├── Direction.groovy │ │ │ │ └── Robot.groovy │ │ │ └── snippet1901_MainFileRunner.groovy │ │ ├── v03/ │ │ │ ├── Listing_19_27_SimpleCommandChain.groovy │ │ │ ├── Listing_19_40_Robot_With.groovy │ │ │ ├── integration/ │ │ │ │ ├── DistanceCategory.groovy │ │ │ │ ├── RobotBaseScript.groovy │ │ │ │ └── SuperBotBaseScript.groovy │ │ │ └── model/ │ │ │ ├── Direction.groovy │ │ │ ├── Distance.groovy │ │ │ ├── Duration.groovy │ │ │ ├── Robot.groovy │ │ │ ├── Speed.groovy │ │ │ ├── SuperBot.groovy │ │ │ └── Unit.groovy │ │ └── xform/ │ │ ├── BusinessLogicScript.groovy │ │ ├── CustomControlStructure.groovy │ │ ├── Listing_19_36_WhenTransformation.groovy │ │ ├── WhenUntilTransform.groovy │ │ ├── extra_WhenTransformationWorksWithoutBraces.groovy │ │ └── snippet1906_WhenUntilXform_Structure.groovy │ └── chap20/ │ ├── Listing_20_01_Grapes_for_twitter_urls.groovy │ ├── Listing_20_02_Scriptom_Windows_only.groovy │ ├── Listing_20_03_ActivX_Windows_only.groovy │ ├── Listing_20_10_SquaringMapValue.groovy │ ├── Listing_20_11_Synchronized.groovy │ └── Listing_20_12_DbC_invariants.groovy └── test.groovy ================================================ FILE CONTENTS ================================================ ================================================ FILE: .idea/vcs.xml ================================================ ================================================ FILE: LICENSE ================================================ 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. ================================================ FILE: README.md ================================================ # Groovy In Action Source code of the book [Groovy in Action, 2nd edition (manning,](http://manning.com/koenig2/?a_aid=regina&a_bid=8ade3b0e) [amazon)](http://www.amazon.com/gp/product/1935182447/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182447&linkCode=as2&tag=httpgroovycan-20&linkId=XLTAIALXLIUBWPOH) ### Use it? Star it! All source code is free for everybody's use under the Apache 2 license. If you want to do us a favor in return, please give this repo a "star" such that we can get at least a feeling of how many developers are using it. _Thanks!_ # Prerequisites * Java 1.7 or higher * Groovy 2.4.1 or higher # Considerations One can run all listings by calling groovy alltests However, since some listings rely on external constraints like special versions of the JVM (e.g. to test Groovy features for Java 8) or OS-specific integration features, some listings may be excluded from execution. Listings are usually made such that you can `cd` into the directory for that chapter and call the listing via groovy mylistingname If no other instructions apply, you best use Groovy 2.4.1 and Java 7. More recent versions will also work in most cases. There are code adaptions to Java 8. Please use the Java_8 branch if you rely on those. Keep groovin' The authors ================================================ FILE: alltests.groovy ================================================ for (number in 1..20) { def ant = new AntBuilder() def dir = 'listings/chap' + number.toString().padLeft(2, '0') def runner = "../../test" if (number == 11) { def home = System.getenv("JAVA_HOME") jfxcp = "$home/jre/lib/jfxrt.jar" runner = "-classpath $jfxcp " + runner } else if (number == 10) { // add type extension source files to classpath runner = "-classpath . " + runner } println "testing dir $dir" def os = System.getProperty("os.name").toLowerCase() def groovy = os.contains('windows') ? System.getenv("GROOVY_HOME") + '\\bin\\groovy.bat' : 'groovy' ant.exec( dir: dir, outputproperty: "cmdOut", executable: groovy) { arg(line: runner) } def out = ant.project.properties.cmdOut println out if (out.contains('FAILED')) { out.split("\n").grep(~/.*FAILED:.*/).each { println it } System.exit(1) } } ================================================ FILE: listings/allsources.txt ================================================ ./appD/Listing_D_01_GStrings.groovy ./appD/Listing_D_02_Lists.groovy ./appD/Listing_D_03_Closures.groovy ./appD/Listing_D_04_Regex.groovy ./appD/Listing_D_05_GPath.groovy ./chap01/customers.xml ./chap01/data.txt ./chap01/groovysh.txt ./chap01/Listing_01_01_Gold.groovy ./chap01/snippet0101_customers.groovy ./chap01/snippet0101_fileLineNumbers.groovy ./chap01/snippet0101_newDates.txt ./chap01/snippet0101_printPackageNames.groovy ./chap01/snippet0101_printPackageNamesGpath.groovy ./chap01/snippet0102_printGroovyWebSiteCount.groovy ./chap01/snippet0103_googleIpAdr.groovy ./chap02/Book.groovy ./chap02/Listing_02_01_Assertions.groovy ./chap02/Listing_02_02_Book.txt ./chap02/Listing_02_03_BookScript.groovy ./chap02/Listing_02_04_BookBean.groovy ./chap02/Listing_02_05_ImmutableBook.groovy ./chap02/Listing_02_06_Grab.groovy ./chap02/Listing_02_07_Clinks.groovy ./chap02/Listing_02_08_ControlStructures.groovy ./chap02/snippet0201_comments.groovy ./chap02/snippet0202_failing_assert.groovy ./chap02/snippet0202_failing_assertion_error.txt ./chap02/snippet0203_clinks_java.groovy ./chap02/snippet0203_gstring.groovy ./chap02/snippet0203_int_usage.groovy ./chap02/snippet0203_map_usage.groovy ./chap02/snippet0203_range_usage.groovy ./chap02/snippet0203_roman.groovy ./chap02/snippet0204_evaluate_jdk7_only.groovy ./chap02/snippet0204_evaluate_jdk8_only.groovy ./chap02/snippet0204_failing_typechecked.groovy ./chap03/ArrayListSummer.java ./chap03/extra_escaped_characters_table36.groovy ./chap03/extra_method_operators_table34.groovy ./chap03/extra_numeric_literals_table32.groovy ./chap03/extra_numerical_coercion_table310.groovy ./chap03/extra_optional_typing_table33.groovy ./chap03/extra_primitive_values_table31.groovy ./chap03/Listing_03_01_PrimitiveMethodsObjectOperators.groovy ./chap03/Listing_03_02_ListMapCast.groovy ./chap03/Listing_03_03_DefiningOperators.groovy ./chap03/Listing_03_04_DefiningGStrings.groovy ./chap03/Listing_03_05_StringOperations.groovy ./chap03/Listing_03_06_RegexGStrings.groovy ./chap03/Listing_03_07_RegularExpressions.groovy ./chap03/Listing_03_08_EachMatch.groovy ./chap03/Listing_03_09_PatternReuse.groovy ./chap03/Listing_03_10_PatternsClassification.groovy ./chap03/Listing_03_11_NumberMethodsGDK.groovy ./chap03/regex_dgm.txt ./chap03/snippet0301_autoboxing.groovy ./chap03/snippet0304_GString_internals.groovy ./chap03/snippet0304_stringbuffer.groovy ./chap03/snippet0305_matcher_each_group.groovy ./chap03/snippet0305_matcher_groups.groovy ./chap03/snippet0305_matcher_parallel_assignment.groovy ./chap03/snippet0305_matcher_plain.groovy ./chap03/snippet0306_GDK_methods_for_numbers.groovy ./chap04/extra_EnumRange.groovy ./chap04/extra_ListCast.groovy ./chap04/extra_ListTable.groovy ./chap04/extra_Map_as.groovy ./chap04/extra_Map_group.groovy ./chap04/extra_MaxMinSum.groovy ./chap04/extra_SplitList.groovy ./chap04/Listing_04_01_range_declarations.groovy ./chap04/Listing_04_02_ranges_are_objects.groovy ./chap04/Listing_04_03_custom_ranges.groovy ./chap04/Listing_04_04_list_declarations.groovy ./chap04/Listing_04_05_list_subscript_operator.groovy ./chap04/Listing_04_06_list_add_remove.groovy ./chap04/Listing_04_07_lists_control_structures.groovy ./chap04/Listing_04_08_list_content_manipulation.groovy ./chap04/Listing_04_09_list_other_methods.groovy ./chap04/Listing_04_10_list_quicksort.groovy ./chap04/Listing_04_11_list_mapreduce.groovy ./chap04/Listing_04_12_map_declarations.groovy ./chap04/Listing_04_13_map_accessors.groovy ./chap04/Listing_04_14_map_query_methods.groovy ./chap04/Listing_04_15_map_iteration.groovy ./chap04/Listing_04_16_map_content.groovy ./chap04/Listing_04_17_map_example.groovy ./chap04/snippet0402_ListAsSet.groovy ./chap04/snippet0402_ListRemoveNulls.groovy ./chap04/snippet0402_ListStreams_jdk8_plus.groovy ./chap04/snippet0403_Map_Ctor_Expression.groovy ./chap04/snippet0403_Map_Ctor_Unquoted.groovy ./chap04/snippet0403_Map_MapReduce.groovy ./chap04/snippet0403_Map_String_accessors.groovy ./chap05/extra_Closure_delegate.groovy ./chap05/extra_Closure_myWith.groovy ./chap05/extra_ClosureProperty.groovy ./chap05/Listing_05_01_closure_simple_declaration.groovy ./chap05/Listing_05_02_simple_method_closure.groovy ./chap05/Listing_05_03_multi_method_closure.groovy ./chap05/Listing_05_04_closure_all_declarations.groovy ./chap05/Listing_05_05_simple_closure_calling.groovy ./chap05/Listing_05_06_calling_closures.groovy ./chap05/Listing_05_07_simple_currying.groovy ./chap05/Listing_05_08_logging_curry_example.groovy ./chap05/Listing_05_09_closure_scope.groovy ./chap05/Listing_05_10_closure_accumulator.groovy ./chap05/Listing_05_11_visitor_pattern.groovy ./chap05/snippet0501_envelope.groovy.txt ./chap05/snippet0504_closure_default_params.groovy ./chap05/snippet0504_closure_isCase.groovy ./chap05/snippet0504_closure_paramcount.groovy ./chap05/snippet0505_map_with.groovy ./chap05/snippet0505_scoping.groovy ./chap05/snippet0506_closure_return.groovy ./chap05/snippet0507_closure_composition.groovy ./chap05/snippet0508_memoize.groovy ./chap05/snippet0509_trampoline.groovy ./chap06/extra_if_return.groovy ./chap06/extra_in_operator.groovy ./chap06/extra_switch_return.groovy ./chap06/Listing_06_01_groovy_truth.groovy ./chap06/Listing_06_02_assignment_bug.groovy ./chap06/Listing_06_03_if_then_else.groovy ./chap06/Listing_06_04_conditional_operator.groovy ./chap06/Listing_06_05_switch_basic.groovy ./chap06/Listing_06_06_switch_advanced.groovy ./chap06/Listing_06_07_assert_host.groovy ./chap06/Listing_06_08_while.groovy ./chap06/Listing_06_09_for.groovy ./chap06/Listing_06_10_break_continue.groovy ./chap06/Listing_06_11_exception_example.groovy ./chap06/myFileName.txt ./chap06/snippet0602_bad_file_read.groovy ./chap06/snippet0602_bad_file_read_with_message.groovy ./chap06/snippet0602_failing_assert.groovy ./chap06/snippet0603_each_loop_iterate.groovy ./chap06/snippet0603_file_iterate_lines.groovy ./chap06/snippet0603_for_loop_iterate.groovy ./chap06/snippet0603_null_iterate.groovy ./chap06/snippet0603_object_iterate.groovy ./chap06/snippet0603_regex_iterate_match.groovy ./chap06/snippet0604_multicatch.groovy ./chap07/business/Vendor.groovy ./chap07/Listing_07_01_Declaring_Variables.groovy ./chap07/Listing_07_02_TypeBreaking_Assignment.groovy ./chap07/Listing_07_03_Referencing_Fields.groovy ./chap07/Listing_07_04_Overriding_Field_Access.groovy ./chap07/Listing_07_05_Declaring_Methods.groovy ./chap07/Listing_07_06_Declaring_Parameters.groovy ./chap07/Listing_07_07_Parameter_Usages.groovy ./chap07/Listing_07_08_Safe_Dereferencing.groovy ./chap07/Listing_07_09_Instantiation.groovy ./chap07/Listing_07_10_Instantiation_Named.groovy ./chap07/Listing_07_11_Classes.groovy ./chap07/Listing_07_13_Import.groovy ./chap07/Listing_07_14_Import_As_BugFix.groovy ./chap07/Listing_07_15_Import_As_NameClash.groovy ./chap07/Listing_07_16_Multimethods.groovy ./chap07/Listing_07_17_MultiEquals.groovy ./chap07/Listing_07_18_Traits.groovy ./chap07/Listing_07_19_Declaring_Beans.groovy ./chap07/Listing_07_20_Calling_Beans.groovy ./chap07/Listing_07_21_Calling_Beans_Advanced.groovy ./chap07/Listing_07_22_Property_Methods.groovy ./chap07/Listing_07_23_Expando.groovy ./chap07/Listing_07_24_GPath.groovy ./chap07/snippet0703_Implicit_Closure_To_SAM.groovy ./chap07/snippet0705_Spread_List.groovy ./chap07/snippet0705_Spread_Map.groovy ./chap07/snippet0705_Spread_Range.groovy ./chap07/thirdparty/MathLib.groovy ./chap07/thirdparty2/MathLib.groovy ./chap08/custom/Custom.groovy ./chap08/custom/useCustom.groovy ./chap08/failing_Listing_08_15_EMC_static.groovy ./chap08/failing_Listing_08_16_EMC_super.groovy ./chap08/groovy/runtime/metaclass/custom/CustomMetaClass.groovy ./chap08/Listing_08_01_method_missing.groovy ./chap08/Listing_08_02_mini_gorm.groovy ./chap08/Listing_08_03_property_missing.groovy ./chap08/Listing_08_04_bin_property.groovy ./chap08/Listing_08_05_closure_dynamic.groovy ./chap08/Listing_08_06_property_method.groovy ./chap08/Listing_08_07_MetaClass_jdk7_only.groovy ./chap08/Listing_08_07_MetaClass_jdk8_plus.groovy ./chap08/Listing_08_08_ProxyMetaClass.groovy ./chap08/Listing_08_09_Expando.groovy ./chap08/Listing_08_10_EMC.groovy ./chap08/Listing_08_11_EMC_Groovy_Class.groovy ./chap08/Listing_08_12_EMC_Groovy_Object.groovy ./chap08/Listing_08_13_EMC_Java_Object.groovy ./chap08/Listing_08_14_EMC_Builder.groovy ./chap08/Listing_08_15_EMC_static.groovy ./chap08/Listing_08_16_EMC_super.groovy ./chap08/Listing_08_17_EMC_hooks.groovy ./chap08/Listing_08_18_Existing_Categories.groovy ./chap08/Listing_08_19_Marshal.groovy ./chap08/Listing_08_20_MarshalCategory.groovy ./chap08/Listing_08_21_Test_Mixin.groovy ./chap08/Listing_08_22_Sieve_Mixin.groovy ./chap08/Listing_08_23_Millimeter.groovy ./chap08/Listing_08_24_create_factory.groovy ./chap08/Listing_08_25_fake_assign.groovy ./chap08/Listing_08_26_restore_emc.groovy ./chap08/Listing_08_27_intercept_cache_invoke.groovy ./chap08/markup.html ./chap09/gradlew.bat ./chap09/Listing_09_01_ToStringDetective.groovy ./chap09/Listing_09_02_ToStringSleuth.groovy ./chap09/Listing_09_03_EqualsAndHashCode.groovy ./chap09/Listing_09_04_TupleConstructor.groovy ./chap09/Listing_09_05_Lazy.groovy ./chap09/Listing_09_06_IndexedProperty.groovy ./chap09/Listing_09_07_InheritConstructors.groovy ./chap09/Listing_09_08_Sortable.groovy ./chap09/Listing_09_09_Builder.groovy ./chap09/Listing_09_10_Canonical.groovy ./chap09/Listing_09_11_Immutable.groovy ./chap09/Listing_09_12_Delegate.groovy ./chap09/Listing_09_13_Singleton.groovy ./chap09/Listing_09_14_Memoized.groovy ./chap09/Listing_09_15_TailRecursive.groovy ./chap09/Listing_09_16_Log.groovy ./chap09/Listing_09_17_Synchronized.groovy ./chap09/Listing_09_18_SynchronizedCustomLock.groovy ./chap09/Listing_09_19_ReadWriteLock.groovy ./chap09/Listing_09_20_AutoClone.groovy ./chap09/Listing_09_21_AutoCloneCopyConstructor.groovy ./chap09/Listing_09_22_AutoExternalize.groovy ./chap09/Listing_09_23_TimedInterrupt.groovy ./chap09/Listing_09_24_ThreadInterrupt.groovy ./chap09/Listing_09_25_ConditionalInterrupt.groovy ./chap09/Listing_09_26_Field.groovy ./chap09/Listing_09_27_BaseScript.groovy ./chap09/Listing_09_28_AstByHand.groovy ./chap09/Listing_09_29_AstByHandWithUtils.groovy ./chap09/Listing_09_30_AstBuildFromSpec.groovy ./chap09/Listing_09_31_AstBuildFromString.groovy ./chap09/Listing_09_32_AstBuildFromStringMixed.groovy ./chap09/Listing_09_33_AstBuildFromCode.groovy ./chap09/Listing_09_34_GreeterMainTransform.groovy ./chap09/Listing_09_35_GreeterMainTransform2.groovy ./chap09/Listing_09_38_AstTesting1.groovy ./chap09/Listing_09_39_AstTesting2.groovy ./chap09/Listing_09_40_AstTesting3.groovy ./chap09/Listing_09_41_AstTesting4.groovy ./chap09/Listing_09_42_AstTesting5.groovy ./chap09/Listings.txt ./chap09/settings.gradle ./chap09/snippet0902_autoCloneDefault.txt ./chap09/snippet0902_autoCloneSerialization.txt ./chap09/snippet0902_autoExternalize.txt ./chap09/snippet0902_fieldEquivalent.txt ./chap09/snippet0902_mapCreation.txt ./chap09/snippet0902_noisySetDelegateByHand.txt ./chap09/snippet0902_noisySetInheritance.txt ./chap09/snippet0902_nonTailCallReverseList.txt ./chap09/snippet0902_readWriteByHand.txt ./chap09/snippet0902_readWriteLock.txt ./chap09/snippet0902_singletonByHand.txt ./chap09/snippet0902_toStringEquivalent.txt ./chap09/snippet0903_greeterExpanded.txt ./chap09/snippet0903_greeterScript.txt ./chap09/snippet0903_localMain.txt ./chap09/snippet0903_localMainTransformation.txt ./chap09/snippet0905_GetCompiledTimeScript.txt ./chap09/src/main/groovy/regina/CompiledAtASTTransformation.groovy ./chap09/src/test/groovy/regina/CompiledAtASTTransformationTest.groovy ./chap10/extra1004_JavaDispatch.java ./chap10/extra1004_RuntimeGroovyDispatch.groovy ./chap10/Greeter.java ./chap10/Listing_10_01_Duck.groovy ./chap10/Listing_10_02_failing_Typo.groovy ./chap10/Listing_10_03_ClassTC.groovy ./chap10/Listing_10_04_OneMethodTC.groovy ./chap10/Listing_10_05_CompileTimeTypo.groovy ./chap10/Listing_10_06_MethodNameTypo.groovy ./chap10/Listing_10_07_MethodArgsFlipped.groovy ./chap10/Listing_10_08_InvalidAssignments.groovy ./chap10/Listing_10_09_AssignmentsWithCoercion.groovy ./chap10/Listing_10_10_DefField.groovy ./chap10/Listing_10_11_InPlaceList.groovy ./chap10/Listing_10_12_Generics.groovy ./chap10/Listing_10_13_ListStyleCtorRuntime.groovy ./chap10/Listing_10_14_ListStyleCtorTC.groovy ./chap10/Listing_10_15_MapStyleCtorBad.groovy ./chap10/Listing_10_16_ListStyleCtor.groovy ./chap10/Listing_10_17_ListStyleCtorFixed.groovy ./chap10/Listing_10_18_CodeAsData.groovy ./chap10/Listing_10_19_ClosuresBadReturnType.groovy ./chap10/Listing_10_20_UserValidation.groovy ./chap10/Listing_10_21_UserValidationTC.groovy ./chap10/Listing_10_22_UserValidation_ExplicitTypes.groovy ./chap10/Listing_10_23_UserValidation_SAM.groovy ./chap10/Listing_10_24_UserValidation_ClosureParams.groovy ./chap10/Listing_10_25_UserValidation_DSL.groovy ./chap10/Listing_10_26_UserValidation_DelegatesTo.groovy ./chap10/Listing_10_27_UserValidation_DelegatesToTarget.groovy ./chap10/Listing_10_28_Category.groovy ./chap10/Listing_10_29_EMC.groovy ./chap10/Listing_10_30_Builder.groovy ./chap10/Listing_10_31_MixedTypeChecking.groovy ./chap10/Listing_10_32_Skip.groovy ./chap10/Listing_10_33_FlowTyping.groovy ./chap10/Listing_10_34_FlowTypingOk.groovy ./chap10/Listing_10_35_LUB.groovy ./chap10/Listing_10_36_Condition.groovy ./chap10/Listing_10_37_ClosureSharedVar.groovy ./chap10/Listing_10_38_LubError.groovy ./chap10/Listing_10_39_LubOk.groovy ./chap10/Listing_10_41_FibBench.groovy ./chap10/Listing_10_41_JavaGreeter.txt ./chap10/Listing_10_42_StaticCompileDispatch.groovy ./chap10/Listing_10_43_MonkeyPatching.groovy ./chap10/Listing_10_44_BookingDSL.groovy ./chap10/Listing_10_45_MultiValidation.groovy ./chap10/Listing_10_46_RobotExtension.groovy ./chap10/Listing_10_47_SQLExtension.groovy ./chap10/markup.html ./chap10/snippet1003_GroovyGreeter.groovy ./chap10/snippet1005_RobotMainTC.groovy ./chap10/snippet1005_SqlMainTC.groovy ./chap10/User.groovy ./chap11/Listing_11_01_SquaresFactors.xml ./chap11/Listing_11_02_SquaresFactors.java ./chap11/Listing_11_03_MarkupBuilderPlain.groovy ./chap11/Listing_11_04_NodeBuilder.groovy ./chap11/Listing_11_05_NodeBuilderLogic.groovy ./chap11/Listing_11_06_MarkupBuilderLogic.groovy ./chap11/Listing_11_07_MarkupBuilderHtml.groovy ./chap11/Listing_11_08_StreamingMarkupBuilderLogic.groovy ./chap11/Listing_11_09_ExampleBuild.xml ./chap11/Listing_11_10_PW_SwingBuilder.groovy ./chap11/Listing_11_11_Swing_Widgets.groovy ./chap11/Listing_11_12_Swing_Layout.groovy ./chap11/Listing_11_13_Table_Demo.groovy ./chap11/Listing_11_14_Binding.groovy ./chap11/Listing_11_15_Plotter.groovy ./chap11/Listing_11_16_Groovyfx.groovy ./chap11/Listing_11_17_CalorieCounterBuilderSupport.groovy ./chap11/Listing_11_18_CalorieCounterFactoryBuilderSupport.groovy ./chap11/Listing_11_19_CalorieCounterByHand.groovy ./chap11/markup.html ./chap11/snippet1103_MarkupBuilderOutput.html ./chap11/snippet1103_MarkupWithHyphen.groovy ./chap11/snippet1106_AntBuilderIf.groovy ./chap11/snippet1106_AntIf.xml ./chap11/snippet1107_binding.txt ./chap11/snippet1107_Printer.groovy ./chap12/data/example.txt ./chap12/Listing_12_01_info_jdk6_only.groovy ./chap12/Listing_12_01_info_jdk7_only.groovy ./chap12/Listing_12_01_info_jdk8_plus.groovy ./chap12/Listing_12_02_properties.groovy ./chap12/Listing_12_03_File_Iteration.groovy ./chap12/Listing_12_04_Filesystem.groovy ./chap12/Listing_12_05_Traversal.groovy ./chap12/Listing_12_06_File_Read.groovy ./chap12/Listing_12_07_File_Write.groovy ./chap12/Listing_12_08_Writer_LeftShift.groovy ./chap12/Listing_12_09_File_Transform_jdk7_plus.groovy ./chap12/Listing_12_10_File_ObjectStreams.groovy ./chap12/Listing_12_11_Temp_Dir.groovy ./chap12/Listing_12_12_Threads.groovy ./chap12/Listing_12_13_Processes_UnixCommands.groovy ./chap12/Listing_12_14_Processes_ZipUnzip.groovy ./chap12/Listing_12_15_SimpleTemplateEngine.groovy ./chap12/Listing_12_16_GroovletExample.groovy ./chap12/Listing_12_17_HelloWorldGroovlet.groovy ./chap12/Listing_12_19_InspectGroovlet.groovy ./chap12/Listing_12_20_HiLowGame.groovy ./chap12/Listing_12_21_NumberTemplate.txt ./chap12/Listing_12_22_TemplateGroovlet.groovy ./chap12/Number.template.html ./chap12/snippet1201_SlowTyping.groovy ./chap12/snippet1201_UseCategory.groovy ./chap12/snippet1202_base64.groovy ./chap12/web.xml ./chap13/extra_NeoGremlinGraph.groovy ./chap13/layering/AthleteApplication.groovy ./chap13/layering/AthleteDAO.groovy ./chap13/layering/DataAccessObject.groovy ./chap13/layering/DbHelper.groovy ./chap13/Listing_13_01_Connecting.groovy ./chap13/Listing_13_02_ConnectingDataSource.groovy ./chap13/Listing_13_03_Creating.groovy ./chap13/Listing_13_04_Inserting.groovy ./chap13/Listing_13_05_Reading.groovy ./chap13/Listing_13_06_Updating.groovy ./chap13/Listing_13_07_Delete.groovy ./chap13/Listing_13_08_Transactions.groovy ./chap13/Listing_13_09_Batching.groovy ./chap13/Listing_13_10_Paging.groovy ./chap13/Listing_13_11_Metadata.groovy ./chap13/Listing_13_12_MoreMetadata.groovy ./chap13/Listing_13_13_NamedOrdinal.groovy ./chap13/Listing_13_14_StoredProcBasic.groovy ./chap13/Listing_13_15_StoredProcParam.groovy ./chap13/Listing_13_16_StoredProcInOut.groovy ./chap13/Listing_13_17_DataSetBasics.groovy ./chap13/Listing_13_18_DataSetFiltering.groovy ./chap13/Listing_13_19_DataSetViews.groovy ./chap13/Listing_13_20_DbHelper.txt ./chap13/Listing_13_21_DataAccessObject.txt ./chap13/Listing_13_22_AthleteDAO.txt ./chap13/Listing_13_23_AthleteApplication.txt ./chap13/Listing_13_24_AthleteAppMain.groovy ./chap13/Listing_13_25_AthleteAppTest.groovy ./chap13/Listing_13_26_MongoAthletes.groovy ./chap13/Listing_13_27_NeoAthletes.groovy ./chap13/Listing_13_28_NeoGremlin.groovy ./chap13/snippet1301_ConnectingWithGrab.groovy ./chap13/snippet1301_ConnectingWithInstance.groovy ./chap13/snippet1301_ConnectingWithMap.groovy ./chap13/snippet1301_ReadEachRow.groovy ./chap13/snippet1301_ReadEachRowList.groovy ./chap13/snippet1301_ReadQuery.groovy ./chap13/snippet1301_ReadRows.groovy ./chap13/util/DbUtil.groovy ./chap13/util/MarathonRelationships.groovy ./chap13/util/Neo4jUtil.groovy ./chap14/data/GroovyPlans.html ./chap14/data/GroovyPlans.template.html ./chap14/data/plan.json ./chap14/data/plan.xml ./chap14/data/StreamedGroovyPlans.html ./chap14/data/style.css ./chap14/data/XPathGroovyPlans.html ./chap14/Listing_14_01_Plan.txt ./chap14/Listing_14_02_DOM.groovy ./chap14/Listing_14_03_DOM_Category.groovy ./chap14/Listing_14_04_XmlParser.groovy ./chap14/Listing_14_05_XmlSlurper.groovy ./chap14/Listing_14_06_SAX.groovy ./chap14/Listing_14_07_StAX.groovy ./chap14/Listing_14_08_XmlBoiler.groovy ./chap14/Listing_14_09_XmlStreamer.groovy ./chap14/Listing_14_10_StreamedHtml.groovy ./chap14/Listing_14_11_UpdateDomCategory.groovy ./chap14/Listing_14_12_UpdateParser.groovy ./chap14/Listing_14_13_UpdateSlurper.groovy ./chap14/Listing_14_14_XPath.groovy ./chap14/Listing_14_15_GroovyPlansTemplate.txt ./chap14/Listing_14_16_XPathTemplate.groovy ./chap14/Listing_14_17_JsonParser.groovy ./chap14/Listing_14_18_JsonBuilder.groovy ./chap14/Listing_14_19_JsonBuilderLogic.groovy ./chap14/Listing_14_20_JsonOutputAthlete.groovy ./chap14/log4j.xml ./chap14/UpdateChecker.groovy ./chap15/data/conv.templ.xml ./chap15/Listing_15_01_RSS_bbcnews.groovy ./chap15/Listing_15_02_ATOM_devworks.groovy ./chap15/Listing_15_03_REST_jira_url.groovy ./chap15/Listing_15_04_REST_jira_httpb_get.groovy ./chap15/Listing_15_05_REST_currency_httpb_get.groovy ./chap15/Listing_15_06_REST_currency_httpb_post.groovy ./chap15/Listing_15_07_REST_currency_jaxrs.groovy ./chap15/Listing_15_08_REST_currency_jaxrs_proxy.groovy ./chap15/Listing_15_09_XMLRPC_echo.groovy ./chap15/Listing_15_10_XMLRPC_jira.groovy ./chap15/Listing_15_11_SOAP_wsdl.groovy ./chap15/Listing_15_12_SOAP11_currency_url.groovy ./chap15/Listing_15_13_SOAP12_currency_httpb.groovy ./chap15/Listing_15_14_SOAP11_currency_wslite.groovy ./chap15/Listing_15_15_SOAP12_currency_wslite.groovy ./chap16/HelloIntegrationWorld.java ./chap16/Listing_16_01_HelloIntegration.groovy ./chap16/Listing_16_02_HelloIntegrationJava.txt ./chap16/Listing_16_03_MultilineScript.groovy ./chap16/Listing_16_04_UsingEval.groovy ./chap16/Listing_16_05_Binding.groovy ./chap16/Listing_16_06_BindingTwoWay.groovy ./chap16/Listing_16_07_ClassInScript.groovy ./chap16/Listing_16_08_Payment_calculator.groovy ./chap16/Listing_16_09_MethodsInBinding.groovy ./chap16/Listing_16_10_ShapeInfoMain.txt ./chap16/Listing_16_11_SpringConfig.txt ./chap16/Listing_16_12_BeanToString.groovy ./chap16/shapes/Circle.groovy ./chap16/shapes/MaxAreaInfo.groovy ./chap16/shapes/MaxPerimeterInfo.java ./chap16/shapes/Shape.java ./chap16/shapes/ShapeInfo.java ./chap16/shapes/ShapeInfoMain.java ./chap16/shapes/Square.java ./chap16/spring/common/Shape.java ./chap16/spring/common/ShapeInfo.java ./chap16/spring/groovy/Circle.groovy ./chap16/spring/groovy/MaxAreaInfo.groovy ./chap16/spring/java/MaxPerimeterInfo.java ./chap16/spring/java/ShapeInfoFactoryMain.java ./chap16/spring/java/ShapeInfoMain.java ./chap16/spring/java/ShapeInfoSpringMain.java ./chap16/spring/java/Square.java ./chap16/spring/resources/beans.xml ./chap17/automation/src/main/groovy/Calculator.groovy ./chap17/automation/src/test/groovy/CalculatorTest.groovy ./chap17/cobertura/src/main/groovy/BiggestPairCalc.groovy ./chap17/cobertura/src/main/groovy/BiggestPairCalcFixed.groovy ./chap17/cobertura/src/test/groovy/BiggestPairCalcTest.groovy ./chap17/Converter.groovy ./chap17/Counter.groovy ./chap17/extra_ParameterizedTestNG.groovy ./chap17/extra_TestNG.groovy ./chap17/Farm.groovy ./chap17/Listing_17_01_Celsius.groovy ./chap17/Listing_17_02_CounterTest.groovy ./chap17/Listing_17_03_HashMapTest.groovy ./chap17/Listing_17_04_GroovyTestSuite.groovy ./chap17/Listing_17_05_AllTestSuite.groovy ./chap17/Listing_17_06_DataDrivenJUnitTest.groovy ./chap17/Listing_17_07_PropertyBased.groovy ./chap17/Listing_17_08_Balancer.groovy ./chap17/Listing_17_09_BalancerStub.groovy ./chap17/Listing_17_10_BalancerMock.groovy ./chap17/Listing_17_11_LoggingCounterTest.groovy ./chap17/Listing_17_12_JUnitPerf.groovy ./chap17/Listing_17_13_SpockSimple.groovy ./chap17/Listing_17_14_SpockMock.groovy ./chap17/Listing_17_15_SpockMockWildcards.groovy ./chap17/Listing_17_16_SpockMockClosureChecks.groovy ./chap17/Listing_17_17_SpockDataDriven.groovy ./chap17/LoggingCounter.groovy ./chap17/MovieTheater.groovy ./chap17/Purchase.groovy ./chap17/snippet1701_JUnit4.groovy ./chap17/snippet1704_listPropertyCheck.groovy ./chap18/Listing_18_01_ConcurrentSquares.groovy ./chap18/Listing_18_02_ConcurrentSquaresTransparent.groovy ./chap18/Listing_18_03_ConcurrentSquaresTransitive.groovy ./chap18/Listing_18_04_MapFilterReduce.groovy ./chap18/Listing_18_05_SquaresMapReduce.groovy ./chap18/Listing_18_06_Dataflow.groovy ./chap18/Listing_18_07_DataflowStreams.groovy ./chap18/Listing_18_08_Actors.groovy ./chap18/Listing_18_09_ActorsLifecycle.groovy ./chap18/Listing_18_10_ActorsMessageAware.groovy ./chap18/Listing_18_11_Agent.groovy ./chap18/Listing_18_12.txt ./chap18/Listing_18_13_YahooForkJoin.groovy ./chap18/Listing_18_14_YahooMapReduce.groovy ./chap18/Listing_18_15_YahooDataflow.groovy ./chap18/snippet1801_startThread.groovy ./chap18/snippet1803_java_parallel_streams_jdk8_only.groovy ./chap18/snippet1804_deadlock.groovy ./chap18/snippet1804_nondeterministic.groovy ./chap18/YahooService.groovy ./chap19/extra_19_41_FetchOptions.groovy ./chap19/FetchOptions.groovy ./chap19/FetchOptionsBuilder.groovy ./chap19/Listing_19_06_Binding.groovy ./chap19/Listing_19_29_OrderDSL.groovy ./chap19/Listing_19_30_WhenIfControlStructure.groovy ./chap19/Listing_19_31_Until_failing_.groovy ./chap19/Listing_19_32_UntilControlStructure.groovy ./chap19/Listing_19_38_GivenWhenThen.groovy ./chap19/Listing_19_42_FetchOptionsScript.groovy ./chap19/Listing_19_43_RubyStyleNewify.groovy ./chap19/Listing_19_44_PythonStyleNewify.groovy ./chap19/Listing_19_45_Terms.groovy ./chap19/Listing_19_46_NewifyInjected.txt ./chap19/Listing_19_47_No_IO.groovy ./chap19/Listing_19_48_ArithmeticShell.groovy ./chap19/Listing_19_49_TimedInterrupt.groovy ./chap19/Listing_19_50_SystemExitGuard.groovy ./chap19/Listing_19_52_QueryCustomizer.groovy ./chap19/Listings.txt ./chap19/Query.groovy ./chap19/v01/Listing_19_01_SelfContainedScript.groovy ./chap19/v02/integration/CaseRobotBaseScript.groovy ./chap19/v02/integration/CustomBinding.groovy ./chap19/v02/integration/RobotBaseScript.groovy ./chap19/v02/Listing_19_04_MainSimple.groovy ./chap19/v02/Listing_19_05_MainGroovyShell.groovy ./chap19/v02/Listing_19_07_MainBinding.groovy ./chap19/v02/Listing_19_08_MainDirectionConstants.groovy ./chap19/v02/Listing_19_09_MainDirectionsSpread.groovy ./chap19/v02/Listing_19_10_MainImplicitMethod.groovy ./chap19/v02/Listing_19_12_MainBaseScript.groovy ./chap19/v02/Listing_19_13_MainImportCustomizer.groovy ./chap19/v02/Listing_19_14_MainCustomBaseScriptClass.groovy ./chap19/v02/Listing_19_16_MainMethodClosure.groovy ./chap19/v02/Listing_19_19_MainLowerCase.groovy ./chap19/v02/model/Direction.groovy ./chap19/v02/model/Robot.groovy ./chap19/v02/snippet1901_MainFileRunner.groovy ./chap19/v03/integration/DistanceCategory.groovy ./chap19/v03/integration/RobotBaseScript.groovy ./chap19/v03/integration/SuperBotBaseScript.groovy ./chap19/v03/Listing_19_27_SimpleCommandChain.groovy ./chap19/v03/Listing_19_39_Robot_With.groovy ./chap19/v03/model/Direction.groovy ./chap19/v03/model/Distance.groovy ./chap19/v03/model/Duration.groovy ./chap19/v03/model/Robot.groovy ./chap19/v03/model/Speed.groovy ./chap19/v03/model/SuperBot.groovy ./chap19/v03/model/Unit.groovy ./chap19/xform/BusinessLogicScript.groovy ./chap19/xform/CustomControlStructure.groovy ./chap19/xform/extra_WhenTransformationWorksWithoutBraces.groovy ./chap19/xform/Listing_19_36_WhenTransformation.groovy ./chap19/xform/snippet1906_WhenUntilXform_Structure.groovy ./chap19/xform/WhenUntilTransform.groovy ./chap20/Listing_20_01_Grapes_for_twitter_urls.groovy ./chap20/Listing_20_02_Scriptom_Windows_only.groovy ./chap20/Listing_20_03_ActivX_Windows_only.groovy ./chap20/Listing_20_10_SquaringMapValue.groovy ./chap20/Listing_20_11_Synchronized.groovy ./chap20/Listing_20_12_DbC_invariants.groovy ================================================ FILE: listings/appD/Listing_D_01_GStrings.groovy ================================================ // normal use def g1 = "1 + 1 equals ${1 + 1}" assert g1 == '1 + 1 equals 2' assert g1 instanceof CharSequence assert g1 instanceof GString def x = 10 def g2 = "$x" // reference assert g2 == "10" def g3 = "${x}" // expression assert g3 == "10" // lazy evaluation with a writeable closure! def g4 = "${ -> x}" // closure x = 20 // value change after definition assert g4 == "20" // lazy evaluation! ================================================ FILE: listings/appD/Listing_D_02_Lists.groovy ================================================ assert [1,2,3,4] == (1..4) assert [1,2,3] + [1] == [1,2,3,1] assert [1,2,3] << 1 == [1,2,3,1] assert [1,2,3,1] - [1] == [2,3] assert [1,2,3] * 2 == [1,2,3,1,2,3] assert [1,[2,3]].flatten() == [1,2,3] assert [1,2,3].reverse() == [3,2,1] assert [1,2,3].disjoint([4,5,6]) assert [1,2,3].intersect([4,3,1]) == [3,1] assert [1,2,3].collect{ it+3 } == [4,5,6] assert [1,2,3,1].unique().size() == 3 assert [1,2,3,1].count(1) == 2 assert [1,2,3,4].min() == 1 assert [1,2,3,4].max() == 4 assert [1,2,3,4].sum() == 10 assert [4,2,1,3].sort() == [1,2,3,4] assert [4,2,1,3].findAll{ it%2 == 0 } == [4,2] def animals = ['cat','kangaroo','koala','dog'] assert animals[2] == 'koala' def kanimals = animals[1..2] assert animals.findAll{ it =~ /k.*/ } == kanimals assert animals.find{ it =~ /k.*/ } == kanimals[0] assert animals.grep(~/k.*/) == kanimals // parallel assignment as swap def a = 1, b = 2 (a, b) = [b, a] assert a == 2 assert b == 1 // lesser known methods assert animals.sort { it.size() } == ['cat', 'dog', 'koala', 'kangaroo'] assert animals.max { it.size() } == 'kangaroo' assert animals.groupBy { it.size() } == [ 3:['cat','dog'], 5:['koala'], 8:['kangaroo'] ] assert [1,2,3].permutations().toList() == [ [1, 2, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2], [2, 1, 3], [1, 3, 2] ] assert (1..10).collate(3) == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]] def matrix = [ ['a', 'b'], [ 1 , 2 ] ] assert matrix.transpose() == [ ['a', 1], ['b', 2] ] assert matrix.combinations() == [ ['a', 1], ['b', 1], ['a', 2], ['b', 2] ] ================================================ FILE: listings/appD/Listing_D_03_Closures.groovy ================================================ def add = { x, y -> x + y } def mult = { x, y -> x * y } assert add(1,3) == 4 assert mult(1,3) == 3 def min = { x, y -> [x,y].min() } def max = { x, y -> [x,y].max() } def atLeastTen = max.curry(10) assert atLeastTen(5) == 10 assert atLeastTen(15) == 15 def pairWise(list, Closure invoke) { if (list.size() < 2) return [] def next = invoke(list[0],list[1]) return [next] + pairWise(list[1..-1], invoke) } assert pairWise(1..5, add) == [3, 5, 7, 9] assert pairWise(1..5, mult) == [2, 6, 12, 20] assert pairWise(1..5, min) == [1, 2, 3, 4] assert pairWise(1..5, max) == [2, 3, 4, 5] assert 'cbaxabc' == ['a','b','c'].inject('x') { result, item -> item + result + item } assert [1,2,3].grep{ it<3 } == [1,2] assert [1,2,3].any{ it%2 == 0 } assert [1,2,3].every{ it<4 } assert (1..9).collect{it}.join() == '123456789' assert (1..4).collect{it*2}.join() == '2468' ================================================ FILE: listings/appD/Listing_D_04_Regex.groovy ================================================ def twister = 'she sells sea shells by the sea shore' // contains word 'shore' assert twister =~ 'shore' // contains 'sea' twice (two ways) assert (twister =~ 'sea').count == 2 assert twister.split(/ /).grep(~/sea/).size() == 2 // words that start with 'sh', \b = word boundary def shwords = (twister =~ /sh[a-z]*\b/).collect{it}.join(' ') assert shwords == 'she shells shore' // sh-words by parallel assignment def (a, b, c) = twister =~ /sh[a-z]*\b/ assert a == 'she' assert b == 'shells' assert c == 'shore' // four words have three letter, \S = non-Space letter assert (twister =~ /\b\S{3}\b/).count == 4 // three words start with 's' and have 4, 5, or 6 letters assert (twister =~ /\bs\S{4}\S?\b/).count == 3 // replace words with 'X', \w = word character assert twister.replaceAll(/\w+/,'X') == 'X X X X X X X X' // starts with 'she' and ends with 'shore' def pattern = ~/she.*shore/ assert pattern.matcher(twister).matches() // replace 'sea' with 'ocean' but only if preceded by word 'the' def ocean = twister.replaceAll('(?<=the )sea','ocean') assert ocean == 'she sells sea shells by the ocean shore' // swap 1st and 2nd pairs of words def pairs = twister =~ /(\S+) (\S+) ?/ assert pairs.hasGroup() twister = [1, 0, 2, 3].collect{ pairs[it][0] }.join() assert twister == 'sea shells she sells by the sea shore' ================================================ FILE: listings/appD/Listing_D_05_GPath.groovy ================================================ import groovy.xml.dom.DOMCategory def recipeXml = ''' Self-raising Flour Icing sugar Butter Milk Preheat oven to 230 degrees celsius Sift flour and icing sugar into a bowl Melt butter and mix into dry ingredients Gradually add milk to the mixture until moist Turn onto floured board and cut into portions Bake for 15 minutes Serve with jam and whipped cream ''' def recipe = new XmlSlurper().parseText(recipeXml) assert 4 == recipe.ingredients.ingredient.size() // should be 14 elements in total assert 14 == recipe.'**'.findAll{true}.size() // step 4 (index 3 because we start from 0) involves milk assert recipe.steps.step[3].text().contains('milk') assert '2 cups' == recipe.ingredients.ingredient[0].'@amount'.toString() // two ingredients have '2 tablespoons' amount attribute def ingredients = recipe.ingredients.ingredient.grep{ it.'@amount' == '2 tablespoons' } assert ingredients.size() == 2 // every step has at least 4 words assert recipe.steps.step.every{ step -> step.text().tokenize(' ').size() >= 4 } def recipe2 = new XmlParser().parseText(recipeXml) /* … processing steps … */ def reader = new StringReader(recipeXml) def doc = groovy.xml.DOMBuilder.parse(reader) def recipe3 = doc.documentElement use (groovy.xml.dom.DOMCategory) { /* … processing steps … */ } ================================================ FILE: listings/chap01/Listing_01_01_Gold.groovy ================================================ List fibo = [1, 1] //#A List gold = [1, 2] //#B while ( ! isGolden( gold[-1] ) ) { //#C fibo.add( fibo[-1] + fibo[-2] ) //#D gold.add( fibo[-1] / fibo[-2] ) //#E } println "found golden ratio with fibo(${ fibo.size-1 }) as" println fibo[-1] + " / " + fibo[-2] + " = " + gold[-1] println "_" * 10 + "|" + "_" * (10 * gold[-1]) def isGolden(candidate) { //#F def small = 1 //#G def big = small * candidate //#H return isCloseEnough( (small+big)/big, big/small) } def isCloseEnough(a,b) { return (a-b).abs() < 1.0e-9 } //#A Initial Fibonacci numbers //#B Golden ration candidates //#C Last gold candidate //#D Next fibo number //#E Next golden candidate //#F Candidate satisfies golden rule //#G Smaller section //#H Bigger section ================================================ FILE: listings/chap01/customers.xml ================================================ ================================================ FILE: listings/chap01/data.txt ================================================ first line second line ================================================ FILE: listings/chap01/groovysh.txt ================================================ Groovy Shell (2.4.0, JVM: 1.7.0_75) Type ':help' or ':h' for help. -------------------------------------------------------------------- groovy:000> "Welcome, " + System.properties."user.name" ===> Welcome, Dierk groovy:000> ================================================ FILE: listings/chap01/snippet0101_customers.groovy ================================================ def customers = new XmlSlurper().parse(new File('customers.xml')) for (customer in customers.corporate.customer) { println "${customer.@name} works for ${customer.@company}" } ================================================ FILE: listings/chap01/snippet0101_fileLineNumbers.groovy ================================================ def number = 0 new File('data.txt').eachLine { line -> number++ println "$number: $line" } ================================================ FILE: listings/chap01/snippet0101_newDates.txt ================================================ import java.util.*; // Java Date today = new Date(); // Java today = new Date() // Groovy require 'date' # Ruby today = Date.new # Ruby import java.util._ // Scala var today = new Date // Scala (import '(java.util Date)) ; Clojure (def today (new Date)) ; Clojure (def today (Date.)) ; Clojure alternative ================================================ FILE: listings/chap01/snippet0101_printPackageNames.groovy ================================================ def classes = [String, List, File] for (clazz in classes) { println clazz.package.name } ================================================ FILE: listings/chap01/snippet0101_printPackageNamesGpath.groovy ================================================ println( [String, List, File]*.package*.name ) ================================================ FILE: listings/chap01/snippet0102_printGroovyWebSiteCount.groovy ================================================ import static groovyx.gpars.GParsPool.withPool def urls = [ 'http://www.groovy-lang.org', 'http://gpars.codehaus.org', 'http://gr8conf.org/' ]*.toURL() println withPool { urls.collectParallel { it.text.findAll(~/[Gg]roovy/).size() } } ================================================ FILE: listings/chap01/snippet0103_googleIpAdr.groovy ================================================ InetAddress.getAllByName("google.com").collect { it.toString().split('/')[1] } ================================================ FILE: listings/chap02/Book.groovy ================================================ class Book { private String title Book (String theTitle) { title = theTitle } String getTitle(){ return title } } ================================================ FILE: listings/chap02/Listing_02_01_Assertions.groovy ================================================ assert(true) assert 1 == 1 def x = 1 assert x == 1 def y = 1 ; assert y == 1 ================================================ FILE: listings/chap02/Listing_02_02_Book.txt ================================================ see Book.groovy ================================================ FILE: listings/chap02/Listing_02_03_BookScript.groovy ================================================ Book gina = new Book('Groovy in Action') assert gina.getTitle() == 'Groovy in Action' assert getTitleBackwards(gina) == 'noitcA ni yvoorG' String getTitleBackwards(book) { String title = book.getTitle() return title.reverse() } ================================================ FILE: listings/chap02/Listing_02_04_BookBean.groovy ================================================ class BookBean { String title //#A } def groovyBook = new BookBean() groovyBook.setTitle('Groovy in Action') //#B assert groovyBook.getTitle() == 'Groovy in Action' //#B groovyBook.title = 'Groovy conquers the world' //#C assert groovyBook.title == 'Groovy conquers the world' //#C //#A Property declaration //#B Property use with explicit getter calls //#C Property use with Groovy shortcuts ================================================ FILE: listings/chap02/Listing_02_05_ImmutableBook.groovy ================================================ import groovy.transform.Immutable @Immutable class FixedBook { //#A String title } def gina = new FixedBook('Groovy in Action') //#B def regina = new FixedBook(title:'Groovy in Action') //#C assert gina.title == 'Groovy in Action' assert gina == regina //#D try { gina.title = "Oops!" //#E assert false, "should not reach here" } catch (ReadOnlyPropertyException expected) { println "Expected Error: '$expected.message'" } //#A AST annotation //#B Positional constructor //#C Named-arg constructor //#D Standard equals() //#E Not allowed! ================================================ FILE: listings/chap02/Listing_02_06_Grab.groovy ================================================ @Grab('commons-lang:commons-lang:2.4') import org.apache.commons.lang.ClassUtils class Outer { class Inner {} } assert !ClassUtils.isInnerClass(Outer) assert ClassUtils.isInnerClass(Outer.Inner) ================================================ FILE: listings/chap02/Listing_02_07_Clinks.groovy ================================================ def totalClinks = 0 def partyPeople = 100 1.upto(partyPeople) { guestNumber -> clinksWithGuest = guestNumber-1 totalClinks += clinksWithGuest //#A } assert totalClinks == (partyPeople * (partyPeople-1)) / 2 //#A Modifies outer scope ================================================ FILE: listings/chap02/Listing_02_08_ControlStructures.groovy ================================================ if (false) assert false //#A if (null) //#B { //#C assert false } else { assert true } def i = 0 //#D while (i < 10) { //#D i++ //#D } //#D assert i == 10 //#D def clinks = 0 //#E for (remainingGuests in 0..9) { //#E clinks += remainingGuests //#E } //#E assert clinks == (10*9)/2 //#E def list = [0, 1, 2, 3] //#F for (j in list) { //#F assert j == list[j] //#F } //#F list.each() { item -> //#G assert item == list[item] //#G } //#G switch(3) { //#H case 1 : assert false; break //#H case 3 : assert true; break //#H default: assert false //#H } //#H //#A The if as one-liner //#B Null is false //#C Blocks may start on new line //#D Classic while //#E The for in range //#F The for in list //#G The each method with a closure //#H Class switch ================================================ FILE: listings/chap02/snippet0201_comments.groovy ================================================ #!/usr/bin/env groovy // some line comment /* some multi- line comment */ ================================================ FILE: listings/chap02/snippet0202_failing_assert.groovy ================================================ def a = 5 def b = 9 assert b == a + a //#A //#A expected to fail ================================================ FILE: listings/chap02/snippet0202_failing_assertion_error.txt ================================================ Assertion failed: assert b == a + a //#A | | | | | 9 | 5 | 5 //#B | 10 //#C false //#C at snippet22_failing_assert.run(snippet22_failing_assert.groovy:3) #A Expression is retained #B Referenced values #C Subexpression values ================================================ FILE: listings/chap02/snippet0203_clinks_java.groovy ================================================ // Java snippet int totalClinks = 0; int partyPeople = 100; for(int guestNumber = 1; guestNumber <= partyPeople; guestNumber++) { int clinksWithGuest = guestNumber-1; totalClinks += clinksWithGuest; } ================================================ FILE: listings/chap02/snippet0203_gstring.groovy ================================================ def nick = 'ReGina' def book = 'Groovy in Action, 2nd ed.' assert "$nick is $book" == 'ReGina is Groovy in Action, 2nd ed.' ================================================ FILE: listings/chap02/snippet0203_int_usage.groovy ================================================ def x = 1 def y = 2 assert x + y == 3 assert x.plus(y) == 3 assert x instanceof Integer ================================================ FILE: listings/chap02/snippet0203_map_usage.groovy ================================================ def http = [ 100 : 'CONTINUE', 200 : 'OK', 400 : 'BAD REQUEST' ] assert http[200] == 'OK' http[500] = 'INTERNAL SERVER ERROR' assert http.size() == 4 ================================================ FILE: listings/chap02/snippet0203_range_usage.groovy ================================================ def x = 1..10 assert x.contains(5) assert !x.contains(15) assert x.size() == 10 assert x.from == 1 assert x.to == 10 assert x.reverse() == 10..1 ================================================ FILE: listings/chap02/snippet0203_roman.groovy ================================================ def roman = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII'] //#A assert roman[4] == 'IV' //#B roman[8] = 'VIII' //#C assert roman.size() == 9 //#A List of Roman numerals //#B List access //#C List expansion ================================================ FILE: listings/chap02/snippet0204_evaluate_jdk7_only.groovy ================================================ //java.class.version //jdk5=49.0 //jdk6=50.0 //jdk7=51.0 //jdk8=52.0 def code = '1 + ' code += System.getProperty('java.class.version') assert code == '1 + 51.0' assert 52.0 == evaluate(code) ================================================ FILE: listings/chap02/snippet0204_evaluate_jdk8_only.groovy ================================================ //java.class.version //jdk5=49.0 //jdk6=50.0 //jdk7=51.0 //jdk8=52.0 def code = '1 + ' code += System.getProperty('java.class.version') assert code == '1 + 52.0' assert 53.0 == evaluate(code) ================================================ FILE: listings/chap02/snippet0204_failing_typechecked.groovy ================================================ class Universe { @groovy.transform.TypeChecked int answer() { "forty two" } } println new Universe().answer() ================================================ FILE: listings/chap03/ArrayListSummer.java ================================================ public class ArrayListSummer { public static void main(String[] args) { // (60 * 60 * 24 * 365).toString(); int secondsPerYear = 60 * 60 * 24 * 365; // secondsPerYear.toString(); new Integer(secondsPerYear).toString(); } } ================================================ FILE: listings/chap03/Listing_03_01_PrimitiveMethodsObjectOperators.groovy ================================================ (60 * 60 * 24 * 365).toString(); // invalid Java int secondsPerYear = 60 * 60 * 24 * 365; secondsPerYear.toString(); // invalid Java new Integer(secondsPerYear).toString(); assert "abc" - "a" == "bc" // invalid Java ================================================ FILE: listings/chap03/Listing_03_02_ListMapCast.groovy ================================================ import java.awt.* Point topLeft = new Point(0, 0) // classic Point botRight = [100, 100] // List cast Point center = [x:50, y:50] // Map cast assert botRight instanceof Point assert center instanceof Point def rect = new Rectangle() rect.location = [0, 0] // Point rect.size = [width:100, height:100] // Dimension ================================================ FILE: listings/chap03/Listing_03_03_DefiningOperators.groovy ================================================ import groovy.transform.Immutable @Immutable //#1 class Money { int amount String currency Money plus (Money other) { //#2 if (null == other) return this if (other.currency != currency) { throw new IllegalArgumentException( "cannot add $other.currency to $currency") } return new Money(amount + other.amount, currency) } } Money buck = new Money(1, 'USD') assert buck assert buck == new Money(1, 'USD') //#3 assert buck + buck == new Money(2, 'USD') //#4 //#1 Overrides == operator //#2 Implements + operator //#3 Use overridden == //#4 Use implemented + ================================================ FILE: listings/chap03/Listing_03_04_DefiningGStrings.groovy ================================================ import static java.util.Calendar.* def me = 'Tarzan' def you = 'Jane' def line = "me $me - you $you" //#1 assert line == 'me Tarzan - you Jane' TimeZone.default = TimeZone.getTimeZone('GMT') def date = new Date(0) def dateMap = [y:date[YEAR]-1900, m:date[MONTH], d:date[DAY_OF_MONTH]] def out = "Year $dateMap.y Month $dateMap.m Day $dateMap.d" //#2 assert out == 'Year 70 Month 0 Day 1' def tz = TimeZone.getTimeZone('GMT') def format = 'd MMM YYYY HH:mm:SS z' out = "Date is ${date.format(format, tz)} !" //#3 assert out == 'Date is 1 Jan 1970 00:00:00 GMT !' //#4 start def sql = """ SELECT FROM MyTable WHERE Year = $dateMap.y """ assert sql == """ SELECT FROM MyTable WHERE Year = 70 """ //#4 end out = "my 0.02\$" //#A assert out == 'my 0.02$' //#B //#1 Abbreviated dollar syntax //#2 Extended dot syntax //#3 Full syntax with braces //#4 Multiline GStrings //#A Escaped dollar sign //#B Literal dollar sign ================================================ FILE: listings/chap03/Listing_03_05_StringOperations.groovy ================================================ String greeting = 'Hello Groovy!' assert greeting.startsWith('Hello') assert greeting.getAt(0) == 'H' assert greeting[0] == 'H' assert greeting.indexOf('Groovy') >= 0 assert greeting.contains('Groovy') assert greeting[6..11] == 'Groovy' assert 'Hi' + greeting - 'Hello' == 'Hi Groovy!' assert greeting.count('o') == 3 assert 'x'.padLeft(3) == ' x' assert 'x'.padRight(3,'_') == 'x__' assert 'x'.center(3) == ' x ' assert 'x' * 3 == 'xxx' ================================================ FILE: listings/chap03/Listing_03_06_RegexGStrings.groovy ================================================ assert "abc" == /abc/ assert "\\d" == /\d/ def reference = "hello" assert reference == /$reference/ assert "\$" == /$/ ================================================ FILE: listings/chap03/Listing_03_07_RegularExpressions.groovy ================================================ def twister = 'she sells sea shells at the sea shore of seychelles' // twister must contain a substring of size 3 // that starts with s and ends with a assert twister =~ /s.a/ //#1 def finder = (twister =~ /s.a/) //#2 assert finder instanceof java.util.regex.Matcher //#2 // twister must contain only words delimited by single spaces assert twister ==~ /(\w+ \w+)*/ //#A def WORD = /\w+/ matches = (twister ==~ /($WORD $WORD)*/) //#B assert matches instanceof java.lang.Boolean //#B assert !(twister ==~ /s.e/) //#C def wordsByX = twister.replaceAll(WORD, 'x') assert wordsByX == 'x x x x x x x x x x' def words = twister.split(/ /) //#D assert words.size() == 10 assert words[0] == 'she' //#1 Regex find operator as usable in if //#2 Find expression evaluates to a matcher object //#A Regex match operator //#B Match expression evaluates to a boolean //#C Match is full unlike find //#D Split returns a list of words ================================================ FILE: listings/chap03/Listing_03_08_EachMatch.groovy ================================================ def myFairStringy = 'The rain in Spain stays mainly in the plain!' // words that end with 'ain': \b\w*ain\b def wordEnding = /\w*ain/ def rhyme = /\b$wordEnding\b/ def found = '' myFairStringy.eachMatch(rhyme) { match -> //#1 found += match + ' ' } assert found == 'rain Spain plain ' found = '' (myFairStringy =~ rhyme).each { match -> //#2 found += match + ' ' } assert found == 'rain Spain plain ' def cloze = myFairStringy.replaceAll(rhyme){ it-'ain'+'___' } //#3 assert cloze == 'The r___ in Sp___ stays mainly in the pl___!' //#1 String.eachMatch(regex){} //#2 Matcher.each {} //#3 String.replaceAll(regex){} ================================================ FILE: listings/chap03/Listing_03_09_PatternReuse.groovy ================================================ def twister = 'she sells sea shells at the sea shore of seychelles' // some more complicated regex: // word that starts and ends with same letter def regex = /\b(\w)\w*\1\b/ def many = 100 * 1000 start = System.nanoTime() many.times{ twister =~ regex //#1 } timeImplicit = System.nanoTime() - start start = System.nanoTime() pattern = ~regex //#A many.times{ pattern.matcher(twister) //#B } timePredef = System.nanoTime() - start assert timeImplicit > timePredef * 2 //#C //#1 Find operator with implicit pattern construction //#A Explicit pattern construction //#B Apply pattern on a string //#C At least twice as fast (possibly 3–5 times) ================================================ FILE: listings/chap03/Listing_03_10_PatternsClassification.groovy ================================================ def fourLetters = ~/\w{4}/ assert fourLetters.isCase('work') assert 'love' in fourLetters switch('beer'){ case fourLetters : assert true; break default : assert false } beasts = ['bear','wolf','tiger','regex'] assert beasts.grep(fourLetters) == ['bear','wolf'] ================================================ FILE: listings/chap03/Listing_03_11_NumberMethodsGDK.groovy ================================================ def store = '' 10.times{ //#A store += 'x' } assert store == 'xxxxxxxxxx' store = '' 1.upto(5) { number -> //#B store += number } assert store == '12345' store = '' 2.downto(-2) { number -> //#C store += number + ' ' } assert store == '2 1 0 -1 -2 ' store = '' 0.step(0.5, 0.1 ){ number -> //#D store += number + ' ' } assert store == '0 0.1 0.2 0.3 0.4 ' //#A Repetition //#B Walking up with loop variable //#C Walking down //#D Walking with step width ================================================ FILE: listings/chap03/extra_escaped_characters_table36.groovy ================================================ println "A '\b' Backspace" println "A '\t' Tab" println "A '\r' Carriage return" println "A '\n' Line feed" println "A '\f' Form feed" println "A '\\' Backslash" println "A '\$' Dollar sign" println "A '\u00A9' (Copyright symbol) - Unicode character U+00A9" println "A '\54' (Comma) - ASCII code 44 (44 decimal = 54 octal)" println "A '\'' Single quote" println "A '\"' Double quote" ================================================ FILE: listings/chap03/extra_method_operators_table34.groovy ================================================ def a = 2 def b = 3 assert a + b == a.plus(b) assert a - b == a.minus(b) assert a * b == a.multiply(b) assert a / b == a.div(b) assert a % b == a.mod(b) a = 2 assert ++a == 2.next() assert a == 3 a = 2 assert a++ == 2 assert a == 3 a = 2 assert --a == 2.previous() assert a == 1 a = 2 assert a-- == 2 assert a == 1 a = 2 assert -a == a.unaryMinus() // added in 2.2.0-beta-2 //assert (+a) == a.unaryPlus() assert a ** b == a.power(b) assert (a | b) == a.or(b) assert (a & b) == a.and(b) assert (a ^ b) == a.xor(b) // added in 2.2.0-beta-2 //assert ~a == a.bitwiseNegate() a = [foo:5] assert a['foo'] == a.getAt('foo') a['bar'] = 6 assert a == [foo:5, bar:6] a = [foo:5] a.putAt('bar', 6) assert a == [foo:5, bar:6] a = 2 assert a << b == a.leftShift(b) assert a >> b == a.rightShift(b) assert a >>> b == a.rightShiftUnsigned(b) enum AgeBand { OLD, YOUNG def isCase(Person p) { p.age in 0..21 == (this == AgeBand.YOUNG) } } class Person { String name int age } def classify(p) { switch(p) { case AgeBand.OLD: return "$p.name is old!" case AgeBand.YOUNG: return "$p.name is young!" } } assert classify(new Person(name: 'Tom', age: 15)) == 'Tom is young!' assert classify(new Person(name: 'Mary', age: 25)) == 'Mary is old!' assert a in b == b.isCase(a) assert (a != b) == !(a == b) assert a <=> b == a.compareTo(b) assert a > b == a.compareTo(b) > 0 assert a >= b == a.compareTo(b) >= 0 assert a < b == a.compareTo(b) < 0 assert a <= b == a.compareTo(b) <= 0 assert a as Integer == a.asType(Integer) ================================================ FILE: listings/chap03/extra_numeric_literals_table32.groovy ================================================ [15, 0x1234ffff, 0b00110011, 100_000_000].each { assert it instanceof Integer } [100L, 200l].each{ assert it instanceof Long } [1.23f, 4.56F].each{ assert it instanceof Float } [1.23d, 4.56D].each{ assert it instanceof Double } [123g, 456G, 1G].each{ assert it instanceof BigInteger } [1.23, 4.56, 1.4E4, 2.8e4, 1.23g, 1.23G, 1.0, 1.0G, 0E1].each{ assert it instanceof BigDecimal } ================================================ FILE: listings/chap03/extra_numerical_coercion_table310.groovy ================================================ assert 1f*2f instanceof Double assert (Byte)1+(Byte)2 instanceof Integer assert 1*2L instanceof Long assert 1 + 0.5 == 1.5 assert 1/2 instanceof BigDecimal assert (1/2) == 0.5 assert (int)(1/2) == 0 assert 1.intdiv(2) == 0 // no coercion when exceeding range with + def a = Integer.MAX_VALUE assert (a+1) instanceof Integer assert (a+1) == Integer.MIN_VALUE assert (a+1L) instanceof Long assert (a+1G) instanceof BigInteger // but does coerce with the power operator assert 2**30 instanceof Integer assert 2**31 instanceof BigInteger assert 2**3.5 instanceof Double assert 2G+1G instanceof BigInteger assert 2.5G+1G instanceof BigDecimal assert 0G == 0.0f assert 1.5G == 1.5f assert !(1.1G == 1.1f) ================================================ FILE: listings/chap03/extra_optional_typing_table33.groovy ================================================ def a = 1; assert a instanceof Integer //|#1 def b = 1.0f; assert b instanceof Float //|#1 int c = 1; assert c instanceof Integer //|#2 float d = 1; assert d instanceof Float //|#2 Integer e = 1; assert e instanceof Integer //|#3 String f = '1'; assert f instanceof String //|#3 ================================================ FILE: listings/chap03/extra_primitive_values_table31.groovy ================================================ byte a = 0 ; assert a instanceof Byte short b = 0 ; assert b instanceof Short int c = 0 ; assert c instanceof Integer long d = 0L ; assert d instanceof Long float e = 0F ; assert e instanceof Float double f = 0D ; assert f instanceof Double char g = 'a' ; assert g instanceof Character boolean h = true ; assert h instanceof Boolean ================================================ FILE: listings/chap03/regex_dgm.txt ================================================ Matcher long size() int getCount() Object getAt( int idx) void setIndex( int idx) boolean hasGroup() Pattern boolean isCase(Object switchValue) String Pattern bitwiseNegate() String replaceFirst(Pattern pattern, String replacement) boolean matches(Pattern pattern) String minus(Object target) // if (target instanceof Pattern) Object splitEachLine(String regex) {match -> ... } String replaceAll(String regex) {match -> ... } String replaceAll(Pattern pattern, String replacement) String find(String regex) String find(Pattern pattern) String find(String regex) {match -> ... } String find(Pattern pattern) {match -> ... } List findAll(String regex) List findAll(Pattern pattern) List findAll(String regex) {match -> ... } List findAll(Pattern pattern) {match -> ... } String eachMatch(String regex) {match -> ... } String eachMatch(Pattern pattern) {match -> ... } File Object splitEachLine(String sep) {match -> ... } Reader Object splitEachLine(String sep) {match -> ... } InputStream Object splitEachLine(String sep, String charset) {match -> ... } Object splitEachLine(String sep) {match -> ... } ================================================ FILE: listings/chap03/snippet0301_autoboxing.groovy ================================================ assert 'ABCDE'.indexOf(67) == 2 ================================================ FILE: listings/chap03/snippet0304_GString_internals.groovy ================================================ def me = 'Tarzan' def you = 'Jane' def line = "me $me - you $you" assert line == 'me Tarzan - you Jane' assert line instanceof GString assert line.strings[0] == 'me ' assert line.strings[1] == ' - you ' assert line.values[0] == 'Tarzan' assert line.values[1] == 'Jane' ================================================ FILE: listings/chap03/snippet0304_stringbuffer.groovy ================================================ def greeting = 'Hello' greeting <<= ' Groovy' //#1 assert greeting instanceof java.lang.StringBuffer greeting << '!' //#2 assert greeting.toString() == 'Hello Groovy!' greeting[1..4] = 'i' //#A assert greeting.toString() == 'Hi Groovy!' //#1 Left shift and assign //#2 Left shift on StringBuffer //#A Substring 'ello' becomes 'i' ================================================ FILE: listings/chap03/snippet0305_matcher_each_group.groovy ================================================ def matcher = 'a:1 b:2 c:3' =~ /(\S+):(\S+)/ matcher.each { full, key, value -> assert full.size() == 3 assert key.size() == 1 // a,b,c assert value.size() == 1 // 1,2,3 } ================================================ FILE: listings/chap03/snippet0305_matcher_groups.groovy ================================================ def matcher = 'a:1 b:2 c:3' =~ /(\S+):(\S+)/ assert matcher.hasGroup() assert matcher[0] == ['a:1', 'a', '1'] // 1st match assert matcher[1][2] == '2' // 2nd match, 2nd group ================================================ FILE: listings/chap03/snippet0305_matcher_parallel_assignment.groovy ================================================ def (a,b,c) = 'a b c' =~ /\S/ assert a == 'a' assert b == 'b' assert c == 'c' ================================================ FILE: listings/chap03/snippet0305_matcher_plain.groovy ================================================ def matcher = 'a b c' =~ /\S/ assert matcher[0] == 'a' assert matcher[1..2] == ['b','c'] assert matcher.size() == 3 ================================================ FILE: listings/chap03/snippet0306_GDK_methods_for_numbers.groovy ================================================ assert 1 == (-1).abs() assert 2 == 2.5.toInteger() // conversion assert 2 == 2.5 as Integer // enforced coercion assert 2 == (int) 2.5 // cast assert 3 == 2.5f.round() assert 3.142 == Math.PI.round(3) assert 4 == 4.5f.trunc() assert 2.718 == Math.E.trunc(3) assert '2.718'.isNumber() // String methods assert 5 == '5'.toInteger() assert 5 == '5' as Integer assert 53 == (int) '5' // gotcha! assert '6 times' == 6 + ' times' // Number + String ================================================ FILE: listings/chap04/Listing_04_01_range_declarations.groovy ================================================ assert (0..10).contains(0) //#A assert (0..10).contains(5) //#A assert (0..10).contains(10) //#A assert (0..10).contains(-1) == false //#A assert (0..10).contains(11) == false //#A assert (0..<10).contains(9) //#B assert (0..<10).contains(10) == false //#B def a = 0..10 //#1 assert a instanceof Range //#1 assert a.contains(5) //#1 a = new IntRange(0,10) //#C assert a.contains(5) //#C assert (0.0..1.0).contains(1.0) //#D assert (0.0..1.0).containsWithinBounds(0.5) //#D def today = new Date() //#2 def yesterday = today - 1 //#2 assert (yesterday..today).size() == 2 //#2 assert ('a'..'c').contains('b') //#3 def log = '' //#E for (element in 5..9){ //#E log += element //#E } //#E assert log == '56789' //#E log = '' //#F for (element in 9..5){ //#F log += element //#F } //#F assert log == '98765' //#F log = '' //#4 (9..<5).each { element -> //#4 log += element //#4 } //#4 assert log == '9876' //#4 //#A Inclusive ranges //#B Half-exclusive ranges //#1 References to ranges //#C Explicit construction //#D Bounds checking //#2 Date ranges //#3 String ranges //#E for-in-range loop //#F Loop with reverse range //#4 Half-exclusive, reverse, each with closure ================================================ FILE: listings/chap04/Listing_04_02_ranges_are_objects.groovy ================================================ def result = '' //#A (5..9).each { element -> //#A result += element //#A } //#A assert result == '56789' //#A assert 5 in 0..10 //#1 assert (0..10).isCase(5) //#1 //#1 def age = 36 //#1 switch(age){ //#1 case 16..20 : insuranceRate = 0.05 ; break //#1 case 21..50 : insuranceRate = 0.06 ; break //#1 case 51..65 : insuranceRate = 0.07 ; break //#1 default: throw new IllegalArgumentException() //#1 } //#1 assert insuranceRate == 0.06 //#1 def ages = [20, 36, 42, 56] //#2 def midage = 21..50 //#2 assert ages.grep(midage) == [36, 42] //#2 //#A Iterating over a range //#1 Ranges for classification //#2 Filtering with ranges ================================================ FILE: listings/chap04/Listing_04_03_custom_ranges.groovy ================================================ class Weekday implements Comparable { static final DAYS = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ] private int index = 0 Weekday(String day) { //#A index = DAYS.indexOf(day) } Weekday next() { return new Weekday(DAYS[(index + 1) % DAYS.size()]) } Weekday previous() { return new Weekday(DAYS[index - 1]) //#1 } int compareTo(Object other) { return this.index <=> other.index } String toString() { return DAYS[index] } } def mon = new Weekday('Mon') def fri = new Weekday('Fri') def worklog = '' for (day in mon..fri) { //#B worklog += day.toString() + ' ' } assert worklog == 'Mon Tue Wed Thu Fri ' //#A Allow all values //#1 Range bound methods //#B Working through the week ================================================ FILE: listings/chap04/Listing_04_04_list_declarations.groovy ================================================ List myList = [1, 2, 3] assert myList.size() == 3 assert myList[0] == 1 assert myList instanceof ArrayList List emptyList = [] assert emptyList.size() == 0 List longList = (0..1000).toList() assert longList[555] == 555 List explicitList = new ArrayList() explicitList.addAll(myList) //#1 assert explicitList.size() == 3 explicitList[0] = 10 assert explicitList[0] == 10 explicitList = new LinkedList(myList) //#1 assert explicitList.size() == 3 explicitList[0] = 10 assert explicitList[0] == 10 //#1 Fill from myList //////////////////////// extra examples: assert args instanceof String[] //#2 assert args.size() == 0 //#3 List flat = [0, *myList, 4] //#4 assert flat == [0, 1, 2, 3, 4] //#2 Command-line args //#3 Array as list //#4 Spread ================================================ FILE: listings/chap04/Listing_04_05_list_subscript_operator.groovy ================================================ def myList = ['a','b','c','d','e','f'] assert myList[0..2] == ['a','b','c'] //#A assert myList[0,2,4] == ['a','c','e'] //#B myList[0..2] = ['x','y','z'] //#C assert myList == ['x','y','z','d','e','f'] myList[3..5] = [] //#1 assert myList == ['x','y','z'] myList[1..1] = [0, 1, 2] //#2 assert myList == ['x', 0, 1, 2, 'z'] //#A getAt(Range) //#B getAt(collection of indexes) //#C putAt(Range) //#1 Removing elements //#2 Adding elements ================================================ FILE: listings/chap04/Listing_04_06_list_add_remove.groovy ================================================ myList = [] myList += 'a' //#A assert myList == ['a'] myList += ['b','c'] //#B assert myList == ['a','b','c'] myList = [] myList << 'a' << 'b' //#C assert myList == ['a','b'] assert myList - ['b'] == ['a'] //#D assert myList * 2 == ['a','b','a','b'] //#E //#A plus(Object) //#B plus(Collection) //#C leftShift is like append //#D minus(Collection) //#E Multiply ================================================ FILE: listings/chap04/Listing_04_07_lists_control_structures.groovy ================================================ myList = ['a', 'b', 'c'] assert myList.isCase('a') assert 'b' in myList def candidate = 'c' switch(candidate){ case myList : assert true; break //#1 default : assert false } assert ['x','a','z'].grep(myList) == ['a'] //#2 myList = [] if (myList) assert false //#3 // Lists can be iterated with a 'for' loop def expr = '' for (i in [1,'*',5]){ //#4 expr += i } assert expr == '1*5' //#1 Classify by containment //#2 Intersection filter //#3 Empty lists are false //#4 for in Collection ================================================ FILE: listings/chap04/Listing_04_08_list_content_manipulation.groovy ================================================ assert [1,[2,3]].flatten() == [1,2,3] assert [1,2,3].intersect([4,3,1])== [3,1] assert [1,2,3].disjoint([4,5,6]) list = [1,2,3] popped = list.pop() //#1 assert popped == 3 assert list == [1,2] assert [1,2].reverse() == [2,1] assert [3,1,2].sort() == [1,2,3] list = [ [1,0], [0,1,2] ] list = list.sort { a,b -> a[0] <=> b[0] } //#2 assert list == [ [0,1,2], [1,0] ] list = list.sort { item -> item.size() } //#3 assert list == [ [1,0], [0,1,2] ] list = ['a','b','c'] list.remove(2) //#4 assert list == ['a','b'] list.remove('b') //#5 assert list == ['a'] list = ['a','b','b','c'] list.removeAll(['b','c']) assert list == ['a'] def doubled = [1,2,3].collect{ item -> //#6 item*2 } assert doubled == [2,4,6] def odd = [1,2,3].findAll{ item -> //#7 item % 2 == 1 } assert odd == [1,3] //#1 Treating a list like a stack //#2 Comparing lists by first element //#3 Comparing lists by size //#4 Removing by index //#5 Removing by value //#6 Transforming one list into another //#7 Finding every element matching the closure ================================================ FILE: listings/chap04/Listing_04_09_list_other_methods.groovy ================================================ def list = [1, 2, 3] assert list.first() == 1 assert list.head() == 1 assert list.tail() == [2, 3] assert list.last() == 3 assert list.count(2) == 1 //#A assert list.max() == 3 //#A assert list.min() == 1 //#A //#A def even = list.find { item -> //#A item % 2 == 0 //#A } //#A assert even == 2 //#A //#A assert list.every { item -> item < 5 } //#A assert list.any { item -> item < 2 } //#A def store = '' list.each { item -> //#B store += item //#B } //#B assert store == '123' //#B //#B store = '' //#B list.reverseEach { item -> //#B store += item //#B } //#B assert store == '321' //#B //#B store = '' //#B list.eachWithIndex { item, index -> //#B store += "$index:$item " //#B } //#B assert store == '0:1 1:2 2:3 ' //#B assert list.join('-') == '1-2-3' //#C //#C result = list.inject(0) { clinks, guests -> //#C clinks + guests //#C } //#C assert result == 0 + 1 + 2 + 3 //#C assert list.sum() == 6 //#C //#C factorial = list.inject(1) { fac, item -> //#C fac * item //#C } //#C assert factorial == 1 * 1 * 2 * 3 //#C //#A Querying //#B Iteration //#C Accumulation ================================================ FILE: listings/chap04/Listing_04_10_list_quicksort.groovy ================================================ def quickSort(list) { if (list.size() < 2) return list def pivot = list[list.size().intdiv(2)] def left = list.findAll { item -> item < pivot } //#1 def middle = list.findAll { item -> item == pivot } //#1 def right = list.findAll { item -> item > pivot } //#1 return quickSort(left) + middle + quickSort(right) //#A } assert quickSort([]) == [] assert quickSort([1]) == [1] assert quickSort([1,2]) == [1,2] assert quickSort([2,1]) == [1,2] assert quickSort([3,1,2]) == [1,2,3] assert quickSort([3,1,2,2]) == [1,2,2,3] assert quickSort([1.0f,'a',10,null]) == [null,1.0f,10,'a'] //#2 assert quickSort('bca') == 'abc'.toList() //#3 //#1 Classify by pivot //#A Recursive calls //#2 Ducktyped items //#3 Ducktyped structure ================================================ FILE: listings/chap04/Listing_04_11_list_mapreduce.groovy ================================================ def urls = [ new URL('http', 'myshop.com', 80, 'index.html'), new URL('https', 'myshop.com', 443, 'buynow.html'), new URL('ftp', 'myshop.com', 21, 'downloads') ] assert urls .findAll{ it.port < 99 } .collect{ it.file.toUpperCase() } .sort() .join(', ') == 'DOWNLOADS, INDEX.HTML' ================================================ FILE: listings/chap04/Listing_04_12_map_declarations.groovy ================================================ def myMap = [a:1, b:2, c:3] assert myMap instanceof LinkedHashMap assert myMap.size() == 3 assert myMap['a'] == 1 def emptyMap = [:] assert emptyMap.size() == 0 def explicitMap = new TreeMap() explicitMap.putAll(myMap) assert explicitMap['a'] == 1 def composed = [x:'y', *:myMap] //#A assert composed == [x:'y', a:1, b:2, c:3] //#A Spread operator ================================================ FILE: listings/chap04/Listing_04_13_map_accessors.groovy ================================================ def myMap = [a:1, b:2, c:3] assert myMap['a'] == 1 //#A assert myMap.a == 1 //#A assert myMap.get('a') == 1 //#A assert myMap.get('a',0) == 1 //#A assert myMap['d'] == null //#B assert myMap.d == null //#B assert myMap.get('d') == null //#B assert myMap.get('d',0) == 0 //#C assert myMap.d == 0 //#C myMap['d'] = 1 //#D assert myMap.d == 1 //#D myMap.d = 2 //#D assert myMap.d == 2 //#D //#A Retrieve existing elements //#B Attempt to retrieve missing elements //#C Default value //#D Single putAt ================================================ FILE: listings/chap04/Listing_04_14_map_query_methods.groovy ================================================ def myMap = [a:1, b:2, c:3] def other = [b:2, c:3, a:1] assert myMap == other //#A assert !myMap.isEmpty() //#B assert myMap.size() == 3 //#B assert myMap.containsKey('a') //#B assert myMap.containsValue(1) //#B assert myMap.entrySet() instanceof Collection //#B assert myMap.any {entry -> entry.value > 2 } //#1 assert myMap.every {entry -> entry.key < 'd'} //#1 assert myMap.keySet() == ['a','b','c'] as Set //#C assert myMap.values().toList() == [1, 2, 3] //#D //#A Call to equals //#B JDK methods //#1 GDK methods //#C Set equals //#D List equals ================================================ FILE: listings/chap04/Listing_04_15_map_iteration.groovy ================================================ def myMap = [a:1, b:2, c:3] def store = '' myMap.each { entry -> //#A store += entry.key //#A store += entry.value //#A } //#A assert store == 'a1b2c3' store = '' myMap.each { key, value -> //#B store += key //#B store += value //#B } //#B assert store == 'a1b2c3' store = '' for (key in myMap.keySet()) { //#C store += key //#C } //#C assert store == 'abc' store = '' for (value in myMap.values()) { //#D store += value //#D } //#D assert store == '123' //#A Iterate over entries //#B Iterate over keys/values //#C Iterate over just the keys //#D Iterate over just the values ================================================ FILE: listings/chap04/Listing_04_16_map_content.groovy ================================================ def myMap = [a:1, b:2, c:3] myMap.clear() assert myMap.isEmpty() myMap = [a:1, b:2, c:3] myMap.remove('a') assert myMap.size() == 2 assert [a:1] + [b:2] == [a:1, b:2] myMap = [a:1, b:2, c:3] def abMap = myMap.subMap(['a', 'b']) //#1 assert abMap.size() == 2 abMap = myMap.findAll { entry -> entry.value < 3 } assert abMap.size() == 2 assert abMap.a == 1 def found = myMap.find { entry -> entry.value < 2 } assert found.key == 'a' assert found.value == 1 def doubled = myMap.collect { entry -> entry.value *= 2 } assert doubled instanceof List assert doubled.every { item -> item % 2 == 0 } def addTo = [] myMap.collect(addTo) { entry -> entry.value *= 2 } assert addTo instanceof List assert addTo.every { item -> item % 2 == 0 } //#1 Create a view onto the original map ================================================ FILE: listings/chap04/Listing_04_17_map_example.groovy ================================================ def textCorpus = """ Look for the bare necessities The simple bare necessities Forget about your worries and your strife I mean the bare necessities Old Mother Nature's recipes That bring the bare necessities of life """ def words = textCorpus.tokenize() def wordFrequency = [:] words.each { word -> wordFrequency[word] = wordFrequency.get(word,0) + 1 //#1 } def wordList = wordFrequency.keySet().toList() wordList.sort { wordFrequency[it] } //#2 def statistic = "\n" wordList[-1..-5].each { word -> statistic += word.padLeft(12) + ': ' statistic += wordFrequency[word] + "\n" } assert statistic == """ necessities: 4 bare: 4 the: 3 your: 2 life: 1 """ //#1 Update frequency count //#2 Sort by frequency ================================================ FILE: listings/chap04/extra_EnumRange.groovy ================================================ enum Month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec } def noClams = Month.May .. Month.Aug def thisMonth = Month.Aug boolean iWarnedYou = false if (thisMonth in noClams) { //#1 println "Don't eat clams this month," println "it has no 'r' in its name!" iWarnedYou = true } assert iWarnedYou //#1 'in' operator ================================================ FILE: listings/chap04/extra_ListCast.groovy ================================================ Set names = ['Dierk', 'Paul'] as Set assert names instanceof Set assert names.toListString() ==~ /\[\w+, \w+\]/ assert names.asList() instanceof List java.awt.Point p = [10, 20] assert p.x == 10 ================================================ FILE: listings/chap04/extra_ListTable.groovy ================================================ def table = [ [0, 1], [2, 3] ] table = table.collectNested { item -> item + 1 } assert table == [ [1, 2], [3, 4] ] assert table.transpose() == [ [1, 3], [2, 4] ] assert table.combinations() == [ [1, 3], [2, 3], [1, 4], [2, 4] ] ================================================ FILE: listings/chap04/extra_Map_as.groovy ================================================ def absComp = [ compare: { a,b -> a.abs() <=> b.abs() } ] def list = [-3, -1, 2] list.sort(true, absComp as Comparator) assert list == [-1, 2, -3] ================================================ FILE: listings/chap04/extra_Map_group.groovy ================================================ def tzones = [ dierk: +1, guillaume: +1, jon: 0, paul: +9, tara: -7 ] assert tzones.groupBy { key, val -> val.intdiv 5 } == [ 0: [dierk:1, guillaume:1, jon:0], 1: [paul: 9], (-1): [tara:-7] ] ================================================ FILE: listings/chap04/extra_MaxMinSum.groovy ================================================ def kings = ['Dierk', 'Paul'] assert kings.max { item -> item.size() } == 'Dierk' assert kings.min { item -> item.size() } == 'Paul' assert kings.sum { item -> item.size() } == 9 ================================================ FILE: listings/chap04/extra_SplitList.groovy ================================================ def list = [0, 3, 2, 1] def (small, big) = list.split { it < 2 } assert small == [0, 1] assert big == [3, 2] def group = list.groupBy { it % 2 } assert group[0] == [0, 2] assert group[1] == [3, 1] ================================================ FILE: listings/chap04/snippet0402_ListAsSet.groovy ================================================ def x = [1, 1, 1] assert [1] == new HashSet(x).toList() assert [1] == x.unique() assert [1] == [1, '1'].unique { item -> item.toInteger() } ================================================ FILE: listings/chap04/snippet0402_ListRemoveNulls.groovy ================================================ List x = [1, null, null, 2] assert [1, 2] == x.findAll { it != null } assert [1, 2] == x.grep { it } assert [1, 2] == x - [null] x.removeAll([null]) assert [1, 2] == x ================================================ FILE: listings/chap04/snippet0402_ListStreams_jdk8_plus.groovy ================================================ def urls = [ new URL('http', 'myshop.com', 80, 'index.html'), new URL('https', 'myshop.com', 443, 'buynow.html'), new URL('ftp', 'myshop.com', 21, 'downloads') ] // Groovy with Java 8 import java.util.stream.Collectors def commaSep = Collectors.joining(", ") assert urls.stream() .filter{ it.port < 99 } .map{ it.file.toUpperCase() } .sorted() .collect(commaSep) == 'DOWNLOADS, INDEX.HTML' ================================================ FILE: listings/chap04/snippet0403_Map_Ctor_Expression.groovy ================================================ def x = 'a' assert ['x':1] == [x:1] assert ['a':1] == [(x):1] ================================================ FILE: listings/chap04/snippet0403_Map_Ctor_Unquoted.groovy ================================================ assert ['a':1] == [a:1] ================================================ FILE: listings/chap04/snippet0403_Map_MapReduce.groovy ================================================ def people = [peter: 40, paul: 30, mary: 20] assert people .findAll{ _, age -> age < 35 } .collect{ name, _ -> name.toUpperCase() } .sort() .join(', ') == 'MARY, PAUL' ================================================ FILE: listings/chap04/snippet0403_Map_String_accessors.groovy ================================================ def myMap = ['a.b':1] assert myMap.'a.b' == 1 ================================================ FILE: listings/chap05/Listing_05_01_closure_simple_declaration.groovy ================================================ def log = '' (1..10).each { counter -> log += counter } assert log == '12345678910' log = '' (1..10).each { log += it } assert log == '12345678910' ================================================ FILE: listings/chap05/Listing_05_02_simple_method_closure.groovy ================================================ class SizeFilter { Integer limit boolean sizeUpTo(String value) { return value.size() <= limit } } SizeFilter filter6 = new SizeFilter(limit:6) //#1 SizeFilter filter5 = new SizeFilter(limit:5) //#1 Closure sizeUpTo6 = filter6.&sizeUpTo //#2 def words = ['long string', 'medium', 'short', 'tiny'] assert 'medium' == words.find (sizeUpTo6) //#3 assert 'short' == words.find (filter5.&sizeUpTo) //#4 //#1 GroovyBean constructor calls //#2 Method closure assignment //#3 Calling with closure //#4 Passing a method closure directly ================================================ FILE: listings/chap05/Listing_05_03_multi_method_closure.groovy ================================================ class MultiMethodSample { int mysteryMethod (String value) { return value.length() } int mysteryMethod (List list) { return list.size() } int mysteryMethod (int x, int y) { return x+y } } MultiMethodSample instance = new MultiMethodSample() Closure multi = instance.&mysteryMethod //#1 assert 10 == multi ('string arg') //#2 assert 3 == multi (['list', 'of', 'values']) //#2 assert 14 == multi (6, 8) //#2 //#1 Only a single closure is created //#2 Different implementations are called based on argument types ================================================ FILE: listings/chap05/Listing_05_04_closure_all_declarations.groovy ================================================ Map map = ['a':1, 'b':2] map.each{ key, value -> map[key] = value * 2 } //#1 assert map == ['a':2, 'b':4] Closure doubler = {key, value -> map[key] = value * 2 }//#2 map.each(doubler) //#2 assert map == ['a':4, 'b':8] def doubleMethod (entry){ //#3 entry.value = entry.value * 2 //#3 } doubler = this.&doubleMethod //#4 map.each(doubler) //#4 assert map == ['a':8, 'b':16] //#1 Parameter sequence with commas //#2 Assign and then call a closure reference //#3 Usual method declaration //#4 Reference and call a method as a closure ================================================ FILE: listings/chap05/Listing_05_05_simple_closure_calling.groovy ================================================ def adder = { x, y -> return x+y } assert adder(4, 3) == 7 assert adder.call(2, 6) == 8 ================================================ FILE: listings/chap05/Listing_05_06_calling_closures.groovy ================================================ def benchmark(int repeat, Closure worker) { //#1 def start = System.nanoTime() //#2 repeat.times { worker(it) } //#3 def stop = System.nanoTime() //#4 return stop - start //#4 } def slow = benchmark(10000) { (int) it / 2 } //#5 def fast = benchmark(10000) { it.intdiv(2) } //#5 assert fast * 2 < slow //#5 //#1 Put closures last //#2 Some pre-work //#3 Call closure the given number of times //#4 Some post-work //#5 Pass different closures for analysis ================================================ FILE: listings/chap05/Listing_05_07_simple_currying.groovy ================================================ def mult = { x, y -> return x * y } def twoTimes = mult.curry(2) assert twoTimes(5) == 10 ================================================ FILE: listings/chap05/Listing_05_08_logging_curry_example.groovy ================================================ def configurator = { format, filter, line -> //#1 filter(line) ? format(line) : null //#1 } def appender = { config, append, line -> //#2 def out = config(line) //#2 if (out) append(out) //#2 } def dateFormatter = { line -> "${new Date()}: $line" } //#3 def debugFilter = { line -> line.contains('debug') } //#3 def consoleAppender = { line -> println line } //#3 def myConf = configurator.curry(dateFormatter, debugFilter) //#4 def myLog = appender.curry(myConf, consoleAppender) //#4 myLog('here is some debug message') myLog('this will not be printed') //#1 Configuration use //#2 Formatting use //#3 Filter, format, and output parts //#4 Putting it all together ================================================ FILE: listings/chap05/Listing_05_09_closure_scope.groovy ================================================ class Mother { def prop = 'prop' def method(){ 'method' } Closure birth (param) { //#1 def local = 'local' def closure = { [ this, prop, method(), local, param ] } return closure } } Mother julia = new Mother() def closure = julia.birth('param') //#2 def context = closure.call() //#3 assert context[0] == julia //#4 assert context[1, 2] == ['prop', 'method'] //#5 assert context[3, 4] == ['local', 'param' ] //#6 assert closure.thisObject == julia //|#7 assert closure.owner == julia //|#7 assert closure.delegate == julia //|#8 assert closure.resolveStrategy == Closure.OWNER_FIRST //|#8 //#1 Creation method //#2 Closure declaration time //#3 Closure execution time //#4 What "this" refers to //#5 Free variables, resolved //#6 Bound variables //#7 Read only //#8 Scope control ================================================ FILE: listings/chap05/Listing_05_10_closure_accumulator.groovy ================================================ def foo(n) { return { n += it } } def accumulator = foo(1) assert accumulator(2) == 3 assert accumulator(1) == 4 ================================================ FILE: listings/chap05/Listing_05_11_visitor_pattern.groovy ================================================ class Drawing { List shapes def accept(Closure yield) { shapes.each{it.accept(yield)} } } class Shape { def accept(Closure yield) { yield(this) } } class Square extends Shape { def width def area() { width**2 } } class Circle extends Shape { def radius def area() { Math.PI * radius**2 } } def picture = new Drawing(shapes: [new Square(width:1), new Circle(radius:1)]) def total = 0 picture.accept { total += it.area() } println "The shapes in this drawing cover an area of $total units." println 'The individual contributions are: ' picture.accept { println it.class.name + ":" + it.area() } ================================================ FILE: listings/chap05/extra_ClosureProperty.groovy ================================================ class GrailsController { def params = [a:1, b:2] def list = { params.keySet().toList() } } def controller = new GrailsController() assert controller.list() == ['a', 'b'] controller.list = { controller.params.values().toList() } assert controller.list() == [1, 2] ================================================ FILE: listings/chap05/extra_Closure_delegate.groovy ================================================ def list = [] def expected = [1, 2] list.with { add 1 add 2 assert delegate == expected } ================================================ FILE: listings/chap05/extra_Closure_myWith.groovy ================================================ def with(Closure doit) { // fake implementation doit.delegate = list doit() } ================================================ FILE: listings/chap05/snippet0501_envelope.groovy.txt ================================================ Closure envelope = { person -> new Letter(person).send() } addressBook.each (envelope) ================================================ FILE: listings/chap05/snippet0504_closure_default_params.groovy ================================================ def adder = { x, y=5 -> return x+y } assert adder(4, 3) == 7 assert adder.call(7) == 12 ================================================ FILE: listings/chap05/snippet0504_closure_isCase.groovy ================================================ def odd = { it % 2 == 1} assert [1,2,3].grep(odd) == [1, 3] switch(10) { case odd : assert false } if (2 in odd) assert false ================================================ FILE: listings/chap05/snippet0504_closure_paramcount.groovy ================================================ def numParams (Closure closure){ closure.getMaximumNumberOfParameters() } assert numParams { one -> } == 1 assert numParams { one, two -> } == 2 def paramTypes (Closure closure){ closure.getParameterTypes() } assert paramTypes { String s -> } == [String] assert paramTypes { Number n, Date d -> } == [Number, Date] ================================================ FILE: listings/chap05/snippet0505_map_with.groovy ================================================ def map = [:] map.with { a = 1 b = 2 } assert map == [a:1, b:2] ================================================ FILE: listings/chap05/snippet0505_scoping.groovy ================================================ def x = 0 10.times { x++ } assert x == 10 ================================================ FILE: listings/chap05/snippet0506_closure_return.groovy ================================================ assert [2, 4, 6] == [1, 2, 3].collect { it * 2 } assert [2, 4, 6] == [1, 2, 3].collect { return it * 2 } assert [1, 4, 3] == [1, 2, 3].collect { if (it % 2 == 0) return it * 2 return it } ================================================ FILE: listings/chap05/snippet0507_closure_composition.groovy ================================================ def mult = { x, y -> return x * y } def twoTimes = mult.curry(2) assert twoTimes(5) == 10 def fourTimes = twoTimes >> twoTimes def eightTimes = twoTimes << fourTimes assert eightTimes(1) == twoTimes(fourTimes(1)) ================================================ FILE: listings/chap05/snippet0508_memoize.groovy ================================================ def fib fib = { it < 2 ? 1 : fib(it-1) + fib(it-2) } fib = fib.memoize() assert fib(40) == 165_580_141 // nano time // without memoize 22_903_497_000 // with memoize 1_074_000 ================================================ FILE: listings/chap05/snippet0509_trampoline.groovy ================================================ def last last = { it.size() == 1 ? it.head() : last.trampoline(it.tail()) } last = last.trampoline() assert last(0..10_000) == 10_000 ================================================ FILE: listings/chap06/Listing_06_01_groovy_truth.groovy ================================================ assert true //#A assert !false //#A assert ('a' =~ /./) //#B assert !('a' =~ /b/) //#B assert [1] //#C assert ![] //#C Iterator iter = [1].iterator() assert iter //#D iter.next() //#D assert !iter //#D assert ['a':1] //#E assert ![:] //#E assert 'a' //#F assert !'' //#F assert 1 //#G assert 1.1 //#G assert 1.2f //#G assert 1.3g //#G assert 2L //#G assert 3G //#G assert !0 //#G assert ! null //#H assert new Object() //#H class AlwaysFalse { boolean asBoolean() { false } //#I } assert ! new AlwaysFalse() //#J //#A Boolean values are trivial //#B Matchers must match //#C Collections must be nonempty //#D Iterators must have next element //#E Maps must be nonempty //#F Strings must be nonempty //#G Numbers (any type) must be nonzero //#H Objects must be non-null //#I Custom truth //#J Calls asBoolean() ================================================ FILE: listings/chap06/Listing_06_02_assignment_bug.groovy ================================================ def x = 1 if (x == 2) { //#1 assert false } /******************* if (x = 2) { //#2 println x } ********************/ if ((x = 3)) { //#3 println x } assert x == 3 def store = [] while (x = x - 1) { //#4 store << x } assert store == [2, 1] while (x = 2) { //#5 println x break } //#1 Normal comparison //#2 Not allowed; compiler error //#3 Assign and test in nested expression //#4 Deliberate assign and test in while //#5 Ouch—this will print 2 ================================================ FILE: listings/chap06/Listing_06_03_if_then_else.groovy ================================================ if (true) assert true else assert false if (1) { assert true } else { assert false } if ('nonempty') assert true else if (['x']) assert false else assert false if (0) assert false else if ([]) assert false else assert true ================================================ FILE: listings/chap06/Listing_06_04_conditional_operator.groovy ================================================ def result = (1==1) ? 'ok' : 'failed' assert result == 'ok' result = 'some string' ? 10 : ['x'] assert result == 10 ================================================ FILE: listings/chap06/Listing_06_05_switch_basic.groovy ================================================ def a = 1 def log = '' switch (a) { case 0 : log += '0' //#A case 1 : log += '1' //#A case 2 : log += '2' ; break default : log += 'default' } assert log == '12' //#A Fall through ================================================ FILE: listings/chap06/Listing_06_06_switch_advanced.groovy ================================================ switch (10) { case 0 : assert false ; break case 0..9 : assert false ; break case [8,9,11] : assert false ; break case Float : assert false ; break //#1 case {it%3 == 0}: assert false ; break //#2 case ~/../ : assert true ; break //#3 default : assert false ; break } //#1 Type case //#2 Closure case //#3 Regular expression case ================================================ FILE: listings/chap06/Listing_06_07_assert_host.groovy ================================================ def host = /\/\/([a-zA-Z0-9-]+(\.[a-zA-Z0-9-])*?)(:|\/)/ //#A assertHost 'http://a.b.c:8080/bla', host, 'a.b.c' assertHost 'http://a.b.c/bla', host, 'a.b.c' assertHost 'http://127.0.0.1:8080/bla', host, '127.0.0.1' assertHost 'http://t-online.de/bla', host, 't-online.de' assertHost 'http://T-online.de/bla', host, 'T-online.de' def assertHost (candidate, regex, expected){ candidate.eachMatch(regex){ assert it[1] == expected } } // ... use host regex ... //#B //#A Regular expression matching host //#B Trailing code goes here ================================================ FILE: listings/chap06/Listing_06_08_while.groovy ================================================ def list = [1, 2, 3] while (list) { list.remove(0) } assert list == [] while (list.size() < 3) list << list.size() + 1 assert list == [1, 2, 3] ================================================ FILE: listings/chap06/Listing_06_09_for.groovy ================================================ def store = '' //#1 for (String s in 'a'..'c') store += s //#1 assert store == 'abc' //#1 store = '' //#2 for (i in [1, 2, 3]) { //#2 store += i //#2 } //#2 assert store == '123' //#2 def myString = 'Old school Java' //#3 store = '' //#3 for (int i=0; i < myString.size(); i++) { //#3 store += myString[i] //#3 } //#3 assert store == myString //#3 myString = 'Java range index' //#4 store = '' //#4 for (int i : 0 ..< myString.size()) { //#4 store += myString[i] //#4 } //#4 assert store == myString //#4 myString = 'Groovy range index' //#5 store = '' //#5 for (i in 0 ..< myString.size()) { //#5 store += myString[i] //#5 } //#5 assert store == myString //#5 myString = 'Java string Iterable' //#6 store = '' //#6 for (String s : myString) { //#6 store += s //#6 } //#6 assert store == myString //#6 myString = 'Groovy iterator' //#7 store = '' //#7 for (s in myString) { //#7 store += s //#7 } //#7 assert store == myString //#7 //#1 Explicit typing, over string range, no braces //#2 Implicit typing, over list as collection, braces //#3 Explicit typing, Java-style traditional for loop, braces //#4 Explicit typing, Java-style iterable index, braces //#5 Implicit typing, over half-exclusive IntRange, braces //#6 Explicit typing, Java-style iterable value, braces //#7 Implicit typing, over string as collection, braces ================================================ FILE: listings/chap06/Listing_06_10_break_continue.groovy ================================================ def a = 1 while (true) { //#A a++ break //#B } assert a == 2 for (i in 0..10) { if (i==0) continue //#C a++ if (i > 0) break //#D } assert a==3 //#A Do forever //#B Forever is over now //#C Proceed with 1 //#D Premature loop end ================================================ FILE: listings/chap06/Listing_06_11_exception_example.groovy ================================================ def myMethod() { throw new IllegalArgumentException() } def log = [] try { myMethod() } catch (Exception e) { log << e.toString() } finally { log << 'finally' } assert log.size() == 2 ================================================ FILE: listings/chap06/extra_if_return.groovy ================================================ def mac() { if (System.properties.'os.name'.contains('Mac')) "We're on Mac." // no 'return' else "Oh, well ..." // no 'return' } println mac() ================================================ FILE: listings/chap06/extra_in_operator.groovy ================================================ assert 1 in [0, 1, 2] // list assert 1 in 0..3 // range assert 'Hello' in String // class assert 'Hello' in ~/H.*/ // pattern ================================================ FILE: listings/chap06/extra_switch_return.groovy ================================================ def mac() { switch(System.properties.'os.name') { case 'Mac OS X': "We're on Mac."; break // no 'return' default: "Oh, well ..." // no 'return' } } println mac() ================================================ FILE: listings/chap06/myFileName.txt ================================================ line one line two ================================================ FILE: listings/chap06/snippet0602_bad_file_read.groovy ================================================ try { input = new File('no such file') assert input.exists() assert input.canRead() println input.text } catch (AssertionError error) { assert "\n" + error.message == ''' assert input.exists() | | | false no such file''' } ================================================ FILE: listings/chap06/snippet0602_bad_file_read_with_message.groovy ================================================ try { input = new File('/no such file') assert input.exists(), "cannot find: $input.canonicalPath" assert input.canRead() println input.text } catch (AssertionError error) { def root = new File('/').canonicalPath assert error.message == 'cannot find: ' + root + 'no such file. ' + 'Expression: input.exists()' } ================================================ FILE: listings/chap06/snippet0602_failing_assert.groovy ================================================ def a = 1 try { assert a == 2 } catch (AssertionError error) { assert "\n" + error.message ==''' assert a == 2 | | 1 false''' } ================================================ FILE: listings/chap06/snippet0603_each_loop_iterate.groovy ================================================ (0..9).each { println it } ================================================ FILE: listings/chap06/snippet0603_file_iterate_lines.groovy ================================================ def file = new File('myFileName.txt') for (line in file) println line ================================================ FILE: listings/chap06/snippet0603_for_loop_iterate.groovy ================================================ for (x in 0..9) { println x } ================================================ FILE: listings/chap06/snippet0603_null_iterate.groovy ================================================ for (x in null) println 'This will not be printed!' ================================================ FILE: listings/chap06/snippet0603_object_iterate.groovy ================================================ for (x in new Object()) println "Printed once for object $x" ================================================ FILE: listings/chap06/snippet0603_regex_iterate_match.groovy ================================================ def matcher = '12xy3'=~/\d/ for (match in matcher) println match ================================================ FILE: listings/chap06/snippet0604_multicatch.groovy ================================================ try { if (Math.random() < 0.5) 1 / 0 else null.hashCode() } catch (ArithmeticException | NullPointerException exception) { println exception.class.name } ================================================ FILE: listings/chap07/Listing_07_01_Declaring_Variables.groovy ================================================ class ClassWithTypedAndUntypedFieldsAndProperties { public fieldWithModifier String typedField def untypedField protected field1, field2, field3 private assignedField = new Date() static classField public static final String CONSTA = 'a', CONSTB = 'b' def someMethod(){ def localUntypedMethodVar = 1 int localTypedMethodVar = 1 def localVarWithoutAssignment, andAnotherOne } } def localvar = 1 //#A boundvar1 = 1 //#B def someMethod(){ //#C def localMethodVar = 1 //#C boundvar2 = 1 //#C } //#C someMethod() //#A Local variable to the script //#B From the binding //#C Local method to the script ================================================ FILE: listings/chap07/Listing_07_02_TypeBreaking_Assignment.groovy ================================================ final String PI = '3.14' assert PI.class.name == 'java.lang.String' assert PI.size() == 4 GroovyAssert.shouldFail(ClassCastException){ Float areaOfCircleRadiusOne = PI } ================================================ FILE: listings/chap07/Listing_07_03_Referencing_Fields.groovy ================================================ class Counter { public count = 0 } def counter = new Counter() counter.count = 1 assert counter.count == 1 def fieldName = 'count' counter[fieldName] = 2 assert counter['count'] == 2 ================================================ FILE: listings/chap07/Listing_07_04_Overriding_Field_Access.groovy ================================================ class PretendFieldCounter { public count = 0 Object get (String name) { return 'pretend value' } void set (String name, Object value) { count++ } } def pretender = new PretendFieldCounter() assert pretender.isNoField == 'pretend value' assert pretender.count == 0 pretender.isNoFieldEither = 'just to increase counter' assert pretender.count == 1 ================================================ FILE: listings/chap07/Listing_07_05_Declaring_Methods.groovy ================================================ class ClassWithTypedAndUntypedMethods { static void main(args) { //#1 def some = new ClassWithTypedAndUntypedMethods() some.publicVoidMethod() assert 'hi' == some.publicUntypedMethod() assert 'ho' == some.publicTypedMethod() combinedMethod() //#A } void publicVoidMethod() { } def publicUntypedMethod() { return 'hi' } String publicTypedMethod() { return 'ho' } private static final void combinedMethod() { } } //#1 Implicit public //#A Call static method of current class ================================================ FILE: listings/chap07/Listing_07_06_Declaring_Parameters.groovy ================================================ class ClassWithTypedAndUntypedMethodParams { static void main(args) { assert 'untyped' == method(1) assert 'typed' == method('whatever') assert 'two args' == method(1, 2) } static method(arg) { return 'untyped' } static method(String arg) { return 'typed' } static method(arg1, Number arg2) { return 'two args' } } ================================================ FILE: listings/chap07/Listing_07_07_Parameter_Usages.groovy ================================================ class Summer { def sumWithDefaults(a, b, c=0){ //#1 return a + b + c } def sumWithList(List args){ //#2 return args.inject(0){sum,i -> sum += i} } def sumWithOptionals(a, b, Object[] optionals){ //#3 return a + b + sumWithList(optionals.toList()) } def sumNamed(Map args){ //#4 ['a','b','c'].each{args.get(it,0)} return args.a + args.b + args.c } } def summer = new Summer() assert 2 == summer.sumWithDefaults(1,1) assert 3 == summer.sumWithDefaults(1,1,1) assert 2 == summer.sumWithList([1,1]) assert 3 == summer.sumWithList([1,1,1]) assert 2 == summer.sumWithOptionals(1,1) assert 3 == summer.sumWithOptionals(1,1,1) assert 2 == summer.sumNamed(a:1, b:1) assert 3 == summer.sumNamed(a:1, b:1, c:1) assert 1 == summer.sumNamed(c:1) //#1 Explicit arguments and a default value //#2 Define arguments as a list //#3 Optional arguments as an array //#4 Define arguments as a map ================================================ FILE: listings/chap07/Listing_07_08_Safe_Dereferencing.groovy ================================================ def map = [a:[b:[c:1]]] assert map.a.b.c == 1 if (map && map.a && map.a.x){ //#1 assert map.a.x.c == null } try { assert map.a.x.c == null } catch (NullPointerException ignore){ //#2 } assert map?.a?.x?.c == null //#3 //#1 Protect with if: short-circuit evaluation //#2 Protect with try/catch //#3 Safe dereferencing ================================================ FILE: listings/chap07/Listing_07_09_Instantiation.groovy ================================================ class VendorWithCtor { String name, product VendorWithCtor(name, product) { //#A this.name = name this.product = product } } def first = new VendorWithCtor('Canoo','ULC') //#B def second = ['Canoo','ULC'] as VendorWithCtor //#1 VendorWithCtor third = ['Canoo','ULC'] //#2 //#A Constructor definition //#B Normal constructor use //#1 Coercion with as //#2 Coercion in assignment ================================================ FILE: listings/chap07/Listing_07_10_Instantiation_Named.groovy ================================================ class SimpleVendor { String name, product } new SimpleVendor() new SimpleVendor(name: 'Canoo') new SimpleVendor(product: 'ULC') new SimpleVendor(name: 'Canoo', product: 'ULC') def vendor = new SimpleVendor(name: 'Canoo') assert 'Canoo' == vendor.name ================================================ FILE: listings/chap07/Listing_07_11_Classes.groovy ================================================ class Vendor { public String name public String product public Address address = new Address() } class Address { public String street, town, state public int zip } def canoo = new Vendor() canoo.name = 'Canoo Engineering AG' canoo.product = 'UltraLightClient (ULC)' canoo.address.street = 'Kirschgartenst. 7' canoo.address.zip = 4051 canoo.address.town = 'Basel' canoo.address.state = 'Switzerland' assert canoo.dump() =~ /ULC/ assert canoo.address.dump() =~ /Basel/ ================================================ FILE: listings/chap07/Listing_07_13_Import.groovy ================================================ import business.* def canoo = new Vendor() canoo.name = 'Canoo Engineering AG' canoo.product = 'UltraLightClient (ULC)' assert canoo.dump() =~ /ULC/ ================================================ FILE: listings/chap07/Listing_07_14_Import_As_BugFix.groovy ================================================ import thirdparty.MathLib as OrigMathLib class MathLib extends OrigMathLib { Integer twice(Integer value) { return value * 2 } } // nothing changes below here //#A def mathlib = new MathLib() assert 10 == mathlib.twice(5) //#B assert 2 == mathlib.half(5) //#C //#A Usage code for library remains unchanged //#B Invoke fixed method //#C Invoke original method ================================================ FILE: listings/chap07/Listing_07_15_Import_As_NameClash.groovy ================================================ import thirdparty.MathLib as TwiceHalfMathLib import thirdparty2.MathLib as IncMathLib def math1 = new TwiceHalfMathLib() def math2 = new IncMathLib() assert 3 == math1.half(math2.increment(5)) ================================================ FILE: listings/chap07/Listing_07_16_Multimethods.groovy ================================================ def oracle(Object o) { return 'object' } def oracle(String o) { return 'string' } Object x = 1 Object y = 'foo' assert 'object' == oracle(x) assert 'string' == oracle(y) //#A //#A This would return object in Java ================================================ FILE: listings/chap07/Listing_07_17_MultiEquals.groovy ================================================ class Equalizer { boolean equals(Equalizer e){ return true } } Object same = new Equalizer() Object other = new Object() assert new Equalizer().equals( same ) assert ! new Equalizer().equals( other ) ================================================ FILE: listings/chap07/Listing_07_18_Traits.groovy ================================================ trait HasId { //#1 long id } trait HasVersion { long version } trait Persistent { boolean save() { println "saving ${this.dump()}" } } trait Entity implements Persistent, HasId, HasVersion { //#2 boolean save() { version++ Persistent.super.save() //#3 } } class Publication implements Entity { //#4 String title } class Book extends Publication { String isbn } Entity gina = new Book(id:1, version:1, title:"gina", isbn:"111111") gina.save() assert gina.version == 2 //#1 Defining a trait with state //#2 Traits can use subtyping //#3 Use specific methods //#4 Implementing the trait ================================================ FILE: listings/chap07/Listing_07_19_Declaring_Beans.groovy ================================================ import java.io.Serializable class MyBean implements Serializable { def untyped String typed def item1, item2 def assigned = 'default value' } def bean = new MyBean() assert 'default value' == bean.getAssigned() bean.setUntyped('some value') assert 'some value' == bean.getUntyped() bean = new MyBean(typed:'another value') assert 'another value' == bean.getTyped() ================================================ FILE: listings/chap07/Listing_07_20_Calling_Beans.groovy ================================================ class MrBean { String firstname, lastname //#A String getName(){ //#1 return "$firstname $lastname" } } def bean = new MrBean(firstname: 'Rowan') //#B bean.lastname = 'Atkinson' //#2 assert 'Rowan Atkinson' == bean.name //#3 //#A Groovy style properties //#1 Getter for derived property //#B Generic constructor //#2 Call setter //#3 Call getter ================================================ FILE: listings/chap07/Listing_07_21_Calling_Beans_Advanced.groovy ================================================ class DoublerBean { public value //#A void setValue(value){ this.value = value //#1 } def getValue(){ value * 2 //#2 } } def bean = new DoublerBean(value: 100) assert 200 == bean.value //#3 assert 100 == bean.@value //#B //#A Visible field //#1 Inner field access //#2 Inner field access //#3 Property access //#B Outer field access ================================================ FILE: listings/chap07/Listing_07_22_Property_Methods.groovy ================================================ class ClassWithProperties { def someProperty public someField private somePrivateField } def obj = new ClassWithProperties() def store = [] obj.properties.each { property -> store += property.key store += property.value } assert store.contains('someProperty') assert store.contains('someField') == false assert store.contains('somePrivateField') == false assert store.contains('class') assert obj.properties.size() == 2 ================================================ FILE: listings/chap07/Listing_07_23_Expando.groovy ================================================ def boxer = new Expando() assert null == boxer.takeThis boxer.takeThis = 'ouch!' assert 'ouch!' == boxer.takeThis boxer.fightBack = {times -> delegate.takeThis * times } assert 'ouch!ouch!ouch!' == boxer.fightBack(3) ================================================ FILE: listings/chap07/Listing_07_24_GPath.groovy ================================================ class Invoice { //#A List items //#A Date date //#A } //#A class LineItem { //#A Product product //#A int count //#A int total() { //#A return product.dollar * count //#A } //#A } //#A class Product { //#A String name //#A def dollar //#A } //#A def ulcDate = Date.parse('yyyy-MM-dd', '2015-01-01') def otherDate = Date.parse('yyyy-MM-dd', '2015-02-02') def ulc = new Product(dollar:1499, name:'ULC') //#B def ve = new Product(dollar:499, name:'Visual Editor') //#B //#B def invoices = [ //#B new Invoice(date:ulcDate, items: [ //#B new LineItem(count:5, product:ulc), //#B new LineItem(count:1, product:ve) //#B ]), //#B new Invoice(date:otherDate, items: [ //#B new LineItem(count:4, product:ve) //#B ]) //#B ] //#B def allItems = invoices.items.flatten() assert [5*1499, 499, 4*499] == allItems*.total() //#1 assert ['ULC'] == allItems.grep{it.total() > 7000}.product.name //#2 def searchDates = invoices.grep{ //#3 it.items.any{it.product == ulc} //#3 }.date*.toString() //#3 assert [ulcDate.toString()] == searchDates //#A Set up data structures //#B Fill with sample data //#1 Total for each line item //#2 Query of product names //#3 Query of invoice date ================================================ FILE: listings/chap07/business/Vendor.groovy ================================================ package business class Vendor { public String name public String product public Address address = new Address() } class Address { public String street, town, state public int zip } ================================================ FILE: listings/chap07/snippet0703_Implicit_Closure_To_SAM.groovy ================================================ import java.awt.event.ActionListener listeners = [] def addListener(ActionListener al) { listeners << al } addListener { println "I heard that!" } listeners*.actionPerformed() ================================================ FILE: listings/chap07/snippet0705_Spread_List.groovy ================================================ def getList(){ return [1,2,3] } def sum(a,b,c){ return a + b + c } assert 6 == sum(*list) ================================================ FILE: listings/chap07/snippet0705_Spread_Map.groovy ================================================ def map = [a:1,b:2] assert [a:1, b:2, c:3] == [c:3, *:map] ================================================ FILE: listings/chap07/snippet0705_Spread_Range.groovy ================================================ def range = (1..3) assert [0,1,2,3] == [0,*range] ================================================ FILE: listings/chap07/thirdparty/MathLib.groovy ================================================ package thirdparty class MathLib { Integer twice(Integer value) { return value * 3 // intentionally wrong! } Integer half(Integer value) { return value / 2 } } ================================================ FILE: listings/chap07/thirdparty2/MathLib.groovy ================================================ package thirdparty2 class MathLib { Integer increment(Integer value) { value + 1 } } ================================================ FILE: listings/chap08/Listing_08_01_method_missing.groovy ================================================ class Pretender { def methodMissing(String name, Object args) { "called $name with $args" } } def bounce = new Pretender() assert bounce.hello('world') == 'called hello with [world]' ================================================ FILE: listings/chap08/Listing_08_02_mini_gorm.groovy ================================================ class MiniGorm { def db = [] Object methodMissing(String name, Object args) { println name db.find { it[name.toLowerCase()-'findby'] == args[0] } //#1 } } def people = new MiniGorm() //#2 def dierk = [first: 'Dierk', last:'Koenig'] def paul = [first: 'Paul', last:'King'] people.db << dierk << paul assert people.findByFirst('Dierk') == dierk //#3 assert people.findByLast('King') == paul ================================================ FILE: listings/chap08/Listing_08_03_property_missing.groovy ================================================ class PropPretender { def propertyMissing(String name) { "accessed $name" } } def bounce = new PropPretender() assert bounce.hello == 'accessed hello' ================================================ FILE: listings/chap08/Listing_08_04_bin_property.groovy ================================================ def propertyMissing(String name) { int result = 0 name.each { result <<= 1 if (it == 'I') result++ } return result } assert IIOI + IOI == IOOIO ================================================ FILE: listings/chap08/Listing_08_05_closure_dynamic.groovy ================================================ class DynamicPretender { Closure whatToDo = { name -> "accessed $name"} //#1 def propertyMissing(String name) { whatToDo(name) //#2 } } def one = new DynamicPretender() assert one.hello == 'accessed hello' one.whatToDo = { name -> name.size() } //#3 assert one.hello == 5 ================================================ FILE: listings/chap08/Listing_08_06_property_method.groovy ================================================ class NoParens { def getProperty(String propertyName) { if (metaClass.hasProperty(this, propertyName)) { //#1 return metaClass.getProperty(this, propertyName) } invokeMethod propertyName, null //#2 } } class PropUser extends NoParens { //#3 boolean existingProperty = true } def user = new PropUser() assert user.existingProperty assert user.toString() == user.toString //#4 ================================================ FILE: listings/chap08/Listing_08_07_MetaClass_jdk7_only.groovy ================================================ MetaClass mc = String.metaClass final Object[] NO_ARGS = [] assert 1 == mc.respondsTo("toString", NO_ARGS).size() assert 3 == mc.properties.size() assert 74 == mc.methods.size() assert 176 == mc.metaMethods.size() assert "" == mc.invokeMethod("","toString", NO_ARGS) assert null == mc.invokeStaticMethod(String, "println", NO_ARGS) assert "" == mc.invokeConstructor(NO_ARGS) ================================================ FILE: listings/chap08/Listing_08_07_MetaClass_jdk8_plus.groovy ================================================ MetaClass mc = String.metaClass final Object[] NO_ARGS = [] assert 1 == mc.respondsTo("toString", NO_ARGS).size() assert 3 == mc.properties.size() assert 76 == mc.methods.size() assert 176 == mc.metaMethods.size() assert "" == mc.invokeMethod("","toString", NO_ARGS) assert null == mc.invokeStaticMethod(String, "println", NO_ARGS) assert "" == mc.invokeConstructor(NO_ARGS) ================================================ FILE: listings/chap08/Listing_08_08_ProxyMetaClass.groovy ================================================ class InspectMe { int outer(){ return inner() } private int inner(){ return 1 } } def tracer = new TracingInterceptor(writer: new StringWriter()) //#1 def proxyMetaClass = ProxyMetaClass.getInstance(InspectMe) proxyMetaClass.interceptor = tracer InspectMe inspectMe = new InspectMe() inspectMe.metaClass = proxyMetaClass //#2 assert 1 == inspectMe.outer() //#3 assert "\n" + tracer.writer.toString() == """ before InspectMe.outer() before InspectMe.inner() after InspectMe.inner() after InspectMe.outer() """ ================================================ FILE: listings/chap08/Listing_08_09_Expando.groovy ================================================ def boxer = new Expando() boxer.takeThis = 'ouch!' boxer.fightBack = { times -> takeThis * times } assert boxer.fightBack(3) == 'ouch!ouch!ouch!' ================================================ FILE: listings/chap08/Listing_08_10_EMC.groovy ================================================ assert String.metaClass =~ /MetaClassImpl/ String.metaClass.low = {-> delegate.toLowerCase() } assert String.metaClass =~ /ExpandoMetaClass/ assert "DiErK".low() == "dierk" ================================================ FILE: listings/chap08/Listing_08_11_EMC_Groovy_Class.groovy ================================================ class MyGroovy1 { } def before = new MyGroovy1() MyGroovy1.metaClass.myProp = "MyGroovy prop" MyGroovy1.metaClass.test = {-> myProp } try { before.test() //#1 assert false, "should throw MME" } catch(mme) { } assert new MyGroovy1().test() == "MyGroovy prop" ================================================ FILE: listings/chap08/Listing_08_12_EMC_Groovy_Object.groovy ================================================ class MyGroovy2 { } def myGroovy = new MyGroovy2() myGroovy.metaClass.myProp = "MyGroovy prop" myGroovy.metaClass.test = {-> myProp } try { new MyGroovy2().test() //#1 assert false, "should throw MME" } catch(mme) { } assert myGroovy.test() == "MyGroovy prop" ================================================ FILE: listings/chap08/Listing_08_13_EMC_Java_Object.groovy ================================================ def myJava = new String() myJava.metaClass.myProp = "MyJava prop" myJava.metaClass.test = {-> myProp } try { new String().test() //#1 assert false, "should throw MME" } catch(mme) { } assert myJava.test() == "MyJava prop" ================================================ FILE: listings/chap08/Listing_08_14_EMC_Builder.groovy ================================================ def move(string, distance) { string.collect { (it as char) + distance as char }.join() } String.metaClass { shift = -1 encode {-> move delegate, shift } decode {-> move delegate, -shift } getCode {-> encode() } getOrig {-> decode() } } assert "IBM".encode() == "HAL" assert "HAL".orig == "IBM" def ibm = "IBM" ibm.shift = 7 assert ibm.code == "PIT" ================================================ FILE: listings/chap08/Listing_08_15_EMC_static.groovy ================================================ Integer.metaClass.static.answer = {-> 42} assert Integer.answer() == 42 ================================================ FILE: listings/chap08/Listing_08_16_EMC_super.groovy ================================================ class MySuperGroovy { } class MySubGroovy extends MySuperGroovy { } MySuperGroovy.metaClass.added = {-> true } assert new MySubGroovy().added() Map.metaClass.toTable = {-> delegate.collect{ [it.key, it.value] } } assert [a:1, b:2].toTable() == [ ['a', 1], ['b', 2] ] ================================================ FILE: listings/chap08/Listing_08_17_EMC_hooks.groovy ================================================ String.metaClass { rightShiftUnsigned = { prefix -> delegate.replaceAll(~/\w+/) { prefix + it } } methodMissing = { String name, args-> delegate.replaceAll name, args[0] } } def people = "Dierk,Guillaume,Paul,Hamlet,Jon" people >>>= "\n " people = people.Dierk('Mittie').Guillaume('Mr.G') assert people == ''' Mittie, Mr.G, Paul, Hamlet, Jon''' ================================================ FILE: listings/chap08/Listing_08_18_Existing_Categories.groovy ================================================ import groovy.time.TimeCategory def janFirst1970 = new Date(0) use TimeCategory, { Date xmas = janFirst1970 + 1.year - 7.days assert xmas.month == Calendar.DECEMBER assert xmas.date == 25 } use Collections, { def list = [0, 1, 2, 3] list.rotate 1 assert list == [3, 0, 1, 2] } ================================================ FILE: listings/chap08/Listing_08_19_Marshal.groovy ================================================ class Marshal { static String marshal(Integer self) { self.toString() } static Integer unMarshal(String self) { self.toInteger() } } use Marshal, { assert 1.marshal() == "1" assert "1".unMarshal() == 1 [Integer.MIN_VALUE, -1, 0, Integer.MAX_VALUE].each { assert it.marshal().unMarshal() == it } } ================================================ FILE: listings/chap08/Listing_08_20_MarshalCategory.groovy ================================================ @Category(Integer) //#1 class IntegerMarshal { String marshal() { toString() //#2 } } @Category(String) class StringMarshal { Integer unMarshal() { this.toInteger() //#3 } } use ([IntegerMarshal, StringMarshal]) { //#4 assert 1.marshal() == "1" assert "1".unMarshal() == 1 } //#1 Specify the type of self //#2 Implicit this //#3 Explicit this //#4 List variant of use ================================================ FILE: listings/chap08/Listing_08_21_Test_Mixin.groovy ================================================ @Mixin(MessageFeature) class FirstTest extends GroovyTestCase { void testWithMixinUsage() { message = "Called from Test" assertMessage "Called from Test" } } class MessageFeature { def message void assertMessage(String msg) { assertEquals msg, message } } ================================================ FILE: listings/chap08/Listing_08_22_Sieve_Mixin.groovy ================================================ class EvenSieve { def getNo2() { removeAll { it % 2 == 0 } return this } } class MinusSieve { def minus(int num) { removeAll { it % num == 0 } return this } } ArrayList.mixin EvenSieve, MinusSieve assert (0..10).toList().no2 - 3 - 5 == [1, 7] ================================================ FILE: listings/chap08/Listing_08_23_Millimeter.groovy ================================================ Number.metaClass { getMm = { delegate } getCm = { delegate * 10.mm } getM = { delegate * 100.cm } } assert 1.m + 20.cm - 8.mm == 1.192.m ================================================ FILE: listings/chap08/Listing_08_24_create_factory.groovy ================================================ import java.awt.Dimension Class.metaClass.make = { Object[] args -> delegate.metaClass.invokeConstructor(*args) } assert new HashMap() == HashMap.make() assert new Integer(42) == Integer.make(42) assert new Dimension(2, 3) == Dimension.make(2, 3) ================================================ FILE: listings/chap08/Listing_08_25_fake_assign.groovy ================================================ interface ChannelComponent {} class Producer implements ChannelComponent { List outChannel } class Adaptor implements ChannelComponent { List inChannel List outChannel } class Printer implements ChannelComponent { List inChannel } class WiringCategory { static connections = [] static setInChannel(ChannelComponent self, value){ //#1 connections << [target:self, source:value] } static getOutChannel(ChannelComponent self){ self } } Producer producer = new Producer() Adaptor adaptor = new Adaptor() Printer printer = new Printer() use WiringCategory, { adaptor.inChannel = producer.outChannel //|#2 printer.inChannel = adaptor.outChannel //|#2 } assert WiringCategory.connections == [ [source: producer, target: adaptor], [source: adaptor, target: printer] ] ================================================ FILE: listings/chap08/Listing_08_26_restore_emc.groovy ================================================ MetaClass oldMetaClass = String.metaClass //#1 MetaMethod alias = String.metaClass.metaMethods //#2 .find { it.name == 'size' } String.metaClass { oldSize = { -> alias.invoke delegate } size = { -> oldSize() * 2 } } assert "abc".size() == 6 assert "abc".oldSize() == 3 if (oldMetaClass.is(String.metaClass)){ String.metaClass { //#3 size = { -> alias.invoke delegate } oldSize = { -> throw new UnsupportedOperationException() } } } else { String.metaClass = oldMetaClass //#4 } assert "abc".size() == 3 ================================================ FILE: listings/chap08/Listing_08_27_intercept_cache_invoke.groovy ================================================ ArrayList.metaClass.methodMissing = { String name, Object args -> assert name.startsWith("findBy") assert args.size() == 1 Object.metaClass."$name" = { value -> //#1 delegate.find { it[name.toLowerCase()-'findby'] == value } } delegate."$name"(args[0]) //#2 } def data = [ [name:'moon', au: 0.0025], [name:'sun', au: 1 ], [name:'neptune', au:30 ], ] assert data.findByName('moon') //#3 assert data.findByName('sun') //#4 assert data.findByAu(1) ================================================ FILE: listings/chap08/custom/Custom.groovy ================================================ package custom class Custom { } ================================================ FILE: listings/chap08/custom/useCustom.groovy ================================================ package custom assert new Custom().metaClass =~ /CustomMetaClass/ ================================================ FILE: listings/chap08/failing_Listing_08_15_EMC_static.groovy ================================================ Integer.metaClass.static.answer = 42 assert Integer.answer == 42 // no such property ================================================ FILE: listings/chap08/failing_Listing_08_16_EMC_super.groovy ================================================ ExpandoMetaClass.enableGlobally() Map.metaClass.getTable = {-> delegate.collect{ [it.key, it.value] } } assert [a:1, b:2].table == [['a', 1], ['b', 2]] ================================================ FILE: listings/chap08/groovy/runtime/metaclass/custom/CustomMetaClass.groovy ================================================ package groovy.runtime.metaclass.custom class CustomMetaClass extends MetaClassImpl { CustomMetaClass(MetaClassRegistry registry, Class theClass) { super(registry, theClass) println "custom meta class is in use" } } ================================================ FILE: listings/chap08/markup.html ================================================ ================================================ FILE: listings/chap09/.gradle/2.2.1/taskArtifacts/cache.properties ================================================ #Sun Feb 01 17:04:25 CET 2015 ================================================ FILE: listings/chap09/Listing_09_01_ToStringDetective.groovy ================================================ import groovy.transform.ToString @ToString class Detective { String firstName, lastName } def sherlock = new Detective(firstName: 'Sherlock', lastName: 'Holmes') assert sherlock .toString() == 'Detective(Sherlock, Holmes)' ================================================ FILE: listings/chap09/Listing_09_02_ToStringSleuth.groovy ================================================ import groovy.transform.ToString @ToString(includeNames = true, ignoreNulls = true) class Sleuth { String firstName, lastName } def nancy = new Sleuth(firstName: 'Nancy', lastName: 'Drew') assert nancy.toString() == 'Sleuth(firstName:Nancy, lastName:Drew)' nancy.lastName = null assert nancy.toString() == 'Sleuth(firstName:Nancy)' ================================================ FILE: listings/chap09/Listing_09_03_EqualsAndHashCode.groovy ================================================ import groovy.transform.EqualsAndHashCode @EqualsAndHashCode class Actor { String firstName, lastName } def magneto = new Actor(firstName:'Ian', lastName: 'McKellen') def gandalf = new Actor(firstName:'Ian', lastName: 'McKellen') assert magneto == gandalf ================================================ FILE: listings/chap09/Listing_09_04_TupleConstructor.groovy ================================================ import groovy.transform.TupleConstructor @TupleConstructor class Athlete { String firstName, lastName } def a1 = new Athlete('Michael', 'Jordan') def a2 = new Athlete('Michael') assert a1.firstName == a2.firstName ================================================ FILE: listings/chap09/Listing_09_05_Lazy.groovy ================================================ class Resource { //#1 private static alive = 0 private static used = 0 Resource() { alive++ } def use() { used++ } static stats() { "$alive alive, $used used" } } class ResourceMain { def res1 = new Resource() //#2 @Lazy res2 = new Resource() //#3 @Lazy static res3 = { new Resource() }() //#4 @Lazy(soft=true) volatile Resource res4 //#5 } new ResourceMain().with { assert Resource.stats() == '1 alive, 0 used' //#6 res2.use() res3.use() res4.use() assert Resource.stats() == '4 alive, 3 used' //#7 assert res4 instanceof Resource //#8 def expected = 'res4=java.lang.ref.SoftReference' assert it.dump().contains(expected) //#9 } //#1 Define Resource class with inbuilt statistics //#2 Declare one normal resource //#3 Declare one @Lazy resource //#4 Declare static resource //#5 Thread safe and compatible with garbage collection //#6 After ResourceMain creation just res1 is alive //#7 Using res2, res3, res4 creates instances lazily //#8 Verify res4 class //#9 Verify soft reference used internally ================================================ FILE: listings/chap09/Listing_09_06_IndexedProperty.groovy ================================================ import groovy.transform.IndexedProperty class Author { String name @IndexedProperty List books } def books = ['The Mysterious Affair at Styles', 'The Murder at the Vicarage'] new Author(name: 'Agatha Christie', books: books).with { books[0] = 'Murder on the Orient Express' //#1 setBooks(0, 'Death on the Nile') //#2 assert getBooks(0) == 'Death on the Nile' //#3 } //#1 Groovy idiom for setting the first property //#2 JavaBean approach to setting a single element //#3 JavaBean approach to reading a single element ================================================ FILE: listings/chap09/Listing_09_07_InheritConstructors.groovy ================================================ import groovy.transform.InheritConstructors @InheritConstructors class MyPrintWriter extends PrintWriter { } def pw1 = new MyPrintWriter(new File('out1.txt')) //#A def pw2 = new MyPrintWriter('out2.txt', 'US-ASCII') //#B [pw1, pw2].each { it << 'foo' it.close() } assert new File('out1.txt').text == new File('out2.txt').text ['out1.txt', 'out2.txt'].each{ new File(it).delete() } //#A File file variant //#B String fileName, String charset variant ================================================ FILE: listings/chap09/Listing_09_08_Sortable.groovy ================================================ import groovy.transform.Sortable @Sortable(includes = 'last,initial') //#1 class Politician { String first Character initial String last String initials() { first[0] + initial + last[0] } } def politicians = [ new Politician(first: 'Margaret', initial: 'H', last: 'Thatcher'), new Politician(first: 'George', initial: 'W', last: 'Bush') ] def sorted = politicians.toSorted() //#2 assert sorted*.initials() == ['GWB', 'MHT'] def byInitial = Politician.comparatorByInitial() //#3 sorted = politicians.toSorted(byInitial) //#4 assert sorted*.initials() == ['MHT', 'GWB'] //#1 Sorts by last then initial //#2 Performs default sort //#3 Autogenerates comparator based on initial //#4 Sorts by initial ================================================ FILE: listings/chap09/Listing_09_09_Builder.groovy ================================================ import groovy.transform.builder.Builder @Builder class Chemist { String first String last int born } def builder = Chemist.builder() //#1 def c = builder.first("Marie").last("Curie").born(1867).build() //#2 assert c.first == "Marie" assert c.last == "Curie" assert c.born == 1867 //#1 Accessing a builder instance //#2 Fluent API style instance creation ================================================ FILE: listings/chap09/Listing_09_10_Canonical.groovy ================================================ import groovy.transform.Canonical @Canonical class Inventor { String firstName, lastName } def i1 = new Inventor('Thomas', 'Edison') //#A def i2 = new Inventor('Thomas') assert i1 != i2 //#B assert i1.firstName == i2.firstName //#B assert i1.toString() == 'Inventor(Thomas, Edison)' //#C //#A Automatic tuple constructor //#B Objects not equal despite equal firstName property //#C Automatic toString method ================================================ FILE: listings/chap09/Listing_09_11_Immutable.groovy ================================================ import groovy.transform.Immutable import static groovy.test.GroovyAssert.shouldFail @Immutable class Genius { String firstName, lastName } def g1 = new Genius(firstName: 'Albert', lastName: "Einstein") //#1 assert g1.toString() == 'Genius(Albert, Einstein)' //#2 def g2 = new Genius('Leonardo', "da Vinci") //#3 assert g2.firstName == 'Leonardo' //#4 assert g1 != g2 //#5 shouldFail(ReadOnlyPropertyException) { g2.lastName = 'DiCaprio' } //#1 Map-based constructor //#2 toString method //#3 Tuple constructor //#4 property getter //#5 appropriate equals and hashCode ================================================ FILE: listings/chap09/Listing_09_12_Delegate.groovy ================================================ class NoisySet2 { @Delegate Set delegate = new HashSet() @Override boolean add(item) { println "adding $item" delegate.add(item) } @Override boolean addAll(Collection items) { items.each { println "adding $it" } delegate.addAll(items) } } Set ns = new NoisySet2() ns.add(1) ns.addAll([2, 3]) assert ns.size() == 3 ================================================ FILE: listings/chap09/Listing_09_13_Singleton.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail @Singleton class Zeus { } assert Zeus.instance def ex = shouldFail(RuntimeException) { new Zeus() } assert ex.message == "Can't instantiate singleton Zeus. Use Zeus.instance" ================================================ FILE: listings/chap09/Listing_09_14_Memoized.groovy ================================================ import groovy.transform.Memoized class Calc { def log = [] @Memoized //#1 int sum(int a, int b) { log << "$a+$b" //#2 a + b } } new Calc().with { assert sum(3, 4) == 7 //#3 assert sum(4, 4) == 8 assert sum(3, 4) == 7 //#4 assert log.join(' ') == '3+4 4+4' //#5 } //#1 Enable memoization by annotating a method //#2 Log all calculations //#3 Calculation performed the first time //#4 Result returned from cache //#5 Logging shows calculations performed once each ================================================ FILE: listings/chap09/Listing_09_15_TailRecursive.groovy ================================================ import groovy.transform.TailRecursive class ListUtil { static reverse(List list) { doReverse(list, []) } @TailRecursive private static doReverse(List todo, List done) { if (todo.isEmpty()) done else doReverse(todo.tail(), [todo.head()] + done) } } assert ListUtil.reverse(['a', 'b', 'c']) == ['c', 'b', 'a'] ================================================ FILE: listings/chap09/Listing_09_16_Log.groovy ================================================ import groovy.util.logging.Log @Log class Database { def search() { log.fine(runLongDatabaseQuery()) } def runLongDatabaseQuery() { println 'Calling database' /* ... */ return 'query result' } } new Database().search() ================================================ FILE: listings/chap09/Listing_09_17_Synchronized.groovy ================================================ import groovy.transform.Synchronized class PhoneBook1 { private final phoneNumbers = [:] @Synchronized def getNumber(key) { phoneNumbers[key] } @Synchronized void addNumber(key, value) { phoneNumbers[key] = value } } def p1 = new PhoneBook1() (0..99).collect { num -> Thread.start { p1.addNumber('Number' + num, '98765' + num) //#A } }*.join() //#B assert p1.getNumber('Number43') == '9876543' //#C //#A Each thread adds a dummy phonebook entry //#B Await completion of 99 parallel threads //#C Check a sample number ================================================ FILE: listings/chap09/Listing_09_18_SynchronizedCustomLock.groovy ================================================ import groovy.transform.Synchronized import groovy.util.logging.Log @Log class PhoneBook2 { private final phoneNumbers = [:] private final lock = new Object[0] //#A @Synchronized('lock') //#B def getNumber(key) { phoneNumbers[key] } def addNumber(key, value) { log.info("Adding phone number $value") synchronized (lock) { //#C phoneNumbers[key] = value } } } def p2 = new PhoneBook2() (0..99).collect { num -> Thread.start { p2.addNumber('Number' + num, '98765' + num) } }*.join() assert p2.getNumber('Number43') == '9876543' //#A Manually create lock //#B Specify the lock name //#C Manual synchronized block ================================================ FILE: listings/chap09/Listing_09_19_ReadWriteLock.groovy ================================================ import groovy.transform.* class PhoneBook3 { private final phoneNumbers = dummyNums() //#A private dummyNums() { (1..8).collectEntries { ['Number' + it, '765432' + it] } } @WithReadLock def getNumber(key) { println "reading started for $key" phoneNumbers[key] sleep 80 println "reading done for $key" } @WithWriteLock def addNumber(key, value) { println "writing started for $key" phoneNumbers[key] = value sleep 100 println "writing done for $key" } } def p3 = new PhoneBook3() (3..4).each{ count -> Thread.start { //#B sleep 100 * count p3.addNumber('Number' + count, '9876543') } } (2..6).collect{ count -> Thread.start { //#C sleep 100 * count p3.getNumber('Number' + count) } }*.join() //#A Fill phonebook with dummy numbers //#B Start some writer threads //#C Start some interleaved reader threads /* reading started for Number2 reading started for Number3 reading done for Number2 reading done for Number3 writing started for Number3 writing done for Number3 reading started for Number4 reading done for Number4 writing started for Number4 writing done for Number4 reading started for Number5 reading started for Number6 reading done for Number6 reading done for Number5 */ ================================================ FILE: listings/chap09/Listing_09_20_AutoClone.groovy ================================================ import groovy.transform.AutoClone @AutoClone class Chef1 { String name List recipes Date born } def name = 'Heston Blumenthal' def recipes = ['Snail porridge', 'Bacon & egg ice cream'] def born = Date.parse('yyyy-MM-dd', '1966-05-27') def c1 = new Chef1(name: name, recipes: recipes, born: born) def c2 = c1.clone() assert c2.recipes == recipes ================================================ FILE: listings/chap09/Listing_09_21_AutoCloneCopyConstructor.groovy ================================================ import groovy.transform.* import static groovy.transform.AutoCloneStyle.* @TupleConstructor @AutoClone(style=COPY_CONSTRUCTOR) class Person { final String name final Date born } @TupleConstructor(includeSuperProperties=true, callSuper=true) @AutoClone(style=COPY_CONSTRUCTOR) class Chef2 extends Person { final List recipes } def name = 'Jamie Oliver' def recipes = ['Lentil Soup', 'Crispy Duck'] def born = Date.parse('yyyy-MM-dd', '1975-05-27') def c1 = new Chef2(name, born, recipes) def c2 = c1.clone() assert c2.name == name assert c2.born == born assert c2.recipes == recipes ================================================ FILE: listings/chap09/Listing_09_22_AutoExternalize.groovy ================================================ import groovy.transform.* @AutoExternalize @ToString class Composer { String name int born boolean married } def c = new Composer(name: 'Wolfgang Amadeus Mozart', born: 1756, married: true) def baos = new ByteArrayOutputStream() baos.withObjectOutputStream{ os -> os.writeObject(c) } def bais = new ByteArrayInputStream(baos.toByteArray()) def loader = getClass().classLoader def result bais.withObjectInputStream(loader) { result = it.readObject().toString() } assert result == 'Composer(Wolfgang Amadeus Mozart, 1756, true)' ================================================ FILE: listings/chap09/Listing_09_23_TimedInterrupt.groovy ================================================ import groovy.transform.TimedInterrupt import java.util.concurrent.TimeoutException import static java.util.concurrent.TimeUnit.MILLISECONDS @TimedInterrupt(value = 480L, unit = MILLISECONDS) //#A class BlastOff1 { def log = [] def countdown(n) { sleep 100 log << n if (n == 0) log << 'ignition' else countdown(n - 1) } } def b = new BlastOff1() Thread.start { try { b.countdown(10) } catch (TimeoutException ignore) { b.log << 'aborted' } }.join() assert b.log.join(' ') == '10 9 8 7 6 aborted' //#A Just a little less than 500 milliseconds ================================================ FILE: listings/chap09/Listing_09_24_ThreadInterrupt.groovy ================================================ import groovy.transform.ThreadInterrupt @ThreadInterrupt class BlastOff2 { def log = [] def countdown(n) { Thread.sleep 100 log << n if (n == 0) log << 'ignition' else countdown(n - 1) } } def b = new BlastOff2() def t1 = Thread.start { try { b.countdown(10) } catch(InterruptedException ignore) { b.log << 'aborted' } } sleep 590 //#A t1.interrupt() t1.join() assert b.log.join(' ') == '10 9 8 7 6 aborted' //#A Just a little less than 600 milliseconds ================================================ FILE: listings/chap09/Listing_09_25_ConditionalInterrupt.groovy ================================================ import groovy.transform.ConditionalInterrupt @ConditionalInterrupt({ count <= 5 }) class BlastOff3 { def log = [] def count = 10 def countdown() { while (count != 0) { log << count count-- } log << 'ignition' } } def b = new BlastOff3() try { b.countdown() } catch (InterruptedException ignore) { b.log << 'aborted' } assert b.log.join(' ') == '10 9 8 7 6 aborted' ================================================ FILE: listings/chap09/Listing_09_26_Field.groovy ================================================ import groovy.transform.Field @Field List awe = [1, 2, 3] def awesum() { awe.sum() } //#A assert awesum() == 6 //#A The variable awe is an instance field of our script ================================================ FILE: listings/chap09/Listing_09_27_BaseScript.groovy ================================================ @BaseScript(LoggingScript) import groovy.transform.BaseScript abstract class LoggingScript extends Script { def log = [] void println(args) { log << args System.out.println args } } println 'hello' println 3 * 5 assert log.join(' ') == 'hello 15' ================================================ FILE: listings/chap09/Listing_09_28_AstByHand.groovy ================================================ import org.codehaus.groovy.ast.ClassHelper import org.codehaus.groovy.ast.expr.* import org.codehaus.groovy.ast.stmt.ReturnStatement def ast = new ReturnStatement( new ConstructorCallExpression( ClassHelper.make(Date), ArgumentListExpression.EMPTY_ARGUMENTS ) ) assert ast instanceof ReturnStatement ================================================ FILE: listings/chap09/Listing_09_29_AstByHandWithUtils.groovy ================================================ import org.codehaus.groovy.ast.stmt.ReturnStatement import static org.codehaus.groovy.ast.ClassHelper.make import static org.codehaus.groovy.ast.tools.GeneralUtils.* def ast = returnS(ctorX(make(Date))) assert ast instanceof ReturnStatement ================================================ FILE: listings/chap09/Listing_09_30_AstBuildFromSpec.groovy ================================================ import org.codehaus.groovy.ast.builder.AstBuilder import org.codehaus.groovy.ast.stmt.ReturnStatement def ast = new AstBuilder().buildFromSpec { returnStatement { constructorCall(Date) { argumentList {} } } } assert ast[0] instanceof ReturnStatement ================================================ FILE: listings/chap09/Listing_09_31_AstBuildFromString.groovy ================================================ import org.codehaus.groovy.ast.builder.AstBuilder import org.codehaus.groovy.ast.stmt.BlockStatement import org.codehaus.groovy.ast.stmt.ReturnStatement def ast = new AstBuilder().buildFromString('new Date()') assert ast[0] instanceof BlockStatement assert ast[0].statements[0] instanceof ReturnStatement ================================================ FILE: listings/chap09/Listing_09_32_AstBuildFromStringMixed.groovy ================================================ import org.codehaus.groovy.ast.builder.AstBuilder import org.codehaus.groovy.control.CompilePhase import org.codehaus.groovy.ast.* def approxPI = 3.14G def ast = new AstBuilder().buildFromString( CompilePhase.CLASS_GENERATION, false, 'static double getTwoPI() { def pi = ' + approxPI + '; pi * 2 }' ) assert ast[1] instanceof ClassNode def method = ast[1].methods.find { it.name == 'getTwoPI' } assert method instanceof MethodNode ================================================ FILE: listings/chap09/Listing_09_33_AstBuildFromCode.groovy ================================================ import org.codehaus.groovy.ast.builder.AstBuilder import org.codehaus.groovy.ast.stmt.ReturnStatement def ast = new AstBuilder().buildFromCode { new Date() } assert ast[0].statements[0] instanceof ReturnStatement ================================================ FILE: listings/chap09/Listing_09_34_GreeterMainTransform.groovy ================================================ import org.codehaus.groovy.ast.* import org.codehaus.groovy.transform.* import java.lang.annotation.* import org.codehaus.groovy.control.* @Retention(RetentionPolicy.SOURCE) //#A @Target([ElementType.METHOD]) //#A @GroovyASTTransformationClass(classes = [MainTransformation]) //#A @interface Main {} //#A import static groovyjarjarasm.asm.Opcodes.* import static org.codehaus.groovy.ast.ClassHelper.VOID_TYPE import static org.codehaus.groovy.ast.tools.GeneralUtils.* @GroovyASTTransformation(phase = CompilePhase.INSTRUCTION_SELECTION) class MainTransformation implements ASTTransformation { private NO_EXCEPTIONS = ClassNode.EMPTY_ARRAY private STRING_ARRAY = ClassHelper.STRING_TYPE.makeArray() void visit(ASTNode[] astNodes, SourceUnit sourceUnit) { if (astNodes?.size() != 2) return //#B if (!(astNodes[0] instanceof AnnotationNode)) return //#B if (astNodes[0].classNode.name != Main.name) return //#B if (!(astNodes[1] instanceof MethodNode)) return //#B def targetMethod = astNodes[1] def targetClass = targetMethod.declaringClass def targetInstance = ctorX(targetClass) def callTarget = callX(targetInstance, targetMethod.name) //#C def mainBody = block(stmt(callTarget)) def visibility = ACC_STATIC | ACC_PUBLIC def parameters = params(param(STRING_ARRAY, 'args')) targetClass.addMethod('main', visibility, //#D VOID_TYPE, parameters, NO_EXCEPTIONS, mainBody) //#D } } new GroovyShell(getClass().classLoader).evaluate ''' class Greeter { @Main def greet() { println "Hello from the greet() method!" } } ''' //#A Annotation class definition //#B Defensive programming via guard clauses //#C new Greeter().greet() //#D add public static void main method ================================================ FILE: listings/chap09/Listing_09_35_GreeterMainTransform2.groovy ================================================ import org.codehaus.groovy.ast.* import org.codehaus.groovy.ast.stmt.BlockStatement import org.codehaus.groovy.transform.* import java.lang.annotation.* import org.codehaus.groovy.control.* @Retention(RetentionPolicy.SOURCE) @Target([ElementType.METHOD]) @GroovyASTTransformationClass(classes = [MainTransformation2]) @interface Main2 { boolean merge() default false //#A } import static org.codehaus.groovy.ast.ClassHelper.VOID_TYPE import static org.codehaus.groovy.ast.tools.GeneralUtils.* @GroovyASTTransformation(phase = CompilePhase.INSTRUCTION_SELECTION) class MainTransformation2 extends AbstractASTTransformation { private MSG1 = "@Main2 annotation use requires no-arg constructor!" private MSG2 = "@Main2 annotation used but main already exists!" private NO_EXCEPTIONS = ClassNode.EMPTY_ARRAY private NO_PARAMS = Parameter.EMPTY_ARRAY private STRING_ARRAY = ClassHelper.STRING_TYPE.makeArray() void visit(ASTNode[] astNodes, SourceUnit sourceUnit) { init(astNodes, sourceUnit) def (anno, mainMethod) = astNodes boolean merge = getMemberValue(anno, 'merge') //#B def mainClass = mainMethod.declaringClass def callTarget if (mainMethod.isStatic()) { callTarget = mainClass } else { if (!hasNoArgConstructor(mainClass)) { addError(MSG1, mainMethod) //#C return } callTarget = ctorX(mainClass) } def callStatement = stmt(callX(callTarget, mainMethod.name)) def parameters = params(param(STRING_ARRAY, 'args')) def existingMain = mainClass.getDeclaredMethod('main', parameters) if (existingMain && !merge) { addError(MSG2, mainMethod) //#D return } if (existingMain) { if (existingMain.code instanceof BlockStatement) { existingMain.code.addStatement(callStatement) //#E } else { block(existingMain.code).addStatement(callStatement) //#F } } else { mainClass.addMethod('main', ACC_STATIC | ACC_PUBLIC, VOID_TYPE, parameters, NO_EXCEPTIONS, block(callStatement)) } } private hasNoArgConstructor(mainClass) { def constructors = mainClass.declaredConstructors def explicitNoArg = constructors.find { it.parameters == NO_PARAMS } def implicitNoArg = constructors.size() == 0 implicitNoArg || explicitNoArg } } new GroovyShell(getClass().classLoader).evaluate ''' class Greeter { public static void main(String[] args) { println 'Hello from main()' } @Main2(merge=true) def greet() { println "Hello from the greet() instance method!" } @Main2(merge=true) static greet2() { println "Hello from the greet2() static method!" } } ''' //#A Define an annotation attribute //#B Read annotation attribute value //#C Indicate error if missing no-arg constructor //#D Indicate error unless explicit merging //#E Handle block statement case //#F Handle single statement case ================================================ FILE: listings/chap09/Listing_09_38_AstTesting1.groovy ================================================ import groovy.transform.WithReadLock import java.util.concurrent.locks.ReentrantReadWriteLock import static java.lang.reflect.Modifier.* class ReadWriteLockTestWithNestedClass extends GroovyTestCase { static class MyClass { //#A @WithReadLock void readerMethod1() {} } void testLockFieldDefaultsForReadLock() { def field = MyClass.getDeclaredField('$reentrantlock') assert isPrivate(field.modifiers) assert !isTransient(field.modifiers) assert isFinal(field.modifiers) assert !isStatic(field.modifiers) assert field.type == ReentrantReadWriteLock } } //#A Nested class ================================================ FILE: listings/chap09/Listing_09_39_AstTesting2.groovy ================================================ import java.util.concurrent.locks.ReentrantReadWriteLock import static java.lang.reflect.Modifier.* class ReadWriteLockTestClassLoader extends GroovyTestCase { public void testLockFieldDefaultsForReadLock() { def tester = new GroovyClassLoader().parseClass(''' class MyClass { @groovy.transform.WithReadLock public void readerMethod1() { } } ''') def field = tester.getDeclaredField('$reentrantlock') assert isPrivate(field.modifiers) assert !isTransient(field.modifiers) assert isFinal(field.modifiers) assert !isStatic(field.modifiers) assert field.type == ReentrantReadWriteLock } } ================================================ FILE: listings/chap09/Listing_09_40_AstTesting3.groovy ================================================ import java.lang.reflect.Modifier class ReadWriteLockTestGroovyShell extends GroovyTestCase { public void testLockFieldDefaultsForReadLock() { def tester = new GroovyShell().evaluate(''' import groovy.transform.WithReadLock class MyClass { @WithReadLock public void readerMethod1() { } } new MyClass() ''') def field = tester.getClass().getDeclaredField('$reentrantlock') assert Modifier.isPrivate(field.modifiers) // and more assertions... } } ================================================ FILE: listings/chap09/Listing_09_41_AstTesting4.groovy ================================================ import org.codehaus.groovy.tools.ast.TransformTestHelper import static groovy.test.GroovyAssert.shouldFail import static org.codehaus.groovy.control.CompilePhase.* def DATE_FMT = /\w{3} \w{3} \d\d \d\d:\d\d:\d\d \S{3,9} \d{4}/ def folder = new File('src/main/groovy/regina') def source = new File(folder, 'CompiledAtASTTransformation.groovy') def transform = getClass().classLoader.parseClass(source).newInstance() def helper = new TransformTestHelper(transform, PARSING) def clazz = helper.parse(' class MyClass {} ') shouldFail(MissingMethodException) { clazz.getCompileTime() } helper = new TransformTestHelper(transform, CONVERSION) clazz = helper.parse(' class MyClass {} ') assert clazz.getCompiledTime() assert clazz.getCompiledTime() =~ DATE_FMT ================================================ FILE: listings/chap09/Listing_09_42_AstTesting5.groovy ================================================ import groovy.transform.ASTTest import org.codehaus.groovy.ast.stmt.ForStatement import org.codehaus.groovy.control.CompilePhase @ASTTest(phase=CompilePhase.SEMANTIC_ANALYSIS, value={ //#A lookup('anchor').each { n -> //#B assert n instanceof ForStatement //#C } }) void doSomething() { println 'Hello, Groovy!' anchor: for (int i=0; i<10;i++) { println "Iteration $i" } //#D } //#A annotate an enclosing node //#B call lookup to find a node labeled with “anchor” //#C perform assertion on each matching node //#D use a label on the node ================================================ FILE: listings/chap09/Listings.txt ================================================ Listings not in the root folder: 09_36: src/main/groovy/regina/CompiledAtASTTransformation.groovy 09_37: src/test/groovy/regina/CompiledAtASTTransformationTest.groovy ================================================ FILE: listings/chap09/build/reports/tests/classes/regina.CompiledAtASTTransformationTest.html ================================================ Test results - Class regina.CompiledAtASTTransformationTest

Class regina.CompiledAtASTTransformationTest

2

tests

0

failures

0

ignored

0.446s

duration

100%

successful

Tests

Test Duration Result
testShouldApplyToScriptAndScriptClasses 0.446s passed
testShouldApplyToThisTest 0s passed
================================================ FILE: listings/chap09/build/reports/tests/css/base-style.css ================================================ body { margin: 0; padding: 0; font-family: sans-serif; font-size: 12pt; } body, a, a:visited { color: #303030; } #content { padding-left: 50px; padding-right: 50px; padding-top: 30px; padding-bottom: 30px; } #content h1 { font-size: 160%; margin-bottom: 10px; } #footer { margin-top: 100px; font-size: 80%; white-space: nowrap; } #footer, #footer a { color: #a0a0a0; } ul { margin-left: 0; } h1, h2, h3 { white-space: nowrap; } h2 { font-size: 120%; } ul.tabLinks { padding-left: 0; padding-top: 10px; padding-bottom: 10px; overflow: auto; min-width: 800px; width: auto !important; width: 800px; } ul.tabLinks li { float: left; height: 100%; list-style: none; padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px; margin-bottom: 0; -moz-border-radius: 7px; border-radius: 7px; margin-right: 25px; border: solid 1px #d4d4d4; background-color: #f0f0f0; } ul.tabLinks li:hover { background-color: #fafafa; } ul.tabLinks li.selected { background-color: #c5f0f5; border-color: #c5f0f5; } ul.tabLinks a { font-size: 120%; display: block; outline: none; text-decoration: none; margin: 0; padding: 0; } ul.tabLinks li h2 { margin: 0; padding: 0; } div.tab { } div.selected { display: block; } div.deselected { display: none; } div.tab table { min-width: 350px; width: auto !important; width: 350px; border-collapse: collapse; } div.tab th, div.tab table { border-bottom: solid #d0d0d0 1px; } div.tab th { text-align: left; white-space: nowrap; padding-left: 6em; } div.tab th:first-child { padding-left: 0; } div.tab td { white-space: nowrap; padding-left: 6em; padding-top: 5px; padding-bottom: 5px; } div.tab td:first-child { padding-left: 0; } div.tab td.numeric, div.tab th.numeric { text-align: right; } span.code { display: inline-block; margin-top: 0em; margin-bottom: 1em; } span.code pre { font-size: 11pt; padding-top: 10px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; margin: 0; background-color: #f7f7f7; border: solid 1px #d0d0d0; min-width: 700px; width: auto !important; width: 700px; } ================================================ FILE: listings/chap09/build/reports/tests/css/style.css ================================================ #summary { margin-top: 30px; margin-bottom: 40px; } #summary table { border-collapse: collapse; } #summary td { vertical-align: top; } .breadcrumbs, .breadcrumbs a { color: #606060; } .infoBox { width: 110px; padding-top: 15px; padding-bottom: 15px; text-align: center; } .infoBox p { margin: 0; } .counter, .percent { font-size: 120%; font-weight: bold; margin-bottom: 8px; } #duration { width: 125px; } #successRate, .summaryGroup { border: solid 2px #d0d0d0; -moz-border-radius: 10px; border-radius: 10px; } #successRate { width: 140px; margin-left: 35px; } #successRate .percent { font-size: 180%; } .success, .success a { color: #008000; } div.success, #successRate.success { background-color: #bbd9bb; border-color: #008000; } .failures, .failures a { color: #b60808; } .skipped, .skipped a { color: #c09853; } div.failures, #successRate.failures { background-color: #ecdada; border-color: #b60808; } ul.linkList { padding-left: 0; } ul.linkList li { list-style: none; margin-bottom: 5px; } ================================================ FILE: listings/chap09/build/reports/tests/index.html ================================================ Test results - Test Summary

Test Summary

2

tests

0

failures

0

ignored

0.446s

duration

100%

successful

Packages

Package Tests Failures Ignored Duration Success rate
regina 2 0 0 0.446s 100%

Classes

Class Tests Failures Ignored Duration Success rate
regina.CompiledAtASTTransformationTest 2 0 0 0.446s 100%
================================================ FILE: listings/chap09/build/reports/tests/js/report.js ================================================ var tabs = new Object(); function initTabs() { var container = document.getElementById('tabs'); tabs.tabs = findTabs(container); tabs.titles = findTitles(tabs.tabs); tabs.headers = findHeaders(container); tabs.select = select; tabs.deselectAll = deselectAll; tabs.select(0); return true; } window.onload = initTabs; function switchTab() { var id = this.id.substr(1); for (var i = 0; i < tabs.tabs.length; i++) { if (tabs.tabs[i].id == id) { tabs.select(i); break; } } return false; } function select(i) { this.deselectAll(); changeElementClass(this.tabs[i], 'tab selected'); changeElementClass(this.headers[i], 'selected'); while (this.headers[i].firstChild) { this.headers[i].removeChild(this.headers[i].firstChild); } var h2 = document.createElement('H2'); h2.appendChild(document.createTextNode(this.titles[i])); this.headers[i].appendChild(h2); } function deselectAll() { for (var i = 0; i < this.tabs.length; i++) { changeElementClass(this.tabs[i], 'tab deselected'); changeElementClass(this.headers[i], 'deselected'); while (this.headers[i].firstChild) { this.headers[i].removeChild(this.headers[i].firstChild); } var a = document.createElement('A'); a.setAttribute('id', 'ltab' + i); a.setAttribute('href', '#tab' + i); a.onclick = switchTab; a.appendChild(document.createTextNode(this.titles[i])); this.headers[i].appendChild(a); } } function changeElementClass(element, classValue) { if (element.getAttribute('className')) { /* IE */ element.setAttribute('className', classValue) } else { element.setAttribute('class', classValue) } } function findTabs(container) { return findChildElements(container, 'DIV', 'tab'); } function findHeaders(container) { var owner = findChildElements(container, 'UL', 'tabLinks'); return findChildElements(owner[0], 'LI', null); } function findTitles(tabs) { var titles = new Array(); for (var i = 0; i < tabs.length; i++) { var tab = tabs[i]; var header = findChildElements(tab, 'H2', null)[0]; header.parentNode.removeChild(header); if (header.innerText) { titles.push(header.innerText) } else { titles.push(header.textContent) } } return titles; } function findChildElements(container, name, targetClass) { var elements = new Array(); var children = container.childNodes; for (var i = 0; i < children.length; i++) { var child = children.item(i); if (child.nodeType == 1 && child.nodeName == name) { if (targetClass && child.className.indexOf(targetClass) < 0) { continue; } elements.push(child); } } return elements; } ================================================ FILE: listings/chap09/build/reports/tests/packages/regina.html ================================================ Test results - Package regina

Package regina

2

tests

0

failures

0

ignored

0.446s

duration

100%

successful

Classes

Class Tests Failures Ignored Duration Success rate
CompiledAtASTTransformationTest 2 0 0 0.446s 100%
================================================ FILE: listings/chap09/build/resources/main/META-INF/services/org.codehaus.groovy.transform.ASTTransformation ================================================ regina.CompiledAtASTTransformation ================================================ FILE: listings/chap09/build/test-results/TEST-regina.CompiledAtASTTransformationTest.xml ================================================ ================================================ FILE: listings/chap09/build.gradle ================================================ apply plugin:'idea' apply plugin:'groovy' apply plugin:'java' repositories { mavenCentral() } dependencies { compile "org.codehaus.groovy:groovy-all:$groovyVersion" testCompile "org.codehaus.groovy:groovy-all:$groovyVersion" testCompile "junit:junit:4.12" } [compileGroovy, compileTestGroovy]*.options*.encoding = 'UTF-8' ================================================ FILE: listings/chap09/gradle/wrapper/gradle-wrapper.properties ================================================ #Thu Apr 10 09:16:15 EST 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-bin.zip ================================================ FILE: listings/chap09/gradle.properties ================================================ version=1.0.0-SNAPSHOT groovyVersion=2.4.0 ================================================ FILE: listings/chap09/gradlew ================================================ #!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # For Cygwin, ensure paths are in UNIX format before anything is touched. if $cygwin ; then [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi # Attempt to set APP_HOME # Resolve links: $0 may be a link 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 SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >&- APP_HOME="`pwd -P`" cd "$SAVED" >&- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. 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 if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" ================================================ FILE: listings/chap09/gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windowz variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: listings/chap09/settings.gradle ================================================ rootProject.name='regina-chap09' ================================================ FILE: listings/chap09/snippet0902_autoCloneDefault.txt ================================================ class Chef1 implements Cloneable { ... Chef1 clone() throws CloneNotSupportedException { Chef1 _result = (Chef1) super.clone() if (recipes instanceof Cloneable) { _result.recipes = (List) recipes.clone() } _result.born = (Date) born.clone() return _result } } ================================================ FILE: listings/chap09/snippet0902_autoCloneSerialization.txt ================================================ class Chef1 implements Cloneable, Serializable { ... Object clone() throws CloneNotSupportedException { def baos = new ByteArrayOutputStream() baos.withObjectOutputStream{ it.writeObject(this) } def bais = new ByteArrayInputStream(baos.toByteArray()) bais.withObjectInputStream(getClass().classLoader){ it.readObject() } } } ================================================ FILE: listings/chap09/snippet0902_autoExternalize.txt ================================================ class Composer implements Externalizable { ... void writeExternal(ObjectOutput out) throws IOException { out.writeObject(name) out.writeInt(born) out.writeBoolean(married) } void readExternal(ObjectInput oin) { name = (String) oin.readObject() born = oin.readInt() married = oin.readBoolean() } } ================================================ FILE: listings/chap09/snippet0902_fieldEquivalent.txt ================================================ class ScriptYYYYY extends Script { List awe = [1, 2, 3] public static void main(String[] args) { new ScriptYYYYY().run() //#A } public awesum() { awe.sum() } public run() { assert awesum() == 6 } } //#A again slightly simplified ================================================ FILE: listings/chap09/snippet0902_mapCreation.txt ================================================ class Chemist { String first, last int born } def c = new Chemist(first: "Marie", last: "Curie", born: 1867) assert c.first == "Marie" assert c.last == "Curie" assert c.born == 1867 ================================================ FILE: listings/chap09/snippet0902_noisySetDelegateByHand.txt ================================================ class NoisySet implements Set { private Set delegate = new HashSet() @Override boolean add(item) { println "adding $item" delegate.add(item) } @Override boolean addAll(Collection items) { items.each { println "adding $it" } delegate.addAll(items) } @Override boolean isEmpty() { return delegate.isEmpty() } @Override boolean contains(Object o) { return delegate.contains(o) } // ... ditto for size, iterator, toArray, remove, // containsAll, retainAll, removeAll, clear ... @Override int size() { return delegate.size() } @Override Iterator iterator() { return delegate.iterator() } @Override Object[] toArray() { return delegate.toArray() } @Override def Object[] toArray(Object[] a) { return delegate.toArray(a) } @Override boolean remove(Object o) { return delegate.remove(o) } @Override boolean containsAll(Collection c) { return delegate.containsAll(c) } @Override boolean retainAll(Collection c) { return delegate.retainAll(c) } @Override boolean removeAll(Collection c) { return delegate.removeAll(c) } @Override void clear() { delegate.clear() } } Set ns = new NoisySet() ns.add(1) ns.addAll([2, 3]) assert ns.size() == 3 ================================================ FILE: listings/chap09/snippet0902_noisySetInheritance.txt ================================================ class NoisySet extends HashSet { @Override boolean add(item) { println "adding $item" super.add(item) } @Override boolean addAll(Collection items) { items.each { println "adding $it" } super.addAll(items) } } new NoisySet().with{ add(1) addAll([2, 3]) assert size() == 3 } ================================================ FILE: listings/chap09/snippet0902_nonTailCallReverseList.txt ================================================ class ListUtil { static reverse(List list) { if (list.isEmpty()) list else reverse(list.tail()) + list.head() } } assert ListUtil.reverse(['a', 'b', 'c']) == ['c', 'b', 'a'] ================================================ FILE: listings/chap09/snippet0902_readWriteByHand.txt ================================================ import java.util.concurrent.locks.ReentrantReadWriteLock class PhoneBook3 { private final phoneNumbers = [:] final private lock = new ReentrantReadWriteLock() def getNumber(key) { lock.readLock().lock() try { phoneNumbers[key] } finally { lock.readLock().unlock() } } def addNumber(key, value) { lock.writeLock().lock() try { phoneNumbers[key] = value } finally { lock.writeLock().unlock() } } } ================================================ FILE: listings/chap09/snippet0902_readWriteLock.txt ================================================ import groovy.transform.* class PhoneBook3 { private final phoneNumbers = [:] @WithReadLock def getNumber(key) { phoneNumbers[key] } @WithWriteLock def addNumber(key, value) { phoneNumbers[key] = value } } ================================================ FILE: listings/chap09/snippet0902_singletonByHand.txt ================================================ class Zeus { static final Zeus instance = new Zeus() private Zeus() { } } assert Zeus.instance ================================================ FILE: listings/chap09/snippet0902_toStringEquivalent.txt ================================================ import org.codehaus.groovy.runtime.InvokerHelper class SleuthExpanded { String firstName String lastName String toString() { def _result = new StringBuilder() def $toStringFirst = true _result.append('Sleuth(') def firstName = InvokerHelper.getProperty(this, 'firstName') if (firstName != null) { if ($toStringFirst) { $toStringFirst = false } else { _result.append(', ') } _result.append('firstName:') if (firstName.is(this)) { _result.append('(this)') } else { _result.append(InvokerHelper.toString(firstName)) } } def lastName = InvokerHelper.getProperty(this, 'lastName') if (lastName != null) { if ($toStringFirst) { $toStringFirst = false } else { _result.append(', ') } _result.append('lastName:') if (lastName.is(this)) { _result.append('(this)') } else { _result.append(InvokerHelper.toString(lastName)) } } _result.append(')') return _result.toString() } } def nancy = new SleuthExpanded(firstName: 'Nancy', lastName: 'Drew') assert nancy.toString() == 'Sleuth(firstName:Nancy, lastName:Drew)' nancy.lastName = null assert nancy.toString() == 'Sleuth(firstName:Nancy)' ================================================ FILE: listings/chap09/snippet0903_greeterExpanded.txt ================================================ class Greeter { def greet() { println "Hello from the greet() method!" } public static void main(String[] args) { new Greeter().greet() } } ================================================ FILE: listings/chap09/snippet0903_greeterScript.txt ================================================ class Greeter { @Main def greet() { println "Hello from the greet() method!" } } ================================================ FILE: listings/chap09/snippet0903_localMain.txt ================================================ @Retention(RetentionPolicy.SOURCE) @Target([ElementType.METHOD]) @GroovyASTTransformationClass(classes = [MainTransformation]) @interface Main {} ================================================ FILE: listings/chap09/snippet0903_localMainTransformation.txt ================================================ @GroovyASTTransformation(phase = CompilePhase.INSTRUCTION_SELECTION) class MainTransformation implements ASTTransformation { void visit(ASTNode[] astNodes, SourceUnit sourceUnit) { // perform any checks // construct appropriate main method // add main method to class } } ================================================ FILE: listings/chap09/snippet0905_GetCompiledTimeScript.txt ================================================ println 'script compiled at: ' + compiledTime class MyClass { } println 'script class compiled at: ' + MyClass.compiledTime ================================================ FILE: listings/chap09/src/main/groovy/regina/CompiledAtASTTransformation.groovy ================================================ package regina import org.codehaus.groovy.ast.* import org.codehaus.groovy.transform.* import org.codehaus.groovy.control.* import org.codehaus.groovy.ast.builder.AstBuilder import static groovyjarjarasm.asm.Opcodes.* @GroovyASTTransformation(phase=CompilePhase.CONVERSION) class CompiledAtASTTransformation implements ASTTransformation { private static final compileTime = new Date().toString() void visit(ASTNode[] astNodes, SourceUnit sourceUnit) { List classes = sourceUnit.ast?.classes classes.each { ClassNode clazz -> clazz.addMethod(makeMethod()) } } MethodNode makeMethod() { def ast = new AstBuilder().buildFromSpec { method('getCompiledTime', ACC_PUBLIC | ACC_STATIC, String) { parameters {} exceptions {} block { returnStatement { constant(compileTime) } } annotations {} } } ast[0] } } ================================================ FILE: listings/chap09/src/main/resources/META-INF/services/org.codehaus.groovy.transform.ASTTransformation ================================================ regina.CompiledAtASTTransformation ================================================ FILE: listings/chap09/src/test/groovy/regina/CompiledAtASTTransformationTest.groovy ================================================ package regina class CompiledAtASTTransformationTest extends GroovyTestCase { // matches format: EEE MMM dd HH:mm:ss zzz yyyy static DATE_FMT = /\w{3} \w{3} \d\d \d\d:\d\d:\d\d \S{3,9} \d{4}/ @Override protected void setUp() throws Exception { super.setUp() } void testShouldApplyToThisTest() { assert compiledTime.toString() =~ DATE_FMT } void testShouldApplyToScriptAndScriptClasses() { assertScript ''' import static regina.CompiledAtASTTransformationTest.* assert compiledTime.toString() =~ DATE_FMT class MyClass { } assert MyClass.compiledTime.toString() =~ DATE_FMT ''' } } ================================================ FILE: listings/chap10/Greeter.java ================================================ public class Greeter { // Java! static void greet(Object o) { System.out.println("Hello, object " + o); } static void greet(String s) { System.out.println("Hello, string " + s); } public static void main(String... args) { Object o = "Bob"; String s = "Bob"; greet(o); greet(s); } } ================================================ FILE: listings/chap10/Listing_10_01_Duck.groovy ================================================ class Duck { def methodMissing(String name, args) { println "$name!" } } def duck = new Duck() duck.quack() ================================================ FILE: listings/chap10/Listing_10_02_failing_Typo.groovy ================================================ class Detective { String firstName String lastName } def sherlock = new Detective(firstname: 'Sherlock', lastname: 'Holmes') assert sherlock.lastName == 'Holmes' ================================================ FILE: listings/chap10/Listing_10_03_ClassTC.groovy ================================================ import groovy.transform.TypeChecked @TypeChecked //#A class Sleuth { String firstName String lastName String getFullName() { "$firstName $lastName" } } assert new Sleuth(firstName: 'Nancy', lastName: 'Drew').fullName == 'Nancy Drew' //#A Class annotation ================================================ FILE: listings/chap10/Listing_10_04_OneMethodTC.groovy ================================================ import groovy.transform.TypeChecked class Actor { String firstName, lastName @TypeChecked String getFullName() { "$firstName $lastName" } //#1 void makePeace() { new AntBuilder().echo('Peace was never an option') //#2 } } def magneto = new Actor(firstName: 'Ian', lastName: 'McKellen') assert magneto.fullName == 'Ian McKellen' magneto.makePeace() //#1 Checked //#2 Dynamic features allowed ================================================ FILE: listings/chap10/Listing_10_05_CompileTimeTypo.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.TypeChecked @TypeChecked class Sleuth { String firstName String lastName //#A String getFullName() { "$firstName $lastname" } //#B } '''.trim() println e.message assert e.message.contains( '[Static type checking] - The variable [lastname] is undeclared') //#A Uppercase N in lastName //#B Incorrect lowercase n in lastname ================================================ FILE: listings/chap10/Listing_10_06_MethodNameTypo.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' @groovy.transform.TypeChecked class Person { String name String getFullName() { name.toUppercase() } //#A } ''' println e.message assert e.message.contains( 'Cannot find matching method java.lang.String#toUppercase()') //#A Incorrect lowercase c ================================================ FILE: listings/chap10/Listing_10_07_MethodArgsFlipped.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' @groovy.transform.TypeChecked class Repeat { static void repeat(int n, String message) { n.times{ println message } } static void validateAll(String... args) { repeat('Hello', 4) } } ''' println e.message assert e.message.contains( 'Cannot find matching method Repeat#repeat(java.lang.String, int)') ================================================ FILE: listings/chap10/Listing_10_08_InvalidAssignments.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' @groovy.transform.TypeChecked void testAssignmentsShouldThrowCompilationErrors() { Set set = new Object() //#A byte b = 200L //#B List list = ['Richard', 'Mary'] //#C int prim = null //#D } ''' // massage to account for error message typo fixed in 2.4.1 def message = e.message.replaceAll('loose of precision', 'loss of precision') [ 'Cannot assign value of type java.lang.Object to variable of ' + 'type java.util.Set', // typo loose should be loss in 2.4.1 'Possible loss of precision from long to byte', 'Incompatible generic argument types. Cannot assign ' + 'java.util.List to: java.util.List ', 'Cannot assign value of type java.lang.Object to variable of type int' ].each{ assert message.contains(it) } //#A Cannot cast Object into Set //#B Possible loss of precision //#C Wrong generics //#D Primitives cannot be null ================================================ FILE: listings/chap10/Listing_10_09_AssignmentsWithCoercion.groovy ================================================ enum MyEnum { var, val } @groovy.transform.TypeChecked void testAssignmentsWithCoercion() { MyEnum val = 'val' //#A assert val == MyEnum.val String blue = java.awt.Color.BLUE //#B assert blue == 'java.awt.Color[r=0,g=0,b=255]' boolean nonEmpty = new Date() //#C Boolean empty = '' //#C assert nonEmpty assert !empty Class stringClass = 'java.lang.String' //#D assert stringClass.interfaces.size() == 3 } testAssignmentsWithCoercion() //#A Strings coerced to enum values //#B Anything coerced to String //#C Anything coerced to boolean/Boolean //#D Strings coerced to classes ================================================ FILE: listings/chap10/Listing_10_10_DefField.groovy ================================================ class Holder { def value = 'My value' //#1 } @groovy.transform.TypeChecked void testNoCompileTimeErrorDueToDef() { def holder = new Holder() //#2 holder.value = 5 //#3 } testNoCompileTimeErrorDueToDef() //#1 Property declaration //#2 Create Holder instance //#3 Holder value type changes! ================================================ FILE: listings/chap10/Listing_10_11_InPlaceList.groovy ================================================ def authors = ['Dierk', 'Guillaume'] //#1 authors.each { println it } //#A //#1 Declaration of a list //#A List iteration ================================================ FILE: listings/chap10/Listing_10_12_Generics.groovy ================================================ import groovy.transform.TypeChecked @TypeChecked void printAuthors() { def authors = ['Dierk', 'Guillaume'] printToUpperCase(authors) } void printToUpperCase(List authors) { authors.each { println it.toUpperCase() } } printAuthors() ================================================ FILE: listings/chap10/Listing_10_13_ListStyleCtorRuntime.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail void oneDimensional() { java.awt.Dimension d = [100] //#A } shouldFail(ClassCastException) { oneDimensional() } //#A Two parameters required! Runtime error here! ================================================ FILE: listings/chap10/Listing_10_14_ListStyleCtorTC.groovy ================================================ import org.codehaus.groovy.control.CompilationFailedException import static groovy.test.GroovyAssert.shouldFail def e = shouldFail CompilationFailedException, ''' @groovy.transform.TypeChecked void alsoOneDimensional() { java.awt.Dimension d = [100] //#A } ''' assert e.message.contains( 'No matching constructor found: java.awt.Dimension(int)') //#A Two parameters required. Compilation fails! ================================================ FILE: listings/chap10/Listing_10_15_MapStyleCtorBad.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.TypeChecked class Athlete { String first String last int age } @TypeChecked void ageInteger() { Athlete ok = [first: 'Michael', last: 'Jordan', age: 52] //#A } @TypeChecked void ageString() { Athlete bad = [first: 'Michael', last: 'Jordan', age: '52'] //#B } @TypeChecked void ageStringNormal() { def alsoBad = new Athlete(first: 'Michael', last: 'Jordan', age: '52') //#B } //#A Passes //#B Fails ''' assert e.message.contains( 'Cannot assign value of type java.lang.String to variable of type int') ================================================ FILE: listings/chap10/Listing_10_16_ListStyleCtor.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.* @TupleConstructor class Author { String first String last int born } @TypeChecked Author createAuthor(List params) { Author a = params //#A a } createAuthor(['Agatha', 'Christie', 1890]) ''' assert e.message.contains('Cannot assign value of type java.util.List' + ' to variable of type Author') //#A Compile-time error! ================================================ FILE: listings/chap10/Listing_10_17_ListStyleCtorFixed.groovy ================================================ import groovy.transform.* @TupleConstructor class Author { String first String last int born } @TypeChecked Author createAuthor(List params) { if (params.size() != 3) { throw new IllegalArgumentException('Incorrect number of arguments') } String first = params[0] //#A String last = params[1] //#A Integer age = (Integer) params[2] //#B Author a = [first, last, age] //#C a } assert createAuthor(['Agatha', 'Christie', 1890]).born == 1890 //#A no need to cast as String on LHS //#B Cast required //#C Passes ================================================ FILE: listings/chap10/Listing_10_18_CodeAsData.groovy ================================================ def sum1(int x, int y) { x + y } //#1 def sum2 = { int x, int y -> x + y } //#2 assert sum1(3, 4) == 7 assert sum2(4, 5) == 9 //#1 sum function defined using a method //#2 sum function defined using a closure ================================================ FILE: listings/chap10/Listing_10_19_ClosuresBadReturnType.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.TypeChecked class Logger { static void print(Closure messageProvider) { println "Received message : ${messageProvider()}" } } @TypeChecked void testMessage() { def returnsString = { 'Hello, Groovy!' } def returnsInt = { int x, int y -> x + y } Logger.print(returnsString) //#1 Logger.print(returnsInt) //#2 } ''' println e.message.readLines().find{ it.contains('[Static ') } assert e.message.contains( 'Cannot call Logger#print(groovy.lang.Closure )' + ' with arguments [groovy.lang.Closure ]') //#1 Passes //#2 Compilation fails ================================================ FILE: listings/chap10/Listing_10_20_UserValidation.groovy ================================================ void validate(User u, Closure rule) { if (!rule.call(u)) { //#1 println "User $u.name $u.password rejected" } } void validateAll(user) { validate(user) { !it.name.isEmpty() } //#2 validate(user) { it.password.size() > 7 } //#3 } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) //#1 Apply rule //#2 Example passing rule //#3 Example failing rule ================================================ FILE: listings/chap10/Listing_10_21_UserValidationTC.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' class User { String name, password } import groovy.transform.TypeChecked void validate(User u, Closure rule) { if (!rule.call(u)) { println "User $u.name $u.password rejected" } } @TypeChecked void validateAll(user) { //#1 validate(user) { !it.name.isEmpty() } //#2 validate(user) { it.password.size() > 7 } //#3 } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) ''' // println out just the error messages println e.message.readLines().findAll{ it.contains('[Static type checking]') }*.replaceAll(/.*(\[Static type checking\])(.*)/, '$1$2').join('\n') assert e.message.contains('No such property: name for class: java.lang.Object') assert e.message.contains('No such property: password for class: java.lang.Object') assert e.message =~ /Cannot find matching method.*validate\(java.lang.Object, groovy.lang.Closure\)/ //#1 Type of user is Object //#2 No property name for Object //#3 No property password for Object ================================================ FILE: listings/chap10/Listing_10_22_UserValidation_ExplicitTypes.groovy ================================================ import groovy.transform.TypeChecked void validate(User u, Closure rule) { if (!rule.call(u)) { println "User $u.name $u.password rejected" } } @TypeChecked void validateAll(User user) { //#A validate(user) { User u -> !u.name.isEmpty() } //#A validate(user) { User u -> u.password.size() > 7 } //#A } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) //#A User type in method and closure declarations ================================================ FILE: listings/chap10/Listing_10_23_UserValidation_SAM.groovy ================================================ import groovy.transform.TypeChecked interface Predicate { boolean apply(On e) } //#1 void validate(User u, Predicate rule) { //#2 if (!rule.apply(u)) { println "User $u.name $u.password rejected" } } @TypeChecked void validateAll(User user) { validate(user) { !it.name.isEmpty() } //#3 validate(user) { it.password.size() > 7 } //#3 } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) //#1 SAM type definition //#2 SAM type argument //#3 Implicit type inferred ================================================ FILE: listings/chap10/Listing_10_24_UserValidation_ClosureParams.groovy ================================================ import groovy.transform.TypeChecked import groovy.transform.stc.* void validate(User u, @ClosureParams(FirstParam) Closure rule) { //#1 if (!rule.call(u)) { println "User $u.name $u.password rejected" } } @TypeChecked void validateAll(User user) { validate(user) { !it.name.isEmpty() } validate(user) { it.password.size() > 7 } } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) ================================================ FILE: listings/chap10/Listing_10_25_UserValidation_DSL.groovy ================================================ def validate(User u, Closure rule) { rule.delegate = u //#1 rule() //#2 } void validateAll(User u) { validate(u) { if (name.isEmpty()) println 'Empty name' } //#3 validate(u) { if (password.size() < 8) println 'Password too short' }//#3 } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) //#1 Set user as delegate //#2 Call validation rule //#3 Simplified rule syntax ================================================ FILE: listings/chap10/Listing_10_26_UserValidation_DelegatesTo.groovy ================================================ import groovy.transform.TypeChecked def validate(User u, @DelegatesTo(User) Closure rule) { //#A rule.delegate = u rule() } @TypeChecked void validateAll(User u) { validate(u) { if (name.isEmpty()) println 'Empty name' } validate(u) { if (password.size() < 8) println 'Password too short' } } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) //#A Annotation on Closure parameter ================================================ FILE: listings/chap10/Listing_10_27_UserValidation_DelegatesToTarget.groovy ================================================ import groovy.transform.TypeChecked def validate(@DelegatesTo.Target User u, @DelegatesTo Closure rule) { //#A rule.delegate = u rule() } @TypeChecked void validateAll(User u) { validate(u) { if (name.isEmpty()) println 'Empty name' } validate(u) { if (password.size() < 8) println 'Password too short' } } def bob = new User(name: 'Bob', password: 'secr3t') validateAll(bob) //#A Annotate the Closure and the User ================================================ FILE: listings/chap10/Listing_10_28_Category.groovy ================================================ import groovy.time.TimeCategory class VacationHelper { static duration() { use(TimeCategory) { doCompute() } } static doCompute() { 1.week - 1.day } } assert VacationHelper.duration().toString() == '6 days' ================================================ FILE: listings/chap10/Listing_10_29_EMC.groovy ================================================ class Spy { static { def mc = new ExpandoMetaClass(Spy, false, true) //#A mc.initialize() Spy.metaClass = mc } String name = "James" void methodMissing(String name, args) { if (name.startsWith('changeNameTo')) { println "Adding method $name" String newName = name.substring(12) def newMethod = { delegate.name = newName } //#1 Spy.metaClass."$name" = newMethod //#2 newMethod() //#B } else { throw new MissingMethodException(name, this.class, args) } } } def spy = new Spy() assert "James" == spy.name spy.changeNameToAustin() assert "Austin" == spy.name spy.changeNameToMaxwell() assert "Maxwell" == spy.name spy.changeNameToAustin() //#1 If method not found, define new one //#2 Cache method //#A Create an ExpandoMetaClass for Spy class //#B Call new method ================================================ FILE: listings/chap10/Listing_10_30_Builder.groovy ================================================ import groovy.xml.MarkupBuilder def writer = new StringWriter() def xml = new MarkupBuilder(writer) //#A xml.html { //#1 head { //#1 title('An XHTML Page') //#1 } } println writer //#A Instantiate MarkupBuilder //#1 Method calls that @TypeChecked would reject ================================================ FILE: listings/chap10/Listing_10_31_MixedTypeChecking.groovy ================================================ import groovy.xml.MarkupBuilder import groovy.transform.TypeChecked class HTMLExample { private static String buildPage(String pageTitle) { def writer = new StringWriter() def xml = new MarkupBuilder(writer) xml.html { head { title(pageTitle) } } writer } @TypeChecked //#A static String page404() { buildPage '404 - Not Found' } } HTMLExample.page404() //#A Type check only this method ================================================ FILE: listings/chap10/Listing_10_32_Skip.groovy ================================================ import groovy.xml.MarkupBuilder import groovy.transform.TypeChecked import groovy.transform.TypeCheckingMode @TypeChecked //#A class HTMLExample2 { @TypeChecked(TypeCheckingMode.SKIP) //#B private static String buildPage(String pageTitle) { def writer = new StringWriter() def xml = new MarkupBuilder(writer) xml.html { head { title(pageTitle) } } writer } static String page404() { buildPage '404 - Not Found' } } HTMLExample2.page404() //#A Type check class //#B But exclude this method ================================================ FILE: listings/chap10/Listing_10_33_FlowTyping.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.TypeChecked @TypeChecked def flowTyping() { def var = 'A string' //#1 var = var.toUpperCase() //#2 var = var.length() //#3 var = String.valueOf(var) //#4 var = 2*var //#5 var } //#1 Assign String to var //#2 Assign another String to var //#3 Assign int to var //#4 Assign String to var //#5 FAIL! Trying to call (int*String) ''' println e.message.readLines().find{ it.contains('[Static type') } assert e.message.contains('Cannot find matching method int#multiply(java.lang.String)') ================================================ FILE: listings/chap10/Listing_10_34_FlowTypingOk.groovy ================================================ import groovy.transform.TypeChecked interface Flying { void fly() } class Bird implements Flying { void fly() { println "I'm flying!" } } class Canary extends Bird { void sing() { println "Tweet!" } } @TypeChecked void main() { def o = new Bird() o.fly() //#1 o = new Canary() o.fly() //#2 o.sing() //#2 // o = new Bird() // o.sing() //#A } main() //#1 a bird can fly //#2 a canary can fly too and also sing //#A Would fail compilation ================================================ FILE: listings/chap10/Listing_10_35_LUB.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.TypeChecked interface Polite { void greet() void thank() } class Person implements Polite { String name void greet() { println "Hello, I'm $name!" } void thank() { println 'Thanks!' } } class Owl implements Polite { void greet() { hoot() } void thank() { hoot() } void hoot() { println 'Hoot' } } @TypeChecked void main() { def list = [new Person(name: 'Bill'), new Owl()] //#A Polite p1 = list[0] //#B Polite o1 = list[1] //#B Owl o2 = list[0] //#1 Person p2 = list[1] //#2 // extra sample (comment out and not mentioned in the book): // a way to overcome above problem if we wanted to in Groovy // def tuple = new Tuple2(new Person(name: 'Bill'), new Owl()) // Person p3 = tuple.first // Owl o3 = tuple.second } main() //#A Create list with Person and Owl //#B Assign either element to variable of type Polite //#1 Try to assign 1st element to Owl //#2 Try to assign 2nd element to Person ''' assert e.message.contains('Cannot assign value of type Polite to variable of type Owl') assert e.message.contains('Cannot assign value of type Polite to variable of type Person') ================================================ FILE: listings/chap10/Listing_10_36_Condition.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.TypeChecked @TypeChecked void leastUpperBoundOnConditional() { def o = new Date() //#1 if (Math.random()) { //#A o = 'Hello' //#2 } o.time //#B } //#1 Variable initialized with Date //#A Random condition //#2 Assign a String //#B Try to call o.time ''' assert e.message.contains('No such property: time for class: java.io.Serializable') ================================================ FILE: listings/chap10/Listing_10_37_ClosureSharedVar.groovy ================================================ import groovy.transform.TypeChecked @TypeChecked def captureOfALocalVariable() { def msg = 'Hello' //#A def cl = { msg = 'Hi!' } //#B assert msg == 'Hello' cl() //#1 assert msg == 'Hi!' } captureOfALocalVariable() //#A Variable msg is closure shared variable //#B Closure can write to msg //#1 Closure is called ================================================ FILE: listings/chap10/Listing_10_38_LubError.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.transform.TypeChecked @TypeChecked void notAllowed() { def var = "String" def cl = { var = new Date() } cl() var = var.toUpperCase() } ''' assert e.message.contains( 'A closure shared variable [var] has been assigned with ') ================================================ FILE: listings/chap10/Listing_10_39_LubOk.groovy ================================================ import groovy.transform.TypeChecked class A { void foo() {} } class B extends A { void bar() {} } @TypeChecked void main() { def var = new A() def cl = { var = new B() } cl() var.foo() } main() ================================================ FILE: listings/chap10/Listing_10_40_FibBench.groovy ================================================ @Grab('org.gperfutils:gbench:0.4.3-groovy-2.4') import groovy.transform.CompileStatic def dynamicFib(n) { n<1 ? 1 : dynamicFib(n-1) + dynamicFib(n-2) } int primFib(int n) { n<1 ? 1 : primFib(n-1) + primFib(n-2) } @CompileStatic int staticFib(int n) { n<1 ? 1 : staticFib(n-1) + staticFib(n-2) } def r = benchmark { 'Dynamic Groovy' { dynamicFib(10) } 'Primitive optimized Groovy' { primFib(10) } 'Statically compiled Groovy' { staticFib(10) } } r.prettyPrint() ================================================ FILE: listings/chap10/Listing_10_41_JavaGreeter.txt ================================================ see: Greeter.java ================================================ FILE: listings/chap10/Listing_10_42_StaticCompileDispatch.groovy ================================================ import groovy.transform.CompileStatic static String prettify(String s) { "String: $s" } static String prettify(Date d) { "Date: ${d.time}" } @CompileStatic void test() { def var = "I'm a String" //#1 println prettify(var) //#2 } test() //#1 Using def, which is equivalent to Object //#2 Calls prettify(String) ================================================ FILE: listings/chap10/Listing_10_43_MonkeyPatching.groovy ================================================ import groovy.transform.CompileStatic class MyFramework { static int sizeOf(String s) { s.size() } //#1 @CompileStatic static int staticSizeOf(String s) { s.size() } //#2 } String s = 'a happy new year!' s.metaClass.size = { -> 5 } //#3 assert s.size() == 5 //#4 assert MyFramework.sizeOf(s) == 5 //#5 assert MyFramework.staticSizeOf(s) == 17 //#6 //#1 sizeOf method uses dynamic dispatch //#2 staticSizeOf method uses static dispatch //#3 change metaclass so that size always returns 5 //#4 check that size returns 5 //#5 check that calling size from the framework returns 5 //#6 check that from statically compiled method returns the original size ================================================ FILE: listings/chap10/Listing_10_44_BookingDSL.groovy ================================================ import groovy.transform.Canonical @Canonical class Booking { String meetingRoom String className Date start, end } def book(meeting) { [room: { name -> [between: { sd -> [and: { ed -> [to: { to -> def b = new Booking(meetingRoom: name, className: to, start: sd, end: ed) println b b }] }] }] }] } def meeting @Category(Integer) class TimeCategory { static Date getAm(Integer self) { def d = Calendar.instance d.set(Calendar.MINUTE, 0) d.set(Calendar.SECOND, 0) d.set(Calendar.HOUR_OF_DAY, self) d.time } } use(TimeCategory) { book meeting room 'Honolulu' between 9.am and 12.am to 'B2' } ================================================ FILE: listings/chap10/Listing_10_45_MultiValidation.groovy ================================================ import groovy.transform.TypeChecked class Address { String country } class WishList { List items } def validate(@DelegatesTo.Target def o, @DelegatesTo Closure rule) { //#1 rule.delegate = o rule() } @TypeChecked void validateAll() { def a = new Address(country: 'Australia') validate(a) { //#2 if (country[0] == 'X') //#3 println 'No countries start with that' } def wl = new WishList(items: ['iphone', 'iphone']) validate(wl) { //#4 if (items != items.toUnique()) //#5 println 'Some item appeared twice' } } validateAll() //#1 Compiler will determine type //#2 First param is Address //#3 Address inferred so country will be found //#4 First param is WishList //#5 WishList inferred so items will be found ================================================ FILE: listings/chap10/Listing_10_46_RobotExtension.groovy ================================================ unresolvedVariable { var -> //#1 if (var.name == 'robot') { //#1 storeType(var, lookupClassNodeFor('Robot')) //#1 handled = true //#1 } } unresolvedProperty { pexp -> //#2 if (getType(pexp.objectExpression) == int_TYPE && //#2 pexp.propertyAsString == 'meters') { //#2 storeType(pexp, long_TYPE) //#2 handled = true //#2 } } //#1 An unresolved 'robot' variable has type Robot //#2 An unresolved 'meters' property on an int has type long ================================================ FILE: listings/chap10/Listing_10_47_SQLExtension.groovy ================================================ @Grab('com.github.jsqlparser:jsqlparser:0.9.2') import net.sf.jsqlparser.parser.CCJSqlParserManager afterMethodCall { mc -> def receiver = mc.receiver if (!isVariableExpression(receiver)) return //#1 def method = getTargetMethod(mc) //#1 if (classNodeFor(groovy.sql.Sql) == getType(receiver) //#1 && method.name == 'eachRow') { //#1 def argList = getArguments(mc) //#1 if (argList && isConstantExpression(argList[0])) { //#1 def pm = new CCJSqlParserManager() //#2 def sqlQuery = argList[0].text //#2 try { //#2 pm.parse(new StringReader(sqlQuery)) //#2 } catch (e) { addStaticTypeError("SQL query is not valid: $e", argList[0]) //#3 } } } } //#1 Info extraction and guards //#2 Validate SQL using library //#3 Flag an error if invalid ================================================ FILE: listings/chap10/User.groovy ================================================ class User { String name String password } ================================================ FILE: listings/chap10/extra1004_JavaDispatch.java ================================================ import java.util.Date; class JavaDispatch { public static String prettify(Object o) { if (o instanceof String) { return doPrettify((String) o); } if (o instanceof Date) { return doPrettify((Date) o); } return doPrettify(o); } static String doPrettify(Object o) { return "Value:"+o.toString(); } static String doPrettify(String s) { return "String:"+s; } static String doPrettify(Date d) { return "Date:"+d.getTime(); } } ================================================ FILE: listings/chap10/extra1004_RuntimeGroovyDispatch.groovy ================================================ static String prettify(String s) { "String: $s" } static String prettify(Date d) { "Date: ${d.time}" } def var = "I'm a String" println prettify(var) ================================================ FILE: listings/chap10/markup.html ================================================ Constructed by MarkupBuilder

What can I do with MarkupBuilder?







================================================ FILE: listings/chap10/snippet1003_GroovyGreeter.groovy ================================================ public class GroovyGreeter { static void greet(Object o) { System.out.println("Hello, object " + o); } static void greet(String s) { System.out.println("Hello, string " + s); } public static void main(String... args) { Object o = "Bob"; String s = "Bob"; greet(o); greet(s); } } ================================================ FILE: listings/chap10/snippet1005_RobotMainTC.groovy ================================================ import groovy.transform.TypeChecked class Robot { void move(long distance) { println "Moving $distance meters" } } @TypeChecked(extensions = 'Listing_10_46_RobotExtension.groovy') main() { robot.move 100.meters } binding.robot = new Robot() Integer.metaClass.getMeters = { delegate } main() ================================================ FILE: listings/chap10/snippet1005_SqlMainTC.groovy ================================================ import static groovy.test.GroovyAssert.shouldFail def e = shouldFail ''' import groovy.sql.Sql import groovy.transform.TypeChecked @TypeChecked(extensions = 'Listing_10_47_SQLExtension.groovy') findAthletes(Sql sql) { sql.eachRow('select * frm Athlete') { row -> println row } //#A } //#A Typo 'frm' not 'from' ''' println e.message assert e.message.contains('[Static type checking] - SQL query is not valid') ================================================ FILE: listings/chap11/Listing_11_01_SquaresFactors.xml ================================================ Squares and factors of 10..15 ================================================ FILE: listings/chap11/Listing_11_02_SquaresFactors.java ================================================ import org.w3c.dom.Element; import org.w3c.dom.Document; public class Listing_11_02_SquaresFactors { public void process(Document doc) { /////////// EXAMPLE START // Java! // … doc made available here … Element numbers = doc.createElement("numbers"); Element description = doc.createElement("description"); doc.appendChild(numbers); numbers.appendChild(description); description.setTextContent("Squares and factors of 10..15"); for (int i=10; i <= 15; i++) { Element number = doc.createElement("number"); numbers.appendChild(number); number.setAttribute("value", String.valueOf(i)); number.setAttribute("square", String.valueOf(i*i)); for (int j=2; j < i; j++) { if (i % j== 0) { Element factor = doc.createElement("factor"); factor.setAttribute("value", String.valueOf(j)); number.appendChild(factor); } } } ////////// EXAMPLE END } } ================================================ FILE: listings/chap11/Listing_11_03_MarkupBuilderPlain.groovy ================================================ def builder = new groovy.xml.MarkupBuilder() builder.numbers { description 'Squares and factors of 10..15' for (i in 10..15) { number (value: i, square: i*i) { //#1 for (j in 2.. """ //#1 NEW: MarkupBuilder replaces NodeBuilder ================================================ FILE: listings/chap11/Listing_11_07_MarkupBuilderHtml.groovy ================================================ def writer = new FileWriter('markup.html') def html = new groovy.xml.MarkupBuilder(writer) html.html { head { title 'Constructed by MarkupBuilder' } body { h1 'What can I do with MarkupBuilder?' parent { mkp.yield "Some text" child('Child text') mkp.yield "more text" } form (action:'whatever') { for (line in ['Produce HTML','Produce XML','Have some fun']){ input(type:'checkbox',checked:'checked', id:line, '') label(for:line, line) br() } } } } ================================================ FILE: listings/chap11/Listing_11_08_StreamingMarkupBuilderLogic.groovy ================================================ def builder = new groovy.xml.StreamingMarkupBuilder() def writable = builder.bind { //#A invoices { //#B for (day in 1..3) { def invDate = Date.parse('yyyy-MM-dd', "2015-01-0$day") invoice(date: invDate) { item(count: day) { product(name: 'ULC', dollar: 1499) } } } } } def result = writable.toString() //#C assert result.startsWith("') //#|D //#A The bind method introduces the markup Closure //#B The root node must be included in the markup //#C Or writable.writeTo(file) //#D Checking start and end of long single line ================================================ FILE: listings/chap11/Listing_11_09_ExampleBuild.xml ================================================ ================================================ FILE: listings/chap11/Listing_11_10_PW_SwingBuilder.groovy ================================================ import groovy.swing.SwingBuilder swing = new SwingBuilder() frame = swing.frame(title:'Password') { passwordField(columns:10, actionPerformed: { event -> println event.source.text // any further processing is called here System.exit(0) } ) } frame.pack() frame.visible = true ================================================ FILE: listings/chap11/Listing_11_11_Swing_Widgets.groovy ================================================ import groovy.swing.SwingBuilder swing = new SwingBuilder() frame = swing.frame(title:'Demo') { menuBar { menu('File') { menuItem 'New' menuItem 'Open' } } panel { label 'Label 1' slider() comboBox(items:['one','two','three']) } } frame.pack() frame.visible = true ================================================ FILE: listings/chap11/Listing_11_12_Swing_Layout.groovy ================================================ import groovy.swing.SwingBuilder import java.awt.BorderLayout as BL swing = new SwingBuilder() frame = swing.frame(title:'Layout Demo') { panel(layout: new BL()) { button(constraints: BL.NORTH, 'North' ) button(constraints: BL.CENTER, 'Center') button(constraints: BL.SOUTH, 'South' ) button(constraints: BL.EAST, 'East' ) button(constraints: BL.WEST, 'West' ) } } frame.pack() frame.visible = true ================================================ FILE: listings/chap11/Listing_11_13_Table_Demo.groovy ================================================ import groovy.swing.SwingBuilder import groovy.transform.Canonical import javax.swing.JLabel import javax.swing.JTable import javax.swing.table.TableCellRenderer import java.awt.Color import java.awt.Component import static java.awt.Color.* @Canonical class NamedColor { String name Color foreground, background } purple = new NamedColor('Purple', WHITE, new Color(127, 0, 255)) mediumBlue = new NamedColor('Blue', WHITE, new Color(64, 128, 255)) brightYellow = new NamedColor('Yellow', BLACK, YELLOW) brightRed = new NamedColor('Red', BLACK, RED) data = [ [name: 'Anthony', color: mediumBlue], [name: 'Greg', color: brightYellow], [name: 'Jeff', color: purple], [name: 'Murray', color: brightRed] ] swing = new SwingBuilder() frame = swing.frame(title: 'Table Demo') { scrollPane { table(id: 'table') { tableModel(list: data) { propertyColumn(header: 'Name', propertyName: 'name') propertyColumn( header: 'Color', propertyName: 'color', type: NamedColor //#1 ) //closureColumn(header: 'Color', read: {it.color.name}) } } } } frame.pack() swing.table.setDefaultRenderer(NamedColor, new ColorRenderer()) //#2 frame.visible = true class ColorRenderer extends JLabel implements TableCellRenderer { //#3 ColorRenderer() { opaque = true } Component getTableCellRendererComponent(JTable table, color, boolean selected, boolean focus, int row, int col) { background = color.background foreground = color.foreground text = color.name horizontalAlignment = CENTER this } } //#1 Model can have rich types //#2 Registering a renderer for a rich type //#3 Implementing a renderer ================================================ FILE: listings/chap11/Listing_11_14_Binding.groovy ================================================ import groovy.beans.* import groovy.swing.SwingBuilder import java.awt.event.ActionEvent import java.awt.event.ActionListener import java.beans.PropertyVetoException class Person implements ActionListener { @Bindable String name @Vetoable int age void actionPerformed(ActionEvent e) { if (e.actionCommand == name) setAge(age + 1) } } class BirthdayNotifier { @ListenerList List listeners def triggerBirthday(name) { def event = new ActionEvent(this, 0, name) fireActionPerformed(event) } } data = [ new Person(name: 'Anthony', age: 51), new Person(name: 'Greg', age: 42), new Person(name: 'Jeff', age: 60), new Person(name: 'Murray', age: 54) ] swing = new SwingBuilder() frame = swing.frame(title: 'Binding Demo') { table { tableModel(list: data, id: 'tableModel') { propertyColumn(header: 'Name', propertyName: 'name', editable: true) propertyColumn(header: 'Age', propertyName: 'age', type: Integer, editable: true) } } } frame.pack() frame.visible = true notifier = new BirthdayNotifier() data.each { it.addPropertyChangeListener { evt -> println "$evt.newValue has replaced $evt.oldValue" //#1 } it.addVetoableChangeListener { evt -> if (evt.newValue < 0) //#2 throw new PropertyVetoException("Can't have -ve age", evt) //#2 else //#2 println "$evt.source.name now has age $evt.newValue" //#2 } notifier.addActionListener(it) //#3 } try { data[0].age = -99 //#4 } catch (e) { println "Change ignored: $e.message" } data[1].name = 'Sam' //#5 data[1].age = 36 //#5 notifier.triggerBirthday(data[2].name) //#6 swing.tableModel.fireTableDataChanged() //#1 Log when the name changes //#2 Log when the age change but veto -ve ages //#3 Listen for birthday notifications //#4 Attempt to trigger invalid age //#5 Sam replaces Greg //#6 Jeff has a birthday ================================================ FILE: listings/chap11/Listing_11_15_Plotter.groovy ================================================ import groovy.swing.SwingBuilder import java.awt.Color import java.awt.BorderLayout as BL //#|1 import javax.swing.WindowConstants as WC //#|1 import javax.swing.BorderFactory as BF //#|1 import javax.swing.JOptionPane swing = new SwingBuilder() paint = swing.action( name: 'Paint', closure: this.&paintGraph, //#2 mnemonic: 'P', accelerator: 'ctrl P' ) about = swing.action( name: 'About', closure: this.&showAbout, mnemonic: 'A', accelerator: 'F1' ) frame = swing.frame(title:'Plotter', location:[100,100], size:[500,500], //#3 defaultCloseOperation:WC.EXIT_ON_CLOSE) { menuBar (){ menu(mnemonic:'A','Action'){ menuItem(action:paint) } glue() //#4 menu(mnemonic:'H','Help'){ menuItem(action:about) } } panel (border:BF.createEmptyBorder(6,6,6,6)) { borderLayout() vbox (constraints: BL.NORTH){ hbox { hstrut(width:10) label 'f(x) = ' textField(id:'function',action:paint,'Math.sin(x)') button(action:paint) } } vbox (constraints: BL.WEST){ labeledSpinner('max',1d) //#5 20.times { swing.vglue()} labeledSpinner('min',-1d) } vbox(constraints: BL.CENTER, border:BF.createTitledBorder('Function Plot')) { panel(id:'canvas') } hbox (constraints: BL.SOUTH){ hstrut(width:10) labeledSpinner('from',0d) 10.times { swing.hglue()} //#6 labeledSpinner('to',6.3d) } } } frame.visible = true // implementation methods def labeledSpinner(label, value){ //#7 swing.label(label) swing.hstrut() swing.spinner(id:label, stateChanged:this.&paintGraph, model:swing.spinnerNumberModel(value:value) ) } def paintGraph(event) { //#8 calc = new Dynamo(swing.function.text) gfx = swing.canvas.graphics int width = swing.canvas.size.width int height = swing.canvas.size.height gfx.color = new Color(255, 255, 150) gfx.fillRect(0, 0, width, height) gfx.color = Color.blue xFactor = (swing.to.value - swing.from.value) / width yFactor = height / (swing.max.value - swing.min.value) int ceiling = height + swing.min.value * yFactor int lastY = calc.f(swing.from.value) * yFactor for (x in (1..width)) { //#9 int y = calc.f(swing.from.value + x * xFactor) * yFactor gfx.drawLine(x-1, ceiling-lastY, x, ceiling-y) lastY = y } } void showAbout(event) { //#10 JOptionPane.showMessageDialog(frame, '''A Function Plotter that serves as a SwingBuilder example for Groovy in Action''') } // Keep all dynamic invocation handling in one place. class Dynamo { static final GroovyShell SHELL = new GroovyShell() Script functionScript Dynamo(String function){ functionScript = SHELL.parse(function) //#11 } Object f(x) { functionScript.x = x return functionScript.run() //#12 } } //#1 type aliases as shortcuts //#2 refer to method closure //#3 general constructor //#4 separate help menu //#5 use factory method //#6 build with logic //#7 factory method //#8 method used as closure //#9 main plotting loop //#10 show message dialog //#11 once per paint //#12 for each x ================================================ FILE: listings/chap11/Listing_11_16_Groovyfx.groovy ================================================ @Grab('org.codehaus.groovyfx:groovyfx:0.3.1') import static groovyx.javafx.GroovyFX.start start { stage title: 'GroovyFX Hello World', visible: true, { scene fill: BLACK, width: 600, height: 300, { hbox padding: 40, alignment:'center', { text 'Hello', font: '80pt sanserif', { fill linearGradient(endX: 0, stops: [PALEGREEN, SEAGREEN]) } text ' FX ', font: '80pt sanserif', { fill linearGradient(endX: 0, stops: [CYAN, DODGERBLUE]) effect dropShadow(color: DODGERBLUE, radius: 25, spread: 0.35) } imageView 'file:World.png', effect:reflection() } } } } ================================================ FILE: listings/chap11/Listing_11_17_CalorieCounterBuilderSupport.groovy ================================================ class CalorieBuilder1 extends BuilderSupport { def calories = 0.0 def name = 'root' def calorieDatabase = [ crust : [thin: 169, classic: 212, deepdish: 259, stuffed: 360], topping : [pepperoni: 24, veggies: 10, cheese: 50], appetizer: [wings: 60, 'garlic-bread': 180] ] def createNode(name) { [name: name, calories: 0.0] } def createNode(name, value) { def result = createNode(name) + [value: value] findCalories(result, name, value) //#1 result } def createNode(name, Map attributes) { createNode(name) + [*: attributes] } def createNode(name, Map attributes, value) { createNode(name, value) + [*: attributes] } void setParent(parent, child) { if (child.size && parent.size && child.size != parent.size) //#2 throw new IllegalStateException("Conflicting sizes found") if (child.size) { child.scale = (child.size == 'large') ? 1.5 : 1.0 } } void nodeCompleted(parentOrNull, node) { def parent = parentOrNull ?: this def qty = node.quantity ?: 1 def scale = node.scale ?: 1.0 findCalories(node, parent.name, node.name) //#3 parent.calories += node.calories * qty * scale } private void findCalories(Map map, name, value) { if (calorieDatabase.containsKey(name)) { map.calories = calorieDatabase[name][value].toInteger() } } } def lunch = new CalorieBuilder1() lunch.count { pizza(size: 'large') { crust('thin') topping('pepperoni') topping('veggies') } appetizer { wings(quantity: 2) 'garlic-bread'() } } assert lunch.calories == 604.5 //#1 Handle cases like crust('thin') //#2 Check consistency between child and parent //#3 Handle cases like appetizer { wings() } ================================================ FILE: listings/chap11/Listing_11_18_CalorieCounterFactoryBuilderSupport.groovy ================================================ class CalorieBuilder2 extends FactoryBuilderSupport { def calories = 0.0 def factory = new CalorieBeanFactory(getClass().classLoader) protected void postInstantiate(name, Map attrs, node) { super.postInstantiate(name, attrs, node) attrs.each { k, v -> node[k] = v } } protected Factory resolveFactory(name, Map attrs, value) { return factory } void setParent(parent, child) { if (child.hasProperty("size")) { child.scale = child.size == 'large' ? 1.5 : 1.0 } } void nodeCompleted(parentOrNull, node) { def parent = parentOrNull ?: this def qty = node.quantity ?: 1 def scale = node.scale ?: 1.0 parent.calories += node.calories * qty * scale } } class CalorieBeanFactory extends AbstractFactory { private ClassLoader loader CalorieBeanFactory(ClassLoader loader) { this.loader = loader } def newInstance(FactoryBuilderSupport fbs, name, value, Map attrs) { def className = name[0].toUpperCase() + name[1..-1].replaceAll(/-(.)/) { it[1].toUpperCase() } def clazz = loader.loadClass(className) return value ? clazz.newInstance(value: value) : clazz.newInstance() } } class Countable { int quantity def scale def calories = 0.0 } class Count extends Countable {} class Pizza extends Countable { def size } abstract class CountableGroup extends Countable { String value abstract getCalorieDB() def getCalories() { calorieDB[value] } } class Crust extends CountableGroup { def calorieDB = [thin: 169, classic: 212, deepdish: 259, stuffed: 360] } class Topping extends CountableGroup { def calorieDB = [pepperoni: 24, veggies: 10, cheese: 50] } class Appetizer extends Countable {} class Wings extends Countable { def calories = 60 } class GarlicBread extends Countable { def calories = 180 } def lunch = new CalorieBuilder2() lunch.count { pizza(size: 'large') { crust('thin') topping('pepperoni') topping('veggies') } appetizer { wings(quantity: 2) 'garlic-bread'() } } assert lunch.calories == 604.5 ================================================ FILE: listings/chap11/Listing_11_19_CalorieCounterByHand.groovy ================================================ class CalorieBuilder3 { def calorieDatabase = [ crust : [thin: 169, classic: 212, deepdish: 259, stuffed: 360], topping : [pepperoni: 24, veggies: 10, cheese: 50], appetizer: [wings: 60, 'garlic-bread': 180] ] def parent = new Stack() def getCalories() { parent.peek().calories } CalorieBuilder3() { parent.push([calories:0.0]) } def invokeMethod(String methodName, args) { def current = [name: methodName, calories:0.0] if (args && args[0] instanceof Map) { current << args[0] } countCalories(current, parent.peek().name, methodName) if (args && args[0] instanceof String) { countCalories(current, methodName, args[0]) } if (args && args.size() > 1 && args[1] instanceof String) { countCalories(current, methodName, args[1]) } current.scale = current.size == 'large' ? 1.5 : 1.0 if (args && args[-1] instanceof Closure) { parent.push(current) Closure nested = args[-1] nested.delegate = this nested.call() parent.pop() } def qty = current.quantity ?: 1 def scale = current.scale ?: 1.0 parent.peek().calories += current.calories * qty * scale } private void countCalories(Map current, String key, String value) { if (calorieDatabase.containsKey(key)) { current.calories = calorieDatabase[key][value].toInteger() } } } def lunch = new CalorieBuilder3() lunch.count { pizza(size: 'large') { crust('thin') topping('pepperoni') topping('veggies') } appetizer { wings(quantity: 2) 'garlic-bread'() } } assert lunch.calories == 604.5 ================================================ FILE: listings/chap11/markup.html ================================================ Constructed by MarkupBuilder

What can I do with MarkupBuilder?

Some text Child textmore text



================================================ FILE: listings/chap11/snippet1103_MarkupBuilderOutput.html ================================================ Constructed by MarkupBuilder

What can I do with MarkupBuilder?




================================================ FILE: listings/chap11/snippet1103_MarkupWithHyphen.groovy ================================================ def writer = new StringWriter() def builder = new groovy.xml.MarkupBuilder(writer) def web = builder.'web-app' { builder.'display-name'('Groovy WebApp') } def result = writer.toString().replaceAll("\r","") assert "\n"+result == """ Groovy WebApp """ ================================================ FILE: listings/chap11/snippet1106_AntBuilderIf.groovy ================================================ ant = new AntBuilder() if ( ! System.properties.'java.version'.contains('1.7')) { ant.fail 'This build script requires JDK 1.7.x but was ' + System.properties.'java.version' } // further action ================================================ FILE: listings/chap11/snippet1106_AntIf.xml ================================================ This build script requires JDK 1.4.x. ================================================ FILE: listings/chap11/snippet1107_Printer.groovy ================================================ import groovy.swing.SwingBuilder swing = new SwingBuilder() button = swing.button('Print') frame = swing.frame(title:'Printer') { panel { textField(columns:10) widget(button) } } button.actionPerformed = { println frame.title } frame.pack() frame.visible = true ================================================ FILE: listings/chap11/snippet1107_binding.txt ================================================ import java.beans.* class Person { private String name private int age final private PropertyChangeSupport this$propChangeSupport = new PropertyChangeSupport(this) final private VetoableChangeSupport this$vetoChangeSupport = new VetoableChangeSupport(this) void addPropertyChangeListener(PropertyChangeListener listener) { this$propChangeSupport.addPropertyChangeListener(listener) } void addPropertyChangeListener(String name, PropertyChangeListener listener) { this$propChangeSupport.addPropertyChangeListener(name, listener) } void removePropertyChangeListener(PropertyChangeListener listener) { this$propChangeSupport.removePropertyChangeListener(listener) } void removePropertyChangeListener(String name, PropertyChangeListener listener) { this$propChangeSupport.removePropertyChangeListener(name, listener) } void firePropertyChange(String name, oldValue, newValue) { this$propChangeSupport.firePropertyChange(name, oldValue, newValue) } PropertyChangeListener[] getPropertyChangeListeners() { return this$propChangeSupport.getPropertyChangeListeners() } PropertyChangeListener[] getPropertyChangeListeners(String name) { return this$propChangeSupport.getPropertyChangeListeners(name) } void setName(String value) { this.firePropertyChange('name', name, name = value ) } void addVetoableChangeListener(VetoableChangeListener listener) { this$vetoChangeSupport.addVetoableChangeListener(listener) } void addVetoableChangeListener(String name, VetoableChangeListener listener) { this$vetoChangeSupport.addVetoableChangeListener(name, listener) } void removeVetoableChangeListener(VetoableChangeListener listener) { this$vetoChangeSupport.removeVetoableChangeListener(listener) } void removeVetoableChangeListener(String name, VetoableChangeListener listener) { this$vetoChangeSupport.removeVetoableChangeListener(name, listener) } void fireVetoableChange(String name, oldValue, newValue) { this$vetoChangeSupport.fireVetoableChange(name, oldValue, newValue) } VetoableChangeListener[] getVetoableChangeListeners() { return this$vetoChangeSupport.getVetoableChangeListeners() } VetoableChangeListener[] getVetoableChangeListeners(String name) { return this$vetoChangeSupport.getVetoableChangeListeners(name) } void setAge(int value) throws PropertyVetoException { this.fireVetoableChange('age', age, value) age = value } String getName() { name } int getAge() { age } } ================================================ FILE: listings/chap12/Listing_12_01_info_jdk6_only.groovy ================================================ def newline = "\n" assert newline.toString() == "\n" assert newline.dump() == '''''' ================================================ FILE: listings/chap12/Listing_12_01_info_jdk7_only.groovy ================================================ def newline = "\n" assert newline.toString() == "\n" assert newline.dump() == '''''' assert newline.inspect() == /'\n'/ ================================================ FILE: listings/chap12/Listing_12_01_info_jdk8_plus.groovy ================================================ def newline = "\n" assert newline.toString() == "\n" assert newline.dump() == '''''' assert newline.inspect() == /'\n'/ ================================================ FILE: listings/chap12/Listing_12_02_properties.groovy ================================================ class MyClass { def first = 1 // read-write property def getSecond() { first * 2 } // read-only property public third = 3 // public field def myMethod() { } // public method } def obj = new MyClass() assert obj.hasProperty('first') //|#1 assert obj.respondsTo('myMethod') //|#2 def keys = ['first', 'second', 'class'] assert obj.properties.keySet() == new HashSet(keys) assert 1 == obj.properties['first'] //|#3 assert 1 == obj.properties.first //|#3 assert 1 == obj.first //|#4 assert 1 == obj['first'] // getAt('first') //|#4 def one = 'first' def two = 'second' obj[one] = obj[two] // putAt(one) //#5 assert obj.dump() =~ 'first=2' //#6 //#1 Property check //#2 Method check //#3 Properties map //#4 Direct access //#5 Dynamic assignment //#6 Field introspection ================================================ FILE: listings/chap12/Listing_12_03_File_Iteration.groovy ================================================ file = new File('Listing_12_03_File_Iteration.groovy') file.each { println it } assert file.any { it =~ /File/ } assert 3 == file.findAll { it =~ /File/ }.size() assert 5 == file.grep { it }.size() ================================================ FILE: listings/chap12/Listing_12_04_Filesystem.groovy ================================================ import static groovy.io.FileType.DIRECTORIES import static groovy.io.FileType.FILES def topDir = new File('../chap09') def srcDir = new File(topDir, 'src') dirs = [] srcDir.eachDir { dirs << it.name } //#A assert ['main', 'test'] == dirs dirs = [] topDir.eachDirRecurse { dirs << it.name } //#B assert dirs.containsAll(['gradle', 'src', 'main']) assert dirs.containsAll(['groovy', 'services', 'wrapper']) dirs = [] topDir.eachDirMatch(~/[^l]*/) { dirs << it.name } //#C assert dirs == ['src'] files = [] topDir.eachFile { files << it.name } //#D assert files.contains('Listing_09_01_ToStringDetective.groovy') assert files.contains('src') files = [] topDir.eachFile(FILES) { files << it.name } //#E assert files.contains('Listing_09_01_ToStringDetective.groovy') count = 0 srcDir.eachFileRecurse { if (it.directory) count++ } //#F assert 9 == count count = 0 srcDir.eachFileRecurse(DIRECTORIES) { count++ } //#G assert 9 == count files = [] topDir.eachFileMatch(~/Listing_09_01.*/) { files << it.name } //#H assert ['Listing_09_01_ToStringDetective.groovy'] == files //#A Closure recording directory names //#B Recursively record directory names //#C Record directory names matching a pattern (.gradle is excluded here) //#D Record filenames and directory names //#E Record filenames //#F Count directory names recursively //#G Count directory names recursively, alternative solution //#H Record filenames and directory names matching a pattern ================================================ FILE: listings/chap12/Listing_12_05_Traversal.groovy ================================================ import static groovy.io.FileType.ANY import static groovy.io.FileVisitResult.SKIP_SUBTREE def totalSize = 0 def count = 0 def sortByTypeThenName = { a, b -> a.isFile() != b.isFile() ? a.isFile() <=> b.isFile() : a.name <=> b.name } def log = [] inputDir = new File('../chap09/') inputDir.traverse( type : ANY, nameFilter : ~/.*groovy.*/, excludeNameFilter : ~/.*Test.*/, preDir : { if (it.name =~ '.?gradle|build') return SKIP_SUBTREE count = 0 totalSize = 0 }, postDir : { if (count) { log << "Found $count files in $it.name : $totalSize bytes" count = 0 totalSize = 0 } }, postRoot : true, sort : sortByTypeThenName ) {it -> totalSize += it.size(); count++ } println log.join('\n') assert log.size() == 3 assert log*.replaceAll(/\d+/, '*').join('\n') == ''' Found * files in regina : * bytes Found * files in services : * bytes Found * files in chap* : * bytes '''.trim() ================================================ FILE: listings/chap12/Listing_12_06_File_Read.groovy ================================================ example = new File('data/example.txt') lines = ['line one', 'line two', 'line three'] assert lines == example.readLines() example.eachLine { assert it.startsWith('line') } hex = [] example.eachByte { hex << it } assert hex.size() == example.length() example.splitEachLine(/\s/) { assert 'line' == it[0] } example.withReader { reader -> assert 'line one' == reader.readLine() } ================================================ FILE: listings/chap12/Listing_12_07_File_Write.groovy ================================================ def outFile = new File('data/example.txt') def lines = ['line one','line two','line three'] outFile.write(lines[0..1].join("\n")) //#A outFile.append("\n"+lines[2]) //#A assert lines == outFile.readLines() outFile.withWriter { writer -> //#B writer.writeLine(lines[0]) //#B } //#B outFile.withWriterAppend('ISO8859-1') { writer -> //#B writer << lines[1] << "\n" //#B } outFile << lines[2] //#C //#A Writing/appending with simple method calls //#B Writing/appending with closures //#C Appending with the leftshift operator ================================================ FILE: listings/chap12/Listing_12_08_Writer_LeftShift.groovy ================================================ TimeZone.default = TimeZone.getTimeZone("CET") reader = new StringReader('abc') writer = new StringWriter() writer << "\nsome String" << "\n" writer << [a:1, b:2] << "\n" writer << [3,4] << "\n" writer << new Date(0) << "\n" writer << reader << "\n" assert writer.toString() == ''' some String [a:1, b:2] [3, 4] Thu Jan 01 01:00:00 CET 1970 abc ''' ================================================ FILE: listings/chap12/Listing_12_09_File_Transform_jdk7_plus.groovy ================================================ def n = System.lineSeparator() //#1 reader = new StringReader('abc') writer = new StringWriter() reader.transformChar(writer) { it.next() } //#A assert 'bcd' == writer.toString() reader = new File('data/example.txt').newReader() writer = new StringWriter() reader.transformLine(writer) { it - 'line' } //#B assert " one${n} two${n} three${n}" == writer.toString() input = new File('data/example.txt') writer = new StringWriter() input.filterLine(writer) { it =~ /one/ } //#C assert "line one${n}" == writer.toString() writer = new StringWriter() writer << input.filterLine { it.size() > 8 } //#2 assert "line three${n}" == writer.toString() //#1 System dependent line separator //#2 Read only long lines //#A Transform ‘abc’ to ‘bcd’ //#B Chop ‘line’ from each line of the example file //#C Read only lines containing “one” ================================================ FILE: listings/chap12/Listing_12_10_File_ObjectStreams.groovy ================================================ file = new File('objects.dat') file.deleteOnExit() //#A objects = [1, "Hello Groovy!", new Date()] file.withObjectOutputStream { outstream -> objects.each { outstream << it //#B } } retrieved = [] file.withObjectInputStream { instream -> instream.eachObject { retrieved << it //#C } } assert retrieved == objects //#A Clean up after ourselves //#B Serialize each object in the list in turn //#C Deserialize each object in turn ================================================ FILE: listings/chap12/Listing_12_11_Temp_Dir.groovy ================================================ File tempDir = File.createTempDir() //#A assert tempDir.directorySize() == 0 //#B File source = new File(tempDir, 'input.dat') //#C source.bytes = "hello world".bytes assert tempDir.directorySize() == 11 //#D File destination = new File(tempDir, 'output.dat') destination.withDataOutputStream { os-> //#E source.withDataInputStream { is-> os << is } } assert tempDir.directorySize() == 22 tempDir.deleteDir() //#F //#A Create a temporary directory //#B Check that the directory is empty //#C Create a file and set the file contents //#D Check that the directory size increased //#E Copy the file and check that the directory size doubled //#F Delete the directory ================================================ FILE: listings/chap12/Listing_12_12_Threads.groovy ================================================ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; Thread.metaClass.'static'.getName = { Thread.currentThread().name } //#A BlockingQueue sharedQueue = [] as LinkedBlockingQueue //#B Thread.start('push') { //#C 10.times { try { println("${Thread.name}\t: ${it}") sharedQueue << it sleep 100 } catch (InterruptedException ignore) {} } } Thread.start('pop') { //#D for (i in 0..9) { sleep 200 println("${Thread.name}\t: ${sharedQueue.take()}") } } //#A Create a new method to get the thread name //#B Create a shared queue //#C Start a thread producing 10 items //#D Start a thread consuming 10 items ================================================ FILE: listings/chap12/Listing_12_13_Processes_UnixCommands.groovy ================================================ // works for unix-based systems def listFiles = 'ls'.execute() def ignoreCase = "tr '[A-Z]' '[a-z]'".execute() def reverseSort = 'sort -r'.execute() listFiles | ignoreCase | reverseSort reverseSort.waitForOrKill(1000) if (reverseSort.exitValue()) { print reverseSort.err.text } else { print reverseSort.text } ================================================ FILE: listings/chap12/Listing_12_14_Processes_ZipUnzip.groovy ================================================ // works for systems with gzip and gunzip on the path def outputBuffer = new StringBuffer() def errorBuffer = new StringBuffer() zipProcess = 'gzip -c'.execute() unzipProcess = 'gunzip -c'.execute() unzipProcess.consumeProcessOutput(outputBuffer, errorBuffer) zipProcess.consumeProcessErrorStream(errorBuffer) zipProcess | unzipProcess zipProcess.withWriter { writer -> writer << 'Hello World' } unzipProcess.waitForOrKill(1000) println 'Output: ' + outputBuffer println 'Error : ' + errorBuffer ================================================ FILE: listings/chap12/Listing_12_15_SimpleTemplateEngine.groovy ================================================ mailReminder = //#A ''' Dear ${salutation?salutation+' ':''}$lastname, another month has passed and it's time for these <%=tasks.size()%> tasks: <% tasks.each { %>- $it <% } %> your collaboration is very much appreciated ''' def engine = new groovy.text.SimpleTemplateEngine() def template = engine.createTemplate(mailReminder) def binding = [ salutation: 'Mrs.', //|#B lastname : 'Davis', //|#B tasks : ['visit the Groovy in Action (GinA) page', //|#B 'chat with GinA readers'] //|#B ] assert template.make(binding).toString() == //#C ''' Dear Mrs. Davis, another month has passed and it's time for these 2 tasks: - visit the Groovy in Action (GinA) page - chat with GinA readers your collaboration is very much appreciated ''' //#A Text of template containing placeholders //#B Variables to substitute in the template //#C Evaluate the template against the binding ================================================ FILE: listings/chap12/Listing_12_16_GroovletExample.groovy ================================================ @Grab('org.eclipse.jetty.aggregate:jetty-server:8.1.16.v20140903') @Grab('org.eclipse.jetty.aggregate:jetty-servlet:8.1.16.v20140903') @Grab('javax.servlet:javax.servlet-api:3.0.1') import org.eclipse.jetty.server.Server import org.eclipse.jetty.servlet.* import groovy.servlet.* import static org.eclipse.jetty.servlet.ServletContextHandler.* def server = new Server(1234) def context = new ServletContextHandler(server, "/", SESSIONS) context.resourceBase = "." context.addServlet(GroovyServlet, "*.groovy") server.start() ================================================ FILE: listings/chap12/Listing_12_17_HelloWorldGroovlet.groovy ================================================ html.html{ head { title 'Groovlet Demonstrator' } body { h1 'Welcome to the World of Groovlets' } } ================================================ FILE: listings/chap12/Listing_12_19_InspectGroovlet.groovy ================================================ html.html{ head { title 'Groovlet Demonstrator' } body { h1 'Variables in the Binding:' table(summary:'binding') { tbody { binding.variables.each { key, value -> tr { td key.toString() td(value ? value.toString() : 'null') } } } } } } ================================================ FILE: listings/chap12/Listing_12_20_HiLowGame.groovy ================================================ def session = request.session def guess = params.guess guess = guess ? guess.toInteger() : null if (params.restart) guess = null if (!session.goal || params.restart) { //#A session.goal = (Math.random()*100).toInteger() //#A } //#A def goal = session.goal html.html{ head { title 'Think of a Number' } //#B body { h1 'Think of a Number' if (goal && guess) { div "Your guess $guess is " //#C switch (guess) { case goal : div 'correct!'; break //#D case {it < goal} : div 'too low' ; break //#D case {it > goal} : div 'too high'; break //#D } } p "What's your guess (0..100)?" form(action:'Listing_12_20_HiLowGame.groovy'){ //#E input(type:'text', name:'guess', '') button(type:'submit', 'Guess') button(type:'submit', name:'restart', value:'true', 'New Game') } } } //#A Generate a number to guess, if necessary //#B Start a builder to generate the HTML //#C Use a GString as a simple template for text //#D Classify the guess appropriately //#E Display a form posting to the same page again ================================================ FILE: listings/chap12/Listing_12_21_NumberTemplate.txt ================================================ see: Number.template.html ================================================ FILE: listings/chap12/Listing_12_22_TemplateGroovlet.groovy ================================================ def session = request.session def guess = params.guess guess = guess ? guess.toInteger() : null if (params.restart) guess = null if (!session.goal || params.restart) { session.goal = (Math.random()*100).toInteger() } def engine = new groovy.text.SimpleTemplateEngine() //#1 def source = getClass().classLoader. //#1 getResource('Number.template.html') //#1 def template = engine.createTemplate(source) //#1 out << template.make(guess: guess, goal: session.goal) //#1 //#1 Template rendering code ================================================ FILE: listings/chap12/Number.template.html ================================================ Think of a Number

Think of a Number

<% if (guess) { %> Your guess $guess is <% switch (guess) { case goal : out << 'correct!'; break case {it < goal} : out << 'too low' ; break case {it > goal} : out << 'too high'; break } } %>

What"s your guess (0..100)?

================================================ FILE: listings/chap12/data/example.txt ================================================ line one line two line three ================================================ FILE: listings/chap12/snippet1201_SlowTyping.groovy ================================================ text = """ This text appears slowly on the screen as if someone was typing it. """ for (c in text) { sleep 100 print c } ================================================ FILE: listings/chap12/snippet1201_UseCategory.groovy ================================================ class StringCasingCategory { static String lower(String string) { return string.toLowerCase() } } use(StringCasingCategory) { assert "groovy" == "GroOvy".lower() } ================================================ FILE: listings/chap12/snippet1202_base64.groovy ================================================ byte[] data = new byte[256] for (i in 0..255) { data[i] = i } store = data.encodeBase64().toString() assert store.startsWith('AAECAwQFBg') assert store.endsWith ('r7/P3+/w==') restored = store.decodeBase64() assert data.toList() == restored.toList() ================================================ FILE: listings/chap12/web.xml ================================================ Groovlet groovy.servlet.GroovyServlet Template groovy.servlet.TemplateServlet Groovlet *.groovy Template *.html Template *.gsp ================================================ FILE: listings/chap13/Listing_13_01_Connecting.groovy ================================================ @Grab('org.hsqldb:hsqldb:2.3.2') @GrabConfig(systemClassLoader=true) ////////////////////////////////// import groovy.sql.Sql def url = 'jdbc:hsqldb:mem:GinA' def user = 'sa' def password = '' def driver = 'org.hsqldb.jdbcDriver' def sql = Sql.newInstance(url, user, password, driver) // use 'sql' instance ... // optional test of a system table within HSQLDB assert sql.firstRow('SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS')[0] == 1 sql.close() ================================================ FILE: listings/chap13/Listing_13_02_ConnectingDataSource.groovy ================================================ @Grab('org.hsqldb:hsqldb:2.3.2') @GrabConfig(systemClassLoader=true) ////////////////////////////////// import groovy.sql.Sql import org.hsqldb.jdbc.JDBCDataSource def dataSource = new JDBCDataSource( database: 'jdbc:hsqldb:mem:marathon', user: 'sa', password: '') def sql = new Sql(dataSource) // use 'sql' instance ... // optional test of a system table within HSQLDB assert sql.firstRow('SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS')[0] == 1 sql.close() ================================================ FILE: listings/chap13/Listing_13_03_Creating.groovy ================================================ @Grab('org.hsqldb:hsqldb:2.3.2') @GrabConfig(systemClassLoader=true) ////////////////////////////////// import groovy.sql.Sql def url = 'jdbc:hsqldb:mem:GinA' def user = 'sa' def password = '' def driver = 'org.hsqldb.jdbcDriver' def sql = Sql.newInstance(url, user, password, driver) sql.execute ''' CREATE TABLE Athlete ( athleteId INTEGER GENERATED BY DEFAULT AS IDENTITY, --#A firstname VARCHAR(64), lastname VARCHAR(64), dateOfBirth DATE ); ''' sql.close() //#A Column value will be automatically generated ================================================ FILE: listings/chap13/Listing_13_04_DbUtilClass.txt ================================================ see: util/DbUtil.groovy ================================================ FILE: listings/chap13/Listing_13_05_Inserting.groovy ================================================ import util.DbUtil def sql = DbUtil.create() sql.execute ''' INSERT INTO Athlete (firstname, lastname, dateOfBirth) VALUES ('Paul', 'Tergat', '1969-06-17') ''' //#A def data = [first: 'Khalid', last: 'Khannouchi', birth: '1971-12-22'] def keys = sql.executeInsert """ INSERT INTO Athlete (firstname, lastname, dateOfBirth) VALUES (${data.first}, ${data.last}, ${data.birth}) """ //#B assert keys[0] == [1] //#1 def insertSql = ''' INSERT INTO Athlete (firstname, lastname, dateOfBirth) VALUES (?,?,?) ''' def params = ['Ronaldo', 'da Costa', '1970-06-07'] def keyColumnNames = ['ATHLETEID'] keys = sql.executeInsert insertSql, params, keyColumnNames //#C assert keys[0] == [ATHLETEID: 2] //#2 sql.close() //#A Insert using plain statement //#B GString variant //#C List of params variant //#1 Checking generated keys for second row //#2 Checking generated athleteId key for third row ================================================ FILE: listings/chap13/Listing_13_06_Reading.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) def expected = ['Paul Tergat', 'Khalid Khannouchi', 'Ronaldo da Costa'] def rowNum = 0 sql.query('SELECT firstname, lastname FROM Athlete') { resultSet -> //#1 while (resultSet.next()) { //#2 def first = resultSet.getString(1) //#3 def last = resultSet.getString('lastname') //#3 assert expected[rowNum++] == "$first $last" } } rowNum = 0 sql.eachRow('SELECT firstname, lastname FROM Athlete') { row -> //#4 def first = row[0] //#5 def last = row.lastname //#5 assert expected[rowNum++] == "$first $last" } def first = sql.firstRow('SELECT lastname, dateOfBirth FROM Athlete') //#6 assert first.values().sort().join(',') == 'Tergat,1969-06-17' //#5 List athletes = sql.rows('SELECT firstname, lastname FROM Athlete') //#7 assert athletes.size() == 3 assert athletes.collect { "$it.FIRSTNAME ${it[-1]}" } == expected //#5 assert sql.firstRow('SELECT COUNT(*) AS num FROM Athlete').num == 3 //#8 //#1 Read using query //#2 External iteration on the ResultSet //#3 Access properties via JDBC API calls //#4 Read using rows //#5 Access properties via map or list styles //#6 Read using firstRow //#7 Read using rows //#8 More efficient size calculation ================================================ FILE: listings/chap13/Listing_13_07_Updating.groovy ================================================ import util.DbUtil def sql = DbUtil.create() sql.execute ''' INSERT INTO Athlete (lastname) VALUES ('da Costa') ''' sql.execute ''' UPDATE Athlete SET firstname='Ronaldo' where lastname='da Costa' ''' def updateCount = sql.executeUpdate ''' UPDATE Athlete SET dateOfBirth='1970-06-07' where lastname='da Costa' ''' assert updateCount == 1 //#A def row = sql.firstRow ''' SELECT * FROM Athlete where lastname = 'da Costa' ''' assert "${row.firstname} ${row.lastname} ${row.dateofbirth}" == 'Ronaldo da Costa 1970-06-07' sql.close() //#A Check one row was updated ================================================ FILE: listings/chap13/Listing_13_08_Delete.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) //#A assert sql.firstRow('SELECT COUNT(*) as num FROM Athlete').num == 3 //#B sql.execute "DELETE FROM Athlete WHERE lastname = 'Tergat'" assert sql.firstRow('SELECT COUNT(*) as num FROM Athlete').num == 2 //#C //#A Populate using our helper method //#B Check initially three rows //#C Two rows left after delete ================================================ FILE: listings/chap13/Listing_13_09_Transactions.groovy ================================================ import static util.DbUtil.* def sql = create() populate(sql) sql.withTransaction { insertAthlete(sql, 'Haile', 'Gebrselassie', '1973-04-18') insertAthlete(sql, 'Patrick', 'Makau', '1985-03-02') } assert sql.firstRow('SELECT COUNT(*) as num FROM Athlete').num == 5 // modify above to show transaction rollback /* try { sql.withTransaction { insertAthlete(sql, 'Haile', 'Gebrselassie', '1973-04-18') insertAthlete(sql, 'Patrick', 'Makau' * 100, '1985-03-02') } } catch(ignore) { println ignore.message } assert sql.firstRow('SELECT COUNT(*) as num FROM Athlete').num == 3 */ ================================================ FILE: listings/chap13/Listing_13_10_Batching.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) DbUtil.enableLogging() sql.withBatch { stmt -> stmt.addBatch ''' INSERT INTO Athlete (firstname, lastname, dateOfBirth) VALUES ('Paula', 'Radcliffe', '1973-12-17')''' stmt.addBatch """ INSERT INTO Record (time, venue, whenRun, fkAthlete) SELECT ${2*60*60+15*60+25}, 'London', '2003-04-13', athleteId FROM Athlete WHERE lastname='Radcliffe'""" } //22/04/2013 6:34:59 AM groovy.sql.BatchingStatementWrapper processResult //FINE: Successfully executed batch with 2 command(s) assert sql.firstRow('SELECT COUNT(*) as num FROM Athlete').num == 4 assert sql.firstRow('SELECT COUNT(*) as num FROM Record').num == 5 def qry = ''' INSERT INTO Athlete (firstname, lastname, dateOfBirth) VALUES (?,?,?) ''' sql.withBatch(3, qry) { ps -> ps.addBatch('Catherine', 'Ndereba', '1972-07-21') ps.addBatch('Naoko', 'Takahashi', '1972-05-06') ps.addBatch('Tegla', 'Loroupe', '1973-05-09') ps.addBatch('Ingrid', 'Kristiansen', '1956-03-21') } //Sep 24, 2014 10:32:03 PM groovy.sql.BatchingStatementWrapper processResult //FINE: Successfully executed batch with 3 command(s) //Sep 24, 2014 10:32:03 PM groovy.sql.BatchingStatementWrapper processResult //FINE: Successfully executed batch with 1 command(s) assert sql.firstRow('SELECT COUNT(*) as num FROM Athlete').num == 8 ================================================ FILE: listings/chap13/Listing_13_11_Paging.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) def qry = 'SELECT * FROM Athlete' assert sql.rows(qry, 1, 2)*.lastname == ['Tergat', 'Khannouchi'] assert sql.rows(qry, 3, 2)*.lastname == ['da Costa'] ================================================ FILE: listings/chap13/Listing_13_12_Metadata.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) def dump(sql, tablename) { println " CONTENT OF TABLE ${tablename} ".center(32, '-') sql.eachRow('SELECT * FROM ' + tablename) { rs -> def meta = rs.getMetaData() if (meta.columnCount <= 0) return for (i in 0.. def width = meta.columnCount * 12 println " CONTENT OF TABLE ${tablename} ".center(width, '-') (1..meta.columnCount).each { print meta.getColumnLabel(it).padRight(12) } println() println '-' * width } def printRow = { row -> row.toRowResult().values().each { print it.toString().padRight(12) } println() } sql.eachRow('SELECT * FROM ' + tablename, printColNames, printRow) } def oldOut = System.out def baos = new ByteArrayOutputStream() System.setOut(new PrintStream(baos)) dump2(sql, 'Athlete') assert baos.toString().readLines()*.trim().join('\n') == '''\ ----------- CONTENT OF TABLE Athlete ----------- ATHLETEID FIRSTNAME LASTNAME DATEOFBIRTH ------------------------------------------------ 0 Paul Tergat 1969-06-17 1 Khalid Khannouchi 1971-12-22 2 Ronaldo da Costa 1970-06-07\ ''' baos.reset() dump2(sql, 'Record') System.setOut(oldOut) assert baos.toString().readLines()*.trim().join('\n') == '''\ ----------------- CONTENT OF TABLE Record ------------------ RECORDID TIME VENUE WHENRUN FKATHLETE ------------------------------------------------------------ 0 7495 Berlin 2003-09-28 0 1 7538 London 2002-04-14 1 2 7542 Chicago 1999-10-24 1 3 7565 Berlin 1998-09-20 2\ ''' ================================================ FILE: listings/chap13/Listing_13_14_NamedOrdinal.groovy ================================================ import groovy.transform.Canonical import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) def insertPrefix = ''' INSERT INTO Athlete (firstname, lastname, dateOfBirth) VALUES ''' sql.execute insertPrefix + '(:first,:last,:dob)', first: 'Ingrid', last: 'Kristiansen', dob: '1956-03-21' def loroupe = [first: 'Tegla', last: 'Loroupe', dob: '1973-05-09'] sql.execute insertPrefix + '(:first,:last,:dob)', loroupe @Canonical class Athlete { String first, last, dob } def ndereba = new Athlete('Catherine', 'Ndereba', '1972-07-21') sql.execute insertPrefix + '(?.first,?.last,?.dob)', ndereba def takahashi = new Athlete('Naoko', 'Takahashi') def takahashiExtra = [dob: '1972-05-06'] def namedOrdinalSuffix = '(?1.first,?1.last,?2.dob)' sql.execute insertPrefix + namedOrdinalSuffix, takahashi, takahashiExtra assert sql.firstRow('SELECT COUNT(*) as num FROM Athlete').num == 7 ================================================ FILE: listings/chap13/Listing_13_15_StoredProcBasic.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) sql.execute ''' CREATE FUNCTION SELECT_ATHLETE_RECORD () RETURNS TABLE (lastname VARCHAR(64), venue VARCHAR(64), whenRun DATE) READS SQL DATA RETURN TABLE ( SELECT Athlete.lastname, Record.venue, Record.whenRun FROM Athlete, Record WHERE Athlete.athleteId = Record.fkAthlete ORDER BY whenRun ) ''' def result = [] sql.eachRow('CALL SELECT_ATHLETE_RECORD()') { result << "$it.lastname $it.venue $it.whenRun" } assert result == [ 'da Costa Berlin 1998-09-20', 'Khannouchi Chicago 1999-10-24', 'Khannouchi London 2002-04-14', 'Tergat Berlin 2003-09-28' ] ================================================ FILE: listings/chap13/Listing_13_16_StoredProcParam.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) sql.execute ''' CREATE FUNCTION FULL_NAME (p_lastname VARCHAR(64)) RETURNS VARCHAR(100) READS SQL DATA BEGIN ATOMIC DECLARE ans VARCHAR(100); SELECT CONCAT(firstname, ' ', lastname) INTO ans FROM Athlete WHERE lastname = p_lastname; RETURN ans; END ''' assert sql.firstRow("{? = call FULL_NAME(?)}", ['Tergat'])[0] == 'Paul Tergat' ================================================ FILE: listings/chap13/Listing_13_17_StoredProcInOut.groovy ================================================ import groovy.sql.Sql import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) sql.execute ''' CREATE PROCEDURE CONCAT_NAME (OUT fullname VARCHAR(100), IN first VARCHAR(50), IN last VARCHAR(50)) BEGIN ATOMIC SET fullname = CONCAT(first, ' ', last); END ''' sql.call("{call CONCAT_NAME(?, ?, ?)}", [Sql.VARCHAR, 'Paul', 'Tergat']) { fullname -> assert fullname == 'Paul Tergat' } ================================================ FILE: listings/chap13/Listing_13_18_DataSetBasics.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) def athletes = sql.dataSet('Athlete') def result = [] athletes.each { result << it.firstname } //#1 assert result == ['Paul', 'Khalid', 'Ronaldo'] //#A athletes.add( firstname: 'Paula', lastname: 'Radcliffe', dateOfBirth: '1973-12-17' ) result = athletes.rows().collect { it.firstname } //#2 assert result == ['Paul', 'Khalid', 'Ronaldo', 'Paula'] //#B //#A Initially we have our three sample athletes //#B Confirm we now have four athletes //#1 Treating a SQL table like a list of map-like rows //#2 Using rows followed by collect ================================================ FILE: listings/chap13/Listing_13_19_DataSetFiltering.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) DbUtil.enableLogging() def athletes = sql.dataSet('Athlete') athletes.add( firstname: 'Paula', lastname: 'Radcliffe', dateOfBirth: '1973-12-17' ) def query = athletes.findAll { it.firstname >= 'P' } query = query.findAll { it.dateOfBirth > '1970-01-01' } query = query.sort { it.dateOfBirth } query = query.reverse() assert query.sql == 'select * from Athlete where firstname >= ? and ' + 'dateOfBirth > ? order by dateOfBirth DESC' assert query.parameters == ['P', '1970-01-01'] assert query.rows()*.firstname == ['Paula', 'Ronaldo'] ================================================ FILE: listings/chap13/Listing_13_20_DataSetViews.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) sql.execute ''' DROP VIEW AthleteRecord IF EXISTS; CREATE VIEW AthleteRecord AS SELECT * FROM Athlete LEFT OUTER JOIN Record ON fkAthlete=athleteId; ''' def records = sql.dataSet('AthleteRecord').findAll { it.firstname == 'Khalid' } def result = records.rows().collect { "$it.lastname $it.venue" } assert ['Khannouchi London', 'Khannouchi Chicago'] == result ================================================ FILE: listings/chap13/Listing_13_21_DbHelper.txt ================================================ see: layering/DbHelper.groovy ================================================ FILE: listings/chap13/Listing_13_22_DataAccessObject.txt ================================================ see: layering/DataAccessObject.groovy ================================================ FILE: listings/chap13/Listing_13_23_AthleteDAO.txt ================================================ see: layering/AthleteDAO.groovy ================================================ FILE: listings/chap13/Listing_13_24_AthleteApplication.txt ================================================ see: layering/AthleteApplication.groovy ================================================ FILE: listings/chap13/Listing_13_25_AthleteAppMain.groovy ================================================ import layering.* def app = new AthleteApplication() app.init() app.mainLoop() ================================================ FILE: listings/chap13/Listing_13_26_AthleteAppTest.groovy ================================================ import layering.* def app = new AthleteApplication() app.init() // next line only for the benefit of alltests.groovy def oldOut = System.out ByteArrayOutputStream baos = captureSystemOut() overrideSystemIn() try { app.mainLoop() } finally { // next line only for the benefit of alltests.groovy System.setOut(oldOut) } verifyOutput(baos) def captureSystemOut() { //#A def baos = new ByteArrayOutputStream() System.out = new PrintStream(baos) baos } def overrideSystemIn() { //#B System.in = new ByteArrayInputStream('''\ create Paul Tergat 1969-06-17 create Khalid Khannouchi update 1 dateOfBirth 1971-12-22 sort firstname delete 1 exit '''.bytes) } def verifyOutput(output) { assert output.toString().readLines()*.trim().join('\n') == ''' commands: create list update delete sort exit 1 Athlete(s) in DB: id firstname lastname dateOfBirth 0: Paul Tergat 1969-06-17 commands: create list update delete sort exit 2 Athlete(s) in DB: id firstname lastname dateOfBirth 0: Paul Tergat 1969-06-17 1: Khalid Khannouchi null commands: create list update delete sort exit 1 row(s) updated 2 Athlete(s) in DB: id firstname lastname dateOfBirth 0: Paul Tergat 1969-06-17 1: Khalid Khannouchi 1971-12-22 commands: create list update delete sort exit 2 Athlete(s) in DB: id firstname lastname dateOfBirth 1: Khalid Khannouchi 1971-12-22 0: Paul Tergat 1969-06-17 commands: create list update delete sort exit 1 row(s) deleted 1 Athlete(s) in DB: id firstname lastname dateOfBirth 0: Paul Tergat 1969-06-17 commands: create list update delete sort exit''' } //#A Capture standard output stream for testing //#B Replace standard input stream with canned input ================================================ FILE: listings/chap13/Listing_13_27_MongoAthletes.groovy ================================================ @Grab('com.gmongo:gmongo:1.3') import com.gmongo.GMongo import com.mongodb.util.JSON import groovy.transform.Field @Field db = new GMongo().getDB('athletes') db.athletes.drop() db.athletes << [first: 'Paul', last: 'Tergat', dob: '1969-06-17', records: [ [time: 2 * 60 * 60 + 4 * 60 + 55, venue: 'Berlin', when: '2003-09-28'] ]] def insertAthlete(first, last, dob) { db.athletes << [first: first, last: last, dob: dob] } def insertRecord(h, m, s, venue, date, lastname) { db.athletes.update( [last: lastname], [$addToSet: [records: [time: h * 60 * 60 + m * 60 + s, venue: venue, when: date]]] ) } insertAthlete('Khalid', 'Khannouchi', '1971-12-22') insertAthlete('Ronaldo', 'da Costa', '1970-06-07') insertRecord(2, 5, 38, 'London', '2002-04-14', 'Khannouchi') insertRecord(2, 5, 42, 'Chicago', '1999-10-24', 'Khannouchi') insertRecord(2, 6, 05, 'Berlin', '1998-09-20', 'da Costa') def radcliffe = """{ first: 'Paula', last: 'Radcliffe', dob: '1973-12-17', records: [ {time: ${2 * 60 * 60 + 15 * 60 + 25}, venue: 'London', when: '2003-04-13'} ] }""" db.athletes << JSON.parse(radcliffe) assert db.athletes.count == 4 db.athletes.find().each { println "$it._id $it.last ${it.records.size()}" } //516b15fc2b10a15fa09331f2 Tergat 1 //516b15fc2b10a15fa09331f3 Khannouchi 2 //516b15fc2b10a15fa09331f4 da Costa 1 //516b15fc2b10a15fa09331f5 Radcliffe 1 def londonAthletes = db.athletes.find('records.venue': 'London')*.first assert londonAthletes == ['Khalid', 'Paula'] def youngAthletes = db.athletes.aggregate( [$project: [first: 1, dob: 1]], [$match: [dob: [$gte: '1970-01-01']]], [$sort: [dob: -1]] ) assert youngAthletes.results()*.first == ['Paula', 'Khalid', 'Ronaldo'] ================================================ FILE: listings/chap13/Listing_13_28_NeoAthletes.groovy ================================================ @Grab('org.neo4j:neo4j-kernel:2.1.6') @Grab('org.neo4j:neo4j-lucene-index:2.1.6;transitive=false') @Grab('org.apache.lucene:lucene-core:3.6.2') import org.neo4j.graphdb.* import org.neo4j.graphdb.traversal.* import static util.Neo4jUtil.* import static util.MarathonRelationships.* def db = create() def tx = null def athlete1, athlete2, athlete3, athlete4 def record1, record2a, record2b, record3, record4a, record4b try { tx = db.beginTx() athlete1 = db.createNode() //#A athlete1.first = 'Paul' //#A athlete1.last = 'Tergat' //#A athlete1.dob = '1969-06-17' //#A record1 = db.createNode() //#B record1.time = 2 * 60 * 60 + 4 * 60 + 55 //#B record1.venue = 'Berlin' //#B record1.when = '2003-09-28' //#B athlete1.set(record1) assert 'Paul Tergat won the Berlin marathon on 2003-09-28' == "$athlete1.first $athlete1.last won the " + "$record1.venue marathon on $record1.when" athlete2 = insertAthlete( //#C db, 'Khalid', 'Khannouchi', '1971-12-22') //#C record2a = insertRecord( //#C db, 2, 5, 38, 'London', '2002-04-14', athlete2) //#C record2b = insertRecord( //#C db, 2, 5, 42, 'Chicago', '1999-10-24', athlete2) //#C athlete3 = insertAthlete(db, 'Ronaldo', 'da Costa', '1970-06-07') record3 = insertRecord(db, 2, 6, 5, 'Berlin', '1998-09-20', athlete3) athlete4 = insertAthlete(db, 'Paula', 'Radcliffe', '1973-12-17') record4a = insertRecord( db, 2, 17, 18, 'Chicago', '2002-10-13', athlete4) record4b = insertRecord( db, 2, 15, 25, 'London', '2003-04-13', athlete4) def allAthletes = [athlete1, athlete2, athlete3, athlete4] //#D def londonRecords = allAthletes.findAll { athlete -> //#D athlete.getRelationships(set).any { //#D record -> record.getOtherNode(athlete).venue == 'London' //#D } //#D } //#D assert londonRecords*.last == ['Khannouchi', 'Radcliffe'] record2b.broke(record3) //#E record2a.broke(record2b) //#E record1.broke(record2a) //#E record4b.broke(record4a) //#E def result = [] //#F for (Path p in db.traversalDescription().breadthFirst(). //#F relationships(broke). //#F evaluator(Evaluators.fromDepth(1)). //#F uniqueness(Uniqueness.NONE). //#F traverse(record3)) { //#F def newRecord = p.endNode() //#F result << "$newRecord.venue $newRecord.when" //#F } //#F def expected = ['Chicago 1999-10-24', 'London 2002-04-14', 'Berlin 2003-09-28'] assert expected == result tx.success() } finally { tx?.close() // for the benefit of alltests, don't wait for shutdown hook db?.shutdown() } //#A Create athlete1 by hand //#B Create record1 by hand //#C Create using utility methods //#D Find athletes holding a record set in London //#E Additional graph edges of interest //#F Find world records superseding record3 ================================================ FILE: listings/chap13/Listing_13_29_NeoGremlin.groovy ================================================ @Grab('org.neo4j:neo4j-kernel:2.1.6') @Grab('org.neo4j:neo4j-management:2.1.6') @Grab('org.neo4j:neo4j-cypher:2.1.6;transitive=false') @Grab('org.neo4j:neo4j-cypher-commons:2.1.6;transitive=false') @Grab('org.neo4j:neo4j-cypher-compiler-1.9:2.0.4;transitive=false') @Grab('org.neo4j:neo4j-cypher-compiler-2.0:2.0.4;transitive=false') @Grab('org.neo4j:neo4j-cypher-compiler-2.1:2.1.6;transitive=false') @Grab('org.neo4j:neo4j-lucene-index:2.1.6;transitive=false') @Grab('org.apache.lucene:lucene-core:3.6.2') @Grab('com.tinkerpop.gremlin:gremlin-groovy:2.6.0;transitive=false') @Grab('com.tinkerpop.gremlin:gremlin-java:2.6.0;transitive=false') @Grab('com.tinkerpop.blueprints:\ blueprints-neo4j2-graph:2.6.0;transitive=false') @Grab('commons-configuration:commons-configuration:1.6') @Grab('com.tinkerpop.blueprints:blueprints-core:2.6.0;transitive=false') @Grab('com.tinkerpop:pipes:2.6.0;transitive=false') @Grab('org.parboiled:parboiled-scala_2.10:1.1.6;transitive=false') @Grab('org.parboiled:parboiled-core:1.1.6') @Grab('org.scala-lang:scala-library:2.10.4') @Grab('com.googlecode.concurrentlinkedhashmap:\ concurrentlinkedhashmap-lru:1.4.1') @GrabExclude('junit:junit') @GrabExclude('org.hamcrest:hamcrest-all') @GrabExclude('org.mockito:mockito-core') import com.tinkerpop.blueprints.Graph import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph import com.tinkerpop.gremlin.groovy.Gremlin import static util.Neo4jUtil.* def db = create() def tx = null def athlete1, athlete2, athlete3, athlete4 def record1, record2a, record2b, record3, record4a, record4b Gremlin.load() try { tx = db.beginTx() // create athlete1 .. athlete4 athlete1 = insertAthlete(db, 'Paul', 'Tergat', '1969-06-17') record1 = insertRecord( db, 2, 4, 55, 'Berlin', '2003-09-28', athlete1) athlete2 = insertAthlete(db, 'Khalid', 'Khannouchi', '1971-12-22') record2a = insertRecord( db, 2, 5, 38, 'London', '2002-04-14', athlete2) record2b = insertRecord( db, 2, 5, 42, 'Chicago', '1999-10-24', athlete2) athlete3 = insertAthlete(db, 'Ronaldo', 'da Costa', '1970-06-07') record3 = insertRecord( db, 2, 6, 5, 'Berlin', '1998-09-20', athlete3) athlete4 = insertAthlete(db, 'Paula', 'Radcliffe', '1973-12-17') record4a = insertRecord( db, 2, 17, 18, 'Chicago', '2002-10-13', athlete4) record4b = insertRecord( db, 2, 15, 25, 'London', '2003-04-13', athlete4) record2b.broke(record3) record2a.broke(record2b) record1.broke(record2a) record4b.broke(record4a) Graph g = new Neo4j2Graph(db) def pretty = { it.collect { "$it.venue $it.when" }.join(', ') } def results = [] g.V('venue', 'London').fill(results) println 'London world records: ' + pretty(results) results = [] g.V('venue', 'London').in('broke').fill(results) println 'World records after London: ' + pretty(results) results = [] def emitAll = { true } def forever = { true } def berlin98 = { it.venue == 'Berlin' && it.when.startsWith('1998') } g.V.filter(berlin98).in('broke'). loop(1, forever, emitAll).fill(results) println 'World records after Berlin 1998: ' + pretty(results) tx.success() } finally { tx?.close() } ================================================ FILE: listings/chap13/extra_NeoGremlinGraph.groovy ================================================ /* */ @Grab('org.neo4j:neo4j-kernel:2.1.4') @Grab('org.neo4j:neo4j-management:2.1.4') @Grab('org.neo4j:neo4j-cypher:2.1.4;transitive=false') @Grab('org.neo4j:neo4j-cypher-commons:2.1.4') @Grab('org.neo4j:neo4j-cypher-compiler-1.9:2.0.4') @Grab('org.neo4j:neo4j-cypher-compiler-2.0:2.0.4') @Grab('org.neo4j:neo4j-cypher-compiler-2.1:2.1.4') @Grab('org.neo4j:neo4j-lucene-index:2.1.4;transitive=false') @Grab('org.apache.lucene:lucene-core:3.6.2') @Grab('com.tinkerpop.gremlin:gremlin-groovy:2.6.0;transitive=false') @Grab('com.tinkerpop.gremlin:gremlin-java:2.6.0;transitive=false') @Grab('com.tinkerpop.blueprints:blueprints-neo4j2-graph:2.6.0;transitive=false') @Grab('commons-configuration:commons-configuration:1.6') @Grab('com.tinkerpop.blueprints:blueprints-core:2.6.0;transitive=false') @Grab('com.tinkerpop:pipes:2.6.0;transitive=false') //@Grab('codehaus-stax:stax:1.1.1') //@GrabResolver('https://repository.jboss.org/nexus/content/repositories/thirdparty-releases') //@GrabExclude('org.codehaus.groovy:groovy') @GrabExclude('junit:junit') @GrabExclude('org.hamcrest:hamcrest-all') @GrabExclude('org.mockito:mockito-core') /* */ import com.tinkerpop.blueprints.Graph import com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph import com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter import com.tinkerpop.gremlin.groovy.Gremlin import static util.Neo4jUtil.* println 'starting' def db = create() def tx = null def athlete1, athlete2, athlete3, athlete4 def record1, record2a, record2b, record3, record4a, record4b println 'about to load' Gremlin.load() println 'loaded' try { tx = db.beginTx() // create athlete1 .. athlete4 athlete1 = insertAthlete(db, 'Paul', 'Tergat', '1969-06-17') record1 = insertRecord( db, 2, 4, 55, 'Berlin', '2003-09-28', athlete1) athlete2 = insertAthlete(db, 'Khalid', 'Khannouchi', '1971-12-22') record2a = insertRecord( db, 2, 5, 38, 'London', '2002-04-14', athlete2) record2b = insertRecord( db, 2, 5, 42, 'Chicago', '1999-10-24', athlete2) athlete3 = insertAthlete(db, 'Ronaldo', 'da Costa', '1970-06-07') record3 = insertRecord( db, 2, 6, 5, 'Berlin', '1998-09-20', athlete3) athlete4 = insertAthlete(db, 'Paula', 'Radcliffe', '1973-12-17') record4a = insertRecord( db, 2, 17, 18, 'Chicago', '2002-10-13', athlete4) record4b = insertRecord( db, 2, 15, 25, 'London', '2003-04-13', athlete4) record2b.broke(record3) record2a.broke(record2b) record1.broke(record2a) record4b.broke(record4a) Graph g = new Neo4j2Graph(db) def writer = new GraphMLWriter(g) def out = new FileOutputStream("/temp/athletes.graphml") writer.outputGraph(out) writer.setNormalize(true) out.close() tx.success() } finally { tx?.close() } ================================================ FILE: listings/chap13/layering/AthleteApplication.groovy ================================================ package layering class AthleteApplication { def helper = new DbHelper() //#1 def athleteDAO = new AthleteDAO(db: helper.db) //#1 def sortBy = 'athleteId' //#1 def done = false def init() { helper.executeDdl(athleteDAO) } //#1 def exit() { done = true } def sort(field) { sortBy = field list() } def create(first, last = null, dob = null) { athleteDAO.create([first, last, dob]) list() } def list() { def athletes = athleteDAO.all(sortBy) println athletes.size() + ' Athlete(s) in DB: ' println 'id firstname lastname dateOfBirth' athletes.each { athlete -> println athlete.athleteId + ': ' + athlete.firstname.padRight(10) + ' ' + athlete.lastname.padRight(12) + ' ' + athlete.dateOfBirth } } def update(id, field, newValue) { def count = athleteDAO.update(field, newValue, id) println count + ' row(s) updated' list() } def delete(id) { def count = athleteDAO.delete(id) println count + ' row(s) deleted' list() } def mainLoop() { //#2 def reader = System.in.newReader() while (!done) { println '\ncommands: create list update delete sort exit' def input = reader.readLine().tokenize() //#A def method = input.remove(0) //#A this."$method"(*input) //#A } } } //#1 Initialization //#2 Entry point //#A Commands are provided as methods, then arguments ================================================ FILE: listings/chap13/layering/AthleteDAO.groovy ================================================ package layering class AthleteDAO extends DataAccessObject { List getFields() { return [ 'firstname', 'VARCHAR(64)', 'lastname', 'VARCHAR(64)', 'dateOfBirth', 'DATE' ] } } ================================================ FILE: listings/chap13/layering/DataAccessObject.groovy ================================================ package layering abstract class DataAccessObject { def db abstract List getFields() //#1 def dataSet() { db.dataSet(tablename) } //#2 def getIdField() { tablename.toLowerCase() + 'Id' } //#2 private getWhereId() { "WHERE $idField = ?" } //#2 String getTablename() { def name = this.getClass().name return name[name.lastIndexOf('.') + 1..-4] } def create(List args) { //#3 Map argMap = [:] args.eachWithIndex { arg, i -> argMap[fieldNames[i]] = arg } dataSet().add argMap } Map getSchema() { Map result = [:] fieldNames.each { result[it] = fields[fields.indexOf(it) + 1] } return result } List getFieldNames() { List result = [] 0.step(fields.size(), 2) { result << fields[it] } return result } def update(field, newValue, id) { def stmt = "UPDATE $tablename SET $field = ? ${getWhereId()}" db.executeUpdate stmt, [newValue, id] } def delete(id) { def stmt = "DELETE FROM $tablename ${getWhereId()}" db.executeUpdate stmt, [id] } def all(sortField) { //#4 def selects = fieldNames + idField def result = [] def stmt = "SELECT " + selects.join(',') + " FROM $tablename ORDER BY $sortField" db.eachRow(stmt.toString()) { rs -> Map businessObject = [:] selects.each { businessObject[it] = rs[it] } result << businessObject } return result } } //#1 Subclass implements this to provide field list //#2 Properties for use in SQL statements //#3 Create operation //#4 Sample read operation ================================================ FILE: listings/chap13/layering/DbHelper.groovy ================================================ package layering //@Grab('org.hsqldb:hsqldb:2.3.2') import groovy.sql.Sql import groovy.text.SimpleTemplateEngine as STE import org.hsqldb.jdbc.JDBCDataSource class DbHelper { Sql db DbHelper() { db = new Sql(new JDBCDataSource( database: 'jdbc:hsqldb:mem:GinA', user: 'sa', password: '')) } def simpleTemplate = new STE().createTemplate(''' DROP TABLE $name IF EXISTS cascade; CREATE TABLE $name ( ${lowname}Id INTEGER GENERATED BY DEFAULT AS IDENTITY, $fields ); ''') def executeDdl(DataAccessObject dao) { def template = simpleTemplate def binding = [ name: dao.tablename, lowname: dao.tablename.toLowerCase(), fields: dao.schema.collect { key, val -> " ${key.padRight(12)} $val" }.join(",\n") ] def stmt = template.make(binding).toString() db.execute stmt } } ================================================ FILE: listings/chap13/marathon/active_tx_log ================================================ tm_tx_log.1 ================================================ FILE: listings/chap13/marathon/messages.log ================================================ 2015-02-01 16:39:29.276+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-02-01 16:39:29.352+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-02-01 16:39:29.353+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-02-01 16:39:29.355+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-02-01 16:39:29.355+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 2.75 GB Committed virtual memory: 6.80 GB Total swap space: 1.00 GB Free swap space: 981.75 MB 2015-02-01 16:39:29.359+0000 INFO [org.neo4j]: JVM memory information: Free memory: 186.19 MB Total memory: 244.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=4.06 MB, used=4.00 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=63.00 MB, used=29.61 MB, max=1.31 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.49 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=17.71 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=29.00 MB, used=28.87 MB, max=82.00 MB, threshold=0.00 B 2015-02-01 16:39:29.367+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.2; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 78 Process id: 4500@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-02-01 16:39:29.369+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/2.4.0, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-02-01 16:39:29.370+0000 INFO [org.neo4j]: Java classpath: [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/qdox-1.12.1.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jcommander-1.47.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/bsf-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovysh-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-antlr-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xmlpull-1.1.3.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-nio-2.4.0.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/servlet-api-2.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-sql-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-xml-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsp-api-2.0.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-ant-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-test-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovydoc-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jmx-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/openbeans-1.0.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-junit-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jline-2.12.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/projects/git/regina/listings/chap13/./ [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ivy-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-json-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-console-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-templates-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsr166y-1.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-swing-2.4.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/hamcrest-core-1.3.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-launcher-1.9.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-docgenerator-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/multiverse-core-0.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-logging-1.2.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jsr223-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/junit-4.12.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-testng-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-servlet-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/testng-6.8.13.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/gpars-1.2.1.jar 2015-02-01 16:39:29.373+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/regina/listings/chap13 2015-02-01 16:39:29.373+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/regina/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/2.4.0 sun.cpu.isalist = 2015-02-01 16:39:29.373+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:b49d:fbff:fe48:bef5%10 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%5 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-02-01 16:39:29.374+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-02-01 16:39:29.407+0000 INFO [org.neo4j]: Creating new db @ marathon/neostore 2015-02-01 16:39:29.433+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.434+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.434+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.436+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.439+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.440+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.440+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.440+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.444+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.444+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.445+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.445+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.445+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-01 16:39:29.446+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.446+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.446+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-01 16:39:29.449+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=13904084b mappedMem=1390411776b (storeSize=0b) 2015-02-01 16:39:29.452+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=17028866b mappedMem=1702887424b (storeSize=0b) 2015-02-01 16:39:29.452+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-01 16:39:29.454+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=3858750b mappedMem=385875968b (storeSize=0b) 2015-02-01 16:39:29.455+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-01 16:39:29.457+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-01 16:39:29.458+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.463+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.463+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.464+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.465+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.465+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.466+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.466+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.467+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.468+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.468+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.469+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.470+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.470+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.471+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:29.472+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=10 switches=0 ooe=0 2015-02-01 16:39:29.479+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.479+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.480+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.480+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.480+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-01 16:39:29.481+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-01 16:39:29.481+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-01 16:39:29.481+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-01 16:39:29.481+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=13904084b mappedMem=1390411776b (storeSize=0b) 2015-02-01 16:39:29.482+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=17028866b mappedMem=1702887424b (storeSize=0b) 2015-02-01 16:39:29.482+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-01 16:39:29.482+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=3858750b mappedMem=385875968b (storeSize=0b) 2015-02-01 16:39:29.482+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-01 16:39:29.483+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-01 16:39:29.483+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-02-01 16:39:29.548+0000 INFO [org.neo4j]: No lucene scan store index found, this might just be first use. Preparing to rebuild. 2015-02-01 16:39:29.573+0000 INFO [org.neo4j]: No lucene scan store index found, this might just be first use. Preparing to rebuild. 2015-02-01 16:39:29.693+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=0, lastTxId=1 (clean) 2015-02-01 16:39:29.696+0000 INFO [org.neo4j]: Rebuilding lucene scan store, this may take a while 2015-02-01 16:39:29.697+0000 INFO [org.neo4j]: Lucene scan store rebuilt (roughly -1 nodes) 2015-02-01 16:39:29.699+0000 INFO [org.neo4j]: TM new log: tm_tx_log.1 2015-02-01 16:39:29.703+0000 INFO [org.neo4j]: Kernel health set to OK 2015-02-01 16:39:29.712+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=0, lastTxId=1 (clean) 2015-02-01 16:39:29.716+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-02-01 16:39:29.716+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-02-01 16:39:29.718+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-02-01 16:39:29.718+0000 INFO [org.neo4j]: Neo4j component versions: 2015-02-01 16:39:29.719+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-01 16:39:29.719+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-01 16:39:29.719+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-02-01 16:39:29.722+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-02-01 16:39:29.722+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-02-01 16:39:29.722+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-02-01 16:39:29.723+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-02-01 16:39:29.723+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=0 high=-1 RelationshipStore: used=0 high=-1 RelationshipTypeStore: used=0 high=-1 LabelTokenStore: used=0 high=-1 PropertyStore: used=0 high=-1 PropertyIndexStore: used=0 high=-1 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-02-01 16:39:29.723+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-02-01 16:39:29.723+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-02-01 16:39:29.723+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-02-01 16:39:29.724+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-02-01 16:39:29.724+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 175066800128 / 35 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-01T17:39:29+0100 - 40.00 B lucene.log.1: 2015-02-01T17:39:29+0100 - 16.00 B lucene.log.active: 2015-02-01T17:39:29+0100 - 4.00 B - Total: 2015-02-01T17:39:29+0100 - 60.00 B lock: 2015-02-01T17:39:29+0100 - 0.00 B messages.log: 2015-02-01T17:39:29+0100 - 22.22 kB neostore: 2015-02-01T17:39:29+0100 - 81.00 B neostore.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.labeltokenstore.db: 2015-02-01T17:39:29+0100 - 0.00 B neostore.labeltokenstore.db.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.labeltokenstore.db.names: 2015-02-01T17:39:29+0100 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.nodestore.db: 2015-02-01T17:39:29+0100 - 0.00 B neostore.nodestore.db.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.nodestore.db.labels: 2015-02-01T17:39:29+0100 - 68.00 B neostore.nodestore.db.labels.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.propertystore.db: 2015-02-01T17:39:29+0100 - 0.00 B neostore.propertystore.db.arrays: 2015-02-01T17:39:29+0100 - 128.00 B neostore.propertystore.db.arrays.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.propertystore.db.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.propertystore.db.index: 2015-02-01T17:39:29+0100 - 0.00 B neostore.propertystore.db.index.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.propertystore.db.index.keys: 2015-02-01T17:39:29+0100 - 38.00 B neostore.propertystore.db.index.keys.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.propertystore.db.strings: 2015-02-01T17:39:29+0100 - 128.00 B neostore.propertystore.db.strings.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.relationshipgroupstore.db: 2015-02-01T17:39:29+0100 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.relationshipstore.db: 2015-02-01T17:39:29+0100 - 0.00 B neostore.relationshipstore.db.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.relationshiptypestore.db: 2015-02-01T17:39:29+0100 - 0.00 B neostore.relationshiptypestore.db.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.relationshiptypestore.db.names: 2015-02-01T17:39:29+0100 - 38.00 B neostore.relationshiptypestore.db.names.id: 2015-02-01T17:39:29+0100 - 9.00 B neostore.schemastore.db: 2015-02-01T17:39:29+0100 - 64.00 B neostore.schemastore.db.id: 2015-02-01T17:39:29+0100 - 9.00 B nioneo_logical.log.1: 2015-02-01T17:39:29+0100 - 16.00 B nioneo_logical.log.active: 2015-02-01T17:39:29+0100 - 4.00 B schema: label: lucene: write.lock: 2015-02-01T17:39:29+0100 - 0.00 B - Total: 2015-02-01T17:39:29+0100 - 0.00 B - Total: 2015-02-01T17:39:29+0100 - 0.00 B - Total: 2015-02-01T17:39:29+0100 - 0.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-02-01T17:39:29+0100 - 0.00 B 2015-02-01 16:39:29.732+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-02-01 16:39:29.791+0000 INFO [org.neo4j]: Database is now ready 2015-02-01 16:39:30.044+0000 INFO [org.neo4j]: Shutdown started 2015-02-01 16:39:30.044+0000 INFO [org.neo4j]: Database is now unavailable 2015-02-01 16:39:30.046+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-02-01 16:39:30.046+0000 INFO [org.neo4j]: TM shutting down 2015-02-01 16:39:30.052+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-02-01 16:39:30.053+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=2 switches=0 ooe=0 2015-02-01 16:39:30.053+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-02-01 16:39:30.054+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.055+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.055+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.056+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=6 switches=0 ooe=0 2015-02-01 16:39:30.057+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-02-01 16:39:30.057+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.058+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=20 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.059+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=10 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.059+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.060+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=10 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.061+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.061+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-01 16:39:30.062+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=26 switches=0 ooe=0 2015-02-01 16:39:30.063+0000 INFO [org.neo4j]: NeoStore closed 2015-02-01 16:39:30.063+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-02-01 16:39:30.063+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-02-02 01:28:48.120+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-02-02 01:28:48.199+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-02-02 01:28:48.201+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-02-02 01:28:48.203+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-02-02 01:28:48.206+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 2.49 GB Committed virtual memory: 6.81 GB Total swap space: 1.00 GB Free swap space: 981.75 MB 2015-02-02 01:28:48.211+0000 INFO [org.neo4j]: JVM memory information: Free memory: 262.02 MB Total memory: 310.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=3.19 MB, used=3.01 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=129.00 MB, used=25.29 MB, max=1.31 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.49 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=12.19 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=25.50 MB, used=25.15 MB, max=82.00 MB, threshold=0.00 B 2015-02-02 01:28:48.219+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.2; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 71 Process id: 5798@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-02-02 01:28:48.221+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/2.4.0, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-02-02 01:28:48.222+0000 INFO [org.neo4j]: Java classpath: [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/qdox-1.12.1.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jcommander-1.47.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/bsf-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovysh-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-antlr-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xmlpull-1.1.3.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-nio-2.4.0.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/servlet-api-2.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-sql-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-xml-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsp-api-2.0.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-ant-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-test-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovydoc-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jmx-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/openbeans-1.0.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-junit-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jline-2.12.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/projects/git/regina/listings/chap13/./ [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ivy-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-json-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-console-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-templates-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsr166y-1.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-swing-2.4.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/hamcrest-core-1.3.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-launcher-1.9.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-docgenerator-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/multiverse-core-0.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-logging-1.2.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jsr223-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/junit-4.12.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-testng-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-servlet-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/testng-6.8.13.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/gpars-1.2.1.jar 2015-02-02 01:28:48.226+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/regina/listings/chap13 2015-02-02 01:28:48.226+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/regina/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/2.4.0 sun.cpu.isalist = 2015-02-02 01:28:48.227+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:b49d:fbff:fe48:bef5%10 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%5 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-02-02 01:28:48.230+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-02-02 01:28:48.297+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-02-02 01:28:48.299+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-02-02 01:28:48.301+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-02 01:28:48.304+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-02 01:28:48.306+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-02 01:28:48.308+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-02-02 01:28:48.310+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-02-02 01:28:48.313+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-02 01:28:48.329+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=820b) 2015-02-02 01:28:48.334+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=340b) 2015-02-02 01:28:48.336+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-02 01:28:48.340+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=150b) 2015-02-02 01:28:48.343+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-02 01:28:48.346+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-02 01:28:48.348+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-02-02 01:28:48.586+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=1, lastTxId=10 (clean) 2015-02-02 01:28:48.592+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-02-02 01:28:48.600+0000 INFO [org.neo4j]: Kernel health set to OK 2015-02-02 01:28:48.612+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=1, lastTxId=1 (clean) 2015-02-02 01:28:48.618+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-02-02 01:28:48.618+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-02-02 01:28:48.620+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-02-02 01:28:48.620+0000 INFO [org.neo4j]: Neo4j component versions: 2015-02-02 01:28:48.621+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:28:48.621+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:28:48.621+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-02-02 01:28:48.624+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-02-02 01:28:48.625+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-02-02 01:28:48.625+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-02-02 01:28:48.625+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-02-02 01:28:48.625+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=10 high=9 RelationshipStore: used=10 high=9 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=20 high=19 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-02-02 01:28:48.626+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-02-02 01:28:48.626+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-02-02 01:28:48.626+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-02-02 01:28:48.627+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-02-02 01:28:48.627+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 174778966016 / 35 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-01T17:39:30+0100 - 40.00 B lucene.log.1: 2015-02-02T02:28:48+0100 - 16.00 B lucene.log.active: 2015-02-02T02:28:48+0100 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B - Total: 2015-02-02T02:28:48+0100 - 76.00 B lock: 2015-02-02T02:28:48+0100 - 0.00 B messages.log: 2015-02-02T02:28:48+0100 - 45.09 kB neostore: 2015-02-02T02:28:48+0100 - 81.00 B neostore.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.labeltokenstore.db: 2015-02-02T02:28:48+0100 - 0.00 B neostore.labeltokenstore.db.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.labeltokenstore.db.names: 2015-02-02T02:28:48+0100 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.nodestore.db: 2015-02-02T02:28:48+0100 - 150.00 B neostore.nodestore.db.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.nodestore.db.labels: 2015-02-02T02:28:48+0100 - 68.00 B neostore.nodestore.db.labels.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.propertystore.db: 2015-02-02T02:28:48+0100 - 820.00 B neostore.propertystore.db.arrays: 2015-02-02T02:28:48+0100 - 128.00 B neostore.propertystore.db.arrays.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.propertystore.db.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.propertystore.db.index: 2015-02-02T02:28:48+0100 - 54.00 B neostore.propertystore.db.index.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.propertystore.db.index.keys: 2015-02-02T02:28:48+0100 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.propertystore.db.strings: 2015-02-02T02:28:48+0100 - 128.00 B neostore.propertystore.db.strings.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.relationshipgroupstore.db: 2015-02-02T02:28:48+0100 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.relationshipstore.db: 2015-02-02T02:28:48+0100 - 340.00 B neostore.relationshipstore.db.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.relationshiptypestore.db: 2015-02-02T02:28:48+0100 - 10.00 B neostore.relationshiptypestore.db.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.relationshiptypestore.db.names: 2015-02-02T02:28:48+0100 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-02-02T02:28:48+0100 - 9.00 B neostore.schemastore.db: 2015-02-02T02:28:48+0100 - 64.00 B neostore.schemastore.db.id: 2015-02-02T02:28:48+0100 - 9.00 B nioneo_logical.log.1: 2015-02-02T02:28:48+0100 - 16.00 B nioneo_logical.log.active: 2015-02-02T02:28:48+0100 - 4.00 B nioneo_logical.log.v0: 2015-02-01T17:39:30+0100 - 4.52 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-02-02T02:28:48+0100 - 0.00 B - Total: 2015-02-02T02:28:48+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-02-02T02:28:48+0100 - 0.00 B 2015-02-02 01:28:48.637+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-02-02 01:28:48.685+0000 INFO [org.neo4j]: Database is now ready 2015-02-02 01:28:48.914+0000 INFO [org.neo4j]: Shutdown started 2015-02-02 01:28:48.914+0000 INFO [org.neo4j]: Database is now unavailable 2015-02-02 01:28:48.918+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-02-02 01:28:48.918+0000 INFO [org.neo4j]: TM shutting down 2015-02-02 01:28:48.924+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-02-02 01:28:48.925+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-02-02 01:28:48.926+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-02-02 01:28:48.927+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.928+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.929+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.929+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-02-02 01:28:48.930+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-02-02 01:28:48.930+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.931+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=20 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.932+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=10 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.933+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.934+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=10 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.934+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.935+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:28:48.937+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-02-02 01:28:48.938+0000 INFO [org.neo4j]: NeoStore closed 2015-02-02 01:28:48.938+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-02-02 01:28:48.938+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-02-02 01:29:25.276+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-02-02 01:29:25.340+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-02-02 01:29:25.342+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-02-02 01:29:25.343+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-02-02 01:29:25.344+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 2.38 GB Committed virtual memory: 6.80 GB Total swap space: 1.00 GB Free swap space: 981.75 MB 2015-02-02 01:29:25.345+0000 INFO [org.neo4j]: JVM memory information: Free memory: 253.70 MB Total memory: 310.50 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=4.06 MB, used=3.98 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=125.00 MB, used=18.93 MB, max=1.30 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=15.00 MB, used=14.69 MB, max=15.00 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=23.18 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=36.50 MB, used=36.35 MB, max=82.00 MB, threshold=0.00 B 2015-02-02 01:29:25.347+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.2; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 101 Process id: 5798@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-02-02 01:29:25.348+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/2.4.0, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-02-02 01:29:25.349+0000 INFO [org.neo4j]: Java classpath: [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/qdox-1.12.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-scala_2.10/jars/parboiled-scala_2.10-1.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jcommander-1.47.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/bsf-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-configuration/commons-configuration/jars/commons-configuration-1.6.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovysh-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-antlr-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xmlpull-1.1.3.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.4.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-junit-1.9.4.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-management/jars/neo4j-management-2.1.6.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-groovy/jars/gremlin-groovy-2.6.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ivy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-json-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-templates-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-java/jars/gremlin-java-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/hamcrest-core-1.3.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/multiverse-core-0.7.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-commons/jars/neo4j-cypher-commons-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/junit-4.12.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-servlet-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/testng-6.8.13.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-core/jars/parboiled-core-1.1.6.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils/jars/commons-beanutils-1.7.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-nio-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/servlet-api-2.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-digester/commons-digester/jars/commons-digester-1.8.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-sql-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-xml-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsp-api-2.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.0/jars/neo4j-cypher-compiler-2.0-2.0.4.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-ant-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher/jars/neo4j-cypher-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-test-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.scala-lang/scala-library/jars/scala-library-2.10.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovydoc-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jmx-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/openbeans-1.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jline-2.12.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [loader.1] file:/projects/git/regina/listings/chap13/./ [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils-core/jars/commons-beanutils-core-1.8.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-console-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-neo4j2-graph/jars/blueprints-neo4j2-graph-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsr166y-1.7.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-core/jars/blueprints-core-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-swing-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.1/jars/neo4j-cypher-compiler-2.1-2.1.6.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-launcher-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-docgenerator-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-logging-1.2.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jsr223-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-testng-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-collections/commons-collections/jars/commons-collections-3.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop/pipes/jars/pipes-2.6.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.googlecode.concurrentlinkedhashmap/concurrentlinkedhashmap-lru/jars/concurrentlinkedhashmap-lru-1.4.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/gpars-1.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-1.9/jars/neo4j-cypher-compiler-1.9-2.0.4.jar 2015-02-02 01:29:25.353+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/regina/listings/chap13 2015-02-02 01:29:25.353+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/regina/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/2.4.0 sun.cpu.isalist = 2015-02-02 01:29:25.353+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:b49d:fbff:fe48:bef5%10 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%5 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-02-02 01:29:25.354+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-02-02 01:29:25.397+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-02-02 01:29:25.399+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-02-02 01:29:25.399+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-02 01:29:25.400+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-02 01:29:25.400+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-02 01:29:25.400+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-02-02 01:29:25.401+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-02-02 01:29:25.402+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-02 01:29:25.414+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=1640b) 2015-02-02 01:29:25.416+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=680b) 2015-02-02 01:29:25.416+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-02 01:29:25.418+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=300b) 2015-02-02 01:29:25.419+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-02 01:29:25.420+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-02 01:29:25.421+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-02-02 01:29:25.559+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=2, lastTxId=11 (clean) 2015-02-02 01:29:25.567+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-02-02 01:29:25.574+0000 INFO [org.neo4j]: Kernel health set to OK 2015-02-02 01:29:25.582+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=2, lastTxId=1 (clean) 2015-02-02 01:29:25.586+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-02-02 01:29:25.586+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-02-02 01:29:25.595+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-02-02 01:29:25.595+0000 INFO [org.neo4j]: Neo4j component versions: 2015-02-02 01:29:25.597+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:29:25.597+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.1 (neo4j-cypher-compiler-2.1), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:29:25.597+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:29:25.597+0000 INFO [org.neo4j]: Neo4j - Cypher (neo4j-cypher), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:29:25.597+0000 INFO [org.neo4j]: Neo4j - Graph DB Monitoring and Management tools (neo4j-management), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:29:25.598+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.0 (neo4j-cypher-compiler-2.0), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-02-02 01:29:25.598+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 1.9 (neo4j-cypher-compiler-1.9), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-02-02 01:29:25.598+0000 INFO [org.neo4j]: Neo4j - Cypher Commons (neo4j-cypher-commons), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-02 01:29:25.598+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-02-02 01:29:25.600+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-02-02 01:29:25.600+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-02-02 01:29:25.600+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-02-02 01:29:25.600+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-02-02 01:29:25.600+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=20 high=19 RelationshipStore: used=20 high=19 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=40 high=39 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-02-02 01:29:25.601+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-02-02 01:29:25.601+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-02-02 01:29:25.601+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-02-02 01:29:25.601+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-02-02 01:29:25.602+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 174755573760 / 35 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-02T02:28:48+0100 - 40.00 B lucene.log.1: 2015-02-02T02:29:25+0100 - 16.00 B lucene.log.active: 2015-02-02T02:29:25+0100 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B lucene.log.v1: 2015-02-02T02:28:48+0100 - 16.00 B - Total: 2015-02-02T02:29:25+0100 - 92.00 B lock: 2015-02-02T02:29:25+0100 - 0.00 B messages.log: 2015-02-02T02:29:25+0100 - 71.99 kB neostore: 2015-02-02T02:29:25+0100 - 81.00 B neostore.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.labeltokenstore.db: 2015-02-02T02:29:25+0100 - 0.00 B neostore.labeltokenstore.db.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.labeltokenstore.db.names: 2015-02-02T02:29:25+0100 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.nodestore.db: 2015-02-02T02:29:25+0100 - 300.00 B neostore.nodestore.db.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.nodestore.db.labels: 2015-02-02T02:29:25+0100 - 68.00 B neostore.nodestore.db.labels.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.propertystore.db: 2015-02-02T02:29:25+0100 - 1.60 kB neostore.propertystore.db.arrays: 2015-02-02T02:29:25+0100 - 128.00 B neostore.propertystore.db.arrays.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.propertystore.db.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.propertystore.db.index: 2015-02-02T02:29:25+0100 - 54.00 B neostore.propertystore.db.index.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.propertystore.db.index.keys: 2015-02-02T02:29:25+0100 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.propertystore.db.strings: 2015-02-02T02:29:25+0100 - 128.00 B neostore.propertystore.db.strings.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.relationshipgroupstore.db: 2015-02-02T02:29:25+0100 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.relationshipstore.db: 2015-02-02T02:29:25+0100 - 680.00 B neostore.relationshipstore.db.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.relationshiptypestore.db: 2015-02-02T02:29:25+0100 - 10.00 B neostore.relationshiptypestore.db.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.relationshiptypestore.db.names: 2015-02-02T02:29:25+0100 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-02-02T02:29:25+0100 - 9.00 B neostore.schemastore.db: 2015-02-02T02:29:25+0100 - 64.00 B neostore.schemastore.db.id: 2015-02-02T02:29:25+0100 - 9.00 B nioneo_logical.log.1: 2015-02-02T02:29:25+0100 - 16.00 B nioneo_logical.log.active: 2015-02-02T02:29:25+0100 - 4.00 B nioneo_logical.log.v0: 2015-02-01T17:39:30+0100 - 4.52 kB nioneo_logical.log.v1: 2015-02-02T02:28:48+0100 - 3.34 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-02-02T02:29:25+0100 - 0.00 B - Total: 2015-02-02T02:29:25+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-02-02T02:29:25+0100 - 0.00 B 2015-02-02 01:29:25.609+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-02-02 01:29:25.651+0000 INFO [org.neo4j]: Database is now ready 2015-02-02 01:29:26.798+0000 INFO [org.neo4j]: Shutdown started 2015-02-02 01:29:26.800+0000 INFO [org.neo4j]: Database is now unavailable 2015-02-02 01:29:26.803+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-02-02 01:29:26.804+0000 INFO [org.neo4j]: TM shutting down 2015-02-02 01:29:26.809+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-02-02 01:29:26.811+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-02-02 01:29:26.812+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-02-02 01:29:26.813+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.813+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.814+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.815+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-02-02 01:29:26.815+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-02-02 01:29:26.816+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.817+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=60 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.818+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=34 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.818+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.819+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=60 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.820+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.821+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-02 01:29:26.823+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-02-02 01:29:26.824+0000 INFO [org.neo4j]: NeoStore closed 2015-02-02 01:29:26.824+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-02-02 01:29:26.824+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-02-06 00:41:40.694+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-02-06 00:41:40.795+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-02-06 00:41:40.796+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-02-06 00:41:40.799+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-02-06 00:41:40.803+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 7.64 GB Committed virtual memory: 6.81 GB Total swap space: 2.00 GB Free swap space: 1.19 GB 2015-02-06 00:41:40.807+0000 INFO [org.neo4j]: JVM memory information: Free memory: 259.47 MB Total memory: 310.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=3.19 MB, used=3.04 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=129.00 MB, used=27.83 MB, max=1.31 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.48 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=12.22 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=25.50 MB, used=25.15 MB, max=82.00 MB, threshold=0.00 B 2015-02-06 00:41:40.815+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.2; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 72 Process id: 5385@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-02-06 00:41:40.817+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/2.4.0, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-02-06 00:41:40.818+0000 INFO [org.neo4j]: Java classpath: [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/qdox-1.12.1.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jcommander-1.47.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/bsf-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovysh-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-antlr-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xmlpull-1.1.3.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-nio-2.4.0.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/servlet-api-2.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-sql-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-xml-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsp-api-2.0.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-ant-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-test-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovydoc-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jmx-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/openbeans-1.0.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-junit-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jline-2.12.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/projects/git/regina/listings/chap13/./ [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ivy-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-json-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-console-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-templates-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsr166y-1.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-swing-2.4.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/hamcrest-core-1.3.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-launcher-1.9.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-docgenerator-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/multiverse-core-0.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-logging-1.2.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jsr223-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/junit-4.12.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-testng-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-servlet-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/testng-6.8.13.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/gpars-1.2.1.jar 2015-02-06 00:41:40.822+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/regina/listings/chap13 2015-02-06 00:41:40.822+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/regina/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/2.4.0 sun.cpu.isalist = 2015-02-06 00:41:40.822+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:10c4:ecff:fed9:b394%8 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%4 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-02-06 00:41:40.824+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-02-06 00:41:40.900+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-02-06 00:41:40.903+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-02-06 00:41:40.905+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-06 00:41:40.908+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-06 00:41:40.910+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-06 00:41:40.912+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-02-06 00:41:40.914+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-02-06 00:41:40.916+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-06 00:41:40.934+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=2460b) 2015-02-06 00:41:40.939+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=1020b) 2015-02-06 00:41:40.942+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-06 00:41:40.945+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=450b) 2015-02-06 00:41:40.948+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-06 00:41:40.952+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-06 00:41:40.954+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-02-06 00:41:41.222+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=3, lastTxId=12 (clean) 2015-02-06 00:41:41.227+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-02-06 00:41:41.234+0000 INFO [org.neo4j]: Kernel health set to OK 2015-02-06 00:41:41.245+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=3, lastTxId=1 (clean) 2015-02-06 00:41:41.250+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-02-06 00:41:41.250+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-02-06 00:41:41.253+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-02-06 00:41:41.253+0000 INFO [org.neo4j]: Neo4j component versions: 2015-02-06 00:41:41.254+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:41.254+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:41.254+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-02-06 00:41:41.257+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-02-06 00:41:41.257+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-02-06 00:41:41.258+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-02-06 00:41:41.258+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-02-06 00:41:41.258+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=30 high=29 RelationshipStore: used=30 high=29 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=60 high=59 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-02-06 00:41:41.259+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-02-06 00:41:41.259+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-02-06 00:41:41.259+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-02-06 00:41:41.260+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-02-06 00:41:41.260+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 174680444928 / 35 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-02T02:29:26+0100 - 40.00 B lucene.log.1: 2015-02-06T01:41:41+0100 - 16.00 B lucene.log.active: 2015-02-06T01:41:41+0100 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B lucene.log.v1: 2015-02-02T02:28:48+0100 - 16.00 B lucene.log.v2: 2015-02-02T02:29:26+0100 - 16.00 B - Total: 2015-02-06T01:41:41+0100 - 108.00 B lock: 2015-02-06T01:41:40+0100 - 0.00 B messages.log: 2015-02-06T01:41:41+0100 - 95.23 kB neostore: 2015-02-06T01:41:40+0100 - 81.00 B neostore.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.labeltokenstore.db: 2015-02-06T01:41:40+0100 - 0.00 B neostore.labeltokenstore.db.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.labeltokenstore.db.names: 2015-02-06T01:41:40+0100 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.nodestore.db: 2015-02-06T01:41:40+0100 - 450.00 B neostore.nodestore.db.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.nodestore.db.labels: 2015-02-06T01:41:40+0100 - 68.00 B neostore.nodestore.db.labels.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.propertystore.db: 2015-02-06T01:41:40+0100 - 2.40 kB neostore.propertystore.db.arrays: 2015-02-06T01:41:40+0100 - 128.00 B neostore.propertystore.db.arrays.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.propertystore.db.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.propertystore.db.index: 2015-02-06T01:41:40+0100 - 54.00 B neostore.propertystore.db.index.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.propertystore.db.index.keys: 2015-02-06T01:41:40+0100 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.propertystore.db.strings: 2015-02-06T01:41:40+0100 - 128.00 B neostore.propertystore.db.strings.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.relationshipgroupstore.db: 2015-02-06T01:41:40+0100 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.relationshipstore.db: 2015-02-06T01:41:40+0100 - 1020.00 B neostore.relationshipstore.db.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.relationshiptypestore.db: 2015-02-06T01:41:40+0100 - 10.00 B neostore.relationshiptypestore.db.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.relationshiptypestore.db.names: 2015-02-06T01:41:40+0100 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-02-06T01:41:40+0100 - 9.00 B neostore.schemastore.db: 2015-02-06T01:41:40+0100 - 64.00 B neostore.schemastore.db.id: 2015-02-06T01:41:40+0100 - 9.00 B nioneo_logical.log.1: 2015-02-06T01:41:41+0100 - 16.00 B nioneo_logical.log.active: 2015-02-06T01:41:41+0100 - 4.00 B nioneo_logical.log.v0: 2015-02-01T17:39:30+0100 - 4.52 kB nioneo_logical.log.v1: 2015-02-02T02:28:48+0100 - 3.34 kB nioneo_logical.log.v2: 2015-02-02T02:29:26+0100 - 3.34 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-02-06T01:41:41+0100 - 0.00 B - Total: 2015-02-06T01:41:41+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-02-06T01:41:41+0100 - 0.00 B 2015-02-06 00:41:41.270+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-02-06 00:41:41.317+0000 INFO [org.neo4j]: Database is now ready 2015-02-06 00:41:41.545+0000 INFO [org.neo4j]: Shutdown started 2015-02-06 00:41:41.546+0000 INFO [org.neo4j]: Database is now unavailable 2015-02-06 00:41:41.550+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-02-06 00:41:41.550+0000 INFO [org.neo4j]: TM shutting down 2015-02-06 00:41:41.557+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-02-06 00:41:41.558+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-02-06 00:41:41.559+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-02-06 00:41:41.560+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.560+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.561+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.562+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-02-06 00:41:41.562+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-02-06 00:41:41.563+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.564+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=20 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.565+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=10 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.565+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.566+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=10 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.567+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.568+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:41.569+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-02-06 00:41:41.570+0000 INFO [org.neo4j]: NeoStore closed 2015-02-06 00:41:41.570+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-02-06 00:41:41.570+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-02-06 00:41:42.646+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-02-06 00:41:42.710+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-02-06 00:41:42.712+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-02-06 00:41:42.714+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-02-06 00:41:42.714+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 7.56 GB Committed virtual memory: 6.81 GB Total swap space: 2.00 GB Free swap space: 1.19 GB 2015-02-06 00:41:42.715+0000 INFO [org.neo4j]: JVM memory information: Free memory: 172.99 MB Total memory: 310.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=4.06 MB, used=4.00 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=129.00 MB, used=104.62 MB, max=1.30 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.47 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=21.92 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=33.50 MB, used=33.45 MB, max=82.00 MB, threshold=0.00 B 2015-02-06 00:41:42.717+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.2; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 95 Process id: 5385@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-02-06 00:41:42.718+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/2.4.0, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-02-06 00:41:42.718+0000 INFO [org.neo4j]: Java classpath: [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/qdox-1.12.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-scala_2.10/jars/parboiled-scala_2.10-1.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jcommander-1.47.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/bsf-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-configuration/commons-configuration/jars/commons-configuration-1.6.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovysh-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-antlr-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xmlpull-1.1.3.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.4.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-junit-1.9.4.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-management/jars/neo4j-management-2.1.6.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-groovy/jars/gremlin-groovy-2.6.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ivy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-json-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-templates-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-java/jars/gremlin-java-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/hamcrest-core-1.3.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/multiverse-core-0.7.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-commons/jars/neo4j-cypher-commons-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/junit-4.12.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-servlet-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/testng-6.8.13.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-core/jars/parboiled-core-1.1.6.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils/jars/commons-beanutils-1.7.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-nio-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/servlet-api-2.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-digester/commons-digester/jars/commons-digester-1.8.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-sql-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-xml-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsp-api-2.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.0/jars/neo4j-cypher-compiler-2.0-2.0.4.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-ant-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher/jars/neo4j-cypher-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-test-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.scala-lang/scala-library/jars/scala-library-2.10.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovydoc-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jmx-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/openbeans-1.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jline-2.12.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [loader.1] file:/projects/git/regina/listings/chap13/./ [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils-core/jars/commons-beanutils-core-1.8.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-console-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-neo4j2-graph/jars/blueprints-neo4j2-graph-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsr166y-1.7.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-core/jars/blueprints-core-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-swing-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.1/jars/neo4j-cypher-compiler-2.1-2.1.6.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-launcher-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-docgenerator-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-logging-1.2.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jsr223-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-testng-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-collections/commons-collections/jars/commons-collections-3.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop/pipes/jars/pipes-2.6.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.googlecode.concurrentlinkedhashmap/concurrentlinkedhashmap-lru/jars/concurrentlinkedhashmap-lru-1.4.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/gpars-1.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-1.9/jars/neo4j-cypher-compiler-1.9-2.0.4.jar 2015-02-06 00:41:42.722+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/regina/listings/chap13 2015-02-06 00:41:42.722+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/regina/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/2.4.0 sun.cpu.isalist = 2015-02-06 00:41:42.723+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:10c4:ecff:fed9:b394%8 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%4 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-02-06 00:41:42.723+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-02-06 00:41:42.767+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-02-06 00:41:42.768+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-02-06 00:41:42.769+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-06 00:41:42.769+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-06 00:41:42.770+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-06 00:41:42.770+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-02-06 00:41:42.770+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-02-06 00:41:42.771+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-06 00:41:42.788+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=3280b) 2015-02-06 00:41:42.791+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=1360b) 2015-02-06 00:41:42.791+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-06 00:41:42.793+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=600b) 2015-02-06 00:41:42.794+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-06 00:41:42.795+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-06 00:41:42.796+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-02-06 00:41:42.971+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=4, lastTxId=13 (clean) 2015-02-06 00:41:42.976+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-02-06 00:41:42.980+0000 INFO [org.neo4j]: Kernel health set to OK 2015-02-06 00:41:42.988+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=4, lastTxId=1 (clean) 2015-02-06 00:41:42.991+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-02-06 00:41:42.991+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-02-06 00:41:43.007+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-02-06 00:41:43.007+0000 INFO [org.neo4j]: Neo4j component versions: 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.1 (neo4j-cypher-compiler-2.1), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Cypher (neo4j-cypher), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Graph DB Monitoring and Management tools (neo4j-management), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.0 (neo4j-cypher-compiler-2.0), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 1.9 (neo4j-cypher-compiler-1.9), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: Neo4j - Cypher Commons (neo4j-cypher-commons), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 00:41:43.010+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-02-06 00:41:43.012+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-02-06 00:41:43.012+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-02-06 00:41:43.013+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-02-06 00:41:43.013+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-02-06 00:41:43.013+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=40 high=39 RelationshipStore: used=40 high=39 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=80 high=79 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-02-06 00:41:43.013+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-02-06 00:41:43.013+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-02-06 00:41:43.013+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-02-06 00:41:43.014+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-02-06 00:41:43.014+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 174680317952 / 35 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-06T01:41:41+0100 - 40.00 B lucene.log.1: 2015-02-06T01:41:43+0100 - 16.00 B lucene.log.active: 2015-02-06T01:41:42+0100 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B lucene.log.v1: 2015-02-02T02:28:48+0100 - 16.00 B lucene.log.v2: 2015-02-02T02:29:26+0100 - 16.00 B lucene.log.v3: 2015-02-06T01:41:41+0100 - 16.00 B - Total: 2015-02-06T01:41:42+0100 - 124.00 B lock: 2015-02-06T01:41:42+0100 - 0.00 B messages.log: 2015-02-06T01:41:43+0100 - 122.37 kB neostore: 2015-02-06T01:41:42+0100 - 81.00 B neostore.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.labeltokenstore.db: 2015-02-06T01:41:42+0100 - 0.00 B neostore.labeltokenstore.db.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.labeltokenstore.db.names: 2015-02-06T01:41:42+0100 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.nodestore.db: 2015-02-06T01:41:42+0100 - 600.00 B neostore.nodestore.db.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.nodestore.db.labels: 2015-02-06T01:41:42+0100 - 68.00 B neostore.nodestore.db.labels.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.propertystore.db: 2015-02-06T01:41:42+0100 - 3.20 kB neostore.propertystore.db.arrays: 2015-02-06T01:41:42+0100 - 128.00 B neostore.propertystore.db.arrays.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.propertystore.db.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.propertystore.db.index: 2015-02-06T01:41:42+0100 - 54.00 B neostore.propertystore.db.index.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.propertystore.db.index.keys: 2015-02-06T01:41:42+0100 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.propertystore.db.strings: 2015-02-06T01:41:42+0100 - 128.00 B neostore.propertystore.db.strings.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.relationshipgroupstore.db: 2015-02-06T01:41:42+0100 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.relationshipstore.db: 2015-02-06T01:41:42+0100 - 1.33 kB neostore.relationshipstore.db.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.relationshiptypestore.db: 2015-02-06T01:41:42+0100 - 10.00 B neostore.relationshiptypestore.db.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.relationshiptypestore.db.names: 2015-02-06T01:41:42+0100 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-02-06T01:41:42+0100 - 9.00 B neostore.schemastore.db: 2015-02-06T01:41:42+0100 - 64.00 B neostore.schemastore.db.id: 2015-02-06T01:41:42+0100 - 9.00 B nioneo_logical.log.1: 2015-02-06T01:41:43+0100 - 16.00 B nioneo_logical.log.active: 2015-02-06T01:41:42+0100 - 4.00 B nioneo_logical.log.v0: 2015-02-01T17:39:30+0100 - 4.52 kB nioneo_logical.log.v1: 2015-02-02T02:28:48+0100 - 3.34 kB nioneo_logical.log.v2: 2015-02-02T02:29:26+0100 - 3.34 kB nioneo_logical.log.v3: 2015-02-06T01:41:41+0100 - 3.34 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-02-06T01:41:42+0100 - 0.00 B - Total: 2015-02-06T01:41:42+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-02-06T01:41:42+0100 - 0.00 B 2015-02-06 00:41:43.022+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-02-06 00:41:43.063+0000 INFO [org.neo4j]: Database is now ready 2015-02-06 00:41:44.296+0000 INFO [org.neo4j]: Shutdown started 2015-02-06 00:41:44.297+0000 INFO [org.neo4j]: Database is now unavailable 2015-02-06 00:41:44.304+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-02-06 00:41:44.305+0000 INFO [org.neo4j]: TM shutting down 2015-02-06 00:41:44.311+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-02-06 00:41:44.312+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-02-06 00:41:44.313+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-02-06 00:41:44.314+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.315+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.315+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.316+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-02-06 00:41:44.317+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-02-06 00:41:44.318+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.319+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=100 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.320+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=58 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.320+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.321+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=110 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.322+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.323+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 00:41:44.324+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-02-06 00:41:44.325+0000 INFO [org.neo4j]: NeoStore closed 2015-02-06 00:41:44.325+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-02-06 00:41:44.325+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-02-06 16:00:28.468+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-02-06 16:00:28.566+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-02-06 16:00:28.568+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-02-06 16:00:28.571+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-02-06 16:00:28.573+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 4.74 GB Committed virtual memory: 6.81 GB Total swap space: 2.00 GB Free swap space: 1.60 GB 2015-02-06 16:00:28.577+0000 INFO [org.neo4j]: JVM memory information: Free memory: 259.83 MB Total memory: 310.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=3.19 MB, used=3.05 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=129.00 MB, used=27.64 MB, max=1.31 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.49 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=12.04 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=25.50 MB, used=25.15 MB, max=82.00 MB, threshold=0.00 B 2015-02-06 16:00:28.582+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.2; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 71 Process id: 6465@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-02-06 16:00:28.584+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/2.4.0, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-02-06 16:00:28.584+0000 INFO [org.neo4j]: Java classpath: [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/qdox-1.12.1.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jcommander-1.47.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/bsf-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovysh-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-antlr-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xmlpull-1.1.3.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-nio-2.4.0.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/servlet-api-2.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-sql-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-xml-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsp-api-2.0.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-ant-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-test-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovydoc-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jmx-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/openbeans-1.0.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-junit-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jline-2.12.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/projects/git/regina/listings/chap13/./ [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ivy-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-json-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-console-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-templates-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsr166y-1.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-swing-2.4.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/hamcrest-core-1.3.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-launcher-1.9.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-docgenerator-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/multiverse-core-0.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-logging-1.2.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jsr223-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/junit-4.12.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-testng-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-servlet-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/testng-6.8.13.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/gpars-1.2.1.jar 2015-02-06 16:00:28.588+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/regina/listings/chap13 2015-02-06 16:00:28.588+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/regina/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/2.4.0 sun.cpu.isalist = 2015-02-06 16:00:28.589+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:10c4:ecff:fed9:b394%8 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%4 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-02-06 16:00:28.592+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-02-06 16:00:28.667+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-02-06 16:00:28.669+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-02-06 16:00:28.671+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-06 16:00:28.673+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-06 16:00:28.675+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-06 16:00:28.677+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-02-06 16:00:28.678+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-02-06 16:00:28.681+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-06 16:00:28.699+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=4100b) 2015-02-06 16:00:28.703+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=1700b) 2015-02-06 16:00:28.705+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-06 16:00:28.708+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=750b) 2015-02-06 16:00:28.711+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-06 16:00:28.714+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-06 16:00:28.716+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-02-06 16:00:28.955+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=5, lastTxId=14 (clean) 2015-02-06 16:00:28.961+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-02-06 16:00:28.968+0000 INFO [org.neo4j]: Kernel health set to OK 2015-02-06 16:00:28.979+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=5, lastTxId=1 (clean) 2015-02-06 16:00:28.984+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-02-06 16:00:28.984+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-02-06 16:00:28.987+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-02-06 16:00:28.987+0000 INFO [org.neo4j]: Neo4j component versions: 2015-02-06 16:00:28.988+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:28.988+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:28.988+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-02-06 16:00:28.990+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-02-06 16:00:28.991+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-02-06 16:00:28.991+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-02-06 16:00:28.991+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-02-06 16:00:28.991+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=50 high=49 RelationshipStore: used=50 high=49 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=100 high=99 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-02-06 16:00:28.992+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-02-06 16:00:28.992+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-02-06 16:00:28.992+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-02-06 16:00:28.992+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-02-06 16:00:28.993+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 174966755328 / 35 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-06T01:41:44+0100 - 40.00 B lucene.log.1: 2015-02-06T17:00:28+0100 - 16.00 B lucene.log.active: 2015-02-06T17:00:28+0100 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B lucene.log.v1: 2015-02-02T02:28:48+0100 - 16.00 B lucene.log.v2: 2015-02-02T02:29:26+0100 - 16.00 B lucene.log.v3: 2015-02-06T01:41:41+0100 - 16.00 B lucene.log.v4: 2015-02-06T01:41:44+0100 - 16.00 B - Total: 2015-02-06T17:00:28+0100 - 140.00 B lock: 2015-02-06T17:00:28+0100 - 0.00 B messages.log: 2015-02-06T17:00:28+0100 - 145.86 kB neostore: 2015-02-06T17:00:28+0100 - 81.00 B neostore.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.labeltokenstore.db: 2015-02-06T17:00:28+0100 - 0.00 B neostore.labeltokenstore.db.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.labeltokenstore.db.names: 2015-02-06T17:00:28+0100 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.nodestore.db: 2015-02-06T17:00:28+0100 - 750.00 B neostore.nodestore.db.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.nodestore.db.labels: 2015-02-06T17:00:28+0100 - 68.00 B neostore.nodestore.db.labels.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.propertystore.db: 2015-02-06T17:00:28+0100 - 4.00 kB neostore.propertystore.db.arrays: 2015-02-06T17:00:28+0100 - 128.00 B neostore.propertystore.db.arrays.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.propertystore.db.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.propertystore.db.index: 2015-02-06T17:00:28+0100 - 54.00 B neostore.propertystore.db.index.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.propertystore.db.index.keys: 2015-02-06T17:00:28+0100 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.propertystore.db.strings: 2015-02-06T17:00:28+0100 - 128.00 B neostore.propertystore.db.strings.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.relationshipgroupstore.db: 2015-02-06T17:00:28+0100 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.relationshipstore.db: 2015-02-06T17:00:28+0100 - 1.66 kB neostore.relationshipstore.db.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.relationshiptypestore.db: 2015-02-06T17:00:28+0100 - 10.00 B neostore.relationshiptypestore.db.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.relationshiptypestore.db.names: 2015-02-06T17:00:28+0100 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-02-06T17:00:28+0100 - 9.00 B neostore.schemastore.db: 2015-02-06T17:00:28+0100 - 64.00 B neostore.schemastore.db.id: 2015-02-06T17:00:28+0100 - 9.00 B nioneo_logical.log.1: 2015-02-06T17:00:29+0100 - 16.00 B nioneo_logical.log.active: 2015-02-06T17:00:28+0100 - 4.00 B nioneo_logical.log.v0: 2015-02-01T17:39:30+0100 - 4.52 kB nioneo_logical.log.v1: 2015-02-02T02:28:48+0100 - 3.34 kB nioneo_logical.log.v2: 2015-02-02T02:29:26+0100 - 3.34 kB nioneo_logical.log.v3: 2015-02-06T01:41:41+0100 - 3.34 kB nioneo_logical.log.v4: 2015-02-06T01:41:44+0100 - 3.34 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-02-06T17:00:28+0100 - 0.00 B - Total: 2015-02-06T17:00:28+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-02-06T17:00:28+0100 - 0.00 B 2015-02-06 16:00:29.003+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-02-06 16:00:29.050+0000 INFO [org.neo4j]: Database is now ready 2015-02-06 16:00:29.281+0000 INFO [org.neo4j]: Shutdown started 2015-02-06 16:00:29.281+0000 INFO [org.neo4j]: Database is now unavailable 2015-02-06 16:00:29.285+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-02-06 16:00:29.285+0000 INFO [org.neo4j]: TM shutting down 2015-02-06 16:00:29.293+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-02-06 16:00:29.293+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-02-06 16:00:29.295+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-02-06 16:00:29.295+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.296+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.296+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.297+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-02-06 16:00:29.297+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-02-06 16:00:29.298+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.299+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=20 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.300+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=10 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.301+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.302+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=10 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.302+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.303+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:29.304+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-02-06 16:00:29.305+0000 INFO [org.neo4j]: NeoStore closed 2015-02-06 16:00:29.305+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-02-06 16:00:29.305+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-02-06 16:00:30.398+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-02-06 16:00:30.463+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-02-06 16:00:30.464+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-02-06 16:00:30.466+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-02-06 16:00:30.467+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 4.67 GB Committed virtual memory: 6.81 GB Total swap space: 2.00 GB Free swap space: 1.60 GB 2015-02-06 16:00:30.468+0000 INFO [org.neo4j]: JVM memory information: Free memory: 173.98 MB Total memory: 310.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=4.00 MB, used=3.93 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=129.00 MB, used=103.74 MB, max=1.30 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.48 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=21.79 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=33.50 MB, used=33.44 MB, max=82.00 MB, threshold=0.00 B 2015-02-06 16:00:30.470+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.2; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 94 Process id: 6465@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-02-06 16:00:30.471+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/2.4.0, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-02-06 16:00:30.471+0000 INFO [org.neo4j]: Java classpath: [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/qdox-1.12.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-scala_2.10/jars/parboiled-scala_2.10-1.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jcommander-1.47.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/bsf-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-configuration/commons-configuration/jars/commons-configuration-1.6.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovysh-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-antlr-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xmlpull-1.1.3.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.4.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-junit-1.9.4.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-management/jars/neo4j-management-2.1.6.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-groovy/jars/gremlin-groovy-2.6.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ivy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-json-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-templates-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-java/jars/gremlin-java-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/hamcrest-core-1.3.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/multiverse-core-0.7.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-commons/jars/neo4j-cypher-commons-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/junit-4.12.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-servlet-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/testng-6.8.13.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-core/jars/parboiled-core-1.1.6.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-1.9.4.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils/jars/commons-beanutils-1.7.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-nio-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/servlet-api-2.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-digester/commons-digester/jars/commons-digester-1.8.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-sql-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-xml-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsp-api-2.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.0/jars/neo4j-cypher-compiler-2.0-2.0.4.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-ant-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher/jars/neo4j-cypher-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-test-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.scala-lang/scala-library/jars/scala-library-2.10.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-groovydoc-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jmx-2.4.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/openbeans-1.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jline-2.12.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [loader.1] file:/projects/git/regina/listings/chap13/./ [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils-core/jars/commons-beanutils-core-1.8.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-console-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-neo4j2-graph/jars/blueprints-neo4j2-graph-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/jsr166y-1.7.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-core/jars/blueprints-core-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-swing-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.1/jars/neo4j-cypher-compiler-2.1-2.1.6.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/ant-launcher-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-docgenerator-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-logging-1.2.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-jsr223-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/groovy-testng-2.4.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-collections/commons-collections/jars/commons-collections-3.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop/pipes/jars/pipes-2.6.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.googlecode.concurrentlinkedhashmap/concurrentlinkedhashmap-lru/jars/concurrentlinkedhashmap-lru-1.4.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/2.4.0/lib/gpars-1.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-1.9/jars/neo4j-cypher-compiler-1.9-2.0.4.jar 2015-02-06 16:00:30.475+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/regina/listings/chap13 2015-02-06 16:00:30.475+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/regina/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/2.4.0/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/2.4.0/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/2.4.0 sun.cpu.isalist = 2015-02-06 16:00:30.476+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:10c4:ecff:fed9:b394%8 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%4 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-02-06 16:00:30.476+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-02-06 16:00:30.522+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-02-06 16:00:30.523+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-02-06 16:00:30.523+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-02-06 16:00:30.524+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-02-06 16:00:30.524+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-02-06 16:00:30.524+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-02-06 16:00:30.525+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-02-06 16:00:30.526+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-02-06 16:00:30.542+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=4920b) 2015-02-06 16:00:30.545+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=2040b) 2015-02-06 16:00:30.545+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-02-06 16:00:30.547+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=900b) 2015-02-06 16:00:30.548+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-02-06 16:00:30.549+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-02-06 16:00:30.550+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-02-06 16:00:30.722+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=6, lastTxId=15 (clean) 2015-02-06 16:00:30.731+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-02-06 16:00:30.736+0000 INFO [org.neo4j]: Kernel health set to OK 2015-02-06 16:00:30.743+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=6, lastTxId=1 (clean) 2015-02-06 16:00:30.746+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-02-06 16:00:30.746+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-02-06 16:00:30.764+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-02-06 16:00:30.764+0000 INFO [org.neo4j]: Neo4j component versions: 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.1 (neo4j-cypher-compiler-2.1), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Cypher (neo4j-cypher), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Graph DB Monitoring and Management tools (neo4j-management), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.0 (neo4j-cypher-compiler-2.0), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 1.9 (neo4j-cypher-compiler-1.9), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: Neo4j - Cypher Commons (neo4j-cypher-commons), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-02-06 16:00:30.766+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-02-06 16:00:30.768+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-02-06 16:00:30.768+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-02-06 16:00:30.768+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-02-06 16:00:30.768+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-02-06 16:00:30.768+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=60 high=59 RelationshipStore: used=60 high=59 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=120 high=119 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-02-06 16:00:30.769+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-02-06 16:00:30.769+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-02-06 16:00:30.769+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-02-06 16:00:30.769+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-02-06 16:00:30.770+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 174966628352 / 35 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-06T17:00:29+0100 - 40.00 B lucene.log.1: 2015-02-06T17:00:30+0100 - 16.00 B lucene.log.active: 2015-02-06T17:00:30+0100 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B lucene.log.v1: 2015-02-02T02:28:48+0100 - 16.00 B lucene.log.v2: 2015-02-02T02:29:26+0100 - 16.00 B lucene.log.v3: 2015-02-06T01:41:41+0100 - 16.00 B lucene.log.v4: 2015-02-06T01:41:44+0100 - 16.00 B lucene.log.v5: 2015-02-06T17:00:29+0100 - 16.00 B - Total: 2015-02-06T17:00:30+0100 - 156.00 B lock: 2015-02-06T17:00:30+0100 - 0.00 B messages.log: 2015-02-06T17:00:30+0100 - 173.24 kB neostore: 2015-02-06T17:00:30+0100 - 81.00 B neostore.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.labeltokenstore.db: 2015-02-06T17:00:30+0100 - 0.00 B neostore.labeltokenstore.db.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.labeltokenstore.db.names: 2015-02-06T17:00:30+0100 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.nodestore.db: 2015-02-06T17:00:30+0100 - 900.00 B neostore.nodestore.db.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.nodestore.db.labels: 2015-02-06T17:00:30+0100 - 68.00 B neostore.nodestore.db.labels.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.propertystore.db: 2015-02-06T17:00:30+0100 - 4.80 kB neostore.propertystore.db.arrays: 2015-02-06T17:00:30+0100 - 128.00 B neostore.propertystore.db.arrays.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.propertystore.db.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.propertystore.db.index: 2015-02-06T17:00:30+0100 - 54.00 B neostore.propertystore.db.index.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.propertystore.db.index.keys: 2015-02-06T17:00:30+0100 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.propertystore.db.strings: 2015-02-06T17:00:30+0100 - 128.00 B neostore.propertystore.db.strings.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.relationshipgroupstore.db: 2015-02-06T17:00:30+0100 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.relationshipstore.db: 2015-02-06T17:00:30+0100 - 1.99 kB neostore.relationshipstore.db.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.relationshiptypestore.db: 2015-02-06T17:00:30+0100 - 10.00 B neostore.relationshiptypestore.db.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.relationshiptypestore.db.names: 2015-02-06T17:00:30+0100 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-02-06T17:00:30+0100 - 9.00 B neostore.schemastore.db: 2015-02-06T17:00:30+0100 - 64.00 B neostore.schemastore.db.id: 2015-02-06T17:00:30+0100 - 9.00 B nioneo_logical.log.1: 2015-02-06T17:00:30+0100 - 16.00 B nioneo_logical.log.active: 2015-02-06T17:00:30+0100 - 4.00 B nioneo_logical.log.v0: 2015-02-01T17:39:30+0100 - 4.52 kB nioneo_logical.log.v1: 2015-02-02T02:28:48+0100 - 3.34 kB nioneo_logical.log.v2: 2015-02-02T02:29:26+0100 - 3.34 kB nioneo_logical.log.v3: 2015-02-06T01:41:41+0100 - 3.34 kB nioneo_logical.log.v4: 2015-02-06T01:41:44+0100 - 3.34 kB nioneo_logical.log.v5: 2015-02-06T17:00:29+0100 - 3.34 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-02-06T17:00:30+0100 - 0.00 B - Total: 2015-02-06T17:00:30+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-02-06T17:00:30+0100 - 0.00 B 2015-02-06 16:00:30.778+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-02-06 16:00:30.816+0000 INFO [org.neo4j]: Database is now ready 2015-02-06 16:00:32.050+0000 INFO [org.neo4j]: Shutdown started 2015-02-06 16:00:32.051+0000 INFO [org.neo4j]: Database is now unavailable 2015-02-06 16:00:32.054+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-02-06 16:00:32.055+0000 INFO [org.neo4j]: TM shutting down 2015-02-06 16:00:32.061+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-02-06 16:00:32.062+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-02-06 16:00:32.063+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-02-06 16:00:32.064+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.064+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.065+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.066+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-02-06 16:00:32.066+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-02-06 16:00:32.067+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.068+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=140 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.069+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=82 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.070+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.071+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=160 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.072+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.073+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-02-06 16:00:32.074+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-02-06 16:00:32.075+0000 INFO [org.neo4j]: NeoStore closed 2015-02-06 16:00:32.075+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-02-06 16:00:32.075+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-06-04 10:16:00.045+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-06-04 10:16:00.147+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-06-04 10:16:00.149+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-06-04 10:16:00.152+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-06-04 10:16:00.152+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 6.71 GB Committed virtual memory: 6.79 GB Total swap space: 4.00 GB Free swap space: 993.75 MB 2015-06-04 10:16:00.157+0000 INFO [org.neo4j]: JVM memory information: Free memory: 244.94 MB Total memory: 310.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=3.31 MB, used=3.26 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=129.00 MB, used=45.21 MB, max=1.31 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.49 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=11.87 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=25.50 MB, used=25.18 MB, max=82.00 MB, threshold=0.00 B 2015-06-04 10:16:00.164+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.3; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 78 Process id: 38491@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-06-04 10:16:00.167+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/current/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/current/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/current, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-06-04 10:16:00.167+0000 INFO [org.neo4j]: Java classpath: [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.3/lib/groovy-2.4.3.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-test-2.4.3.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-launcher-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-xml-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-json-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-groovysh-2.4.3.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-bsf-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jsp-api-2.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-docgenerator-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-servlet-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-junit-1.9.4.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jcommander-1.47.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-jsr223-2.4.3.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-testng-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jline-2.12.jar [classpath + loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-2.4.3.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/multiverse-core-0.7.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/gpars-1.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/servlet-api-2.4.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/commons-logging-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-templates-2.4.3.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-console-2.4.3.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/xmlpull-1.1.3.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jansi-1.11.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/qdox-1.12.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ivy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/bsf-2.4.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jsr166y-1.7.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/junit-4.12.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-antlr-1.9.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/hamcrest-core-1.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-ant-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-groovydoc-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/openbeans-1.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-nio-2.4.3.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/testng-6.8.13.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-sql-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-swing-2.4.3.jar [loader.1] file:/projects/git/GroovyInAction/listings/chap13/./ [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-jmx-2.4.3.jar 2015-06-04 10:16:00.172+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/GroovyInAction/listings/chap13 2015-06-04 10:16:00.172+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/GroovyInAction/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/current/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/current/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/current/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/current sun.cpu.isalist = 2015-06-04 10:16:00.172+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:e42b:b3ff:fef6:4282%9 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%4 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-06-04 10:16:00.175+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-06-04 10:16:00.247+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-06-04 10:16:00.248+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-06-04 10:16:00.248+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-06-04 10:16:00.250+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-06-04 10:16:00.250+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-06-04 10:16:00.251+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-06-04 10:16:00.251+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-06-04 10:16:00.252+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-06-04 10:16:00.267+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=5740b) 2015-06-04 10:16:00.270+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=2380b) 2015-06-04 10:16:00.270+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-06-04 10:16:00.272+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=1050b) 2015-06-04 10:16:00.273+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-06-04 10:16:00.274+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-06-04 10:16:00.275+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-06-04 10:16:00.529+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=7, lastTxId=16 (clean) 2015-06-04 10:16:00.534+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-06-04 10:16:00.540+0000 INFO [org.neo4j]: Kernel health set to OK 2015-06-04 10:16:00.551+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=7, lastTxId=1 (clean) 2015-06-04 10:16:00.555+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-06-04 10:16:00.555+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-06-04 10:16:00.558+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-06-04 10:16:00.558+0000 INFO [org.neo4j]: Neo4j component versions: 2015-06-04 10:16:00.559+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:00.559+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:00.559+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-06-04 10:16:00.561+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-06-04 10:16:00.562+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-06-04 10:16:00.562+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-06-04 10:16:00.562+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-06-04 10:16:00.562+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=70 high=69 RelationshipStore: used=70 high=69 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=140 high=139 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-06-04 10:16:00.563+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-06-04 10:16:00.563+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-06-04 10:16:00.563+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-06-04 10:16:00.563+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-06-04 10:16:00.563+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 127505285120 / 25 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-02-06T17:00:32+0100 - 40.00 B lucene.log.1: 2015-06-04T12:16:00+0200 - 16.00 B lucene.log.active: 2015-06-04T12:16:00+0200 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B lucene.log.v1: 2015-02-02T02:28:48+0100 - 16.00 B lucene.log.v2: 2015-02-02T02:29:26+0100 - 16.00 B lucene.log.v3: 2015-02-06T01:41:41+0100 - 16.00 B lucene.log.v4: 2015-02-06T01:41:44+0100 - 16.00 B lucene.log.v5: 2015-02-06T17:00:29+0100 - 16.00 B lucene.log.v6: 2015-02-06T17:00:32+0100 - 16.00 B - Total: 2015-06-04T12:16:00+0200 - 172.00 B lock: 2015-06-04T12:16:00+0200 - 0.00 B messages.log: 2015-06-04T12:16:00+0200 - 197.17 kB neostore: 2015-06-04T12:16:00+0200 - 81.00 B neostore.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.labeltokenstore.db: 2015-06-04T12:16:00+0200 - 0.00 B neostore.labeltokenstore.db.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.labeltokenstore.db.names: 2015-06-04T12:16:00+0200 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.nodestore.db: 2015-06-04T12:16:00+0200 - 1.03 kB neostore.nodestore.db.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.nodestore.db.labels: 2015-06-04T12:16:00+0200 - 68.00 B neostore.nodestore.db.labels.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.propertystore.db: 2015-06-04T12:16:00+0200 - 5.61 kB neostore.propertystore.db.arrays: 2015-06-04T12:16:00+0200 - 128.00 B neostore.propertystore.db.arrays.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.propertystore.db.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.propertystore.db.index: 2015-06-04T12:16:00+0200 - 54.00 B neostore.propertystore.db.index.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.propertystore.db.index.keys: 2015-06-04T12:16:00+0200 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.propertystore.db.strings: 2015-06-04T12:16:00+0200 - 128.00 B neostore.propertystore.db.strings.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.relationshipgroupstore.db: 2015-06-04T12:16:00+0200 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.relationshipstore.db: 2015-06-04T12:16:00+0200 - 2.32 kB neostore.relationshipstore.db.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.relationshiptypestore.db: 2015-06-04T12:16:00+0200 - 10.00 B neostore.relationshiptypestore.db.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.relationshiptypestore.db.names: 2015-06-04T12:16:00+0200 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-06-04T12:16:00+0200 - 9.00 B neostore.schemastore.db: 2015-06-04T12:16:00+0200 - 64.00 B neostore.schemastore.db.id: 2015-06-04T12:16:00+0200 - 9.00 B nioneo_logical.log.1: 2015-06-04T12:16:00+0200 - 16.00 B nioneo_logical.log.active: 2015-06-04T12:16:00+0200 - 4.00 B nioneo_logical.log.v0: 2015-02-01T17:39:30+0100 - 4.52 kB nioneo_logical.log.v1: 2015-02-02T02:28:48+0100 - 3.34 kB nioneo_logical.log.v2: 2015-02-02T02:29:26+0100 - 3.34 kB nioneo_logical.log.v3: 2015-02-06T01:41:41+0100 - 3.34 kB nioneo_logical.log.v4: 2015-02-06T01:41:44+0100 - 3.34 kB nioneo_logical.log.v5: 2015-02-06T17:00:29+0100 - 3.34 kB nioneo_logical.log.v6: 2015-02-06T17:00:32+0100 - 3.34 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-06-04T12:16:00+0200 - 0.00 B - Total: 2015-06-04T12:16:00+0200 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-06-04T12:16:00+0200 - 0.00 B 2015-06-04 10:16:00.577+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-06-04 10:16:00.624+0000 INFO [org.neo4j]: Database is now ready 2015-06-04 10:16:00.866+0000 INFO [org.neo4j]: Shutdown started 2015-06-04 10:16:00.867+0000 INFO [org.neo4j]: Database is now unavailable 2015-06-04 10:16:00.870+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-06-04 10:16:00.870+0000 INFO [org.neo4j]: TM shutting down 2015-06-04 10:16:00.875+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-06-04 10:16:00.876+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-06-04 10:16:00.877+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-06-04 10:16:00.878+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.878+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.879+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.880+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-06-04 10:16:00.880+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-06-04 10:16:00.881+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.882+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=20 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.883+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=10 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.883+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.884+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=10 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.885+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.885+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:00.886+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-06-04 10:16:00.887+0000 INFO [org.neo4j]: NeoStore closed 2015-06-04 10:16:00.887+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-06-04 10:16:00.888+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- 2015-06-04 10:16:01.881+0000 INFO [org.neo4j]: No locking implementation specified, defaulting to 'community' 2015-06-04 10:16:01.946+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics START --- 2015-06-04 10:16:01.947+0000 INFO [org.neo4j]: Neo4j Kernel properties: neostore.propertystore.db.mapped_memory=1326M neostore.nodestore.db.mapped_memory=368M neostore.relationshipstore.db.mapped_memory=1624M neostore.propertystore.db.strings.mapped_memory=1127M store_dir=marathon neostore.propertystore.db.arrays.mapped_memory=1277M ephemeral=false 2015-06-04 10:16:01.949+0000 INFO [org.neo4j]: Diagnostics providers: org.neo4j.kernel.configuration.Config org.neo4j.kernel.info.DiagnosticsManager SYSTEM_MEMORY JAVA_MEMORY OPERATING_SYSTEM JAVA_VIRTUAL_MACHINE CLASSPATH LIBRARY_PATH SYSTEM_PROPERTIES NETWORK 2015-06-04 10:16:01.950+0000 INFO [org.neo4j]: System memory information: Total Physical memory: 16.00 GB Free Physical memory: 6.62 GB Committed virtual memory: 6.81 GB Total swap space: 4.00 GB Free swap space: 993.75 MB 2015-06-04 10:16:01.951+0000 INFO [org.neo4j]: JVM memory information: Free memory: 154.50 MB Total memory: 310.00 MB Max memory: 3.56 GB Garbage Collector: PS Scavenge: [PS Eden Space, PS Survivor Space] Garbage Collector: PS MarkSweep: [PS Eden Space, PS Survivor Space, PS Old Gen, PS Perm Gen] Memory Pool: Code Cache (Non-heap memory): committed=4.19 MB, used=4.08 MB, max=48.00 MB, threshold=0.00 B Memory Pool: PS Eden Space (Heap memory): committed=129.00 MB, used=126.13 MB, max=1.30 GB, threshold=? Memory Pool: PS Survivor Space (Heap memory): committed=10.50 MB, used=10.48 MB, max=10.50 MB, threshold=? Memory Pool: PS Old Gen (Heap memory): committed=170.50 MB, used=21.41 MB, max=2.67 GB, threshold=0.00 B Memory Pool: PS Perm Gen (Non-heap memory): committed=33.50 MB, used=33.47 MB, max=82.00 MB, threshold=0.00 B 2015-06-04 10:16:01.953+0000 INFO [org.neo4j]: Operating system information: Operating System: Mac OS X; version: 10.10.3; arch: x86_64; cpus: 8 Max number of file descriptors: 10240 Number of open file descriptors: 101 Process id: 38491@Dierk-Konigs-MacBook-Pro.local Byte order: LITTLE_ENDIAN Local timezone: Europe/Zurich 2015-06-04 10:16:01.953+0000 INFO [org.neo4j]: JVM information: VM Name: Java HotSpot(TM) 64-Bit Server VM VM Vendor: Oracle Corporation VM Version: 24.51-b03 JIT compiler: HotSpot 64-Bit Tiered Compilers VM Arguments: [-Dscript.name=/Users/dierkkoenig/.gvm/groovy/current/bin/groovy, -Dprogram.name=groovy, -Dgroovy.starter.conf=/Users/dierkkoenig/.gvm/groovy/current/conf/groovy-starter.conf, -Dgroovy.home=/Users/dierkkoenig/.gvm/groovy/current, -Dtools.jar=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar] 2015-06-04 10:16:01.954+0000 INFO [org.neo4j]: Java classpath: [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-scala_2.10/jars/parboiled-scala_2.10-1.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-test-2.4.3.jar [loader.2] file:/Users/dierkkoenig/.gvm/groovy/2.4.3/lib/groovy-2.4.3.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-configuration/commons-configuration/jars/commons-configuration-1.6.jar [loader.3] file:/Users/dierkkoenig/Library/Java/Extensions/libJNPRAuthKit.jnilib [loader.3] file:/System/Library/Java/Extensions/vecmath.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-xml-2.4.3.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunec.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jsp-api-2.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-junit-1.9.4.jar [loader.3] file:/System/Library/Java/Extensions/libJ3D.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jcommander-1.47.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-jsr223-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jline-2.12.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-lang/commons-lang/jars/commons-lang-2.4.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/localedata.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/charsets.jar [loader.3] file:/System/Library/Java/Extensions/j3daudio.jar [loader.3] file:/System/Library/Java/Extensions/j3dcore.jar [loader.3] file:/usr/lib/java/libjdns_sd.jnilib [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-management/jars/neo4j-management-2.1.6.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/zipfs.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-groovy/jars/gremlin-groovy-2.6.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/classes [loader.3] file:/System/Library/Java/Extensions/jai_core.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/xmlpull-1.1.3.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jansi-1.11.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-1.9.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.gremlin/gremlin-java/jars/gremlin-java-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ivy-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/bsf-2.4.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/junit-4.12.jar [loader.3] file:/Library/Java/Extensions/RXTXcomm.jar [loader.1] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-antlr-1.9.4.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.geronimo.specs/geronimo-jta_1.1_spec/jars/geronimo-jta_1.1_spec-1.1.1.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/dnsns.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/hamcrest-core-1.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-ant-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-groovydoc-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/openbeans-1.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-commons/jars/neo4j-cypher-commons-2.1.6.jar [loader.3] file:/System/Library/Java/Extensions/AppleScriptEngine.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/testng-6.8.13.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/xstream-1.4.7.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-sql-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-swing-2.4.3.jar [loader.1] file:/projects/git/GroovyInAction/listings/chap13/./ [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.parboiled/parboiled-core/jars/parboiled-core-1.1.6.jar [loader.3] file:/System/Library/Java/Extensions/dns_sd.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jce.jar [loader.3] file:/System/Library/Java/Extensions/MRJToolkit.jar [loader.3] file:/opt/subversion/lib/libsvnjavahl-1.0.0.0.dylib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils/jars/commons-beanutils-1.7.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/sunrsasign.jar [loader.3] file:/System/Library/Java/Extensions/libmlib_jai.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/ant-launcher-1.9.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-json-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-groovysh-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-bsf-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-docgenerator-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-servlet-2.4.3.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-digester/commons-digester/jars/commons-digester-1.8.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.0/jars/neo4j-cypher-compiler-2.0-2.0.4.jar [loader.3] file:/System/Library/Java/Extensions/mlibwrapper_jai.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-primitive-collections/jars/neo4j-primitive-collections-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-testng-2.4.3.jar [classpath + loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-2.4.3.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.apache.lucene/lucene-core/jars/lucene-core-3.6.2.jar [loader.3] file:/Library/Java/Extensions/librxtxSerial.jnilib [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher/jars/neo4j-cypher-2.1.6.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DAudio.jnilib [loader.3] file:/System/Library/Java/Extensions/libAppleScriptEngine.jnilib [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jfr.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.scala-lang/scala-library/jars/scala-library-2.10.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/multiverse-core-0.7.0.jar [loader.3] file:/System/Library/Java/Extensions/libJ3DUtils.jnilib [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/gpars-1.2.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-kernel/jars/neo4j-kernel-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/servlet-api-2.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/commons-logging-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-templates-2.4.3.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-console-2.4.3.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/jsse.jar [loader.3] file:/System/Library/Java/Extensions/j3dutils.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-lucene-index/jars/neo4j-lucene-index-2.1.6.jar [loader.1] file:/Users/dierkkoenig/.groovy/grapes/org.hsqldb/hsqldb/jars/hsqldb-2.3.2.jar [loader.3] file:/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar [loader.3] file:/System/Library/Java/Extensions/jai_codec.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-beanutils/commons-beanutils-core/jars/commons-beanutils-core-1.8.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-neo4j2-graph/jars/blueprints-neo4j2-graph-2.6.0.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/qdox-1.12.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop.blueprints/blueprints-core/jars/blueprints-core-2.6.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-2.1/jars/neo4j-cypher-compiler-2.1-2.1.6.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/resources.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/jsr166y-1.7.0.jar [bootstrap] /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/commons-collections/commons-collections/jars/commons-collections-3.2.1.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-nio-2.4.3.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.tinkerpop/pipes/jars/pipes-2.6.0.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/com.googlecode.concurrentlinkedhashmap/concurrentlinkedhashmap-lru/jars/concurrentlinkedhashmap-lru-1.4.1.jar [loader.0] file:/Users/dierkkoenig/.groovy/grapes/org.neo4j/neo4j-cypher-compiler-1.9/jars/neo4j-cypher-compiler-1.9-2.0.4.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/commons-cli-1.2.jar [loader.1] file:/Users/dierkkoenig/.gvm/groovy/current/lib/groovy-jmx-2.4.3.jar 2015-06-04 10:16:01.958+0000 INFO [org.neo4j]: Library path: /Users/dierkkoenig/Library/Java/Extensions /Library/Java/Extensions /Network/Library/Java/Extensions /System/Library/Java/Extensions /usr/lib/java /projects/git/GroovyInAction/listings/chap13 2015-06-04 10:16:01.958+0000 INFO [org.neo4j]: System.properties: sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib user.country.format = CH gopherProxySet = false path.separator = : file.encoding.pkg = sun.io user.country = DE sun.java.launcher = SUN_STANDARD sun.os.patch.level = unknown program.name = groovy user.dir = /projects/git/GroovyInAction/listings/chap13 tools.jar = /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/lib/tools.jar sun.jnu.encoding = UTF-8 script.name = /Users/dierkkoenig/.gvm/groovy/current/bin/groovy sun.management.compiler = HotSpot 64-Bit Tiered Compilers http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 user.home = /Users/dierkkoenig user.timezone = Europe/Zurich file.encoding = UTF-8 user.name = dierkkoenig sun.java.command = org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /Users/dierkkoenig/.gvm/groovy/current/conf/groovy-starter.conf --classpath . ../../test sun.arch.data.model = 64 user.language = de awt.toolkit = sun.lwawt.macosx.LWCToolkit file.separator = / sun.io.unicode.encoding = UnicodeBig sun.cpu.endian = little groovy.starter.conf = /Users/dierkkoenig/.gvm/groovy/current/conf/groovy-starter.conf socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16 ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16 groovy.home = /Users/dierkkoenig/.gvm/groovy/current sun.cpu.isalist = 2015-06-04 10:16:01.959+0000 INFO [org.neo4j]: Network information: Interface awdl0: address: fe80:0:0:0:e42b:b3ff:fef6:4282%9 Interface en0: address: fe80:0:0:0:2acf:e9ff:fe19:ca6d%4 address: 10.0.1.19 Interface lo0: address: fe80:0:0:0:0:0:0:1%1 address: 0:0:0:0:0:0:0:1 address: 127.0.0.1 2015-06-04 10:16:01.959+0000 INFO [org.neo4j]: --- INITIALIZED diagnostics END --- 2015-06-04 10:16:02.025+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=114b) 2015-06-04 10:16:02.026+0000 INFO [org.neo4j]: [marathon/neostore.relationshiptypestore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=10b) 2015-06-04 10:16:02.027+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db.names] brickCount=0 brickSize=0b mappedMem=0b (storeSize=38b) 2015-06-04 10:16:02.027+0000 INFO [org.neo4j]: [marathon/neostore.labeltokenstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=0b) 2015-06-04 10:16:02.028+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.strings] brickCount=0 brickSize=1181696b mappedMem=1181745152b (storeSize=128b) 2015-06-04 10:16:02.028+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index.keys] brickCount=0 brickSize=0b mappedMem=0b (storeSize=266b) 2015-06-04 10:16:02.028+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.index] brickCount=0 brickSize=0b mappedMem=0b (storeSize=54b) 2015-06-04 10:16:02.029+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db.arrays] brickCount=0 brickSize=1339008b mappedMem=1339031552b (storeSize=128b) 2015-06-04 10:16:02.045+0000 INFO [org.neo4j]: [marathon/neostore.propertystore.db] brickCount=0 brickSize=1390392b mappedMem=1390411776b (storeSize=6560b) 2015-06-04 10:16:02.047+0000 INFO [org.neo4j]: [marathon/neostore.relationshipstore.db] brickCount=0 brickSize=1702856b mappedMem=1702887424b (storeSize=2720b) 2015-06-04 10:16:02.047+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db.labels] brickCount=0 brickSize=0b mappedMem=0b (storeSize=68b) 2015-06-04 10:16:02.049+0000 INFO [org.neo4j]: [marathon/neostore.nodestore.db] brickCount=0 brickSize=385875b mappedMem=385875968b (storeSize=1200b) 2015-06-04 10:16:02.050+0000 INFO [org.neo4j]: [marathon/neostore.schemastore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=64b) 2015-06-04 10:16:02.054+0000 INFO [org.neo4j]: [marathon/neostore.relationshipgroupstore.db] brickCount=0 brickSize=0b mappedMem=0b (storeSize=25b) 2015-06-04 10:16:02.054+0000 INFO [org.neo4j]: [marathon/neostore] brickCount=0 brickSize=0b mappedMem=0b (storeSize=81b) 2015-06-04 10:16:02.194+0000 INFO [org.neo4j]: Opened logical log [marathon/nioneo_logical.log.1] version=8, lastTxId=17 (clean) 2015-06-04 10:16:02.202+0000 INFO [org.neo4j]: TM opening log: marathon/tm_tx_log.1 2015-06-04 10:16:02.206+0000 INFO [org.neo4j]: Kernel health set to OK 2015-06-04 10:16:02.213+0000 INFO [org.neo4j]: Opened logical log [marathon/index/lucene.log.1] version=8, lastTxId=1 (clean) 2015-06-04 10:16:02.217+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions START --- 2015-06-04 10:16:02.217+0000 INFO [org.neo4j]: Graph Database: org.neo4j.kernel.EmbeddedGraphDatabase StoreId{creationTime=1422808769411, randomId=1762119504651947014, storeVersion=14406081294923270, upgradeTime=1422808769411, upgradeId=1762119504651947014} 2015-06-04 10:16:02.233+0000 INFO [org.neo4j]: Kernel version: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6 2015-06-04 10:16:02.233+0000 INFO [org.neo4j]: Neo4j component versions: 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Lucene Index (neo4j-lucene-index), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.1 (neo4j-cypher-compiler-2.1), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Graph Database Kernel (neo4j-kernel), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Cypher (neo4j-cypher), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Graph DB Monitoring and Management tools (neo4j-management), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 2.0 (neo4j-cypher-compiler-2.0), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Cypher Compiler 1.9 (neo4j-cypher-compiler-1.9), version: 2.0.4; revision: 2.0.4:2.0-maint:130/4a7d10bc274a5d26a180bbe9df25100e8a694748 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: Neo4j - Cypher Commons (neo4j-cypher-commons), version: 2.1.6; revision: 2.1.6:2.1-maint:605/0d7f25fc608f15c54ec1a01f4ba4564ebfb1071a 2015-06-04 10:16:02.235+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:Versions END --- 2015-06-04 10:16:02.237+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS START --- 2015-06-04 10:16:02.237+0000 INFO [org.neo4j]: Store versions: Store versions: NeoStore v0.A.3 SchemaStore v0.A.3 NodeStore v0.A.3 RelationshipStore v0.A.3 RelationshipTypeStore v0.A.3 LabelTokenStore v0.A.3 PropertyStore v0.A.3 PropertyIndexStore v0.A.3 StringPropertyStore v0.A.3 ArrayPropertyStore v0.A.3 RelationshipGroupStore v0.A.3 2015-06-04 10:16:02.238+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_VERSIONS END --- 2015-06-04 10:16:02.238+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE START --- 2015-06-04 10:16:02.238+0000 INFO [org.neo4j]: Id usage: Id usage: SchemaStore: used=1 high=0 NodeStore: used=80 high=79 RelationshipStore: used=80 high=79 RelationshipTypeStore: used=2 high=1 LabelTokenStore: used=0 high=-1 PropertyStore: used=160 high=159 PropertyIndexStore: used=6 high=5 StringPropertyStore: used=1 high=0 ArrayPropertyStore: used=1 high=0 RelationshipGroupStore: used=1 high=0 2015-06-04 10:16:02.238+0000 INFO [org.neo4j]: --- STARTED diagnostics for NEO_STORE_ID_USAGE END --- 2015-06-04 10:16:02.238+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS START --- 2015-06-04 10:16:02.238+0000 INFO [org.neo4j]: --- STARTED diagnostics for PERSISTENCE_WINDOW_POOL_STATS END --- 2015-06-04 10:16:02.239+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles START --- 2015-06-04 10:16:02.239+0000 INFO [org.neo4j]: Disk space on partition (Total / Free / Free %): 499082485760 / 127505190912 / 25 Storage files: (filename : modification date - size) active_tx_log: 2015-02-01T17:39:29+0100 - 11.00 B index: lucene-store.db: 2015-06-04T12:16:00+0200 - 40.00 B lucene.log.1: 2015-06-04T12:16:02+0200 - 16.00 B lucene.log.active: 2015-06-04T12:16:02+0200 - 4.00 B lucene.log.v0: 2015-02-01T17:39:30+0100 - 16.00 B lucene.log.v1: 2015-02-02T02:28:48+0100 - 16.00 B lucene.log.v2: 2015-02-02T02:29:26+0100 - 16.00 B lucene.log.v3: 2015-02-06T01:41:41+0100 - 16.00 B lucene.log.v4: 2015-02-06T01:41:44+0100 - 16.00 B lucene.log.v5: 2015-02-06T17:00:29+0100 - 16.00 B lucene.log.v6: 2015-02-06T17:00:32+0100 - 16.00 B lucene.log.v7: 2015-06-04T12:16:00+0200 - 16.00 B - Total: 2015-06-04T12:16:02+0200 - 188.00 B lock: 2015-06-04T12:16:02+0200 - 0.00 B messages.log: 2015-06-04T12:16:02+0200 - 225.00 kB neostore: 2015-06-04T12:16:02+0200 - 81.00 B neostore.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.labeltokenstore.db: 2015-06-04T12:16:02+0200 - 0.00 B neostore.labeltokenstore.db.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.labeltokenstore.db.names: 2015-06-04T12:16:02+0200 - 38.00 B neostore.labeltokenstore.db.names.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.nodestore.db: 2015-06-04T12:16:02+0200 - 1.17 kB neostore.nodestore.db.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.nodestore.db.labels: 2015-06-04T12:16:02+0200 - 68.00 B neostore.nodestore.db.labels.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.propertystore.db: 2015-06-04T12:16:02+0200 - 6.41 kB neostore.propertystore.db.arrays: 2015-06-04T12:16:02+0200 - 128.00 B neostore.propertystore.db.arrays.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.propertystore.db.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.propertystore.db.index: 2015-06-04T12:16:02+0200 - 54.00 B neostore.propertystore.db.index.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.propertystore.db.index.keys: 2015-06-04T12:16:02+0200 - 266.00 B neostore.propertystore.db.index.keys.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.propertystore.db.strings: 2015-06-04T12:16:02+0200 - 128.00 B neostore.propertystore.db.strings.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.relationshipgroupstore.db: 2015-06-04T12:16:02+0200 - 25.00 B neostore.relationshipgroupstore.db.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.relationshipstore.db: 2015-06-04T12:16:02+0200 - 2.66 kB neostore.relationshipstore.db.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.relationshiptypestore.db: 2015-06-04T12:16:02+0200 - 10.00 B neostore.relationshiptypestore.db.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.relationshiptypestore.db.names: 2015-06-04T12:16:02+0200 - 114.00 B neostore.relationshiptypestore.db.names.id: 2015-06-04T12:16:02+0200 - 9.00 B neostore.schemastore.db: 2015-06-04T12:16:02+0200 - 64.00 B neostore.schemastore.db.id: 2015-06-04T12:16:02+0200 - 9.00 B nioneo_logical.log.1: 2015-06-04T12:16:02+0200 - 16.00 B nioneo_logical.log.active: 2015-06-04T12:16:02+0200 - 4.00 B nioneo_logical.log.v6: 2015-02-06T17:00:32+0100 - 3.34 kB nioneo_logical.log.v7: 2015-06-04T12:16:00+0200 - 3.34 kB schema: label: lucene: segments.gen: 2015-02-01T17:39:30+0100 - 20.00 B segments_1: 2015-02-01T17:39:30+0100 - 32.00 B write.lock: 2015-06-04T12:16:02+0200 - 0.00 B - Total: 2015-06-04T12:16:02+0200 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B - Total: 2015-02-01T17:39:29+0100 - 52.00 B store_lock: 2015-02-01T17:39:29+0100 - 0.00 B tm_tx_log.1: 2015-06-04T12:16:02+0200 - 0.00 B 2015-06-04 10:16:02.247+0000 INFO [org.neo4j]: --- STARTED diagnostics for KernelDiagnostics:StoreFiles END --- 2015-06-04 10:16:02.288+0000 INFO [org.neo4j]: Database is now ready 2015-06-04 10:16:03.553+0000 INFO [org.neo4j]: Shutdown started 2015-06-04 10:16:03.554+0000 INFO [org.neo4j]: Database is now unavailable 2015-06-04 10:16:03.558+0000 INFO [org.neo4j]: Closed log marathon/index/lucene.log 2015-06-04 10:16:03.558+0000 INFO [org.neo4j]: TM shutting down 2015-06-04 10:16:03.564+0000 INFO [org.neo4j]: Closed log marathon/nioneo_logical.log 2015-06-04 10:16:03.565+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db.names hit=0 miss=4 switches=0 ooe=0 2015-06-04 10:16:03.566+0000 INFO [org.neo4j]: marathon/neostore.relationshiptypestore.db hit=0 miss=2 switches=0 ooe=0 2015-06-04 10:16:03.566+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db.names hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.567+0000 INFO [org.neo4j]: marathon/neostore.labeltokenstore.db hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.568+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.strings hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.569+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index.keys hit=0 miss=12 switches=0 ooe=0 2015-06-04 10:16:03.569+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.index hit=0 miss=6 switches=0 ooe=0 2015-06-04 10:16:03.570+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db.arrays hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.571+0000 INFO [org.neo4j]: marathon/neostore.propertystore.db hit=180 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.572+0000 INFO [org.neo4j]: marathon/neostore.relationshipstore.db hit=106 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.573+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db.labels hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.574+0000 INFO [org.neo4j]: marathon/neostore.nodestore.db hit=210 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.574+0000 INFO [org.neo4j]: marathon/neostore.schemastore.db hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.575+0000 INFO [org.neo4j]: marathon/neostore.relationshipgroupstore.db hit=0 miss=0 switches=0 ooe=0 2015-06-04 10:16:03.576+0000 INFO [org.neo4j]: marathon/neostore hit=0 miss=18 switches=0 ooe=0 2015-06-04 10:16:03.578+0000 INFO [org.neo4j]: NeoStore closed 2015-06-04 10:16:03.578+0000 INFO [org.neo4j]: --- STOPPING diagnostics START --- 2015-06-04 10:16:03.578+0000 INFO [org.neo4j]: --- STOPPING diagnostics END --- ================================================ FILE: listings/chap13/marathon/store_lock ================================================ ================================================ FILE: listings/chap13/snippet1301_ConnectingWithGrab.groovy ================================================ @Grab('org.hsqldb:hsqldb:2.3.2') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql def url = 'jdbc:hsqldb:mem:GinA' def user = 'sa' def password = '' def driver = 'org.hsqldb.jdbcDriver' def sql = Sql.newInstance(url, user, password, driver) // use 'sql' instance ... // optional test of a system table within HSQLDB assert sql.firstRow('SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS')[0] == 1 sql.close() ================================================ FILE: listings/chap13/snippet1301_ConnectingWithInstance.groovy ================================================ import groovy.sql.Sql def url = 'jdbc:hsqldb:mem:GinA' def user = 'sa' def password = '' def driver = 'org.hsqldb.jdbcDriver' Sql.withInstance(url, user, password, driver) { sql -> // use 'sql' instance ... // optional test of a system table within HSQLDB assert sql.firstRow('SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS')[0] == 1 } ================================================ FILE: listings/chap13/snippet1301_ConnectingWithMap.groovy ================================================ import groovy.sql.Sql import static java.sql.ResultSet.CONCUR_READ_ONLY // ... def sql = Sql.newInstance( url: 'jdbc:hsqldb:mem:GinA', user: 'sa', password: '', driver: 'org.hsqldb.jdbcDriver', cacheStatements: true, resultSetConcurrency: CONCUR_READ_ONLY) // use 'sql' instance ... sql.close() ================================================ FILE: listings/chap13/snippet1301_ReadEachRow.groovy ================================================ import util.DbUtil import java.text.SimpleDateFormat def sql = DbUtil.create() DbUtil.populate(sql) println ' Athlete Info '.center(25, '-') def fmt = new SimpleDateFormat('dd. MMM yyyy (E)', Locale.US) sql.eachRow('SELECT * FROM Athlete') { athlete -> println athlete.firstname + ' ' + athlete.lastname println 'born on ' + fmt.format(athlete.dateOfBirth) println '-' * 25 } sql.close() ================================================ FILE: listings/chap13/snippet1301_ReadEachRowList.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) sql.eachRow('SELECT firstname, lastname FROM Athlete') { row -> println row[0] + ' ' + row[1] } sql.close() ================================================ FILE: listings/chap13/snippet1301_ReadQuery.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) sql.query('SELECT firstname, lastname FROM Athlete') { resultSet -> if (resultSet.next()) { print resultSet.getString(1) print ' ' println resultSet.getString('lastname') } } sql.close() ================================================ FILE: listings/chap13/snippet1301_ReadRows.groovy ================================================ import util.DbUtil def sql = DbUtil.create() DbUtil.populate(sql) List athletes = sql.rows('SELECT firstname, lastname FROM Athlete') println "There are ${athletes.size()} Athletes:" println athletes.collect{"${it[0]} ${it.lastname}"}.join(", ") sql.close() ================================================ FILE: listings/chap13/util/DbUtil.groovy ================================================ package util @Grab('org.hsqldb:hsqldb:2.3.2') @GrabConfig(systemClassLoader=true) import groovy.sql.Sql import java.util.logging.Level import java.util.logging.Logger class DbUtil { static Sql create() { def url = 'jdbc:hsqldb:mem:GinA' def user = 'sa' def password = '' def driver = 'org.hsqldb.jdbcDriver' def sql = Sql.newInstance(url, user, password, driver) sql.execute """ DROP TABLE Athlete IF EXISTS cascade; DROP TABLE Record IF EXISTS; """ sql.execute """ CREATE TABLE Athlete ( athleteId INTEGER GENERATED BY DEFAULT AS IDENTITY, firstname VARCHAR(64), lastname VARCHAR(64), dateOfBirth DATE, UNIQUE(athleteId) ); """ sql.execute ''' CREATE TABLE Record ( recordId INTEGER GENERATED BY DEFAULT AS IDENTITY, time INTEGER, -- in seconds venue VARCHAR(64), whenRun DATE, fkAthlete INTEGER, CONSTRAINT fk FOREIGN KEY (fkAthlete) REFERENCES Athlete (athleteId) ON DELETE CASCADE ); ''' sql } static void populate(sql) { insertAthlete(sql, 'Paul', 'Tergat', '1969-06-17') insertAthlete(sql, 'Khalid', 'Khannouchi', '1971-12-22') insertAthlete(sql, 'Ronaldo', 'da Costa', '1970-06-07') insertRecord(sql, 2, 4, 55, 'Berlin', '2003-09-28', 'Tergat') insertRecord(sql, 2, 5, 38, 'London', '2002-04-14', 'Khannouchi') insertRecord(sql, 2, 5, 42, 'Chicago', '1999-10-24', 'Khannouchi') insertRecord(sql, 2, 6, 05, 'Berlin', '1998-09-20', 'da Costa') } static void insertAthlete(sql, first, last, dob) { sql.execute """ INSERT INTO Athlete (firstname, lastname, dateOfBirth) VALUES (${first},${last},${dob}) """ } static void insertRecord(sql, h, m, s, venue, date, lastname) { def time = h * 60 * 60 + m * 60 + s sql.execute """ INSERT INTO Record (time, venue, whenRun, fkAthlete) SELECT $time, $venue, $date, athleteId FROM Athlete WHERE lastname=$lastname """ } // To enable logging, call the method below. You might also need // to adjust the logging.properties file in JRE_HOME/lib to have: // java.util.logging.ConsoleHandler.level = FINE static void enableLogging() { Logger.getLogger('groovy.sql').level = Level.FINE } } ================================================ FILE: listings/chap13/util/MarathonRelationships.groovy ================================================ package util @Grab('org.neo4j:neo4j-kernel:2.1.6') import org.neo4j.graphdb.* enum MarathonRelationships implements RelationshipType { set, broke } ================================================ FILE: listings/chap13/util/Neo4jUtil.groovy ================================================ package util @Grab('org.neo4j:neo4j-kernel:2.1.6') @Grab('org.neo4j:neo4j-lucene-index:2.1.6;transitive=false') @Grab('org.apache.lucene:lucene-core:3.6.2') import org.neo4j.graphdb.* import org.neo4j.graphdb.factory.GraphDatabaseFactory class Neo4jUtil { static create() { //#A def factory = new GraphDatabaseFactory() def db = factory.newEmbeddedDatabase("marathon") addShutdownHook { db.shutdown() } GraphDatabaseService.metaClass { createNode { Map properties -> def n = delegate.createNode() properties.each { k, v -> n[k] = v } n } } Node.metaClass { propertyMissing { String name, val -> delegate.setProperty(name, val) } propertyMissing { String name -> delegate.getProperty(name) } methodMissing { String name, args -> delegate.createRelationshipTo(args[0], MarathonRelationships."$name") } } Relationship.metaClass { propertyMissing { String name, val -> delegate.setProperty(name, val) } propertyMissing { String name -> delegate.getProperty(name) } } db } static insertAthlete(db, first, last, dob) { //#B db.createNode(first: first, last: last, dob: dob) } static insertRecord(db, h, m, s, venue, when, athlete) { //#C def secs = h * 60 * 60 + m * 60 + s def record = db.createNode(time: secs, venue: venue, when: when) athlete.set(record) record } } //#A Create database and turn on metaClass syntactic sugar //#B Utility method to create athlete //#C Utility method to create record ================================================ FILE: listings/chap14/Listing_14_01_Plan.txt ================================================ see: data/plan.xml ================================================ FILE: listings/chap14/Listing_14_02_DOM.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import javax.xml.parsers.DocumentBuilderFactory import static org.w3c.dom.Node.* def factory = DocumentBuilderFactory.newInstance() def builder = factory.newDocumentBuilder() def doc = builder.parse(new FileInputStream('data/plan.xml')) def plan = doc.documentElement String info(node) { switch (node.nodeType) { case ELEMENT_NODE: return "element: $node.nodeName" case ATTRIBUTE_NODE: return "attribute: $node.nodeName=$node.nodeValue" case TEXT_NODE: return "text: $node.nodeValue" } return "some other type: $node.nodeType" } assert info(plan) == 'element: plan' assert plan.childNodes.length == 5 //#1 // what we'd have to do without groovy-xml DGM methods //def firstWeek = null //for (int i = 0; !firstWeek && i < plan.childNodes.length; i++) { // if (plan.childNodes.item(i).nodeName == 'week') // firstWeek = plan.childNodes.item(i) //} def firstWeek = plan.childNodes.find { it.nodeName == 'week' } //#2 assert info(firstWeek) == 'element: week' def firstWeekCapacity = firstWeek.attributes.getNamedItem('capacity') assert info(firstWeekCapacity) == 'attribute: capacity=8' def firstTask = firstWeek.childNodes.item(1) //#3 assert info(firstTask) == 'element: task' def firstTaskText = firstTask.childNodes.item(0) assert info(firstTaskText) == 'text: easy' def firstTaskTitle = firstTask.attributes.getNamedItem('title') assert info(firstTaskTitle) == 'attribute: title=read XML chapter' def firstTaskTitleText = firstTaskTitle.childNodes.item(0) assert info(firstTaskTitleText) == 'text: read XML chapter' //#1 Element and whitespace children visible //#2 Object iteration method //#3 Indexed access ================================================ FILE: listings/chap14/Listing_14_03_DOM_Category.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.DOMBuilder import groovy.xml.dom.DOMCategory def doc = DOMBuilder.parse(new FileReader('data/plan.xml')) def plan = doc.documentElement use(DOMCategory) { assert plan.name() == 'plan' //|#1 assert plan.week[0].name() == 'week' //|#1 assert plan.week[0].'@capacity' == '8' // #2 assert plan.week.task[0].name() == 'task' assert plan.week.task[0].text() == 'easy' // #3 // bonus material below here for comparative purposes with later examples assert plan.week.task.size() == 5 assert plan.week.task.'@done'*.toInteger().sum() == 6 assert plan.week[1].task.every{ it.'@done' == '0' } // For legacy reasons, text nodes are regarded as children by // DOMCategory which yields slightly different code than for XmlParser // and XmlSlurper when using breadthFirst() and children() though // depthFirst() avoids these differences as it was introduced later def elementNames = { it.nodeName.startsWith('#') ? [] : [it.name] } assert plan.breadthFirst().iterator().collectMany(elementNames).join('->') == 'plan->week->week->task->task->task->task->task' assert plan.depthFirst()*.name().join('->') == 'plan->week->task->task->task->week->task->task' assert plan.'**'*.name().join('->') == 'plan->week->task->task->task->week->task->task' } ================================================ FILE: listings/chap14/Listing_14_04_XmlParser.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') def plan = new XmlParser().parse(new File('data/plan.xml')) // #1 assert plan.name() == 'plan' assert plan.week[0].name() == 'week' def firstTask = plan.week[0].task[0] // #2 assert firstTask.name() == 'task' assert firstTask.text() == 'easy' assert firstTask.@title == 'read XML chapter' // bonus examples below here for comparison with other listings assert plan.children().size() == 2 //def firstWeek = plan.children().find { it.name() == 'week' } //def firstWeek = plan.week[0] assert firstTask.'@title' == 'read XML chapter' assert plan.week.task.size() == 5 assert plan.week.task.@done*.toInteger().sum() == 6 assert plan.week[1].task.every{ it.@done == '0' } assert plan.breadthFirst()*.name().join('->') == 'plan->week->week->task->task->task->task->task' assert plan.depthFirst()*.name().join('->') == 'plan->week->task->task->task->week->task->task' assert plan.'**'*.name().join('->') == 'plan->week->task->task->task->week->task->task' ================================================ FILE: listings/chap14/Listing_14_05_XmlSlurper.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') def plan = new XmlSlurper().parse(new File('data/plan.xml')) assert plan.week.task.size() == 5 assert plan.week.task.@done*.toInteger().sum() == 6 assert plan.week[1].task.every{ it.@done == '0' } assert plan.breadthFirst()*.name().join('->') == 'plan->week->week->task->task->task->task->task' assert plan.depthFirst()*.name().join('->') == 'plan->week->task->task->task->week->task->task' assert plan.depthFirst()*.name() == plan.'**'*.name() // bonus material below here for comparison with other listings assert plan.name() == 'plan' assert plan.children().size() == 2 def firstWeek = plan.children().find { it.name() == 'week' } def firstTask = firstWeek.task[0] assert firstTask.name() == 'task' assert firstTask.text() == 'easy' assert firstTask.'@title' == 'read XML chapter' ================================================ FILE: listings/chap14/Listing_14_06_SAX.groovy ================================================ import javax.xml.parsers.SAXParserFactory import org.xml.sax.* import org.xml.sax.helpers.DefaultHandler class PlanHandler extends DefaultHandler { //#1 def underway = [] def upcoming = [] void startElement(String namespace, String localName, String qName, Attributes atts) { //#2 if (qName != 'task') return //#3 def title = atts.getValue('title') def total = atts.getValue('total') switch (atts.getValue('done')) { case '0' : upcoming << title ; break case { it != total } : underway << title ; break } } } def handler = new PlanHandler() def factory = SAXParserFactory.newInstance() def reader = factory.newSAXParser().XMLReader //#4 reader.contentHandler = handler new File('data/plan.xml').withInputStream { is -> reader.parse(new InputSource(is)) } assert handler.underway == [ 'use in current project' ] assert handler.upcoming == [ 're-read DB chapter', 'use DB/XML combination' ] ================================================ FILE: listings/chap14/Listing_14_07_StAX.groovy ================================================ // requires stax.jar and stax-api.jar for Java 1.5 import javax.xml.stream.* def input = 'file:data/plan.xml'.toURL() def underway = [] def upcoming = [] def eachStartElement(inputStream, Closure yield) { def token = XMLInputFactory.newInstance() .createXMLStreamReader(inputStream) //#1 try { while (token.hasNext()) { //#2 if (token.startElement) yield token token.next() } } finally { token?.close() inputStream?.close() } } class XMLStreamCategory { //|#3 static Object get(XMLStreamReader self, String key) { //|#3 return self.getAttributeValue(null, key) //|#3 } //|#3 } //|#3 use (XMLStreamCategory) { eachStartElement(input.openStream()) { element -> if (element.name.toString() != 'task') return switch (element.done) { case '0' : upcoming << element.title break case { it != element.total } : underway << element.title } } } assert underway == [ 'use in current project' ] assert upcoming == [ 're-read DB chapter', 'use DB/XML combination' ] ================================================ FILE: listings/chap14/Listing_14_08_XmlBoiler.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.MarkupBuilder void numberfy(Node node) { //#1 def atts = node.attributes() atts.keySet().grep(['capacity', 'total', 'done']).each { atts[it] = atts[it].toInteger() } node.each { if (it instanceof Node) numberfy(it) } } void taskStatus(task) { //#2 def atts = task.attributes() switch (atts.done) { case 0: atts.status = 'scheduled'; break case 1.. h1("Week No. $i: ${week.@status}") dl { week.task.each { task -> dt(class: task.@status, task.@title) dd("(${task.@done}/${task.@total}): ${task.@status}") } } } } } } def node = new XmlParser().parse(new File('data/plan.xml')) numberfy(node) //#|5 node.week.each { weekStatus(it) } //#|5 new File('data/GroovyPlans.html').withWriter { writer -> def builder = new MarkupBuilder(writer) htmlReport(builder, node) } ================================================ FILE: listings/chap14/Listing_14_09_XmlStreamer.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.StreamingMarkupBuilder def path = new XmlSlurper().parse(new File('data/plan.xml')) def builder = new StreamingMarkupBuilder() def copier = builder.bind{ mkp.yield(path) } def result = "$copier" assert result.startsWith('') ================================================ FILE: listings/chap14/Listing_14_10_StreamedHtml.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.StreamingMarkupBuilder def taskStatus(task) { //#1 switch (task.@done.toInteger()) { case 0: return 'scheduled' case 1.. h1("Week No. $i: ${owner.weekStatus(week)}") dl { week.task.each { task -> def status = owner.taskStatus(task) dt(class: status, task.@title) dd("(${task.@done}/${task.@total}): $status") } } } } } } def heater = new StreamingMarkupBuilder().bind(markup) //#5 def outfile = new File('data/StreamedGroovyPlans.html') outfile.withWriter{ it << heater } //#6 ================================================ FILE: listings/chap14/Listing_14_11_UpdateDomCategory.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.DOMBuilder import groovy.xml.XmlUtil import groovy.xml.dom.DOMCategory def doc = DOMBuilder.parse(new FileReader('data/plan.xml')) def plan = doc.documentElement use(DOMCategory) { plan.week[0].task[2]['@done'] = '2' // #1 plan.week[0].task[2].value = 'time saver' // #2 plan.week[1].task[1].replaceNode { task(done:'0', total:'4', title:'build web service') } // an alternative to replace node is remove then append // def oldTask = plan.week[1].task[1] // plan.week[1].removeChild(oldTask) // plan.week[1].appendNode('task', [done:'0', total:'4', // title:'build web service']) // plan.week[1].appendNode('task', [done:'0', total:'1', // title:'build web service client']) plan.week[1].task[1] + { task(done:'0', total:'1', title:'build web service client') } } UpdateChecker.check(XmlUtil.serialize(plan)) ================================================ FILE: listings/chap14/Listing_14_12_UpdateParser.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.XmlUtil def plan = new XmlParser().parse(new File('data/plan.xml')) plan.week[0].task[2].@done = '2' plan.week[0].task[2].value = 'time saver' plan.week[1].task[1].replaceNode { task(done:'0', total:'4', title:'build web service') } //plan.week[1].appendNode('task', [done:'0', total:'1', // title:'build web service client']) plan.week[1].task[1] + { task(done:'0', total:'1', title:'build web service client') } UpdateChecker.check(XmlUtil.serialize(plan)) ================================================ FILE: listings/chap14/Listing_14_13_UpdateSlurper.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.XmlUtil def plan = new XmlSlurper().parse(new File('data/plan.xml')) plan.week[0].task[2].@done = '2' plan.week[0].task[2] = 'time saver' plan.week[1].task[1].replaceNode { task(done:'0', total:'4', title:'build web service') } //plan.week[1].appendNode { // task(done:'0', total:'1', title:'build web service client') //} plan.week[1].task[1] + { task(done:'0', total:'1', title:'build web service client') } //plan.week[1] << { // task(done:'0', total:'1', title:'build web service client') //} UpdateChecker.check(XmlUtil.serialize(plan)) ================================================ FILE: listings/chap14/Listing_14_14_XPath.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.DOMBuilder import groovy.xml.dom.DOMCategory import javax.xml.xpath.XPathFactory import static javax.xml.xpath.XPathConstants.NODESET import static javax.xml.xpath.XPathConstants.NUMBER def doc = DOMBuilder.parse(new FileReader('data/plan.xml')) def plan = doc.documentElement def xpath = XPathFactory.newInstance().newXPath() def out = new StringBuilder() use(DOMCategory) { //#1 xpath.evaluate('//week', plan, NODESET).eachWithIndex { wk, i -> //#2 out << "\nWeek No. $i\n" int total = xpath.evaluate('sum(task/@total)', wk, NUMBER) //|#3 int done = xpath.evaluate('sum(task/@done)', wk, NUMBER) //|#3 out << " planned $total of ${wk.'@capacity'}\n" //#4 out << " done $done of $total" } } assert out.toString() == ''' Week No. 0 planned 7 of 8 done 6 of 7 Week No. 1 planned 4 of 8 done 0 of 4''' ================================================ FILE: listings/chap14/Listing_14_15_GroovyPlansTemplate.txt ================================================ see: data/GroovyPlans.template.html ================================================ FILE: listings/chap14/Listing_14_16_XPathTemplate.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-templates:2.2.0') import groovy.xml.DOMBuilder import groovy.xml.dom.DOMCategory import groovy.text.SimpleTemplateEngine as STE import javax.xml.xpath.XPathFactory import static javax.xml.xpath.XPathConstants.NODESET import static javax.xml.xpath.XPathConstants.NUMBER def doc = DOMBuilder.parse(new FileReader('data/plan.xml')) def plan = doc.documentElement def xpath = XPathFactory.newInstance().newXPath() def binding = [scale:1, weeks:[] ] use(DOMCategory) { xpath.evaluate('//week', plan, NODESET).each{ week -> //#1 binding.weeks << [ total: (int) xpath.evaluate('sum(task/@total)', week, NUMBER), done: (int) xpath.evaluate('sum(task/@done)', week, NUMBER), capacity: week.'@capacity'.toInteger() ] } } def max = binding.weeks.capacity.max() //#2 if (max > 0) binding.scale = 200.intdiv(max) def templateFile = new File('data/GroovyPlans.template.html') def template = new STE().createTemplate(templateFile) //#3 new File('data/XPathGroovyPlans.html').withWriter { it << template.make(binding) } ================================================ FILE: listings/chap14/Listing_14_17_JsonParser.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-json:2.2.0') import groovy.json.JsonSlurper // add .newReader() to the file in Groovy versions prior to 2.2.0 def plan = new JsonSlurper().parse(new File('data/plan.json')) assert plan.weeks[0].tasks[0].status == 'easy' assert plan.weeks[1].capacity == 8 assert plan.weeks[1].tasks[0].title == 're-read DB chapter' ================================================ FILE: listings/chap14/Listing_14_18_JsonBuilder.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-json:2.2.0') import groovy.json.JsonBuilder def builder = new JsonBuilder() builder.weeks { capacity '8' tasks( [{ done '0' total '4' title 'build web service' }, { done '0' total '1' title 'build web service client' }] ) } assert builder.toString() == '{"weeks":{"capacity":"8","tasks":[' + '{"done":"0","total":"4","title":"build web service"},' + '{"done":"0","total":"1","title":"build web service client"}' + ']}}' ================================================ FILE: listings/chap14/Listing_14_19_JsonBuilderLogic.groovy ================================================ import groovy.json.JsonBuilder def builder = new JsonBuilder() builder { invoices(1..3) { day -> //#1 invoice(date: "2015-01-0$day") { //#2 item(count: day) { //#2 product(name: 'ULC', dollar: 1499) //#2 } //#2 } //#2 } } assert builder.toPrettyString().startsWith( //#3 '''{ "invoices": [ { "invoice": [ { "date": "2015-01-01" ''') //#1 Pretended method can take collection and Closure //#2 Closure defines JSON for each item in collection //#4 Check the start of pretty output ================================================ FILE: listings/chap14/Listing_14_20_JsonOutputAthlete.groovy ================================================ import static groovy.json.JsonOutput.* def json = toJson([date: '2015-01-01', time: '6 am']) assert json == '{"date":"2015-01-01","time":"6 am"}' class Athlete { String first, last } def mj = new Athlete(first: 'Michael', last: 'Jordan') assert toJson(mj) == '{"first":"Michael","last":"Jordan"}' def pt = new Athlete(first: 'Paul', last: 'Tergat') def athletes = [basketball: mj, marathon: pt] json = toJson(athletes) assert prettyPrint(json) == ''' { "basketball": { "first": "Michael", "last": "Jordan" }, "marathon": { "first": "Paul", "last": "Tergat" } } '''.trim() ================================================ FILE: listings/chap14/UpdateChecker.groovy ================================================ class UpdateChecker { static check(text) { def updated = new XmlParser().parseText(text) updated.week[0].with { w0 -> assert w0.task.@done*.toInteger().sum() == 7 assert w0.find{ it.text() == 'time saver' } } updated.week[1].with { w1 -> assert w1.children().size() == 3 assert w1.find{ it.@total == "4" } assert w1.find{ it.@title == "build web service client" } assert !w1.find{ it.@title == "use DB/XML combination" } } } } ================================================ FILE: listings/chap14/data/GroovyPlans.html ================================================ Current Groovy progress

Week No. 0: in progress

read XML chapter
(2/2): finished
try some reporting
(3/3): finished
use in current project
(1/2): in progress

Week No. 1: scheduled

re-read DB chapter
(0/1): scheduled
use DB/XML combination
(0/3): scheduled
================================================ FILE: listings/chap14/data/GroovyPlans.template.html ================================================ Current Groovy progress <% weeks.eachWithIndex{ week, i -> %>

Week No. $i

<% ['capacity','total','done'].each{ attr -> %> <% } // end of attribute %>
$attr ${week[attr]}
 
<% } // end of week %> ================================================ FILE: listings/chap14/data/StreamedGroovyPlans.html ================================================ Current Groovy progress

Week No. 0: in progress

read XML chapter
(2/2): finished
try some reporting
(3/3): finished
use in current project
(1/2): in progress

Week No. 1: scheduled

re-read DB chapter
(0/1): scheduled
use DB/XML combination
(0/3): scheduled
================================================ FILE: listings/chap14/data/XPathGroovyPlans.html ================================================ Current Groovy progress

Week No. 0

capacity 8
 
total 7
 
done 6
 

Week No. 1

capacity 8
 
total 4
 
done 0
 
================================================ FILE: listings/chap14/data/plan.json ================================================ { "weeks": [ { "capacity": 8, "tasks": [ { "done": 2, "total": 2, "title": "read XML chapter", "status": "easy" }, { "done": 3, "total": 3, "title": "try some reporting", "status": "fun" }, { "done": 1, "total": 2, "title": "use in current project" } ] }, { "capacity": 8, "tasks": [ { "done": 0, "total": 1, "title": "re-read DB chapter" }, { "done": 0, "total": 3, "title": "use DB/XML combination" } ] } ]} ================================================ FILE: listings/chap14/data/plan.xml ================================================ easy fun ================================================ FILE: listings/chap14/data/style.css ================================================ body {font-family:sans-serif;} h1 { font-size: large; } dl { padding-left: 10px} dt { font-weight:bold; } dt.finished { font-weight:normal; text-decoration:line-through; } dd {} ================================================ FILE: listings/chap14/log4j.xml ================================================ ================================================ FILE: listings/chap15/Listing_15_01_RSS_bbcnews.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') def base = 'http://news.bbc.co.uk/rss/newsonline_uk_edition/' def url = base + 'front_page/rss091.xml' println 'The top three news today:' def items = new XmlParser().parse(url).channel[0].item for (item in items[0..2]) { println item.title.text() println item.link.text() println item.description.text() println '----' } /* The top three news today: Three Britons killed in balloon crash http://www.bbc.co.uk/news/uk-21588495... Three Britons are dead and another is in hospital... ---- Europe jitters over Italy deadlock http://www.bbc.co.uk/news/world-europe-21587123... European politicians and markets react anxiously after Italy's general election... ---- Russia meteor's origin tracked down http://www.bbc.co.uk/news/science-environment-21579422... Astronomers trace origin of meteor that broke up over Russia earlier this month... ---- */ /* ... Three Britons killed in balloon crash Three Britons are dead and another is in hospital... http://www.bbc.co.uk/news/uk-21588495... Tue, 26 Feb 2013 13:20:07 GMT ... ... */ ================================================ FILE: listings/chap15/Listing_15_02_ATOM_devworks.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.Namespace def url = 'http://www.ibm.com/developerworks/views/java/rss/' + 'libraryview.jsp?feed_by=atom' def atom = new Namespace('http://www.w3.org/2005/Atom') def numEntries = 3 //#A def entries = new XmlParser().parse(url)[atom.entry][0.. ... Java.next: The Java.next languages A new developerWorks series by Neal Ford that performs a deep comparison of three next-generation JVM languages: Groovy, Scala, and Clojure... 29 Jan 2013 05:00:00 +0000 ... ... */ /* 26 Feb 2013 Test automation and continuous integration with STAF/STAX 05 Feb 2013 HTML5 2D game development: Manipulating time, Part 1 29 Jan 2013 *Java.next: The Java.next languages 29 Jan 2013 Functional thinking: Why functional programming is on the rise 15 Jan 2013 Look-ahead Java deserialization 08 Jan 2013 HTML5 2D game development: Implementing Sprite behaviors 08 Jan 2013 Agile DevOps: Continuous software delivery in the cloud 19 Dec 2012 *Functional thinking: Laziness, Part 2 */ ================================================ FILE: listings/chap15/Listing_15_03_REST_jira_url.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') //@Grab('org.codehaus.groovy:groovy-json:2.2.0') import groovy.json.JsonSlurper class Jira { def base = 'https://issues.apache.org/jira/rest/api/latest/issue/' def slurper = new JsonSlurper() def query(key) { def httpConnection = new URL(base + key).openConnection() assert httpConnection.responseCode == httpConnection.HTTP_OK slurper.parse(httpConnection.inputStream.newReader()) } } def jira = new Jira() def response = jira.query("GROOVY-5999") response.fields.with { assert summary == "Make @Delegate work with @DelegatesTo" assert fixVersions.name == ['2.1.1'] assert resolutiondate.startsWith('2013-02-14') } ================================================ FILE: listings/chap15/Listing_15_04_REST_jira_httpb_get.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') //@Grab('org.codehaus.groovy:groovy-json:2.2.0') @Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') import groovyx.net.http.RESTClient def base = 'https://issues.apache.org/jira/rest/api/latest/' def jira = new RESTClient(base) jira.get(path: 'issue/GROOVY-5999') { resp, json -> assert resp.status == 200 json.fields.with { assert summary == "Make @Delegate work with @DelegatesTo" assert fixVersions.name == ['2.1.1'] assert resolutiondate.startsWith('2013-02-14') } } ================================================ FILE: listings/chap15/Listing_15_05_REST_currency_httpb_get.groovy ================================================ @Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') import groovyx.net.http.RESTClient def url = 'http://www.webservicex.net/CurrencyConvertor.asmx/' def converter = new RESTClient(url) def params = [FromCurrency: 'USD', ToCurrency: 'EUR'] converter.get(path: 'ConversionRate', query: params) { resp, data -> assert resp.status == 200 assert data.name() == 'double' println data.text() } // => http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=EUR // => 0.882 // => 0.882 // Apparently webservicex.net is having issues with their currency converter. Expect a ConversionRate of "-1". ================================================ FILE: listings/chap15/Listing_15_06_REST_currency_httpb_post.groovy ================================================ @Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') import groovyx.net.http.RESTClient import static groovyx.net.http.ContentType.URLENC def url = 'http://www.webservicex.net/CurrencyConvertor.asmx/' def converter = new RESTClient(url) def postBody = [FromCurrency: 'USD', ToCurrency: 'EUR'] converter.post(path: 'ConversionRate', body: postBody, requestContentType: URLENC) { resp, data -> assert resp.status == 200 assert data.name() == 'double' println data.text() } // => http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate // => 0.882 // => 0.882 ================================================ FILE: listings/chap15/Listing_15_07_REST_currency_jaxrs.groovy ================================================ @Grab('org.jboss.resteasy:resteasy-client:3.0.10.Final') import javax.ws.rs.client.ClientBuilder def client = ClientBuilder.newClient() def base = "http://www.webservicex.net/CurrencyConvertor.asmx" def response = client.target(base + '/ConversionRate') .queryParam("FromCurrency", "USD") .queryParam("ToCurrency", "EUR") .request().get(String) //#1 def rate = new XmlSlurper().parseText(response) assert rate.name() == 'double' println rate.text() //#1 specify a String response // => 0.882 ================================================ FILE: listings/chap15/Listing_15_08_REST_currency_jaxrs_proxy.groovy ================================================ @Grab('org.jboss.resteasy:resteasy-client:3.0.10.Final') import javax.ws.rs.GET import javax.ws.rs.Path import javax.ws.rs.Produces import javax.ws.rs.QueryParam import javax.ws.rs.client.ClientBuilder interface CurrencyConvertor { @GET @Path("ConversionRate") @Produces("application/xml") String convert(@QueryParam("FromCurrency") String from, @QueryParam("ToCurrency") String to) } def client = ClientBuilder.newClient() def base = "http://www.webservicex.net/CurrencyConvertor.asmx" def proxy = client.target(base).proxy(CurrencyConvertor) def response = proxy.convert("USD", "EUR") def root = new XmlSlurper().parseText(response) assert root.name() == 'double' println root.text() // => 0.882 ================================================ FILE: listings/chap15/Listing_15_09_XMLRPC_echo.groovy ================================================ @Grab('org.codehaus.groovy:groovy-xmlrpc:0.8') import groovy.net.xmlrpc.XMLRPCServerProxy as Proxy import groovy.net.xmlrpc.XMLRPCServer as Server def server = new Server() server.echo = { return it } def socket = new ServerSocket(8080) server.startServer(socket) remote = new Proxy("http://localhost:8080/") //|#A assert 'Hello world!' == remote.echo('Hello world!') //|#A server.stopServer() //#A Client code ================================================ FILE: listings/chap15/Listing_15_10_XMLRPC_jira.groovy ================================================ @Grab('org.codehaus.groovy:groovy-xmlrpc:0.8') import groovy.net.xmlrpc.XMLRPCServerProxy as Proxy class JiraProxy extends Proxy { JiraProxy(url) { super(url) } Object invokeMethod(String methodname, args) { super.invokeMethod('jira1.' + methodname, args) } } def jira = new JiraProxy('https://issues.apache.org/jira/rpc/xmlrpc') // insert your ASF username and password below jira.login('username', '****') { loginToken -> def projects = getProjectsNoSchemes(loginToken) println "${projects.size()} projects found in the Apache jira" def groovy = projects.find { it.name == 'Groovy' } if (groovy) { println "Found the $groovy.name project with key $groovy.key" println "Description: $groovy.description" println "Led by $groovy.lead and hosted at $groovy.projectUrl" } } /* 519 projects found in the Apache jira Found the groovy project with key GROOVY Description: Groovy programming language: a modern dynamic language for the JVM Led by guillaume and hosted at https://groovy.incubator.apache.org/ */ ================================================ FILE: listings/chap15/Listing_15_11_SOAP_wsdl.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-xml:2.2.0') import groovy.xml.Namespace def url = 'http://www.webservicex.net/CurrencyConvertor.asmx?WSDL' def wsdl = new Namespace('http://schemas.xmlsoap.org/wsdl/','wsdl') def doc = new XmlParser().parse(url) println doc[wsdl.portType][wsdl.operation].'@name' // -> [ConversionRate, ConversionRate, ConversionRate] ================================================ FILE: listings/chap15/Listing_15_12_SOAP11_currency_url.groovy ================================================ //@Grab('org.codehaus.groovy:groovy-templates:2.2.0') import groovy.text.SimpleTemplateEngine as STE import groovy.xml.Namespace def file = new File('data/conv.templ.xml') //#A def template = new STE().createTemplate(file) def params = [from:'USD', to:'EUR'] def request = template.make(params).toString().getBytes('UTF-8') def url = 'http://www.webservicex.net/CurrencyConvertor.asmx' def conn = new URL(url).openConnection() def reqProps = [ 'Content-Type': 'text/xml; charset=UTF-8', //#|B 'SOAPAction' : 'http://www.webserviceX.NET/ConversionRate', //#|B 'Accept' : 'application/soap+xml, text/*' //#|B ] reqProps.each { key,value -> conn.addRequestProperty(key,value) } conn.requestMethod = 'POST' conn.doOutput = true conn.outputStream << new ByteArrayInputStream(request) //#C if (conn.responseCode != conn.HTTP_OK) { println "Error - HTTP:${conn.responseCode}" return } def resp = new XmlParser().parse(conn.inputStream) //#D def serv = new Namespace('http://www.webserviceX.NET/') def result = serv.ConversionRateResult //#E print "Current USD to EUR conversion rate: " println resp.depthFirst().find{result == it.name()}.text() // Current USD to EUR conversion rate: 0.882 //#A Templated envelope of SOAP request //#B Request headers to use every time //#C Send the request //#D Parse the response //#E Extract the result ================================================ FILE: listings/chap15/Listing_15_13_SOAP12_currency_httpb.groovy ================================================ @Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.7.2') import groovyx.net.http.RESTClient import static groovyx.net.http.ContentType.XML def base = 'http://www.webserviceX.NET/CurrencyConvertor.asmx' def soapEnv = 'http://www.w3.org/2003/05/soap-envelope' def contentType = 'application/soap+xml; charset=UTF-8' new RESTClient(base).with { parser.'application/soap+xml' = parser.'application/xml' //#1 headers = ['Content-Type': contentType] //#2 post(requestContentType: XML, body: { 'soap:Envelope'('xmlns:soap': soapEnv) { 'soap:Body' { ConversionRate(xmlns: 'http://www.webserviceX.NET/') { FromCurrency('USD') ToCurrency('EUR') } } } }) { resp, data -> assert resp.status == 200 println data.text() } } //#1 register a SOAP response parser //#2 Content-Type expected by SOAP server // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" // => http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate // => 0.882 // => 0.882 /* ${from} ${to} */ ================================================ FILE: listings/chap15/Listing_15_14_SOAP11_currency_wslite.groovy ================================================ @Grab('com.github.groovy-wslite:groovy-wslite:1.1.0') import wslite.soap.SOAPClient def url = 'http://www.webservicex.net/CurrencyConvertor.asmx?WSDL' def client = new SOAPClient(url) def action = "http://www.webserviceX.NET/ConversionRate" def response = client.send(SOAPAction: action) { body { ConversionRate(xmlns: 'http://www.webserviceX.NET/') { FromCurrency('USD') ToCurrency('EUR') } } } assert response.httpResponse.statusCode == 200 println response.ConversionRateResponse.ConversionRateResult // => 0.882 ================================================ FILE: listings/chap15/Listing_15_15_SOAP12_currency_wslite.groovy ================================================ @Grab('com.github.groovy-wslite:groovy-wslite:1.1.0') import wslite.soap.* def url = 'http://www.webserviceX.NET/CurrencyConvertor.asmx?WSDL' def client = new SOAPClient(url) def response = client.send { version SOAPVersion.V1_2 body { ConversionRate(xmlns: 'http://www.webserviceX.NET/') { FromCurrency('USD') ToCurrency('EUR') } } } assert response.httpResponse.statusCode == 200 println response.ConversionRateResponse.ConversionRateResult // => 0.882 ================================================ FILE: listings/chap15/data/conv.templ.xml ================================================ ${from} ${to} ================================================ FILE: listings/chap16/HelloIntegrationWorld.java ================================================ // Java import groovy.lang.GroovyShell; public class HelloIntegrationWorld { public static void main(String[] args) { GroovyShell shell = new GroovyShell(); Object result = shell.evaluate("12+23"); assert result.equals(35); } } ================================================ FILE: listings/chap16/Listing_16_01_HelloIntegration.groovy ================================================ def shell = new GroovyShell() def result = shell.evaluate("12 + 23") assert result == 35 ================================================ FILE: listings/chap16/Listing_16_02_HelloIntegrationJava.txt ================================================ see: HelloIntegrationWorld.java ================================================ FILE: listings/chap16/Listing_16_03_MultilineScript.groovy ================================================ def shell = new GroovyShell() def kineticEnergy = shell.evaluate(''' def mass = 22.3 def velocity = 10.6 mass * velocity**2 / 2 ''') assert kineticEnergy == 1252.814 ================================================ FILE: listings/chap16/Listing_16_04_UsingEval.groovy ================================================ assert "Hello" == Eval.me("'Hello'") assert 1 == Eval.x (1, "x") assert 3 == Eval.xy (1, 2, "x+y") assert 6 == Eval.xyz(1, 2, 3, "x+y+z") ================================================ FILE: listings/chap16/Listing_16_05_Binding.groovy ================================================ def binding = new Binding() //#1 binding.mass = 22.3 //#1 binding.velocity = 10.6 //#1 def shell = new GroovyShell(binding) //#2 def expression = "mass * velocity ** 2 / 2" //#2 assert shell.evaluate(expression) == 1252.814 //#2 binding.setVariable("mass", 25.4) //#3 assert shell.evaluate(expression) == 1426.972 //#3 //#1 Create and populate the binding //#2 Evaluate the expression using the binding //#3 Change the binding data and re-evaluate ================================================ FILE: listings/chap16/Listing_16_06_BindingTwoWay.groovy ================================================ def binding = new Binding(x: 6, y: 4) //#1 def shell = new GroovyShell(binding) shell.evaluate(''' xSquare = x * x //#2 yCube = y * y * y //#2 ''') assert binding.getVariable("xSquare") == 36 //#3 assert binding.yCube == 64 //#4 //#1 Prepopulating the binding data //#2 Setting binding data within the evaluated script //#3 Method access to binding data //#4 Groovy property access to binding data ================================================ FILE: listings/chap16/Listing_16_07_ClassInScript.groovy ================================================ def shell = new GroovyShell() def clazz = shell.evaluate(''' class MyClass { //#A def method() { "value" } //#A } //#A return MyClass //#A ''') assert clazz.name == "MyClass" def instance = clazz.newInstance() //#B assert instance.method() == "value" //#C //#A Define a new class //#B Create an instance of the class //#C Use the object as normal ================================================ FILE: listings/chap16/Listing_16_08_Payment_calculator.groovy ================================================ def monthly = "amount*(rate/12) / (1-(1+rate/12)**-numberOfMonths)" def shell = new GroovyShell() def script = shell.parse(monthly) //#A script.binding.amount = 154000 //#B script.rate = 3.75/100 //#C script.numberOfMonths = 240 assert script.run() == 913.0480050387338 script.binding = new Binding(amount: 185000, //|#D rate: 3.50/100, //|#D numberOfMonths: 300) //|#D assert script.run() == 926.1536089487843 //#A Parse formula into reusable script //#B Access binding variable //#C Access binding variable using shorthand //#D Create new binding ================================================ FILE: listings/chap16/Listing_16_09_MethodsInBinding.groovy ================================================ def binding = new Binding(multiply: { a, b -> a * b }) //#A def shell = new GroovyShell(binding) def value = shell.evaluate(''' multiply(5, 6) //#B ''') assert value == 30 //#A Create closure within the binding //#B Call the closure like a normal method ================================================ FILE: listings/chap16/Listing_16_10_ShapeInfoMain.txt ================================================ see: shapes/ShapeInfoMain.java ================================================ FILE: listings/chap16/Listing_16_11_SpringConfig.txt ================================================ see: spring/beans.xml ================================================ FILE: listings/chap16/Listing_16_12_BeanToString.groovy ================================================ import groovy.transform.ToString import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.* def conf = new CompilerConfiguration() def astCustomizer = new ASTTransformationCustomizer(ToString) //#1 def sourceAwareCustomizer = new SourceAwareCustomizer(astCustomizer) //#2 sourceAwareCustomizer.baseNameValidator = { //#3 name -> name.endsWith 'Bean' } conf.addCompilationCustomizers(sourceAwareCustomizer) def gcl = new GroovyClassLoader(getClass().classLoader, conf) //#4 def clazz = gcl.parseClass ''' class MrBean { String first, last } ''', 'MrBean.groovy' def result = clazz.newInstance() result.first = 'Rowan' result.last = 'Atkinson' assert result.toString() == 'MrBean(Rowan, Atkinson)' //#1 Create ToString AST customizer //#2 Wrap into a source aware customizer //#3 Create a basename filter //#4 Use conf with GroovyClassLoader ================================================ FILE: listings/chap16/shapes/Circle.groovy ================================================ package shapes class Circle implements Shape { double radius Circle(double radius) { this.radius = radius } double area() { return Math.PI * radius ** 2 } double perimeter() { return 2 * Math.PI * radius } } ================================================ FILE: listings/chap16/shapes/MaxAreaInfo.groovy ================================================ package shapes class MaxAreaInfo implements ShapeInfo { void displayInfo(Shape s1, Shape s2) { print "The shape with the biggest area is: " println s1.area() > s2.area() ? s1.class.simpleName : s2.class.simpleName } } ================================================ FILE: listings/chap16/shapes/MaxPerimeterInfo.java ================================================ package shapes; public class MaxPerimeterInfo { void displayInfo(Square s, Circle c) { System.out.print("The shape with the biggest perimeter is: "); System.out.println(s.perimeter() > c.perimeter() ? "square" : "circle"); } } ================================================ FILE: listings/chap16/shapes/Shape.java ================================================ package shapes; public interface Shape { double area(); double perimeter(); } ================================================ FILE: listings/chap16/shapes/ShapeInfo.java ================================================ package shapes; public interface ShapeInfo { void displayInfo(Shape s1, Shape s2); } ================================================ FILE: listings/chap16/shapes/ShapeInfoMain.java ================================================ package shapes; // Java public class ShapeInfoMain { public static void main(String[] args) { Square s = new Square(7); Circle c = new Circle(4); new MaxAreaInfo().displayInfo(s, c); new MaxPerimeterInfo().displayInfo(s, c); } } ================================================ FILE: listings/chap16/shapes/Square.java ================================================ package shapes; public class Square implements Shape { private double side; Square(double side) { this.side = side; } public double area() { return side * side; } public double perimeter() { return 4 * side; } } ================================================ FILE: listings/chap16/spring/common/Shape.java ================================================ package spring.common; public interface Shape { double area(); double perimeter(); } ================================================ FILE: listings/chap16/spring/common/ShapeInfo.java ================================================ package spring.common; public interface ShapeInfo { void displayInfo(Shape s1, Shape s2); } ================================================ FILE: listings/chap16/spring/groovy/Circle.groovy ================================================ package spring.groovy import spring.common.Shape class Circle implements Shape { double radius String color = "Blue" Circle(double radius) { this.radius = radius } double area() { return Math.PI * radius ** 2 } double perimeter() { return 2 * Math.PI * radius } String toString() { return color + " Groovy Circle" } } ================================================ FILE: listings/chap16/spring/groovy/MaxAreaInfo.groovy ================================================ package spring.groovy import spring.common.Shape import spring.common.ShapeInfo class MaxAreaInfo implements ShapeInfo { void displayInfo(Shape s1, Shape s2) { print "The shape with the biggest area is: " if (s1.area() > s2.area()) println s1 else println s2 } } ================================================ FILE: listings/chap16/spring/java/MaxPerimeterInfo.java ================================================ package spring.java; import spring.common.Shape; import spring.common.ShapeInfo; public class MaxPerimeterInfo implements ShapeInfo { public String getPrefix() { return null; } public void setPrefix(String value) { } public void displayInfo(Shape s1, Shape s2) { System.out.print("The shape with the biggest perimeter is: "); System.out.println(s1.perimeter() > s2.perimeter() ? s1.getClass().getName() : s2.getClass().getName()); } } ================================================ FILE: listings/chap16/spring/java/ShapeInfoFactoryMain.java ================================================ package spring.java; import spring.common.Shape; import spring.common.ShapeInfo; import java.lang.reflect.Constructor; public class ShapeInfoFactoryMain { public static void main(String[] args) { try { Shape s = new Square(7); Class groovyCircle = Class.forName("spring.groovy.Circle"); Class groovyMaxAreaInfo = Class.forName("spring.groovy.MaxAreaInfo"); Constructor cons = groovyCircle.getConstructors()[0]; Shape c = (Shape) cons.newInstance(4); ShapeInfo info = (ShapeInfo) groovyMaxAreaInfo.newInstance(); info.displayInfo(s, c); new MaxPerimeterInfo().displayInfo(s, c); } catch (Exception e) { e.printStackTrace(); } } } ================================================ FILE: listings/chap16/spring/java/ShapeInfoMain.java ================================================ package spring.java; import spring.groovy.Circle; import spring.groovy.MaxAreaInfo; import spring.common.Shape; public class ShapeInfoMain { public static void main(String[] args) { Shape s = new Square(7); Shape c = new Circle(4); new MaxAreaInfo().displayInfo(s, c); new MaxPerimeterInfo().displayInfo(s, c); } } ================================================ FILE: listings/chap16/spring/java/ShapeInfoSpringMain.java ================================================ package spring.java; import spring.common.Shape; import spring.common.ShapeInfo; //import org.springframework.core.io.Resource; //import org.springframework.core.io.FileSystemResource; //import org.springframework.beans.factory.xml.XmlBeanFactory; //import org.springframework.beans.factory.BeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class ShapeInfoSpringMain { public static void main(String[] args) { try { ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml"); // Resource resource = new FileSystemResource("spring/beans.xml"); // BeanFactory factory = new XmlBeanFactory(resource); Shape s = new Square(7); Shape c = (Shape) ctx.getBean("circle"); ShapeInfo info = (ShapeInfo) ctx.getBean("maxareainfo3"); info.displayInfo(s, c); new MaxPerimeterInfo().displayInfo(s, c); } catch (Exception e) { e.printStackTrace(); } } } ================================================ FILE: listings/chap16/spring/java/Square.java ================================================ package spring.java; import spring.common.Shape; public class Square implements Shape { private double side; private String color = "White"; public Square(double side) { this.side = side; } public double area() { return side * side; } public double perimeter() { return 4 * side; } public String toString(){ return color + " Java Square"; } } ================================================ FILE: listings/chap16/spring/resources/beans.xml ================================================ ================================================ FILE: listings/chap17/.classpath ================================================ ================================================ FILE: listings/chap17/.project ================================================ chap17 org.eclipse.jdt.core.javabuilder org.eclipse.jdt.groovy.core.groovyNature org.eclipse.jdt.core.javanature ================================================ FILE: listings/chap17/Converter.groovy ================================================ class Converter { static celsius (fahrenheit) { (fahrenheit - 32) * 5 / 9 } } ================================================ FILE: listings/chap17/Counter.groovy ================================================ class Counter { int biggerThan(items, threshold) { items.grep{ it > threshold }.size() } } ================================================ FILE: listings/chap17/Farm.groovy ================================================ class Farm { def getMachines() { /* some expensive code here */ throw new RuntimeException('should not reach here') } } ================================================ FILE: listings/chap17/Listing_17_01_Celsius.groovy ================================================ import static Converter.celsius assert 20 == celsius(68) assert 35 == celsius(95) assert -17 == celsius(0).toInteger() //#A assert 0 == celsius(32) //#A Round down to whole number ================================================ FILE: listings/chap17/Listing_17_02_CounterTest.groovy ================================================ class Listing_17_02_CounterTest extends GroovyTestCase { static final Integer[] NEG_NUMBERS = [-2, -3, -4] //#A static final Integer[] POS_NUMBERS = [4, 5, 6] //#A static final Integer[] MIXED_NUMBERS = [4, -6, 0] //#A private Counter counter void setUp() { counter = new Counter() } void testCounterWorks() { assertEquals(2, counter.biggerThan([5, 10, 15], 7)) } void testCountHowManyFromSampleNumbers() { check(0, NEG_NUMBERS, -1) //#B check(0, NEG_NUMBERS, -2) //#B check(2, NEG_NUMBERS, -4) //#B check(3, NEG_NUMBERS, -5) //#B check(0, POS_NUMBERS, 7) //#B check(0, POS_NUMBERS, 6) //#B check(2, POS_NUMBERS, 4) //#B check(3, POS_NUMBERS, 3) //#B check(0, MIXED_NUMBERS, 5) //#B check(1, MIXED_NUMBERS, 2) //#B check(1, MIXED_NUMBERS, 1) //#B check(1, MIXED_NUMBERS, 0) //#B check(2, MIXED_NUMBERS, -1) //#B check(3, MIXED_NUMBERS, -7) //#B } void testInputDataUnchanged() { //#C def numbers = NEG_NUMBERS.clone() def origLength = numbers.size() counter.biggerThan(numbers, 0 /* don't care */) assertLength origLength, numbers assertArrayEquals NEG_NUMBERS, numbers } void testCountHowManyFromSampleStrings() { //#D check(2, ['Dog', 'Cat', 'Antelope'], 'Bird') } void testInputDataAssumptions() { //#E assertTrue NEG_NUMBERS.every { it < 0 } assertTrue POS_NUMBERS.every { it > 0 } assertContains 0, MIXED_NUMBERS int negCount = 0 int posCount = 0 MIXED_NUMBERS.each { if (it < 0) negCount++ else if (it > 0) posCount++ } assert negCount && posCount } private check(expectedCount, items, threshold) { assertEquals(expectedCount, counter.biggerThan(items, threshold) ) } } //#A Constants repeated in the test //#B Use a helper method to make code simpler //#C Tests proving we don’t change the array //#D Calculator doesn’t only work with numbers //#E Test constants sanity check ================================================ FILE: listings/chap17/Listing_17_03_HashMapTest.groovy ================================================ class Listing_17_03_HashMapTest extends GroovyTestCase { static final KEY = new Object() static final MAP = [key1: new Object(), key2: new Object()] void testHashtableRejectsNull() { shouldFail(NullPointerException) { new Hashtable()[KEY] = null } } void testBadInitialSize() { def msg = shouldFail(IllegalArgumentException) { //#A new HashMap(-1) } assertEquals "Illegal initial capacity: -1", msg //#B } void testHashMapAcceptsNull() { def myMap = new HashMap() myMap[KEY] = null assert myMap.keySet().contains(KEY) } void testHashMapReturnsOriginalObjects() { def myMap = new HashMap() MAP.entrySet().each { myMap[it] = MAP[it] assertSame MAP[it], myMap[it] } assert MAP.dump().contains('java.lang.Object') //#C assert myMap.size() == MAP.size() } } //#A Check that the right kind of exception is thrown //#B Check the message //#C Use Groovy inspection to examine the map ================================================ FILE: listings/chap17/Listing_17_04_GroovyTestSuite.groovy ================================================ import junit.framework.* import junit.textui.TestRunner static Test suite() { def suite = new TestSuite() def gts = new GroovyTestSuite() suite.addTestSuite(gts.compile("Listing_17_02_CounterTest.groovy")) suite.addTestSuite(gts.compile("Listing_17_03_HashMapTest.groovy")) return suite } TestRunner.run(suite()) ================================================ FILE: listings/chap17/Listing_17_05_AllTestSuite.groovy ================================================ def suite = AllTestSuite.suite(".", "Listing_17_*Counter*Test.groovy") junit.textui.TestRunner.run(suite) ================================================ FILE: listings/chap17/Listing_17_06_DataDrivenJUnitTest.groovy ================================================ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Parameterized import org.junit.runners.Parameterized.Parameters import static Converter.celsius @RunWith(Parameterized) //#1 class Listing_17_06_DataDrivenJUnitTest { private c, f, scenario @Parameters static scenarios() {[ //#2 [0, 32, 'Freezing'], [20, 68, 'Garden party conditions'], [35, 95, 'Beach conditions'], [100, 212, 'Boiling'] ]*.toArray()} Listing_17_06_DataDrivenJUnitTest(c, f, scenario) { //#3 this.c = c this.f = f this.scenario = scenario } @Test void convert() { def actual = celsius(f) def msg = "$scenario: ${f}°F should convert into ${c}°C" assert c == actual, msg } } //#1 Special test runner //#2 Array of test data //#3 Constructor parameters consume a row of test data ================================================ FILE: listings/chap17/Listing_17_07_PropertyBased.groovy ================================================ @Grab('net.java.quickcheck:quickcheck:0.6') import static net.java.quickcheck.generator.PrimitiveGenerators.* import static java.lang.Math.round import static Converter.celsius def gen = integers(-40, 240) //#1 def liquidC = 0..100 def liquidF = 32..212 100.times { int f = gen.next() //#2 int c = round(celsius(f)) assert c <= f //#3 assert c in liquidC == f in liquidF //#4 } //#1 Select integers from this range //#2 Get the next integer //#3 Celsius less than Fahrenheit (above -40 degrees) //#4 Water should be liquid in this range ================================================ FILE: listings/chap17/Listing_17_08_Balancer.groovy ================================================ import static org.junit.Assert.assertSame def relay(request, farm) { //#|A farm.machines.sort { it.load }[0].send(request) //#|A } //#|A class FakeMachine { //#B def load def send(request) { return this } } final LOW_LOAD = 5, HIGH_LOAD = 10 def farm = [machines: [ //#|C new FakeMachine(load:HIGH_LOAD), //#|C new FakeMachine(load:LOW_LOAD)]] //#|C assertSame(LOW_LOAD, relay(null, farm).load) //#A Subject under test //#B Replacement class //#C Map replaces farm ================================================ FILE: listings/chap17/Listing_17_09_BalancerStub.groovy ================================================ import groovy.mock.interceptor.StubFor def relay(request) { new Farm().getMachines().sort { it.load }[0].send(request) } def fakeOne = new Expando(load:10, send: { false } ) def fakeTwo = new Expando(load:5, send: { true } ) def farmStub = new StubFor(Farm) //#A farmStub.demand.getMachines { [fakeOne, fakeTwo ] } //#B farmStub.use { //#|C assert relay(null) //#|C } //#|C //#A Create stub //#B Specify demanded behavior //#C Call the class under test using stub ================================================ FILE: listings/chap17/Listing_17_10_BalancerMock.groovy ================================================ import groovy.mock.interceptor.MockFor class SortableFarm extends Farm { void sort() { /* here the Farm would sort its machines by load */ } } def relay(request) { def farm = new SortableFarm() farm.sort() farm.getMachines()[0].send(request) } def farmMock = new MockFor(SortableFarm) //#A farmMock.demand.sort(){} //#|B farmMock.demand.getMachines { [new Expando(send: {} )] } //#|B farmMock.use { relay(null) } //#A Create mock //#B Specify demanded behavior ================================================ FILE: listings/chap17/Listing_17_11_LoggingCounterTest.groovy ================================================ import java.util.logging.Level class Listing_17_11_LoggingCounterTest extends GroovyLogTestCase { static final MIXED_NUMBERS = [99, 2, 1, 0, -1, -2, -99] //#A private count void setUp() { count = new LoggingCounter() } void testCounterAndLog() { def log = stringLog(Level.FINER, 'LoggingCounter') { //#B def bigger = count.biggerThan(MIXED_NUMBERS, -1) //#C assertEquals(4, bigger) //#D } checkLogCount(1, "was equal", log) checkLogCount(4, "was bigger", log) checkLogCount(2, "was smaller", log) checkLogCount(4, /[^d][^o][^n][^'][^t] count this one/, log) checkLogCount(3, "don't count this one", log) } private checkLogCount(expectedCount, regex, log) { //#E def matcher = (log =~ regex) assertTrue log, expectedCount == matcher.count } } //#A Test data //#B Set up stringLog //#C Invoke SUT //#D Traditional JUnit style assert //#E Helper method asserting patterns within the log ================================================ FILE: listings/chap17/Listing_17_12_JUnitPerf.groovy ================================================ @Grab('junitperf:junitperf:1.9.1') @GrabResolver('https://repository.jboss.org/') import com.clarkware.junitperf.* import junit.framework.* import junit.textui.TestRunner import static Converter.celsius class Listing_17_12_JUnitPerf extends TestCase { Listing_17_12_JUnitPerf(String testName) { super(testName) //#A } void testConverter() { //#B assert 0 == celsius(32) //#C assert 100 == celsius(212) //#C } static main(args) { TestRunner.run(suite()) } static Test suite() { def testCase = new Listing_17_12_JUnitPerf("testConverter") //#D def numUsers = 20 //#E def stagger = new ConstantTimer(100) //#E def loadTest = new LoadTest(testCase, numUsers, stagger) //#F def timeLimit = 2100 //#G return new TimedTest(loadTest, timeLimit) //#H } } //#A Call super //#B Traditional nontimed JUnit test //#C Class under test //#D Define test case //#E 20 users for load staggered at 100 ms //#F Decorate testcase to simulate load //#G Must return within 2100 ms //#H Return decorated time-constrained test ================================================ FILE: listings/chap17/Listing_17_13_SpockSimple.groovy ================================================ @Grab('org.spockframework:spock-core:1.0-groovy-2.4') import spock.lang.Specification class GivenWhenThenSpec extends Specification { def "test adding a new item to a set"() { given: def items = [4, 6, 3, 2] as Set when: items << 1 then: items.size() == 5 } } ================================================ FILE: listings/chap17/Listing_17_14_SpockMock.groovy ================================================ @Grab('org.spockframework:spock-core:1.0-groovy-2.4') import spock.lang.Specification class Listing_17_14_SpockMock extends Specification { def "buy ticket for a movie theater"() { given: def purchase = new Purchase("Lord of the Rings", 2) MovieTheater theater = Mock() //#A theater.hasSeatsAvailable("Lord of the Rings", 2) >> true //#B when: purchase.fill(theater) then: purchase.completed 1 * theater.purchaseTicket("Lord of the Rings", 2) //#C } } //#A Creation of mock theater //#B Mock hasSeatsAvailable call returning true //#C Assert purchaseTicket has been called 1 time ================================================ FILE: listings/chap17/Listing_17_15_SpockMockWildcards.groovy ================================================ @Grab('org.spockframework:spock-core:1.0-groovy-2.4') import spock.lang.Specification class Listing_17_15_SpockMockWildcards extends Specification { def "cannot buy a ticket when the movie is sold out"() { given: def purchase = new Purchase("Lord of the rings", 2) MovieTheater theater = Mock() when: theater.hasSeatsAvailable(_, _) >> false //#A purchase.fill(theater) then: !purchase.completed 0 * theater.purchaseTicket(_, _) //#B } } //#A Mock hasSeatsAvailable call, any args, return false //#B The purchaseTicket method has not been called ================================================ FILE: listings/chap17/Listing_17_16_SpockMockClosureChecks.groovy ================================================ @Grab('org.spockframework:spock-core:1.0-groovy-2.4') import spock.lang.Specification class Listing_17_16_SpockMockClosureChecks extends Specification { def "on couples night tickets are sold in pairs"() { given: def purchase = new Purchase("Lord of the Rings", 2) MovieTheater theater = Mock() theater.hasSeatsAvailable("Lord of the Rings", 2) >> true when: purchase.fill(theater) then: 1 * theater.purchaseTicket(_, { it % 2 == 0 }) //#1 } } //#1 Closure argument checking ================================================ FILE: listings/chap17/Listing_17_17_SpockDataDriven.groovy ================================================ @Grab('org.spockframework:spock-core:1.0-groovy-2.4') import spock.lang.* import static Converter.celsius class Listing_17_17_SpockDataDriven extends Specification { @Unroll // def "test temperature scenarios"() { def "Scenario #scenario: #tempFºF should convert to #tempCºC"() { expect: celsius(tempF) == tempC where: scenario | tempF || tempC 'Freezing' | 32 || 0 'Garden party conditions' | 68 || 20 'Beach conditions' | 95 || 35 'Boiling' | 212 || 100 } } ================================================ FILE: listings/chap17/LoggingCounter.groovy ================================================ import java.util.logging.* class LoggingCounter { static final LOG = Logger.getLogger('LoggingCounter') def biggerThan(items, target) { int count = 0 items.each { if (it > target) { count++ LOG.finer "item was bigger - count this one" } else if (it == target) { LOG.finer "item was equal - don't count this one" } else { LOG.finer "item was smaller - don't count this one" } } return count } } ================================================ FILE: listings/chap17/MovieTheater.groovy ================================================ interface MovieTheater { void purchaseTicket(name, number) boolean hasSeatsAvailable(name, number) } ================================================ FILE: listings/chap17/Purchase.groovy ================================================ import groovy.transform.TupleConstructor @TupleConstructor class Purchase { def name, number, completed = false def fill(theater) { if (theater.hasSeatsAvailable(name, number)) { theater.purchaseTicket(name, number) completed = true } } } ================================================ FILE: listings/chap17/automation/build.gradle ================================================ apply plugin: 'groovy' version = '1.0' repositories { mavenCentral() } dependencies { compile "org.codehaus.groovy:groovy-all:2.4.0" testCompile "junit:junit:4.12" } task initProject () << { if (hasProperty(initPlugins)) { initPlugins.split(',').each { plug -> project.apply { plugin(plug.trim()) } } } project.sourceSets*.allSource.srcDirTrees.flatten().dir.each { dir -> dir.mkdirs() } } ================================================ FILE: listings/chap17/automation/gradle/wrapper/gradle-wrapper.properties ================================================ #Thu Apr 10 09:16:15 EST 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-bin.zip ================================================ FILE: listings/chap17/automation/gradlew ================================================ #!/bin/bash ############################################################################## ## ## ## Gradle wrapper script for UN*X ## ## ## ############################################################################## # Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. GRADLE_OPTS="$GRADLE_OPTS -Xmx640m" # JAVA_OPTS="$JAVA_OPTS -Xmx512m" GRADLE_APP_NAME=Gradle warn ( ) { echo "${PROGNAME}: $*" } die ( ) { warn "$*" exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # Attempt to set JAVA_HOME if it's not already set. if [ -z "$JAVA_HOME" ] ; then if $darwin ; then [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home" [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" else javaExecutable="`which javac`" [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." # readlink(1) is not available as standard on Solaris 10. readLink=`which readlink` [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME." javaExecutable="`readlink -f \"$javaExecutable\"`" javaHome="`dirname \"$javaExecutable\"`" javaHome=`expr "$javaHome" : '\(.*\)/bin'` export JAVA_HOME="$javaHome" fi fi # For Cygwin, ensure paths are in UNIX format before anything is touched. if $cygwin ; then [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties # Determine the Java command to use to start the JVM. 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="java" fi fi if [ ! -x "$JAVACMD" ] ; then die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD" fi if [ -z "$JAVA_HOME" ] ; then warn "JAVA_HOME environment variable is not set" fi # For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name if $darwin; then JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME" # we may also want to set -Xdock:image fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi GRADLE_APP_BASE_NAME=`basename "$0"` "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \ -classpath "$CLASSPATH" \ -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \ -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \ $STARTER_MAIN_CLASS \ "$@" ================================================ FILE: listings/chap17/automation/gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem ## @rem Gradle startup script for Windows ## @rem ## @rem ########################################################################## @rem @rem $Revision: 10602 $ $Date: 2008-01-25 02:49:54 +0100 (ven., 25 janv. 2008) $ @rem @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal @rem Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. @rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m @rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=.\ @rem Determine the command interpreter to execute the "CD" later set COMMAND_COM="cmd.exe" if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe" if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com" @rem Use explicit find.exe to prevent cygwin and others find.exe from being used set FIND_EXE="find.exe" if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe" if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe" :check_JAVA_HOME @rem Make sure we have a valid JAVA_HOME if not "%JAVA_HOME%" == "" goto have_JAVA_HOME echo. echo ERROR: Environment variable JAVA_HOME has not been set. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. echo. goto end :have_JAVA_HOME @rem Validate JAVA_HOME %COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul if not errorlevel 1 goto init echo. echo ERROR: JAVA_HOME might be set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation if there are problems. echo. :init @rem get name of script to launch with full path @rem Get command-line arguments, handling Windowz variants SET _marker=%JAVA_HOME: =% @rem IF NOT "%_marker%" == "%JAVA_HOME%" ECHO JAVA_HOME "%JAVA_HOME%" contains spaces. Please change to a location without spaces if this causes problems. if not "%OS%" == "Windows_NT" goto win9xME_args if "%eval[2+2]" == "4" goto 4NT_args IF "%_marker%" == "%JAVA_HOME%" goto :win9xME_args set _FIXPATH= call :fixpath "%JAVA_HOME%" set JAVA_HOME=%_FIXPATH:~1% goto win9xME_args :fixpath if not %1.==. ( for /f "tokens=1* delims=;" %%a in (%1) do ( call :shortfilename "%%a" & call :fixpath "%%b" ) ) goto :EOF :shortfilename for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi goto :EOF :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain set CLASSPATH=%DIRNAME%\gradle\wrapper\gradle-wrapper.jar set WRAPPER_PROPERTIES=%DIRNAME%\gradle\wrapper\gradle-wrapper.properties set JAVA_EXE=%JAVA_HOME%\bin\java.exe set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%" "%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1 rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%" exit /b "%ERRORLEVEL%" :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: listings/chap17/automation/pom.xml ================================================ 4.0.0 ReGinA Chap17 jar 1.0 Chap17 org.codehaus.gmaven gmaven-plugin ${gmaven.version} compile testCompile 1.7 org.codehaus.gmaven.runtime gmaven-runtime-1.7 1.3 org.codehaus.groovy groovy-all org.codehaus.groovy groovy-all ${groovy.version} compile org.codehaus.gmaven gmaven-plugin 1.3 org.apache.maven.plugins maven-compiler-plugin 2.3.2 1.5 1.5 org.apache.maven.plugins maven-surefire-plugin 2.8 org.apache.maven.surefire surefire-junit47 2.8 junit junit 4.8.2 test org.testng testng 6.0.1 test org.codehaus.groovy groovy-all ${groovy.version} test 1.3 1.8.0-rc-3 ================================================ FILE: listings/chap17/automation/src/main/groovy/Calculator.groovy ================================================ class Calculator { def add(number1, number2) { return number1 + number2 } } ================================================ FILE: listings/chap17/automation/src/test/groovy/CalculatorTest.groovy ================================================ import org.junit.Test class CalculatorTest { @Test void testAdd() { def calculator = new Calculator() assert 10 == calculator.add(3, 7) } } ================================================ FILE: listings/chap17/cobertura/build.gradle ================================================ plugins { id 'net.saliman.cobertura' version '2.2.6' } apply plugin: 'groovy' repositories { mavenCentral() } dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.0' testCompile 'junit:junit:4.12' } ================================================ FILE: listings/chap17/cobertura/gradle/wrapper/gradle-wrapper.properties ================================================ #Thu Apr 10 09:16:15 EST 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-bin.zip ================================================ FILE: listings/chap17/cobertura/gradlew ================================================ #!/bin/bash ############################################################################## ## ## ## Gradle wrapper script for UN*X ## ## ## ############################################################################## # Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. GRADLE_OPTS="$GRADLE_OPTS -Xmx640m" # JAVA_OPTS="$JAVA_OPTS -Xmx512m" GRADLE_APP_NAME=Gradle warn ( ) { echo "${PROGNAME}: $*" } die ( ) { warn "$*" exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # Attempt to set JAVA_HOME if it's not already set. if [ -z "$JAVA_HOME" ] ; then if $darwin ; then [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home" [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" else javaExecutable="`which javac`" [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." # readlink(1) is not available as standard on Solaris 10. readLink=`which readlink` [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME." javaExecutable="`readlink -f \"$javaExecutable\"`" javaHome="`dirname \"$javaExecutable\"`" javaHome=`expr "$javaHome" : '\(.*\)/bin'` export JAVA_HOME="$javaHome" fi fi # For Cygwin, ensure paths are in UNIX format before anything is touched. if $cygwin ; then [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` fi STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties # Determine the Java command to use to start the JVM. 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="java" fi fi if [ ! -x "$JAVACMD" ] ; then die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD" fi if [ -z "$JAVA_HOME" ] ; then warn "JAVA_HOME environment variable is not set" fi # For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name if $darwin; then JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME" # we may also want to set -Xdock:image fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi GRADLE_APP_BASE_NAME=`basename "$0"` "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \ -classpath "$CLASSPATH" \ -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \ -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \ $STARTER_MAIN_CLASS \ "$@" ================================================ FILE: listings/chap17/cobertura/gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem ## @rem Gradle startup script for Windows ## @rem ## @rem ########################################################################## @rem @rem $Revision: 10602 $ $Date: 2008-01-25 02:49:54 +0100 (ven., 25 janv. 2008) $ @rem @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal @rem Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. @rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m @rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=.\ @rem Determine the command interpreter to execute the "CD" later set COMMAND_COM="cmd.exe" if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe" if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com" @rem Use explicit find.exe to prevent cygwin and others find.exe from being used set FIND_EXE="find.exe" if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe" if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe" :check_JAVA_HOME @rem Make sure we have a valid JAVA_HOME if not "%JAVA_HOME%" == "" goto have_JAVA_HOME echo. echo ERROR: Environment variable JAVA_HOME has not been set. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. echo. goto end :have_JAVA_HOME @rem Validate JAVA_HOME %COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul if not errorlevel 1 goto init echo. echo ERROR: JAVA_HOME might be set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation if there are problems. echo. :init @rem get name of script to launch with full path @rem Get command-line arguments, handling Windowz variants SET _marker=%JAVA_HOME: =% @rem IF NOT "%_marker%" == "%JAVA_HOME%" ECHO JAVA_HOME "%JAVA_HOME%" contains spaces. Please change to a location without spaces if this causes problems. if not "%OS%" == "Windows_NT" goto win9xME_args if "%eval[2+2]" == "4" goto 4NT_args IF "%_marker%" == "%JAVA_HOME%" goto :win9xME_args set _FIXPATH= call :fixpath "%JAVA_HOME%" set JAVA_HOME=%_FIXPATH:~1% goto win9xME_args :fixpath if not %1.==. ( for /f "tokens=1* delims=;" %%a in (%1) do ( call :shortfilename "%%a" & call :fixpath "%%b" ) ) goto :EOF :shortfilename for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi goto :EOF :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain set CLASSPATH=%DIRNAME%\gradle\wrapper\gradle-wrapper.jar set WRAPPER_PROPERTIES=%DIRNAME%\gradle\wrapper\gradle-wrapper.properties set JAVA_EXE=%JAVA_HOME%\bin\java.exe set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%" "%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1 rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%" exit /b "%ERRORLEVEL%" :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: listings/chap17/cobertura/src/main/groovy/BiggestPairCalc.groovy ================================================ class BiggestPairCalc { int sumBiggestPair(a, b, c) { def op1 = a def op2 = b if (c > a) { op1 = c } else if (c > b) { op2 = c } return op1 + op2 } } ================================================ FILE: listings/chap17/cobertura/src/main/groovy/BiggestPairCalcFixed.groovy ================================================ class BiggestPairCalcFixed { int sumBiggestPair(int a, int b, int c) { def op1 = a def op2 = b if (c > [a, b].min()) { op1 = c op2 = [a, b].max() } return op1 + op2 } } ================================================ FILE: listings/chap17/cobertura/src/test/groovy/BiggestPairCalcTest.groovy ================================================ class BiggestPairCalcTest extends GroovyTestCase { void testSumBiggestPair() { def calc = new BiggestPairCalc() testCalc(calc) // def fixed = new BiggestPairCalcFixed() // testCalc(fixed) // assertEquals(11, fixed.sumBiggestPair(5, 2, 6)) // assertEquals(15, fixed.sumBiggestPair(5, 9, 6)) // assertEquals(16, fixed.sumBiggestPair(10, 2, 6)) } private void testCalc(calc) { assertEquals(9, calc.sumBiggestPair(5, 4, 1)) assertEquals(15, calc.sumBiggestPair(5, 9, 6)) assertEquals(16, calc.sumBiggestPair(10, 2, 6)) //assertEquals(11, calc.sumBiggestPair(5, 2, 6)) } } ================================================ FILE: listings/chap17/extra_ParameterizedTestNG.groovy ================================================ @Grab('org.codehaus.groovy:groovy-testng:2.4.0') @Grab('com.google.code.guice:guice:1.0') @GrabConfig(systemClassLoader = true) import org.testng.annotations.DataProvider import org.testng.annotations.Test import static Converter.celsius class extra_ParameterizedTestNG { Object[][] scenarios = [ [ 0, 32, 'Freezing'], [ 20, 68, 'Garden party conditions'], [ 35, 95, 'Beach conditions'], [100, 212, 'Boiling'] ] @DataProvider(name = 'scenarios') Object[][] scenarios() { scenarios } @Test(dataProvider = 'scenarios') void convert(c, f, scenario) { def actual = celsius(f) def msg = "$scenario: $fºF should convert into $cºC" assert c == actual, msg } } ================================================ FILE: listings/chap17/extra_TestNG.groovy ================================================ @Grab('org.codehaus.groovy:groovy-testng:2.4.0') @Grab('com.google.code.guice:guice:1.0') @GrabConfig(systemClassLoader=true) import org.testng.annotations.Test class extra_TestNG { @Test void shouldAdd() { assert 2 == 1 + 1 } } ================================================ FILE: listings/chap17/snippet1701_JUnit4.groovy ================================================ import org.junit.Test import static org.junit.Assert.assertEquals class SimpleJUnit4Test { @Test void shouldAdd() { assertEquals("Groovy should add correctly", 2, 1 + 1) } } ================================================ FILE: listings/chap17/snippet1704_listPropertyCheck.groovy ================================================ @Grab('net.java.quickcheck:quickcheck:0.6') import static net.java.quickcheck.generator.PrimitiveGenerators.* import static net.java.quickcheck.generator.CombinedGeneratorsIterables.* for (words in someNonEmptyLists(strings())) { assert words*.size().sum() == words.sum().size() } ================================================ FILE: listings/chap17/test-output/Command line suite/Command line test.html ================================================ TestNG: Command line test

Command line test

Tests passed/Failed/Skipped:1/0/0
Started on:Thu Jun 04 12:16:31 CEST 2015
Total time:0 seconds (2 ms)
Included groups:
Excluded groups:

(Hover the method name to see the test class name)

PASSED TESTS
Test method Exception Time (seconds) Instance
shouldAdd
Test class: extra_TestNG
0 extra_TestNG@2ec2a43e

================================================ FILE: listings/chap17/test-output/Command line suite/Command line test.xml ================================================ ================================================ FILE: listings/chap17/test-output/emailable-report.html ================================================ TestNG Report
Test# Passed# Skipped# FailedTime (ms)Included GroupsExcluded Groups
Command line suite
Command line test1002
ClassMethodStartTime (ms)
Command line suite
Command line test — passed
extra_TestNGshouldAdd14334129910561

Command line test

extra_TestNG#shouldAdd

back to summary

================================================ FILE: listings/chap17/test-output/index.html ================================================ TestNG reports
Test results
1 suite
extra_TestNG
shouldAdd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Command line suite">
  <test name="Command line test" preserve-order="false">
    <classes>
      <class name="extra_TestNG"/>
    </classes>
  </test> <!-- Command line test -->
</suite> <!-- Command line suite -->
            
Tests for Command line suite
  • Command line test (1 class)
Groups for Command line suite
Times for Command line suite
Total running time: 1 ms
Reporter output for Command line suite
0 ignored methods
Methods in chronological order
extra_TestNG
shouldAdd 0 ms
================================================ FILE: listings/chap17/test-output/junitreports/TEST-extra_ParameterizedTestNG.xml ================================================ ================================================ FILE: listings/chap17/test-output/junitreports/TEST-extra_TestNG.xml ================================================ ================================================ FILE: listings/chap17/test-output/old/Command line suite/Command line test.properties ================================================ [SuiteResult context=Command line test] ================================================ FILE: listings/chap17/test-output/old/Command line suite/classes.html ================================================
Class name Method name Groups
extra_TestNG   
@Test
  shouldAdd  
@BeforeClass
@BeforeMethod
@AfterMethod
@AfterClass
================================================ FILE: listings/chap17/test-output/old/Command line suite/groups.html ================================================

Groups used for this test run

================================================ FILE: listings/chap17/test-output/old/Command line suite/index.html ================================================ Results for Command line suite ================================================ FILE: listings/chap17/test-output/old/Command line suite/main.html ================================================ Results for Command line suite Select a result on the left-hand pane. ================================================ FILE: listings/chap17/test-output/old/Command line suite/methods-alphabetical.html ================================================

Methods run, sorted chronologically

>> means before, << means after


Command line suite

(Hover the method name to see the test class name)

TimeDelta (ms)Suite
configuration
Test
configuration
Class
configuration
Groups
configuration
Method
configuration
Test
method
ThreadInstances
15/06/04 12:16:31 0      shouldAdd main@1098448570
================================================ FILE: listings/chap17/test-output/old/Command line suite/methods-not-run.html ================================================

Methods that were not run

================================================ FILE: listings/chap17/test-output/old/Command line suite/methods.html ================================================

Methods run, sorted chronologically

>> means before, << means after


Command line suite

(Hover the method name to see the test class name)

TimeDelta (ms)Suite
configuration
Test
configuration
Class
configuration
Groups
configuration
Method
configuration
Test
method
ThreadInstances
15/06/04 12:16:31 0      shouldAdd main@1098448570
================================================ FILE: listings/chap17/test-output/old/Command line suite/reporter-output.html ================================================

Reporter output

================================================ FILE: listings/chap17/test-output/old/Command line suite/testng.xml.html ================================================ testng.xml for Command line suite<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Command line suite">
  <test name="Command line test" preserve-order="false">
    <classes>
      <class name="extra_TestNG"/>
    </classes>
  </test> <!-- Command line test -->
</suite> <!-- Command line suite -->
================================================ FILE: listings/chap17/test-output/old/Command line suite/toc.html ================================================ Results for Command line suite

Results for
Command line suite

1 test 1 class 1 method:
  chronological
  alphabetical
  not run (0)
0 group reporter output testng.xml

Command line test (1/0/0) Results
================================================ FILE: listings/chap17/test-output/old/index.html ================================================ Test results

Test results

SuitePassedFailedSkippedtestng.xml
Total100 
Command line suite 100Link
================================================ FILE: listings/chap17/test-output/testng-reports.css ================================================ body { margin: 0px 0px 5px 5px; } ul { margin: 0px; } li { list-style-type: none; } a { text-decoration: none; } a:hover { text-decoration: underline; } .navigator-selected { background: #ffa500; } .wrapper { position: absolute; top: 60px; bottom: 0; left: 400px; right: 0; overflow: auto; } .navigator-root { position: absolute; top: 60px; bottom: 0; left: 0; width: 400px; overflow-y: auto; } .suite { margin: 0px 10px 10px 0px; background-color: #fff8dc; } .suite-name { padding-left: 10px; font-size: 25px; font-family: Times; } .main-panel-header { padding: 5px; background-color: #9FB4D9; //afeeee; font-family: monospace; font-size: 18px; } .main-panel-content { padding: 5px; margin-bottom: 10px; background-color: #DEE8FC; //d0ffff; } .rounded-window { border-radius: 10px; border-style: solid; border-width: 1px; } .rounded-window-top { border-top-right-radius: 10px 10px; border-top-left-radius: 10px 10px; border-style: solid; border-width: 1px; overflow: auto; } .light-rounded-window-top { border-top-right-radius: 10px 10px; border-top-left-radius: 10px 10px; } .rounded-window-bottom { border-style: solid; border-width: 0px 1px 1px 1px; border-bottom-right-radius: 10px 10px; border-bottom-left-radius: 10px 10px; overflow: auto; } .method-name { font-size: 12px; font-family: monospace; } .method-content { border-style: solid; border-width: 0px 0px 1px 0px; margin-bottom: 10; padding-bottom: 5px; width: 80%; } .parameters { font-size: 14px; font-family: monospace; } .stack-trace { white-space: pre; font-family: monospace; font-size: 12px; font-weight: bold; margin-top: 0px; margin-left: 20px; } .testng-xml { font-family: monospace; } .method-list-content { margin-left: 10px; } .navigator-suite-content { margin-left: 10px; font: 12px 'Lucida Grande'; } .suite-section-title { margin-top: 10px; width: 80%; border-style: solid; border-width: 1px 0px 0px 0px; font-family: Times; font-size: 18px; font-weight: bold; } .suite-section-content { list-style-image: url(bullet_point.png); } .top-banner-root { position: absolute; top: 0; height: 45px; left: 0; right: 0; padding: 5px; margin: 0px 0px 5px 0px; background-color: #0066ff; font-family: Times; color: #fff; text-align: center; } .top-banner-title-font { font-size: 25px; } .test-name { font-family: 'Lucida Grande'; font-size: 16px; } .suite-icon { padding: 5px; float: right; height: 20; } .test-group { font: 20px 'Lucida Grande'; margin: 5px 5px 10px 5px; border-width: 0px 0px 1px 0px; border-style: solid; padding: 5px; } .test-group-name { font-weight: bold; } .method-in-group { font-size: 16px; margin-left: 80px; } table.google-visualization-table-table { width: 100%; } .reporter-method-name { font-size: 14px; font-family: monospace; } .reporter-method-output-div { padding: 5px; margin: 0px 0px 5px 20px; font-size: 12px; font-family: monospace; border-width: 0px 0px 0px 1px; border-style: solid; } .ignored-class-div { font-size: 14px; font-family: monospace; } .ignored-methods-div { padding: 5px; margin: 0px 0px 5px 20px; font-size: 12px; font-family: monospace; border-width: 0px 0px 0px 1px; border-style: solid; } .border-failed { border-top-left-radius: 10px 10px; border-bottom-left-radius: 10px 10px; border-style: solid; border-width: 0px 0px 0px 10px; border-color: #f00; } .border-skipped { border-top-left-radius: 10px 10px; border-bottom-left-radius: 10px 10px; border-style: solid; border-width: 0px 0px 0px 10px; border-color: #edc600; } .border-passed { border-top-left-radius: 10px 10px; border-bottom-left-radius: 10px 10px; border-style: solid; border-width: 0px 0px 0px 10px; border-color: #19f52d; } .times-div { text-align: center; padding: 5px; } .suite-total-time { font: 16px 'Lucida Grande'; } .configuration-suite { margin-left: 20px; } .configuration-test { margin-left: 40px; } .configuration-class { margin-left: 60px; } .configuration-method { margin-left: 80px; } .test-method { margin-left: 100px; } .chronological-class { background-color: #0ccff; border-style: solid; border-width: 0px 0px 1px 1px; } .method-start { float: right; } .chronological-class-name { padding: 0px 0px 0px 5px; color: #008; } .after, .before, .test-method { font-family: monospace; font-size: 14px; } .navigator-suite-header { font-size: 22px; margin: 0px 10px 5px 0px; background-color: #deb887; text-align: center; } .collapse-all-icon { padding: 5px; float: right; } ================================================ FILE: listings/chap17/test-output/testng-reports.js ================================================ $(document).ready(function() { $('a.navigator-link').click(function() { // Extract the panel for this link var panel = getPanelName($(this)); // Mark this link as currently selected $('.navigator-link').parent().removeClass('navigator-selected'); $(this).parent().addClass('navigator-selected'); showPanel(panel); }); installMethodHandlers('failed'); installMethodHandlers('skipped'); installMethodHandlers('passed', true); // hide passed methods by default $('a.method').click(function() { showMethod($(this)); return false; }); // Hide all the panels and display the first one (do this last // to make sure the click() will invoke the listeners) $('.panel').hide(); $('.navigator-link').first().click(); // Collapse/expand the suites $('a.collapse-all-link').click(function() { var contents = $('.navigator-suite-content'); if (contents.css('display') == 'none') { contents.show(); } else { contents.hide(); } }); }); // The handlers that take care of showing/hiding the methods function installMethodHandlers(name, hide) { function getContent(t) { return $('.method-list-content.' + name + "." + t.attr('panel-name')); } function getHideLink(t, name) { var s = 'a.hide-methods.' + name + "." + t.attr('panel-name'); return $(s); } function getShowLink(t, name) { return $('a.show-methods.' + name + "." + t.attr('panel-name')); } function getMethodPanelClassSel(element, name) { var panelName = getPanelName(element); var sel = '.' + panelName + "-class-" + name; return $(sel); } $('a.hide-methods.' + name).click(function() { var w = getContent($(this)); w.hide(); getHideLink($(this), name).hide(); getShowLink($(this), name).show(); getMethodPanelClassSel($(this), name).hide(); }); $('a.show-methods.' + name).click(function() { var w = getContent($(this)); w.show(); getHideLink($(this), name).show(); getShowLink($(this), name).hide(); showPanel(getPanelName($(this))); getMethodPanelClassSel($(this), name).show(); }); if (hide) { $('a.hide-methods.' + name).click(); } else { $('a.show-methods.' + name).click(); } } function getHashForMethod(element) { return element.attr('hash-for-method'); } function getPanelName(element) { return element.attr('panel-name'); } function showPanel(panelName) { $('.panel').hide(); var panel = $('.panel[panel-name="' + panelName + '"]'); panel.show(); } function showMethod(element) { var hashTag = getHashForMethod(element); var panelName = getPanelName(element); showPanel(panelName); var current = document.location.href; var base = current.substring(0, current.indexOf('#')) document.location.href = base + '#' + hashTag; var newPosition = $(document).scrollTop() - 65; $(document).scrollTop(newPosition); } function drawTable() { for (var i = 0; i < suiteTableInitFunctions.length; i++) { window[suiteTableInitFunctions[i]](); } for (var k in window.suiteTableData) { var v = window.suiteTableData[k]; var div = v.tableDiv; var data = v.tableData var table = new google.visualization.Table(document.getElementById(div)); table.draw(data, { showRowNumber : false }); } } ================================================ FILE: listings/chap17/test-output/testng-results.xml ================================================ ================================================ FILE: listings/chap17/test-output/testng.css ================================================ .invocation-failed, .test-failed { background-color: #DD0000; } .invocation-percent, .test-percent { background-color: #006600; } .invocation-passed, .test-passed { background-color: #00AA00; } .invocation-skipped, .test-skipped { background-color: #CCCC00; } .main-page { font-size: x-large; } ================================================ FILE: listings/chap18/Listing_18_01_ConcurrentSquares.groovy ================================================ import static groovyx.gpars.GParsPool.withPool def numbers = [1, 2, 3, 4, 5, 6] def squares = [1, 4, 9, 16, 25, 36] withPool { assert squares == numbers.collectParallel { it * it } } ================================================ FILE: listings/chap18/Listing_18_02_ConcurrentSquaresTransparent.groovy ================================================ import static groovyx.gpars.GParsPool.withPool def numbers = [1, 2, 3, 4, 5, 6] def squares = [1, 4, 9, 16, 25, 36] withPool { assertSquares(numbers.makeConcurrent(), squares) } def assertSquares(numbers, squares) { assert squares == numbers.collect { it * it } } ================================================ FILE: listings/chap18/Listing_18_03_ConcurrentSquaresTransitive.groovy ================================================ import static groovyx.gpars.GParsPool.withPool withPool { def numbers = [1, 2, 3, 4, 5, 6].makeConcurrent() def squares = [1, 4, 9] assert squares == numbers.collect{ it * it }.grep{ it < 10 } } ================================================ FILE: listings/chap18/Listing_18_04_MapFilterReduce.groovy ================================================ import static groovyx.gpars.GParsPool.withPool withPool { assert 55 == [0, 1, 2, 3, 4].parallel .map { it + 1 } .map { it ** 2 } .reduce { a, b -> a + b } } ================================================ FILE: listings/chap18/Listing_18_05_SquaresMapReduce.groovy ================================================ import static groovyx.gpars.GParsPool.withPool withPool { def numbers = [1, 2, 3, 4, 5, 6] assert [1, 4, 9] == numbers.parallel .map { it * it } .filter { it < 10 } .collection } ================================================ FILE: listings/chap18/Listing_18_06_Dataflow.groovy ================================================ import groovyx.gpars.dataflow.Dataflows import static groovyx.gpars.dataflow.Dataflow.task final flow = new Dataflows() task { flow.result = flow.x + flow.y } //#1 task { flow.x = 10 } //|#2 task { flow.y = 5 } //|#2 assert 15 == flow.result //#3 //#1 Assign derived value //#2 Assign value //#3 Read value ================================================ FILE: listings/chap18/Listing_18_07_DataflowStreams.groovy ================================================ import static groovyx.gpars.dataflow.Dataflow.* import groovyx.gpars.dataflow.DataflowQueue def chances = new DataflowQueue() def amounts = new DataflowQueue() def payouts = new DataflowQueue() operator( inputs: [chances, amounts], outputs:[payouts], { chance, amount -> payouts << chance * amount } ) task { [0.1, 0.2, 0.3].each { chances << it } } task { [300, 200, 100].each { amounts << it } } [30, 40, 30].each { assert it == payouts.val } ================================================ FILE: listings/chap18/Listing_18_08_Actors.groovy ================================================ import static groovyx.gpars.actor.Actors.* def decrypt = reactor { code -> code.reverse() } //#1 def audit = reactor { println it } //#2 def main = actor { //#3 decrypt 'terces pot' //#4 react { plainText -> //#5 audit plainText //#6 } } main.join() audit.stop() audit.join() //#1 reactor factory method //#2 reactor factory method //#3 actor factory method //#4 send message //#5 wait for reply //#6 send message ================================================ FILE: listings/chap18/Listing_18_09_ActorsLifecycle.groovy ================================================ import static groovyx.gpars.actor.Actors.* def stopper = reactor { stop() } stopper.metaClass.afterStop = { inbox -> println inbox } stopper.send() ================================================ FILE: listings/chap18/Listing_18_10_ActorsMessageAware.groovy ================================================ import static groovyx.gpars.actor.Actors.* def manual = reactor { message -> switch (message) { //#1 case Number: reply 'number'; break case String: reply 'string'; break } } def auto = messageHandler { when { String message -> reply 'string' } //#2 when { Number message -> reply 'number' } } //#1 Self-made dispatch //#2 Groovy method dispatch ================================================ FILE: listings/chap18/Listing_18_11_Agent.groovy ================================================ import groovyx.gpars.agent.Agent def guard = new Agent() guard { updateValue 'GPars' } guard { updateValue(it + ' is groovy!') } assert "GPars is groovy!" == guard.val ================================================ FILE: listings/chap18/Listing_18_12.txt ================================================ see: YahooService.groovy ================================================ FILE: listings/chap18/Listing_18_13_YahooForkJoin.groovy ================================================ import static groovyx.gpars.GParsPool.withPool import static YahooService.getYearEndClosing def tickers = ['AAPL', 'GOOG', 'IBM', 'ORCL', 'MSFT'] withPool(tickers.size()) { def top = tickers.makeConcurrent() .collect { [ticker: it, price: getYearEndClosing(it, 2014)] } .max { it.price } assert top == [ticker: 'GOOG', price: 526.4024f] } ================================================ FILE: listings/chap18/Listing_18_14_YahooMapReduce.groovy ================================================ import static groovyx.gpars.GParsPool.withPool import static YahooService.getYearEndClosing def ticker = ['AAPL', 'GOOG', 'IBM', 'ORCL', 'MSFT'] withPool(ticker.size()) { def top = ticker.parallel .map { [ticker: it, price: getYearEndClosing(it, 2014)] } .max { it.price } assert top == [ticker: 'GOOG', price: 526.4024f] } ================================================ FILE: listings/chap18/Listing_18_15_YahooDataflow.groovy ================================================ import groovyx.gpars.dataflow.Dataflows import static YahooService.getYearEndClosing import static groovyx.gpars.dataflow.Dataflow.task def tickers = ['AAPL', 'GOOG', 'IBM', 'ORCL', 'MSFT'] def price = new Dataflows() tickers.each { ticker -> task { price[ticker] = getYearEndClosing(ticker, 2014) } //#A } def top = tickers.max { price[it] } //#B assert top == 'GOOG' && price[top] == 526.4024f //#A Set when available //#B Read sequentially ================================================ FILE: listings/chap18/YahooService.groovy ================================================ class YahooService { static getYearEndClosingUnsafe(String ticker, int year) { def url = "http://real-chart.finance.yahoo.com/table.csv?" + "s=$ticker&a=11&b=1&c=$year&d=11&e=31&f=$year&g=d&ignore=.csv" def data = url.toURL().text return data.split("\n")[1].split(",")[4].toFloat() } static getYearEndClosing(String ticker, int year) { try { getYearEndClosingUnsafe(ticker, year) } catch (all) { println "Could not get $ticker, returning -1. $all" return -1 } } } ================================================ FILE: listings/chap18/snippet1801_startThread.groovy ================================================ def thread = Thread.start { println "I'm in a new thread" } thread.join() ================================================ FILE: listings/chap18/snippet1803_java_parallel_streams_jdk8_only.groovy ================================================ // Groovy with Java 8 def numbers = [1, 2, 3, 4, 5, 6] assert [1, 4, 9] == numbers.parallelStream() .map { it * it } .filter { it < 10 } .collect() ================================================ FILE: listings/chap18/snippet1804_deadlock.groovy ================================================ import groovyx.gpars.dataflow.Dataflows import static groovyx.gpars.dataflow.Dataflow.task final flow = new Dataflows() task { flow.x = flow.y } task { flow.y = flow.x } ================================================ FILE: listings/chap18/snippet1804_nondeterministic.groovy ================================================ import groovyx.gpars.dataflow.Dataflows import static groovyx.gpars.dataflow.Dataflow.task final flow = new Dataflows() task { flow.list = [0] } task { flow.list[0] = 1 } println flow.list ================================================ FILE: listings/chap19/FetchOptions.groovy ================================================ final class FetchOptions { //#2 private int limit, offset, chunkSize, prefetchSize private FetchOptions() {} //#3 FetchOptions limit(int lim) { this.limit = lim return this //#1 } FetchOptions offset(int offs) { this.offset = offs return this } FetchOptions chunkSize(int cs) { this.chunkSize = cs return this } FetchOptions prefetchSize(int ps) { this.prefetchSize = ps return this } static final class Builder { //#5 private Builder() {} //#6 static FetchOptions withDefaults() { //#4 new FetchOptions() //#4 } static FetchOptions withLimit(int lim) { //#7 new FetchOptions().limit(lim) } static FetchOptions withOffset(int offs) { new FetchOptions().offset(offs) } static FetchOptions withChunkSize(int cs) { new FetchOptions().chunkSize(cs) } static FetchOptions withPrefetchSize(int ps) { new FetchOptions().prefetchSize(ps) } } } //#1 Enable chaining //#2 Non-extensible class //#3 Private constructor //#4 Default factory method //#5 Non-extensible class //#6 Private constructor //#7 One of several specialized factory methods ================================================ FILE: listings/chap19/FetchOptionsBuilder.groovy ================================================ class FetchOptionsBuilder { static FetchOptions fetchOptions(Closure c) { def opts = FetchOptions.Builder.withDefaults() opts.with c return opts } } ================================================ FILE: listings/chap19/Listing_19_06_Binding.groovy ================================================ def binding = new Binding(distance: 11400, time: 5 * 60) //#1 def shell = new GroovyShell(binding) //#2 shell.evaluate ''' speed = distance / time //#3 ''' assert binding.distance == 11400 //#4 assert binding.time == 5 * 60 //#4 assert binding.speed == 38 //#5 //#1 Create and populate binding //#2 Pass binding to GroovyShell //#3 Calculation only involving binding variables //#4 Input variables unchanged //#5 Result also in binding ================================================ FILE: listings/chap19/Listing_19_29_OrderDSL.groovy ================================================ def of = "silent word" //#1 def buy(n) { [shares: { of -> //#2 [:].withDefault { ticker -> //#3 println "buy $n shares of $ticker" } }] } buy 200 shares of GOOG //#1 Define silent word //#2 Unused parameter //#3 Map with Closure defining behavior for unknown keys ================================================ FILE: listings/chap19/Listing_19_30_WhenIfControlStructure.groovy ================================================ def when(boolean condition, Closure block) { if (condition) block() } def a = 1 def b = 2 when(a < b, { println "a < b" }) //#1 when (a < b) { println "a < b" } //#1 Closure is the last parameter ================================================ FILE: listings/chap19/Listing_19_31_Until_failing_.groovy ================================================ def until(boolean condition, Closure closure) { while (!condition) closure() } def counter = 0 until(counter == 10) { //#1 counter++ } //#1 Eagerly calculated expression ================================================ FILE: listings/chap19/Listing_19_32_UntilControlStructure.groovy ================================================ def until(Closure condition, Closure closure) { while (!condition()) closure() //#1 } def counter = 0 until({ counter == 10 }) { //#2 counter++ } assert counter == 10 //#1 Evaluating closure for each iteration //#2 Passing a closure as first parameter ================================================ FILE: listings/chap19/Listing_19_39_GivenWhenThen.groovy ================================================ def given(Closure g) { def valueHolder = [:] g.delegate = valueHolder g.resolveStrategy = Closure.DELEGATE_FIRST g() [when: { Closure w -> w.delegate = valueHolder w.resolveStrategy = Closure.DELEGATE_FIRST w() [then: { Closure t -> t.delegate = valueHolder t.resolveStrategy = Closure.DELEGATE_FIRST t() }] }] } given { a = 1 b = 2 } when { result = a + b } then { assert result == 3 } ================================================ FILE: listings/chap19/Listing_19_43_FetchOptionsScript.groovy ================================================ import static FetchOptionsBuilder.fetchOptions fetchOptions { limit 10 offset 60 chunkSize 1000 } ================================================ FILE: listings/chap19/Listing_19_44_RubyStyleNewify.groovy ================================================ import groovy.transform.ToString @ToString class Car { String make String model } @Newify def car = Car.new(make: 'Porsche', model: '911') assert car.toString() == 'Car(Porsche, 911)' ================================================ FILE: listings/chap19/Listing_19_45_PythonStyleNewify.groovy ================================================ import groovy.transform.Canonical @Canonical class Country { String name } @Canonical class City { String name String zipCode Country country } @Newify([City, Country]) def paris = City('Paris', '75000', Country('France')) assert paris.toString() == 'City(Paris, 75000, Country(France))' ================================================ FILE: listings/chap19/Listing_19_46_Terms.groovy ================================================ import groovy.transform.* interface Term {} @Canonical class Value implements Term { def content } @Canonical class Add implements Term { def left, right } @Canonical class Mult implements Term { def left, right } def term = new Mult(new Value('a'), new Add(new Value('b'), new Value('c'))) @Newify([Value, Mult, Add]) def term2 = Mult(Value('a'), Add(Value('b'), Value('c'))) import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer def config = new CompilerConfiguration() config.addCompilationCustomizers( new ASTTransformationCustomizer( //#1 value: [Value, Mult, Add], Newify) //#1 ) def shell = new GroovyShell( this.class.classLoader, new Binding(), config) //#2 def term3 = shell.evaluate ''' Mult( //#3 Value('a'), //#3 Add( //#3 Value('b'), //#3 Value('c') //#3 ) //#3 ) //#3 ''' assert term3.toString() == 'Mult(Value(a), Add(Value(b), Value(c)))' //#1 Pass annotation and parameters to customizer //#2 Pass config to GroovyShell //#3 Implicit Newify ================================================ FILE: listings/chap19/Listing_19_47_NewifyInjected.txt ================================================ see second half of: Listing_19_46_Terms.groovy ================================================ FILE: listings/chap19/Listing_19_48_No_IO.groovy ================================================ import org.codehaus.groovy.control.* import org.codehaus.groovy.control.customizers.* def secure = new SecureASTCustomizer() secure.starImportsBlacklist = ['java.io.*'] //#1 secure.indirectImportCheckEnabled = true //#2 def config = new CompilerConfiguration() config.addCompilationCustomizers(secure) def shell = new GroovyShell(config) groovy.test.GroovyAssert.shouldFail { shell.evaluate ''' //#3 new File('.') //#3 ''' //#3 } //#1 Disallow java.io imports //#2 Disallow explicit java.io class references //#3 Evaluate violating script ================================================ FILE: listings/chap19/Listing_19_49_ArithmeticShell.groovy ================================================ import org.codehaus.groovy.ast.expr.* import org.codehaus.groovy.ast.stmt.* import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.ImportCustomizer import org.codehaus.groovy.control.customizers.SecureASTCustomizer import static org.codehaus.groovy.syntax.Types.* def imports = new ImportCustomizer().addStaticStars('java.lang.Math') def secure = new SecureASTCustomizer() secure.with { closuresAllowed = false //#1 methodDefinitionAllowed = false //#2 importsWhitelist = [] //#3 staticImportsWhitelist = [] //#3 staticStarImportsWhitelist = ['java.lang.Math'] //#3 tokensWhitelist = [ //#4 PLUS, MINUS, MULTIPLY, DIVIDE, MOD, POWER, PLUS_PLUS, MINUS_MINUS, COMPARE_EQUAL, COMPARE_NOT_EQUAL, COMPARE_LESS_THAN, COMPARE_LESS_THAN_EQUAL, COMPARE_GREATER_THAN, COMPARE_GREATER_THAN_EQUAL, ] constantTypesClassesWhiteList = [ //#5 Integer, Float, Long, Double, BigDecimal, Integer.TYPE, Long.TYPE, Float.TYPE, Double.TYPE ] receiversClassesWhiteList = [ //#6 Math, Integer, Float, Double, Long, BigDecimal ] statementsWhitelist = [ //#7 BlockStatement, ExpressionStatement ] expressionsWhitelist = [ //#8 BinaryExpression, ConstantExpression, MethodCallExpression, StaticMethodCallExpression, ArgumentListExpression, PropertyExpression, UnaryMinusExpression, UnaryPlusExpression, PrefixExpression, PostfixExpression, TernaryExpression, ElvisOperatorExpression, BooleanExpression, ClassExpression ] } def config = new CompilerConfiguration() config.addCompilationCustomizers(imports, secure) def shell = new GroovyShell(config) def result = shell.evaluate('1+cos(PI/2)') //#9 assert result == 1 //#1 Disable closures //#2 Disable methods //#3 Disable imports and static imports except lava.lang.Math //#4 Allow mathematical tokens //#5 Allow number types //#6 Allow number receivers //#7 Allow only blocks and statements //#8 Allow only math-related expressions //#9 Run the shell ================================================ FILE: listings/chap19/Listing_19_50_TimedInterrupt.groovy ================================================ import groovy.transform.* import org.codehaus.groovy.control.* import org.codehaus.groovy.control.customizers.* import java.util.concurrent.TimeoutException import static groovy.test.GroovyAssert.shouldFail def config = new CompilerConfiguration() //#2 config.addCompilationCustomizers( //#2 new ASTTransformationCustomizer(value: 2, TimedInterrupt) //#2 ) def shell = new GroovyShell(config) def te = shouldFail(TimeoutException) { shell.evaluate ''' for (i in 1..1000) { //#1 sleep 1000 //#1 } ''' } println te.message //#1 Create lengthy loop //#2 Add 2 second timeout to our script ================================================ FILE: listings/chap19/Listing_19_51_SystemExitGuard.groovy ================================================ import org.codehaus.groovy.ast.* import org.codehaus.groovy.ast.expr.* import org.codehaus.groovy.control.* import org.codehaus.groovy.control.customizers.* import org.codehaus.groovy.classgen.* import org.codehaus.groovy.syntax.* import static groovy.test.GroovyAssert.shouldFail import static org.codehaus.groovy.control.CompilePhase.* def config = new CompilerConfiguration() def filter = new CompilationCustomizer(CANONICALIZATION) { //#1 void call(SourceUnit src, GeneratorContext ctxt, ClassNode cn) { //#2 new ClassCodeVisitorSupport() { //#3 void visitMethodCallExpression(MethodCallExpression call) { //#4 if (call.objectExpression.text == 'java.lang.System' && //#5 call.method.text == 'exit') { //#5 src.addError(new SyntaxException( //#6 'System.exit() forbidden', //#6 call.lineNumber, call.columnNumber)) //#6 } super.visitMethodCallExpression(call) } SourceUnit getSourceUnit() { src } }.visitClass(cn) } } config.addCompilationCustomizers(filter) def shell = new GroovyShell(config) def ce = shouldFail(CompilationFailedException) { shell.parse ''' System.exit(0) ''' } println ce.message //#1 Extend CompilationCustomizer //#2 Override call method //#3 Define visitor //#4 Override method call visits //#5 Detect System.exit //#6 Flag error ================================================ FILE: listings/chap19/Listing_19_53_QueryCustomizer.groovy ================================================ import org.codehaus.groovy.ast.ClassCodeVisitorSupport import org.codehaus.groovy.ast.ClassNode import org.codehaus.groovy.ast.expr.MethodCallExpression import org.codehaus.groovy.ast.expr.StaticMethodCallExpression import org.codehaus.groovy.classgen.GeneratorContext import org.codehaus.groovy.control.SourceUnit import org.codehaus.groovy.control.customizers.CompilationCustomizer import org.codehaus.groovy.syntax.SyntaxException import static org.codehaus.groovy.control.CompilePhase.* new CompilationCustomizer(SEMANTIC_ANALYSIS) { void call(SourceUnit src, GeneratorContext ctxt, ClassNode cn) { new ClassCodeVisitorSupport() { boolean inQueryClosure = false void visitStaticMethodCallExpression( //#1 StaticMethodCallExpression call) { //#1 if (call.method == 'query' && call.ownerType.name == 'Query') //#1 inQueryClosure = true super.visitStaticMethodCallExpression(call) if (inQueryClosure) inQueryClosure = false } void visitMethodCallExpression(MethodCallExpression call) { def methName = call.method.text if ( inQueryClosure && //#2 call.objectExpression.text == 'this' && //#2 !(methName in ['select', 'from', 'where'])) { //#2 src.addError(new SyntaxException( //#3 "No query verb ${methName}, only select/from/where", //#3 call.lineNumber, call.columnNumber)) //#3 } super.visitMethodCallExpression(call) } SourceUnit getSourceUnit() { src } }.visitClass(cn) } } Query.query { select all from table where true } //#1 Track when inside Query.query //#2 Check method calls are to known methods //#3 Add error if unknown methods found ================================================ FILE: listings/chap19/Listings.txt ================================================ Listing number and folder name (or file name if not standard form of Listing_19_XX_YY.groovy) 19_01: v01/ 19_02: v02/model/Direction.groovy 19_03: v02/model/Robot.groovy 19_04: v02/ 19_05: v02/ 19_06: / 19_07: v02/ 19_08: v02/ 19_09: v02/ 19_10: v02/ 19_11: v02/integration/RobotBaseScript.groovy 19_12: v02/ 19_13: v02/ 19_14: v02/ 19_15: v03/integration/RobotBaseScript.groovy 19_16: v02/ 19_17: v02/integration/CaseRobotBaseScript.groovy 19_18: v02/integration/CustomBinding.groovy 19_19: v02/ 19_20: v03/model/Unit.groovy 19_21: v03/model/Distance.groovy 19_22: v03/integration/DistanceCategory.groovy 19_23: v03/integration/DistanceCategory.groovy (yes, it is the same) 19_24: v03/model/Speed.groovy 19_25: v03/model/Duration.groovy 19_26: v03/model/Distance.groovy (yes, again) 19_27: v03/Listing_19_27_SimpleCommandChain.groovy 19_28: v03/Listing_19_27_SimpleCommandChain.groovy (again) 19_29: / 19_30: / 19_31: / 19_32: / 19_33: xform/CustomControlStructure.groovy 19_34: xform/WhenUntilTransform_Structure.groovy 19_35: xform/BusinessLogicScript.groovy 19_36: xform/ 19_37: xform/WhenUtilTransform.groovy (just visit method) 19_38: xform/WhenUtilTransform.groovy (same file: full) 19_39: / 19_40: v03/ 19_41: FetchOptions.groovy 19_42: FetchOptionsBuilder.groovy 19_43: / 19_44: / 19_45: / 19_46: Listing_19_46_Terms.groovy (part 1) 19_47: Listing_19_46_Terms.groovy (part 2) 19_48: / 19_49: / 19_50: / 19_51: / 19_52: Query.groovy 19_53: / ================================================ FILE: listings/chap19/Query.groovy ================================================ class Query { static query(Closure c) { //#1 def q = c.clone() //#2 q.resolveStrategy = Closure.DELEGATE_FIRST //#2 q.delegate = new Query() //#2 q() //#2 } def getProperty(String name) { name } //#3 Query select(column) { this } //#4 Query from(table) { this } //#4 Query where(condition) { this } //#4 } //#1 DSL entry point //#2 Define delegate and resolution strategy //#3 Trivial implementation of property resolution //#4 Enable method chaining ================================================ FILE: listings/chap19/extra_FetchOptions_traditional.groovy ================================================ def options = FetchOptions.Builder.withLimit(10).offset(60).chunkSize(1000) println options ================================================ FILE: listings/chap19/v01/Listing_19_01_SelfContainedScript.groovy ================================================ package v01 import static Direction.* //#2 enum Direction { //#1 left, right, forward, backward //#1 } //#1 class Robot { //#3 void move(Direction dir) { //#4 println "robot moved $dir" //#4 } //#4 } def robot = new Robot() //#5 robot.move left //#6 //#1 The enum definition //#2 Make constants available in script //#3 Define class //#4 Method definition //#5 Create instance //#6 Instruct robot to move ================================================ FILE: listings/chap19/v02/Listing_19_04_MainSimple.groovy ================================================ package v02 import v02.model.Robot //#A import static v02.model.Direction.* //#B def robot = new Robot() robot.move left //#A Import Robot class from model package //#B Use static import for directions ================================================ FILE: listings/chap19/v02/Listing_19_05_MainGroovyShell.groovy ================================================ package v02 def shell = new GroovyShell() //#1 shell.evaluate ''' //#2 import v02.model.Robot //#2 import static v02.model.Direction.* //#2 //#2 def robot = new Robot() //#2 //#2 robot.move left //#2 ''' //#2 //#1 Instantiates the shell //#2 Shell evaluates inline script ================================================ FILE: listings/chap19/v02/Listing_19_07_MainBinding.groovy ================================================ package v02 import v02.model.Robot def binding = new Binding(robot: new Robot()) //#1 def shell = new GroovyShell(this.class.classLoader, binding) //#2 shell.evaluate ''' import static v02.model.Direction.* robot.move left ''' //#1 Create binding using named params or map //#2 Binding passed to GroovyShell constructor ================================================ FILE: listings/chap19/v02/Listing_19_08_MainDirectionConstants.groovy ================================================ package v02 import v02.model.* def binding = new Binding( robot: new Robot(), left: Direction.left, //#1 right: Direction.right, //#1 forward: Direction.forward, //#1 backward: Direction.backward //#1 ) def shell = new GroovyShell(this.class.classLoader, binding) shell.evaluate ''' robot.move left //#2 ''' //#1 Inject directions //#2 Import free script ================================================ FILE: listings/chap19/v02/Listing_19_09_MainDirectionsSpread.groovy ================================================ package v02 import v02.model.* def binding = new Binding( robot: new Robot(), *: Direction.values().collectEntries { [(it.name()): it] } //#1 ) def shell = new GroovyShell(this.class.classLoader, binding) shell.evaluate ''' robot.move left ''' //#1 Inject directions using spread-map operator ================================================ FILE: listings/chap19/v02/Listing_19_10_MainImplicitMethod.groovy ================================================ package v02 import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.* import v02.model.Robot def binding = new Binding(robot: new Robot()) def importCustomizer = new ImportCustomizer() importCustomizer.addStaticStars 'v02.model.Direction' def config = new CompilerConfiguration() config.addCompilationCustomizers importCustomizer def shell = new GroovyShell(this.class.classLoader, binding, config) shell.evaluate ''' move left ''' + ''' def move(dir) { robot.move dir } ''' ================================================ FILE: listings/chap19/v02/Listing_19_12_MainBaseScript.groovy ================================================ package v02 import v02.model.* def binding = new Binding( robot: new Robot(), *: Direction.values().collectEntries { [(it.name()): it] } ) def shell = new GroovyShell(this.class.classLoader, binding) shell.evaluate ''' @BaseScript(v02.integration.RobotBaseScript) import groovy.transform.BaseScript move left ''' ================================================ FILE: listings/chap19/v02/Listing_19_13_MainImportCustomizer.groovy ================================================ package v02 import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.* import v02.model.Robot def binding = new Binding(robot: new Robot()) //#1 def importCustomizer = new ImportCustomizer() //#2 importCustomizer.addStaticStars 'v02.model.Direction' //#3 def config = new CompilerConfiguration() config.addCompilationCustomizers importCustomizer //#4 def shell = new GroovyShell(this.class.classLoader, binding, config) //#5 shell.evaluate ''' robot.move left ''' //#1 Inject only variables into binding //#2 Create import customizer //#3 Direction.* enum values statically imported with star import //#4 Import customizer added to compiler configuration //#5 Compiler configuration passed to GroovyShell ================================================ FILE: listings/chap19/v02/Listing_19_14_MainCustomBaseScriptClass.groovy ================================================ package v02 import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.* import v02.integration.RobotBaseScript import v02.model.* def binding = new Binding(robot: new Robot()) def importCustomizer = new ImportCustomizer() importCustomizer.addStaticStars Direction.name def config = new CompilerConfiguration() config.addCompilationCustomizers importCustomizer config.scriptBaseClass = RobotBaseScript.name //#A def shell = new GroovyShell(this.class.classLoader, binding, config) shell.evaluate ''' move left ''' //#A Specify script base class ================================================ FILE: listings/chap19/v02/Listing_19_16_MainMethodClosure.groovy ================================================ package v02 import v02.model.* def robot = new Robot() def binding = new Binding( robot: robot, move: robot.&move, //#1 *: Direction.values().collectEntries { [(it.name()): it] } ) def shell = new GroovyShell(this.class.classLoader, binding) shell.evaluate ''' move left ''' //#1 Method closure reference to robot’s move() method ================================================ FILE: listings/chap19/v02/Listing_19_19_MainLowerCase.groovy ================================================ package v02 import org.codehaus.groovy.control.* import v02.integration.* import v02.model.* def binding = new CustomBinding(robot: new Robot()) def config = new CompilerConfiguration() config.scriptBaseClass = CaseRobotBaseScript.name //#A def shell = new GroovyShell(this.class.classLoader, binding, config) shell.evaluate ''' mOVe lEfT ''' //#A Specify script base class ================================================ FILE: listings/chap19/v02/integration/CaseRobotBaseScript.groovy ================================================ package v02.integration abstract class CaseRobotBaseScript extends RobotBaseScript { def invokeMethod(String name, args) { //#1 getBinding().robot."${name.toLowerCase()}"(*args) //#2 } } //#1 Intercept method invocation //#2 Mixed-case script calls become lowercase robot calls ================================================ FILE: listings/chap19/v02/integration/CustomBinding.groovy ================================================ package v02.integration import v02.model.Direction class CustomBinding extends Binding { private Map variables CustomBinding(Map vars) { this.variables = [ *: vars, //#1 *: Direction.values().collectEntries { [(it.name()): it] } //#1 ] } def getVariable(String name) { variables[name.toLowerCase()] //#2 } } //#1 Merge constructor variables and Direction constants //#2 Variable lookup via lowercase key ================================================ FILE: listings/chap19/v02/integration/RobotBaseScript.groovy ================================================ package v02.integration import v02.model.Direction abstract class RobotBaseScript extends Script { void move(Direction dir) { this.binding.robot.move dir } } ================================================ FILE: listings/chap19/v02/model/Direction.groovy ================================================ package v02.model enum Direction { left, right, forward, backward } ================================================ FILE: listings/chap19/v02/model/Robot.groovy ================================================ package v02.model class Robot { void move(Direction dir) { println "robot moved $dir" } } ================================================ FILE: listings/chap19/v02/snippet1901_MainFileRunner.groovy ================================================ package v02 import v02.model.Robot def shell = new GroovyShell(this.class.classLoader) // assumes script is run from parent directory shell.evaluate 'v02/CommandScript.groovy' as File // assumes script is on the classpath def script = Robot.getResource("/v02/CommandScript.groovy") shell.evaluate new File(script.toURI()) ================================================ FILE: listings/chap19/v03/Listing_19_27_SimpleCommandChain.groovy ================================================ package v03 import v03.model.* import v03.integration.* import static v03.model.Direction.right // listing 19.27 def move(Direction dir) { [by: { Distance dist -> [at: { Speed speed -> println "robot moved $dir by $dist at $speed" }] }] } // end use(DistanceCategory) { def h = Duration.hour // listing 19.28 def map1 = move(right) def byClosure = map1['by'] def map2 = byClosure(3.meters) def atClosure = map2['at'] atClosure(5.km / h) // end move right by 3.meters at 5.km/h } ================================================ FILE: listings/chap19/v03/Listing_19_40_Robot_With.groovy ================================================ package v03 import v03.model.Robot import static v03.model.Direction.* def robot = new Robot() robot.with { //#1 move left //#2 move forward //#2 } //#1 Demarcate block where robot will be delegate //#2 Streamlined syntax available within block ================================================ FILE: listings/chap19/v03/integration/DistanceCategory.groovy ================================================ package v03.integration import v03.model.* class DistanceCategory { static Distance getCentimeters(Number num) { new Distance(num, Unit.centimeter) } static Distance getMeters(Number num) { new Distance(num, Unit.meter) } static Distance getKilometers(Number num) { new Distance(num, Unit.kilometer) } static Distance getCm(Number num) { getCentimeters(num) } static Distance getM(Number num) { getMeters(num) } static Distance getKm(Number num) { getKilometers(num) } } ================================================ FILE: listings/chap19/v03/integration/RobotBaseScript.groovy ================================================ package v03.integration import v03.model.Robot abstract class RobotBaseScript extends Script { // In some older version of Groovy there was a bug where @Lazy // and @Delegate didn't work together. If you have troubles, // comment out the existing line and replace with next line: // @Delegate Robot robot = new Robot() @Delegate @Lazy Robot robot = this.binding.robot } ================================================ FILE: listings/chap19/v03/integration/SuperBotBaseScript.groovy ================================================ package v03.integration import v03.model.SuperBot abstract class SuperBotBaseScript extends Script { // In some older version of Groovy there was a bug where @Lazy // and @Delegate didn't work together. If you have troubles, // comment out the existing line and replace with next line: // @Delegate SuperBot robot = new SuperBot() @Delegate @Lazy SuperBot robot = this.binding.robot } ================================================ FILE: listings/chap19/v03/model/Direction.groovy ================================================ package v03.model enum Direction { left, right, forward, backward } ================================================ FILE: listings/chap19/v03/model/Distance.groovy ================================================ package v03.model import groovy.transform.TupleConstructor @TupleConstructor class Distance { Number amount Unit unit Speed div(Duration dur) { new Speed(amount, unit) } String toString() { "$amount$unit" } } ================================================ FILE: listings/chap19/v03/model/Duration.groovy ================================================ package v03.model enum Duration { hour } ================================================ FILE: listings/chap19/v03/model/Robot.groovy ================================================ package v03.model class Robot { def move(Direction dir) { println "robot moved $dir" } def move(Direction dir, Distance d) { println "robot moved $dir by $d" } def move(Map m, Direction dir) { println "robot moved $dir by $m.by at ${m.at ?: '1 km/h'}" } } ================================================ FILE: listings/chap19/v03/model/Speed.groovy ================================================ package v03.model import groovy.transform.TupleConstructor @TupleConstructor class Speed { Number amount Unit unit String toString() { "$amount $unit/h" } } ================================================ FILE: listings/chap19/v03/model/SuperBot.groovy ================================================ package v03.model class SuperBot extends Robot { def move(Direction dir) { [by: { Distance dist -> [at: { Speed s -> println "robot moved $dir by $dist at $s" }] }] } def deploy(Direction dir) { [arm: { -> println "deploy $dir arm" }()] } } ================================================ FILE: listings/chap19/v03/model/Unit.groovy ================================================ package v03.model enum Unit { centimeter('cm', 0.01), meter ( 'm', 1), kilometer ('km', 1000) String abbreviation double multiplier Unit(String abbr, double mult) { this.abbreviation = abbr this.multiplier = mult } String toString() { abbreviation } } ================================================ FILE: listings/chap19/xform/BusinessLogicScript.groovy ================================================ package xform abstract class BusinessLogicScript extends Script { def when(boolean condition, Closure closure) { if (condition) closure() } } ================================================ FILE: listings/chap19/xform/CustomControlStructure.groovy ================================================ package xform import java.lang.annotation.* import org.codehaus.groovy.transform.* @Retention(RetentionPolicy.SOURCE) //#1 @Target(ElementType.TYPE) //#2 @GroovyASTTransformationClass(classes = [WhenUntilTransform]) //#3 @interface CustomControlStructure {} //#1 Annotation thrown away before runtime //#2 Class annotation //#3 Reference to transform implementation class ================================================ FILE: listings/chap19/xform/Listing_19_36_WhenTransformation.groovy ================================================ package xform import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer def binding = new Binding([customer: [name: 'John Doe', age: 32]]) //#1 def config = new CompilerConfiguration() //#2 config.scriptBaseClass = BusinessLogicScript.class.name //#3 config.addCompilationCustomizers( //#4 new ASTTransformationCustomizer(CustomControlStructure)) //#4 def shell = new GroovyShell(this.class.classLoader, binding, config) //#5 def result = shell.evaluate ''' //#6 when (customer.age >= 21) { //#6 "Alcohol allowed for ${customer.name}" //#6 } //#6 ''' //#6 assert result == "Alcohol allowed for John Doe" //#7 //#1 Populate binding with customer //#2 Config instance //#3 Define base script //#4 Inject transform annotation //#5 Create configured shell //#6 Evaluate script //#7 Confirm result ================================================ FILE: listings/chap19/xform/WhenUntilTransform.groovy ================================================ package xform import org.codehaus.groovy.ast.* import org.codehaus.groovy.ast.expr.* import org.codehaus.groovy.ast.stmt.* import org.codehaus.groovy.control.* import org.codehaus.groovy.transform.* @GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS) class WhenUntilTransform implements ASTTransformation { void visit(ASTNode[] nodes, SourceUnit unit) { ClassNode annotatedClass = nodes[1] new ClassCodeVisitorSupport() { def currentMethod def currentBlock def currentStatement void visitMethod(MethodNode method) { currentMethod = method super.visitMethod(method) } void visitBlockStatement(BlockStatement block) { currentBlock = block super.visitBlockStatement(block) } void visitExpressionStatement(ExpressionStatement statement) { currentStatement = statement super.visitExpressionStatement(statement) } void visitMethodCallExpression(MethodCallExpression mCall) { if ( mCall.objectExpression instanceof VariableExpression && mCall.objectExpression.variable == 'this' && mCall.method instanceof ConstantExpression && mCall.method.value == 'when' && mCall.arguments.expressions.size() == 1 ) { def idx = currentBlock.statements.findIndexOf { it == currentStatement } if (idx + 1 >= currentBlock.statements.size()) { addError( "The when instruction has no body.", mCall) } else { def whenCode = currentBlock.statements[idx + 1] def closureExp = new ClosureExpression( Parameter.EMPTY_ARRAY, whenCode) closureExp.variableScope = new VariableScope() closureExp.variableScope.parent = currentBlock.variableScope mCall.arguments.addExpression(closureExp) currentBlock.statements.remove(idx + 1) } } super.visitMethodCallExpression(mCall) } protected SourceUnit getSourceUnit() { unit } }.visitClass(annotatedClass) } } ================================================ FILE: listings/chap19/xform/extra_WhenTransformationWorksWithoutBraces.groovy ================================================ package xform import org.codehaus.groovy.control.CompilerConfiguration import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer def binding = new Binding([customer: [name: 'John Doe', age: 32]]) //#1 def config = new CompilerConfiguration() //#2 config.scriptBaseClass = BusinessLogicScript.class.name //#3 config.addCompilationCustomizers( //#4 new ASTTransformationCustomizer(CustomControlStructure)) //#4 def shell = new GroovyShell(this.class.classLoader, binding, config) //#5 def result = shell.evaluate ''' when (customer.age >= 21) "Alcohol allowed for ${customer.name}" ''' //#6 assert result == "Alcohol allowed for John Doe" //#7 ================================================ FILE: listings/chap19/xform/snippet1906_WhenUntilXform_Structure.groovy ================================================ package xform // checks that our skeleton contains no typos new GroovyShell().parse ''' import org.codehaus.groovy.ast.* import org.codehaus.groovy.control.* import org.codehaus.groovy.transform.* @GroovyASTTransformation(phase = CompilePhase.SEMANTIC_ANALYSIS) class WhenUntilTransform implements ASTTransformation { void visit(ASTNode[] nodes, SourceUnit unit) { // we’ll fill in the gaps! } } ''' ================================================ FILE: listings/chap20/Listing_20_01_Grapes_for_twitter_urls.groovy ================================================ @Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='1.2') import org.ccil.cowan.tagsoup.Parser def parser = new XmlParser(new Parser()) def html = parser.parse("http://manning.com/koenig2") def twitterUrls = html.body.'**'.a.@href.grep(~/.*twitter.*/) println twitterUrls.join("\n") assert 'http://www.twitter.com/mittie' in twitterUrls ================================================ FILE: listings/chap20/Listing_20_02_Scriptom_Windows_only.groovy ================================================ //@Grab('org.codehaus.groovy.modules.scriptom:scriptom:1.6.0') //@GrabExclude("org.codehaus.groovy:groovy") import org.codehaus.groovy.scriptom.ActiveXObject def explorer = new ActiveXObject('InternetExplorer.Application') explorer.Visible = true explorer.AddressBar = true explorer.Navigate('http://www.groovy-lang.org/') ================================================ FILE: listings/chap20/Listing_20_03_ActivX_Windows_only.groovy ================================================ //@Grab('org.codehaus.groovy.modules.scriptom:scriptom:1.6.0') //@GrabExclude("org.codehaus.groovy:groovy") import org.codehaus.groovy.scriptom.ActiveXObject def PARENT = 0 def OPTS = 0 def sh = new ActiveXObject('Shell.Application') def folder = sh.BrowseForFolder(PARENT, 'Choose a folder', OPTS) println "Chosen folder: ${folder.Items().Item().Path.value}" ================================================ FILE: listings/chap20/Listing_20_10_SquaringMapValue.groovy ================================================ def squareMapValues = { map -> if (map == null) { return null } if (!map) { return [] } return map.values().collect { it * it } } assert [1, 4, 9] == squareMapValues([a: 1, b: 2, c: 3]) ================================================ FILE: listings/chap20/Listing_20_11_Synchronized.groovy ================================================ class Person { List addresses @groovy.transform.Synchronized void setAddresses(List addresses) { this.addresses.clear() this.addresses.addAll(addresses) } } assert new Person() ================================================ FILE: listings/chap20/Listing_20_12_DbC_invariants.groovy ================================================ @Grab('org.gcontracts:gcontracts-core:1.2.12') import org.gcontracts.annotations.* @Invariant({ waterVolume >= 0; waterVolume <= maxVolume }) class Kettle { int waterVolume = 0 int maxVolume = 1000 // listing 20.13: @Requires({ amount > 0 }) @Ensures({ waterVolume == maxVolume || waterVolume > old.waterVolume }) void addWater(int amount) { waterVolume = Math.min(maxVolume, amount + waterVolume) } // listing 20.14 @Requires({ desiredAmount > 0 }) @Ensures({ result >= 0; result == 0 ? waterVolume == old.waterVolume : waterVolume < old.waterVolume }) int pour(int desiredAmount) { int amountPoured = (desiredAmount <= waterVolume ? desiredAmount : waterVolume) waterVolume = waterVolume - amountPoured amountPoured } } def kettle = new Kettle() kettle.addWater(600) kettle.addWater(600) assert kettle.waterVolume == kettle.maxVolume ================================================ FILE: test.groovy ================================================ import groovy.io.FileType def failed = [] def excludes = [ '_failing_', // any script that is meant to fail 'snippet1901_MainFileRunner.groovy', // requires a src file on classpath 'Listing_10_46_RobotExtension.groovy', // TC extension not standalone 'Listing_10_47_SQLExtension.groovy', // TC extension not standalone 'Listing_12_16_GroovletExample.groovy', // starts a servlet engine 'Listing_12_17_HelloWorldGroovlet.groovy', // groovlet; not standalone script 'Listing_12_19_InspectGroovlet.groovy', // groovlet; not standalone script 'Listing_12_20_HiLowGame.groovy', // groovlet; not standalone script 'Listing_12_22_TemplateGroovlet.groovy', // groovlet; not standalone script 'Listing_13_25_AthleteAppMain.groovy', // meant to run from commandline 'Listing_13_27_MongoAthletes.groovy', // requires mongodb to be installed 'Listing_15_10_XMLRPC_jira.groovy', // requires codehaus JIRA credentials 'extra_NeoGremlinGraph.groovy', // Grab seems a little fragile and only extra example ] def ver = System.getProperty('java.version')[0..2].toBigDecimal() def os = System.getProperty("os.name").toLowerCase() if (os.contains('windows')) { excludes += [ 'Listing_12_13_Processes_UnixCommands.groovy', // runs 'ls' etc. 'Listing_12_14_Processes_ZipUnzip.groovy', // needs gzip/gunzip ] } //excludes += ['snippet13_googleIpAdr.groovy'] // uncomment if no Internet new File('.').traverse(type: FileType.FILES, nameFilter: ~/Listing_.*groovy|snippet.*groovy|extra_.*groovy/) { file -> if (excludes.any { file =~ it }) return if (file.name.contains('Windows_only') && !os.contains('windows')) return if (ver != 1.8 && file.name.contains('_jdk8_only')) return if (ver != 1.7 && file.name.contains('_jdk7_only')) return if (ver != 1.6 && file.name.contains('_jdk6_only')) return if (ver < 1.8 && file.name.contains('_jdk8_plus')) return if (ver < 1.7 && file.name.contains('_jdk7_plus')) return println "evaluating $file" try { new GroovyShell().run(file) println "OK" } catch (Throwable t) { failed << file println "FAILED " + t.message } } failed.each { print "\nFAILED: " + it }