Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DARIAH-DE Aggregator Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DARIAH-DE
DARIAH-DE Aggregator Services
Commits
c986f892
Commit
c986f892
authored
11 years ago
by
Thorsten Vitt
Browse files
Options
Downloads
Patches
Plain Diff
Allow integration-testing access to protected resources
parent
6245caa1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TESTING.md
+48
-0
48 additions, 0 deletions
TESTING.md
pom.xml
+42
-0
42 additions, 0 deletions
pom.xml
src/test/java/info/textgrid/services/aggregator/html/HtmlAT.java
+23
-0
23 additions, 0 deletions
...t/java/info/textgrid/services/aggregator/html/HtmlAT.java
with
113 additions
and
0 deletions
TESTING.md
0 → 100644
+
48
−
0
View file @
c986f892
% Testing the Aggregator
% Thorsten Vitt
%
Automatic Tests
===============
Unit Tests
----------
Unit tests are run against individual classes in the source directory.
The complete service will
*not*
be set up.
Test classes are placed under
`src/test`
and named
`*Test.java`
. Tests will be
run using the surefire plugin when you run maven to any of the interesting
phases and can be skipped by passing the
`-DskipTests`
parameter.
Integration Tests
-----------------
Integration tests are tests against a fully setup service. A local
tomcat running the service will be set up, and the tests will be run in
a separate application. The system property
`service.url`
will contain
the root URL of the aggregator service to run.
Integration tests are executed using the failsafe plugin by running
`mvn
verify`
. The tests live in files called
`*IT.java`
under
`src/test`
.
Integration Tests with Authentication
-------------------------------------
These tests work like normal integration tests, but additionally they are
passed a session ID that is required to access non-public TextGrid resources in
the
`sid`
system property.
Implementors call the files containing the tests
`*AT.java`
(for
*a*
uthenticated
*t*
ests) and place them under
`src/test`
. To test,
1.
[
Get a session ID
](
https://textgridlab.org/1.0/WebAuthN/WebAuthN2.php?authZinstance=textgrid-ws3.sub.uni-goettingen.de
)
for the user
*tgtest*
2.
run maven using
`mvn -Dsid=<session ID> verify`
Interactive Testing
===================
You can run a local copy of the service using
`mvn tomcat:run-war`
. The
service will then be available at
<http://localhost:13000/aggregator>
for you to test interactively.
This diff is collapsed.
Click to expand it.
pom.xml
+
42
−
0
View file @
c986f892
...
...
@@ -436,6 +436,48 @@
<aggregator.endpoint.published>
https://textgridlab.org/1.0/aggregator
</aggregator.endpoint.published>
</properties>
</profile>
<profile>
<id>
authtests
</id>
<activation>
<property>
<name>
sid
</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-failsafe-plugin
</artifactId>
<version>
2.8.1
</version>
<executions>
<execution>
<id>
integration-test
</id>
<goals>
<goal>
integration-test
</goal>
</goals>
<configuration>
<includes>
<includes>
**/*IT.java
</includes>
<includes>
**/*AT.java
</includes>
</includes>
<systemPropertyVariables>
<service.url>
http://localhost:${test.server.port}/aggregator
</service.url>
<sid>
${sid}
</sid>
</systemPropertyVariables>
</configuration>
</execution>
<execution>
<id>
verify
</id>
<goals>
<goal>
verify
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<organization>
<name>
TextGrid
</name>
...
...
This diff is collapsed.
Click to expand it.
src/test/java/info/textgrid/services/aggregator/html/HtmlAT.java
0 → 100644
+
23
−
0
View file @
c986f892
package
info.textgrid.services.aggregator.html
;
import
info.textgrid.services.aggregator.AbstractIntegrationTest
;
import
java.io.IOException
;
import
java.net.HttpURLConnection
;
import
java.net.MalformedURLException
;
import
org.junit.Assert
;
import
org.junit.Test
;
public
class
HtmlAT
extends
AbstractIntegrationTest
{
@Test
public
void
testSimpleGet
()
throws
MalformedURLException
,
IOException
{
final
HttpURLConnection
connection
=
createRequest
(
"/html/textgrid:1zzbt.0?sid="
+
System
.
getProperty
(
"sid"
));
connection
.
connect
();
Assert
.
assertEquals
(
200
,
connection
.
getResponseCode
());
Assert
.
assertEquals
(
"text/xml"
,
connection
.
getContentType
());
Assert
.
assertTrue
(
"Content length > 0"
,
readContents
(
connection
)
>
0
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment