Skip to content

Commit

Permalink
Merge pull request #67 from dcrissman/add-info-methods
Browse files Browse the repository at this point in the history
Make use of the new AbstractMongoCRUDTestController
  • Loading branch information
luan-cestari committed Apr 15, 2015
2 parents aa34a68 + 64e0019 commit 403da1d
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 193 deletions.
2 changes: 0 additions & 2 deletions lightblue-ldap-integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,11 @@
<dependency>
<groupId>com.redhat.lightblue.mongo</groupId>
<artifactId>lightblue-mongo-config</artifactId>
<version>1.4.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.redhat.lightblue.mongo</groupId>
<artifactId>lightblue-mongo-test</artifactId>
<version>1.4.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.io.IOException;
import java.util.Arrays;

import org.apache.commons.lang.StringUtils;
Expand All @@ -38,12 +39,10 @@
import com.redhat.lightblue.Response;
import com.redhat.lightblue.crud.FindRequest;
import com.redhat.lightblue.crud.InsertionRequest;
import com.redhat.lightblue.ldap.test.LdapServerExternalResource;
import com.redhat.lightblue.mongo.test.MongoServerExternalResource;
import com.redhat.lightblue.ldap.test.AbstractLdapCRUDController;
import com.redhat.lightblue.test.FakeClientIdentification;
import com.redhat.lightblue.util.test.AbstractJsonNodeTest;
import com.unboundid.ldap.sdk.Attribute;
import java.io.IOException;

/**
* <b>NOTE:</b> This test suite is intended to be run in a certain order. Selectively running unit tests
Expand All @@ -68,15 +67,8 @@ public static void beforeClass() throws Exception {
new Attribute("objectClass", "organizationalUnit"),
new Attribute("ou", "Departments")});

System.setProperty("ldap.host", "localhost");
System.setProperty("ldap.port", String.valueOf(LdapServerExternalResource.DEFAULT_PORT));
System.setProperty("ldap.database", "test");
System.setProperty("ldap.person.basedn", BASEDB_USERS);
System.setProperty("ldap.department.basedn", BASEDB_DEPARTMENTS);

System.setProperty("mongo.host", "localhost");
System.setProperty("mongo.port", String.valueOf(MongoServerExternalResource.DEFAULT_PORT));
System.setProperty("mongo.database", "lightblue");
}

public ITCaseLdapCRUDControllerTest() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@
import com.redhat.lightblue.Response;
import com.redhat.lightblue.crud.FindRequest;
import com.redhat.lightblue.crud.InsertionRequest;
import com.redhat.lightblue.ldap.test.LdapServerExternalResource;
import com.redhat.lightblue.ldap.test.AbstractLdapCRUDController;
import com.redhat.lightblue.metadata.types.DateType;
import com.redhat.lightblue.mongo.test.MongoServerExternalResource;
import com.redhat.lightblue.util.test.AbstractJsonNodeTest;

@RunWith(value = Parameterized.class)
Expand All @@ -59,14 +58,7 @@ public static Collection<Object[]> data() {

@BeforeClass
public static void beforeClass() throws Exception {
System.setProperty("ldap.host", "localhost");
System.setProperty("ldap.port", String.valueOf(LdapServerExternalResource.DEFAULT_PORT));
System.setProperty("ldap.database", "test");
System.setProperty("ldap.datatype.basedn", "dc=example,dc=com");

System.setProperty("mongo.host", "localhost");
System.setProperty("mongo.port", String.valueOf(MongoServerExternalResource.DEFAULT_PORT));
System.setProperty("mongo.database", "lightblue");
}

private final String cn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import org.junit.rules.ExpectedException;

import com.fasterxml.jackson.databind.JsonNode;
import com.redhat.lightblue.ldap.test.LdapServerExternalResource;
import com.redhat.lightblue.ldap.test.AbstractLdapCRUDController;
import com.redhat.lightblue.metadata.EntityMetadata;
import com.redhat.lightblue.metadata.Metadata;
import com.redhat.lightblue.mongo.test.MongoServerExternalResource;
import com.redhat.lightblue.util.test.AbstractJsonNodeTest;
import com.unboundid.ldap.sdk.Attribute;

Expand All @@ -47,14 +46,7 @@ public static void beforeClass() throws Exception {
new Attribute("objectClass", "organizationalUnit"),
new Attribute("ou", "Users")});

System.setProperty("ldap.host", "localhost");
System.setProperty("ldap.port", String.valueOf(LdapServerExternalResource.DEFAULT_PORT));
System.setProperty("ldap.database", "test");
System.setProperty("ldap.person.basedn", BASEDB_USERS);

System.setProperty("mongo.host", "localhost");
System.setProperty("mongo.port", String.valueOf(MongoServerExternalResource.DEFAULT_PORT));
System.setProperty("mongo.database", "lightblue");
}

public ITCaseLdapCRUDController_InvalidMetadata_Test() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
import com.redhat.lightblue.Response;
import com.redhat.lightblue.crud.FindRequest;
import com.redhat.lightblue.crud.InsertionRequest;
import com.redhat.lightblue.ldap.test.LdapServerExternalResource;
import com.redhat.lightblue.mongo.test.MongoServerExternalResource;
import com.redhat.lightblue.ldap.test.AbstractLdapCRUDController;
import com.unboundid.ldap.sdk.Attribute;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
Expand All @@ -50,14 +49,7 @@ public static void beforeClass() throws Exception {
new Attribute("objectClass", "organizationalUnit"),
new Attribute("ou", "Users")});

System.setProperty("ldap.host", "localhost");
System.setProperty("ldap.port", String.valueOf(LdapServerExternalResource.DEFAULT_PORT));
System.setProperty("ldap.database", "test");
System.setProperty("ldap.personWithAddress.basedn", BASEDB_USERS);

System.setProperty("mongo.host", "localhost");
System.setProperty("mongo.port", String.valueOf(MongoServerExternalResource.DEFAULT_PORT));
System.setProperty("mongo.database", "lightblue");
}

public ITCaseLdapCRUDController_Objects_Test() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
import com.redhat.lightblue.Response;
import com.redhat.lightblue.crud.FindRequest;
import com.redhat.lightblue.crud.InsertionRequest;
import com.redhat.lightblue.ldap.test.LdapServerExternalResource;
import com.redhat.lightblue.mongo.test.MongoServerExternalResource;
import com.redhat.lightblue.ldap.test.AbstractLdapCRUDController;
import com.unboundid.ldap.sdk.Attribute;

/**
Expand All @@ -55,14 +54,7 @@ public static void beforeClass() throws Exception {
new Attribute("objectClass", "organizationalUnit"),
new Attribute("ou", "Customers")});

System.setProperty("ldap.host", "localhost");
System.setProperty("ldap.port", String.valueOf(LdapServerExternalResource.DEFAULT_PORT));
System.setProperty("ldap.database", "test");
System.setProperty("ldap.customer.basedn", BASEDB_CUSTOMERS);

System.setProperty("mongo.host", "localhost");
System.setProperty("mongo.port", String.valueOf(MongoServerExternalResource.DEFAULT_PORT));
System.setProperty("mongo.database", "lightblue");
}

public ITCaseLdapCRUDController_WithProperties_Test() throws Exception {
Expand Down Expand Up @@ -111,7 +103,7 @@ public void test2FindCustomerWithProperties() throws Exception {
+ "\"cn\":\"Frodo Baggins\","
+ "\"interfaces#\":4,"
+ "\"interfaces\":[\"top\",\"person\",\"organizationalPerson\",\"inetOrgPerson\"]}]",
entityData.toString(), true);
entityData.toString(), true);
}

}
11 changes: 11 additions & 0 deletions lightblue-ldap-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,16 @@
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.redhat.lightblue</groupId>
<artifactId>lightblue-core-test</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.redhat.lightblue.mongo</groupId>
<artifactId>lightblue-mongo-test</artifactId>
<scope>compile</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright 2015 Red Hat, Inc. and/or its affiliates.
This file is part of lightblue.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.redhat.lightblue.ldap.test;

import static com.redhat.lightblue.util.JsonUtils.json;

import java.io.IOException;

import org.junit.BeforeClass;
import org.junit.ClassRule;

import com.fasterxml.jackson.databind.JsonNode;
import com.redhat.lightblue.ldap.test.LdapServerExternalResource.InMemoryLdapServer;
import com.redhat.lightblue.mongo.test.AbstractMongoCRUDTestController;

@InMemoryLdapServer
public abstract class AbstractLdapCRUDController extends AbstractMongoCRUDTestController {

@ClassRule
public static LdapServerExternalResource ldapServer = LdapServerExternalResource.createDefaultInstance();

@BeforeClass
public static void prepareLdapDatasources() {
if (System.getProperty("ldap.datasource") == null) {
System.setProperty("ldap.datasource", "myldapdatasource");
}
if (System.getProperty("ldap.host") == null) {
System.setProperty("ldap.host", "localhost");
}
if (System.getProperty("ldap.port") == null) {
System.setProperty("ldap.port", String.valueOf(ldapServer.getPort()));
}
if (System.getProperty("ldap.database") == null) {
System.setProperty("ldap.database", "test");
}
}

public AbstractLdapCRUDController() throws Exception {
super();
}

@Override
protected JsonNode getLightblueCrudJson() throws Exception {
return json(loadResource("/ldap-lightblue-crud.json", true));
}

@Override
protected JsonNode getLightblueMetadataJson() throws Exception {
return json(loadResource("/ldap-lightblue-metadata.json", true));
}

@Override
protected JsonNode getDatasourcesJson() {
try {
if (getDatasourcesResourceName() == null) {
return json(loadResource("/ldap-datasources.json", true));
} else {
return json(loadResource(getDatasourcesResourceName(), false));
}
} catch (IOException e) {
throw new RuntimeException("Unable to load resource '" + getDatasourcesResourceName() + "'", e);
}
}

}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 403da1d

Please sign in to comment.