Skip to main content
summaryrefslogtreecommitdiffstats
blob: 462d34e60969260c73e59f4782534b49c61eab18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0"?>
<project name="Test OSEE Application Server Launcher" default="run" basedir=".">

	<!--
	${extraVMargs}

   $xserver-db-home
	$xserver-db-name=psql.osee.eclipse.org \
   $xserver-db-username=osee.eclipse \
   $xserver-db-password=osee.eclipse \
   $xserver-db-address=127.0.0.1 \
   $xserver-db-port=1623 \
   
   ${xserver-authentication} 
	${xserver-data}
	${xserver-home}	
	${xserver-port}
	${xserver-telnet-port}
	${xserver-log-config}
	-->

	<target name="init">
		<echo message="extraVMargs: [${extraVMargs}]" />

		<for param="argline" delimiter=" -D" list="${extraVMargs}" trim="true">
			<sequential>
				<propertyregex property="argName" override="true" input="@{argline}" regexp="(.*?)=" select="\1" casesensitive="false" />
				<propertyregex property="argValue" override="true" input="@{argline}" regexp="=(.*)" select="\1" casesensitive="false" />
				<echo message="Found arg - [${argName}]=[${argValue}]" />
				<property name="${argName}" value="${argValue}" />
			</sequential>
		</for>

		<property name="xserver-use-demo-data" value="false" />
		<property name="osee.app.server.config.file" value="${xserver-data}/osee.hsql.test.json" />

		<echo message="Server Config File: [${osee.app.server.config.file}]" />
		<echo message="Server Data Directory:  [${osee.application.server.data}]" />

		<echo message="Osee Application Server Home: [${xserver-home}]" />
		<echo message="Osee Application Server Port: [${xserver-port}]" />
		<echo message="Osee Application Server Telnet Port: [${xserver-telnet-port}]" />
		<echo message="Osee Application Server Db Address: [${xserver-db-address}:${xserver-db-port}]" />

		<mkdir dir="${xserver-data}" />

		<property name="osee.application.server.data" value="${xserver-data}/binary_data" />
		<mkdir dir="${osee.application.server.data}" />

		<!-- copy server data to temp area -->
		<if>
			<equals arg1="${xserver-use-demo-data}" arg2="true" />
			<then>
				<copy todir="${osee.application.server.data}">
					<fileset dir="${xserver-project}/target/server/demo/binary_data" />
				</copy>

				<!-- copy database data to server area -->
				<copy file="${xserver-project}/target/server/demo/hsql/osee.hsql.db.properties" tofile="${xserver-data}/${xserver-db-name}.properties" />
				<copy file="${xserver-project}/target/server/demo/hsql/osee.hsql.db.script" tofile="${xserver-data}/${xserver-db-name}.script" />
			</then>
		</if>
	</target>

	<target name="writeHsqlConnectionFile" depends="init">
		<writeJsonConfig dbaddress="${xserver-db-address}" dbpath="${xserver-db-home}" dbport="${xserver-db-port}" filepath="${osee.app.server.config.file}" />
	</target>

	<target name="run" depends="init,writeHsqlConnectionFile,startServer" />

	<target name="startServer">
		<pathconvert property="launcherJarPath" setonempty="false">
			<path>
				<fileset dir="${xserver-home}/plugins">
					<include name="org.eclipse.equinox.launcher_*.jar" />
				</fileset>
			</path>
		</pathconvert>

		<mkdir dir="${xserver-data}" />

		<forget daemon="false">
			<echo message="Launching Osee Application Server..." />
			<!-- Test Should Complete in 30 mins (timeout vale) - currently, they only take ~13 mins -->
			<java taskname="int-test-server" failonerror="true" maxmemory="1024m" timeout="1800000" jar="${launcherJarPath}" fork="yes">
				<classpath>
					<fileset dir="${xserver-home}/plugins" includes="org.eclipse.equinox.launcher_*.jar" />
					<pathelement location="${xserver-home}/plugins" />
				</classpath>
				<sysproperty key="osee.log.default" value="INFO" />
				<sysproperty key="osee.check.tag.queue.on.startup" value="false" />
				<sysproperty key="osgi.noShutdown" value="true" />
				<sysproperty key="org.osgi.service.http.port" value="${xserver-port}" />
				<sysproperty key="osee.application.server.data" value="${osee.application.server.data}" />
				<sysproperty key="osee.authentication.protocol" value="${xserver-authentication}" />
				<sysproperty key="logback.configurationFile" value="${xserver-log-config}" />
				<sysproperty key="osgi.configuration.area" value="${xserver-project}/configuration" />
				<sysproperty key="cm.config.uri" value="${osee.app.server.config.file}" />

				<jvmarg line="${additionalJvmArgs}" />
				<arg line=" -console ${xserver-telnet-port} -consoleLog -configuration &quot;${xserver-home}/configuration&quot;" />
			</java>
		</forget>

		<sleep seconds="20"/>
		
		<waitfor maxwait="20" maxwaitunit="second" checkevery="1" checkeveryunit="second" >
			<http url="http://127.0.0.1:${xserver-port}/orcs/datastore/info" />
		</waitfor>
	</target>

	<target name="stopServer">
		<!--<echo message="Osee Application Server Telnet Port: [${xserver-telnet-port}]" />
		<telnet server="localhost" port="${xserver-telnet-port}" initialCR="yes" timeout="1000">
			<read>osgi&gt;</read>
			<write>exit</write>
			<read>Really want to stop Equinox? (y/n; default=y)</read>
			<write>y</write>
		</telnet>
		<sleep milliseconds="500" />-->

		<echo message="Osee Application Server Port: [${xserver-port}]" />
		<post to="http://127.0.0.1:${xserver-port}/osee/console?cmd=osee&amp;args=server_shutdown" verbose="true" wantresponse="true" property="shutdownOutput" />
		<echo message="${shutdownOutput}" />
		<sleep milliseconds="10000" />
	</target>

	<macrodef name="writeJsonConfig">
		<attribute name="dbAddress" />
		<attribute name="dbPort" />
		<attribute name="dbPath" />
		<attribute name="filePath" />
		<sequential>
			<propertyregex property="dbFilePath" input="@{dbPath}" override="true" regexp="\\" replace="/" global="true" defaultValue="@{dbPath}" />

			<echo message="Writing Json Configuration" />
			<echo file="@{filePath}">
{
    "config": [
        {
            "service.pid": "org.eclipse.osee.jdbc.internal.osgi.JdbcComponentFactory",
            "jdbc.service": [
                {
                    "service.id": "1001",
                    "jdbc.server.host": "@{dbAddress}",
                    "jdbc.server.port": "@{dbPort}",
                    "jdbc.server.db.data.path": "${dbFilePath}",
                    "jdbc.client.db.username": "public",
                    "jdbc.client.connection.pool.enabled": "true",
                    "jdbc.client.connection.pool.max.active.connections": "100",
                    "jdbc.client.connection.pool.max.idle.connections": "100",
                    "osgi.binding": [
                        "client.jdbc.service",
                        "activity.jdbc.service",
                        "orcs.jdbc.service",
                        "account.jdbc.service",
                        "oauth.jdbc.service",
				            "app.server.jdbc.service",
            				"server.jdbc.service"
                    ]
                }
            ]
        }
    ]
}				
			</echo>
		</sequential>
	</macrodef>

</project>

Back to the top