Clean up code to conform to basic checkstyle

Issue gh-3746
This commit is contained in:
Rob Winch
2016-03-13 12:14:32 -05:00
parent 5775f7bd80
commit f221920a19
1245 changed files with 13198 additions and 3394 deletions

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms;
import java.util.ArrayList;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms;
import javax.sql.DataSource;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms;
/**

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms;
/**

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms;
import java.sql.ResultSet;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms;
import org.springframework.util.Assert;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms.secured;
import javax.sql.DataSource;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms.secured;
import sample.dms.DocumentDao;

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample.dms.secured;
import java.sql.ResultSet;

View File

@@ -1,40 +0,0 @@
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
/**
* Basic integration test for DMS sample when security has been added.
*
* @author Ben Alex
*
*/
@ContextConfiguration(locations = { "classpath:applicationContext-dms-shared.xml",
"classpath:applicationContext-dms-secure.xml" })
public class SecureDmsIntegrationTests extends DmsIntegrationTests {
@Test
public void testBasePopulation() {
assertThat(jdbcTemplate.queryForObject("select count(id) from DIRECTORY", Integer.class)).isEqualTo(9);
assertThat(jdbcTemplate.queryForObject("select count(id) from FILE", Integer.class)).isEqualTo(90);
assertThat(jdbcTemplate.queryForObject("select count(id) from ACL_SID", Integer.class)).isEqualTo(4); // 3 users + 1 role
assertThat(jdbcTemplate.queryForObject("select count(id) from ACL_CLASS", Integer.class)).isEqualTo(2); // Directory
// and
// File
assertThat(jdbcTemplate.queryForObject("select count(id) from ACL_OBJECT_IDENTITY", Integer.class))
.isEqualTo(100);
assertThat(jdbcTemplate.queryForObject("select count(id) from ACL_ENTRY", Integer.class)).isEqualTo(115);
}
public void testMarissaRetrieval() {
process("rod", "koala", true);
}
public void testScottRetrieval() {
process("scott", "wombat", true);
}
public void testDianneRetrieval() {
process("dianne", "emu", true);
}
}

View File

@@ -1,7 +1,42 @@
import static org.assertj.core.api.Assertions.*;
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample;
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.After;
import org.junit.Test;
import sample.dms.AbstractElement;
import sample.dms.Directory;
import sample.dms.DocumentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -9,9 +44,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import sample.dms.AbstractElement;
import sample.dms.Directory;
import sample.dms.DocumentDao;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Basic integration test for DMS sample.
@@ -40,9 +73,12 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
@Test
public void testBasePopulation() {
assertThat(jdbcTemplate.queryForObject("select count(id) from DIRECTORY", Integer.class)).isEqualTo(9);
assertThat((int) jdbcTemplate.queryForObject("select count(id) from FILE", Integer.class)).isEqualTo(90);
assertThat(documentDao.findElements(Directory.ROOT_DIRECTORY).length).isEqualTo(3);
assertThat(this.jdbcTemplate.queryForObject("select count(id) from DIRECTORY",
Integer.class)).isEqualTo(9);
assertThat((int) this.jdbcTemplate.queryForObject("select count(id) from FILE",
Integer.class)).isEqualTo(90);
assertThat(this.documentDao.findElements(Directory.ROOT_DIRECTORY).length)
.isEqualTo(3);
}
@Test
@@ -64,7 +100,7 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
SecurityContextHolder.getContext().setAuthentication(
new UsernamePasswordAuthenticationToken(username, password));
System.out.println("------ Test for username: " + username + " ------");
AbstractElement[] rootElements = documentDao
AbstractElement[] rootElements = this.documentDao
.findElements(Directory.ROOT_DIRECTORY);
assertThat(rootElements.length).isEqualTo(3);
Directory homeDir = null;
@@ -80,17 +116,19 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
System.out.println("Home directory......: " + homeDir.getFullName());
System.out.println("Non-home directory..: " + nonHomeDir.getFullName());
AbstractElement[] homeElements = documentDao.findElements(homeDir);
assertThat(homeElements.length).isEqualTo(12); // confidential and shared directories,
// plus 10 files
AbstractElement[] homeElements = this.documentDao.findElements(homeDir);
assertThat(homeElements.length).isEqualTo(12); // confidential and shared
// directories,
// plus 10 files
AbstractElement[] nonHomeElements = documentDao.findElements(nonHomeDir);
assertThat(nonHomeElements.length).isEqualTo(shouldBeFiltered ? 11 : 12); // cannot see
// the user's
// "confidential"
// sub-directory
// when
// filtering
AbstractElement[] nonHomeElements = this.documentDao.findElements(nonHomeDir);
assertThat(nonHomeElements.length).isEqualTo(shouldBeFiltered ? 11 : 12); // cannot
// see
// the user's
// "confidential"
// sub-directory
// when
// filtering
// Attempt to read the other user's confidential directory from the returned
// results
@@ -104,15 +142,19 @@ public class DmsIntegrationTests extends AbstractTransactionalJUnit4SpringContex
}
if (shouldBeFiltered) {
assertThat(nonHomeConfidentialDir).withFailMessage("Found confidential directory when we should not have").isNull();
assertThat(nonHomeConfidentialDir)
.withFailMessage(
"Found confidential directory when we should not have")
.isNull();
}
else {
System.out.println("Inaccessible dir....: "
+ nonHomeConfidentialDir.getFullName());
assertThat(documentDao.findElements(nonHomeConfidentialDir).length).isEqualTo(10); // 10
// files
// (no
// sub-directories)
System.out.println(
"Inaccessible dir....: " + nonHomeConfidentialDir.getFullName());
assertThat(this.documentDao.findElements(nonHomeConfidentialDir).length)
.isEqualTo(10); // 10
// files
// (no
// sub-directories)
}
SecurityContextHolder.clearContext();

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* 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.
*/
package sample;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Basic integration test for DMS sample when security has been added.
*
* @author Ben Alex
*
*/
@ContextConfiguration(locations = { "classpath:applicationContext-dms-shared.xml",
"classpath:applicationContext-dms-secure.xml" })
public class SecureDmsIntegrationTests extends DmsIntegrationTests {
@Override
@Test
public void testBasePopulation() {
assertThat(this.jdbcTemplate.queryForObject("select count(id) from DIRECTORY",
Integer.class)).isEqualTo(9);
assertThat(this.jdbcTemplate.queryForObject("select count(id) from FILE",
Integer.class)).isEqualTo(90);
assertThat(this.jdbcTemplate.queryForObject("select count(id) from ACL_SID",
Integer.class)).isEqualTo(4); // 3 users + 1 role
assertThat(this.jdbcTemplate.queryForObject("select count(id) from ACL_CLASS",
Integer.class)).isEqualTo(2); // Directory
// and
// File
assertThat(this.jdbcTemplate.queryForObject(
"select count(id) from ACL_OBJECT_IDENTITY", Integer.class))
.isEqualTo(100);
assertThat(this.jdbcTemplate.queryForObject("select count(id) from ACL_ENTRY",
Integer.class)).isEqualTo(115);
}
@Override
public void testMarissaRetrieval() {
process("rod", "koala", true);
}
@Override
public void testScottRetrieval() {
process("scott", "wombat", true);
}
@Override
public void testDianneRetrieval() {
process("dianne", "emu", true);
}
}