Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Created TestSuite to make it easier to run more tests at once.
Browse files Browse the repository at this point in the history
  • Loading branch information
myrle-krantz committed Jul 12, 2017
1 parent 7891ae8 commit 6700e6f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 13 deletions.
15 changes: 2 additions & 13 deletions component-test/src/main/java/AbstractComponentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.mifos.core.lang.security.RsaKeyPairFactory;
import io.mifos.core.test.env.TestEnvironment;
import io.mifos.core.test.fixture.TenantDataStoreContextTestRule;
import io.mifos.core.test.fixture.cassandra.CassandraInitializer;
import io.mifos.core.test.listener.EnableEventRecording;
import io.mifos.core.test.listener.EventRecorder;
import io.mifos.identity.api.v1.PermittableGroupIds;
Expand All @@ -38,8 +37,6 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -60,8 +57,7 @@
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
classes = {AbstractComponentTest.TestConfiguration.class})
@TestPropertySource(properties = {"cassandra.cl.read = LOCAL_QUORUM", "cassandra.cl.write = LOCAL_QUORUM", "cassandra.cl.delete = LOCAL_QUORUM", "identity.token.refresh.secureCookie = false", "identity.passwordExpiresInDays = 93"})
public class AbstractComponentTest {
static final String APP_NAME = "identity-v1";
public class AbstractComponentTest extends SuiteTestEnvironment {
@Configuration
@EnableApiFactory
@EnableEventRecording
Expand All @@ -80,15 +76,8 @@ public TestConfiguration() {
static final String AHMES_PASSWORD = "fractions";
static final String AHMES_FRIENDS_PASSWORD = "sekhem";

final static TestEnvironment testEnvironment = new TestEnvironment(APP_NAME);
final static CassandraInitializer cassandraInitializer = new CassandraInitializer();
private final static TenantDataStoreContextTestRule tenantDataStoreContext = TenantDataStoreContextTestRule.forRandomTenantName(cassandraInitializer);

@ClassRule
public static TestRule orderClassRules = RuleChain
.outerRule(testEnvironment)
.around(cassandraInitializer)
.around(tenantDataStoreContext);
public final static TenantDataStoreContextTestRule tenantDataStoreContext = TenantDataStoreContextTestRule.forRandomTenantName(cassandraInitializer);

//Not using this as a rule because initialize in identityManager is different.
static final TenantApplicationSecurityEnvironmentTestRule tenantApplicationSecurityEnvironment = new TenantApplicationSecurityEnvironmentTestRule(testEnvironment);
Expand Down
36 changes: 36 additions & 0 deletions component-test/src/main/java/SuiteTestEnvironment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2017 The Mifos Initiative.
*
* 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.
*/
import io.mifos.core.test.env.TestEnvironment;
import io.mifos.core.test.fixture.cassandra.CassandraInitializer;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
import org.junit.rules.RunExternalResourceOnce;
import org.junit.rules.TestRule;

/**
* @author Myrle Krantz
*/
public class SuiteTestEnvironment {
static final String APP_NAME = "identity-v1";

final static TestEnvironment testEnvironment = new TestEnvironment(APP_NAME);
final static CassandraInitializer cassandraInitializer = new CassandraInitializer();

@ClassRule
public static TestRule orderClassRules = RuleChain
.outerRule(new RunExternalResourceOnce(testEnvironment))
.around(new RunExternalResourceOnce(cassandraInitializer));
}
40 changes: 40 additions & 0 deletions component-test/src/main/java/TestSuite.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2017 The Mifos Initiative.
*
* 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.
*/


import org.junit.runner.RunWith;
import org.junit.runners.Suite;

/**
* @author Myrle Krantz
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
TestApplications.class,
TestAuthentication.class,
TestKeyRotation.class,
//TestPasswords.class,
TestPermittableGroups.class,
TestProvisioning.class,
//TestRefreshToken.class,
TestRoles.class,
TestUsers.class,
})
public class TestSuite extends SuiteTestEnvironment {
//TODO: Add TestPasswords and TestRefreshToken back in.
// For some reason, they fail in the test suite even though
// they succeed when run individually.
}

0 comments on commit 6700e6f

Please sign in to comment.